laymur 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8277 -8139
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +10 -1
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +13 -9
- package/dist/miscellaneous/generic-plane/shared.d.ts +5 -0
- package/dist/miscellaneous/webglCapabilities.d.ts +2 -3
- package/package.json +1 -4
- package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.Internal.d.ts +0 -6
- package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.d.ts +0 -1
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{MathUtils as t,Color as i,Vector4 as s,Texture as e,Vector2 as r,Vector3 as h,Matrix3 as n,Matrix4 as o,PlaneGeometry as a,InstancedBufferGeometry as l,ShaderMaterial as u,InstancedBufferAttribute as c,Mesh as d,Scene as f,OrthographicCamera as v,Quaternion as p,CanvasTexture as w,UVMapping as g,ClampToEdgeWrapping as y,LinearFilter as m,RGBAFormat as b,UnsignedByteType as _,SRGBColorSpace as x,NoColorSpace as S,WebGLRenderTarget as E,PerspectiveCamera as I,Ray as M}from"three";class C{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:0;this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,e):this.t.set(i,new Map([[t,e]])))}insert(t,i,s){let e=arguments.length>2&&void 0!==s?s:0;if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,e)}const r=this.t.get(i);void 0===r?this.t.set(i,new Map([[t,e]])):r.has(t)||r.set(t,e)}remove(t,i){if(void 0===i)return void this.i.delete(t);const s=this.t.get(i);void 0!==s&&(s.delete(t),0===s.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const s=this.t.get(i);return void 0!==s&&s.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const s=this.t.get(i);return void 0!==s?s.get(t):void 0}}class T{constructor(){this.o=new Map}on(t,i,s,e){return this.h(t,!1,arguments.length>3&&void 0!==e?e:0,i,s),this}once(t,i,s,e){return this.h(t,!0,arguments.length>3&&void 0!==e?e:0,i,s),this}off(t,i,s){const e=this.o.get(t);if(void 0===e)return this;e.u&&(e.u=!1,e.v=e.v.slice());const r=e.v;if(0===r.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;r.length>t;t++){const i=r[t];e.l.remove(i._,i.p)}return this}{const h=r.length;if(r[0]._===i&&r[0].p===s)return 1===h?this.o.delete(t):r.shift(),this;const n=h-1;if(r[n]._===i&&r[n].p===s)return r.pop(),this;if(10>h||r[0].M===r[n].M)for(let t=1;n>t;t++){const e=r[t];if(e._===i&&e.p===s)return r.splice(t,1),this}else{const t=e.l.getPriority(i,s);if(void 0===t)return this;let h=0,n=r.length-1;for(;n>=h;){const i=h+n>>>1;t>r[i].M?h=i+1:n=i-1}const o=h;for(n=r.length-1;n>=h;){const i=h+n>>>1;r[i].M>t?n=i-1:h=i+1}const a=n;for(let t=o;a>=t;t++)if(r[t]._===i&&r[t].p===s)return r.splice(t,1),this}}return this}emit(t){const i=this.o.get(t);if(void 0===i)return!1;if(0===i.v.length)return!1;i.u?i.v=i.v.slice():i.u=!0;const s=i.v;let e=!1;for(var r=arguments.length,h=Array(r>1?r-1:0),n=1;r>n;n++)h[n-1]=arguments[n];for(let t=0;s.length>t;t++){const i=s[t];i._.apply(i.p,h),i.k&&(e=!0,i.m=!0)}const o=this.o.get(t);if(void 0===o)return!0;o.v===s&&(o.u=!1);const a=o.v;if(e){let i=0;for(let t=0;a.length>t;t++){const s=a[t];s.m?o.l.remove(s._,s.p):a[i++]=s}0===i?this.o.delete(t):a.length=i}return!0}h(t,i,s,e,r){let h=this.o.get(t);if(void 0===h)return void this.o.set(t,{v:[{_:e,p:r,M:s,k:i,m:!1}],u:!1,l:new C(e,r,s)});if(h.l.has(e,r))throw Error("Event listener already exists");h.l.insert(e,r,s);const n={_:e,p:r,M:s,k:i,m:!1};h.u&&(h.u=!1,h.v=h.v.slice());{const t=h.v,i=n.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(n);if(t[0].M>=i)return void t.unshift(n);{let s=0,e=t.length;for(;e>s;){const r=s+e>>>1;i>t[r].M?s=r+1:e=r}t.splice(s,0,n)}}}}var P,H;function A(t){return t===P.INTERACTIVE||t===P.INTERACTIVE_TRANSPARENT}function U(t){return t!==P.HIDDEN}function R(t,i,s){return(i=(t=>{var i=(t=>{if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return t+""})(t);return"symbol"==typeof i?i:i+""})(i))in t?Object.defineProperty(t,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[i]=s,t}function V(){return new B}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE",t[t.INTERACTIVE_TRANSPARENT=3]="INTERACTIVE_TRANSPARENT"})(P||(P={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(H||(H={}));class B{constructor(){R(this,"index",{}),R(this,"array",[])}size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const s=this.index[t.id()];if(void 0===s){const s=new D(t,i());return this.index[t.id()]=this.array.length,this.array.push(s),s}return this.array[s]}insert(t,i){const s=new D(t,i),e=this.index[t.id()];return void 0===e?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[e]=s,s}erase(t){const i=this.index[t.id()];if(void 0===i)return;this.index[t.id()]=void 0;const s=this.array[i],e=this.array.pop();return s!==e&&(this.array[i]=e,this.index[e.first.id()]=i),s}copy(){const t=new B;for(let i=0;this.array.length>i;i++){const s=this.array[i].copy();t.array[i]=s,t.index[s.first.id()]=i}return t}}class D{constructor(t,i){R(this,"first",void 0),R(this,"second",void 0),this.first=t,this.second=i}copy(){return new D(this.first,this.second)}}class L{constructor(t){let i=arguments.length>0&&void 0!==t?t:"";R(this,"_name",void 0),R(this,"_value",0),R(this,"_context",null),R(this,"_id",k++),this._name=i}id(){return this._id}name(){return this._name}setName(t){this._name=t}context(){return this._context}setContext(t){this._context=t}value(){return this._value}setValue(t){this._value=t}plus(t){return new O(this,t)}minus(t){return new O(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new O([t,this])}divide(t){return new O([1/t,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}}let k=0;class O{constructor(){R(this,"_terms",void 0),R(this,"_constant",void 0);let t=(t=>{let i=0,s=()=>0,e=V();for(let r=0,h=t.length;h>r;++r){let h=t[r];if("number"==typeof h)i+=h;else if(h instanceof L)e.setDefault(h,s).second+=1;else if(h instanceof O){i+=h.constant();let t=h.terms();for(let i=0,r=t.size();r>i;i++){let r=t.itemAt(i);e.setDefault(r.first,s).second+=r.second}}else{if(!(h instanceof Array))throw Error("invalid Expression argument: "+h);{if(2!==h.length)throw Error("array must have length 2");let t=h[0],r=h[1];if("number"!=typeof t)throw Error("array item 0 must be a number");if(r instanceof L)e.setDefault(r,s).second+=t;else{if(!(r instanceof O))throw Error("array item 1 must be a variable or expression");{i+=r.constant()*t;let h=r.terms();for(let i=0,r=h.size();r>i;i++){let r=h.itemAt(i);e.setDefault(r.first,s).second+=r.second*t}}}}}}return{terms:e,constant:i}})(arguments);this._terms=t.terms,this._constant=t.constant}terms(){return this._terms}constant(){return this._constant}value(){let t=this._constant;for(let i=0,s=this._terms.size();s>i;i++){let s=this._terms.itemAt(i);t+=s.first.value()*s.second}return t}plus(t){return new O(this,t)}minus(t){return new O(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new O([t,this])}divide(t){return new O([1/t,this])}isConstant(){return 0==this._terms.size()}toString(){let t=this._terms.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this._constant||(t+=" + "),t+=this._constant,t}}var W,N;class j{static create(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:1,h=0;return h+=1e6*Math.max(0,Math.min(1e3,t*r)),h+=1e3*Math.max(0,Math.min(1e3,i*r)),h+=Math.max(0,Math.min(1e3,s*r)),h}static clip(t){return Math.max(0,Math.min(j.required,t))}}R(j,"required",(W=j).create(1e3,1e3,1e3)),R(j,"strong",W.create(1,0,0)),R(j,"medium",W.create(0,1,0)),R(j,"weak",W.create(0,0,1)),(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(N||(N={}));class z{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:j.required;R(this,"_expression",void 0),R(this,"_operator",void 0),R(this,"_strength",void 0),R(this,"_id",F++),this._operator=i,this._strength=j.clip(r),this._expression=void 0===s&&t instanceof O?t:t.minus(s)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength+")"}}let F=0;class G{constructor(){R(this,"maxIterations",1e3),R(this,"_cnMap",V()),R(this,"_rowMap",V()),R(this,"_varMap",V()),R(this,"_editMap",V()),R(this,"_infeasibleRows",[]),R(this,"_objective",new Z),R(this,"_artificial",null),R(this,"_idTick",0)}createConstraint(t,i,s,e){let r=new z(t,i,s,arguments.length>3&&void 0!==e?e:j.required);return this.addConstraint(r),r}addConstraint(t){if(void 0!==this._cnMap.find(t))throw Error("duplicate constraint");let i=this._createRow(t),s=i.row,e=i.tag,r=this._chooseSubject(s,e);if(r.type()===Y.Invalid&&s.allDummies()){if(!$(s.constant()))throw Error("unsatisfiable constraint");r=e.marker}if(r.type()===Y.Invalid){if(!this._addWithArtificialVariable(s))throw Error("unsatisfiable constraint")}else s.solveFor(r),this._substitute(r,s),this._rowMap.insert(r,s);this._cnMap.insert(t,e),this._optimize(this._objective)}removeConstraint(t){let i=this._cnMap.erase(t);if(void 0===i)throw Error("unknown constraint");this._removeConstraintEffects(t,i.second);let s=i.second.marker,e=this._rowMap.erase(s);if(void 0===e){let t=this._getMarkerLeavingSymbol(s);if(t.type()===Y.Invalid)throw Error("failed to find leaving row");e=this._rowMap.erase(t),e.second.solveForEx(t,s),this._substitute(s,e.second)}this._optimize(this._objective)}hasConstraint(t){return this._cnMap.contains(t)}getConstraints(){return this._cnMap.array.map(t=>{let{first:i}=t;return i})}addEditVariable(t,i){if(void 0!==this._editMap.find(t))throw Error("duplicate edit variable");if((i=j.clip(i))===j.required)throw Error("bad required strength");let s=new O(t),e=new z(s,N.Eq,void 0,i);this.addConstraint(e);let r=this._cnMap.find(e).second;this._editMap.insert(t,{tag:r,constraint:e,constant:0})}removeEditVariable(t){let i=this._editMap.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this._editMap.contains(t)}suggestValue(t,i){let s=this._editMap.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this._rowMap,r=s.second,h=i-r.constant;r.constant=i;let n=r.tag.marker,o=e.find(n);if(void 0!==o)return 0>o.second.add(-h)&&this._infeasibleRows.push(n),void this._dualOptimize();let a=r.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(h)&&this._infeasibleRows.push(a),void this._dualOptimize();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t),s=i.second,r=s.coefficientFor(n);0!==r&&0>s.add(h*r)&&i.first.type()!==Y.External&&this._infeasibleRows.push(i.first)}this._dualOptimize()}updateVariables(){let t=this._varMap,i=this._rowMap;for(let s=0,e=t.size();e>s;++s){let e=t.itemAt(s),r=i.find(e.second);e.first.setValue(void 0!==r?r.second.constant():0)}}_getVarSymbol(t){return this._varMap.setDefault(t,()=>this._makeSymbol(Y.External)).second}_createRow(t){let i=t.expression(),s=new Z(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!$(i.second)){let t=this._getVarSymbol(i.first),e=this._rowMap.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let r=this._objective,h=t.strength(),n={marker:q,other:q};switch(t.op()){case N.Le:case N.Ge:{let i=t.op()===N.Le?1:-1,e=this._makeSymbol(Y.Slack);if(n.marker=e,s.insertSymbol(e,i),j.required>h){let t=this._makeSymbol(Y.Error);n.other=t,s.insertSymbol(t,-i),r.insertSymbol(t,h)}break}case N.Eq:if(j.required>h){let t=this._makeSymbol(Y.Error),i=this._makeSymbol(Y.Error);n.marker=t,n.other=i,s.insertSymbol(t,-1),s.insertSymbol(i,1),r.insertSymbol(t,h),r.insertSymbol(i,h)}else{let t=this._makeSymbol(Y.Dummy);n.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:n}}_chooseSubject(t,i){let s=t.cells();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t);if(i.first.type()===Y.External)return i.first}let e=i.marker.type();return e!==Y.Slack&&e!==Y.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==Y.Slack&&e!==Y.Error||t.coefficientFor(i.other)>=0?q:i.other):i.marker}_addWithArtificialVariable(t){let i=this._makeSymbol(Y.Slack);this._rowMap.insert(i,t.copy()),this._artificial=t.copy(),this._optimize(this._artificial);let s=$(this._artificial.constant());this._artificial=null;let e=this._rowMap.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let r=this._anyPivotableSymbol(t);if(r.type()===Y.Invalid)return!1;t.solveForEx(i,r),this._substitute(r,t),this._rowMap.insert(r,t)}let r=this._rowMap;for(let t=0,s=r.size();s>t;++t)r.itemAt(t).second.removeSymbol(i);return this._objective.removeSymbol(i),s}_substitute(t,i){let s=this._rowMap;for(let e=0,r=s.size();r>e;++e){let r=s.itemAt(e);r.second.substitute(t,i),0>r.second.constant()&&r.first.type()!==Y.External&&this._infeasibleRows.push(r.first)}this._objective.substitute(t,i),this._artificial&&this._artificial.substitute(t,i)}_optimize(t){let i=0;for(;this.maxIterations>i;){let s=this._getEnteringSymbol(t);if(s.type()===Y.Invalid)return;let e=this._getLeavingSymbol(s);if(e.type()===Y.Invalid)throw Error("the objective is unbounded");let r=this._rowMap.erase(e).second;r.solveForEx(e,s),this._substitute(s,r),this._rowMap.insert(s,r),i++}throw Error("solver iterations exceeded")}_dualOptimize(){let t=this._rowMap,i=this._infeasibleRows;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this._getDualEnteringSymbol(e.second);if(i.type()===Y.Invalid)throw Error("dual optimize failed");let r=e.second;t.erase(s),r.solveForEx(s,i),this._substitute(i,r),t.insert(i,r)}}}_getEnteringSymbol(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first;if(0>s.second&&e.type()!==Y.Dummy)return e}return q}_getDualEnteringSymbol(t){let i=Number.MAX_VALUE,s=q,e=t.cells();for(let t=0,r=e.size();r>t;++t){let r=e.itemAt(t),h=r.first,n=r.second;if(n>0&&h.type()!==Y.Dummy){let t=this._objective.coefficientFor(h)/n;i>t&&(i=t,s=h)}}return s}_getLeavingSymbol(t){let i=Number.MAX_VALUE,s=q,e=this._rowMap;for(let r=0,h=e.size();h>r;++r){let h=e.itemAt(r),n=h.first;if(n.type()!==Y.External){let e=h.second,r=e.coefficientFor(t);if(0>r){let t=-e.constant()/r;i>t&&(i=t,s=n)}}}return s}_getMarkerLeavingSymbol(t){let i=Number.MAX_VALUE,s=i,e=i,r=q,h=r,n=r,o=r,a=this._rowMap;for(let i=0,r=a.size();r>i;++i){let r=a.itemAt(i),l=r.second,u=l.coefficientFor(t);if(0===u)continue;let c=r.first;if(c.type()===Y.External)o=c;else if(0>u){let t=-l.constant()/u;s>t&&(s=t,h=c)}else{let t=l.constant()/u;e>t&&(e=t,n=c)}}return h!==r?h:n!==r?n:o}_removeConstraintEffects(t,i){i.marker.type()===Y.Error&&this._removeMarkerEffects(i.marker,t.strength()),i.other.type()===Y.Error&&this._removeMarkerEffects(i.other,t.strength())}_removeMarkerEffects(t,i){let s=this._rowMap.find(t);void 0!==s?this._objective.insertRow(s.second,-i):this._objective.insertSymbol(t,-i)}_anyPivotableSymbol(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first.type();if(e===Y.Slack||e===Y.Error)return s.first}return q}_makeSymbol(t){return new X(t,this._idTick++)}}function $(t){return 0>t?1e-8>-t:1e-8>t}var Y;(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})(Y||(Y={}));let X=class{constructor(t,i){R(this,"_id",void 0),R(this,"_type",void 0),this._id=i,this._type=t}id(){return this._id}type(){return this._type}},q=new X(Y.Invalid,-1);class Z{constructor(t){let i=arguments.length>0&&void 0!==t?t:0;R(this,"_cellMap",V()),R(this,"_constant",void 0),this._constant=i}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let t=this._cellMap;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==Y.Dummy)return!1;return!0}copy(){let t=new Z(this._constant);return t._cellMap=this._cellMap.copy(),t}add(t){return this._constant+=t}insertSymbol(t,i){let s=arguments.length>1&&void 0!==i?i:1;$(this._cellMap.setDefault(t,()=>0).second+=s)&&this._cellMap.erase(t)}insertRow(t,i){let s=arguments.length>1&&void 0!==i?i:1;this._constant+=t._constant*s;let e=t._cellMap;for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);this.insertSymbol(i.first,i.second*s)}}removeSymbol(t){this._cellMap.erase(t)}reverseSign(){this._constant=-this._constant;let t=this._cellMap;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this._cellMap,s=-1/i.erase(t).second;this._constant*=s;for(let t=0,e=i.size();e>t;++t)i.itemAt(t).second*=s}solveForEx(t,i){this.insertSymbol(t,-1),this.solveFor(i)}coefficientFor(t){let i=this._cellMap.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this._cellMap.erase(t);void 0!==s&&this.insertRow(i,s.second)}}const J=1e3;var K;function Q(t){switch(t){case K.P0:return j.create(J,J,J);case K.P1:return j.create(100,0,0);case K.P2:return j.create(10,0,0);case K.P3:return j.create(0,100,0);case K.P4:return j.create(0,10,0);case K.P5:return j.create(0,0,100);case K.P6:return j.create(0,0,10);case K.P7:return j.create(0,0,1);default:throw Error("convertPriority.priority: invalid priority")}}(t=>{t[t.P0=0]="P0",t[t.P1=1]="P1",t[t.P2=2]="P2",t[t.P3=3]="P3",t[t.P4=4]="P4",t[t.P5=5]="P5",t[t.P6=6]="P6",t[t.P7=7]="P7"})(K||(K={}));class tt{constructor(){this.dirty=!1,this.S=!1,this.I=[],this.C=0}createInputCatcher(t,i,s,e){const r=this.C++;return this.I.push({handler:r,catchPointerDown:t,catchPointerMove:i,catchPointerUp:s,zIndex:e,active:!0}),this.S=!0,this.dirty=!0,r}destroyInputCatcher(t){const i=this.I.findIndex(i=>i.handler===t);if(-1===i)throw Error("UIInputWrapper.destroyInputCatcher.handler: handler not found");this.I.splice(i,1)}getZIndex(t){this.T();const i=this.I.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getZIndex.handler: handler not found");return i.zIndex}setZIndex(t,i){const s=this.I.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setZIndex.handler: handler not found");s.zIndex!==i&&(s.zIndex=i,this.S=!0,this.dirty=!0)}getActive(t){const i=this.I.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getActive.handler: handler not found");return i.active}setActive(t,i){const s=this.I.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setActive.handler: handler not found");s.active!==i&&(s.active=i)}onPointerDown(t,i,s){this.T();for(let e=this.I.length-1;e>=0;e--){const r=this.I[e];if(r.active&&r.catchPointerDown(t,i,s))break}}onPointerMove(t,i,s){this.T();for(let e=this.I.length-1;e>=0;e--){const r=this.I[e];if(r.active&&r.catchPointerMove(t,i,s))break}}onPointerUp(t,i,s){this.T();for(let e=this.I.length-1;e>=0;e--){const r=this.I[e];if(r.active&&r.catchPointerUp(t,i,s))break}}T(){if(this.S){this.I.sort((t,i)=>t.zIndex-i.zIndex);const t=this.I.length,i=1024>t?1:1024/t;for(let s=0;t>s;s++)this.I[s].zIndex=s*i;this.S=!1}}}function it(t){return.04045>t?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function st(t){return.0031308>t?12.92*t:1.055*Math.pow(t,.41666)-.055}const et={black:0,white:16777215,red:16711680,green:32768,blue:255,yellow:16776960,cyan:65535,magenta:16711935,gray:8421504,grey:8421504,silver:12632256,maroon:8388608,olive:8421376,lime:65280,aqua:65535,teal:32896,navy:128,fuchsia:16711935,purple:8388736,orange:16753920,pink:16761035,brown:10824234,gold:16766720,violet:15631086,indigo:4915330,coral:16744272,salmon:16416882,khaki:15787660,plum:14524637,orchid:14315734,tan:13808780,beige:16119260,mint:10025880,lavender:15132410,crimson:14423100,azure:15794175,ivory:16777200,snow:16775930};class rt{constructor(){this.P=1,this.H=1,this.A=1,this.U=1,this.R=0,this.V=0,this.B=1,this.D=!1,this.L=!1,this.O=!1,arguments.length>0&&this.set(...arguments)}static get black(){return new rt("black")}static get white(){return new rt("white")}static get red(){return new rt("red")}static get green(){return new rt("green")}static get blue(){return new rt("blue")}static get yellow(){return new rt("yellow")}static get cyan(){return new rt("cyan")}static get magenta(){return new rt("magenta")}static get gray(){return new rt("gray")}static get grey(){return new rt("grey")}static get silver(){return new rt("silver")}static get maroon(){return new rt("maroon")}static get olive(){return new rt("olive")}static get lime(){return new rt("lime")}static get aqua(){return new rt("aqua")}static get teal(){return new rt("teal")}static get navy(){return new rt("navy")}static get fuchsia(){return new rt("fuchsia")}static get purple(){return new rt("purple")}static get orange(){return new rt("orange")}static get pink(){return new rt("pink")}static get brown(){return new rt("brown")}static get gold(){return new rt("gold")}static get violet(){return new rt("violet")}static get indigo(){return new rt("indigo")}static get coral(){return new rt("coral")}static get salmon(){return new rt("salmon")}static get khaki(){return new rt("khaki")}static get plum(){return new rt("plum")}static get orchid(){return new rt("orchid")}static get tan(){return new rt("tan")}static get beige(){return new rt("beige")}static get mint(){return new rt("mint")}static get lavender(){return new rt("lavender")}static get crimson(){return new rt("crimson")}static get azure(){return new rt("azure")}static get ivory(){return new rt("ivory")}static get snow(){return new rt("snow")}get r(){return this.W(),this.P}get g(){return this.W(),this.H}get b(){return this.W(),this.A}get a(){return this.U}get hue(){return this.N(),this.R}get saturation(){return this.N(),this.V}get lightness(){return this.N(),this.B}get dirty(){return this.D}set r(i){i=t.clamp(i,0,1),this.W(),i!==this.P&&(this.P=i,this.O=!0,this.D=!0)}set g(i){i=t.clamp(i,0,1),this.W(),i!==this.H&&(this.H=i,this.O=!0,this.D=!0)}set b(i){i=t.clamp(i,0,1),this.W(),i!==this.A&&(this.A=i,this.O=!0,this.D=!0)}set a(i){(i=t.clamp(i,0,1))!==this.U&&(this.U=i,this.D=!0)}set hue(i){i=t.clamp(i,0,360),this.N(),i!==this.R&&(this.R=i,this.L=!0,this.D=!0)}set saturation(i){i=t.clamp(i,0,1),this.N(),i!==this.V&&(this.V=i,this.L=!0,this.D=!0)}set lightness(i){i=t.clamp(i,0,1),this.N(),i!==this.B&&(this.B=i,this.L=!0,this.D=!0)}setDirtyFalse(){this.D=!1}set(){for(var t=arguments.length,s=Array(t),e=0;t>e;e++)s[e]=arguments[e];if(0===s.length||void 0===s[0])return this.setRGBA(1,1,1,1);if(s.length>=3&&"number"==typeof s[0]){const[t,i,e,r=1]=s;return this.setRGBA(t,i,e,r)}const[r,h=1]=s;if("string"==typeof r)return r.startsWith("#")?this.setHexString(r):this.setColorName(r,h);if(r instanceof rt)return this.copy(r);if(r instanceof i)return this.setThreeColor(r,h);if("number"==typeof r)return this.setHexRGB(r,h);throw Error("UIColor.set: cannot create color from provided arguments")}setRGBA(i,s,e,r){let h=arguments.length>3&&void 0!==r?r:this.U;return i=t.clamp(i,0,1),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.W(),i===this.P&&s===this.H&&e===this.A&&h===this.U||(this.P=i,this.H=s,this.A=e,this.U=h,this.O=!0,this.D=!0),this}getHexRGBA(){return this.W(),Math.round(255*this.P)<<24|Math.round(255*this.H)<<16|Math.round(255*this.A)<<8|Math.round(255*this.U)}getHexRGB(){return this.W(),Math.round(255*this.P)<<16|Math.round(255*this.H)<<8|Math.round(255*this.A)}getHexStringRGB(){return"#"+this.getHexRGB().toString(16).padStart(6,"0")}getHexStringRGBA(){return"#"+this.getHexRGBA().toString(16).padStart(8,"0")}setHexRGBA(t){this.W();const i=(t>>16&255)/255,s=(t>>8&255)/255,e=(255&t)/255,r=(t>>24&255)/255;return i===this.P&&s===this.H&&e===this.A&&r===this.U||(this.P=i,this.H=s,this.A=e,this.U=r,this.O=!0,this.D=!0),this}setHexRGB(i,s){let e=arguments.length>1&&void 0!==s?s:this.U;e=t.clamp(e,0,1),this.W();const r=(i>>16&255)/255,h=(i>>8&255)/255,n=(255&i)/255;return r===this.P&&h===this.H&&n===this.A&&e===this.U||(this.P=r,this.H=h,this.A=n,this.U=e,this.O=!0,this.D=!0),this}setHexString(t){if(!t.startsWith("#"))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');const i=t.slice(1);if(6===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGB(t)}if(8===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGBA(t)}throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"')}setHSL(i,s,e,r){let h=arguments.length>3&&void 0!==r?r:this.U;return i=t.clamp(i,0,360),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.N(),i===this.R&&s===this.V&&e===this.B&&h===this.U||(this.R=i,this.V=s,this.B=e,this.U=h,this.L=!0,this.D=!0),this}setColorName(i,s){let e=arguments.length>1&&void 0!==s?s:this.U;e=t.clamp(e,0,1);const r=i.toLowerCase().trim(),h=et[r];if(void 0===h)throw Error("UIColor.setColorName.colorName: unknown color name");return this.setHexRGB(h,e)}setGLSLColor(i,s,e,r){let h=arguments.length>3&&void 0!==r?r:this.U;h=t.clamp(h,0,1),this.W();const n=st(i),o=st(s),a=st(e);return n===this.P&&o===this.H&&a===this.A&&h===this.U||(this.P=n,this.H=o,this.A=a,this.U=h,this.O=!0,this.D=!0),this}setThreeColor(i,s){let e=arguments.length>1&&void 0!==s?s:this.U;return e=t.clamp(e,0,1),this.W(),i.r===this.P&&i.g===this.H&&i.b===this.A&&e===this.U||(this.P=i.r,this.H=i.g,this.A=i.b,this.U=e,this.O=!0,this.D=!0),this}toCSSColor(){return this.W(),`rgba(${Math.round(255*this.P)}, ${Math.round(255*this.H)}, ${Math.round(255*this.A)}, ${this.U})`}toGLSLColor(t){let i=arguments.length>0&&void 0!==t?t:new s;return this.W(),i.x=it(this.P),i.y=it(this.H),i.z=it(this.A),i.w=this.U,i}toThreeColor(t){let s=arguments.length>0&&void 0!==t?t:new i;return this.W(),s.r=this.P,s.g=this.H,s.b=this.A,s}copy(t){return t instanceof rt?(this.W(),t.W(),this.P===t.P&&this.H===t.H&&this.A===t.A&&this.U===t.U||(this.P=t.P,this.H=t.H,this.A=t.A,this.U=t.U,this.O=!0,this.D=!0)):(this.W(),this.P===t.r&&this.H===t.g&&this.A===t.b&&1===this.U||(this.P=t.r,this.H=t.g,this.A=t.b,this.U=1,this.O=!0,this.D=!0)),this}clone(){return this.W(),new rt(this.P,this.H,this.A,this.U)}W(){if(this.L){const{R:t,V:i,B:s}=this,e=(1-Math.abs(2*s-1))*i,r=t/60,h=e*(1-Math.abs(r%2-1));let[n,o,a]=1>r?[e,h,0]:2>r?[h,e,0]:3>r?[0,e,h]:4>r?[0,h,e]:5>r?[h,0,e]:[e,0,h];const l=s-e/2;this.P=n+l,this.H=o+l,this.A=a+l,this.L=!1}}N(){if(this.O){const{P:t,H:i,A:s}=this,e=Math.max(t,i,s),r=Math.min(t,i,s),h=e-r,n=(e+r)/2;let o=0;0!==h&&(o=e===t?(i-s)/h+(s>i?6:0):e===i?(s-t)/h+2:(t-i)/h+4,o*=60);const a=0===h?0:h/(1-Math.abs(2*n-1));this.R=o,this.V=a,this.B=n,this.O=!1}}}document.createElement("canvas").getContext("webgl2");const ht=(()=>{var t;if("undefined"==typeof OffscreenCanvas)return!1;const i=document.createElement("canvas");i.width=4,i.height=4;const s=null!==(t=i.getContext("webgl"))&&void 0!==t?t:i.getContext("webgl2");if(!s)return!1;try{const t=new OffscreenCanvas(4,4),i=t.getContext("2d");if(!i)return!1;i.fillStyle="#ff0000",i.fillRect(0,0,4,4);const e=s.createTexture();if(s.bindTexture(s.TEXTURE_2D,e),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t),s.getError()!==s.NO_ERROR)return s.deleteTexture(e),!1;const r=s.createFramebuffer();if(s.bindFramebuffer(s.FRAMEBUFFER,r),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.checkFramebufferStatus(s.FRAMEBUFFER)!==s.FRAMEBUFFER_COMPLETE)return s.deleteFramebuffer(r),s.deleteTexture(e),!1;const h=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,h),s.bindFramebuffer(s.FRAMEBUFFER,null),s.deleteFramebuffer(r),s.deleteTexture(e),!!(h[0]>200&&50>h[1]&&50>h[2]&&h[3]>200)}catch(t){return!1}})(),nt=(()=>{var t;const i=document.createElement("canvas"),s=null!==(t=i.getContext("webgl2"))&&void 0!==t?t:i.getContext("webgl");if(!s)return!1;if(s instanceof WebGL2RenderingContext)try{const t=s.createTexture();s.bindTexture(s.TEXTURE_2D,t),s.texStorage2D(s.TEXTURE_2D,1,s.SRGB8_ALPHA8,2,2);const i=s.getError();return s.deleteTexture(t),i===s.NO_ERROR}catch(t){return!1}const e=s.getExtension("EXT_sRGB");if(!e)return!1;try{const t=s.createTexture();s.bindTexture(s.TEXTURE_2D,t),s.texImage2D(s.TEXTURE_2D,0,e.SRGB_ALPHA_EXT,2,2,0,e.SRGB_ALPHA_EXT,s.UNSIGNED_BYTE,null);const i=s.getError();return s.deleteTexture(t),i===s.NO_ERROR}catch(t){return!1}})(),ot=Object.freeze({glslTypeName:"float",bufferSize:1,instantiable:!0}),at=Object.freeze({glslTypeName:"sampler2D",bufferSize:-1,instantiable:!1}),lt=Object.freeze({glslTypeName:"vec2",bufferSize:2,instantiable:!0}),ut=Object.freeze({glslTypeName:"vec3",bufferSize:3,instantiable:!0}),ct=Object.freeze({glslTypeName:"vec4",bufferSize:4,instantiable:!0}),dt=Object.freeze({glslTypeName:"mat3",bufferSize:9,instantiable:!0}),ft=Object.freeze({glslTypeName:"mat4",bufferSize:16,instantiable:!0});function vt(t){if("string"==typeof t)switch(t){case"number":return ot;case"Texture":return at;case"UIColor":case"Vector4":return ct;case"Vector2":return lt;case"Vector3":return ut;case"Matrix3":return dt;case"Matrix4":return ft;default:throw Error("resolveGLSLTypeInfo.value: unsupported property type name")}if("function"==typeof t){if(t===Number)return ot;if(t===e)return at;if(t===rt)return ct;if(t===r)return lt;if(t===h)return ut;if(t===s)return ct;if(t===n)return dt;if(t===o)return ft;throw Error("resolveGLSLTypeInfo.value: unsupported property type constructor")}if("number"==typeof t)return ot;if(t instanceof e)return at;if(t instanceof rt)return ct;if(t instanceof r)return lt;if(t instanceof h)return ut;if(t instanceof s)return ct;if(t instanceof n)return dt;if(t instanceof o)return ft;throw Error("resolveGLSLTypeInfo.value: unsupported property type")}function pt(t,i){const s=i.uniforms["p_"+t];if(void 0===s)throw Error("resolvePropertyUniform.name: unknown uniform");return s}function wt(t,i){for(const s in i){if(!(s in t))return!1;const e=t[s].glslTypeInfo;if(e.glslTypeName!==i[s].glslTypeInfo.glslTypeName)return!1;if(!e.instantiable&&t[s]!==i[s])return!1}return!0}function gt(t){const i={};for(const s in t){const e=t[s];i[s]={value:e,glslTypeInfo:vt(e)}}return i}function yt(t){return"number"==typeof t||t instanceof e?t:t.clone()}function mt(t){const i={};for(const s in t)i[s]=yt(t[s]);return i}function bt(t,i,s){return`\n // Defines\n #define PI 3.14159265359\n #define SRGB_SUPPORTED ${nt?"1":"0"}\n \n // Uniforms\n ${t.join("\n")}\n \n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n \n // User varyings\n ${i.join("\n")}\n \n #include <alphahash_pars_fragment>\n \n // sRGB decode helper\n vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {\n #if SRGB_SUPPORTED\n return texture2D(textureSampler, uv);\n #else\n vec4 textureValue = texture2D(textureSampler, uv);\n return vec4(pow(textureValue.rgb, vec3(2.2)), textureValue.a);\n #endif\n }\n \n // Source must define vec4 draw() function\n ${s}\n void main() {\n vec4 diffuseColor = draw();\n #ifdef USE_ALPHATEST\n if (diffuseColor.a < 0.50) {\n discard;\n }\n #endif\n #ifdef USE_ALPHAHASH\n if (diffuseColor.a < getAlphaHashThreshold(p_position)) {\n discard;\n }\n #endif\n gl_FragColor = linearToOutputTexel(diffuseColor);\n }\n `}var _t;(t=>{t[t.CLIP=0]="CLIP",t[t.HASH=1]="HASH",t[t.BLEND=2]="BLEND"})(_t||(_t={}));const xt=(()=>{const t=new a(1,1);t.translate(.5,.5,0);const i=new l;return i.index=t.index,i.setAttribute("position",t.attributes.position),i.setAttribute("uv",t.attributes.uv),t.dispose(),i})(),St=new s,Et=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function It(t,i,e){if(t instanceof rt)t.toGLSLColor(St),i[e]=St.x,i[e+1]=St.y,i[e+2]=St.z,i[e+3]=St.w;else if(t instanceof r)i[e]=t.x,i[e+1]=t.y;else if(t instanceof h)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z;else if(t instanceof s)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z,i[e+3]=t.w;else if(t instanceof n||t instanceof o){const s=t.elements;for(let t=0;s.length>t;t++)i[e+t]=s[t]}else"number"==typeof t&&(i[e]=t)}function Mt(t,i){const s=vt(t);if(!s.instantiable)throw Error("buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type");return new c(new Float32Array(i*s.bufferSize),s.bufferSize)}function Ct(t,i,e){if("number"==typeof t)return i[e];if(t instanceof r)return new r(i[e],i[e+1]);if(t instanceof h)return new h(i[e],i[e+1],i[e+2]);if(t instanceof s)return new s(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof rt)return(new rt).setGLSLColor(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof n){const t=new n;return t.fromArray(i,e),t}if(t instanceof o){const t=new o;return t.fromArray(i,e),t}throw Error("reconstructValue.referenceValue: cannot reconstruct value for type")}class Tt extends d{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:4;const h={},n={instanceVisibility:{value:1,glslTypeInfo:vt("number")},instanceTransform:{value:(new o).identity(),glslTypeInfo:vt("Matrix4")}};for(const t in i){const s=i[t];s.glslTypeInfo.instantiable?n[t]=s:h[t]=s}const a=xt.clone(),l=((t,i,s,e)=>{const r={},h=[],n=[],o=[],a=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];r["p_"+t]={value:s instanceof rt?s.toGLSLColor():s},h.push(`uniform ${e.glslTypeName} p_${t};`)}for(const t in s){const{glslTypeInfo:i}=s[t];n.push(`attribute ${i.glslTypeName} a_${t};`),o.push(`varying ${i.glslTypeName} p_${t};`),a.push(`p_${t} = a_${t};`)}const l=`\n // User attributes\n ${n.join("\n")}\n\n // Uniforms\n ${h.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${o.join("\n")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${a.join("\n")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `,c=bt(h,o,t);return new u({uniforms:r,vertexShader:l,fragmentShader:c,transparent:e===_t.BLEND,alphaTest:e===_t.CLIP?.5:0,alphaHash:e===_t.HASH,depthWrite:e!==_t.BLEND,depthTest:!0})})(t,h,n,s);super(a,l),this.source=t,this.transparency=s,this.j=new Map,this.F=new Map,this.C=0,this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1,this.G=a,this.G.instanceCount=0,this.$=l,this.Y=h,this.X=n,this.q=Math.max(4*Math.ceil(r/4),4);for(const t in this.X){const{value:i}=this.X[t],s=Mt(i,this.q);this.G.setAttribute("a_"+t,s),this.F.set(t,s)}for(const t in this.Y){const{value:i}=this.Y[t];pt(t,this.$).value=i}this.$.uniformsNeedUpdate=!0}get instanceCount(){return this.G.instanceCount}createInstance(){const t=this.C++,i=this.G.instanceCount;this.Z(i+1),this.j.set(t,i),this.G.instanceCount++;{const t=this.F.get("instanceVisibility"),s=this.F.get("instanceTransform");((t,i,s)=>{t[s]=1;const e=16*s;for(let t=0;16>t;t++)i[e+t]=Et[t]})(t.array,s.array,i),t.needsUpdate=!0,s.needsUpdate=!0}return t}destroyInstance(t){const i=this.J(t);this.j.delete(t);const s=this.G.instanceCount-1;s>i&&(this.K(s,i),this.tt(s,i)),this.G.instanceCount--}setProperties(t,i){const s=this.J(t);for(const t in i){const{value:e,glslTypeInfo:r}=i[t];if(r.instantiable){const i=this.it(t);It(e,i.array,s*i.itemSize),i.needsUpdate=!0}else pt(t,this.$).value=e,this.$.uniformsNeedUpdate=!0}}setTransform(t,i){const s=this.J(t),e=this.it("instanceTransform"),r=e.array,h=16*s,n=i.elements;for(let t=0;16>t;t++)r[h+t]=n[t];e.needsUpdate=!0}setVisibility(t,i){const s=this.J(t),e=this.it("instanceVisibility");e.array[s]=i?1:0,e.needsUpdate=!0}isPartiallyCompatible(t,i,s){return this.transparency===(arguments.length>2&&void 0!==s?s:_t.BLEND)&&this.source===t&&wt(Object.assign(Object.assign({},this.Y),this.X),i)}arePropertiesPartiallyCompatible(t){return wt(Object.assign(Object.assign({},this.Y),this.X),t)}extractInstanceData(t){return{source:this.source,properties:this.st(t),transparency:this.transparency,transform:this.et(t),visibility:this.rt(t)}}destroy(){this.G.dispose(),this.$.dispose(),this.F.clear(),this.j.clear()}st(t){const i=this.J(t),s={};for(const t in this.Y)s[t]=this.Y[t];for(const t in this.X){const{value:e,glslTypeInfo:r}=this.X[t],h=this.F.get(t);s[t]={value:Ct(e,h.array,i*h.itemSize),glslTypeInfo:r}}return s}et(t){const i=this.J(t),s=this.F.get("instanceTransform").array,e=new o;return e.fromArray(s,16*i),e}rt(t){const i=this.J(t);return this.F.get("instanceVisibility").array[i]>=.5}Z(t){if(this.q>=t)return;const i=4*Math.ceil(t/4);for(const[t,s]of this.F){const e=s.itemSize,r=new Float32Array(i*e);r.set(s.array);const h=new c(r,e);this.G.setAttribute("a_"+t,h),this.F.set(t,h)}this.q=i}K(t,i){for(const s of this.F.values()){const e=s.array,r=s.itemSize,h=t*r,n=i*r;for(let t=0;r>t;t++)e[n+t]=e[h+t];s.needsUpdate=!0}}tt(t,i){for(const[s,e]of this.j)if(e===t){this.j.set(s,i);break}}J(t){const i=this.j.get(t);if(void 0===i)throw Error("UIGenericInstancedPlane.resolveIndex.handler: invalid handler");return i}it(t){const i=this.F.get(t);if(void 0===i)throw Error("UIGenericInstancedPlane.resolveAttribute.name: unknown attribute");return i}}const Pt=new a(1,1).translate(.5,.5,0);class Ht extends d{constructor(t,i,s,e,r){const h=((t,i,s,e)=>{const r={p_transform:{value:e}},h=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];r["p_"+t]={value:s instanceof rt?s.toGLSLColor():s},h.push(`uniform ${e.glslTypeName} p_${t};`)}const n=`\n // Default uniform declarations\n uniform mat4 p_transform;\n\n // Custom uniform declarations\n ${h.join("\n")}\n\n // Default varying declarations\n varying vec3 p_position;\n varying vec2 p_uv;\n\n void main() {\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * p_transform * vec4(position, 1.0);\n }\n `,o=bt(h,[],t);return new u({uniforms:r,vertexShader:n,fragmentShader:o,transparent:s===_t.BLEND,alphaTest:s===_t.CLIP?.5:0,alphaHash:s===_t.HASH,depthWrite:s!==_t.BLEND,depthTest:!0})})(t,i,r,s);super(Pt,h),this.ht=t,this.$=h,this.nt=i,this.ot=r,this.lt=s,this.visible=e,this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1}get transparency(){return this.ot}setProperties(t){for(const i in t){const s=t[i],r=pt(i,this.$),h=s.value;if(s.value instanceof rt)s.value.toGLSLColor(r.value),this.nt[i].value.copy(s.value);else if("number"==typeof h||h instanceof e)r.value=s.value,this.nt[i].value=s.value;else{const t=s.value;r.value.copy(t),this.nt[i].value.copy(t)}}this.$.uniformsNeedUpdate=!0}setTransform(t){pt("transform",this.$).value.copy(t),this.$.uniformsNeedUpdate=!0,this.lt.copy(t)}setVisibility(t){this.visible=t}setTransparency(t){this.ot!==t&&(this.$.transparent=t===_t.BLEND,this.$.alphaTest=t===_t.CLIP?.5:0,this.$.alphaHash=t===_t.HASH,this.$.depthWrite=t!==_t.BLEND,this.$.needsUpdate=!0,this.ot=t)}extractPlaneData(){return{source:this.ht,properties:Object.assign({},this.nt),transform:this.lt.clone(),visibility:this.visible,transparency:this.ot}}isPartiallyCompatible(t,i,s){return this.ot===s&&this.ht===t&&wt(this.nt,i)}arePropertiesPartiallyCompatible(t){return wt(this.nt,t)}destroy(){this.$.dispose()}}function At(t){return!("instanceHandler"in t)}function Ut(t){return"instanceHandler"in t}class Rt{constructor(t){this.ut=t,this.C=0,this.ct=new Map}createPlane(t,i,s,e,r){const h=this.C++;return this.dt(h,{source:t,properties:gt(mt(i)),transform:s.clone(),visibility:e,transparency:r}),h}destroyPlane(t){const i=this.ft(t);if(At(i))this.ut.remove(i.plane),i.plane.destroy();else{const t=i.plane;1===t.instanceCount?(this.ut.remove(t),t.destroy()):2===t.instanceCount?this.vt(t,i):t.destroyInstance(i.instanceHandler)}this.ct.delete(t)}setProperties(t,i){const s=this.ft(t),e=gt(i);if(At(s))return void s.plane.setProperties(e);if(s.plane.arePropertiesPartiallyCompatible(e))return void s.plane.setProperties(s.instanceHandler,e);const r=s.plane.extractInstanceData(s.instanceHandler);for(const t in e)r.properties[t]={value:yt(e[t].value),glslTypeInfo:e[t].glslTypeInfo};this.destroyPlane(t),this.dt(t,r)}setTransform(t,i){const s=this.ft(t);At(s)?s.plane.setTransform(i):s.plane.setTransform(s.instanceHandler,i)}setVisibility(t,i){const s=this.ft(t);At(s)?s.plane.setVisibility(i):s.plane.setVisibility(s.instanceHandler,i)}setTransparency(t,i){const s=this.ft(t);if(s.plane.transparency===i)return;if(At(s))return void s.plane.setTransparency(i);const e=s.plane.extractInstanceData(s.instanceHandler);this.destroyPlane(t),this.dt(t,Object.assign(Object.assign({},e),{transparency:i}))}wt(t,i){const{source:s,properties:e,transform:r,visibility:h,transparency:n}=i.plane.extractPlaneData();this.destroyPlane(t);const o=new Tt(s,e,n),a=o.createInstance();return o.setProperties(a,e),o.setTransform(a,r),o.setVisibility(a,h),this.ut.add(o),this.ct.set(t,{plane:o,instanceHandler:a}),o}vt(t,i){let s;for(const[e,r]of this.ct)if(Ut(r)&&r!==i&&r.plane===t){s=[e,r];break}if(!s)throw Error("UIGenericPlaneRegistry.demoteInstancedPlaneToSinglePlane.instancedPlane: remaining pair not found");const{source:e,properties:r,transform:h,visibility:n,transparency:o}=t.extractInstanceData(s[1].instanceHandler);this.ut.remove(t),t.destroy();const a=new Ht(e,r,h,n,o);this.ut.add(a),this.ct.set(s[0],{plane:a})}gt(t,i,s,e,r){const h=i.createInstance();i.setProperties(h,s),i.setTransform(h,e),i.setVisibility(h,r),this.ct.set(t,{plane:i,instanceHandler:h})}dt(t,i){const{source:s,properties:e,transparency:r,transform:h,visibility:n}=i,o=this.yt(s,e,r);if(o)return void this.gt(t,o,e,h,n);const a=this.bt(s,e,r);if(a){const i=this.wt(a[0],a[1]);return void this.gt(t,i,e,h,n)}const l=new Ht(s,e,h,n,r);this.ut.add(l),this.ct.set(t,{plane:l})}bt(t,i,s){for(const e of this.ct){const r=e[1];if(At(r)&&r.plane.isPartiallyCompatible(t,i,s))return[e[0],r]}}yt(t,i,s){for(const e of this.ct){const r=e[1];if(Ut(r)&&r.plane.isPartiallyCompatible(t,i,s))return r.plane}}ft(t){const i=this.ct.get(t);if(!i)throw Error("UIGenericPlaneRegistry.resolvePlaneDescriptor.handler: descriptor not found");return i}}let Vt=new i,Bt=0,Dt=!1,Lt=!1,kt=!1,Ot=!1;class Wt{constructor(t,i){this.ut=new f,this._t=new Rt(this.ut),this.xt=new v(0,t,i,0,-1024,1024)}createPlane(t,i,s,e,r){return this._t.createPlane(t,i,s,e,r)}destroyPlane(t){this._t.destroyPlane(t)}setTransform(t,i){this._t.setTransform(t,i)}setProperties(t,i){this._t.setProperties(t,i)}setVisibility(t,i){this._t.setVisibility(t,i)}setTransparency(t,i){this._t.setTransparency(t,i)}insertCustomObject(t){return this.ut.add(t),this}removeCustomObject(t){return this.ut.remove(t),this}resize(t,i){return this.xt.right=t,this.xt.top=i,this.xt.updateProjectionMatrix(),this}render(t){return Vt=t.getClearColor(Vt),Bt=t.getClearAlpha(),Dt=t.autoClear,Lt=t.autoClearColor,kt=t.autoClearDepth,Ot=t.autoClearStencil,t.autoClear=!1,t.autoClearColor=!1,t.autoClearDepth=!1,t.autoClearStencil=!1,t.setClearColor(0,1),t.clear(!1,!0,!0),t.render(this.ut,this.xt),t.setClearColor(Vt),t.setClearAlpha(Bt),t.autoClear=Dt,t.autoClearColor=Lt,t.autoClearDepth=kt,t.autoClearStencil=Ot,this}}class Nt{constructor(t,i){let s=arguments.length>1?i:void 0;if(this.constant=arguments.length>0&&void 0!==t?t:0,this.St=s?new Map(s):new Map,s)for(let t=0;s.length>t;t++)Jt()}static plus(t,i){const s=new Nt(t.constant+i.constant,Array.from(t.St.entries()));for(const[t,e]of i.St)s.plus(t,e);return s}static minus(t,i){const s=new Nt(t.constant-i.constant,Array.from(t.St.entries()));for(const[t,e]of i.St)s.minus(t,e);return s}plus(t,i){var s;return this.St.set(t,(null!==(s=this.St.get(t))&&void 0!==s?s:0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,s]of this.St)this.St.set(i,s*t);return this}divide(t){if(0===t)throw Error("UIExpression.divide.value: cannot divide by zero");return this.multiply(1/t)}hasTerm(t){return this.St.has(t)}copy(t){this.constant=t.constant,this.St.clear();for(const[i,s]of t.St)this.St.set(i,s);return this}clone(){return new Nt(this.constant,Array.from(this.St.entries()))}prepareTerms(){return Array.from(this.St.entries())}}var jt,zt;(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(jt||(jt={}));class Ft{constructor(){this.dirty=!1,this.Et=new G,this.It=!1,this.Mt=new Map,this.Ct=0,this.Tt=new Map,this.Pt=0}createVariable(t,i){var s,e,r;const h=this.Ct++,n=new L;if(i===K.P0){const e={variable:n,priority:i,value:t};this.Mt.set(h,e),e.constraint=this.Ht(new Nt(0,[[h,1]]),new Nt(t),jt.EQUAL,i);try{null===(s=this.Et)||void 0===s||s.addConstraint(e.constraint)}catch(t){this.Et=void 0}}else{this.Mt.set(h,{variable:n,priority:i,value:t});try{null===(e=this.Et)||void 0===e||e.addEditVariable(n,Q(i)),null===(r=this.Et)||void 0===r||r.suggestValue(n,t)}catch(t){this.Et=void 0}}return this.It=!0,this.dirty=!0,h}removeVariable(t){var i,s;const e=this.Mt.get(t);if(void 0===e)throw Error("UISolverWrapper.removeVariable.index: variable does not exist");for(const i of this.Tt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error("UISolverWrapper.removeVariable.index: variable is used in constraint");try{e.constraint?null===(i=this.Et)||void 0===i||i.removeConstraint(e.constraint):null===(s=this.Et)||void 0===s||s.removeEditVariable(e.variable)}catch(t){this.Et=void 0}this.Mt.delete(t),this.It=!0,this.dirty=!0}suggestVariableValue(t,i){var s;const e=this.Mt.get(t);if(void 0===e)throw Error("UISolverWrapper.suggestVariableValue.index: variable does not exist");e.value!==i&&(e.value=i,e.constraint?e.constraint=this.At(e.constraint,(new Nt).plus(t,1),new Nt(e.value),jt.EQUAL,e.priority):null===(s=this.Et)||void 0===s||s.suggestValue(e.variable,i),this.It=!0,this.dirty=!0)}setVariablePriority(t,i){var s,e;const r=this.Mt.get(t);if(void 0===r)throw Error("UISolverWrapper.setVariablePriority.index: variable does not exist");if(i!==r.priority){if(r.priority=i,r.priority===K.P0){const i=(new Nt).plus(t,1),e=new Nt(r.value);r.constraint=this.Ht(i,e,jt.EQUAL,r.priority);try{null===(s=this.Et)||void 0===s||s.addConstraint(r.constraint)}catch(t){this.Et=void 0}}else{if(r.constraint)try{null===(e=this.Et)||void 0===e||e.removeConstraint(r.constraint)}catch(t){this.Et=void 0}r.constraint=void 0,this.Ut(t,r)}this.It=!0,this.dirty=!0}}readVariableValue(t){var i;const s=this.Mt.get(t);if(void 0===s)throw Error("UISolverWrapper.readVariableValue.index: variable does not exist");return void 0===this.Et&&this.Rt(),this.It&&(null===(i=this.Et)||void 0===i||i.updateVariables(),this.It=!1),s.variable.value()}createConstraint(t,i,s,e,r){var h;const n=this.Pt++,o=this.Ht(t,i,s,e);if(this.Tt.set(n,{constraint:o,lhs:t.clone(),rhs:i.clone(),priority:e,relation:s,enabled:r}),r){try{null===(h=this.Et)||void 0===h||h.addConstraint(o)}catch(t){this.Et=void 0}this.It=!0,this.dirty=!0}return n}removeConstraint(t){var i;const s=this.Tt.get(t);if(void 0===s)throw Error("UISolverWrapper.removeConstraint.index: constraint does not exist");if(s.enabled)try{null===(i=this.Et)||void 0===i||i.removeConstraint(s.constraint)}catch(t){this.Et=void 0}this.Tt.delete(t),this.It=!0,this.dirty=!0}setConstraintLHS(t,i){const s=this.Tt.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintLHS.index: constraint does not exist");s.lhs.copy(i),this.Vt(s),this.It=!0,this.dirty=!0}setConstraintRHS(t,i){const s=this.Tt.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRHS.index: constraint does not exist");s.rhs.copy(i),this.Vt(s),this.It=!0,this.dirty=!0}setConstraintRelation(t,i){const s=this.Tt.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRelation.index: constraint does not exist");s.relation!==i&&(s.relation=i,this.Vt(s),this.It=!0,this.dirty=!0)}setConstraintPriority(t,i){const s=this.Tt.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintPriority.index: constraint does not exist");s.priority!==i&&(s.priority=i,this.Vt(s),this.It=!0,this.dirty=!0)}setConstraintEnabled(t,i){var s,e;const r=this.Tt.get(t);if(void 0===r)throw Error("UISolverWrapper.setConstraintEnabled.index: constraint does not exist");if(i!==r.enabled){r.enabled=i;try{r.enabled?null===(s=this.Et)||void 0===s||s.addConstraint(r.constraint):null===(e=this.Et)||void 0===e||e.removeConstraint(r.constraint)}catch(t){this.Et=void 0}this.It=!0,this.dirty=!0}}Ut(t,i){var s,e,r,h;const n=[];for(const i of this.Tt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{null===(s=this.Et)||void 0===s||s.removeConstraint(i.constraint)}catch(t){this.Et=void 0}n.push(i)}null===(e=this.Et)||void 0===e||e.removeEditVariable(i.variable),null===(r=this.Et)||void 0===r||r.addEditVariable(i.variable,Q(i.priority));for(const t of n)t.constraint=this.Ht(t.lhs,t.rhs,t.relation,t.priority);for(const t of n)try{null===(h=this.Et)||void 0===h||h.addConstraint(t.constraint)}catch(t){this.Et=void 0;break}}Vt(t){t.constraint=t.enabled?this.At(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.Ht(t.lhs,t.rhs,t.relation,t.priority)}At(t,i,s,e,r){var h,n;try{null===(h=this.Et)||void 0===h||h.removeConstraint(t)}catch(t){this.Et=void 0}const o=this.Ht(i,s,e,r);try{null===(n=this.Et)||void 0===n||n.addConstraint(o)}catch(t){this.Et=void 0}return o}Ht(t,i,s,e){return new z(this.Bt(t),(t=>{switch(t){case jt.EQUAL:return N.Eq;case jt.LESS_THAN:return N.Le;case jt.GREATER_THAN:return N.Ge;default:throw Error("convertRelation.relation: invalid relation")}})(s),this.Bt(i),Q(e))}Bt(t){return new O(...t.prepareTerms().map(t=>{let[i,s]=t;const e=this.Mt.get(i);if(void 0===e)throw Error("UISolverWrapper.convertExpression.expression: variable does not exist");return[s,e.variable]}),t.constant)}Rt(){if(this.Et)throw Error("UISolverWrapper.rebuildSolver: solver already exists");this.Et=new G;for(const t of this.Mt.values())t.constraint?this.Et.addConstraint(t.constraint):(this.Et.addEditVariable(t.variable,Q(t.priority)),this.Et.suggestValue(t.variable,t.value));for(const t of this.Tt.values())t.enabled&&this.Et.addConstraint(t.constraint);this.It=!0,this.dirty=!0}}(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.MODE_CHANGED="mode_changed",t.RENDERING="rendering"})(zt||(zt={}));const Gt=P.VISIBLE;class $t extends T{constructor(t){var i,s,e,r;super(),this.name="",this.inputWrapperInternal=new tt,this.Dt=new Ft;const h=null!==(i=t.width)&&void 0!==i?i:1024,n=null!==(s=t.height)&&void 0!==s?s:1024;this.Lt=new Wt(h,n),this.name=null!==(e=t.name)&&void 0!==e?e:"",this.kt=null!==(r=t.mode)&&void 0!==r?r:Gt,this.Ot=h>n?H.HORIZONTAL:H.VERTICAL,this.xVariable=this.Dt.createVariable(0,K.P0),this.yVariable=this.Dt.createVariable(0,K.P0),this.wVariable=this.Dt.createVariable(h,K.P0),this.hVariable=this.Dt.createVariable(n,K.P0)}get sceneWrapper(){return this.Lt}get solverWrapper(){return this.Dt}get inputWrapper(){return this.inputWrapperInternal}get x(){return this.Dt.readVariableValue(this.xVariable)}get y(){return this.Dt.readVariableValue(this.yVariable)}get width(){return this.Dt.readVariableValue(this.wVariable)}get height(){return this.Dt.readVariableValue(this.hVariable)}get mode(){return this.kt}get orientation(){return this.Ot}set mode(t){t!==this.kt&&(this.kt=t,this.emit(zt.MODE_CHANGED,this.kt,this))}resizeInternal(t,i){this.Dt.suggestVariableValue(this.wVariable,t),this.Dt.suggestVariableValue(this.hVariable,i),this.Lt.resize(t,i);const s=t>i?H.HORIZONTAL:H.VERTICAL;s!==this.Ot&&(this.Ot=s,this.emit(zt.ORIENTATION_CHANGED,this.Ot,this))}renderInternal(t,i){U(this.mode)&&(this.emit(zt.RENDERING,t,i,this),this.Lt.render(t)),this.Dt.dirty=!1,this.inputWrapperInternal.dirty=!1}}const Yt=1e-6;function Xt(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof $t}function qt(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function Zt(t){return"object"==typeof t&&null!==t&&"wVariable"in t&&"number"==typeof t.wVariable&&"hVariable"in t&&"number"==typeof t.hVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function Jt(){}function Kt(t,i,s){if(t instanceof $t)return t;if(Xt(t))return t.layer;if(i instanceof $t)return i;if(Xt(i))return i.layer;throw Error(s+": no valid subjects found")}function Qt(t,i,s){if(Xt(i))return i.layer;if(Xt(s))return s.layer;if(i instanceof $t)return i;if(s instanceof $t)return s;throw Error(t+": no valid subjects found")}class ti{constructor(t,i){this.layer=t,this.solverWrapper=this.layer.solverWrapper,this.name=null!=i?i:""}}class ii extends ti{constructor(t,i){var s,e,r;super(t,null==i?void 0:i.name),this.Wt=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.Nt=null!=(s=null==i?void 0:i.priority)?s:K.P0,this.jt=null!=(e=null==i?void 0:i.relation)?e:jt.EQUAL,this.Ot=null!=(r=null==i?void 0:i.orientation)?r:H.ALWAYS,this.layer.on(zt.ORIENTATION_CHANGED,this.Wt)}get priority(){return this.Nt}get relation(){return this.jt}get orientation(){return this.Ot}set priority(t){t!==this.Nt&&(this.Nt=t,this.solverWrapper.setConstraintPriority(this.constraint,this.Nt))}set relation(t){t!==this.jt&&(this.jt=t,this.solverWrapper.setConstraintRelation(this.constraint,this.jt))}set orientation(t){t!==this.Ot&&(this.Ot=t,this.Wt())}destroy(){this.layer.off(zt.ORIENTATION_CHANGED,this.Wt),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.Ot===H.ALWAYS||this.Ot===this.layer.orientation}}class si extends ii{constructor(t,i){let s=arguments.length>1&&void 0!==i?i:{};var e;super(t.layer,s),this.zt=t,this.Ft=null!==(e=s.height)&&void 0!==e?e:t.height,this.constraint=this.solverWrapper.createConstraint(new Nt(0,[[this.zt.hVariable,1]]),new Nt(this.Ft),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Ft}set height(t){this.Ft!==t&&(this.Ft=t,this.solverWrapper.setConstraintRHS(this.constraint,new Nt(t)))}}class ei extends ii{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n;super(Kt(t,i,"UIHorizontalDistanceConstraint.constructor"),e),this.Gt=t,this.$t=i,this.Yt=null!==(r=e.anchorA)&&void 0!==r?r:.5,this.Xt=null!==(h=e.anchorB)&&void 0!==h?h:.5,this.qt=null!==(n=e.distance)&&void 0!==n?n:0,this.constraint=this.solverWrapper.createConstraint(this.Zt(),new Nt(this.qt),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.qt}get anchorA(){return this.Yt}get anchorB(){return this.Xt}set distance(t){this.qt!==t&&(this.qt=t,this.solverWrapper.setConstraintRHS(this.constraint,new Nt(this.qt)))}set anchorA(t){this.Yt!==t&&(this.Yt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorB(t){this.Xt!==t&&(this.Xt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}Zt(){let t,i;if(Zt(this.Gt))t=new Nt(0,[[this.Gt.xVariable,1],[this.Gt.wVariable,this.Yt]]);else{if(!qt(this.Gt))throw Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");t=(new Nt).plus(this.Gt.xVariable,1)}if(Zt(this.$t))i=new Nt(0,[[this.$t.xVariable,1],[this.$t.wVariable,this.Xt]]);else{if(!qt(this.$t))throw Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");i=(new Nt).plus(this.$t.xVariable,1)}return Nt.minus(i,t)}}class ri extends ii{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:{};var h,n,o;const a=null!==(h=r.anchorA)&&void 0!==h?h:.5;super(Qt("UIHorizontalInterpolationConstraint.constructor",t,i),r),this.Gt=t,this.$t=i,this.Jt=s,this.Yt=a,this.Xt=a,this.Kt=null!==(n=r.anchorC)&&void 0!==n?n:.5,this.Qt=null!==(o=r.t)&&void 0!==o?o:.5,this.constraint=this.solverWrapper.createConstraint(this.Zt(),new Nt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.Qt}get anchorA(){return this.Yt}get anchorB(){return this.Xt}get anchorC(){return this.Kt}set t(t){this.Qt!==t&&(this.Qt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorA(t){this.Yt!==t&&(this.Yt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorB(t){this.Xt!==t&&(this.Xt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorC(t){this.Kt!==t&&(this.Kt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}Zt(){let t,i,s;if(Zt(this.Gt))t=new Nt(0,[[this.Gt.xVariable,1],[this.Gt.wVariable,this.Yt]]);else{if(!qt(this.Gt))throw Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Nt).plus(this.Gt.xVariable,1)}if(Zt(this.$t))i=new Nt(0,[[this.$t.xVariable,1],[this.$t.wVariable,this.Xt]]);else{if(!qt(this.$t))throw Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Nt).plus(this.$t.xVariable,1)}if(Zt(this.Jt))s=new Nt(0,[[this.Jt.xVariable,1],[this.Jt.wVariable,this.Kt]]);else{if(!qt(this.Jt))throw Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Nt).plus(this.Jt.xVariable,1)}const e=t.clone().multiply(1-this.Qt),r=i.clone().multiply(this.Qt);return Nt.minus(Nt.minus(s,e),r)}}class hi extends ii{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r;super(Kt(t,i,"UIHorizontalProportionConstraint.constructor"),e),this.Gt=t,this.$t=i,this.ti=null!==(r=e.proportion)&&void 0!==r?r:1,this.constraint=this.solverWrapper.createConstraint(new Nt(0),this.ii(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.ti}set proportion(t){this.ti!==t&&(this.ti=t,this.solverWrapper.setConstraintRHS(this.constraint,this.ii()))}ii(){return Nt.minus(new Nt(0,[[this.Gt.wVariable,this.ti]]),new Nt(0,[[this.$t.wVariable,1]]))}}class ni extends ii{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n;super(Kt(t,i,"UIVerticalDistanceConstraint.constructor"),e),this.Gt=t,this.$t=i,this.Yt=null!==(r=e.anchorA)&&void 0!==r?r:.5,this.Xt=null!==(h=e.anchorB)&&void 0!==h?h:.5,this.qt=null!==(n=e.distance)&&void 0!==n?n:0,this.constraint=this.solverWrapper.createConstraint(this.Zt(),new Nt(this.qt),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.qt}get anchorA(){return this.Yt}get anchorB(){return this.Xt}set distance(t){this.qt!==t&&(this.qt=t,this.solverWrapper.setConstraintRHS(this.constraint,new Nt(this.qt)))}set anchorA(t){this.Yt!==t&&(this.Yt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorB(t){this.Xt!==t&&(this.Xt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}Zt(){let t,i;if(Zt(this.Gt))t=new Nt(0,[[this.Gt.yVariable,1],[this.Gt.hVariable,this.Yt]]);else{if(!qt(this.Gt))throw Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");t=(new Nt).plus(this.Gt.yVariable,1)}if(Zt(this.$t))i=new Nt(0,[[this.$t.yVariable,1],[this.$t.hVariable,this.Xt]]);else{if(!qt(this.$t))throw Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");i=(new Nt).plus(this.$t.yVariable,1)}return Nt.minus(i,t)}}class oi extends ii{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:{};var h,n,o;const a=null!==(h=r.anchorA)&&void 0!==h?h:.5;super(Qt("UIVerticalInterpolationConstraint.constructor",t,i),r),this.Gt=t,this.$t=i,this.Jt=s,this.Yt=a,this.Xt=a,this.Kt=null!==(n=r.anchorC)&&void 0!==n?n:.5,this.Qt=null!==(o=r.t)&&void 0!==o?o:.5,this.constraint=this.solverWrapper.createConstraint(this.Zt(),new Nt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.Qt}get anchorA(){return this.Yt}get anchorB(){return this.Xt}get anchorC(){return this.Kt}set t(t){this.Qt!==t&&(this.Qt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorA(t){this.Yt!==t&&(this.Yt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorB(t){this.Xt!==t&&(this.Xt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}set anchorC(t){this.Kt!==t&&(this.Kt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}Zt(){let t,i,s;if(Zt(this.Gt))t=new Nt(0,[[this.Gt.yVariable,1],[this.Gt.hVariable,this.Yt]]);else{if(!qt(this.Gt))throw Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Nt).plus(this.Gt.yVariable,1)}if(Zt(this.$t))i=new Nt(0,[[this.$t.yVariable,1],[this.$t.hVariable,this.Xt]]);else{if(!qt(this.$t))throw Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Nt).plus(this.$t.yVariable,1)}if(Zt(this.Jt))s=new Nt(0,[[this.Jt.yVariable,1],[this.Jt.hVariable,this.Kt]]);else{if(!qt(this.Jt))throw Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Nt).plus(this.Jt.yVariable,1)}const e=t.clone().multiply(1-this.Qt),r=i.clone().multiply(this.Qt);return Nt.minus(Nt.minus(s,e),r)}}class ai extends ii{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r;super(Kt(t,i,"UIVerticalProportionConstraint.constructor"),e),this.Gt=t,this.$t=i,this.ti=null!==(r=e.proportion)&&void 0!==r?r:1,this.constraint=this.solverWrapper.createConstraint(new Nt(0),this.ii(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.ti}set proportion(t){this.ti!==t&&(this.ti=t,this.solverWrapper.setConstraintRHS(this.constraint,this.ii()))}ii(){return Nt.minus(new Nt(0,[[this.Gt.hVariable,this.ti]]),new Nt(0,[[this.$t.hVariable,1]]))}}class li extends ii{constructor(t,i){let s=arguments.length>1&&void 0!==i?i:{};var e;super(t.layer,s),this.zt=t,this.si=null!==(e=s.width)&&void 0!==e?e:t.width,this.constraint=this.solverWrapper.createConstraint(new Nt(0,[[this.zt.wVariable,1]]),new Nt(this.si),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.si}set width(t){this.si!==t&&(this.si=t,this.solverWrapper.setConstraintRHS(this.constraint,new Nt(t)))}}function ui(t){return void 0===t?{}:Array.isArray(t)?{h:t[0],v:t[1]}:"object"==typeof t&&null!==t&&("h"in t||"v"in t)?t:{h:t,v:t}}class ci{static size(t,i){let s=arguments.length>1&&void 0!==i?i:{};const e=ui(s.size),r=ui(s.priority),h=ui(s.relation),n=ui(s.orientation);return{h:new li(t,{width:e.h,priority:r.h,relation:h.h,orientation:n.h}),v:new si(t,{height:e.v,priority:r.v,relation:h.v,orientation:n.v})}}static distance(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};const r=ui(e.anchorA),h=ui(e.anchorB),n=ui(e.distance),o=ui(e.priority),a=ui(e.relation),l=ui(e.orientation);return{h:new ei(t,i,{anchorA:r.h,anchorB:h.h,distance:n.h,priority:o.h,relation:a.h,orientation:l.h}),v:new ni(t,i,{anchorA:r.v,anchorB:h.v,distance:n.v,priority:o.v,relation:a.v,orientation:l.v})}}static proportion(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};const r=ui(e.proportion),h=ui(e.priority),n=ui(e.relation),o=ui(e.orientation);return{h:new hi(t,i,{proportion:r.h,priority:h.h,relation:n.h,orientation:o.h}),v:new ai(t,i,{proportion:r.v,priority:h.v,relation:n.v,orientation:o.v})}}static interpolation(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:{};const h=ui(r.anchorA),n=ui(r.anchorB),o=ui(r.anchorC),a=ui(r.t),l=ui(r.priority),u=ui(r.relation),c=ui(r.orientation);return{h:new ri(t,i,s,{anchorA:h.h,anchorB:n.h,anchorC:o.h,t:a.h,priority:l.h,relation:u.h,orientation:c.h}),v:new oi(t,i,s,{anchorA:h.v,anchorB:n.v,anchorC:o.v,t:a.v,priority:l.v,relation:u.v,orientation:c.v})}}}class di extends ii{constructor(t,i){let s=arguments.length>1&&void 0!==i?i:{};var e;super(t.layer,s),this.zt=t,this.ei=null!==(e=s.aspect)&&void 0!==e?e:t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Zt(),new Nt(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.ei}set aspect(t){this.ei!==t&&(this.ei=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Zt()))}Zt(){return new Nt(0,[[this.zt.wVariable,1],[this.zt.hVariable,-this.ei]])}}const fi=.5;class vi{static build(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n,o;let a;return!0===e.keepActiveAspect&&(a=new di(i,{orientation:e.orientation})),{activeAspectConstraint:a,xConstraint:new ei(t,i,{anchorA:null!==(r=e.anchorH)&&void 0!==r?r:fi,anchorB:null!==(h=e.anchorH)&&void 0!==h?h:fi,orientation:e.orientation}),yConstraint:new ni(t,i,{anchorA:null!==(n=e.anchorV)&&void 0!==n?n:fi,anchorB:null!==(o=e.anchorV)&&void 0!==o?o:fi,orientation:e.orientation}),widthConstraint:new hi(t,i,{proportion:1,relation:jt.GREATER_THAN,orientation:e.orientation}),heightConstraint:new ai(t,i,{proportion:1,priority:K.P1,orientation:e.orientation})}}}const pi=.5;class wi{static build(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n,o;let a;return!0===e.keepActiveAspect&&(a=new di(i,{orientation:e.orientation})),{activeAspectConstraint:a,xConstraint:new ei(t,i,{anchorA:null!==(r=e.anchorH)&&void 0!==r?r:pi,anchorB:null!==(h=e.anchorH)&&void 0!==h?h:pi,orientation:e.orientation}),yConstraint:new ni(t,i,{anchorA:null!==(n=e.anchorV)&&void 0!==n?n:pi,anchorB:null!==(o=e.anchorV)&&void 0!==o?o:pi,orientation:e.orientation}),widthConstraint:new hi(t,i,{proportion:1,relation:jt.LESS_THAN,orientation:e.orientation}),heightConstraint:new ai(t,i,{proportion:1,priority:K.P1,orientation:e.orientation})}}}class gi extends ii{constructor(t,i,s,e){super(t,arguments.length>3&&void 0!==e?e:{}),this.ri=i,this.hi=s,this.constraint=this.solverWrapper.createConstraint(this.ri,this.hi,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.ri}get rhs(){return this.hi}setLHS(t){this.ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.ri)}setRHS(t){this.hi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.hi)}}class yi extends T{constructor(t,i){var s,e;const r=null!==(s=null==i?void 0:i.x)&&void 0!==s?s:0,h=null!==(e=null==i?void 0:i.y)&&void 0!==e?e:0;super(),this.layer=t,this.name="",this.solverWrapper=this.layer.solverWrapper,this.xVariable=this.solverWrapper.createVariable(r,K.P7),this.yVariable=this.solverWrapper.createVariable(h,K.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}var mi;(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(mi||(mi={}));const bi=.5,_i=mi.ROTATION_SCALE,xi=new h,Si=new p,Ei=new h,Ii=new o,Mi=new h(0,0,1);function Ci(t,i,s,e,r,h,n,o,a,l,u,c,d,f,v,p,w){const g=s-f-v,y=e-p-w,m=o*s*l,b=a*e*u,_=Math.cos(c),x=Math.sin(c),S=m*_-b*x,E=m*x+b*_,I=f*l,M=w*u,C=I*_-M*x,T=I*x+M*_;if(d===mi.POSITION_ROTATION_SCALE)xi.x=t+h-S+C,xi.y=i+n-E+T;else{const r=a*e;xi.x=t+o*s-S+h+C,xi.y=i+r-E+n+T}return xi.z=r,Ei.x=g*l,Ei.y=y*u,Si.setFromAxisAngle(Mi,c),Ii.compose(xi,Si,Ei),Ii}const Ti=new e;var Pi;(t=>{t[t.DIMENSIONS_CHANGED=0]="DIMENSIONS_CHANGED"})(Pi||(Pi={}));class Hi extends T{constructor(t){super(),this.ni=Ti,this.oi=2,this.ai=2,this.li=0,this.ui=0,this.ci=2,this.di=2,this.fi=!1,this.pi=1,this.wi=0,this.gi=0,this.yi=0,this.mi=0,this.bi=!1,this._i=!1,this.xi=!1,void 0!==t&&this.set(t)}get width(){return this.oi/this.pi}get height(){return this.ai/this.pi}get trimmedWidth(){return(this.fi?this.di:this.ci)/this.pi}get trimmedHeight(){return(this.fi?this.ci:this.di)/this.pi}get texture(){return this.ni}get rotated(){return this.fi}get scale(){return this.pi}get trim(){const t=this.pi;return{left:this.wi/t,right:this.gi/t,top:this.yi/t,bottom:this.mi/t}}get textureDirty(){return this.bi}get uvTransformDirty(){return this._i}get trimDirty(){return this.xi}setTextureDirtyFalse(){this.bi=!1}setUVTransformDirtyFalse(){this._i=!1}setTrimDirtyFalse(){this.xi=!1}calculateUVTransform(t){let i=arguments.length>0&&void 0!==t?t:new n;var s,e,r,h;const o=null!==(e=null===(s=this.ni.image)||void 0===s?void 0:s.naturalWidth)&&void 0!==e?e:2,a=null!==(h=null===(r=this.ni.image)||void 0===r?void 0:r.naturalHeight)&&void 0!==h?h:2;if(this.fi){const t=this.ci,s=t/a;i.set(0,this.di/o,this.li/o,-s,0,(a-this.ui-t)/a+s,0,0,1)}else i.set(this.ci/o,0,this.li/o,0,this.di/a,(a-this.ui-this.di)/a,0,0,1);return i}getResolution(t){return(arguments.length>0&&void 0!==t?t:new r).set(this.width,this.height)}set(t){const i=this.width,s=this.height;t instanceof e?this.Si(t):this.Ei(t),this.width===i&&this.height===s||this.emit(Pi.DIMENSIONS_CHANGED,this.width,this.height,this)}Si(t){var i,s,e,r;const h=null!==(s=null===(i=t.image)||void 0===i?void 0:i.naturalWidth)&&void 0!==s?s:2,n=null!==(r=null===(e=t.image)||void 0===e?void 0:e.naturalHeight)&&void 0!==r?r:2;this.oi=h,this.ai=n,this.texture!==t&&(this.ni=t,this.bi=!0),(0!==this.li||0!==this.ui||this.ci!==h||this.di!==n||1!==this.pi||this.fi)&&(this.li=0,this.ui=0,this.ci=h,this.di=n,this.fi=!1,this.pi=1,this._i=!0),0===this.wi&&0===this.gi&&0===this.yi&&0===this.mi||(this.wi=0,this.gi=0,this.yi=0,this.mi=0,this.xi=!0)}Ei(t){var i,s;this.oi=t.sourceSize.w,this.ai=t.sourceSize.h,this.texture!==t.texture&&(this.ni=t.texture,this.bi=!0);const e=null!==(i=t.scale)&&void 0!==i?i:1,r=null!==(s=t.rotated)&&void 0!==s&&s;0===this.li&&0===this.ui&&this.ci===t.frame.w&&this.di===t.frame.h&&this.pi===e&&this.fi===r||(this.li=t.frame.x,this.ui=t.frame.y,this.ci=t.frame.w,this.di=t.frame.h,this.pi=e,this.fi=r,this._i=!0);const h=t.spriteSourceSize,n=h.x,o=h.y,a=this.oi-h.x-h.w,l=this.ai-h.y-h.h;this.wi===n&&this.gi===a&&this.yi===o&&this.mi===l||(this.wi=n,this.gi=a,this.yi=o,this.mi=l,this.xi=!0)}}var Ai,Ui="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}";class Ri{constructor(t){var i,s,e,r,h,n,o,a;this.D=!0,this.Ii=null!==(i=null==t?void 0:t.x)&&void 0!==i?i:0,this.Mi=null!==(s=null==t?void 0:t.y)&&void 0!==s?s:0,this.Ci=null!==(e=null==t?void 0:t.anchorX)&&void 0!==e?e:bi,this.Ti=null!==(r=null==t?void 0:t.anchorY)&&void 0!==r?r:bi,this.Pi=null!==(h=null==t?void 0:t.scaleX)&&void 0!==h?h:1,this.Hi=null!==(n=null==t?void 0:t.scaleY)&&void 0!==n?n:1,this.Ai=null!==(o=null==t?void 0:t.rotation)&&void 0!==o?o:0,this.Ui=null!==(a=null==t?void 0:t.anchorMode)&&void 0!==a?a:_i}get x(){return this.Ii}get y(){return this.Mi}get anchorX(){return this.Ci}get anchorY(){return this.Ti}get scaleX(){return this.Pi}get scaleY(){return this.Hi}get angle(){return t.radToDeg(this.Ai)}get anchorMode(){return this.Ui}get rotation(){return this.Ai}get dirty(){return this.D}set x(t){t!==this.Ii&&(this.Ii=t,this.D=!0)}set y(t){t!==this.Mi&&(this.Mi=t,this.D=!0)}set anchorX(t){t!==this.Ci&&(this.Ci=t,this.D=!0)}set anchorY(t){t!==this.Ti&&(this.Ti=t,this.D=!0)}set scaleX(t){t!==this.Pi&&(this.Pi=t,this.D=!0)}set scaleY(t){t!==this.Hi&&(this.Hi=t,this.D=!0)}set angle(i){const s=t.degToRad(i);s!==this.Ai&&(this.Ai=s,this.D=!0)}set rotation(t){t!==this.Ai&&(this.Ai=t,this.D=!0)}set anchorMode(t){t!==this.Ui&&(this.Ui=t,this.D=!0)}setDirtyFalse(){this.D=!1}reset(){0===this.Ii&&0===this.Mi&&this.Ci===bi&&this.Ti===bi&&1===this.Pi&&1===this.Hi&&0===this.Ai||(this.Ii=0,this.Mi=0,this.Ci=bi,this.Ti=bi,this.Pi=1,this.Hi=1,this.Ai=0,this.D=!0)}copy(t){this.Ii===t.Ii&&this.Mi===t.Mi&&this.Ci===t.Ci&&this.Ti===t.Ti&&this.Pi===t.Pi&&this.Hi===t.Hi&&this.Ai===t.Ai&&this.Ui===t.Ui||(this.Ii=t.Ii,this.Mi=t.Mi,this.Ci=t.Ci,this.Ti=t.Ti,this.Pi=t.Pi,this.Hi=t.Hi,this.Ai=t.Ai,this.Ui=t.Ui,this.D=!0)}}class Vi{}class Bi extends Vi{constructor(t,i,s,e){super(),this.x=t,this.y=i,this.width=s,this.height=e}contains(t,i){return!(this.x>t||t>this.x+this.width||this.y>i||i>this.y+this.height)}}(t=>{t.PRESSED="pointerdown",t.MOVED="pointermove",t.RELEASED="pointerup",t.ENTERED="pointerenter",t.LEFT="pointerleave"})(Ai||(Ai={}));const Di=P.VISIBLE;class Li extends yi{constructor(t,i){var s,e,r,h;const n=null!==(s=null==i?void 0:i.width)&&void 0!==s?s:64,o=null!==(e=null==i?void 0:i.height)&&void 0!==e?e:32;super(t,i),this.Ri=!1,this.catchPointerDown=(t,i,s)=>this.handleInputEvent(t,i,s,Ai.PRESSED),this.catchPointerMove=(t,i,s)=>this.handleInputEvent(t,i,s,Ai.MOVED),this.catchPointerUp=(t,i,s)=>this.handleInputEvent(t,i,s,Ai.RELEASED),this.interactionArea=null!==(r=null==i?void 0:i.interactionArea)&&void 0!==r?r:new Bi(0,0,1,1),this.modeInternal=null!==(h=null==i?void 0:i.mode)&&void 0!==h?h:Di,this.inputWrapper=this.layer.inputWrapper,this.wVariable=this.solverWrapper.createVariable(n,K.P6),this.hVariable=this.solverWrapper.createVariable(o,K.P6),this.Vi=this.inputWrapper.createInputCatcher(this.catchPointerDown,this.catchPointerMove,this.catchPointerUp,0),this.inputWrapper.setActive(this.Vi,A(this.modeInternal))}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get oppositeX(){return this.x+this.width}get oppositeY(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get mode(){return this.modeInternal}get zIndex(){return this.inputWrapper.getZIndex(this.Vi)}set width(t){this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){this.solverWrapper.suggestVariableValue(this.hVariable,t)}set oppositeX(t){this.x=t-this.width}set oppositeY(t){this.y=t-this.height}set centerX(t){this.x=t-this.width/2}set centerY(t){this.y=t-this.height/2}set mode(t){if(this.modeInternal!==t){const i=A(t);this.inputWrapper.setActive(this.Vi,i),this.modeInternal=t}}set zIndex(t){this.inputWrapper.setZIndex(this.Vi,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.inputWrapper.destroyInputCatcher(this.Vi),super.destroy()}handleInputEvent(i,s,e,r){const h=this.interactionArea.contains(t.mapLinear(i,this.x,this.oppositeX,0,1),t.mapLinear(s,this.y,this.oppositeY,0,1));return h&&this.emit(r,i,s,e,this),this.Ri&&!h?this.emit(Ai.LEFT,i,s,e,this):!this.Ri&&h&&this.emit(Ai.ENTERED,i,s,e,this),this.Ri=h,this.modeInternal!==P.INTERACTIVE_TRANSPARENT&&h}}const ki=_t.BLEND;class Oi extends Li{constructor(t,i,s,e){var r,h;super(t,e),this.Bi=!1,this.Di=!1,this.micro=new Ri(null==e?void 0:e.micro),this.Li=null!==(r=null==e?void 0:e.transparencyMode)&&void 0!==r?r:ki,this.sceneWrapper=this.layer.sceneWrapper,this.planeHandler=this.sceneWrapper.createPlane(i,s,(new o).identity(),U(null!==(h=null==e?void 0:e.mode)&&void 0!==h?h:this.mode),this.Li),this.layer.on(zt.RENDERING,this.onWillRender,this)}get transparencyMode(){return this.Li}set transparencyMode(t){this.Li!==t&&(this.Li=t,this.Bi=!0)}set mode(t){this.modeInternal!==t&&(this.Di=U(this.modeInternal)!==U(t),super.mode=t)}destroy(){this.layer.off(zt.RENDERING,this.onWillRender,this),this.sceneWrapper.destroyPlane(this.planeHandler),super.destroy()}setPlaneTransform(){(this.micro.dirty||this.inputWrapper.dirty||this.solverWrapper.dirty)&&(this.sceneWrapper.setTransform(this.planeHandler,((t,i,s,e,r,h,n,o,a,l,u,c,d)=>{const f=s*this.micro.scaleX,v=e*this.micro.scaleY,p=o*f,w=a*v,g=Math.cos(c),y=Math.sin(c),m=p*g-w*y,b=p*y+w*g;if(d===mi.POSITION_ROTATION_SCALE)xi.x=t+h-m,xi.y=i+n-b;else{const r=a*e;xi.x=t+o*s-m+h,xi.y=i+r-b+n}return xi.z=r,Ei.x=f,Ei.y=v,Si.setFromAxisAngle(Mi,c),Ii.compose(xi,Si,Ei),Ii})(this.x,this.y,this.width,this.height,this.zIndex,this.micro.x,this.micro.y,this.micro.anchorX,this.micro.anchorY,0,0,this.micro.rotation,this.micro.anchorMode)),this.micro.setDirtyFalse())}onWillRender(t,i){this.Bi&&(this.sceneWrapper.setTransparency(this.planeHandler,this.Li),this.Bi=!1),this.Di&&(this.sceneWrapper.setVisibility(this.planeHandler,U(this.modeInternal)),this.Di=!1),this.setPlaneTransform()}}var Wi,Ni;(t=>{t[t.PLAYED=0]="PLAYED",t[t.PAUSED=1]="PAUSED",t[t.STOPPED=2]="STOPPED"})(Wi||(Wi={})),(t=>{t[t.NONE=0]="NONE",t[t.LOOP=1]="LOOP",t[t.PING_PONG=2]="PING_PONG"})(Ni||(Ni={}));const ji=Ni.LOOP;class zi extends Oi{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n,o,a;const l=new rt(e.color),u=i.map(t=>new Hi(t)),c=u[0];e.width=null!==(r=e.width)&&void 0!==r?r:c.width,e.height=null!==(h=e.height)&&void 0!==h?h:c.height;const d=c.calculateUVTransform();super(t,Ui,{texture:c.texture,textureTransform:d,color:l},e),this.ki=!1,this.Oi=0,this.Wi=!1,this.Ni=0,this.ji=(t,i,s)=>{this.zi[this.Oi]===s&&(this.width=t,this.height=i)},this.Fi=l,this.zi=u,this.Gi=d,this.$i=null!==(n=e.frameRate)&&void 0!==n?n:24,this.Yi=null!==(o=e.timeScale)&&void 0!==o?o:1,this.Xi=null!==(a=e.loopMode)&&void 0!==a?a:ji,this.qi(),!0===e.playByDefault&&this.play()}get color(){return this.Fi}get duration(){return this.zi.length/this.$i}get frameRate(){return this.$i}get loopMode(){return this.Xi}get sequence(){return this.zi}get timeScale(){return this.Yi}set color(t){this.Fi.set(t)}set frameRate(t){this.$i=t}set loopMode(t){this.Xi=t}set sequence(t){this.stop(),this.Zi();const i=t.length,s=this.zi.length;for(let e=0;Math.min(i,s)>e;e++)this.zi[e].set(t[e]);if(s>i)this.zi.length=i;else if(i>s)for(let e=s;i>e;e++)this.zi.push(new Hi(t[e]));this.qi()}set timeScale(t){this.Yi=t}destroy(){this.Zi(),super.destroy()}play(){this.ki||(this.ki=!0,this.emit(Wi.PLAYED))}pause(){this.ki&&(this.ki=!1,this.emit(Wi.PAUSED))}stop(){(this.ki||this.Ni>0||this.Oi>0)&&(this.ki=!1,this.Ni=0,this.Oi=0,this.Wi=!0,this.emit(Wi.STOPPED))}onWillRender(t,i){if(this.ki&&0!==this.Yi){this.Ni+=i*this.Yi;const t=1/this.$i,s=this.zi.length,e=s-1;if(this.Yi>0)for(;this.Ni>=t;){if(this.Ni-=t,this.Oi+=1,this.Oi>=s)if(this.Xi===Ni.LOOP)this.Oi=0;else{if(this.Xi!==Ni.PING_PONG){this.Oi=e,this.ki=!1,this.emit(Wi.PAUSED);break}this.Oi=e,this.Yi=-this.Yi}this.Wi=!0}else for(;-t>=this.Ni;){if(this.Ni+=t,this.Oi-=1,0>this.Oi)if(this.Xi===Ni.LOOP)this.Oi=e;else{if(this.Xi!==Ni.PING_PONG){this.Oi=0,this.ki=!1,this.emit(Wi.PAUSED);break}this.Oi=0,this.Yi=-this.Yi}this.Wi=!0}}super.onWillRender(t,i)}setPlaneTransform(){let t;this.Fi.dirty&&(null!=t||(t={}),t.color=this.Fi,this.Fi.setDirtyFalse());const i=this.zi[this.Oi];if((i.textureDirty||this.Wi)&&(null!=t||(t={}),t.texture=i.texture,i.setTextureDirtyFalse()),(i.uvTransformDirty||this.Wi)&&(null!=t||(t={}),t.textureTransform=i.calculateUVTransform(this.Gi),i.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.Wi||this.micro.dirty||i.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,s=i.trim;this.sceneWrapper.setTransform(this.planeHandler,Ci(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,s.left,s.right,s.top,s.bottom)),this.Wi=!1,this.micro.setDirtyFalse(),i.setTrimDirtyFalse()}}qi(){for(const t of this.zi)t.on(Pi.DIMENSIONS_CHANGED,this.ji)}Zi(){for(const t of this.zi)t.off(Pi.DIMENSIONS_CHANGED,this.ji)}}function Fi(t,i){if(ht)return new OffscreenCanvas(t,i);const s=document.createElement("canvas");return s.width=t,s.height=i,s}function Gi(t){const i=new w(t,g,y,y,m,m,b,_,1);return i.colorSpace=nt?x:S,i.generateMipmaps=!1,i}const $i=new rt;class Yi extends Oi{constructor(t,i){var s,e;const r=null!==(s=null==i?void 0:i.width)&&void 0!==s?s:2,h=null!==(e=null==i?void 0:i.height)&&void 0!==e?e:2,o=new rt(null==i?void 0:i.color),a=Fi(r,h),l=a.getContext("2d");if(!l)throw Error("UIGraphics.constructor: failed to get 2D context from canvas");const u=Gi(a);u.needsUpdate=!0,super(t,Ui,{texture:u,textureTransform:new n,color:o},i),this.Ji=a,this.Ki=l,this.Qi=u,this.Fi=o}get color(){return this.Fi}set color(t){this.Fi.set(t)}clear(t){return this.Ki.clearRect(0,0,this.Ji.width,this.Ji.height),void 0!==t&&(this.Ki.fillStyle=$i.set(t).toCSSColor(),this.Ki.fillRect(0,0,this.Ji.width,this.Ji.height)),this.Qi.needsUpdate=!0,this}drawRect(t,i,s,e,r){return this.Ki.fillStyle=$i.set(r).toCSSColor(),this.Ki.fillRect(t,i,s,e),this.Qi.needsUpdate=!0,this}drawCircle(t,i,s,e){return this.Ki.fillStyle=$i.set(e).toCSSColor(),this.Ki.beginPath(),this.Ki.arc(t,i,s,0,2*Math.PI),this.Ki.fill(),this.Qi.needsUpdate=!0,this}drawArc(t,i,s,e,r,h){return this.Ki.fillStyle=$i.set(h).toCSSColor(),this.Ki.beginPath(),this.Ki.arc(t,i,s,e,r),this.Ki.fill(),this.Qi.needsUpdate=!0,this}drawPolyline(t,i,s){let e=arguments.length>2&&void 0!==s?s:1;if(2>t.length)return this;this.Ki.strokeStyle=$i.set(i).toCSSColor(),this.Ki.lineWidth=e,this.Ki.beginPath(),this.Ki.moveTo(t[0][0],t[0][1]);for(let i=1;t.length>i;i++)this.Ki.lineTo(t[i][0],t[i][1]);return this.Ki.stroke(),this.Qi.needsUpdate=!0,this}destroy(){this.Qi.dispose(),super.destroy()}onWillRender(t,i){this.Fi.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Fi}),this.Fi.setDirtyFalse()),super.onWillRender(t,i)}}class Xi extends Oi{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h;const n=new rt(e.color),o=new Hi(i),a=o.calculateUVTransform();e.width=null!==(r=e.width)&&void 0!==r?r:o.width,e.height=null!==(h=e.height)&&void 0!==h?h:o.height,super(t,Ui,{texture:o.texture,textureTransform:a,color:n},e),this.ji=(t,i)=>{this.width=t,this.height=i},this.texture=o,this.Gi=a,this.Fi=n,this.texture.on(Pi.DIMENSIONS_CHANGED,this.ji)}get color(){return this.Fi}set color(t){this.Fi.set(t)}destroy(){this.texture.off(Pi.DIMENSIONS_CHANGED,this.ji),super.destroy()}setPlaneTransform(){let t;if(this.Fi.dirty&&(null!=t||(t={}),t.color=this.Fi,this.Fi.setDirtyFalse()),this.texture.textureDirty&&(null!=t||(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(null!=t||(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Gi),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,Ci(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}}class qi{constructor(t){this.B=0,this.P=0,this.Qt=0,this.A=0,this.D=!1,this.set(t)}get left(){return this.B}get right(){return this.P}get top(){return this.Qt}get bottom(){return this.A}get dirty(){return this.D}set left(t){this.B!==t&&(this.B=t,this.D=!0)}set right(t){this.P!==t&&(this.P=t,this.D=!0)}set top(t){this.Qt!==t&&(this.Qt=t,this.D=!0)}set bottom(t){this.A!==t&&(this.A=t,this.D=!0)}setHorizontal(t){this.B===t&&this.P===t||(this.B=t,this.P=t,this.D=!0)}setVertical(t){this.Qt===t&&this.A===t||(this.Qt=t,this.A=t,this.D=!0)}setUnified(t){this.B===t&&this.P===t&&this.Qt===t&&this.A===t||(this.B=t,this.P=t,this.Qt=t,this.A=t,this.D=!0)}set(t){const i=this.B,s=this.P,e=this.Qt,r=this.A;if(void 0===t)this.B=0,this.P=0,this.Qt=0,this.A=0;else if("number"==typeof t)this.B=t,this.P=t,this.Qt=t,this.A=t;else if(Array.isArray(t))if(2===t.length){const i=t[0],s=t[1];this.B=i,this.P=i,this.Qt=s,this.A=s}else{const i=t[1],s=t[2],e=t[3];this.B=t[0],this.P=i,this.Qt=s,this.A=e}else if("left"in t){const i=t.right,s=t.top,e=t.bottom;this.B=t.left,this.P=i,this.Qt=s,this.A=e}else{const i=t.horizontal,s=t.vertical;this.B=i,this.P=i,this.Qt=s,this.A=s}this.B===i&&this.P===s&&this.Qt===e&&this.A===r||(this.D=!0)}setVector4(t){this.B===t.x&&this.P===t.y&&this.Qt===t.z&&this.A===t.w||(this.B=t.x,this.P=t.y,this.Qt=t.z,this.A=t.w,this.D=!0)}toVector4(t){return(arguments.length>0&&void 0!==t?t:new s).set(this.B,this.P,this.Qt,this.A)}reset(){this.setUnified(0)}copy(t){this.B===t.B&&this.P===t.P&&this.Qt===t.Qt&&this.A===t.A||(this.B=t.B,this.P=t.P,this.Qt=t.Qt,this.A=t.A,this.D=!0)}setDirtyFalse(){this.D=!1}}var Zi;(t=>{t[t.NORMALIZED=0]="NORMALIZED",t[t.WORLD=1]="WORLD"})(Zi||(Zi={}));const Ji=Zi.WORLD;class Ki extends Oi{constructor(t,i,e){let r=arguments.length>2&&void 0!==e?e:{};var h,n,o,a,l;const u=new rt(r.color),c=new Hi(i),d=c.calculateUVTransform();r.width=null!==(h=r.width)&&void 0!==h?h:c.width,r.height=null!==(n=r.height)&&void 0!==n?n:c.height;const f=new qi(null!==(o=r.sliceBorders)&&void 0!==o?o:.1),v=new qi(null!==(a=r.sliceRegions)&&void 0!==a?a:.1),p=null!==(l=r.regionMode)&&void 0!==l?l:Ji,w=new s,g=new s;super(t,"vec4 draw(){vec2 localUV=p_uv;float left=p_sliceBorders.x;float right=p_sliceBorders.y;float top=p_sliceBorders.z;float bottom=p_sliceBorders.w;float leftFill=p_sliceRegions.x;float rightFill=p_sliceRegions.y;float topFill=p_sliceRegions.z;float bottomFill=p_sliceRegions.w;float lB=leftFill;float rB=1.0-rightFill;float bB=bottomFill;float tB=1.0-topFill;{float regionL=step(p_uv.x,lB);float regionR=step(rB,p_uv.x);float regionM=1.0-regionL-regionR;float xL=(p_uv.x/lB)*left;float xR=1.0-right+((p_uv.x-rB)/rightFill)*right;float xM=left+((p_uv.x-lB)/(rB-lB))*(1.0-left-right);localUV.x=regionL*xL+regionM*xM+regionR*xR;}{float regionB=step(p_uv.y,bB);float regionT=step(tB,p_uv.y);float regionC=1.0-regionB-regionT;float yB=(p_uv.y/bB)*bottom;float yT=1.0-top+((p_uv.y-tB)/topFill)*top;float yC=bottom+((p_uv.y-bB)/(tB-bB))*(1.0-bottom-top);localUV.y=regionB*yB+regionC*yC+regionT*yT;}vec2 transformedUV=(p_textureTransform*vec3(localUV,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}",{texture:c.texture,textureTransform:d,color:u,sliceBorders:w,sliceRegions:g},r),this.ts=!0,this.ss=new s,this.es=new s,this.rs=!0,this.ji=()=>{this.rs=!0},this.texture=c,this.Gi=d,this.Fi=u,this.hs=f,this.ns=v,this.ls=p,this.ss=w,this.es=g,this.us=this.width,this.cs=this.height,this.texture.on(Pi.DIMENSIONS_CHANGED,this.ji)}get color(){return this.Fi}get regionMode(){return this.ls}get sliceBorders(){return this.hs}get sliceRegions(){return this.ns}set color(t){this.Fi.set(t)}set regionMode(t){this.ls!==t&&(this.ls=t,this.ts=!0)}set sliceBorders(t){this.hs.set(t)}set sliceRegions(t){this.ns.set(t)}destroy(){this.texture.off(Pi.DIMENSIONS_CHANGED,this.ji),super.destroy()}setPlaneTransform(){let t;if((this.rs||this.hs.dirty||this.texture.trimDirty)&&(null!=t||(t={}),t.sliceBorders=this.ds(this.ss),this.hs.setDirtyFalse(),this.rs=!1),(this.ns.dirty||this.ts||this.ls===Zi.WORLD&&this.fs())&&(null!=t||(t={}),t.sliceRegions=this.vs(this.es),this.ns.setDirtyFalse(),this.ts=!1,this.ps()),this.Fi.dirty&&(null!=t||(t={}),t.color=this.Fi,this.Fi.setDirtyFalse()),this.texture.textureDirty&&(null!=t||(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(null!=t||(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Gi),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,Ci(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}ds(t){const i=this.texture.width,s=this.texture.height,e=this.texture.trim,r=e.right/i,h=e.top/s,n=e.bottom/s,o=(i-e.left-e.right)/i,a=(s-e.top-e.bottom)/s,l=this.hs.right,u=this.hs.top,c=this.hs.bottom,d=Math.max(0,this.hs.left-e.left/i)/o,f=Math.max(0,l-r)/o,v=Math.max(0,u-h)/a,p=Math.max(0,c-n)/a;return t.set(Math.min(1,d),Math.min(1,f),Math.min(1,v),Math.min(1,p))}vs(t){if(this.ls===Zi.NORMALIZED)return t.set(this.ns.left,this.ns.right,this.ns.top,this.ns.bottom);const i=this.width,s=this.height;return t.set(this.ns.left/i,this.ns.right/i,this.ns.top/s,this.ns.bottom/s)}fs(){return this.solverWrapper.dirty&&(this.us!==Math.round(this.width)||this.cs!==Math.round(this.height))}ps(){this.us=Math.round(this.width),this.cs=Math.round(this.height)}}class Qi{constructor(t){this.source=t,this.dirtyInternal=!1}get dirty(){return this.dirtyInternal}setDirtyFalse(){this.dirtyInternal=!1}}class ts extends Qi{constructor(t){let i=arguments.length>0&&void 0!==t?t:{x:1,y:0};super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 halfExtents=vec2(aspect,1.0)*0.5;float maxProjection=dot(halfExtents,abs(p_direction));vec2 correctedUV=(p_uv-0.5)*vec2(aspect,1.0);float projection=dot(correctedUV,p_direction);float offset=(projection/maxProjection+1.0)*0.5;return step(offset,p_progress);}"),this.direction=new r,this.ws=new r,this.direction.set(i.x,i.y).normalize(),this.ws.copy(this.direction)}get dirty(){return this.gs(),this.dirtyInternal||!this.ws.equals(this.direction)}setDirtyFalse(){this.gs(),this.ws.copy(this.direction),super.setDirtyFalse()}enumerateProperties(){return this.gs(),{direction:this.direction}}gs(){const t=this.direction.lengthSq();Math.abs(t)>Yt?Math.abs(t-1)>Yt&&this.direction.divideScalar(t):this.direction.set(1,0)}}var is,ss="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;vec4 diffuseColor=srgbTexture2D(p_texture,transformedUV)*p_color;diffuseColor.a*=calculateMask();return diffuseColor;}";class es extends Oi{constructor(i,s,e){let r=arguments.length>2&&void 0!==e?e:{};var h,n,o,a;const l=new rt(r.color),u=new Hi(s),c=u.calculateUVTransform(),d=u.getResolution();r.width=null!==(h=r.width)&&void 0!==h?h:u.width,r.height=null!==(n=r.height)&&void 0!==n?n:u.height;const f=t.clamp(null!==(o=r.progress)&&void 0!==o?o:1,0,1),v=null!==(a=r.maskFunction)&&void 0!==a?a:new ts;super(i,v.source+ss,Object.assign({texture:u.texture,textureTransform:c,textureResolution:d,color:l,progress:f},v.enumerateProperties()),r),this.ys=!1,this.bs=!1,this.ji=(t,i)=>{this.width===t&&this.height===i||(this.width=t,this.height=i,this.bs=!0)},this.texture=u,this.Gi=c,this._s=d,this.Fi=l,this.xs=f,this.Ss=v,this.texture.on(Pi.DIMENSIONS_CHANGED,this.ji)}get color(){return this.Fi}get maskFunction(){return this.Ss}get progress(){return this.xs}set color(t){this.Fi.set(t)}set maskFunction(t){this.Ss!==t&&(this.Ss=t,this.Es())}set progress(i){i=t.clamp(i,0,1),this.xs!==i&&(this.xs=i,this.ys=!0)}setPlaneTransform(){let t;if(this.Fi.dirty&&(null!=t||(t={}),t.color=this.Fi,this.Fi.setDirtyFalse()),this.texture.textureDirty&&(null!=t||(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(null!=t||(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Gi),this.texture.setUVTransformDirtyFalse()),this.ys&&(null!=t||(t={}),t.progress=this.xs,this.ys=!1),this.bs&&(null!=t||(t={}),t.textureResolution=this.texture.getResolution(this._s),this.bs=!1),this.maskFunction.dirty){null!=t||(t={});const i=this.maskFunction.enumerateProperties();for(const s in i)t[s]=i[s];this.maskFunction.setDirtyFalse()}if(t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,Ci(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}Es(){this.sceneWrapper.destroyPlane(this.planeHandler);const t=this.micro,i=this.texture.trim;this.planeHandler=this.sceneWrapper.createPlane(this.Ss.source+ss,Object.assign({texture:this.texture.texture,textureTransform:this.texture.calculateUVTransform(this.Gi),textureResolution:this.texture.getResolution(this._s),color:this.Fi,progress:this.xs},this.Ss.enumerateProperties()),Ci(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom),U(this.mode),this.transparencyMode),this.Fi.setDirtyFalse(),this.texture.setTextureDirtyFalse(),this.texture.setUVTransformDirtyFalse(),this.texture.setTrimDirtyFalse(),this.ys=!1,this.bs=!1,this.Ss.setDirtyFalse(),this.micro.setDirtyFalse()}}(t=>{t[t.EVERY_FRAME=1]="EVERY_FRAME",t[t.EVERY_SECOND_FRAME=2]="EVERY_SECOND_FRAME",t[t.ON_PROPERTIES_CHANGE=3]="ON_PROPERTIES_CHANGE",t[t.ON_DIMENSIONS_CHANGE=4]="ON_DIMENSIONS_CHANGE",t[t.MANUAL=5]="MANUAL"})(is||(is={}));const rs=is.ON_PROPERTIES_CHANGE,hs=new rt(0,0,0,1);class ns extends Oi{constructor(i,s){let e=arguments.length>1&&void 0!==s?s:{};var r,h,o,a,l,u,c,d;const v=t.clamp(null!==(r=e.resolutionFactor)&&void 0!==r?r:.5,.1,2),p=null!==(h=e.width)&&void 0!==h?h:64,w=null!==(o=e.height)&&void 0!==o?o:32,g=new E(p*v,w*v,{format:b,minFilter:m,magFilter:m,type:_,depthBuffer:null===(a=e.enableDepthBuffer)||void 0===a||a,stencilBuffer:!1}),y=new rt(e.color);super(i,Ui,{texture:g.texture,textureTransform:new n,color:y},e),this.Is=!0,this.Ms=!1,this.Cs=!1,this.Ts=!1,this.Fi=y,this.Ps=new rt(null!==(l=e.clearColor)&&void 0!==l?l:hs),this.Hs=g,this.As=null!==(u=e.scene)&&void 0!==u?u:new f,this.Us=null!==(c=e.camera)&&void 0!==c?c:new I(60,p/w,.1,100),this.Rs=v,this.Vs=null!==(d=e.updateMode)&&void 0!==d?d:rs,this.Ts=e.updateMode!==is.MANUAL}get camera(){return this.Us}get clearColor(){return this.Ps}get color(){return this.Fi}get resolutionFactor(){return this.Rs}get scene(){return this.As}get updateMode(){return this.Vs}set camera(t){this.Us!==t&&(this.Us=t,this.Ts=!0)}set clearColor(t){this.Ps.set(t)}set color(t){this.Fi.set(t)}set resolutionFactor(i){i=t.clamp(i,.1,2),this.Rs!==i&&(this.Rs=i,this.Cs=!0)}set scene(t){this.As!==t&&(this.As=t,this.Ts=!0)}set updateMode(t){this.Vs!==t&&(this.Vs=t,this.Ts=!0)}destroy(){this.Hs.dispose(),super.destroy()}requestUpdate(){this.Ms=!0}onWillRender(t,i){this.Is=!this.Is,(this.Ms||this.Vs===is.EVERY_FRAME||this.Vs===is.EVERY_SECOND_FRAME&&this.Is||this.Vs===is.ON_PROPERTIES_CHANGE&&this.Ts||this.Fi.dirty||this.Ps.dirty||this.Vs===is.ON_DIMENSIONS_CHANGE&&(this.Cs||this.solverWrapper.dirty))&&((this.Cs||this.solverWrapper.dirty)&&(this.Hs.setSize(this.width*this.Rs,this.height*this.Rs),this.Cs=!1),this.Fi.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Fi}),this.Fi.setDirtyFalse()),t.setClearColor(this.Ps.getHexRGB(),this.Ps.a),t.setRenderTarget(this.Hs),t.clear(!0,!0,!1),t.render(this.As,this.Us),this.Ts=!1,this.Ms=!1),super.onWillRender(t,i)}}const os="#000000",as="left",ls="Arial",us="normal",cs="normal",ds=!1,fs="transparent",vs=!1,ps="#000000";class ws{constructor(t){this.D=!0,this.Fi=null==t?void 0:t.color,this.Bs=null==t?void 0:t.align,this.Ds=null==t?void 0:t.fontFamily,this.Ls=null==t?void 0:t.fontSize,this.ks=null==t?void 0:t.fontStyle,this.Os=null==t?void 0:t.fontWeight,this.Ws=null==t?void 0:t.lineHeight,this.Ns=null==t?void 0:t.enableShadow,this.js=null==t?void 0:t.shadowOffsetX,this.zs=null==t?void 0:t.shadowOffsetY,this.Fs=null==t?void 0:t.shadowBlur,this.Gs=null==t?void 0:t.shadowColor,this.$s=null==t?void 0:t.enableStroke,this.Ys=null==t?void 0:t.strokeColor,this.Xs=null==t?void 0:t.strokeThickness}get color(){return this.Fi}get align(){return this.Bs}get fontFamily(){return this.Ds}get fontSize(){return this.Ls}get fontStyle(){return this.ks}get fontWeight(){return this.Os}get lineHeight(){return this.Ws}get enableShadow(){return this.Ns}get shadowOffsetX(){return this.js}get shadowOffsetY(){return this.zs}get shadowBlur(){return this.Fs}get shadowColor(){return this.Gs}get enableStroke(){return this.$s}get strokeColor(){return this.Ys}get strokeThickness(){return this.Xs}get dirty(){return this.D}set color(t){t!==this.Fi&&(this.Fi=t,this.D=!0)}set align(t){t!==this.Bs&&(this.Bs=t,this.D=!0)}set fontFamily(t){t!==this.Ds&&(this.Ds=t,this.D=!0)}set fontSize(t){t!==this.Ls&&(this.Ls=t,this.D=!0)}set fontStyle(t){t!==this.ks&&(this.ks=t,this.D=!0)}set fontWeight(t){t!==this.Os&&(this.Os=t,this.D=!0)}set lineHeight(t){t!==this.Ws&&(this.Ws=t,this.D=!0)}set enableShadow(t){t!==this.Ns&&(this.Ns=t,this.D=!0)}set shadowOffsetX(t){t!==this.js&&(this.js=t,this.D=!0)}set shadowOffsetY(t){t!==this.zs&&(this.zs=t,this.D=!0)}set shadowBlur(t){t!==this.Fs&&(this.Fs=t,this.D=!0)}set shadowColor(t){t!==this.Gs&&(this.Gs=t,this.D=!0)}set enableStroke(t){t!==this.$s&&(this.$s=t,this.D=!0)}set strokeColor(t){t!==this.Ys&&(this.Ys=t,this.D=!0)}set strokeThickness(t){t!==this.Xs&&(this.Xs=t,this.D=!0)}static resolve(t,i){var s,e,r,h,n,o,a,l,u,c,d,f,v,p,w,g,y,m,b,_,x,S,E,I,M,C,T,P,H,A;const U=null!==(e=null!==(s=t.Ls)&&void 0!==s?s:i.Ls)&&void 0!==e?e:16;return{color:null!==(h=null!==(r=t.Fi)&&void 0!==r?r:i.Fi)&&void 0!==h?h:os,align:null!==(o=null!==(n=t.Bs)&&void 0!==n?n:i.Bs)&&void 0!==o?o:as,fontFamily:null!==(l=null!==(a=t.Ds)&&void 0!==a?a:i.Ds)&&void 0!==l?l:ls,fontSize:U,fontStyle:null!==(c=null!==(u=t.ks)&&void 0!==u?u:i.ks)&&void 0!==c?c:us,fontWeight:null!==(f=null!==(d=t.Os)&&void 0!==d?d:i.Os)&&void 0!==f?f:cs,lineHeight:null!==(p=null!==(v=t.Ws)&&void 0!==v?v:i.Ws)&&void 0!==p?p:1.2*U,enableShadow:null!==(g=null!==(w=t.Ns)&&void 0!==w?w:i.Ns)&&void 0!==g?g:ds,shadowOffsetX:null!==(m=null!==(y=t.js)&&void 0!==y?y:i.js)&&void 0!==m?m:0,shadowOffsetY:null!==(_=null!==(b=t.zs)&&void 0!==b?b:i.zs)&&void 0!==_?_:0,shadowBlur:null!==(S=null!==(x=t.Fs)&&void 0!==x?x:i.Fs)&&void 0!==S?S:0,shadowColor:null!==(I=null!==(E=t.Gs)&&void 0!==E?E:i.Gs)&&void 0!==I?I:fs,enableStroke:null!==(C=null!==(M=t.$s)&&void 0!==M?M:i.$s)&&void 0!==C?C:vs,strokeColor:null!==(P=null!==(T=t.Ys)&&void 0!==T?T:i.Ys)&&void 0!==P?P:ps,strokeThickness:null!==(A=null!==(H=t.Xs)&&void 0!==H?H:i.Xs)&&void 0!==A?A:0}}setDirtyFalse(){this.D=!1}setDefaults(){this.Fi===os&&this.Bs===as&&this.Ds===ls&&16===this.Ls&&this.ks===us&&this.Os===cs&&19.2===this.Ws&&this.Ns===ds&&0===this.js&&0===this.zs&&0===this.Fs&&this.Gs===fs&&this.$s===vs&&this.Ys===ps&&0===this.Xs||(this.Fi=os,this.Bs=as,this.Ds=ls,this.Ls=16,this.ks=us,this.Os=cs,this.Ws=19.2,this.Ns=ds,this.js=0,this.zs=0,this.Fs=0,this.Gs=fs,this.$s=vs,this.Ys=ps,this.Xs=0,this.D=!0)}clear(){void 0===this.Fi&&void 0===this.Bs&&void 0===this.Ds&&void 0===this.Ls&&void 0===this.ks&&void 0===this.Os&&void 0===this.Ws&&void 0===this.Ns&&void 0===this.js&&void 0===this.zs&&void 0===this.Fs&&void 0===this.Gs&&void 0===this.$s&&void 0===this.Ys&&void 0===this.Xs||(this.Fi=void 0,this.Bs=void 0,this.Ds=void 0,this.Ls=void 0,this.ks=void 0,this.Os=void 0,this.Ws=void 0,this.Ns=void 0,this.js=void 0,this.zs=void 0,this.Fs=void 0,this.Gs=void 0,this.$s=void 0,this.Ys=void 0,this.Xs=void 0,this.D=!0)}copy(t){this.Fi===t.Fi&&this.Bs===t.Bs&&this.Ds===t.Ds&&this.Ls===t.Ls&&this.ks===t.ks&&this.Os===t.Os&&this.Ws===t.Ws&&this.Ns===t.Ns&&this.js===t.js&&this.zs===t.zs&&this.Fs===t.Fs&&this.Gs===t.Gs&&this.$s===t.$s&&this.Ys===t.Ys&&this.Xs===t.Xs||(this.Fi=t.Fi,this.Bs=t.Bs,this.Ds=t.Ds,this.Ls=t.Ls,this.ks=t.ks,this.Os=t.Os,this.Ws=t.Ws,this.Ns=t.Ns,this.js=t.js,this.zs=t.zs,this.Fs=t.Fs,this.Gs=t.Gs,this.$s=t.$s,this.Ys=t.Ys,this.Xs=t.Xs,this.D=!0)}calculatePadding(){var t,i,s,e;let r=0;if(void 0!==this.$s&&(r+=null!==(t=this.Xs)&&void 0!==t?t:0),void 0!==this.Ns){const t=null!==(i=this.Fs)&&void 0!==i?i:0,h=null!==(s=this.js)&&void 0!==s?s:0,n=null!==(e=this.zs)&&void 0!==e?e:0,o=2*t;r+=Math.max(Math.abs(h)+o,Math.abs(n)+o)}return Math.ceil(r)}}class gs{constructor(t){this.D=!0,this.qs=t.text,this.style=new ws(t.style)}get text(){return this.qs}get dirty(){return this.D||this.style.dirty}set text(t){t!==this.qs&&(this.qs=t,this.D=!0)}setDirtyFalse(){this.D=!1,this.style.setDirtyFalse()}}var ys;(t=>{t[t.BREAK=0]="BREAK",t[t.SCALE=1]="SCALE"})(ys||(ys={}));const ms=ys.SCALE;function bs(t){var i;return null!==(i=t.match(/\S+|\s|\n/g))&&void 0!==i?i:[]}function _s(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px "${s.fontFamily}"`,"\n"===i)return{width:1,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const e=t.measureText(i);return{width:Math.ceil(e.width),height:Math.ceil(e.actualBoundingBoxAscent+e.actualBoundingBoxDescent),baseline:e.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function xs(t,i){const s=((t,i)=>{const s=[];let e=[],r=0,h=0,n=0,o=0;for(const a of i)"\n"!==a.text?0!==e.length&&r+a.metrics.width>t?(s.push({chunks:e,width:r,height:h,baseline:n,lineHeight:o}),e=[a],r=a.metrics.width,h=a.metrics.height,n=a.metrics.baseline,o=a.metrics.lineHeight):(e.push(a),r+=a.metrics.width,h=Math.max(h,a.metrics.height),n=Math.max(n,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(e.length>0&&s.push({chunks:e,width:r,height:h,baseline:n,lineHeight:o}),e=[],r=0,h=0,n=0,o=0);return e.length>0&&s.push({chunks:e,width:r,height:h,baseline:n,lineHeight:o}),s})(i,t),e=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let s=0;for(let i=0;t.length>i;i++){const e=t[i];s+=0===i?e.height:e.lineHeight}return{width:i,height:s}})(s);return{lines:s,size:e}}function Ss(t,i,s,e,r){r.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize}px "${e.fontFamily}"`,e.enableShadow&&(r.shadowOffsetX=e.shadowOffsetX,r.shadowOffsetY=e.shadowOffsetY,r.shadowBlur=e.shadowBlur,r.shadowColor=e.shadowColor),e.enableStroke&&(r.strokeStyle=e.strokeColor,r.lineWidth=e.strokeThickness,r.strokeText(s,t,i)),r.fillStyle=e.color,r.fillText(s,t,i)}function Es(t,i,s,e){var r,h;let n=t,o=0;for(const t of s)o=Math.max(t.width,o);for(let t=0;s.length>t;t++){const a=s[t],l=null!==(h=null===(r=a.chunks[0])||void 0===r?void 0:r.style.align)&&void 0!==h?h:as,u=a.chunks.every(t=>t.style.align===l)?l:as;let c=0;"center"===u?c=(o-a.width)/2:"right"===u&&(c=o-a.width);let d=i+c;n+=0===t?a.height:a.lineHeight;for(const t of a.chunks)Ss(d,n,t.text,t.style,e),d+=t.metrics.width}}class Is extends Oi{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h;const o=Fi(2,2),a=o.getContext("2d");if(!a)throw Error("UIText.constructor: failed to create canvas context");const l=Gi(o);l.needsUpdate=!0;const u=new rt(e.color);switch(super(t,Ui,{texture:l,textureTransform:new n,color:u}),this.Zs=[],this.Js=!1,this.Ks=!1,this.Qs=!1,this.te=[],this.ie=!1,this.Fi=u,this.se=new qi(e.padding),this.commonStyle=new ws(e.commonStyle),this.ee=null!==(r=e.maxLineWidth)&&void 0!==r?r:1024,this.re=null!==(h=e.resizeMode)&&void 0!==h?h:ms,this.Ji=o,this.Ki=a,this.Qi=l,this.content=i,this.he=this.width,this.ne=this.height,void 0===e.padding&&this.se.setUnified(this.content.reduce((t,i)=>Math.max(t,i.style.calculatePadding()),this.commonStyle.calculatePadding())),this.re){case ys.SCALE:this.oe();break;case ys.BREAK:this.ae()}}get color(){return this.Fi}get content(){return this.Zs}get maxLineWidth(){return this.ee}get padding(){return this.se}get resizeMode(){return this.re}set color(t){this.Fi.set(t)}set content(t){this.Zs!==t&&(this.Zs="string"==typeof t?[new gs({text:t,style:new ws})]:Array.isArray(t)?t.map(t=>new gs("string"==typeof t?{text:t,style:new ws}:{text:t.text,style:new ws(t.style)})):[new gs({text:t.text,style:new ws(t.style)})],this.Js=!0,this.ie=!0)}set maxLineWidth(t){this.ee!==t&&(this.ee=t,this.Ks=!0)}set padding(t){this.se.set(t)}set resizeMode(t){this.re!==t&&(this.re=t,this.Qs=!0)}destroy(){this.Qi.dispose(),super.destroy()}onWillRender(t,i){switch(this.re){case ys.SCALE:this.oe();break;case ys.BREAK:this.ae()}super.onWillRender(t,i)}oe(){if(!(this.Fi.dirty||this.Qs||this.Ks||this.se.dirty||this.solverWrapper.dirty&&this.he/this.ne!==Math.round(this.width)/Math.round(this.height)||this.le()))return;const t=this.ue(),{lines:i,size:s}=xs(t,this.ee),e=s.height+(this.se.top+this.se.bottom),r=s.width+(this.se.left+this.se.right);this.width=r,this.height=e/r*Math.round(this.width),this.width=r/e*Math.round(this.height);const h=this.he!==e||this.ne!==r;h&&(this.Ji.height=e,this.Ji.width=r),Es(this.se.top,this.se.left,i,this.Ki),this.ce(h),this.Qs=!1,this.Ks=!1,this.se.setDirtyFalse(),this.de(),this.fe()}ae(){if(!(this.Fi.dirty||this.Qs||this.Ks||this.se.dirty||this.ve()||this.le()))return;const t=this.ue(),{size:i}=xs(t,this.ee),s=this.se.top+this.se.bottom,e=this.se.left+this.se.right;this.height=i.height+s,this.width=i.width+e;const{lines:r,size:h}=xs(t,Math.round(this.width)-e);this.height=h.height+s,this.width=h.width+e;const n=Math.max(Math.round(this.width),2),o=Math.max(Math.round(this.height),2),a=this.he!==n||this.ne!==o;a&&(this.Ji.width=n,this.Ji.height=o),Es(this.se.top,this.se.left,r,this.Ki),this.ce(a),this.Qs=!1,this.Ks=!1,this.se.setDirtyFalse(),this.de(),this.fe()}ce(t){let i;this.Fi.dirty&&(null!=i||(i={}),i.color=this.Fi,this.Fi.setDirtyFalse()),t&&(this.Qi.dispose(),this.Qi=Gi(this.Ji),this.Qi.needsUpdate=!0,null!=i||(i={}),i.texture=this.Qi),i&&this.sceneWrapper.setProperties(this.planeHandler,i)}ue(){return this.ie&&(this.te=((t,i,s)=>{const e=[];for(const r of i){const i=ws.resolve(r.style,s);for(const s of bs(r.text)){const r=_s(t,s,i);e.push({text:s,style:i,metrics:r})}}return e})(this.Ki,this.Zs,this.commonStyle),this.ie=!1),this.te}ve(){return this.solverWrapper.dirty&&(this.he!==Math.round(this.width)||this.ne!==Math.round(this.height))}de(){this.he=Math.round(this.width),this.ne=Math.round(this.height)}le(){return this.Js||this.content.some(t=>t.dirty)}fe(){this.Js=!1;for(const t of this.content)t.setDirtyFalse()}}class Ms{constructor(){this.dirty=!1}}class Cs extends Ms{calculateScale(t,i){return 1}}const Ts=new Cs;class Ps extends $t{constructor(t){var i;const s=null!==(i=null==t?void 0:t.resizePolicy)&&void 0!==i?i:Ts,e=s.calculateScale(window.innerWidth,window.innerHeight);super(Object.assign({width:window.innerWidth*e,height:window.innerHeight*e},t)),this.pe=!1,this.we=()=>{const t=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight);this.resizePolicy.dirty=!1,this.pe=!1,this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.ge=t=>{this.ye(t,"onPointerDown",Ai.PRESSED)},this.me=t=>{this.ye(t,"onPointerMove",Ai.MOVED)},this.be=t=>{this.ye(t,"onPointerUp",Ai.RELEASED)},this._e=s,window.addEventListener("resize",this.we),window.addEventListener("pointerdown",this.ge),window.addEventListener("pointermove",this.me),window.addEventListener("pointerup",this.be)}get resizePolicy(){return this._e}set resizePolicy(t){this._e!==t&&(this._e=t,this.pe=!0)}destroy(){window.removeEventListener("resize",this.we),window.removeEventListener("pointerdown",this.ge),window.removeEventListener("pointermove",this.me),window.removeEventListener("pointerup",this.be)}render(t,i){(this.resizePolicy.dirty||this.pe)&&this.we(),super.renderInternal(t,i)}projectWorldPosition(i,s,e){let r=arguments.length>2&&void 0!==e?e:new h;return r.copy(i).project(s),r.x=t.mapLinear(r.x,-1,1,this.x,this.width),r.y=t.mapLinear(r.y,-1,1,this.y,this.height),r}projectLayerPosition(i,s,e,r){let n=arguments.length>2&&void 0!==e?e:-1;return(arguments.length>3&&void 0!==r?r:new h).set(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),n).unproject(s)}buildRay(i,s,e){let r=arguments.length>2&&void 0!==e?e:new M;const n=new h(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),-1).unproject(s),o=new h(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),1).unproject(s).sub(n).normalize();return r.set(n,o)}ye(t,i,s){const e=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,r=e?t.clientX-e.left:t.clientX,h=e?e.bottom-t.clientY:window.innerHeight-t.clientY,n=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight),o=r*n,a=h*n;A(this.mode)&&(this.emit(s,o,a,t.pointerId),this.inputWrapperInternal[i](o,a,t.pointerId))}}class Hs extends Vi{constructor(t,i,s){super(),this.centerX=t,this.centerY=i,this.radius=s}contains(t,i){const s=t-this.centerX,e=i-this.centerY;return this.radius*this.radius>=s*s+e*e}}class As extends Vi{constructor(t){super(),this.vertices=t}contains(t,i){const s=this.vertices.length;if(3>s)return!1;let e=!1;for(let r=0,h=s-1;s>r;h=r++){const s=this.vertices[r],n=this.vertices[h],o=s.x,a=s.y,l=n.y;a>i!=l>i&&(n.x-o)*(i-a)/(l-a)+o>t&&(e=!e)}return e}}class Us extends Vi{constructor(t,i,s,e,r){super(),this.x=t,this.y=i,this.width=s,this.height=e,this.radius=r,this.radius=Math.min(r,Math.min(s,e)/2)}contains(t,i){const s=this.x,e=this.x+this.width,r=this.y,h=this.y+this.height;if(s>t||t>e||r>i||i>h)return!1;const n=s+this.radius,o=e-this.radius,a=r+this.radius,l=h-this.radius;if(t>=n&&o>=t)return!0;if(i>=a&&l>=i)return!0;let u,c;u=n>t?n:o,c=a>i?a:l;const d=t-u,f=i-c;return this.radius*this.radius>=d*d+f*f}}class Rs extends Qi{constructor(t,i){let s=arguments.length>0&&void 0!==t?t:0,e=arguments.length>1&&void 0!==i&&i;super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 p=(p_uv-0.5)*vec2(aspect,1.0);float angle=atan(p.y,p.x);angle=(angle+PI)/(2.0*PI);float adjusted=angle-p_startAngle;adjusted=p_direction>0.0 ? adjusted :-adjusted;adjusted=fract(adjusted);return step(adjusted,p_progress);}"),this.xe=s,this.Se=e}get startAngle(){return this.xe}get inverseDirection(){return this.Se}set startAngle(t){this.xe!==t&&(this.xe=t,this.dirtyInternal=!0)}set inverseDirection(t){this.Se!==t&&(this.Se=t,this.dirtyInternal=!0)}enumerateProperties(){return{direction:this.Se?-1:1,startAngle:this.xe}}}class Vs extends Ms{constructor(t,i){super(),this.Ee=t,this.Ie=i}get rectWidth(){return this.Ee}get rectHeight(){return this.Ie}set rectWidth(t){t!==this.Ee&&(this.Ee=t,this.dirty=!0)}set rectHeight(t){t!==this.Ie&&(this.Ie=t,this.dirty=!0)}calculateScale(t,i){return Math.min(this.Ee/t,this.Ie/i)}}class Bs extends Ms{constructor(t,i){super(),this.Me=t,this.Ce=i}get fixedWidthLandscape(){return this.Me}get fixedHeightPortrait(){return this.Ce}set fixedWidthLandscape(t){t!==this.Me&&(this.Me=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.Ce&&(this.Ce=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.Me/t:this.Ce/i}}class Ds extends Ms{constructor(t,i){super(),this.Te=t,this.Pe=i}get fixedHeightLandscape(){return this.Te}get fixedWidthPortrait(){return this.Pe}set fixedHeightLandscape(t){t!==this.Te&&(this.Te=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.Pe&&(this.Pe=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.Te/i:this.Pe/t}}class Ls extends Ms{constructor(t,i){super(),this.Ee=t,this.Ie=i}get rectWidth(){return this.Ee}get rectHeight(){return this.Ie}set rectWidth(t){t!==this.Ee&&(this.Ee=t,this.dirty=!0)}set rectHeight(t){t!==this.Ie&&(this.Ie=t,this.dirty=!0)}calculateScale(t,i){return Math.max(this.Ee/t,this.Ie/i)}}class ks extends Ms{constructor(t,i){super(),this.Te=t,this.Ce=i}get fixedHeightLandscape(){return this.Te}get fixedHeightPortrait(){return this.Ce}set fixedHeightLandscape(t){t!==this.Te&&(this.Te=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.Ce&&(this.Ce=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.Te/i:this.Ce/i}}class Os extends Ms{constructor(t,i){super(),this.Me=t,this.Pe=i}get fixedWidthLandscape(){return this.Me}get fixedWidthPortrait(){return this.Pe}set fixedWidthLandscape(t){t!==this.Me&&(this.Me=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.Pe&&(this.Pe=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.Me/t:this.Pe/t}}export{yi as UIAnchor,zi as UIAnimatedImage,Ni as UIAnimatedImageLoopMode,Hs as UIAreaCircle,As as UIAreaPolygon,Bi as UIAreaRectangle,Us as UIAreaRoundedRectangle,di as UIAspectConstraint,rt as UIColor,ci as UIConstraint2DBuilder,vi as UICoverConstraintBuilder,gi as UICustomConstraint,Nt as UIExpression,wi as UIFitConstraintBuilder,Ps as UIFullscreenLayer,Yi as UIGraphics,si as UIHeightConstraint,ei as UIHorizontalDistanceConstraint,ri as UIHorizontalInterpolationConstraint,hi as UIHorizontalProportionConstraint,Xi as UIImage,Li as UIInputDummy,Ai as UIInputEvent,Ri as UIMicro,mi as UIMicroAnchorMode,P as UIMode,Ki as UINineSlice,Zi as UINineSliceRegionMode,H as UIOrientation,K as UIPriority,es as UIProgress,Rs as UIProgressMaskFunctionCircular,ts as UIProgressMaskFunctionDirectional,jt as UIRelation,Vs as UIResizePolicyCover,Bs as UIResizePolicyCross,Ds as UIResizePolicyCrossInverted,Ls as UIResizePolicyFit,ks as UIResizePolicyFixedHeight,Os as UIResizePolicyFixedWidth,Cs as UIResizePolicyNone,ns as UIScene,is as UISceneUpdateMode,ii as UISingleParameterConstraint,Is as UIText,ys as UITextResizeMode,_t as UITransparencyMode,ni as UIVerticalDistanceConstraint,oi as UIVerticalInterpolationConstraint,ai as UIVerticalProportionConstraint,li as UIWidthConstraint};
|
|
1
|
+
import{MathUtils as t,Color as i,Vector4 as s,Texture as e,Vector2 as h,Vector3 as r,Matrix3 as n,Matrix4 as o,PlaneGeometry as a,InstancedBufferGeometry as c,ShaderMaterial as u,InstancedBufferAttribute as l,Mesh as f,Scene as d,OrthographicCamera as p,Quaternion as w,CanvasTexture as g,UVMapping as v,ClampToEdgeWrapping as y,LinearFilter as m,RGBAFormat as x,UnsignedByteType as b,SRGBColorSpace as _,NoColorSpace as I,WebGLRenderTarget as S,PerspectiveCamera as E,Ray as M}from"three";class C{constructor(t,i,s=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,s):this.t.set(i,new Map([[t,s]])))}insert(t,i,s=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,s)}const e=this.t.get(i);void 0===e?this.t.set(i,new Map([[t,s]])):e.has(t)||e.set(t,s)}remove(t,i){if(void 0===i)return void this.i.delete(t);const s=this.t.get(i);void 0!==s&&(s.delete(t),0===s.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const s=this.t.get(i);return void 0!==s&&s.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const s=this.t.get(i);return void 0!==s?s.get(t):void 0}}class T{constructor(){this.o=new Map}on(t,i,s,e=0){return this.h(t,!1,e,i,s),this}once(t,i,s,e=0){return this.h(t,!0,e,i,s),this}off(t,i,s){const e=this.o.get(t);if(void 0===e)return this;e.u&&(e.u=!1,e.v=e.v.slice());const h=e.v;if(0===h.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;h.length>t;t++){const i=h[t];e.l.remove(i._,i.p)}return this}{const r=h.length;if(h[0]._===i&&h[0].p===s)return 1===r?this.o.delete(t):h.shift(),this;const n=r-1;if(h[n]._===i&&h[n].p===s)return h.pop(),this;if(10>r||h[0].M===h[n].M)for(let t=1;n>t;t++){const e=h[t];if(e._===i&&e.p===s)return h.splice(t,1),this}else{const t=e.l.getPriority(i,s);if(void 0===t)return this;let r=0,n=h.length-1;for(;n>=r;){const i=r+n>>>1;t>h[i].M?r=i+1:n=i-1}const o=r;for(n=h.length-1;n>=r;){const i=r+n>>>1;h[i].M>t?n=i-1:r=i+1}const a=n;for(let t=o;a>=t;t++)if(h[t]._===i&&h[t].p===s)return h.splice(t,1),this}}return this}emit(t,...i){const s=this.o.get(t);if(void 0===s)return!1;if(0===s.v.length)return!1;s.u?s.v=s.v.slice():s.u=!0;const e=s.v;let h=!1;for(let t=0;e.length>t;t++){const s=e[t];s._.apply(s.p,i),s.k&&(h=!0,s.m=!0)}const r=this.o.get(t);if(void 0===r)return!0;r.v===e&&(r.u=!1);const n=r.v;if(h){let i=0;for(let t=0;n.length>t;t++){const s=n[t];s.m?r.l.remove(s._,s.p):n[i++]=s}0===i?this.o.delete(t):n.length=i}return!0}h(t,i,s,e,h){let r=this.o.get(t);if(void 0===r)return void this.o.set(t,{v:[{_:e,p:h,M:s,k:i,m:!1}],u:!1,l:new C(e,h,s)});if(r.l.has(e,h))throw Error("Event listener already exists");r.l.insert(e,h,s);const n={_:e,p:h,M:s,k:i,m:!1};r.u&&(r.u=!1,r.v=r.v.slice());{const t=r.v,i=n.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(n);if(t[0].M>=i)return void t.unshift(n);{let s=0,e=t.length;for(;e>s;){const h=s+e>>>1;i>t[h].M?s=h+1:e=h}t.splice(s,0,n)}}}}var A,P;function U(t){return t===A.INTERACTIVE||t===A.INTERACTIVE_TRANSPARENT}function H(t){return t!==A.HIDDEN}function R(){return new B}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE",t[t.INTERACTIVE_TRANSPARENT=3]="INTERACTIVE_TRANSPARENT"})(A||(A={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(P||(P={}));class B{index={};array=[];size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const s=this.index[t.id()];if(void 0===s){const s=new V(t,i());return this.index[t.id()]=this.array.length,this.array.push(s),s}return this.array[s]}insert(t,i){const s=new V(t,i),e=this.index[t.id()];return void 0===e?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[e]=s,s}erase(t){const i=this.index[t.id()];if(void 0===i)return;this.index[t.id()]=void 0;const s=this.array[i],e=this.array.pop();return s!==e&&(this.array[i]=e,this.index[e.first.id()]=i),s}copy(){const t=new B;for(let i=0;this.array.length>i;i++){const s=this.array[i].copy();t.array[i]=s,t.index[s.first.id()]=i}return t}}class V{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new V(this.first,this.second)}}class L{constructor(t=""){this.I=t}id(){return this.S}name(){return this.I}setName(t){this.I=t}context(){return this.C}setContext(t){this.C=t}value(){return this.T}setValue(t){this.T=t}plus(t){return new k(this,t)}minus(t){return new k(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new k([t,this])}divide(t){return new k([1/t,this])}toJSON(){return{name:this.I,value:this.T}}toString(){return this.C+"["+this.I+":"+this.T+"]"}I;T=0;C=null;S=D++}let D=0;class k{constructor(){let t=(t=>{let i=0,s=()=>0,e=R();for(let h=0,r=t.length;r>h;++h){let r=t[h];if("number"==typeof r)i+=r;else if(r instanceof L)e.setDefault(r,s).second+=1;else if(r instanceof k){i+=r.constant();let t=r.terms();for(let i=0,h=t.size();h>i;i++){let h=t.itemAt(i);e.setDefault(h.first,s).second+=h.second}}else{if(!(r instanceof Array))throw Error("invalid Expression argument: "+r);{if(2!==r.length)throw Error("array must have length 2");let t=r[0],h=r[1];if("number"!=typeof t)throw Error("array item 0 must be a number");if(h instanceof L)e.setDefault(h,s).second+=t;else{if(!(h instanceof k))throw Error("array item 1 must be a variable or expression");{i+=h.constant()*t;let r=h.terms();for(let i=0,h=r.size();h>i;i++){let h=r.itemAt(i);e.setDefault(h.first,s).second+=h.second*t}}}}}}return{terms:e,constant:i}})(arguments);this.A=t.terms,this.P=t.constant}terms(){return this.A}constant(){return this.P}value(){let t=this.P;for(let i=0,s=this.A.size();s>i;i++){let s=this.A.itemAt(i);t+=s.first.value()*s.second}return t}plus(t){return new k(this,t)}minus(t){return new k(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new k([t,this])}divide(t){return new k([1/t,this])}isConstant(){return 0==this.A.size()}toString(){let t=this.A.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.P||(t+=" + "),t+=this.P,t}A;P}class W{static create(t,i,s,e=1){let h=0;return h+=1e6*Math.max(0,Math.min(1e3,t*e)),h+=1e3*Math.max(0,Math.min(1e3,i*e)),h+=Math.max(0,Math.min(1e3,s*e)),h}static required=W.create(1e3,1e3,1e3);static strong=W.create(1,0,0);static medium=W.create(0,1,0);static weak=W.create(0,0,1);static clip(t){return Math.max(0,Math.min(W.required,t))}}var $;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})($||($={}));class N{constructor(t,i,s,e=W.required){this.U=i,this.H=W.clip(e),this.R=void 0===s&&t instanceof k?t:t.minus(s)}id(){return this.S}expression(){return this.R}op(){return this.U}strength(){return this.H}toString(){return this.R+" "+["<=",">=","="][this.U]+" 0 ("+this.H+")"}R;U;H;S=z++}let z=0;class F{maxIterations=1e3;constructor(){}createConstraint(t,i,s,e=W.required){let h=new N(t,i,s,e);return this.addConstraint(h),h}addConstraint(t){if(void 0!==this.B.find(t))throw Error("duplicate constraint");let i=this.V(t),s=i.row,e=i.tag,h=this.L(s,e);if(h.type()===G.Invalid&&s.allDummies()){if(!O(s.constant()))throw Error("unsatisfiable constraint");h=e.marker}if(h.type()===G.Invalid){if(!this.D(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.W(h,s),this.$.insert(h,s);this.B.insert(t,e),this.N(this.F)}removeConstraint(t){let i=this.B.erase(t);if(void 0===i)throw Error("unknown constraint");this.O(t,i.second);let s=i.second.marker,e=this.$.erase(s);if(void 0===e){let t=this.G(s);if(t.type()===G.Invalid)throw Error("failed to find leaving row");e=this.$.erase(t),e.second.solveForEx(t,s),this.W(s,e.second)}this.N(this.F)}hasConstraint(t){return this.B.contains(t)}getConstraints(){return this.B.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.j.find(t))throw Error("duplicate edit variable");if((i=W.clip(i))===W.required)throw Error("bad required strength");let s=new k(t),e=new N(s,$.Eq,void 0,i);this.addConstraint(e);let h=this.B.find(e).second;this.j.insert(t,{tag:h,constraint:e,constant:0})}removeEditVariable(t){let i=this.j.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.j.contains(t)}suggestValue(t,i){let s=this.j.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this.$,h=s.second,r=i-h.constant;h.constant=i;let n=h.tag.marker,o=e.find(n);if(void 0!==o)return 0>o.second.add(-r)&&this.Y.push(n),void this.X();let a=h.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(r)&&this.Y.push(a),void this.X();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t),s=i.second,h=s.coefficientFor(n);0!==h&&0>s.add(r*h)&&i.first.type()!==G.External&&this.Y.push(i.first)}this.X()}updateVariables(){let t=this.q,i=this.$;for(let s=0,e=t.size();e>s;++s){let e=t.itemAt(s),h=i.find(e.second);e.first.setValue(void 0!==h?h.second.constant():0)}}Z(t){return this.q.setDefault(t,()=>this.J(G.External)).second}V(t){let i=t.expression(),s=new X(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!O(i.second)){let t=this.Z(i.first),e=this.$.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let h=this.F,r=t.strength(),n={marker:Y,other:Y};switch(t.op()){case $.Le:case $.Ge:{let i=t.op()===$.Le?1:-1,e=this.J(G.Slack);if(n.marker=e,s.insertSymbol(e,i),W.required>r){let t=this.J(G.Error);n.other=t,s.insertSymbol(t,-i),h.insertSymbol(t,r)}break}case $.Eq:if(W.required>r){let t=this.J(G.Error),i=this.J(G.Error);n.marker=t,n.other=i,s.insertSymbol(t,-1),s.insertSymbol(i,1),h.insertSymbol(t,r),h.insertSymbol(i,r)}else{let t=this.J(G.Dummy);n.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:n}}L(t,i){let s=t.cells();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t);if(i.first.type()===G.External)return i.first}let e=i.marker.type();return e!==G.Slack&&e!==G.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==G.Slack&&e!==G.Error||t.coefficientFor(i.other)>=0?Y:i.other):i.marker}D(t){let i=this.J(G.Slack);this.$.insert(i,t.copy()),this.K=t.copy(),this.N(this.K);let s=O(this.K.constant());this.K=null;let e=this.$.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let h=this.tt(t);if(h.type()===G.Invalid)return!1;t.solveForEx(i,h),this.W(h,t),this.$.insert(h,t)}let h=this.$;for(let t=0,s=h.size();s>t;++t)h.itemAt(t).second.removeSymbol(i);return this.F.removeSymbol(i),s}W(t,i){let s=this.$;for(let e=0,h=s.size();h>e;++e){let h=s.itemAt(e);h.second.substitute(t,i),0>h.second.constant()&&h.first.type()!==G.External&&this.Y.push(h.first)}this.F.substitute(t,i),this.K&&this.K.substitute(t,i)}N(t){let i=0;for(;this.maxIterations>i;){let s=this.it(t);if(s.type()===G.Invalid)return;let e=this.st(s);if(e.type()===G.Invalid)throw Error("the objective is unbounded");let h=this.$.erase(e).second;h.solveForEx(e,s),this.W(s,h),this.$.insert(s,h),i++}throw Error("solver iterations exceeded")}X(){let t=this.$,i=this.Y;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this.et(e.second);if(i.type()===G.Invalid)throw Error("dual optimize failed");let h=e.second;t.erase(s),h.solveForEx(s,i),this.W(i,h),t.insert(i,h)}}}it(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first;if(0>s.second&&e.type()!==G.Dummy)return e}return Y}et(t){let i=Number.MAX_VALUE,s=Y,e=t.cells();for(let t=0,h=e.size();h>t;++t){let h=e.itemAt(t),r=h.first,n=h.second;if(n>0&&r.type()!==G.Dummy){let t=this.F.coefficientFor(r)/n;i>t&&(i=t,s=r)}}return s}st(t){let i=Number.MAX_VALUE,s=Y,e=this.$;for(let h=0,r=e.size();r>h;++h){let r=e.itemAt(h),n=r.first;if(n.type()!==G.External){let e=r.second,h=e.coefficientFor(t);if(0>h){let t=-e.constant()/h;i>t&&(i=t,s=n)}}}return s}G(t){let i=Number.MAX_VALUE,s=i,e=i,h=Y,r=h,n=h,o=h,a=this.$;for(let i=0,h=a.size();h>i;++i){let h=a.itemAt(i),c=h.second,u=c.coefficientFor(t);if(0===u)continue;let l=h.first;if(l.type()===G.External)o=l;else if(0>u){let t=-c.constant()/u;s>t&&(s=t,r=l)}else{let t=c.constant()/u;e>t&&(e=t,n=l)}}return r!==h?r:n!==h?n:o}O(t,i){i.marker.type()===G.Error&&this.ht(i.marker,t.strength()),i.other.type()===G.Error&&this.ht(i.other,t.strength())}ht(t,i){let s=this.$.find(t);void 0!==s?this.F.insertRow(s.second,-i):this.F.insertSymbol(t,-i)}tt(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first.type();if(e===G.Slack||e===G.Error)return s.first}return Y}J(t){return new j(t,this.rt++)}B=(()=>R())();$=(()=>R())();q=(()=>R())();j=(()=>R())();Y=[];F=new X;K=null;rt=0}function O(t){return 0>t?1e-8>-t:1e-8>t}var G;(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})(G||(G={}));class j{constructor(t,i){this.S=i,this.nt=t}id(){return this.S}type(){return this.nt}S;nt}let Y=new j(G.Invalid,-1);class X{constructor(t=0){this.P=t}cells(){return this.ot}constant(){return this.P}isConstant(){return this.ot.empty()}allDummies(){let t=this.ot;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==G.Dummy)return!1;return!0}copy(){let t=new X(this.P);return t.ot=this.ot.copy(),t}add(t){return this.P+=t}insertSymbol(t,i=1){O(this.ot.setDefault(t,()=>0).second+=i)&&this.ot.erase(t)}insertRow(t,i=1){this.P+=t.P*i;let s=t.ot;for(let t=0,e=s.size();e>t;++t){let e=s.itemAt(t);this.insertSymbol(e.first,e.second*i)}}removeSymbol(t){this.ot.erase(t)}reverseSign(){this.P=-this.P;let t=this.ot;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this.ot,s=-1/i.erase(t).second;this.P*=s;for(let t=0,e=i.size();e>t;++t)i.itemAt(t).second*=s}solveForEx(t,i){this.insertSymbol(t,-1),this.solveFor(i)}coefficientFor(t){let i=this.ot.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this.ot.erase(t);void 0!==s&&this.insertRow(i,s.second)}ot=R();P}const q=1e3;var Z;function J(t){switch(t){case Z.P0:return W.create(q,q,q);case Z.P1:return W.create(100,0,0);case Z.P2:return W.create(10,0,0);case Z.P3:return W.create(0,100,0);case Z.P4:return W.create(0,10,0);case Z.P5:return W.create(0,0,100);case Z.P6:return W.create(0,0,10);case Z.P7:return W.create(0,0,1);default:throw Error("convertPriority.priority: invalid priority")}}(t=>{t[t.P0=0]="P0",t[t.P1=1]="P1",t[t.P2=2]="P2",t[t.P3=3]="P3",t[t.P4=4]="P4",t[t.P5=5]="P5",t[t.P6=6]="P6",t[t.P7=7]="P7"})(Z||(Z={}));class K{constructor(){this.dirty=!1,this.ct=!1,this.ut=[],this.lt=0}createInputCatcher(t,i,s,e){const h=this.lt++;return this.ut.push({handler:h,catchPointerDown:t,catchPointerMove:i,catchPointerUp:s,zIndex:e,active:!0}),this.ct=!0,this.dirty=!0,h}destroyInputCatcher(t){const i=this.ut.findIndex(i=>i.handler===t);if(-1===i)throw Error("UIInputWrapper.destroyInputCatcher.handler: handler not found");this.ut.splice(i,1)}getZIndex(t){this.ft();const i=this.ut.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getZIndex.handler: handler not found");return i.zIndex}setZIndex(t,i){const s=this.ut.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setZIndex.handler: handler not found");s.zIndex!==i&&(s.zIndex=i,this.ct=!0,this.dirty=!0)}getActive(t){const i=this.ut.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getActive.handler: handler not found");return i.active}setActive(t,i){const s=this.ut.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setActive.handler: handler not found");s.active!==i&&(s.active=i)}onPointerDown(t,i,s){this.ft();for(let e=this.ut.length-1;e>=0;e--){const h=this.ut[e];if(h.active&&h.catchPointerDown(t,i,s))break}}onPointerMove(t,i,s){this.ft();for(let e=this.ut.length-1;e>=0;e--){const h=this.ut[e];if(h.active&&h.catchPointerMove(t,i,s))break}}onPointerUp(t,i,s){this.ft();for(let e=this.ut.length-1;e>=0;e--){const h=this.ut[e];if(h.active&&h.catchPointerUp(t,i,s))break}}ft(){if(this.ct){this.ut.sort((t,i)=>t.zIndex-i.zIndex);const t=this.ut.length,i=1024>t?1:1024/t;for(let s=0;t>s;s++)this.ut[s].zIndex=s*i;this.ct=!1}}}function Q(t){return.04045>t?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function tt(t){return.0031308>t?12.92*t:1.055*Math.pow(t,.41666)-.055}const it={black:0,white:16777215,red:16711680,green:32768,blue:255,yellow:16776960,cyan:65535,magenta:16711935,gray:8421504,grey:8421504,silver:12632256,maroon:8388608,olive:8421376,lime:65280,aqua:65535,teal:32896,navy:128,fuchsia:16711935,purple:8388736,orange:16753920,pink:16761035,brown:10824234,gold:16766720,violet:15631086,indigo:4915330,coral:16744272,salmon:16416882,khaki:15787660,plum:14524637,orchid:14315734,tan:13808780,beige:16119260,mint:10025880,lavender:15132410,crimson:14423100,azure:15794175,ivory:16777200,snow:16775930};class st{constructor(...t){this.dt=1,this.wt=1,this.gt=1,this.vt=1,this.yt=0,this.xt=0,this.bt=1,this._t=!1,this.It=!1,this.St=!1,t.length>0&&this.set(...t)}static get black(){return new st("black")}static get white(){return new st("white")}static get red(){return new st("red")}static get green(){return new st("green")}static get blue(){return new st("blue")}static get yellow(){return new st("yellow")}static get cyan(){return new st("cyan")}static get magenta(){return new st("magenta")}static get gray(){return new st("gray")}static get grey(){return new st("grey")}static get silver(){return new st("silver")}static get maroon(){return new st("maroon")}static get olive(){return new st("olive")}static get lime(){return new st("lime")}static get aqua(){return new st("aqua")}static get teal(){return new st("teal")}static get navy(){return new st("navy")}static get fuchsia(){return new st("fuchsia")}static get purple(){return new st("purple")}static get orange(){return new st("orange")}static get pink(){return new st("pink")}static get brown(){return new st("brown")}static get gold(){return new st("gold")}static get violet(){return new st("violet")}static get indigo(){return new st("indigo")}static get coral(){return new st("coral")}static get salmon(){return new st("salmon")}static get khaki(){return new st("khaki")}static get plum(){return new st("plum")}static get orchid(){return new st("orchid")}static get tan(){return new st("tan")}static get beige(){return new st("beige")}static get mint(){return new st("mint")}static get lavender(){return new st("lavender")}static get crimson(){return new st("crimson")}static get azure(){return new st("azure")}static get ivory(){return new st("ivory")}static get snow(){return new st("snow")}get r(){return this.Et(),this.dt}get g(){return this.Et(),this.wt}get b(){return this.Et(),this.gt}get a(){return this.vt}get hue(){return this.Mt(),this.yt}get saturation(){return this.Mt(),this.xt}get lightness(){return this.Mt(),this.bt}get dirty(){return this._t}set r(i){i=t.clamp(i,0,1),this.Et(),i!==this.dt&&(this.dt=i,this.St=!0,this._t=!0)}set g(i){i=t.clamp(i,0,1),this.Et(),i!==this.wt&&(this.wt=i,this.St=!0,this._t=!0)}set b(i){i=t.clamp(i,0,1),this.Et(),i!==this.gt&&(this.gt=i,this.St=!0,this._t=!0)}set a(i){(i=t.clamp(i,0,1))!==this.vt&&(this.vt=i,this._t=!0)}set hue(i){i=t.clamp(i,0,360),this.Mt(),i!==this.yt&&(this.yt=i,this.It=!0,this._t=!0)}set saturation(i){i=t.clamp(i,0,1),this.Mt(),i!==this.xt&&(this.xt=i,this.It=!0,this._t=!0)}set lightness(i){i=t.clamp(i,0,1),this.Mt(),i!==this.bt&&(this.bt=i,this.It=!0,this._t=!0)}setDirtyFalse(){this._t=!1}set(...t){if(0===t.length||void 0===t[0])return this.setRGBA(1,1,1,1);if(t.length>=3&&"number"==typeof t[0]){const[i,s,e,h=1]=t;return this.setRGBA(i,s,e,h)}const[s,e=1]=t;if("string"==typeof s)return s.startsWith("#")?this.setHexString(s):this.setColorName(s,e);if(s instanceof st)return this.copy(s);if(s instanceof i)return this.setThreeColor(s,e);if("number"==typeof s)return this.setHexRGB(s,e);throw Error("UIColor.set: cannot create color from provided arguments")}setRGBA(i,s,e,h=this.vt){return i=t.clamp(i,0,1),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.Et(),i===this.dt&&s===this.wt&&e===this.gt&&h===this.vt||(this.dt=i,this.wt=s,this.gt=e,this.vt=h,this.St=!0,this._t=!0),this}getHexRGBA(){return this.Et(),Math.round(255*this.dt)<<24|Math.round(255*this.wt)<<16|Math.round(255*this.gt)<<8|Math.round(255*this.vt)}getHexRGB(){return this.Et(),Math.round(255*this.dt)<<16|Math.round(255*this.wt)<<8|Math.round(255*this.gt)}getHexStringRGB(){return"#"+this.getHexRGB().toString(16).padStart(6,"0")}getHexStringRGBA(){return"#"+this.getHexRGBA().toString(16).padStart(8,"0")}setHexRGBA(t){this.Et();const i=(t>>16&255)/255,s=(t>>8&255)/255,e=(255&t)/255,h=(t>>24&255)/255;return i===this.dt&&s===this.wt&&e===this.gt&&h===this.vt||(this.dt=i,this.wt=s,this.gt=e,this.vt=h,this.St=!0,this._t=!0),this}setHexRGB(i,s=this.vt){s=t.clamp(s,0,1),this.Et();const e=(i>>16&255)/255,h=(i>>8&255)/255,r=(255&i)/255;return e===this.dt&&h===this.wt&&r===this.gt&&s===this.vt||(this.dt=e,this.wt=h,this.gt=r,this.vt=s,this.St=!0,this._t=!0),this}setHexString(t){if(!t.startsWith("#"))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');const i=t.slice(1);if(6===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGB(t)}if(8===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGBA(t)}throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"')}setHSL(i,s,e,h=this.vt){return i=t.clamp(i,0,360),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.Mt(),i===this.yt&&s===this.xt&&e===this.bt&&h===this.vt||(this.yt=i,this.xt=s,this.bt=e,this.vt=h,this.It=!0,this._t=!0),this}setColorName(i,s=this.vt){s=t.clamp(s,0,1);const e=i.toLowerCase().trim(),h=it[e];if(void 0===h)throw Error("UIColor.setColorName.colorName: unknown color name");return this.setHexRGB(h,s)}setGLSLColor(i,s,e,h=this.vt){h=t.clamp(h,0,1),this.Et();const r=tt(i),n=tt(s),o=tt(e);return r===this.dt&&n===this.wt&&o===this.gt&&h===this.vt||(this.dt=r,this.wt=n,this.gt=o,this.vt=h,this.St=!0,this._t=!0),this}setThreeColor(i,s=this.vt){return s=t.clamp(s,0,1),this.Et(),i.r===this.dt&&i.g===this.wt&&i.b===this.gt&&s===this.vt||(this.dt=i.r,this.wt=i.g,this.gt=i.b,this.vt=s,this.St=!0,this._t=!0),this}toCSSColor(){return this.Et(),`rgba(${Math.round(255*this.dt)}, ${Math.round(255*this.wt)}, ${Math.round(255*this.gt)}, ${this.vt})`}toGLSLColor(t=new s){return this.Et(),t.x=Q(this.dt),t.y=Q(this.wt),t.z=Q(this.gt),t.w=this.vt,t}toThreeColor(t=new i){return this.Et(),t.r=this.dt,t.g=this.wt,t.b=this.gt,t}copy(t){return t instanceof st?(this.Et(),t.Et(),this.dt===t.dt&&this.wt===t.wt&&this.gt===t.gt&&this.vt===t.vt||(this.dt=t.dt,this.wt=t.wt,this.gt=t.gt,this.vt=t.vt,this.St=!0,this._t=!0)):(this.Et(),this.dt===t.r&&this.wt===t.g&&this.gt===t.b&&1===this.vt||(this.dt=t.r,this.wt=t.g,this.gt=t.b,this.vt=1,this.St=!0,this._t=!0)),this}clone(){return this.Et(),new st(this.dt,this.wt,this.gt,this.vt)}Et(){if(this.It){const{yt:t,xt:i,bt:s}=this,e=(1-Math.abs(2*s-1))*i,h=t/60,r=e*(1-Math.abs(h%2-1));let[n,o,a]=1>h?[e,r,0]:2>h?[r,e,0]:3>h?[0,e,r]:4>h?[0,r,e]:5>h?[r,0,e]:[e,0,r];const c=s-e/2;this.dt=n+c,this.wt=o+c,this.gt=a+c,this.It=!1}}Mt(){if(this.St){const{dt:t,wt:i,gt:s}=this,e=Math.max(t,i,s),h=Math.min(t,i,s),r=e-h,n=(e+h)/2;let o=0;0!==r&&(o=e===t?(i-s)/r+(s>i?6:0):e===i?(s-t)/r+2:(t-i)/r+4,o*=60);const a=0===r?0:r/(1-Math.abs(2*n-1));this.yt=o,this.xt=a,this.bt=n,this.St=!1}}}let et,ht;const rt=()=>(ht??(ht=(()=>{const t=document.createElement("canvas"),i=t.getContext("webgl2")??t.getContext("webgl");if(!i)return!1;if(i instanceof WebGL2RenderingContext)try{const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texStorage2D(i.TEXTURE_2D,1,i.SRGB8_ALPHA8,2,2);const s=i.getError();return i.deleteTexture(t),s===i.NO_ERROR}catch{return!1}const s=i.getExtension("EXT_sRGB");if(!s)return!1;try{const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texImage2D(i.TEXTURE_2D,0,s.SRGB_ALPHA_EXT,2,2,0,s.SRGB_ALPHA_EXT,i.UNSIGNED_BYTE,null);const e=i.getError();return i.deleteTexture(t),e===i.NO_ERROR}catch{return!1}})()),ht),nt=Object.freeze({glslTypeName:"float",bufferSize:1,instantiable:!0}),ot=Object.freeze({glslTypeName:"sampler2D",bufferSize:-1,instantiable:!1}),at=Object.freeze({glslTypeName:"vec2",bufferSize:2,instantiable:!0}),ct=Object.freeze({glslTypeName:"vec3",bufferSize:3,instantiable:!0}),ut=Object.freeze({glslTypeName:"vec4",bufferSize:4,instantiable:!0}),lt=Object.freeze({glslTypeName:"mat3",bufferSize:9,instantiable:!0}),ft=Object.freeze({glslTypeName:"mat4",bufferSize:16,instantiable:!0});function dt(t){if("string"==typeof t)switch(t){case"number":return nt;case"Texture":return ot;case"UIColor":case"Vector4":return ut;case"Vector2":return at;case"Vector3":return ct;case"Matrix3":return lt;case"Matrix4":return ft;default:throw Error("resolveGLSLTypeInfo.value: unsupported property type name")}if("function"==typeof t){if(t===Number)return nt;if(t===e)return ot;if(t===st)return ut;if(t===h)return at;if(t===r)return ct;if(t===s)return ut;if(t===n)return lt;if(t===o)return ft;throw Error("resolveGLSLTypeInfo.value: unsupported property type constructor")}if("number"==typeof t)return nt;if(t instanceof e)return ot;if(t instanceof st)return ut;if(t instanceof h)return at;if(t instanceof r)return ct;if(t instanceof s)return ut;if(t instanceof n)return lt;if(t instanceof o)return ft;throw Error("resolveGLSLTypeInfo.value: unsupported property type")}function pt(t,i){const s=i.uniforms["p_"+t];if(void 0===s)throw Error("resolvePropertyUniform.name: unknown uniform");return s}function wt(t){const i={};for(const s in t){const e=t[s];i[s]={value:e,glslTypeInfo:dt(e)}}return i}function gt(t){return"number"==typeof t||t instanceof e?t:t.clone()}function vt(t){const i={};for(const s in t){const e=t[s];i[s]={value:gt(e.value),glslTypeInfo:e.glslTypeInfo}}return i}function yt(t){return t.elements[14]}var mt;(t=>{t[t.CLIP=0]="CLIP",t[t.HASH=1]="HASH",t[t.BLEND=2]="BLEND"})(mt||(mt={}));const xt=(()=>{const t=new a(1,1);t.translate(.5,.5,0);const i=new c;return i.index=t.index,i.setAttribute("position",t.attributes.position),i.setAttribute("uv",t.attributes.uv),t.dispose(),i})(),bt=new s;function _t(t,i,e){if(t instanceof st)t.toGLSLColor(bt),i[e]=bt.x,i[e+1]=bt.y,i[e+2]=bt.z,i[e+3]=bt.w;else if(t instanceof h)i[e]=t.x,i[e+1]=t.y;else if(t instanceof r)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z;else if(t instanceof s)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z,i[e+3]=t.w;else if(t instanceof n||t instanceof o){const s=t.elements;for(let t=0;s.length>t;t++)i[e+t]=s[t]}else"number"==typeof t&&(i[e]=t)}function It(t,i){const s=dt(t);if(!s.instantiable)throw Error("buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type");return new l(new Float32Array(i*s.bufferSize),s.bufferSize)}function St(t,i,e){if("number"==typeof t)return i[e];if(t instanceof h)return new h(i[e],i[e+1]);if(t instanceof r)return new r(i[e],i[e+1],i[e+2]);if(t instanceof s)return new s(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof st)return(new st).setGLSLColor(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof n){const t=new n;return t.fromArray(i,e),t}if(t instanceof o){const t=new o;return t.fromArray(i,e),t}throw Error("reconstructValue.referenceValue: cannot reconstruct value for type")}function Et(t,i,s,e,h){if(0>=e||0===h)return;const r=s*i;t.copyWithin((s+h)*i,r,r+e*i)}function Mt(t,i,s,e,h){for(let r=0;h>r;r++)s[e+r]=t[i+r]}class Ct extends f{constructor(t,i,s,e=1){const h={},r={instanceVisibility:{value:1,glslTypeInfo:dt("number")},instanceTransform:{value:(new o).identity(),glslTypeInfo:dt("Matrix4")}};for(const t in i){const s=i[t];s.glslTypeInfo.instantiable?r[t]=s:h[t]=s}const n=xt.clone(),a=((t,i,s,e)=>{const h={},r=[],n=[],o=[],a=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];h["p_"+t]={value:s instanceof st?s.toGLSLColor():s},r.push(`uniform ${e.glslTypeName} p_${t};`)}for(const t in s){const{glslTypeInfo:i}=s[t];n.push(`attribute ${i.glslTypeName} a_${t};`),o.push(`varying ${i.glslTypeName} p_${t};`),a.push(`p_${t} = a_${t};`)}const c=`\n // User attributes\n ${n.join("\n")}\n\n // Uniforms\n ${r.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${o.join("\n")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${a.join("\n")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `,l=((t,i,s)=>`\n // Defines\n #define PI 3.14159265359\n #define SRGB_SUPPORTED ${rt()?"1":"0"}\n\n // Uniforms\n ${t.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${i.join("\n")}\n\n #include <alphahash_pars_fragment>\n\n // sRGB decode helper\n vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {\n #if SRGB_SUPPORTED\n return texture2D(textureSampler, uv);\n #else\n vec4 textureValue = texture2D(textureSampler, uv);\n return vec4(pow(textureValue.rgb, vec3(2.2)), textureValue.a);\n #endif\n }\n\n // Source must define vec4 draw() function\n ${s}\n void main() {\n vec4 diffuseColor = draw();\n #ifdef USE_ALPHATEST\n if (diffuseColor.a < 0.50) {\n discard;\n }\n #endif\n #ifdef USE_ALPHAHASH\n if (diffuseColor.a < getAlphaHashThreshold(p_position)) {\n discard;\n }\n #endif\n gl_FragColor = linearToOutputTexel(diffuseColor);\n }\n `)(r,o,t);return new u({uniforms:h,vertexShader:c,fragmentShader:l,transparent:e===mt.BLEND,alphaTest:e===mt.CLIP?.5:0,alphaHash:e===mt.HASH,depthWrite:e!==mt.BLEND,depthTest:!0})})(t,h,r,s);super(n,a),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1,this.source=t,this.transparency=s,this.Ct=n,this.Tt=a,this.At=h,this.Pt=r,this.Ut=new Map,this.Ht=Math.max(4*Math.ceil(e/4),4),this.Rt=0,this.Ct.instanceCount=0;for(const t in this.Pt){const{value:i}=this.Pt[t],s=It(i,this.Ht);this.Ct.setAttribute("a_"+t,s),this.Ut.set(t,s)}for(const t in this.At){const{value:i}=this.At[t];pt(t,this.Tt).value=i}this.Tt.uniformsNeedUpdate=!0}get instancesCount(){return this.Rt}insertAt(t,i,s,e){if(0>t||t>this.Rt)throw Error(`UIGenericInstancedPlane.insertAt.index: out of bounds (index=${t}, count=${this.Rt})`);this.Bt(this.Rt+1),this.Rt>t&&this.Vt(t,1),this.Lt(t,i,s,e),this.Rt++,this.Ct.instanceCount=this.Rt}removeAt(t){if(0>t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.removeAt.index: out of bounds (index=${t}, count=${this.Rt})`);this.Rt-1>t&&this.Dt(t+1,1),this.Rt--,this.Ct.instanceCount=this.Rt}setPropertiesAt(t,i){if(0>t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.setPropertiesAt.index: out of bounds (index=${t}, count=${this.Rt})`);for(const s in i){const{value:e,glslTypeInfo:h}=i[s];if(h.instantiable){const i=this.kt(s);_t(e,i.array,t*i.itemSize),i.needsUpdate=!0}else pt(s,this.Tt).value=e,this.Tt.uniformsNeedUpdate=!0}}setTransformAt(t,i){if(0>t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.setTransformAt.index: out of bounds (index=${t}, count=${this.Rt})`);const s=this.kt("instanceTransform"),e=s.array,h=16*t,r=i.elements;for(let t=0;16>t;t++)e[h+t]=r[t];s.needsUpdate=!0}setVisibilityAt(t,i){if(0>t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.setVisibilityAt.index: out of bounds (index=${t}, count=${this.Rt})`);const s=this.kt("instanceVisibility");s.array[t]=i?1:0,s.needsUpdate=!0}extractDataAt(t){if(0>t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.extractDataAt.index: out of bounds (index=${t}, count=${this.Rt})`);const i={};for(const t in this.At){const s=this.At[t];i[t]={value:gt(s.value),glslTypeInfo:s.glslTypeInfo}}for(const s in this.Pt){if("instanceVisibility"===s||"instanceTransform"===s)continue;const{value:e,glslTypeInfo:h}=this.Pt[s],r=this.Ut.get(s);i[s]={value:St(e,r.array,t*r.itemSize),glslTypeInfo:h}}const s=this.Ut.get("instanceTransform").array,e=new o;e.fromArray(s,16*t);const h=this.Ut.get("instanceVisibility");return{source:this.source,properties:i,transform:e,visibility:h.array[t]>=.5,transparency:this.transparency}}getZIndexAt(t){if(0>t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.getZIndexAt.index: out of bounds (index=${t}, count=${this.Rt})`);return this.Ut.get("instanceTransform").array[16*t+14]}merge(t){if(0!==t.Rt){this.Bt(this.Rt+t.Rt);for(const[i,s]of this.Ut){const e=t.Ut.get(i);if(!e)throw Error(`UIGenericInstancedPlane.merge: missing attribute ${i} in source`);const h=s.itemSize;Mt(e.array,0,s.array,this.Rt*h,t.Rt*h),s.needsUpdate=!0}this.Rt+=t.Rt,this.Ct.instanceCount=this.Rt,t.Rt=0,t.Ct.instanceCount=0}}split(t){if(0>=t||t>=this.Rt)throw Error(`UIGenericInstancedPlane.split.atIndex: must be in range (0, count) (atIndex=${t}, count=${this.Rt})`);const i=this.Rt-t,s=new Ct(this.source,vt({...this.At,...this.Pt}),this.transparency,i);for(const[e,h]of this.Ut){const r=s.Ut.get(e);if(!r)throw Error(`UIGenericInstancedPlane.split: missing attribute ${e} in new plane`);const n=h.itemSize;Mt(h.array,t*n,r.array,0,i*n),r.needsUpdate=!0}return s.Rt=i,s.Ct.instanceCount=i,this.Rt=t,this.Ct.instanceCount=t,s}isCompatibleWith(t,i,s){return this.source===t&&this.transparency===s&&((t,i)=>{for(const s in i){if(!(s in t))return!1;const e=t[s].glslTypeInfo;if(e.glslTypeName!==i[s].glslTypeInfo.glslTypeName)return!1;if(!e.instantiable&&t[s].value!==i[s].value)return!1}return!0})({...this.At,...this.Pt},i)}getProperties(){return{...this.At,...this.Pt}}clearInstances(){this.Rt=0,this.Ct.instanceCount=0}destroy(){this.Ct.dispose(),this.Tt.dispose(),this.Ut.clear()}Bt(t){if(this.Ht>=t)return;const i=4*Math.ceil(t/4);for(const[t,s]of this.Ut){const e=s.itemSize,h=new Float32Array(i*e);h.set(s.array);const r=new l(h,e);this.Ct.setAttribute("a_"+t,r),this.Ut.set(t,r)}this.Ht=i}Vt(t,i){const s=this.Rt-t;if(s>0)for(const e of this.Ut.values())Et(e.array,e.itemSize,t,s,i),e.needsUpdate=!0}Dt(t,i){const s=this.Rt-t;if(s>0)for(const e of this.Ut.values())Et(e.array,e.itemSize,t,s,-i),e.needsUpdate=!0}Lt(t,i,s,e){const h=this.kt("instanceVisibility");h.array[t]=e?1:0,h.needsUpdate=!0;const r=this.kt("instanceTransform"),n=r.array,o=16*t,a=s.elements;for(let t=0;16>t;t++)n[o+t]=a[t];r.needsUpdate=!0;for(const s in i){const{value:e,glslTypeInfo:h}=i[s];if(h.instantiable){const i=this.Ut.get(s);i&&(_t(e,i.array,t*i.itemSize),i.needsUpdate=!0)}else pt(s,this.Tt).value=e,this.Tt.uniformsNeedUpdate=!0}}kt(t){const i=this.Ut.get(t);if(void 0===i)throw Error(`UIGenericInstancedPlane.resolveAttribute.name: unknown attribute "${t}"`);return i}}class Tt{constructor(t){this.Wt=new Map,this.lt=0,this.$t=[],this.Nt=new Map,this.zt=new Set,this.Ft=new Set,this.Ot=new Set,this.Gt=!1,this.jt=t}createPlane(t,i,s,e,h){const r=this.lt++,n=wt((t=>{const i={};for(const s in t)i[s]=gt(t[s]);return i})(i)),o=yt(s),a={source:t,properties:n,transform:s.clone(),visibility:e,transparency:h,zIndex:o};return this.Wt.set(r,a),this.zt.add(r),this.Gt=!0,r}destroyPlane(t){if(!this.Wt.has(t))throw Error(`UIPlaneRegistry.destroyPlane: handler ${t} not found`);this.Wt.delete(t),this.zt.has(t)?this.zt.delete(t):(this.Ot.delete(t),this.Ft.add(t),this.Gt=!0)}setProperties(t,i){const s=this.Yt(t),e=wt(i);let h=!1;for(const t in e){const i=e[t];i.glslTypeInfo.instantiable||s.properties[t].value!==i.value&&(h=!0),s.properties[t]={value:i.value,glslTypeInfo:i.glslTypeInfo}}if(h&&!this.zt.has(t))this.Ot.add(t),this.Gt=!0;else{const i=this.Nt.get(t);i&&i.mesh.setPropertiesAt(i.instanceIndex,e)}}setTransform(t,i){const s=this.Yt(t),e=yt(i),h=s.zIndex;if(s.transform.copy(i),s.zIndex=e,h===e||this.zt.has(t)){const s=this.Nt.get(t);s&&s.mesh.setTransformAt(s.instanceIndex,i)}else this.Ot.add(t),this.Gt=!0}setVisibility(t,i){this.Yt(t).visibility=i;const s=this.Nt.get(t);s&&s.mesh.setVisibilityAt(s.instanceIndex,i)}setTransparency(t,i){const s=this.Yt(t);s.transparency!==i&&(s.transparency=i,this.zt.has(t)||(this.Ot.add(t),this.Gt=!0))}flush(){this.Gt&&(this.Xt(),this.qt(),this.Zt(),this.Jt(),this.Kt(),this.Qt(),this.zt.clear(),this.Ft.clear(),this.Ot.clear(),this.Gt=!1)}Xt(){for(const t of this.Ft){const i=this.Nt.get(t);if(!i)continue;const{mesh:s,instanceIndex:e}=i;s.removeAt(e),this.ti(s,e+1,-1),this.Nt.delete(t)}}qt(){for(const t of this.Ot){const i=this.Nt.get(t);if(!i)continue;const{mesh:s,instanceIndex:e}=i;s.removeAt(e),this.ti(s,e+1,-1),this.Nt.delete(t),this.zt.add(t)}}Zt(){if(0===this.zt.size)return;const t=[];for(const i of this.zt){const s=this.Wt.get(i);s&&t.push({handler:i,state:s})}t.sort((t,i)=>t.state.zIndex-i.state.zIndex);for(let i=1;t.length>i;i++)if(t[i].state.zIndex===t[i-1].state.zIndex)throw Error(`UIPlaneRegistry.flush: duplicate zIndex=${t[i].state.zIndex} for handlers ${t[i-1].handler} and ${t[i].handler}`);for(const{handler:i,state:s}of t)this.ii(i,s)}ii(t,i){const{source:s,properties:e,transform:h,visibility:r,transparency:n,zIndex:o}=i;let a=null;for(const t of this.$t){if(!t.isCompatibleWith(s,e,n))continue;if(0===t.instancesCount){a=t;break}const i=t.getZIndexAt(0),h=t.getZIndexAt(t.instancesCount-1);if(o>=i-1&&h+1>=o){a=t;break}}if(a){const i=this.si(a,o);a.insertAt(i,e,h,r),this.ti(a,i,1),this.Nt.set(t,{mesh:a,instanceIndex:i})}else{const i=this.ei(o),a=new Ct(s,vt(e),n);a.insertAt(0,e,h,r),this.$t.splice(i,0,a),this.jt.add(a),this.Nt.set(t,{mesh:a,instanceIndex:0})}}Jt(){let t=0;for(;this.$t.length-1>t;){const i=this.$t[t],s=this.$t[t+1];if(0===i.instancesCount||0===s.instancesCount){t++;continue}const e=i.getZIndexAt(i.instancesCount-1);if(s.getZIndexAt(0)>e&&i.isCompatibleWith(s.source,s.getProperties(),s.transparency)){const e=i.instancesCount;i.merge(s),this.hi(s,i,e),this.jt.remove(s),s.destroy(),this.$t.splice(t+1,1);continue}t++}}Kt(){for(let t=this.$t.length-1;t>=0;t--){const i=this.$t[t];0===i.instancesCount&&(this.jt.remove(i),i.destroy(),this.$t.splice(t,1))}}Yt(t){const i=this.Wt.get(t);if(!i)throw Error(`UIPlaneRegistry.resolveState: handler ${t} not found`);return i}ei(t){for(let i=0;this.$t.length>i;i++){const s=this.$t[i];if(s.instancesCount>0&&s.getZIndexAt(0)>t)return i}return this.$t.length}si(t,i){for(let s=0;t.instancesCount>s;s++)if(t.getZIndexAt(s)>i)return s;return t.instancesCount}ti(t,i,s){for(const e of this.Nt.values())e.mesh!==t||i>e.instanceIndex||(e.instanceIndex+=s)}hi(t,i,s){for(const e of this.Nt.values())e.mesh===t&&(e.mesh=i,e.instanceIndex+=s)}Qt(){this.$t.sort((t,i)=>(t.instancesCount>0?t.getZIndexAt(0):0)-(i.instancesCount>0?i.getZIndexAt(0):0));for(let t=0;this.$t.length>t;t++)this.$t[t].renderOrder=t}}let At=new i,Pt=0,Ut=!1,Ht=!1,Rt=!1,Bt=!1;class Vt{constructor(t,i){this.jt=new d,this.ri=new Tt(this.jt),this.ni=new p(0,t,i,0,-1024,1024),this.ni.matrixAutoUpdate=!1,this.ni.matrixWorldAutoUpdate=!1}createPlane(t,i,s,e,h){return this.ri.createPlane(t,i,s,e,h)}destroyPlane(t){this.ri.destroyPlane(t)}setTransform(t,i){this.ri.setTransform(t,i)}setProperties(t,i){this.ri.setProperties(t,i)}setVisibility(t,i){this.ri.setVisibility(t,i)}setTransparency(t,i){this.ri.setTransparency(t,i)}insertCustomObject(t){return this.jt.add(t),this}removeCustomObject(t){return this.jt.remove(t),this}resize(t,i){return this.ni.right=t,this.ni.top=i,this.ni.updateProjectionMatrix(),this}render(t){return this.ri.flush(),At=t.getClearColor(At),Pt=t.getClearAlpha(),Ut=t.autoClear,Ht=t.autoClearColor,Rt=t.autoClearDepth,Bt=t.autoClearStencil,t.autoClear=!1,t.autoClearColor=!1,t.autoClearDepth=!1,t.autoClearStencil=!1,t.setClearColor(0,1),t.clear(!1,!0,!0),t.render(this.jt,this.ni),t.setClearColor(At),t.setClearAlpha(Pt),t.autoClear=Ut,t.autoClearColor=Ht,t.autoClearDepth=Rt,t.autoClearStencil=Bt,this}}class Lt{constructor(t=0,i){if(this.constant=t,this.oi=i?new Map(i):new Map,i)for(let t=0;i.length>t;t++)jt()}static plus(t,i){const s=new Lt(t.constant+i.constant,Array.from(t.oi.entries()));for(const[t,e]of i.oi)s.plus(t,e);return s}static minus(t,i){const s=new Lt(t.constant-i.constant,Array.from(t.oi.entries()));for(const[t,e]of i.oi)s.minus(t,e);return s}plus(t,i){return this.oi.set(t,(this.oi.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,s]of this.oi)this.oi.set(i,s*t);return this}divide(t){if(0===t)throw Error("UIExpression.divide.value: cannot divide by zero");return this.multiply(1/t)}hasTerm(t){return this.oi.has(t)}copy(t){this.constant=t.constant,this.oi.clear();for(const[i,s]of t.oi)this.oi.set(i,s);return this}clone(){return new Lt(this.constant,Array.from(this.oi.entries()))}prepareTerms(){return Array.from(this.oi.entries())}}var Dt,kt;(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(Dt||(Dt={}));class Wt{constructor(){this.dirty=!1,this.ai=new F,this.ci=!1,this.ui=new Map,this.li=0,this.fi=new Map,this.di=0}createVariable(t,i){const s=this.li++,e=new L;if(i===Z.P0){const h={variable:e,priority:i,value:t};this.ui.set(s,h),h.constraint=this.pi(new Lt(0,[[s,1]]),new Lt(t),Dt.EQUAL,i);try{this.ai?.addConstraint(h.constraint)}catch{this.ai=void 0}}else{this.ui.set(s,{variable:e,priority:i,value:t});try{this.ai?.addEditVariable(e,J(i)),this.ai?.suggestValue(e,t)}catch{this.ai=void 0}}return this.ci=!0,this.dirty=!0,s}removeVariable(t){const i=this.ui.get(t);if(void 0===i)throw Error("UISolverWrapper.removeVariable.index: variable does not exist");for(const i of this.fi.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error("UISolverWrapper.removeVariable.index: variable is used in constraint");try{i.constraint?this.ai?.removeConstraint(i.constraint):this.ai?.removeEditVariable(i.variable)}catch{this.ai=void 0}this.ui.delete(t),this.ci=!0,this.dirty=!0}suggestVariableValue(t,i){const s=this.ui.get(t);if(void 0===s)throw Error("UISolverWrapper.suggestVariableValue.index: variable does not exist");s.value!==i&&(s.value=i,s.constraint?s.constraint=this.wi(s.constraint,(new Lt).plus(t,1),new Lt(s.value),Dt.EQUAL,s.priority):this.ai?.suggestValue(s.variable,i),this.ci=!0,this.dirty=!0)}setVariablePriority(t,i){const s=this.ui.get(t);if(void 0===s)throw Error("UISolverWrapper.setVariablePriority.index: variable does not exist");if(i!==s.priority){if(s.priority=i,s.priority===Z.P0){const i=(new Lt).plus(t,1),e=new Lt(s.value);s.constraint=this.pi(i,e,Dt.EQUAL,s.priority);try{this.ai?.addConstraint(s.constraint)}catch{this.ai=void 0}}else{if(s.constraint)try{this.ai?.removeConstraint(s.constraint)}catch{this.ai=void 0}s.constraint=void 0,this.gi(t,s)}this.ci=!0,this.dirty=!0}}readVariableValue(t){const i=this.ui.get(t);if(void 0===i)throw Error("UISolverWrapper.readVariableValue.index: variable does not exist");return void 0===this.ai&&this.yi(),this.ci&&(this.ai?.updateVariables(),this.ci=!1),i.variable.value()}createConstraint(t,i,s,e,h){const r=this.di++,n=this.pi(t,i,s,e);if(this.fi.set(r,{constraint:n,lhs:t.clone(),rhs:i.clone(),priority:e,relation:s,enabled:h}),h){try{this.ai?.addConstraint(n)}catch{this.ai=void 0}this.ci=!0,this.dirty=!0}return r}removeConstraint(t){const i=this.fi.get(t);if(void 0===i)throw Error("UISolverWrapper.removeConstraint.index: constraint does not exist");if(i.enabled)try{this.ai?.removeConstraint(i.constraint)}catch{this.ai=void 0}this.fi.delete(t),this.ci=!0,this.dirty=!0}setConstraintLHS(t,i){const s=this.fi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintLHS.index: constraint does not exist");s.lhs.copy(i),this.mi(s),this.ci=!0,this.dirty=!0}setConstraintRHS(t,i){const s=this.fi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRHS.index: constraint does not exist");s.rhs.copy(i),this.mi(s),this.ci=!0,this.dirty=!0}setConstraintRelation(t,i){const s=this.fi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRelation.index: constraint does not exist");s.relation!==i&&(s.relation=i,this.mi(s),this.ci=!0,this.dirty=!0)}setConstraintPriority(t,i){const s=this.fi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintPriority.index: constraint does not exist");s.priority!==i&&(s.priority=i,this.mi(s),this.ci=!0,this.dirty=!0)}setConstraintEnabled(t,i){const s=this.fi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintEnabled.index: constraint does not exist");if(i!==s.enabled){s.enabled=i;try{s.enabled?this.ai?.addConstraint(s.constraint):this.ai?.removeConstraint(s.constraint)}catch{this.ai=void 0}this.ci=!0,this.dirty=!0}}gi(t,i){const s=[];for(const i of this.fi.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{this.ai?.removeConstraint(i.constraint)}catch{this.ai=void 0}s.push(i)}this.ai?.removeEditVariable(i.variable),this.ai?.addEditVariable(i.variable,J(i.priority));for(const t of s)t.constraint=this.pi(t.lhs,t.rhs,t.relation,t.priority);for(const t of s)try{this.ai?.addConstraint(t.constraint)}catch{this.ai=void 0;break}}mi(t){t.constraint=t.enabled?this.wi(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.pi(t.lhs,t.rhs,t.relation,t.priority)}wi(t,i,s,e,h){try{this.ai?.removeConstraint(t)}catch{this.ai=void 0}const r=this.pi(i,s,e,h);try{this.ai?.addConstraint(r)}catch{this.ai=void 0}return r}pi(t,i,s,e){return new N(this.xi(t),(t=>{switch(t){case Dt.EQUAL:return $.Eq;case Dt.LESS_THAN:return $.Le;case Dt.GREATER_THAN:return $.Ge;default:throw Error("convertRelation.relation: invalid relation")}})(s),this.xi(i),J(e))}xi(t){return new k(...t.prepareTerms().map(([t,i])=>{const s=this.ui.get(t);if(void 0===s)throw Error("UISolverWrapper.convertExpression.expression: variable does not exist");return[i,s.variable]}),t.constant)}yi(){if(this.ai)throw Error("UISolverWrapper.rebuildSolver: solver already exists");this.ai=new F;for(const t of this.ui.values())t.constraint?this.ai.addConstraint(t.constraint):(this.ai.addEditVariable(t.variable,J(t.priority)),this.ai.suggestValue(t.variable,t.value));for(const t of this.fi.values())t.enabled&&this.ai.addConstraint(t.constraint);this.ci=!0,this.dirty=!0}}(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.MODE_CHANGED="mode_changed",t.RENDERING="rendering"})(kt||(kt={}));const $t=A.VISIBLE;class Nt extends T{constructor(t){super(),this.name="",this.inputWrapperInternal=new K,this.bi=new Wt;const i=t.width??1024,s=t.height??1024;this._i=new Vt(i,s),this.name=t.name??"",this.Ii=t.mode??$t,this.Si=i>s?P.HORIZONTAL:P.VERTICAL,this.xVariable=this.bi.createVariable(0,Z.P0),this.yVariable=this.bi.createVariable(0,Z.P0),this.wVariable=this.bi.createVariable(i,Z.P0),this.hVariable=this.bi.createVariable(s,Z.P0)}get sceneWrapper(){return this._i}get solverWrapper(){return this.bi}get inputWrapper(){return this.inputWrapperInternal}get x(){return this.bi.readVariableValue(this.xVariable)}get y(){return this.bi.readVariableValue(this.yVariable)}get width(){return this.bi.readVariableValue(this.wVariable)}get height(){return this.bi.readVariableValue(this.hVariable)}get mode(){return this.Ii}get orientation(){return this.Si}set mode(t){t!==this.Ii&&(this.Ii=t,this.emit(kt.MODE_CHANGED,this.Ii,this))}resizeInternal(t,i){this.bi.suggestVariableValue(this.wVariable,t),this.bi.suggestVariableValue(this.hVariable,i),this._i.resize(t,i);const s=t>i?P.HORIZONTAL:P.VERTICAL;s!==this.Si&&(this.Si=s,this.emit(kt.ORIENTATION_CHANGED,this.Si,this))}renderInternal(t,i){H(this.mode)&&(this.emit(kt.RENDERING,t,i,this),this._i.render(t)),this.bi.dirty=!1,this.inputWrapperInternal.dirty=!1}}const zt=1e-6;function Ft(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof Nt}function Ot(t){return"object"==typeof t&&null!==t&&"number"==typeof t.xVariable&&"number"==typeof t.yVariable&&"number"==typeof t.x&&"number"==typeof t.y}function Gt(t){return Ot(t)&&"number"==typeof t.wVariable&&"number"==typeof t.hVariable&&"number"==typeof t.width&&"number"==typeof t.height}function jt(){}function Yt(t,i,s){if(t instanceof Nt)return t;if(Ft(t))return t.layer;if(i instanceof Nt)return i;if(Ft(i))return i.layer;throw Error(s+": no valid subjects found")}function Xt(t,i,s){if(Ft(i))return i.layer;if(Ft(s))return s.layer;if(i instanceof Nt)return i;if(s instanceof Nt)return s;throw Error(t+": no valid subjects found")}class qt{constructor(t,i){this.layer=t,this.solverWrapper=this.layer.solverWrapper,this.name=i??""}}class Zt extends qt{constructor(t,i){var s,e,h;super(t,i?.name),this.Ei=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.Mi=(s=i?.priority,s??Z.P0),this.Ci=(e=i?.relation,e??Dt.EQUAL),this.Si=(h=i?.orientation,h??P.ALWAYS),this.layer.on(kt.ORIENTATION_CHANGED,this.Ei)}get priority(){return this.Mi}get relation(){return this.Ci}get orientation(){return this.Si}set priority(t){t!==this.Mi&&(this.Mi=t,this.solverWrapper.setConstraintPriority(this.constraint,this.Mi))}set relation(t){t!==this.Ci&&(this.Ci=t,this.solverWrapper.setConstraintRelation(this.constraint,this.Ci))}set orientation(t){t!==this.Si&&(this.Si=t,this.Ei())}destroy(){this.layer.off(kt.ORIENTATION_CHANGED,this.Ei),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.Si===P.ALWAYS||this.Si===this.layer.orientation}}class Jt extends Zt{constructor(t,i={}){super(t.layer,i),this.Ti=t,this.Ai=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new Lt(0,[[this.Ti.hVariable,1]]),new Lt(this.Ai),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Ai}set height(t){this.Ai!==t&&(this.Ai=t,this.solverWrapper.setConstraintRHS(this.constraint,new Lt(t)))}}class Kt extends Zt{constructor(t,i,s={}){super(Yt(t,i,"UIHorizontalDistanceConstraint.constructor"),s),this.Pi=t,this.Ui=i,this.Hi=s.anchorA??.5,this.Ri=s.anchorB??.5,this.Bi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Vi(),new Lt(this.Bi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Bi}get anchorA(){return this.Hi}get anchorB(){return this.Ri}set distance(t){this.Bi!==t&&(this.Bi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Lt(this.Bi)))}set anchorA(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorB(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}Vi(){let t,i;if(Gt(this.Pi))t=new Lt(0,[[this.Pi.xVariable,1],[this.Pi.wVariable,this.Hi]]);else{if(!Ot(this.Pi))throw Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");t=(new Lt).plus(this.Pi.xVariable,1)}if(Gt(this.Ui))i=new Lt(0,[[this.Ui.xVariable,1],[this.Ui.wVariable,this.Ri]]);else{if(!Ot(this.Ui))throw Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");i=(new Lt).plus(this.Ui.xVariable,1)}return Lt.minus(i,t)}}class Qt extends Zt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Xt("UIHorizontalInterpolationConstraint.constructor",t,i),e),this.Pi=t,this.Ui=i,this.Li=s,this.Hi=h,this.Ri=h,this.Di=e.anchorC??.5,this.ki=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Vi(),new Lt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.ki}get anchorA(){return this.Hi}get anchorB(){return this.Ri}get anchorC(){return this.Di}set t(t){this.ki!==t&&(this.ki=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorA(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorB(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorC(t){this.Di!==t&&(this.Di=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}Vi(){let t,i,s;if(Gt(this.Pi))t=new Lt(0,[[this.Pi.xVariable,1],[this.Pi.wVariable,this.Hi]]);else{if(!Ot(this.Pi))throw Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Lt).plus(this.Pi.xVariable,1)}if(Gt(this.Ui))i=new Lt(0,[[this.Ui.xVariable,1],[this.Ui.wVariable,this.Ri]]);else{if(!Ot(this.Ui))throw Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Lt).plus(this.Ui.xVariable,1)}if(Gt(this.Li))s=new Lt(0,[[this.Li.xVariable,1],[this.Li.wVariable,this.Di]]);else{if(!Ot(this.Li))throw Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Lt).plus(this.Li.xVariable,1)}const e=t.clone().multiply(1-this.ki),h=i.clone().multiply(this.ki);return Lt.minus(Lt.minus(s,e),h)}}class ti extends Zt{constructor(t,i,s={}){super(Yt(t,i,"UIHorizontalProportionConstraint.constructor"),s),this.Pi=t,this.Ui=i,this.Wi=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Lt(0),this.$i(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.Wi}set proportion(t){this.Wi!==t&&(this.Wi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.$i()))}$i(){return Lt.minus(new Lt(0,[[this.Pi.wVariable,this.Wi]]),new Lt(0,[[this.Ui.wVariable,1]]))}}class ii extends Zt{constructor(t,i,s={}){super(Yt(t,i,"UIVerticalDistanceConstraint.constructor"),s),this.Pi=t,this.Ui=i,this.Hi=s.anchorA??.5,this.Ri=s.anchorB??.5,this.Bi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Vi(),new Lt(this.Bi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Bi}get anchorA(){return this.Hi}get anchorB(){return this.Ri}set distance(t){this.Bi!==t&&(this.Bi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Lt(this.Bi)))}set anchorA(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorB(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}Vi(){let t,i;if(Gt(this.Pi))t=new Lt(0,[[this.Pi.yVariable,1],[this.Pi.hVariable,this.Hi]]);else{if(!Ot(this.Pi))throw Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");t=(new Lt).plus(this.Pi.yVariable,1)}if(Gt(this.Ui))i=new Lt(0,[[this.Ui.yVariable,1],[this.Ui.hVariable,this.Ri]]);else{if(!Ot(this.Ui))throw Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");i=(new Lt).plus(this.Ui.yVariable,1)}return Lt.minus(i,t)}}class si extends Zt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Xt("UIVerticalInterpolationConstraint.constructor",t,i),e),this.Pi=t,this.Ui=i,this.Li=s,this.Hi=h,this.Ri=h,this.Di=e.anchorC??.5,this.ki=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Vi(),new Lt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.ki}get anchorA(){return this.Hi}get anchorB(){return this.Ri}get anchorC(){return this.Di}set t(t){this.ki!==t&&(this.ki=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorA(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorB(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}set anchorC(t){this.Di!==t&&(this.Di=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}Vi(){let t,i,s;if(Gt(this.Pi))t=new Lt(0,[[this.Pi.yVariable,1],[this.Pi.hVariable,this.Hi]]);else{if(!Ot(this.Pi))throw Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Lt).plus(this.Pi.yVariable,1)}if(Gt(this.Ui))i=new Lt(0,[[this.Ui.yVariable,1],[this.Ui.hVariable,this.Ri]]);else{if(!Ot(this.Ui))throw Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Lt).plus(this.Ui.yVariable,1)}if(Gt(this.Li))s=new Lt(0,[[this.Li.yVariable,1],[this.Li.hVariable,this.Di]]);else{if(!Ot(this.Li))throw Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Lt).plus(this.Li.yVariable,1)}const e=t.clone().multiply(1-this.ki),h=i.clone().multiply(this.ki);return Lt.minus(Lt.minus(s,e),h)}}class ei extends Zt{constructor(t,i,s={}){super(Yt(t,i,"UIVerticalProportionConstraint.constructor"),s),this.Pi=t,this.Ui=i,this.Wi=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Lt(0),this.$i(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.Wi}set proportion(t){this.Wi!==t&&(this.Wi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.$i()))}$i(){return Lt.minus(new Lt(0,[[this.Pi.hVariable,this.Wi]]),new Lt(0,[[this.Ui.hVariable,1]]))}}class hi extends Zt{constructor(t,i={}){super(t.layer,i),this.Ti=t,this.Ni=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new Lt(0,[[this.Ti.wVariable,1]]),new Lt(this.Ni),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.Ni}set width(t){this.Ni!==t&&(this.Ni=t,this.solverWrapper.setConstraintRHS(this.constraint,new Lt(t)))}}function ri(t){return void 0===t?{}:Array.isArray(t)?{h:t[0],v:t[1]}:"object"==typeof t&&null!==t&&("h"in t||"v"in t)?t:{h:t,v:t}}class ni{static size(t,i={}){const s=ri(i.size),e=ri(i.priority),h=ri(i.relation),r=ri(i.orientation);return{h:new hi(t,{width:s.h,priority:e.h,relation:h.h,orientation:r.h}),v:new Jt(t,{height:s.v,priority:e.v,relation:h.v,orientation:r.v})}}static distance(t,i,s={}){const e=ri(s.anchorA),h=ri(s.anchorB),r=ri(s.distance),n=ri(s.priority),o=ri(s.relation),a=ri(s.orientation);return{h:new Kt(t,i,{anchorA:e.h,anchorB:h.h,distance:r.h,priority:n.h,relation:o.h,orientation:a.h}),v:new ii(t,i,{anchorA:e.v,anchorB:h.v,distance:r.v,priority:n.v,relation:o.v,orientation:a.v})}}static proportion(t,i,s={}){const e=ri(s.proportion),h=ri(s.priority),r=ri(s.relation),n=ri(s.orientation);return{h:new ti(t,i,{proportion:e.h,priority:h.h,relation:r.h,orientation:n.h}),v:new ei(t,i,{proportion:e.v,priority:h.v,relation:r.v,orientation:n.v})}}static interpolation(t,i,s,e={}){const h=ri(e.anchorA),r=ri(e.anchorB),n=ri(e.anchorC),o=ri(e.t),a=ri(e.priority),c=ri(e.relation),u=ri(e.orientation);return{h:new Qt(t,i,s,{anchorA:h.h,anchorB:r.h,anchorC:n.h,t:o.h,priority:a.h,relation:c.h,orientation:u.h}),v:new si(t,i,s,{anchorA:h.v,anchorB:r.v,anchorC:n.v,t:o.v,priority:a.v,relation:c.v,orientation:u.v})}}}class oi extends Zt{constructor(t,i={}){super(t.layer,i),this.Ti=t,this.zi=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Vi(),new Lt(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.zi}set aspect(t){this.zi!==t&&(this.zi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Vi()))}Vi(){return new Lt(0,[[this.Ti.wVariable,1],[this.Ti.hVariable,-this.zi]])}}const ai=.5;class ci{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new oi(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new Kt(t,i,{anchorA:s.anchorH??ai,anchorB:s.anchorH??ai,orientation:s.orientation}),yConstraint:new ii(t,i,{anchorA:s.anchorV??ai,anchorB:s.anchorV??ai,orientation:s.orientation}),widthConstraint:new ti(t,i,{proportion:1,relation:Dt.GREATER_THAN,orientation:s.orientation}),heightConstraint:new ei(t,i,{proportion:1,priority:Z.P1,orientation:s.orientation})}}}const ui=.5;class li{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new oi(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new Kt(t,i,{anchorA:s.anchorH??ui,anchorB:s.anchorH??ui,orientation:s.orientation}),yConstraint:new ii(t,i,{anchorA:s.anchorV??ui,anchorB:s.anchorV??ui,orientation:s.orientation}),widthConstraint:new ti(t,i,{proportion:1,relation:Dt.LESS_THAN,orientation:s.orientation}),heightConstraint:new ei(t,i,{proportion:1,priority:Z.P1,orientation:s.orientation})}}}class fi extends Zt{constructor(t,i,s,e={}){super(t,e),this.Fi=i,this.Oi=s,this.constraint=this.solverWrapper.createConstraint(this.Fi,this.Oi,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.Fi}get rhs(){return this.Oi}setLHS(t){this.Fi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Fi)}setRHS(t){this.Oi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Oi)}}class di extends T{constructor(t,i){const s=i?.x??0,e=i?.y??0;super(),this.layer=t,this.name="",this.solverWrapper=this.layer.solverWrapper,this.xVariable=this.solverWrapper.createVariable(s,Z.P7),this.yVariable=this.solverWrapper.createVariable(e,Z.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}var pi;(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(pi||(pi={}));const wi=.5,gi=pi.ROTATION_SCALE,vi=new r,yi=new w,mi=new r,xi=new o,bi=new r(0,0,1);function _i(t,i,s,e,h,r,n,o,a,c,u,l,f,d,p,w,g){const v=s-d-p,y=e-w-g,m=o*s*c,x=a*e*u,b=Math.cos(l),_=Math.sin(l),I=m*b-x*_,S=m*_+x*b,E=d*c,M=g*u,C=E*b-M*_,T=E*_+M*b;if(f===pi.POSITION_ROTATION_SCALE)vi.x=t+r-I+C,vi.y=i+n-S+T;else{const h=a*e;vi.x=t+o*s-I+r+C,vi.y=i+h-S+n+T}return vi.z=h,mi.x=v*c,mi.y=y*u,yi.setFromAxisAngle(bi,l),xi.compose(vi,yi,mi),xi}const Ii=new e;var Si;(t=>{t[t.DIMENSIONS_CHANGED=0]="DIMENSIONS_CHANGED"})(Si||(Si={}));class Ei extends T{constructor(t){super(),this.Gi=Ii,this.ji=2,this.Yi=2,this.Xi=0,this.qi=0,this.Zi=2,this.Ji=2,this.Ki=!1,this.Qi=1,this.ts=0,this.ss=0,this.es=0,this.hs=0,this.rs=!1,this.ns=!1,this.cs=!1,void 0!==t&&this.set(t)}get width(){return this.ji/this.Qi}get height(){return this.Yi/this.Qi}get trimmedWidth(){return(this.Ki?this.Ji:this.Zi)/this.Qi}get trimmedHeight(){return(this.Ki?this.Zi:this.Ji)/this.Qi}get texture(){return this.Gi}get rotated(){return this.Ki}get scale(){return this.Qi}get trim(){const t=this.Qi;return{left:this.ts/t,right:this.ss/t,top:this.es/t,bottom:this.hs/t}}get textureDirty(){return this.rs}get uvTransformDirty(){return this.ns}get trimDirty(){return this.cs}setTextureDirtyFalse(){this.rs=!1}setUVTransformDirtyFalse(){this.ns=!1}setTrimDirtyFalse(){this.cs=!1}calculateUVTransform(t=new n){const i=this.Gi.image?.naturalWidth??2,s=this.Gi.image?.naturalHeight??2;if(this.Ki){const e=this.Zi,h=e/s;t.set(0,this.Ji/i,this.Xi/i,-h,0,(s-this.qi-e)/s+h,0,0,1)}else t.set(this.Zi/i,0,this.Xi/i,0,this.Ji/s,(s-this.qi-this.Ji)/s,0,0,1);return t}getResolution(t=new h){return t.set(this.width,this.height)}set(t){const i=this.width,s=this.height;t instanceof e?this.us(t):this.ls(t),this.width===i&&this.height===s||this.emit(Si.DIMENSIONS_CHANGED,this.width,this.height,this)}us(t){const i=t.image?.naturalWidth??2,s=t.image?.naturalHeight??2;this.ji=i,this.Yi=s,this.texture!==t&&(this.Gi=t,this.rs=!0),(0!==this.Xi||0!==this.qi||this.Zi!==i||this.Ji!==s||1!==this.Qi||this.Ki)&&(this.Xi=0,this.qi=0,this.Zi=i,this.Ji=s,this.Ki=!1,this.Qi=1,this.ns=!0),0===this.ts&&0===this.ss&&0===this.es&&0===this.hs||(this.ts=0,this.ss=0,this.es=0,this.hs=0,this.cs=!0)}ls(t){this.ji=t.sourceSize.w,this.Yi=t.sourceSize.h,this.texture!==t.texture&&(this.Gi=t.texture,this.rs=!0);const i=t.scale??1,s=t.rotated??!1;0===this.Xi&&0===this.qi&&this.Zi===t.frame.w&&this.Ji===t.frame.h&&this.Qi===i&&this.Ki===s||(this.Xi=t.frame.x,this.qi=t.frame.y,this.Zi=t.frame.w,this.Ji=t.frame.h,this.Qi=i,this.Ki=s,this.ns=!0);const e=t.spriteSourceSize,h=e.x,r=e.y,n=this.ji-e.x-e.w,o=this.Yi-e.y-e.h;this.ts===h&&this.ss===n&&this.es===r&&this.hs===o||(this.ts=h,this.ss=n,this.es=r,this.hs=o,this.cs=!0)}}var Mi,Ci="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}";class Ti{constructor(t){this._t=!0,this.fs=t?.x??0,this.ds=t?.y??0,this.ps=t?.anchorX??wi,this.ws=t?.anchorY??wi,this.gs=t?.scaleX??1,this.vs=t?.scaleY??1,this.ys=t?.rotation??0,this.xs=t?.anchorMode??gi}get x(){return this.fs}get y(){return this.ds}get anchorX(){return this.ps}get anchorY(){return this.ws}get scaleX(){return this.gs}get scaleY(){return this.vs}get angle(){return t.radToDeg(this.ys)}get anchorMode(){return this.xs}get rotation(){return this.ys}get dirty(){return this._t}set x(t){t!==this.fs&&(this.fs=t,this._t=!0)}set y(t){t!==this.ds&&(this.ds=t,this._t=!0)}set anchorX(t){t!==this.ps&&(this.ps=t,this._t=!0)}set anchorY(t){t!==this.ws&&(this.ws=t,this._t=!0)}set scaleX(t){t!==this.gs&&(this.gs=t,this._t=!0)}set scaleY(t){t!==this.vs&&(this.vs=t,this._t=!0)}set angle(i){const s=t.degToRad(i);s!==this.ys&&(this.ys=s,this._t=!0)}set rotation(t){t!==this.ys&&(this.ys=t,this._t=!0)}set anchorMode(t){t!==this.xs&&(this.xs=t,this._t=!0)}setDirtyFalse(){this._t=!1}reset(){0===this.fs&&0===this.ds&&this.ps===wi&&this.ws===wi&&1===this.gs&&1===this.vs&&0===this.ys||(this.fs=0,this.ds=0,this.ps=wi,this.ws=wi,this.gs=1,this.vs=1,this.ys=0,this._t=!0)}copy(t){this.fs===t.fs&&this.ds===t.ds&&this.ps===t.ps&&this.ws===t.ws&&this.gs===t.gs&&this.vs===t.vs&&this.ys===t.ys&&this.xs===t.xs||(this.fs=t.fs,this.ds=t.ds,this.ps=t.ps,this.ws=t.ws,this.gs=t.gs,this.vs=t.vs,this.ys=t.ys,this.xs=t.xs,this._t=!0)}}class Ai{}class Pi extends Ai{constructor(t,i,s,e){super(),this.x=t,this.y=i,this.width=s,this.height=e}contains(t,i){return!(this.x>t||t>this.x+this.width||this.y>i||i>this.y+this.height)}}(t=>{t.PRESSED="pointerdown",t.MOVED="pointermove",t.RELEASED="pointerup",t.ENTERED="pointerenter",t.LEFT="pointerleave"})(Mi||(Mi={}));const Ui=A.VISIBLE;class Hi extends di{constructor(t,i){const s=i?.width??64,e=i?.height??32;super(t,i),this.bs=!1,this.catchPointerDown=(t,i,s)=>this.handleInputEvent(t,i,s,Mi.PRESSED),this.catchPointerMove=(t,i,s)=>this.handleInputEvent(t,i,s,Mi.MOVED),this.catchPointerUp=(t,i,s)=>this.handleInputEvent(t,i,s,Mi.RELEASED),this.interactionArea=i?.interactionArea??new Pi(0,0,1,1),this.modeInternal=i?.mode??Ui,this.inputWrapper=this.layer.inputWrapper,this.wVariable=this.solverWrapper.createVariable(s,Z.P6),this.hVariable=this.solverWrapper.createVariable(e,Z.P6),this._s=this.inputWrapper.createInputCatcher(this.catchPointerDown,this.catchPointerMove,this.catchPointerUp,0),this.inputWrapper.setActive(this._s,U(this.modeInternal))}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get oppositeX(){return this.x+this.width}get oppositeY(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get mode(){return this.modeInternal}get zIndex(){return this.inputWrapper.getZIndex(this._s)}set width(t){this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){this.solverWrapper.suggestVariableValue(this.hVariable,t)}set oppositeX(t){this.x=t-this.width}set oppositeY(t){this.y=t-this.height}set centerX(t){this.x=t-this.width/2}set centerY(t){this.y=t-this.height/2}set mode(t){if(this.modeInternal!==t){const i=U(t);this.inputWrapper.setActive(this._s,i),this.modeInternal=t}}set zIndex(t){this.inputWrapper.setZIndex(this._s,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.inputWrapper.destroyInputCatcher(this._s),super.destroy()}handleInputEvent(i,s,e,h){const r=this.interactionArea.contains(t.mapLinear(i,this.x,this.oppositeX,0,1),t.mapLinear(s,this.y,this.oppositeY,0,1));return r&&this.emit(h,i,s,e,this),this.bs&&!r?this.emit(Mi.LEFT,i,s,e,this):!this.bs&&r&&this.emit(Mi.ENTERED,i,s,e,this),this.bs=r,this.modeInternal!==A.INTERACTIVE_TRANSPARENT&&r}}const Ri=mt.BLEND;class Bi extends Hi{constructor(t,i,s,e){super(t,e),this.Is=!1,this.Ss=!1,this.micro=new Ti(e?.micro),this.Es=e?.transparencyMode??Ri,this.sceneWrapper=this.layer.sceneWrapper,this.planeHandler=this.sceneWrapper.createPlane(i,s,(new o).identity(),H(e?.mode??this.mode),this.Es),this.layer.on(kt.RENDERING,this.onWillRender,this)}get transparencyMode(){return this.Es}set transparencyMode(t){this.Es!==t&&(this.Es=t,this.Is=!0)}set mode(t){this.modeInternal!==t&&(this.Ss=H(this.modeInternal)!==H(t),super.mode=t)}destroy(){this.layer.off(kt.RENDERING,this.onWillRender,this),this.sceneWrapper.destroyPlane(this.planeHandler),super.destroy()}setPlaneTransform(){(this.micro.dirty||this.inputWrapper.dirty||this.solverWrapper.dirty)&&(this.sceneWrapper.setTransform(this.planeHandler,((t,i,s,e,h,r,n,o,a,c,u,l,f)=>{const d=s*this.micro.scaleX,p=e*this.micro.scaleY,w=o*d,g=a*p,v=Math.cos(l),y=Math.sin(l),m=w*v-g*y,x=w*y+g*v;if(f===pi.POSITION_ROTATION_SCALE)vi.x=t+r-m,vi.y=i+n-x;else{const h=a*e;vi.x=t+o*s-m+r,vi.y=i+h-x+n}return vi.z=h,mi.x=d,mi.y=p,yi.setFromAxisAngle(bi,l),xi.compose(vi,yi,mi),xi})(this.x,this.y,this.width,this.height,this.zIndex,this.micro.x,this.micro.y,this.micro.anchorX,this.micro.anchorY,0,0,this.micro.rotation,this.micro.anchorMode)),this.micro.setDirtyFalse())}onWillRender(t,i){this.Is&&(this.sceneWrapper.setTransparency(this.planeHandler,this.Es),this.Is=!1),this.Ss&&(this.sceneWrapper.setVisibility(this.planeHandler,H(this.modeInternal)),this.Ss=!1),this.setPlaneTransform()}}var Vi,Li;(t=>{t[t.PLAYED=0]="PLAYED",t[t.PAUSED=1]="PAUSED",t[t.STOPPED=2]="STOPPED"})(Vi||(Vi={})),(t=>{t[t.NONE=0]="NONE",t[t.LOOP=1]="LOOP",t[t.PING_PONG=2]="PING_PONG"})(Li||(Li={}));const Di=Li.LOOP;class ki extends Bi{constructor(t,i,s={}){const e=new st(s.color),h=i.map(t=>new Ei(t)),r=h[0];s.width=s.width??r.width,s.height=s.height??r.height;const n=r.calculateUVTransform();super(t,Ci,{texture:r.texture,textureTransform:n,color:e},s),this.Ms=!1,this.Cs=0,this.Ts=!1,this.As=0,this.Ps=(t,i,s)=>{this.Us[this.Cs]===s&&(this.width=t,this.height=i)},this.Hs=e,this.Us=h,this.Rs=n,this.Bs=s.frameRate??24,this.Vs=s.timeScale??1,this.Ls=s.loopMode??Di,this.Ds(),!0===s.playByDefault&&this.play()}get color(){return this.Hs}get duration(){return this.Us.length/this.Bs}get frameRate(){return this.Bs}get loopMode(){return this.Ls}get sequence(){return this.Us}get timeScale(){return this.Vs}set color(t){this.Hs.set(t)}set frameRate(t){this.Bs=t}set loopMode(t){this.Ls=t}set sequence(t){this.stop(),this.ks();const i=t.length,s=this.Us.length;for(let e=0;Math.min(i,s)>e;e++)this.Us[e].set(t[e]);if(s>i)this.Us.length=i;else if(i>s)for(let e=s;i>e;e++)this.Us.push(new Ei(t[e]));this.Ds()}set timeScale(t){this.Vs=t}destroy(){this.ks(),super.destroy()}play(){this.Ms||(this.Ms=!0,this.emit(Vi.PLAYED))}pause(){this.Ms&&(this.Ms=!1,this.emit(Vi.PAUSED))}stop(){(this.Ms||this.As>0||this.Cs>0)&&(this.Ms=!1,this.As=0,this.Cs=0,this.Ts=!0,this.emit(Vi.STOPPED))}onWillRender(t,i){if(this.Ms&&0!==this.Vs){this.As+=i*this.Vs;const t=1/this.Bs,s=this.Us.length,e=s-1;if(this.Vs>0)for(;this.As>=t;){if(this.As-=t,this.Cs+=1,this.Cs>=s)if(this.Ls===Li.LOOP)this.Cs=0;else{if(this.Ls!==Li.PING_PONG){this.Cs=e,this.Ms=!1,this.emit(Vi.PAUSED);break}this.Cs=e,this.Vs=-this.Vs}this.Ts=!0}else for(;-t>=this.As;){if(this.As+=t,this.Cs-=1,0>this.Cs)if(this.Ls===Li.LOOP)this.Cs=e;else{if(this.Ls!==Li.PING_PONG){this.Cs=0,this.Ms=!1,this.emit(Vi.PAUSED);break}this.Cs=0,this.Vs=-this.Vs}this.Ts=!0}}super.onWillRender(t,i)}setPlaneTransform(){let t;this.Hs.dirty&&(t??(t={}),t.color=this.Hs,this.Hs.setDirtyFalse());const i=this.Us[this.Cs];if((i.textureDirty||this.Ts)&&(t??(t={}),t.texture=i.texture,i.setTextureDirtyFalse()),(i.uvTransformDirty||this.Ts)&&(t??(t={}),t.textureTransform=i.calculateUVTransform(this.Rs),i.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.Ts||this.micro.dirty||i.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,s=i.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,s.left,s.right,s.top,s.bottom)),this.Ts=!1,this.micro.setDirtyFalse(),i.setTrimDirtyFalse()}}Ds(){for(const t of this.Us)t.on(Si.DIMENSIONS_CHANGED,this.Ps)}ks(){for(const t of this.Us)t.off(Si.DIMENSIONS_CHANGED,this.Ps)}}function Wi(t,i){if(et??(et=(()=>{if("undefined"==typeof OffscreenCanvas)return!1;const t=document.createElement("canvas");t.width=4,t.height=4;const i=t.getContext("webgl")??t.getContext("webgl2");if(!i)return!1;try{const t=new OffscreenCanvas(4,4),s=t.getContext("2d");if(!s)return!1;s.fillStyle="#ff0000",s.fillRect(0,0,4,4);const e=i.createTexture();if(i.bindTexture(i.TEXTURE_2D,e),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),i.getError()!==i.NO_ERROR)return i.deleteTexture(e),!1;const h=i.createFramebuffer();if(i.bindFramebuffer(i.FRAMEBUFFER,h),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return i.deleteFramebuffer(h),i.deleteTexture(e),!1;const r=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,r),i.bindFramebuffer(i.FRAMEBUFFER,null),i.deleteFramebuffer(h),i.deleteTexture(e),!!(r[0]>200&&50>r[1]&&50>r[2]&&r[3]>200)}catch(t){return!1}})()),et)return new OffscreenCanvas(t,i);const s=document.createElement("canvas");return s.width=t,s.height=i,s}function $i(t){const i=new g(t,v,y,y,m,m,x,b,1);return i.colorSpace=rt()?_:I,i.generateMipmaps=!1,i}const Ni=new st;class zi extends Bi{constructor(t,i){const s=i?.width??2,e=i?.height??2,h=new st(i?.color),r=Wi(s,e),o=r.getContext("2d");if(!o)throw Error("UIGraphics.constructor: failed to get 2D context from canvas");const a=$i(r);a.needsUpdate=!0,super(t,Ci,{texture:a,textureTransform:new n,color:h},i),this.Ws=r,this.$s=o,this.Ns=a,this.Hs=h}get color(){return this.Hs}set color(t){this.Hs.set(t)}clear(t){return this.$s.clearRect(0,0,this.Ws.width,this.Ws.height),void 0!==t&&(this.$s.fillStyle=Ni.set(t).toCSSColor(),this.$s.fillRect(0,0,this.Ws.width,this.Ws.height)),this.Ns.needsUpdate=!0,this}drawRect(t,i,s,e,h){return this.$s.fillStyle=Ni.set(h).toCSSColor(),this.$s.fillRect(t,i,s,e),this.Ns.needsUpdate=!0,this}drawCircle(t,i,s,e){return this.$s.fillStyle=Ni.set(e).toCSSColor(),this.$s.beginPath(),this.$s.arc(t,i,s,0,2*Math.PI),this.$s.fill(),this.Ns.needsUpdate=!0,this}drawArc(t,i,s,e,h,r){return this.$s.fillStyle=Ni.set(r).toCSSColor(),this.$s.beginPath(),this.$s.arc(t,i,s,e,h),this.$s.fill(),this.Ns.needsUpdate=!0,this}drawPolyline(t,i,s=1){if(2>t.length)return this;this.$s.strokeStyle=Ni.set(i).toCSSColor(),this.$s.lineWidth=s,this.$s.beginPath(),this.$s.moveTo(t[0][0],t[0][1]);for(let i=1;t.length>i;i++)this.$s.lineTo(t[i][0],t[i][1]);return this.$s.stroke(),this.Ns.needsUpdate=!0,this}destroy(){this.Ns.dispose(),super.destroy()}onWillRender(t,i){this.Hs.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Hs}),this.Hs.setDirtyFalse()),super.onWillRender(t,i)}}class Fi extends Bi{constructor(t,i,s={}){const e=new st(s.color),h=new Ei(i),r=h.calculateUVTransform();s.width=s.width??h.width,s.height=s.height??h.height,super(t,Ci,{texture:h.texture,textureTransform:r,color:e},s),this.Ps=(t,i)=>{this.width=t,this.height=i},this.texture=h,this.Rs=r,this.Hs=e,this.texture.on(Si.DIMENSIONS_CHANGED,this.Ps)}get color(){return this.Hs}set color(t){this.Hs.set(t)}destroy(){this.texture.off(Si.DIMENSIONS_CHANGED,this.Ps),super.destroy()}setPlaneTransform(){let t;if(this.Hs.dirty&&(t??(t={}),t.color=this.Hs,this.Hs.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Rs),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}}class Oi{constructor(t){this.bt=0,this.dt=0,this.ki=0,this.gt=0,this._t=!1,this.set(t)}get left(){return this.bt}get right(){return this.dt}get top(){return this.ki}get bottom(){return this.gt}get dirty(){return this._t}set left(t){this.bt!==t&&(this.bt=t,this._t=!0)}set right(t){this.dt!==t&&(this.dt=t,this._t=!0)}set top(t){this.ki!==t&&(this.ki=t,this._t=!0)}set bottom(t){this.gt!==t&&(this.gt=t,this._t=!0)}setHorizontal(t){this.bt===t&&this.dt===t||(this.bt=t,this.dt=t,this._t=!0)}setVertical(t){this.ki===t&&this.gt===t||(this.ki=t,this.gt=t,this._t=!0)}setUnified(t){this.bt===t&&this.dt===t&&this.ki===t&&this.gt===t||(this.bt=t,this.dt=t,this.ki=t,this.gt=t,this._t=!0)}set(t){const i=this.bt,s=this.dt,e=this.ki,h=this.gt;if(void 0===t)this.bt=0,this.dt=0,this.ki=0,this.gt=0;else if("number"==typeof t)this.bt=t,this.dt=t,this.ki=t,this.gt=t;else if(Array.isArray(t))if(2===t.length){const i=t[0],s=t[1];this.bt=i,this.dt=i,this.ki=s,this.gt=s}else{const i=t[1],s=t[2],e=t[3];this.bt=t[0],this.dt=i,this.ki=s,this.gt=e}else if("left"in t){const i=t.right,s=t.top,e=t.bottom;this.bt=t.left,this.dt=i,this.ki=s,this.gt=e}else{const i=t.horizontal,s=t.vertical;this.bt=i,this.dt=i,this.ki=s,this.gt=s}this.bt===i&&this.dt===s&&this.ki===e&&this.gt===h||(this._t=!0)}setVector4(t){this.bt===t.x&&this.dt===t.y&&this.ki===t.z&&this.gt===t.w||(this.bt=t.x,this.dt=t.y,this.ki=t.z,this.gt=t.w,this._t=!0)}toVector4(t=new s){return t.set(this.bt,this.dt,this.ki,this.gt)}reset(){this.setUnified(0)}copy(t){this.bt===t.bt&&this.dt===t.dt&&this.ki===t.ki&&this.gt===t.gt||(this.bt=t.bt,this.dt=t.dt,this.ki=t.ki,this.gt=t.gt,this._t=!0)}setDirtyFalse(){this._t=!1}}var Gi;(t=>{t[t.NORMALIZED=0]="NORMALIZED",t[t.WORLD=1]="WORLD"})(Gi||(Gi={}));const ji=Gi.WORLD;class Yi extends Bi{constructor(t,i,e={}){const h=new st(e.color),r=new Ei(i),n=r.calculateUVTransform();e.width=e.width??r.width,e.height=e.height??r.height;const o=new Oi(e.sliceBorders??.1),a=new Oi(e.sliceRegions??.1),c=e.regionMode??ji,u=new s,l=new s;super(t,"vec4 draw(){vec2 localUV=p_uv;float left=p_sliceBorders.x;float right=p_sliceBorders.y;float top=p_sliceBorders.z;float bottom=p_sliceBorders.w;float leftFill=p_sliceRegions.x;float rightFill=p_sliceRegions.y;float topFill=p_sliceRegions.z;float bottomFill=p_sliceRegions.w;float lB=leftFill;float rB=1.0-rightFill;float bB=bottomFill;float tB=1.0-topFill;{float regionL=step(p_uv.x,lB);float regionR=step(rB,p_uv.x);float regionM=1.0-regionL-regionR;float xL=(p_uv.x/lB)*left;float xR=1.0-right+((p_uv.x-rB)/rightFill)*right;float xM=left+((p_uv.x-lB)/(rB-lB))*(1.0-left-right);localUV.x=regionL*xL+regionM*xM+regionR*xR;}{float regionB=step(p_uv.y,bB);float regionT=step(tB,p_uv.y);float regionC=1.0-regionB-regionT;float yB=(p_uv.y/bB)*bottom;float yT=1.0-top+((p_uv.y-tB)/topFill)*top;float yC=bottom+((p_uv.y-bB)/(tB-bB))*(1.0-bottom-top);localUV.y=regionB*yB+regionC*yC+regionT*yT;}vec2 transformedUV=(p_textureTransform*vec3(localUV,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}",{texture:r.texture,textureTransform:n,color:h,sliceBorders:u,sliceRegions:l},e),this.zs=!0,this.Fs=new s,this.Os=new s,this.Gs=!0,this.Ps=()=>{this.Gs=!0},this.texture=r,this.Rs=n,this.Hs=h,this.js=o,this.Ys=a,this.Xs=c,this.Fs=u,this.Os=l,this.qs=this.width,this.Zs=this.height,this.texture.on(Si.DIMENSIONS_CHANGED,this.Ps)}get color(){return this.Hs}get regionMode(){return this.Xs}get sliceBorders(){return this.js}get sliceRegions(){return this.Ys}set color(t){this.Hs.set(t)}set regionMode(t){this.Xs!==t&&(this.Xs=t,this.zs=!0)}set sliceBorders(t){this.js.set(t)}set sliceRegions(t){this.Ys.set(t)}destroy(){this.texture.off(Si.DIMENSIONS_CHANGED,this.Ps),super.destroy()}setPlaneTransform(){let t;if((this.Gs||this.js.dirty||this.texture.trimDirty)&&(t??(t={}),t.sliceBorders=this.Js(this.Fs),this.js.setDirtyFalse(),this.Gs=!1),(this.Ys.dirty||this.zs||this.Xs===Gi.WORLD&&this.Ks())&&(t??(t={}),t.sliceRegions=this.Qs(this.Os),this.Ys.setDirtyFalse(),this.zs=!1,this.te()),this.Hs.dirty&&(t??(t={}),t.color=this.Hs,this.Hs.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Rs),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}Js(t){const i=this.texture.width,s=this.texture.height,e=this.texture.trim,h=e.right/i,r=e.top/s,n=e.bottom/s,o=(i-e.left-e.right)/i,a=(s-e.top-e.bottom)/s,c=this.js.right,u=this.js.top,l=this.js.bottom,f=Math.max(0,this.js.left-e.left/i)/o,d=Math.max(0,c-h)/o,p=Math.max(0,u-r)/a,w=Math.max(0,l-n)/a;return t.set(Math.min(1,f),Math.min(1,d),Math.min(1,p),Math.min(1,w))}Qs(t){if(this.Xs===Gi.NORMALIZED)return t.set(this.Ys.left,this.Ys.right,this.Ys.top,this.Ys.bottom);const i=this.width,s=this.height;return t.set(this.Ys.left/i,this.Ys.right/i,this.Ys.top/s,this.Ys.bottom/s)}Ks(){return this.solverWrapper.dirty&&(this.qs!==Math.round(this.width)||this.Zs!==Math.round(this.height))}te(){this.qs=Math.round(this.width),this.Zs=Math.round(this.height)}}class Xi{constructor(t){this.source=t,this.dirtyInternal=!1}get dirty(){return this.dirtyInternal}setDirtyFalse(){this.dirtyInternal=!1}}class qi extends Xi{constructor(t={x:1,y:0}){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 halfExtents=vec2(aspect,1.0)*0.5;float maxProjection=dot(halfExtents,abs(p_direction));vec2 correctedUV=(p_uv-0.5)*vec2(aspect,1.0);float projection=dot(correctedUV,p_direction);float offset=(projection/maxProjection+1.0)*0.5;return step(offset,p_progress);}"),this.direction=new h,this.ie=new h,this.direction.set(t.x,t.y).normalize(),this.ie.copy(this.direction)}get dirty(){return this.se(),this.dirtyInternal||!this.ie.equals(this.direction)}setDirtyFalse(){this.se(),this.ie.copy(this.direction),super.setDirtyFalse()}enumerateProperties(){return this.se(),{direction:this.direction}}se(){const t=this.direction.lengthSq();Math.abs(t)>zt?Math.abs(t-1)>zt&&this.direction.divideScalar(t):this.direction.set(1,0)}}var Zi,Ji="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;vec4 diffuseColor=srgbTexture2D(p_texture,transformedUV)*p_color;diffuseColor.a*=calculateMask();return diffuseColor;}";class Ki extends Bi{constructor(i,s,e={}){const h=new st(e.color),r=new Ei(s),n=r.calculateUVTransform(),o=r.getResolution();e.width=e.width??r.width,e.height=e.height??r.height;const a=t.clamp(e.progress??1,0,1),c=e.maskFunction??new qi;super(i,c.source+Ji,{texture:r.texture,textureTransform:n,textureResolution:o,color:h,progress:a,...c.enumerateProperties()},e),this.ee=!1,this.he=!1,this.Ps=(t,i)=>{this.width===t&&this.height===i||(this.width=t,this.height=i,this.he=!0)},this.texture=r,this.Rs=n,this.re=o,this.Hs=h,this.ne=a,this.oe=c,this.texture.on(Si.DIMENSIONS_CHANGED,this.Ps)}get color(){return this.Hs}get maskFunction(){return this.oe}get progress(){return this.ne}set color(t){this.Hs.set(t)}set maskFunction(t){this.oe!==t&&(this.oe=t,this.ae())}set progress(i){i=t.clamp(i,0,1),this.ne!==i&&(this.ne=i,this.ee=!0)}setPlaneTransform(){let t;if(this.Hs.dirty&&(t??(t={}),t.color=this.Hs,this.Hs.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Rs),this.texture.setUVTransformDirtyFalse()),this.ee&&(t??(t={}),t.progress=this.ne,this.ee=!1),this.he&&(t??(t={}),t.textureResolution=this.texture.getResolution(this.re),this.he=!1),this.maskFunction.dirty){t??(t={});const i=this.maskFunction.enumerateProperties();for(const s in i)t[s]=i[s];this.maskFunction.setDirtyFalse()}if(t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}ae(){this.sceneWrapper.destroyPlane(this.planeHandler);const t=this.micro,i=this.texture.trim;this.planeHandler=this.sceneWrapper.createPlane(this.oe.source+Ji,{texture:this.texture.texture,textureTransform:this.texture.calculateUVTransform(this.Rs),textureResolution:this.texture.getResolution(this.re),color:this.Hs,progress:this.ne,...this.oe.enumerateProperties()},_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom),H(this.mode),this.transparencyMode),this.Hs.setDirtyFalse(),this.texture.setTextureDirtyFalse(),this.texture.setUVTransformDirtyFalse(),this.texture.setTrimDirtyFalse(),this.ee=!1,this.he=!1,this.oe.setDirtyFalse(),this.micro.setDirtyFalse()}}(t=>{t[t.EVERY_FRAME=1]="EVERY_FRAME",t[t.EVERY_SECOND_FRAME=2]="EVERY_SECOND_FRAME",t[t.ON_PROPERTIES_CHANGE=3]="ON_PROPERTIES_CHANGE",t[t.ON_DIMENSIONS_CHANGE=4]="ON_DIMENSIONS_CHANGE",t[t.MANUAL=5]="MANUAL"})(Zi||(Zi={}));const Qi=Zi.ON_PROPERTIES_CHANGE,ts=new st(0,0,0,1);class is extends Bi{constructor(i,s={}){const e=t.clamp(s.resolutionFactor??.5,.1,2),h=s.width??64,r=s.height??32,o=new S(h*e,r*e,{format:x,minFilter:m,magFilter:m,type:b,depthBuffer:s.enableDepthBuffer??!0,stencilBuffer:!1}),a=new st(s.color);super(i,Ci,{texture:o.texture,textureTransform:new n,color:a},s),this.ce=!0,this.ue=!1,this.le=!1,this.fe=!1,this.Hs=a,this.de=new st(s.clearColor??ts),this.pe=o,this.we=s.scene??new d,this.ge=s.camera??new E(60,h/r,.1,100),this.ve=e,this.ye=s.updateMode??Qi,this.fe=s.updateMode!==Zi.MANUAL}get camera(){return this.ge}get clearColor(){return this.de}get color(){return this.Hs}get resolutionFactor(){return this.ve}get scene(){return this.we}get updateMode(){return this.ye}set camera(t){this.ge!==t&&(this.ge=t,this.fe=!0)}set clearColor(t){this.de.set(t)}set color(t){this.Hs.set(t)}set resolutionFactor(i){i=t.clamp(i,.1,2),this.ve!==i&&(this.ve=i,this.le=!0)}set scene(t){this.we!==t&&(this.we=t,this.fe=!0)}set updateMode(t){this.ye!==t&&(this.ye=t,this.fe=!0)}destroy(){this.pe.dispose(),super.destroy()}requestUpdate(){this.ue=!0}onWillRender(t,i){this.ce=!this.ce,(this.ue||this.ye===Zi.EVERY_FRAME||this.ye===Zi.EVERY_SECOND_FRAME&&this.ce||this.ye===Zi.ON_PROPERTIES_CHANGE&&this.fe||this.Hs.dirty||this.de.dirty||this.ye===Zi.ON_DIMENSIONS_CHANGE&&(this.le||this.solverWrapper.dirty))&&((this.le||this.solverWrapper.dirty)&&(this.pe.setSize(this.width*this.ve,this.height*this.ve),this.le=!1),this.Hs.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Hs}),this.Hs.setDirtyFalse()),t.setClearColor(this.de.getHexRGB(),this.de.a),t.setRenderTarget(this.pe),t.clear(!0,!0,!1),t.render(this.we,this.ge),this.fe=!1,this.ue=!1),super.onWillRender(t,i)}}const ss="#000000",es="left",hs="Arial",rs="normal",ns="normal",os=!1,as="transparent",cs=!1,us="#000000";class ls{constructor(t){this._t=!0,this.Hs=t?.color,this.me=t?.align,this.xe=t?.fontFamily,this.be=t?.fontSize,this._e=t?.fontStyle,this.Ie=t?.fontWeight,this.Se=t?.lineHeight,this.Ee=t?.enableShadow,this.Me=t?.shadowOffsetX,this.Ce=t?.shadowOffsetY,this.Te=t?.shadowBlur,this.Ae=t?.shadowColor,this.Pe=t?.enableStroke,this.Ue=t?.strokeColor,this.He=t?.strokeThickness}get color(){return this.Hs}get align(){return this.me}get fontFamily(){return this.xe}get fontSize(){return this.be}get fontStyle(){return this._e}get fontWeight(){return this.Ie}get lineHeight(){return this.Se}get enableShadow(){return this.Ee}get shadowOffsetX(){return this.Me}get shadowOffsetY(){return this.Ce}get shadowBlur(){return this.Te}get shadowColor(){return this.Ae}get enableStroke(){return this.Pe}get strokeColor(){return this.Ue}get strokeThickness(){return this.He}get dirty(){return this._t}set color(t){t!==this.Hs&&(this.Hs=t,this._t=!0)}set align(t){t!==this.me&&(this.me=t,this._t=!0)}set fontFamily(t){t!==this.xe&&(this.xe=t,this._t=!0)}set fontSize(t){t!==this.be&&(this.be=t,this._t=!0)}set fontStyle(t){t!==this._e&&(this._e=t,this._t=!0)}set fontWeight(t){t!==this.Ie&&(this.Ie=t,this._t=!0)}set lineHeight(t){t!==this.Se&&(this.Se=t,this._t=!0)}set enableShadow(t){t!==this.Ee&&(this.Ee=t,this._t=!0)}set shadowOffsetX(t){t!==this.Me&&(this.Me=t,this._t=!0)}set shadowOffsetY(t){t!==this.Ce&&(this.Ce=t,this._t=!0)}set shadowBlur(t){t!==this.Te&&(this.Te=t,this._t=!0)}set shadowColor(t){t!==this.Ae&&(this.Ae=t,this._t=!0)}set enableStroke(t){t!==this.Pe&&(this.Pe=t,this._t=!0)}set strokeColor(t){t!==this.Ue&&(this.Ue=t,this._t=!0)}set strokeThickness(t){t!==this.He&&(this.He=t,this._t=!0)}static resolve(t,i){const s=t.be??i.be??16;return{color:t.Hs??i.Hs??ss,align:t.me??i.me??es,fontFamily:t.xe??i.xe??hs,fontSize:s,fontStyle:t._e??i._e??rs,fontWeight:t.Ie??i.Ie??ns,lineHeight:t.Se??i.Se??1.2*s,enableShadow:t.Ee??i.Ee??os,shadowOffsetX:t.Me??i.Me??0,shadowOffsetY:t.Ce??i.Ce??0,shadowBlur:t.Te??i.Te??0,shadowColor:t.Ae??i.Ae??as,enableStroke:t.Pe??i.Pe??cs,strokeColor:t.Ue??i.Ue??us,strokeThickness:t.He??i.He??0}}setDirtyFalse(){this._t=!1}setDefaults(){this.Hs===ss&&this.me===es&&this.xe===hs&&16===this.be&&this._e===rs&&this.Ie===ns&&19.2===this.Se&&this.Ee===os&&0===this.Me&&0===this.Ce&&0===this.Te&&this.Ae===as&&this.Pe===cs&&this.Ue===us&&0===this.He||(this.Hs=ss,this.me=es,this.xe=hs,this.be=16,this._e=rs,this.Ie=ns,this.Se=19.2,this.Ee=os,this.Me=0,this.Ce=0,this.Te=0,this.Ae=as,this.Pe=cs,this.Ue=us,this.He=0,this._t=!0)}clear(){void 0===this.Hs&&void 0===this.me&&void 0===this.xe&&void 0===this.be&&void 0===this._e&&void 0===this.Ie&&void 0===this.Se&&void 0===this.Ee&&void 0===this.Me&&void 0===this.Ce&&void 0===this.Te&&void 0===this.Ae&&void 0===this.Pe&&void 0===this.Ue&&void 0===this.He||(this.Hs=void 0,this.me=void 0,this.xe=void 0,this.be=void 0,this._e=void 0,this.Ie=void 0,this.Se=void 0,this.Ee=void 0,this.Me=void 0,this.Ce=void 0,this.Te=void 0,this.Ae=void 0,this.Pe=void 0,this.Ue=void 0,this.He=void 0,this._t=!0)}copy(t){this.Hs===t.Hs&&this.me===t.me&&this.xe===t.xe&&this.be===t.be&&this._e===t._e&&this.Ie===t.Ie&&this.Se===t.Se&&this.Ee===t.Ee&&this.Me===t.Me&&this.Ce===t.Ce&&this.Te===t.Te&&this.Ae===t.Ae&&this.Pe===t.Pe&&this.Ue===t.Ue&&this.He===t.He||(this.Hs=t.Hs,this.me=t.me,this.xe=t.xe,this.be=t.be,this._e=t._e,this.Ie=t.Ie,this.Se=t.Se,this.Ee=t.Ee,this.Me=t.Me,this.Ce=t.Ce,this.Te=t.Te,this.Ae=t.Ae,this.Pe=t.Pe,this.Ue=t.Ue,this.He=t.He,this._t=!0)}calculatePadding(){let t=0;if(void 0!==this.Pe&&(t+=this.He??0),void 0!==this.Ee){const i=this.Ce??0,s=2*(this.Te??0);t+=Math.max(Math.abs(this.Me??0)+s,Math.abs(i)+s)}return Math.ceil(t)}}class fs{constructor(t){this._t=!0,this.Re=t.text,this.style=new ls(t.style)}get text(){return this.Re}get dirty(){return this._t||this.style.dirty}set text(t){t!==this.Re&&(this.Re=t,this._t=!0)}setDirtyFalse(){this._t=!1,this.style.setDirtyFalse()}}var ds;(t=>{t[t.BREAK=0]="BREAK",t[t.SCALE=1]="SCALE"})(ds||(ds={}));const ps=ds.SCALE;function ws(t){return t.match(/\S+|\s|\n/g)??[]}function gs(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px "${s.fontFamily}"`,"\n"===i)return{width:1,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const e=t.measureText(i);return{width:Math.ceil(e.width),height:Math.ceil(e.actualBoundingBoxAscent+e.actualBoundingBoxDescent),baseline:e.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function vs(t,i){const s=((t,i)=>{const s=[];let e=[],h=0,r=0,n=0,o=0;for(const a of i)"\n"!==a.text?0!==e.length&&h+a.metrics.width>t?(s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),e=[a],h=a.metrics.width,r=a.metrics.height,n=a.metrics.baseline,o=a.metrics.lineHeight):(e.push(a),h+=a.metrics.width,r=Math.max(r,a.metrics.height),n=Math.max(n,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(e.length>0&&s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),e=[],h=0,r=0,n=0,o=0);return e.length>0&&s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),s})(i,t),e=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let s=0;for(let i=0;t.length>i;i++){const e=t[i];s+=0===i?e.height:e.lineHeight}return{width:i,height:s}})(s);return{lines:s,size:e}}function ys(t,i,s,e,h){h.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize}px "${e.fontFamily}"`,e.enableShadow&&(h.shadowOffsetX=e.shadowOffsetX,h.shadowOffsetY=e.shadowOffsetY,h.shadowBlur=e.shadowBlur,h.shadowColor=e.shadowColor),e.enableStroke&&(h.strokeStyle=e.strokeColor,h.lineWidth=e.strokeThickness,h.strokeText(s,t,i)),h.fillStyle=e.color,h.fillText(s,t,i)}function ms(t,i,s,e){let h=t,r=0;for(const t of s)r=Math.max(t.width,r);for(let t=0;s.length>t;t++){const n=s[t],o=n.chunks[0]?.style.align??es,a=n.chunks.every(t=>t.style.align===o)?o:es;let c=0;"center"===a?c=(r-n.width)/2:"right"===a&&(c=r-n.width);let u=i+c;h+=0===t?n.height:n.lineHeight;for(const t of n.chunks)ys(u,h,t.text,t.style,e),u+=t.metrics.width}}class xs extends Bi{constructor(t,i,s={}){const e=Wi(2,2),h=e.getContext("2d");if(!h)throw Error("UIText.constructor: failed to create canvas context");const r=$i(e);r.needsUpdate=!0;const o=new st(s.color);switch(super(t,Ci,{texture:r,textureTransform:new n,color:o}),this.Be=[],this.Ve=!1,this.De=!1,this.ke=!1,this.We=[],this.$e=!1,this.Hs=o,this.Ne=new Oi(s.padding),this.commonStyle=new ls(s.commonStyle),this.ze=s.maxLineWidth??1024,this.Fe=s.resizeMode??ps,this.Ws=e,this.$s=h,this.Ns=r,this.content=i,this.Oe=this.width,this.je=this.height,void 0===s.padding&&this.Ne.setUnified(this.content.reduce((t,i)=>Math.max(t,i.style.calculatePadding()),this.commonStyle.calculatePadding())),this.Fe){case ds.SCALE:this.Ye();break;case ds.BREAK:this.Xe()}}get color(){return this.Hs}get content(){return this.Be}get maxLineWidth(){return this.ze}get padding(){return this.Ne}get resizeMode(){return this.Fe}set color(t){this.Hs.set(t)}set content(t){this.Be!==t&&(this.Be="string"==typeof t?[new fs({text:t,style:new ls})]:Array.isArray(t)?t.map(t=>new fs("string"==typeof t?{text:t,style:new ls}:{text:t.text,style:new ls(t.style)})):[new fs({text:t.text,style:new ls(t.style)})],this.Ve=!0,this.$e=!0)}set maxLineWidth(t){this.ze!==t&&(this.ze=t,this.De=!0)}set padding(t){this.Ne.set(t)}set resizeMode(t){this.Fe!==t&&(this.Fe=t,this.ke=!0)}destroy(){this.Ns.dispose(),super.destroy()}onWillRender(t,i){switch(this.Fe){case ds.SCALE:this.Ye();break;case ds.BREAK:this.Xe()}super.onWillRender(t,i)}Ye(){if(!(this.Hs.dirty||this.ke||this.De||this.Ne.dirty||this.solverWrapper.dirty&&this.Oe/this.je!==Math.round(this.width)/Math.round(this.height)||this.qe()))return;const t=this.Ze(),{lines:i,size:s}=vs(t,this.ze),e=s.height+(this.Ne.top+this.Ne.bottom),h=s.width+(this.Ne.left+this.Ne.right);this.width=h,this.height=e/h*Math.round(this.width),this.width=h/e*Math.round(this.height);const r=this.Oe!==e||this.je!==h;r&&(this.Ws.height=e,this.Ws.width=h),ms(this.Ne.top,this.Ne.left,i,this.$s),this.Je(r),this.ke=!1,this.De=!1,this.Ne.setDirtyFalse(),this.Ke(),this.Qe()}Xe(){if(!(this.Hs.dirty||this.ke||this.De||this.Ne.dirty||this.th()||this.qe()))return;const t=this.Ze(),{size:i}=vs(t,this.ze),s=this.Ne.top+this.Ne.bottom,e=this.Ne.left+this.Ne.right;this.height=i.height+s,this.width=i.width+e;const{lines:h,size:r}=vs(t,Math.round(this.width)-e);this.height=r.height+s,this.width=r.width+e;const n=Math.max(Math.round(this.width),2),o=Math.max(Math.round(this.height),2),a=this.Oe!==n||this.je!==o;a&&(this.Ws.width=n,this.Ws.height=o),ms(this.Ne.top,this.Ne.left,h,this.$s),this.Je(a),this.ke=!1,this.De=!1,this.Ne.setDirtyFalse(),this.Ke(),this.Qe()}Je(t){let i;this.Hs.dirty&&(i??(i={}),i.color=this.Hs,this.Hs.setDirtyFalse()),t&&(this.Ns.dispose(),this.Ns=$i(this.Ws),this.Ns.needsUpdate=!0,i??(i={}),i.texture=this.Ns),i&&this.sceneWrapper.setProperties(this.planeHandler,i)}Ze(){return this.$e&&(this.We=((t,i,s)=>{const e=[];for(const h of i){const i=ls.resolve(h.style,s);for(const s of ws(h.text)){const h=gs(t,s,i);e.push({text:s,style:i,metrics:h})}}return e})(this.$s,this.Be,this.commonStyle),this.$e=!1),this.We}th(){return this.solverWrapper.dirty&&(this.Oe!==Math.round(this.width)||this.je!==Math.round(this.height))}Ke(){this.Oe=Math.round(this.width),this.je=Math.round(this.height)}qe(){return this.Ve||this.content.some(t=>t.dirty)}Qe(){this.Ve=!1;for(const t of this.content)t.setDirtyFalse()}}class bs{constructor(){this.dirty=!1}}class _s extends bs{calculateScale(t,i){return 1}}const Is=new _s;class Ss extends Nt{constructor(t){const i=t?.resizePolicy??Is,s=i.calculateScale(window.innerWidth,window.innerHeight);super({width:window.innerWidth*s,height:window.innerHeight*s,...t}),this.ih=!1,this.sh=()=>{const t=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight);this.resizePolicy.dirty=!1,this.ih=!1,this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.eh=t=>{this.hh(t,"onPointerDown",Mi.PRESSED)},this.rh=t=>{this.hh(t,"onPointerMove",Mi.MOVED)},this.nh=t=>{this.hh(t,"onPointerUp",Mi.RELEASED)},this.oh=i,window.addEventListener("resize",this.sh),window.addEventListener("pointerdown",this.eh),window.addEventListener("pointermove",this.rh),window.addEventListener("pointerup",this.nh)}get resizePolicy(){return this.oh}set resizePolicy(t){this.oh!==t&&(this.oh=t,this.ih=!0)}destroy(){window.removeEventListener("resize",this.sh),window.removeEventListener("pointerdown",this.eh),window.removeEventListener("pointermove",this.rh),window.removeEventListener("pointerup",this.nh)}render(t,i){(this.resizePolicy.dirty||this.ih)&&this.sh(),super.renderInternal(t,i)}projectWorldPosition(i,s,e=new r){return e.copy(i).project(s),e.x=t.mapLinear(e.x,-1,1,this.x,this.width),e.y=t.mapLinear(e.y,-1,1,this.y,this.height),e}projectLayerPosition(i,s,e=-1,h=new r){return h.set(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),e).unproject(s)}buildRay(i,s,e=new M){const h=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),-1).unproject(s),n=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),1).unproject(s).sub(h).normalize();return e.set(h,n)}hh(t,i,s){const e=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,h=e?t.clientX-e.left:t.clientX,r=e?e.bottom-t.clientY:window.innerHeight-t.clientY,n=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight),o=h*n,a=r*n;U(this.mode)&&(this.emit(s,o,a,t.pointerId),this.inputWrapperInternal[i](o,a,t.pointerId))}}class Es extends Ai{constructor(t,i,s){super(),this.centerX=t,this.centerY=i,this.radius=s}contains(t,i){const s=t-this.centerX,e=i-this.centerY;return this.radius*this.radius>=s*s+e*e}}class Ms extends Ai{constructor(t){super(),this.vertices=t}contains(t,i){const s=this.vertices.length;if(3>s)return!1;let e=!1;for(let h=0,r=s-1;s>h;r=h++){const s=this.vertices[h],n=this.vertices[r],o=s.x,a=s.y,c=n.y;a>i!=c>i&&(n.x-o)*(i-a)/(c-a)+o>t&&(e=!e)}return e}}class Cs extends Ai{constructor(t,i,s,e,h){super(),this.x=t,this.y=i,this.width=s,this.height=e,this.radius=h,this.radius=Math.min(h,Math.min(s,e)/2)}contains(t,i){const s=this.x,e=this.x+this.width,h=this.y,r=this.y+this.height;if(s>t||t>e||h>i||i>r)return!1;const n=s+this.radius,o=e-this.radius,a=h+this.radius,c=r-this.radius;if(t>=n&&o>=t)return!0;if(i>=a&&c>=i)return!0;let u,l;u=n>t?n:o,l=a>i?a:c;const f=t-u,d=i-l;return this.radius*this.radius>=f*f+d*d}}class Ts extends Xi{constructor(t=0,i=!1){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 p=(p_uv-0.5)*vec2(aspect,1.0);float angle=atan(p.y,p.x);angle=(angle+PI)/(2.0*PI);float adjusted=angle-p_startAngle;adjusted=p_direction>0.0 ? adjusted :-adjusted;adjusted=fract(adjusted);return step(adjusted,p_progress);}"),this.ah=t,this.uh=i}get startAngle(){return this.ah}get inverseDirection(){return this.uh}set startAngle(t){this.ah!==t&&(this.ah=t,this.dirtyInternal=!0)}set inverseDirection(t){this.uh!==t&&(this.uh=t,this.dirtyInternal=!0)}enumerateProperties(){return{direction:this.uh?-1:1,startAngle:this.ah}}}class As extends bs{constructor(t,i){super(),this.fh=t,this.dh=i}get rectWidth(){return this.fh}get rectHeight(){return this.dh}set rectWidth(t){t!==this.fh&&(this.fh=t,this.dirty=!0)}set rectHeight(t){t!==this.dh&&(this.dh=t,this.dirty=!0)}calculateScale(t,i){return Math.min(this.fh/t,this.dh/i)}}class Ps extends bs{constructor(t,i){super(),this.ph=t,this.wh=i}get fixedWidthLandscape(){return this.ph}get fixedHeightPortrait(){return this.wh}set fixedWidthLandscape(t){t!==this.ph&&(this.ph=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.wh&&(this.wh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.ph/t:this.wh/i}}class Us extends bs{constructor(t,i){super(),this.gh=t,this.yh=i}get fixedHeightLandscape(){return this.gh}get fixedWidthPortrait(){return this.yh}set fixedHeightLandscape(t){t!==this.gh&&(this.gh=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.yh&&(this.yh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.gh/i:this.yh/t}}class Hs extends bs{constructor(t,i){super(),this.fh=t,this.dh=i}get rectWidth(){return this.fh}get rectHeight(){return this.dh}set rectWidth(t){t!==this.fh&&(this.fh=t,this.dirty=!0)}set rectHeight(t){t!==this.dh&&(this.dh=t,this.dirty=!0)}calculateScale(t,i){return Math.max(this.fh/t,this.dh/i)}}class Rs extends bs{constructor(t,i){super(),this.gh=t,this.wh=i}get fixedHeightLandscape(){return this.gh}get fixedHeightPortrait(){return this.wh}set fixedHeightLandscape(t){t!==this.gh&&(this.gh=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.wh&&(this.wh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.gh/i:this.wh/i}}class Bs extends bs{constructor(t,i){super(),this.ph=t,this.yh=i}get fixedWidthLandscape(){return this.ph}get fixedWidthPortrait(){return this.yh}set fixedWidthLandscape(t){t!==this.ph&&(this.ph=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.yh&&(this.yh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.ph/t:this.yh/t}}export{di as UIAnchor,ki as UIAnimatedImage,Li as UIAnimatedImageLoopMode,Es as UIAreaCircle,Ms as UIAreaPolygon,Pi as UIAreaRectangle,Cs as UIAreaRoundedRectangle,oi as UIAspectConstraint,st as UIColor,ni as UIConstraint2DBuilder,ci as UICoverConstraintBuilder,fi as UICustomConstraint,Lt as UIExpression,li as UIFitConstraintBuilder,Ss as UIFullscreenLayer,zi as UIGraphics,Jt as UIHeightConstraint,Kt as UIHorizontalDistanceConstraint,Qt as UIHorizontalInterpolationConstraint,ti as UIHorizontalProportionConstraint,Fi as UIImage,Hi as UIInputDummy,Mi as UIInputEvent,Ti as UIMicro,pi as UIMicroAnchorMode,A as UIMode,Yi as UINineSlice,Gi as UINineSliceRegionMode,P as UIOrientation,Z as UIPriority,Ki as UIProgress,Ts as UIProgressMaskFunctionCircular,qi as UIProgressMaskFunctionDirectional,Dt as UIRelation,As as UIResizePolicyCover,Ps as UIResizePolicyCross,Us as UIResizePolicyCrossInverted,Hs as UIResizePolicyFit,Rs as UIResizePolicyFixedHeight,Bs as UIResizePolicyFixedWidth,_s as UIResizePolicyNone,is as UIScene,Zi as UISceneUpdateMode,Zt as UISingleParameterConstraint,xs as UIText,ds as UITextResizeMode,mt as UITransparencyMode,ii as UIVerticalDistanceConstraint,si as UIVerticalInterpolationConstraint,ei as UIVerticalProportionConstraint,hi as UIWidthConstraint};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|