laymur 0.1.66 → 0.1.68
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/Builders/UIConstraint2DBuilder.d.ts +3 -3
- package/dist/Elements/UIImage.d.ts +9 -0
- package/dist/Materials/UIMaterial.d.ts +2 -0
- package/dist/Miscellaneous/UIBlending.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -35,8 +35,8 @@ export interface UIConstraint2DResult<TX, TY> {
|
|
|
35
35
|
y: TY;
|
|
36
36
|
}
|
|
37
37
|
export declare class UIConstraint2DBuilder {
|
|
38
|
-
static size(element: UIElement, options
|
|
39
|
-
static distance(elementOne: UIElement | UIAnchor | UILayer, elementTwo: UIElement | UIAnchor, options
|
|
40
|
-
static proportion(elementOne: UIElement | UILayer, elementTwo: UIElement, options
|
|
38
|
+
static size(element: UIElement, options?: Partial<UIConstraintSize2DOptions>): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint>;
|
|
39
|
+
static distance(elementOne: UIElement | UIAnchor | UILayer, elementTwo: UIElement | UIAnchor, options?: Partial<UIConstraintSize2DOptions>): UIConstraint2DResult<UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint>;
|
|
40
|
+
static proportion(elementOne: UIElement | UILayer, elementTwo: UIElement, options?: Partial<UIConstraintProportion2DOptions>): UIConstraint2DResult<UIHorizontalProportionConstraint, UIVerticalProportionConstraint>;
|
|
41
41
|
}
|
|
42
42
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Texture, WebGLRenderer } from "three";
|
|
2
2
|
import type { UILayer } from "../Layers/UILayer";
|
|
3
|
+
import { UIBlending } from "../Miscellaneous/UIBlending";
|
|
3
4
|
import { UIElement } from "./UIElement";
|
|
4
5
|
/**
|
|
5
6
|
* A UI element that displays an image texture.
|
|
@@ -10,6 +11,7 @@ export declare class UIImage extends UIElement {
|
|
|
10
11
|
private readonly material;
|
|
11
12
|
/** The texture displayed by this image */
|
|
12
13
|
private readonly textureInternal;
|
|
14
|
+
private blendingInternal;
|
|
13
15
|
/**
|
|
14
16
|
* Creates a new image UI element.
|
|
15
17
|
*
|
|
@@ -24,6 +26,8 @@ export declare class UIImage extends UIElement {
|
|
|
24
26
|
get color(): number;
|
|
25
27
|
/** Gets the opacity of the image */
|
|
26
28
|
get opacity(): number;
|
|
29
|
+
/** Gets the blending mode of the image */
|
|
30
|
+
get blending(): UIBlending;
|
|
27
31
|
/**
|
|
28
32
|
* Sets the color tint applied to the image
|
|
29
33
|
* @param value - Color in hexadecimal format
|
|
@@ -34,6 +38,11 @@ export declare class UIImage extends UIElement {
|
|
|
34
38
|
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
35
39
|
*/
|
|
36
40
|
set opacity(value: number);
|
|
41
|
+
/**
|
|
42
|
+
* Sets the blending mode of the image
|
|
43
|
+
* @param value - Blending mode to apply
|
|
44
|
+
*/
|
|
45
|
+
set blending(value: UIBlending);
|
|
37
46
|
/**
|
|
38
47
|
* Destroys the image element, disposing of all resources and removing it from the layer.
|
|
39
48
|
* This should be called when the element is no longer needed.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Texture } from "three";
|
|
2
2
|
import { ShaderMaterial } from "three";
|
|
3
|
+
import { UIBlending } from "../Miscellaneous/UIBlending";
|
|
3
4
|
export declare class UIMaterial extends ShaderMaterial {
|
|
4
5
|
constructor(map?: Texture);
|
|
5
6
|
getTexture(): Texture | undefined;
|
|
@@ -8,4 +9,5 @@ export declare class UIMaterial extends ShaderMaterial {
|
|
|
8
9
|
setTexture(value: Texture | undefined): void;
|
|
9
10
|
setColor(value: number): void;
|
|
10
11
|
setOpacity(value: number): void;
|
|
12
|
+
setBlending(blending: UIBlending): void;
|
|
11
13
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from "./Elements/UIText";
|
|
|
23
23
|
export * from "./Layers/UIFullScreenLayer";
|
|
24
24
|
export * from "./Layers/UILayer";
|
|
25
25
|
export * from "./Miscellaneous/symbols";
|
|
26
|
+
export * from "./Miscellaneous/UIBlending";
|
|
26
27
|
export * from "./Miscellaneous/UIMode";
|
|
27
28
|
export * from "./Miscellaneous/UIOrientation";
|
|
28
29
|
export * from "./Miscellaneous/UITextInterfaces";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as n,Vector3 as h,ShaderMaterial as r,Color as o,PlaneGeometry as e,Scene as l,Mesh as u,OrthographicCamera as a,WebGLRenderTarget as d,UnsignedByteType as c,LinearFilter as v,RGBAFormat as f,NoBlending as w,Object3D as g,UniformsUtils as p,PerspectiveCamera as m,CanvasTexture as y}from"three";function b(){return new x}var x=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var n=new C(t,i());return this.index[t.id()]=this.array.length,this.array.push(n),n}return this.array[s]},t.prototype.insert=function(t,i){var s=new C(t,i),n=this.index[t.id()];return void 0===n?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[n]=s,s},t.prototype.erase=function(t){var i=this.index[t.id()];if(void 0!==i){this.index[t.id()]=void 0;var s=this.array[i],n=this.array.pop();return s!==n&&(this.array[i]=n,this.index[n.first.id()]=i),s}},t.prototype.copy=function(){for(var i=new t,s=0;this.array.length>s;s++){var n=this.array[s].copy();i.array[s]=n,i.index[n.first.id()]=s}return i},t}(),C=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),S=function(){function t(t){void 0===t&&(t=""),this.t=0,this.i=null,this.h=E++,this.o=t}return t.prototype.id=function(){return this.h},t.prototype.name=function(){return this.o},t.prototype.setName=function(t){this.o=t},t.prototype.context=function(){return this.i},t.prototype.setContext=function(t){this.i=t},t.prototype.value=function(){return this.t},t.prototype.setValue=function(t){this.t=t},t.prototype.plus=function(t){return new k(this,t)},t.prototype.minus=function(t){return new k(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new k([t,this])},t.prototype.divide=function(t){return new k([1/t,this])},t.prototype.toJSON=function(){return{name:this.o,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.o+":"+this.t+"]"},t}(),E=0,k=function(){function t(){var t=O(arguments);this.l=t.terms,this.u=t.constant}return t.prototype.terms=function(){return this.l},t.prototype.constant=function(){return this.u},t.prototype.value=function(){for(var t=this.u,i=0,s=this.l.size();s>i;i++){var n=this.l.itemAt(i);t+=n.first.value()*n.second}return t},t.prototype.plus=function(i){return new t(this,i)},t.prototype.minus=function(i){return new t(this,"number"==typeof i?-i:[-1,i])},t.prototype.multiply=function(i){return new t([i,this])},t.prototype.divide=function(i){return new t([1/i,this])},t.prototype.isConstant=function(){return 0==this.l.size()},t.prototype.toString=function(){var t=this.l.array.map((t=>t.second+"*"+t.first)).join(" + ");return this.isConstant()||0===this.u||(t+=" + "),t+this.u},t}();function O(t){for(var i=0,s=()=>0,n=b(),h=0,r=t.length;r>h;++h){var o=t[h];if("number"==typeof o)i+=o;else if(o instanceof S)n.setDefault(o,s).second+=1;else if(o instanceof k){i+=o.constant();for(var e=0,l=(c=o.terms()).size();l>e;e++){var u=c.itemAt(e);n.setDefault(u.first,s).second+=u.second}}else{if(!(o instanceof Array))throw Error("invalid Expression argument: "+o);if(2!==o.length)throw Error("array must have length 2");var a=o[0],d=o[1];if("number"!=typeof a)throw Error("array item 0 must be a number");if(d instanceof S)n.setDefault(d,s).second+=a;else{if(!(d instanceof k))throw Error("array item 1 must be a variable or expression");var c;for(i+=d.constant()*a,e=0,l=(c=d.terms()).size();l>e;e++)u=c.itemAt(e),n.setDefault(u.first,s).second+=u.second*a}}}return{terms:n,constant:i}}var M,T=(()=>{function t(){}return t.create=(t,i,s,n)=>{void 0===n&&(n=1);var h=0;return h+=1e6*Math.max(0,Math.min(1e3,t*n)),(h+=1e3*Math.max(0,Math.min(1e3,i*n)))+Math.max(0,Math.min(1e3,s*n))},t.clip=i=>Math.max(0,Math.min(t.required,i)),t.required=t.create(1e3,1e3,1e3),t.strong=t.create(1,0,0),t.medium=t.create(0,1,0),t.weak=t.create(0,0,1),t})();(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(M||(M={}));var F,I=function(){function t(t,i,s,n){void 0===n&&(n=T.required),this.h=A++,this.v=i,this.p=T.clip(n),this.m=void 0===s&&t instanceof k?t:t.minus(s)}return t.prototype.id=function(){return this.h},t.prototype.expression=function(){return this.m},t.prototype.op=function(){return this.v},t.prototype.strength=function(){return this.p},t.prototype.toString=function(){return this.m+" "+["<=",">=","="][this.v]+" 0 ("+this.p+")"},t}(),A=0,B=function(){function t(){this.C=b(),this.S=b(),this.k=b(),this.O=b(),this.M=[],this.T=new U,this.F=null,this.I=0}return t.prototype.createConstraint=function(t,i,s,n){void 0===n&&(n=T.required);var h=new I(t,i,s,n);return this.addConstraint(h),h},t.prototype.addConstraint=function(t){if(void 0!==this.C.find(t))throw Error("duplicate constraint");var i=this.A(t),s=i.row,n=i.tag,h=this.B(s,n);if(h.type()===F.Invalid&&s.allDummies()){if(!$(s.constant()))throw Error("unsatisfiable constraint");h=n.marker}if(h.type()===F.Invalid){if(!this.$(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.P(h,s),this.S.insert(h,s);this.C.insert(t,n),this.U(this.T)},t.prototype.removeConstraint=function(t){var i=this.C.erase(t);if(void 0===i)throw Error("unknown constraint");this.D(t,i.second);var s=i.second.marker,n=this.S.erase(s);if(void 0===n){var h=this.V(s);if(h.type()===F.Invalid)throw Error("failed to find leaving row");(n=this.S.erase(h)).second.solveForEx(h,s),this.P(s,n.second)}this.U(this.T)},t.prototype.hasConstraint=function(t){return this.C.contains(t)},t.prototype.addEditVariable=function(t,i){if(void 0!==this.O.find(t))throw Error("duplicate edit variable");if((i=T.clip(i))===T.required)throw Error("bad required strength");var s=new k(t),n=new I(s,M.Eq,void 0,i);this.addConstraint(n);var h=this.C.find(n).second;this.O.insert(t,{tag:h,constraint:n,constant:0})},t.prototype.removeEditVariable=function(t){var i=this.O.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)},t.prototype.hasEditVariable=function(t){return this.O.contains(t)},t.prototype.suggestValue=function(t,i){var s=this.O.find(t);if(void 0===s)throw Error("unknown edit variable");var n=this.S,h=s.second,r=i-h.constant;h.constant=i;var o=h.tag.marker,e=n.find(o);if(void 0!==e)return 0>e.second.add(-r)&&this.M.push(o),void this.H();var l=h.tag.other;if(void 0!==(e=n.find(l)))return 0>e.second.add(r)&&this.M.push(l),void this.H();for(var u=0,a=n.size();a>u;++u){var d=n.itemAt(u),c=d.second,v=c.coefficientFor(o);0!==v&&0>c.add(r*v)&&d.first.type()!==F.External&&this.M.push(d.first)}this.H()},t.prototype.updateVariables=function(){for(var t=this.k,i=this.S,s=0,n=t.size();n>s;++s){var h=t.itemAt(s),r=i.find(h.second);h.first.setValue(void 0!==r?r.second.constant():0)}},t.prototype.R=function(t){var i=this;return this.k.setDefault(t,(()=>i.L(F.External))).second},t.prototype.A=function(t){for(var i=t.expression(),s=new U(i.constant()),n=i.terms(),h=0,r=n.size();r>h;++h){var o=n.itemAt(h);if(!$(o.second)){var e=this.R(o.first),l=this.S.find(e);void 0!==l?s.insertRow(l.second,o.second):s.insertSymbol(e,o.second)}}var u=this.T,a=t.strength(),d={marker:P,other:P};switch(t.op()){case M.Le:case M.Ge:var c=t.op()===M.Le?1:-1,v=this.L(F.Slack);if(d.marker=v,s.insertSymbol(v,c),T.required>a){var f=this.L(F.Error);d.other=f,s.insertSymbol(f,-c),u.insertSymbol(f,a)}break;case M.Eq:if(T.required>a){var w=this.L(F.Error),g=this.L(F.Error);d.marker=w,d.other=g,s.insertSymbol(w,-1),s.insertSymbol(g,1),u.insertSymbol(w,a),u.insertSymbol(g,a)}else{var p=this.L(F.Dummy);d.marker=p,s.insertSymbol(p)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:d}},t.prototype.B=(t,i)=>{for(var s=t.cells(),n=0,h=s.size();h>n;++n){var r=s.itemAt(n);if(r.first.type()===F.External)return r.first}var o=i.marker.type();return o!==F.Slack&&o!==F.Error||t.coefficientFor(i.marker)>=0?(o=i.other.type())!==F.Slack&&o!==F.Error||t.coefficientFor(i.other)>=0?P:i.other:i.marker},t.prototype.$=function(t){var i=this.L(F.Slack);this.S.insert(i,t.copy()),this.F=t.copy(),this.U(this.F);var s=$(this.F.constant());this.F=null;var n=this.S.erase(i);if(void 0!==n){var h=n.second;if(h.isConstant())return s;var r=this._(h);if(r.type()===F.Invalid)return!1;h.solveForEx(i,r),this.P(r,h),this.S.insert(r,h)}for(var o=this.S,e=0,l=o.size();l>e;++e)o.itemAt(e).second.removeSymbol(i);return this.T.removeSymbol(i),s},t.prototype.P=function(t,i){for(var s=this.S,n=0,h=s.size();h>n;++n){var r=s.itemAt(n);r.second.substitute(t,i),0>r.second.constant()&&r.first.type()!==F.External&&this.M.push(r.first)}this.T.substitute(t,i),this.F&&this.F.substitute(t,i)},t.prototype.U=function(t){for(;;){var i=this.j(t);if(i.type()===F.Invalid)return;var s=this.N(i);if(s.type()===F.Invalid)throw Error("the objective is unbounded");var n=this.S.erase(s).second;n.solveForEx(s,i),this.P(i,n),this.S.insert(i,n)}},t.prototype.H=function(){for(var t=this.S,i=this.M;0!==i.length;){var s=i.pop(),n=t.find(s);if(void 0!==n&&0>n.second.constant()){var h=this.X(n.second);if(h.type()===F.Invalid)throw Error("dual optimize failed");var r=n.second;t.erase(s),r.solveForEx(s,h),this.P(h,r),t.insert(h,r)}}},t.prototype.j=t=>{for(var i=t.cells(),s=0,n=i.size();n>s;++s){var h=i.itemAt(s),r=h.first;if(0>h.second&&r.type()!==F.Dummy)return r}return P},t.prototype.X=function(t){for(var i=Number.MAX_VALUE,s=P,n=t.cells(),h=0,r=n.size();r>h;++h){var o=n.itemAt(h),e=o.first,l=o.second;if(l>0&&e.type()!==F.Dummy){var u=this.T.coefficientFor(e)/l;i>u&&(i=u,s=e)}}return s},t.prototype.N=function(t){for(var i=Number.MAX_VALUE,s=P,n=this.S,h=0,r=n.size();r>h;++h){var o=n.itemAt(h),e=o.first;if(e.type()!==F.External){var l=o.second,u=l.coefficientFor(t);if(0>u){var a=-l.constant()/u;i>a&&(i=a,s=e)}}}return s},t.prototype.V=function(t){for(var i=Number.MAX_VALUE,s=i,n=i,h=P,r=h,o=h,e=h,l=this.S,u=0,a=l.size();a>u;++u){var d=l.itemAt(u),c=d.second,v=c.coefficientFor(t);if(0!==v){var f=d.first;if(f.type()===F.External)e=f;else if(0>v)s>(w=-c.constant()/v)&&(s=w,r=f);else{var w;n>(w=c.constant()/v)&&(n=w,o=f)}}}return r!==h?r:o!==h?o:e},t.prototype.D=function(t,i){i.marker.type()===F.Error&&this.W(i.marker,t.strength()),i.other.type()===F.Error&&this.W(i.other,t.strength())},t.prototype.W=function(t,i){var s=this.S.find(t);void 0!==s?this.T.insertRow(s.second,-i):this.T.insertSymbol(t,-i)},t.prototype._=t=>{for(var i=t.cells(),s=0,n=i.size();n>s;++s){var h=i.itemAt(s),r=h.first.type();if(r===F.Slack||r===F.Error)return h.first}return P},t.prototype.L=function(t){return new z(t,this.I++)},t}();function $(t){return 0>t?1e-8>-t:1e-8>t}(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"})(F||(F={}));var z=function(){function t(t,i){this.h=i,this.Y=t}return t.prototype.id=function(){return this.h},t.prototype.type=function(){return this.Y},t}(),P=new z(F.Invalid,-1),U=function(){function t(t){void 0===t&&(t=0),this.q=b(),this.u=t}return t.prototype.cells=function(){return this.q},t.prototype.constant=function(){return this.u},t.prototype.isConstant=function(){return this.q.empty()},t.prototype.allDummies=function(){for(var t=this.q,i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==F.Dummy)return!1;return!0},t.prototype.copy=function(){var i=new t(this.u);return i.q=this.q.copy(),i},t.prototype.add=function(t){return this.u+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),$(this.q.setDefault(t,(()=>0)).second+=i)&&this.q.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this.u+=t.u*i;for(var s=t.q,n=0,h=s.size();h>n;++n){var r=s.itemAt(n);this.insertSymbol(r.first,r.second*i)}},t.prototype.removeSymbol=function(t){this.q.erase(t)},t.prototype.reverseSign=function(){this.u=-this.u;for(var t=this.q,i=0,s=t.size();s>i;++i){var n=t.itemAt(i);n.second=-n.second}},t.prototype.solveFor=function(t){var i=this.q,s=-1/i.erase(t).second;this.u*=s;for(var n=0,h=i.size();h>n;++n)i.itemAt(n).second*=s},t.prototype.solveForEx=function(t,i){this.insertSymbol(t,-1),this.solveFor(i)},t.prototype.coefficientFor=function(t){var i=this.q.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.q.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const D=Symbol("xSymbol"),V=Symbol("ySymbol"),H=Symbol("widthSymbol"),R=Symbol("heightSymbol"),L=Symbol("addUIElementSymbol"),_=Symbol("removeUIElementSymbol"),j=Symbol("addConstraintSymbol"),N=Symbol("removeUIConstraintSymbol"),X=Symbol("addConstraintSymbol"),W=Symbol("removeConstraintSymbol"),Y=Symbol("addVariableSymbol"),q=Symbol("removeVariableSymbol"),G=Symbol("suggestVariableSymbol"),Q=Symbol("disableConstraintSymbol"),J=Symbol("enableConstraintSymbol"),K=Symbol("needsRecalculation"),Z=Symbol("renderSymbol"),tt=Symbol("clickSymbol"),it=Symbol("sortSymbol");var st;function nt(t){return null!==t&&Object.values(st).some((i=>i===t))}function ht(t){return null!=t?t:st.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(st||(st={}));class rt{constructor(t,i){this.layer=t,this.name="",this.layer[j](this,i)}destroy(){this.layer[N](this)}}const ot=1e3;var et,lt,ut,at,dt;function ct(t){return null!==t&&Object.values(et).some((i=>i===t))}function vt(t){return null!=t?t:et.P0}function ft(t){switch(t){case et.P0:return T.create(ot,ot,ot);case et.P1:return T.create(100,0,0);case et.P2:return T.create(10,0,0);case et.P3:return T.create(0,100,0);case et.P4:return T.create(0,10,0);case et.P5:return T.create(0,0,100);case et.P6:return T.create(0,0,10);case et.P7:return T.create(0,0,1);default:return T.create(ot,ot,ot)}}function wt(t){return null!==t&&Object.values(lt).some((i=>i===t))}function gt(t){return null!=t?t:lt.EQUAL}function pt(t){switch(t){case lt.EQUAL:return M.Eq;case lt.LESS:return M.Le;case lt.GREATER:return M.Ge;default:return M.Eq}}(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"})(et||(et={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(lt||(lt={}));class mt extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={height:null!==(s=null==i?void 0:i.height)&&void 0!==s?s:t.height,power:vt(null==i?void 0:i.power),rule:gt(null==i?void 0:i.rule),orientation:ht(null==i?void 0:i.orientation)},this.options.orientation!==st.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==st.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==st.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new I(new k(this.element[R]),pt(this.options.rule),this.options.height,ft(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class yt{constructor(){this.listeners=new Map,this.signatures=new WeakMap}on(t,i,s,n=100){return this.addListener(t,i,s,n,!1),this}once(t,i,s,n=100){return this.addListener(t,i,s,n,!0),this}off(t,i,s){const n=this.listeners.get(t);if(!(null==n?void 0:n.length))return this.listeners.delete(t),this;if(!i){this.listeners.delete(t);for(const t of n){const i=this.signatures.get(t.callback);i&&(i.delete(t.context),0===i.size&&this.signatures.delete(t.callback))}return this}let h=0;for(let t=0;n.length>t;t++){const r=n[t];if(r.callback!==i||void 0!==s&&r.context!==s)h!==t&&(n[h]=r),h++;else{const t=this.signatures.get(i);t&&(t.delete(r.context),0===t.size&&this.signatures.delete(i))}}return 0===h?this.listeners.delete(t):n.length=h,this}emit(t,...i){const s=this.listeners.get(t);if(!(null==s?void 0:s.length))return!1;const n=s.slice();let h=!1;for(let t=0;n.length>t;t++){const s=n[t];s.callback.apply(s.context,i),s.once&&(h=!0,s.calledAtLeastOnce=!0)}if(h){let i=0;for(let t=0;s.length>t;t++){const n=s[t];if(n.calledAtLeastOnce){const t=this.signatures.get(n.callback);t&&(t.delete(n.context),0===t.size&&this.signatures.delete(n.callback))}else i!==t&&(s[i]=n),i++}0===i?this.listeners.delete(t):s.length=i}return!0}addListener(t,i,s,n,h){let r=this.signatures.get(i);if(void 0!==r){if(r.has(s))throw Error("Event listener already exists")}else r=new Set,this.signatures.set(i,r);r.add(s);const o={callback:i,context:s,priority:n,once:h,calledAtLeastOnce:!1};let e=this.listeners.get(t);if(void 0===e)return void this.listeners.set(t,[o]);let l=0,u=e.length;for(;u>l;){const t=l+u>>>1;e[t].priority>n?u=t:l=t+1}e.splice(l,0,o)}}class bt extends yt{constructor(i,s,n,h){super(),this.layer=i,this.object=h,this[ut]=new S("x"),this[at]=new S("y"),this[dt]=!1,this.name=t.generateUUID(),this.object&&(this.object.matrixAutoUpdate=!1),this.layer[L](this,h),this.layer[Y](this,this[D],ft(et.P7)),this.layer[Y](this,this[V],ft(et.P7)),this[D].setValue(s),this[V].setValue(n),this.layer[G](this,this[D],s),this.layer[G](this,this[V],n)}get x(){return this[D].value()}get y(){return this[V].value()}get zIndex(){var t,i;return null!==(i=null===(t=this.object)||void 0===t?void 0:t.position.z)&&void 0!==i?i:0}get needsRecalculation(){return this[K]}set x(t){this.layer[G](this,this[D],t)}set y(t){this.layer[G](this,this[V],t)}set zIndex(t){this.object&&this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[it](),this.object.updateMatrix())}destroy(){this.layer[q](this,this[V]),this.layer[q](this,this[D]),this.layer[_](this)}[(ut=D,at=V,dt=K,Z)](t,i){this.render(t,i)}applyTransformations(){this[K]&&(this.object&&this.object.updateMatrix(),this[K]=!1)}}const xt=new i,Ct=new s,St=new n,Et=new n,kt=new n,Ot=new n,Mt=new n,Tt=new h,Ft=.5;class It{constructor(){this.x=0,this.y=0,this.anchorX=Ft,this.anchorY=Ft,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=!1}}class At{constructor(t,i){this.raw=t,this.owner=i}get x(){return this.raw.x}get y(){return this.raw.y}get anchorX(){return this.raw.anchorX}get anchorY(){return this.raw.anchorY}get scaleX(){return this.raw.scaleX}get scaleY(){return this.raw.scaleY}get angle(){return t.radToDeg(this.raw.rotation)}get rotation(){return this.raw.rotation}set x(t){t!==this.raw.x&&(this.raw.x=t,this.raw.needsRecalculation=!0)}set y(t){t!==this.raw.y&&(this.raw.y=t,this.raw.needsRecalculation=!0)}set anchorX(t){t!==this.raw.anchorX&&(this.raw.anchorX=t,this.raw.needsRecalculation=!0)}set anchorY(t){t!==this.raw.anchorY&&(this.raw.anchorY=t,this.raw.needsRecalculation=!0)}set scaleX(t){t!==this.raw.scaleX&&(this.raw.scaleX=t,this.raw.needsRecalculation=!0)}set scaleY(t){t!==this.raw.scaleY&&(this.raw.scaleY=t,this.raw.needsRecalculation=!0)}set angle(i){const s=t.degToRad(i);s!==this.raw.rotation&&(this.raw.rotation=s,this.raw.needsRecalculation=!0)}set rotation(t){t!==this.raw.rotation&&(this.raw.rotation=t,this.raw.needsRecalculation=!0)}setAnchorByGlobalPosition(t,i){const s=(t-this.owner.x)/this.owner.width,n=(i-this.owner.y)/this.owner.height;s===this.raw.anchorX&&n===this.raw.anchorY||(this.raw.anchorX=s,this.raw.anchorY=n,this.raw.needsRecalculation=!0)}reset(){0===this.raw.x&&0===this.raw.y&&this.raw.anchorX===Ft&&this.raw.anchorY===Ft&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Ft,this.raw.anchorY=Ft,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=!0)}}var Bt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(Bt||(Bt={}));class $t extends r{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new o(1,1,1)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}setTexture(t){this.uniforms.map.value=t,this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}}const zt=new e(1,1).translate(.5,.5,0),Pt=new l,Ut=new u(zt);Pt.add(Ut);class Dt{constructor(t=0,i=0){this.paddingHorizontalInternal=t,this.paddingVerticalInternal=i,this.camera=new a(-1,1,1,-1,0,1),this.updateCameraTransform()}get paddingHorizontal(){return this.paddingHorizontalInternal}get paddingVertical(){return this.paddingVerticalInternal}set paddingHorizontal(t){this.paddingHorizontalInternal!==t&&(this.paddingHorizontalInternal=t,this.updateCameraTransform())}set paddingVertical(t){this.paddingVerticalInternal!==t&&(this.paddingVerticalInternal=t,this.updateCameraTransform())}render(t,i){Ut.material=i,t.render(Pt,this.camera)}updateCameraTransform(){this.camera.left=-this.paddingHorizontalInternal,this.camera.right=1+this.paddingHorizontalInternal,this.camera.bottom=-this.paddingVerticalInternal,this.camera.top=1+this.paddingVerticalInternal,this.camera.updateProjectionMatrix()}}class Vt{constructor(){this.passes=[],this.defaultMaterial=new $t,this.screen=new Dt,this.needsUpdateInternal=!1,this.paddingHasChangedInternal=!1,this.paddingInternal=0;const t={format:f,minFilter:v,magFilter:v,type:c,depthBuffer:!1,stencilBuffer:!1};this.fromRenderTarget=new d(1,1,t),this.toRenderTarget=new d(1,1,t),this.fromRenderTarget.texture.generateMipmaps=!1,this.toRenderTarget.texture.generateMipmaps=!1}get needsUpdate(){return this.needsUpdateInternal&&this.hasValuablePasses()||this.hasPassesNeedingUpdate()}get paddingHasChanged(){return this.paddingHasChangedInternal}get padding(){return this.paddingInternal}requestUpdate(){this.needsUpdateInternal=!0}compose(t,i,s,n,h=!0){const r=this.hasValuablePasses();if(!(this.needsUpdateInternal&&r||this.hasPassesNeedingUpdate()))return r||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=!1,r?this.defaultMaterial:n;const o=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==o,this.paddingInternal=o;const e=i+2*o,l=s+2*o;this.fromRenderTarget.setSize(e,l),this.toRenderTarget.setSize(e,l),this.setScreenPadding(i,s,o),t.setClearColor(0,0),t.setRenderTarget(this.toRenderTarget),t.clear(!0,!1,!1);const u=n.blending;h&&(n.blending=w),this.screen.render(t,n),n.blending=u;const a={width:i,height:s,padding:o};for(let i=0;this.passes.length>i;i++){const s=this.passes[i];(s.needsUpdate||s.isValuable)&&(this.reverseRenderTargets(),t.setRenderTarget(this.toRenderTarget),t.clear(!0,!1,!1),this.passes[i].render(t,this.fromRenderTarget.texture,a))}return this.needsUpdateInternal=!1,this.defaultMaterial.setTexture(this.toRenderTarget.texture),this.defaultMaterial}destroy(){this.fromRenderTarget.dispose(),this.toRenderTarget.dispose()}hasValuablePasses(){return this.passes.some((t=>t.isValuable))}hasPassesNeedingUpdate(){return this.passes.some((t=>t.needsUpdate))}calculatePadding(){return this.passes.reduce(((t,i)=>Math.max(t,i.padding)),0)}setScreenPadding(t,i,s){this.screen.paddingHorizontal=s/t,this.screen.paddingVertical=s/i}reverseRenderTargets(){const t=this.fromRenderTarget;this.fromRenderTarget=this.toRenderTarget,this.toRenderTarget=t}}class Ht{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var Rt,Lt,_t,jt,Nt,Xt,Wt,Yt,qt,Gt;(t=>{t.CLICK="click"})(Xt||(Xt={}));class Qt extends yt{constructor(i,s,n,h,r,o){super(),this.layer=i,this.object=s,this[Rt]=new S("x"),this[Lt]=new S("y"),this[_t]=new S("width"),this[jt]=new S("height"),this[Nt]=!1,this.name=t.generateUUID(),this.microInternal=new It,this.composerInternal=new Vt,this.modeInternal=Bt.VISIBLE,this.micro=new At(this.microInternal,this),this.composer=new Ht(this.composerInternal),this.object.matrixAutoUpdate=!1,this.layer[L](this,this.object),this.layer[Y](this,this[D],ft(et.P7)),this.layer[Y](this,this[V],ft(et.P7)),this.layer[Y](this,this[H],ft(et.P5)),this.layer[Y](this,this[R],ft(et.P5)),this[D].setValue(n),this[V].setValue(h),this[H].setValue(r),this[R].setValue(o),this.layer[G](this,this[D],n),this.layer[G](this,this[V],h),this.layer[G](this,this[H],r),this.layer[G](this,this[R],o)}get x(){return this[D].value()}get y(){return this[V].value()}get width(){return this[H].value()}get height(){return this[R].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[K]}set x(t){this.layer[G](this,this[D],t)}set y(t){this.layer[G](this,this[V],t)}set width(t){this.layer[G](this,this[H],t)}set height(t){this.layer[G](this,this[R],t)}set zIndex(t){this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[it](),this.object.updateMatrix())}set mode(t){this.modeInternal=t,this.object.visible=t!==Bt.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[q](this,this[R]),this.layer[q](this,this[H]),this.layer[q](this,this[V]),this.layer[q](this,this[D]),this.layer[_](this)}[(Rt=D,Lt=V,_t=H,jt=R,Nt=K,Z)](t,i){this.render(t,i)}[tt](t,i){return this.click(t,i)}applyTransformations(){(this[K]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,n,h,r,o)=>{const e=this.x-o,l=this.y-o,u=this.width+2*o,a=this.height+2*o,d=e+u*i.anchorX,c=l+a*i.anchorY,v=St.set(1,0,-d,0,1,-c,0,0,1),f=Et.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=kt.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=Ot.set(1,0,i.x+d,0,1,i.y+c,0,0,1),p=Mt.multiplyMatrices(g,w).multiply(f).multiply(v),m=Tt.set(e,l,1).applyMatrix3(p);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=u*i.scaleX,t.scale.y=a*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this.object.updateMatrix(),this[K]=!1,this.microInternal.needsRecalculation=!1)}click(t,i){return this.mode===Bt.INTERACTIVE&&(this.applyTransformations(),s=this.x,n=this.y,h=this.width,r=this.height,xt.set(t,i),Ct.min.set(s,n),Ct.max.set(h,r).add(Ct.min),!!Ct.containsPoint(xt)&&(this.emit(Xt.CLICK,this),!0));var s,n,h,r}}const Jt=new o(0);var Kt,Zt,ti;(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.CLICK="click"})(Kt||(Kt={}));class ii extends yt{constructor(){super(...arguments),this.mode=Bt.VISIBLE,this[Wt]=new S,this[Yt]=new S,this[qt]=new S,this[Gt]=new S,this.scene=new l,this.camera=new a,this.solver=new B,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=st.PORTRAIT,this.needsRecalculation=!1}get orientation(){return this.orientationPrivate}get width(){return this[H].value()}get height(){return this[R].value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(Wt=D,Yt=V,qt=H,Gt=R,L)](t,i,s){if(this.elements.has(t))throw Error("Element already added");if(this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i){const t=null!=s?s:this.scene.children.length;i.position.z=t,i.renderOrder=t,this.scene.add(i),this[it]()}}[_](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),i.object&&this.scene.remove(i.object)}[j](t,i){if(this.constraints.has(t))throw Error("Constraint already added");for(const s of i){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(i.constraints.has(t))throw Error("Something went wrong");i.constraints.add(t)}this.constraints.set(t,{elements:i,variables:new Map,constraints:new Set})}[N](t){const i=this.constraints.get(t);if(void 0===i)throw Error("Constraint not found");if(i.variables.size>0)throw Error("Variables should be removed before removing constraint");if(i.constraints.size>0)throw Error("Constraints should be removed before removing constraint");for(const s of i.elements){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(!i.constraints.has(t))throw Error("Something went wrong");i.constraints.delete(t)}this.constraints.delete(t)}[X](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before adding constraint you need to add it's owner");if(n.constraints.has(i))throw Error("Constraint already exists");n.constraints.add(i);try{null===(s=this.solver)||void 0===s||s.addConstraint(i)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[W](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before removing constraint you need to add it's owner");if(!n.constraints.has(i))throw Error("Constraint not found");n.constraints.delete(i);try{null===(s=this.solver)||void 0===s||s.removeConstraint(i)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[Y](t,i,s){var n;const h=t instanceof Qt||t instanceof bt?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before adding variable you need to add it's owner");if(h.variables.has(i))throw Error("Variable already exists");h.variables.set(i,{strength:s,suggestedValue:i.value()});try{null===(n=this.solver)||void 0===n||n.addEditVariable(i,s)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[q](t,i){var s;const n=t instanceof Qt||t instanceof bt?this.elements.get(t):this.constraints.get(t);if(void 0===n)throw Error("Before removing variable you need to add it's owner");if(!n.variables.has(i))throw Error("Variable does not exist");n.variables.delete(i);try{null===(s=this.solver)||void 0===s||s.removeEditVariable(i)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[G](t,i,s){var n;const h=t instanceof Qt||t instanceof bt?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before suggesting variable you need to add it's owner");const r=h.variables.get(i);if(!r)throw Error("Variable does not exist");if(r.suggestedValue!==s){r.suggestedValue=s;try{null===(n=this.solver)||void 0===n||n.suggestValue(i,s)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}}[it](){this.scene.children.sort(((t,i)=>t.position.z-i.position.z));for(let t=0;this.scene.children.length>t;t++){const i=this.scene.children[t];i.position.z=t,i.renderOrder=t}this.camera.position.set(0,0,this.scene.children.length+1),this.camera.near=1,this.camera.far=this.scene.children.length+1+1,this.camera.updateProjectionMatrix(),this.camera.updateMatrix()}render(t,i){var s;if(this.mode===Bt.HIDDEN)return;const n=t.getRenderTarget(),h=t.getClearColor(Jt),r=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=!1,null===(s=this.solver)||void 0===s||s.updateVariables();for(const t of this.elements.keys())t[K]=!0}for(const s of this.elements.keys())s[Z](t,i);t.setRenderTarget(n),t.setClearColor(h),t.setClearAlpha(r),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==Bt.INTERACTIVE)return;this.emit(Kt.CLICK,this,t,i);const s=[...this.elements.keys()].filter((t=>t instanceof Qt)).filter((t=>t.mode===Bt.INTERACTIVE)).sort(((t,i)=>t.zIndex-i.zIndex));for(const n of s)if(n[tt](t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=!0}applyCameraSize(t,i){this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){var s,n,h,r,o,e,l,u;this.constraintX&&(null===(s=this.solver)||void 0===s||s.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(null===(n=this.solver)||void 0===n||n.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(null===(h=this.solver)||void 0===h||h.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(null===(r=this.solver)||void 0===r||r.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new I(new k(this[D]),M.Eq,0,T.required),this.constraintY=new I(new k(this[V]),M.Eq,0,T.required),this.constraintW=new I(new k(this[H]),M.Eq,t,T.required),this.constraintH=new I(new k(this[R]),M.Eq,i,T.required),null===(o=this.solver)||void 0===o||o.addConstraint(this.constraintX),null===(e=this.solver)||void 0===e||e.addConstraint(this.constraintY),null===(l=this.solver)||void 0===l||l.addConstraint(this.constraintW),null===(u=this.solver)||void 0===u||u.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?st.LANDSCAPE:st.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t[J](this.orientationPrivate);for(const t of this.constraints.keys())t[Q](this.orientationPrivate);this.solver=new B;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i);this.emit(Kt.ORIENTATION_CHANGED,this,this.orientation)}}rebuildSolver(){try{this.solver=void 0,this.solver=new B;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i)}catch(t){throw t}}}function si(t,i){if((t instanceof ii?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function ni(t,i,s){if(0>=t||0>=i)throw Error(null!=s?s:`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class hi extends rt{constructor(t,i,s){var n,h,r;si(t,i),super(i.layer,new Set(t instanceof Qt||t instanceof bt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(h=null==s?void 0:s.anchorTwo)&&void 0!==h?h:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:vt(null==s?void 0:s.power),rule:gt(null==s?void 0:s.rule),orientation:ht(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof Qt||this.elementOne instanceof ii?new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.anchorOne)):new k(this.elementOne[D]),i=this.elementTwo instanceof Qt?new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.anchorTwo)):new k(this.elementTwo[D]);this.constraint=new I(i.minus(t),pt(this.parameters.rule),this.parameters.distance,ft(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class ri extends rt{constructor(t,i,s){var n;si(t,i),super(i.layer,new Set(t instanceof Qt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:vt(null==s?void 0:s.power),rule:gt(null==s?void 0:s.rule),orientation:ht(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.elementOne[H]).multiply(this.parameters.proportion),i=new k(this.elementTwo[H]);this.constraint=new I(t.minus(i),pt(this.parameters.rule),0,ft(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class oi extends rt{constructor(t,i,s){var n,h,r;si(t,i),super(i.layer,new Set(t instanceof Qt||t instanceof bt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(h=null==s?void 0:s.anchorTwo)&&void 0!==h?h:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:vt(null==s?void 0:s.power),rule:gt(null==s?void 0:s.rule),orientation:ht(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof Qt||this.elementOne instanceof ii?new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.anchorOne)):new k(this.elementOne[V]),i=this.elementTwo instanceof Qt?new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.anchorTwo)):new k(this.elementTwo[V]);this.constraint=new I(i.minus(t),pt(this.parameters.rule),this.parameters.distance,ft(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class ei extends rt{constructor(t,i,s){var n;si(t,i),super(i.layer,new Set(t instanceof Qt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:vt(null==s?void 0:s.power),rule:gt(null==s?void 0:s.rule),orientation:ht(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.elementOne[R]).multiply(this.parameters.proportion),i=new k(this.elementTwo[R]);this.constraint=new I(t.minus(i),pt(this.parameters.rule),0,ft(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class li extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={width:null!==(s=null==i?void 0:i.width)&&void 0!==s?s:t.width,power:vt(null==i?void 0:i.power),rule:gt(null==i?void 0:i.rule),orientation:ht(null==i?void 0:i.orientation)},this.options.orientation!==st.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==st.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==st.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new I(new k(this.element[H]),pt(this.options.rule),this.options.width,ft(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class ui{static size(t,i){var s,n,h,r,o,e,l,u;return{x:new li(t,{width:null===(s=i.size)||void 0===s?void 0:s.x,power:null===(n=i.power)||void 0===n?void 0:n.x,rule:null===(h=i.rule)||void 0===h?void 0:h.x,orientation:null===(r=i.orientation)||void 0===r?void 0:r.x}),y:new mt(t,{height:null===(o=i.size)||void 0===o?void 0:o.y,power:null===(e=i.power)||void 0===e?void 0:e.y,rule:null===(l=i.rule)||void 0===l?void 0:l.y,orientation:null===(u=i.orientation)||void 0===u?void 0:u.y})}}static distance(t,i,s){var n,h,r,o,e,l,u,a,d,c,v,f;return{x:new hi(t,i,{anchorOne:null===(n=s.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(h=s.anchorTwo)||void 0===h?void 0:h.x,distance:null===(r=s.distance)||void 0===r?void 0:r.x,power:null===(o=s.power)||void 0===o?void 0:o.x,rule:null===(e=s.rule)||void 0===e?void 0:e.x,orientation:null===(l=s.orientation)||void 0===l?void 0:l.x}),y:new oi(t,i,{anchorOne:null===(u=s.anchorOne)||void 0===u?void 0:u.y,anchorTwo:null===(a=s.anchorTwo)||void 0===a?void 0:a.y,distance:null===(d=s.distance)||void 0===d?void 0:d.y,power:null===(c=s.power)||void 0===c?void 0:c.y,rule:null===(v=s.rule)||void 0===v?void 0:v.y,orientation:null===(f=s.orientation)||void 0===f?void 0:f.y})}}static proportion(t,i,s){var n,h,r,o,e,l,u,a;return{x:new ri(t,i,{proportion:null===(n=s.proportion)||void 0===n?void 0:n.x,power:null===(h=s.power)||void 0===h?void 0:h.x,rule:null===(r=s.rule)||void 0===r?void 0:r.x,orientation:null===(o=s.orientation)||void 0===o?void 0:o.x}),y:new ei(t,i,{proportion:null===(e=s.proportion)||void 0===e?void 0:e.y,power:null===(l=s.power)||void 0===l?void 0:l.y,rule:null===(u=s.rule)||void 0===u?void 0:u.y,orientation:null===(a=s.orientation)||void 0===a?void 0:a.y})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(Zt||(Zt={}));class ai{static build(t,i,s,n={}){var h;const r=null!==(h=n.direction)&&void 0!==h?h:Zt.FROM_LEFT_TOP,o=[],e=[];o.push(new hi(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new hi(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const l=r===Zt.FROM_LEFT_TOP?1:0,u=r===Zt.FROM_LEFT_TOP?0:1;return e.push(new oi(t,i,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation}),new oi(t,s,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:o,verticalDistances:e}}}class di{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:hi,proportionConstraint:ri,centerDistanceConstraint:oi})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:oi,proportionConstraint:ei,centerDistanceConstraint:hi})}static buildStack(t,i,s){const n=[],h=[],r=[];for(let o=0;t.length-1>o;o++){const e=t[o],l=t[o+1];n.push(new s.distanceConstraint(e,l,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),!1!==i.keepProportions&&h.push(new s.proportionConstraint(e,l,{power:i.power,orientation:i.orientation})),!1!==i.keepAlignment&&r.push(new s.centerDistanceConstraint(e,l,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:h,alignmentConstraints:r}}}class ci extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.parameters={aspect:null!==(s=null==i?void 0:i.aspect)&&void 0!==s?s:this.element.width/this.element.height,power:vt(null==i?void 0:i.power),rule:gt(null==i?void 0:i.rule),orientation:ht(null==i?void 0:i.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.element[H]).plus(new k(this.element[R]).multiply(-this.parameters.aspect));this.constraint=new I(t,pt(this.parameters.rule),0,ft(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[W](this,this.constraint),this.constraint=void 0)}}class vi extends rt{constructor(t,i,s){var n,h,r;si(t,i),super(i.layer,new Set(t instanceof Qt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={isStrict:null===(n=null==s?void 0:s.isStrict)||void 0===n||n,horizontalAnchor:null!==(h=null==s?void 0:s.horizontalAnchor)&&void 0!==h?h:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ht(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new I(new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.horizontalAnchor)),M.Eq,new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new I(new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new I(new k(this.elementOne[H]),M.Le,new k(this.elementTwo[H])),this.constraintH=new I(new k(this.elementOne[R]),M.Le,new k(this.elementTwo[R])),this.layer[X](this,this.constraintX),this.layer[X](this,this.constraintY),this.layer[X](this,this.constraintW),this.layer[X](this,this.constraintH),this.parameters.isStrict||(this.constraintStrict=new I(new k(this.elementOne[R]),M.Eq,new k(this.elementTwo[R]),T.strong),this.layer[X](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[W](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[W](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[W](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[W](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[W](this,this.constraintStrict),this.constraintStrict=void 0)}}class fi extends rt{constructor(t,i,s){var n,h,r;super(i.layer,new Set(t instanceof Qt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,si(t,i),this.parameters={isStrict:null===(n=null==s?void 0:s.isStrict)||void 0===n||n,horizontalAnchor:null!==(h=null==s?void 0:s.horizontalAnchor)&&void 0!==h?h:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ht(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new I(new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.horizontalAnchor)),M.Eq,new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new I(new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new I(new k(this.elementOne[H]),M.Ge,new k(this.elementTwo[H])),this.constraintH=new I(new k(this.elementOne[R]),M.Ge,new k(this.elementTwo[R])),this.layer[X](this,this.constraintX),this.layer[X](this,this.constraintY),this.layer[X](this,this.constraintW),this.layer[X](this,this.constraintH),!1!==this.parameters.isStrict&&(this.constraintStrict=new I(new k(this.elementOne[R]),M.Eq,new k(this.elementTwo[R]),T.strong),this.layer[X](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[W](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[W](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[W](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[W](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[W](this,this.constraintStrict),this.constraintStrict=void 0)}}class wi extends Qt{constructor(t,i=100,s=100){super(t,new g,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class gi extends Qt{constructor(t,i){var s,n;const h=null===(s=i.image)||void 0===s?void 0:s.width,r=null===(n=i.image)||void 0===n?void 0:n.height;ni(h,r,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${h}) or height (${r}). Image dimensions must be non-zero positive numbers.`);const o=new $t(i);super(t,new u(zt,o),0,0,h,r),this.material=o,this.textureInternal=i,this.applyTransformations()}get texture(){return this.textureInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.textureInternal.image.width,this.textureInternal.image.height,this.material),this.applyTransformations()}}class pi extends r{constructor(t,i){super({uniforms:p.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new o(1,1,1)},foregroundColor:{value:new o(1,1,1)},color:{value:new o(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},opacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}getProgress(){return this.uniforms.progress.value}getBackgroundTexture(){return this.uniforms.background.value}getForegroundTexture(){return this.uniforms.foreground.value}getBackgroundColor(){return this.uniforms.color.value.getHex()}getForegroundColor(){return this.uniforms.color.value.getHex()}getColor(){return this.uniforms.color.value.getHex()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.value}getOpacity(){return this.uniforms.opacity.value}getAngle(){return this.uniforms.angle.value}getIsForwardDirection(){return 1===this.uniforms.direction.value}setProgress(t){this.uniforms.progress.value=t,this.uniformsNeedUpdate=!0}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=!0}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=!0}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=!0}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=!0}}class mi extends Qt{constructor(i,s,n={}){var h,r,o,e,l,a;const d=null===(h=s.image)||void 0===h?void 0:h.width,c=null===(r=s.image)||void 0===r?void 0:r.height;ni(d,c,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(e=null===(o=n.textureBackground)||void 0===o?void 0:o.image)||void 0===e?void 0:e.width,f=null===(a=null===(l=n.textureBackground)||void 0===l?void 0:l.image)||void 0===a?void 0:a.height;n.textureBackground&&ni(v,f,`Invalid image dimensions - texture "${n.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new pi(s,n.textureBackground),g=new u(zt,w);n.progress&&w.setProgress(n.progress),n.isForegroundDirection&&w.setIsForwardDirection(n.isForegroundDirection),n.angle&&w.setAngle(t.degToRad(n.angle)),n.color&&w.setColor(n.color),n.opacity&&w.setOpacity(n.opacity),n.backgroundColor&&w.setBackgroundColor(n.backgroundColor),n.foregroundColor&&w.setForegroundColor(n.foregroundColor),n.backgroundOpacity&&w.setBackgroundOpacity(n.backgroundOpacity),n.foregroundOpacity&&w.setForegroundOpacity(n.foregroundOpacity);const p=null!=v?v:d,m=null!=c?c:f;super(i,g,0,0,p,m),this.material=w,this.imageWidth=p,this.imageHeight=m,this.applyTransformations()}get progress(){return this.material.getProgress()}get backgroundTexture(){return this.material.getBackgroundTexture()}get foregroundTexture(){return this.material.getForegroundTexture()}get backgroundColor(){return this.material.getBackgroundColor()}get foregroundColor(){return this.material.getForegroundColor()}get color(){return this.material.getColor()}get backgroundOpacity(){return this.material.getBackgroundOpacity()}get foregroundOpacity(){return this.material.getForegroundOpacity()}get opacity(){return this.material.getOpacity()}get angle(){return t.radToDeg(this.material.getAngle())}get isForwardDirection(){return this.material.getIsForwardDirection()}set progress(t){this.material.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.material.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.material.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.material.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.material.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set angle(i){this.material.setAngle(t.degToRad(i)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.material.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.imageWidth,this.imageHeight,this.material),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(ti||(ti={}));const yi=ti.PROPERTY_CHANGED;class bi extends Qt{constructor(t,i={}){var s,n,h,r,o,e,a,w,g,p;const y=null!==(s=i.resolutionFactor)&&void 0!==s?s:.5;if(.1>y||y>8)throw Error(`Invalid resolution factor: ${y}. Must be between 0.1 and 8.`);const b=null!==(n=i.width)&&void 0!==n?n:512,x=null!==(h=i.height)&&void 0!==h?h:512;ni(b,x,`Invalid width or height: ${b}x${x}. Must be positive.`);const C=new d(b*y,x*y,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null===(r=i.useDepth)||void 0===r||r,stencilBuffer:!1}),S=new $t(C.texture);super(t,new u(zt,S),0,0,b,x),this.needsRenderInternal=!1,this.sceneInternal=null!==(o=i.scene)&&void 0!==o?o:new l,this.cameraInternal=null!==(e=i.camera)&&void 0!==e?e:new m(75,b/x,.1,100),this.resolutionFactorInternal=y,this.updateModeInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:yi,null!==(w=i.renderedByDefault)&&void 0!==w&&w&&(this.needsRenderInternal=!0),this.clearColorInternal=null!==(g=i.clearColor)&&void 0!==g?g:0,this.clearAlphaInternal=null!==(p=i.clearAlpha)&&void 0!==p?p:0,this.renderTarget=C,this.material=S,this.applyTransformations()}get needsRender(){return this.needsRenderInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}get scene(){return this.sceneInternal}get camera(){return this.cameraInternal}get clearColor(){return this.clearColorInternal}get clearAlpha(){return this.clearAlphaInternal}get resolutionFactor(){return this.resolutionFactorInternal}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.sceneInternal!==t&&(this.sceneInternal=t,this.updateModeInternal===ti.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===ti.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===ti.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===ti.PROPERTY_CHANGED&&this.requestRender())}set resolutionFactor(t){this.resolutionFactorInternal!==t&&(this.resolutionFactorInternal=t,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),this.updateModeInternal===ti.PROPERTY_CHANGED&&this.requestRender())}destroy(){this.material.dispose(),this.renderTarget.dispose(),super.destroy()}requestRender(){this.needsRenderInternal=!0,this.composerInternal.requestUpdate()}render(t){(this.needsRenderInternal||this.updateModeInternal===ti.ALWAYS)&&(this.needsRenderInternal=!1,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),t.setClearColor(this.clearColorInternal,this.clearAlpha),t.setRenderTarget(this.renderTarget),t.clear(!0,!0,!1),t.render(this.sceneInternal,this.cameraInternal)),this.object.material=this.composerInternal.compose(t,this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal,this.material),this.applyTransformations()}}function xi(t,i){var s,n,h,r,o,e,l,u,a,d,c,v,f,w,g,p,m,y,b,x,C,S,E,k,O,M,T,F;const I=Math.max(null!==(n=null!==(s=null==t?void 0:t.fontSize)&&void 0!==s?s:null==i?void 0:i.fontSize)&&void 0!==n?n:16,1),A=null!==(r=null!==(h=null==t?void 0:t.lineHeight)&&void 0!==h?h:null==i?void 0:i.lineHeight)&&void 0!==r?r:1.2*I,B=Math.max(null!==(e=null!==(o=null==t?void 0:t.shadowBlur)&&void 0!==o?o:null==i?void 0:i.shadowBlur)&&void 0!==e?e:0,0),$=Math.max(null!==(u=null!==(l=null==t?void 0:t.strokeWidth)&&void 0!==l?l:null==i?void 0:i.strokeWidth)&&void 0!==u?u:0,0);return{color:null!==(d=null!==(a=null==t?void 0:t.color)&&void 0!==a?a:null==i?void 0:i.color)&&void 0!==d?d:"#000000",fontFamily:null!==(v=null!==(c=null==t?void 0:t.fontFamily)&&void 0!==c?c:null==i?void 0:i.fontFamily)&&void 0!==v?v:"Arial",fontSize:I,fontStyle:null!==(w=null!==(f=null==t?void 0:t.fontStyle)&&void 0!==f?f:null==i?void 0:i.fontStyle)&&void 0!==w?w:"normal",fontWeight:null!==(p=null!==(g=null==t?void 0:t.fontWeight)&&void 0!==g?g:null==i?void 0:i.fontWeight)&&void 0!==p?p:"normal",lineHeight:A,enableShadow:null!==(y=null!==(m=null==t?void 0:t.enableShadow)&&void 0!==m?m:null==i?void 0:i.enableShadow)&&void 0!==y&&y,shadowOffsetX:null!==(x=null!==(b=null==t?void 0:t.shadowOffsetX)&&void 0!==b?b:null==i?void 0:i.shadowOffsetX)&&void 0!==x?x:0,shadowOffsetY:null!==(S=null!==(C=null==t?void 0:t.shadowOffsetY)&&void 0!==C?C:null==i?void 0:i.shadowOffsetY)&&void 0!==S?S:0,shadowBlur:B,shadowColor:null!==(k=null!==(E=null==t?void 0:t.shadowColor)&&void 0!==E?E:null==i?void 0:i.shadowColor)&&void 0!==k?k:"transparent",enableStroke:null!==(M=null!==(O=null==t?void 0:t.enableStroke)&&void 0!==O?O:null==i?void 0:i.enableStroke)&&void 0!==M&&M,strokeColor:null!==(F=null!==(T=null==t?void 0:t.strokeColor)&&void 0!==T?T:null==i?void 0:i.strokeColor)&&void 0!==F?F:"transparent",strokeWidth:$}}function Ci(t){return t.match(/\S+|\s|\n/g)||[]}function Si(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const n=t.measureText(i),h=n.width,r=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(h),height:r,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ei(t,i,s,n,h){h.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,n.enableShadow&&(h.shadowOffsetX=n.shadowOffsetX,h.shadowOffsetY=n.shadowOffsetY,h.shadowBlur=n.shadowBlur,h.shadowColor=n.shadowColor),n.enableStroke&&(h.strokeStyle=n.strokeColor,h.lineWidth=n.strokeWidth,h.strokeText(s,t,i)),h.fillStyle=n.color,h.fillText(s,t,i)}class ki extends Qt{constructor(t,i,s={}){var n;const h=document.createElement("canvas"),r=h.getContext("2d");if(!r)throw Error("Failed to create canvas context");const o=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,n=i?t:t.text,h=xi(i?void 0:t.style,s.defaultStyle);for(const t of Ci(n)){const i=Si(r,t,h);o.push({text:t,style:h,metrics:i})}}const l=((t,i)=>{const s=[];let n=[],h=0,r=0,o=0,e=0;for(const l of i)"\n"!==l.text?h+l.metrics.width>t&&0!==n.length?(s.push({chunks:n,width:h,height:r,baseline:o,lineHeight:e}),n=[l],h=l.metrics.width,r=l.metrics.height,o=l.metrics.baseline,e=l.metrics.lineHeight):(n.push(l),h+=l.metrics.width,r=Math.max(r,l.metrics.height),o=Math.max(o,l.metrics.baseline),e=Math.max(e,l.metrics.lineHeight)):(n.length>0&&s.push({chunks:n,width:h,height:r,baseline:o,lineHeight:e}),n=[],h=0,r=0,o=0,e=0);return n.length>0&&s.push({chunks:n,width:h,height:r,baseline:o,lineHeight:e}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,o),a=(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 n=t[i];s+=0===i?n.height:n.lineHeight,i===t.length-1&&(s+=n.baseline)}return{width:i,height:s}})(l),d=(t=>{var i,s,n,h;return"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(null!==(i=null==t?void 0:t.left)&&void 0!==i?i:0,0),right:Math.max(null!==(s=null==t?void 0:t.right)&&void 0!==s?s:0,0),top:Math.max(null!==(n=null==t?void 0:t.top)&&void 0!==n?n:0,0),bottom:Math.max(null!==(h=null==t?void 0:t.bottom)&&void 0!==h?h:0,0)}})(s.padding);h.width=a.width+d.left+d.right,h.height=a.height+d.top+d.bottom;const c=new y(h),v=new $t(c);super(t,new u(zt,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=h,this.context=r,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let h=this.padding.top;for(let t=0;s.length>t;t++){const r=s[t];let o=i;h+=0===t?r.height:r.lineHeight;for(const t of r.chunks)Ei(o,h,t.text,t.style,n),o+=t.metrics.width}})(0,this.padding.left,l,this.context),this.texture.needsUpdate=!0,this.applyTransformations()}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),this.texture.dispose(),this.canvas.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.suggestedAspect!==t&&(this.suggestedAspect=t,this.height=this.width/((this.textBlockSize.width+this.padding.left+this.padding.right)/(this.textBlockSize.height+this.padding.top+this.padding.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.texture.image.width,this.texture.image.height,this.material),this.applyTransformations()}}class Oi extends ii{constructor(){super(),this.targetScreenHeight=1920,this.onResize=()=>{const t=this.calculateScale();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.onClick=t=>{if(this.mode!==Bt.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,n=i?i.bottom-t.clientY:window.innerHeight-t.clientY,h=this.calculateScale();this.clickInternal(s*h,n*h)},window.addEventListener("resize",this.onResize),window.addEventListener("pointerdown",this.onClick),this.onResize()}get tergetScreenHeight(){return this.targetScreenHeight}set tergetScreenHeight(t){this.targetScreenHeight=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.onResize),window.removeEventListener("pointerdown",this.onClick),super.destroy()}render(t,i){t.clear(!1,!0,!0),super.render(t,i)}calculateScale(){var t;return(null!==(t=this.tergetScreenHeight)&&void 0!==t?t:window.innerHeight)/window.innerHeight}}function Mi(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}class Ti{}export{bt as UIAnchor,ci as UIAspectConstraint,rt as UIConstraint,ui as UIConstraint2DBuilder,ai as UIConstraintContainerBuilder,Zt as UIConstraintContainerDirection,et as UIConstraintPower,lt as UIConstraintRule,di as UIConstraintStackBuilder,vi as UICoverConstraint,wi as UIDummy,Qt as UIElement,Xt as UIElementEvent,fi as UIFitConstraint,Oi as UIFullScreenLayer,Dt as UIFullScreenQuad,mt as UIHeightConstraint,hi as UIHorizontalDistanceConstraint,ri as UIHorizontalProportionConstraint,gi as UIImage,ii as UILayer,Kt as UILayerEvent,Bt as UIMode,st as UIOrientation,Ti as UIPass,mi as UIProgress,bi as UIScene,ti as UISceneUpdateMode,ki as UIText,oi as UIVerticalDistanceConstraint,ei as UIVerticalProportionConstraint,li as UIWidthConstraint,X as addConstraintSymbol,j as addUIConstraintSymbol,L as addUIElementSymbol,Y as addVariableSymbol,tt as clickSymbol,ft as convertPowerToStrength,pt as convertRuleToOperator,Q as disableConstraintSymbol,J as enableConstraintSymbol,R as heightSymbol,ct as isUIConstraintPower,wt as isUIConstraintRule,nt as isUIOrientation,Mi as isUITextSpan,K as needsRecalculation,W as removeConstraintSymbol,N as removeUIConstraintSymbol,_ as removeUIElementSymbol,q as removeVariableSymbol,Z as renderSymbol,ht as resolveOrientation,vt as resolvePower,gt as resolveRule,it as sortSymbol,G as suggestVariableSymbol,H as widthSymbol,D as xSymbol,V as ySymbol};
|
|
1
|
+
import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as n,Vector3 as h,ShaderMaterial as r,Color as o,NormalBlending as e,CustomBlending as u,AddEquation as l,OneMinusDstColorFactor as a,OneFactor as d,MultiplyBlending as c,SubtractiveBlending as v,AdditiveBlending as f,PlaneGeometry as w,Scene as g,Mesh as p,OrthographicCamera as m,WebGLRenderTarget as y,UnsignedByteType as b,LinearFilter as x,RGBAFormat as C,NoBlending as S,Object3D as E,UniformsUtils as k,PerspectiveCamera as M,CanvasTexture as T}from"three";function O(){return new I}var I=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var n=new F(t,i());return this.index[t.id()]=this.array.length,this.array.push(n),n}return this.array[s]},t.prototype.insert=function(t,i){var s=new F(t,i),n=this.index[t.id()];return void 0===n?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[n]=s,s},t.prototype.erase=function(t){var i=this.index[t.id()];if(void 0!==i){this.index[t.id()]=void 0;var s=this.array[i],n=this.array.pop();return s!==n&&(this.array[i]=n,this.index[n.first.id()]=i),s}},t.prototype.copy=function(){for(var i=new t,s=0;this.array.length>s;s++){var n=this.array[s].copy();i.array[s]=n,i.index[n.first.id()]=s}return i},t}(),F=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),A=function(){function t(t){void 0===t&&(t=""),this.C=0,this.S=null,this.T=B++,this.O=t}return t.prototype.id=function(){return this.T},t.prototype.name=function(){return this.O},t.prototype.setName=function(t){this.O=t},t.prototype.context=function(){return this.S},t.prototype.setContext=function(t){this.S=t},t.prototype.value=function(){return this.C},t.prototype.setValue=function(t){this.C=t},t.prototype.plus=function(t){return new $(this,t)},t.prototype.minus=function(t){return new $(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new $([t,this])},t.prototype.divide=function(t){return new $([1/t,this])},t.prototype.toJSON=function(){return{name:this.O,value:this.C}},t.prototype.toString=function(){return this.S+"["+this.O+":"+this.C+"]"},t}(),B=0,$=function(){function t(){var t=P(arguments);this.I=t.terms,this.F=t.constant}return t.prototype.terms=function(){return this.I},t.prototype.constant=function(){return this.F},t.prototype.value=function(){for(var t=this.F,i=0,s=this.I.size();s>i;i++){var n=this.I.itemAt(i);t+=n.first.value()*n.second}return t},t.prototype.plus=function(i){return new t(this,i)},t.prototype.minus=function(i){return new t(this,"number"==typeof i?-i:[-1,i])},t.prototype.multiply=function(i){return new t([i,this])},t.prototype.divide=function(i){return new t([1/i,this])},t.prototype.isConstant=function(){return 0==this.I.size()},t.prototype.toString=function(){var t=this.I.array.map((t=>t.second+"*"+t.first)).join(" + ");return this.isConstant()||0===this.F||(t+=" + "),t+this.F},t}();function P(t){for(var i=0,s=()=>0,n=O(),h=0,r=t.length;r>h;++h){var o=t[h];if("number"==typeof o)i+=o;else if(o instanceof A)n.setDefault(o,s).second+=1;else if(o instanceof $){i+=o.constant();for(var e=0,u=(c=o.terms()).size();u>e;e++){var l=c.itemAt(e);n.setDefault(l.first,s).second+=l.second}}else{if(!(o instanceof Array))throw Error("invalid Expression argument: "+o);if(2!==o.length)throw Error("array must have length 2");var a=o[0],d=o[1];if("number"!=typeof a)throw Error("array item 0 must be a number");if(d instanceof A)n.setDefault(d,s).second+=a;else{if(!(d instanceof $))throw Error("array item 1 must be a variable or expression");var c;for(i+=d.constant()*a,e=0,u=(c=d.terms()).size();u>e;e++)l=c.itemAt(e),n.setDefault(l.first,s).second+=l.second*a}}}return{terms:n,constant:i}}var U,z=(()=>{function t(){}return t.create=(t,i,s,n)=>{void 0===n&&(n=1);var h=0;return h+=1e6*Math.max(0,Math.min(1e3,t*n)),(h+=1e3*Math.max(0,Math.min(1e3,i*n)))+Math.max(0,Math.min(1e3,s*n))},t.clip=i=>Math.max(0,Math.min(t.required,i)),t.required=t.create(1e3,1e3,1e3),t.strong=t.create(1,0,0),t.medium=t.create(0,1,0),t.weak=t.create(0,0,1),t})();(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(U||(U={}));var D,V=function(){function t(t,i,s,n){void 0===n&&(n=z.required),this.T=R++,this.A=i,this.B=z.clip(n),this.$=void 0===s&&t instanceof $?t:t.minus(s)}return t.prototype.id=function(){return this.T},t.prototype.expression=function(){return this.$},t.prototype.op=function(){return this.A},t.prototype.strength=function(){return this.B},t.prototype.toString=function(){return this.$+" "+["<=",">=","="][this.A]+" 0 ("+this.B+")"},t}(),R=0,H=function(){function t(){this.P=O(),this.U=O(),this.D=O(),this.V=O(),this.R=[],this.H=new N,this._=null,this.L=0}return t.prototype.createConstraint=function(t,i,s,n){void 0===n&&(n=z.required);var h=new V(t,i,s,n);return this.addConstraint(h),h},t.prototype.addConstraint=function(t){if(void 0!==this.P.find(t))throw Error("duplicate constraint");var i=this.j(t),s=i.row,n=i.tag,h=this.N(s,n);if(h.type()===D.Invalid&&s.allDummies()){if(!_(s.constant()))throw Error("unsatisfiable constraint");h=n.marker}if(h.type()===D.Invalid){if(!this.X(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.Y(h,s),this.U.insert(h,s);this.P.insert(t,n),this.W(this.H)},t.prototype.removeConstraint=function(t){var i=this.P.erase(t);if(void 0===i)throw Error("unknown constraint");this.q(t,i.second);var s=i.second.marker,n=this.U.erase(s);if(void 0===n){var h=this.G(s);if(h.type()===D.Invalid)throw Error("failed to find leaving row");(n=this.U.erase(h)).second.solveForEx(h,s),this.Y(s,n.second)}this.W(this.H)},t.prototype.hasConstraint=function(t){return this.P.contains(t)},t.prototype.addEditVariable=function(t,i){if(void 0!==this.V.find(t))throw Error("duplicate edit variable");if((i=z.clip(i))===z.required)throw Error("bad required strength");var s=new $(t),n=new V(s,U.Eq,void 0,i);this.addConstraint(n);var h=this.P.find(n).second;this.V.insert(t,{tag:h,constraint:n,constant:0})},t.prototype.removeEditVariable=function(t){var i=this.V.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)},t.prototype.hasEditVariable=function(t){return this.V.contains(t)},t.prototype.suggestValue=function(t,i){var s=this.V.find(t);if(void 0===s)throw Error("unknown edit variable");var n=this.U,h=s.second,r=i-h.constant;h.constant=i;var o=h.tag.marker,e=n.find(o);if(void 0!==e)return 0>e.second.add(-r)&&this.R.push(o),void this.J();var u=h.tag.other;if(void 0!==(e=n.find(u)))return 0>e.second.add(r)&&this.R.push(u),void this.J();for(var l=0,a=n.size();a>l;++l){var d=n.itemAt(l),c=d.second,v=c.coefficientFor(o);0!==v&&0>c.add(r*v)&&d.first.type()!==D.External&&this.R.push(d.first)}this.J()},t.prototype.updateVariables=function(){for(var t=this.D,i=this.U,s=0,n=t.size();n>s;++s){var h=t.itemAt(s),r=i.find(h.second);h.first.setValue(void 0!==r?r.second.constant():0)}},t.prototype.K=function(t){var i=this;return this.D.setDefault(t,(()=>i.Z(D.External))).second},t.prototype.j=function(t){for(var i=t.expression(),s=new N(i.constant()),n=i.terms(),h=0,r=n.size();r>h;++h){var o=n.itemAt(h);if(!_(o.second)){var e=this.K(o.first),u=this.U.find(e);void 0!==u?s.insertRow(u.second,o.second):s.insertSymbol(e,o.second)}}var l=this.H,a=t.strength(),d={marker:j,other:j};switch(t.op()){case U.Le:case U.Ge:var c=t.op()===U.Le?1:-1,v=this.Z(D.Slack);if(d.marker=v,s.insertSymbol(v,c),z.required>a){var f=this.Z(D.Error);d.other=f,s.insertSymbol(f,-c),l.insertSymbol(f,a)}break;case U.Eq:if(z.required>a){var w=this.Z(D.Error),g=this.Z(D.Error);d.marker=w,d.other=g,s.insertSymbol(w,-1),s.insertSymbol(g,1),l.insertSymbol(w,a),l.insertSymbol(g,a)}else{var p=this.Z(D.Dummy);d.marker=p,s.insertSymbol(p)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:d}},t.prototype.N=(t,i)=>{for(var s=t.cells(),n=0,h=s.size();h>n;++n){var r=s.itemAt(n);if(r.first.type()===D.External)return r.first}var o=i.marker.type();return o!==D.Slack&&o!==D.Error||t.coefficientFor(i.marker)>=0?(o=i.other.type())!==D.Slack&&o!==D.Error||t.coefficientFor(i.other)>=0?j:i.other:i.marker},t.prototype.X=function(t){var i=this.Z(D.Slack);this.U.insert(i,t.copy()),this._=t.copy(),this.W(this._);var s=_(this._.constant());this._=null;var n=this.U.erase(i);if(void 0!==n){var h=n.second;if(h.isConstant())return s;var r=this.tt(h);if(r.type()===D.Invalid)return!1;h.solveForEx(i,r),this.Y(r,h),this.U.insert(r,h)}for(var o=this.U,e=0,u=o.size();u>e;++e)o.itemAt(e).second.removeSymbol(i);return this.H.removeSymbol(i),s},t.prototype.Y=function(t,i){for(var s=this.U,n=0,h=s.size();h>n;++n){var r=s.itemAt(n);r.second.substitute(t,i),0>r.second.constant()&&r.first.type()!==D.External&&this.R.push(r.first)}this.H.substitute(t,i),this._&&this._.substitute(t,i)},t.prototype.W=function(t){for(;;){var i=this.it(t);if(i.type()===D.Invalid)return;var s=this.st(i);if(s.type()===D.Invalid)throw Error("the objective is unbounded");var n=this.U.erase(s).second;n.solveForEx(s,i),this.Y(i,n),this.U.insert(i,n)}},t.prototype.J=function(){for(var t=this.U,i=this.R;0!==i.length;){var s=i.pop(),n=t.find(s);if(void 0!==n&&0>n.second.constant()){var h=this.nt(n.second);if(h.type()===D.Invalid)throw Error("dual optimize failed");var r=n.second;t.erase(s),r.solveForEx(s,h),this.Y(h,r),t.insert(h,r)}}},t.prototype.it=t=>{for(var i=t.cells(),s=0,n=i.size();n>s;++s){var h=i.itemAt(s),r=h.first;if(0>h.second&&r.type()!==D.Dummy)return r}return j},t.prototype.nt=function(t){for(var i=Number.MAX_VALUE,s=j,n=t.cells(),h=0,r=n.size();r>h;++h){var o=n.itemAt(h),e=o.first,u=o.second;if(u>0&&e.type()!==D.Dummy){var l=this.H.coefficientFor(e)/u;i>l&&(i=l,s=e)}}return s},t.prototype.st=function(t){for(var i=Number.MAX_VALUE,s=j,n=this.U,h=0,r=n.size();r>h;++h){var o=n.itemAt(h),e=o.first;if(e.type()!==D.External){var u=o.second,l=u.coefficientFor(t);if(0>l){var a=-u.constant()/l;i>a&&(i=a,s=e)}}}return s},t.prototype.G=function(t){for(var i=Number.MAX_VALUE,s=i,n=i,h=j,r=h,o=h,e=h,u=this.U,l=0,a=u.size();a>l;++l){var d=u.itemAt(l),c=d.second,v=c.coefficientFor(t);if(0!==v){var f=d.first;if(f.type()===D.External)e=f;else if(0>v)s>(w=-c.constant()/v)&&(s=w,r=f);else{var w;n>(w=c.constant()/v)&&(n=w,o=f)}}}return r!==h?r:o!==h?o:e},t.prototype.q=function(t,i){i.marker.type()===D.Error&&this.ht(i.marker,t.strength()),i.other.type()===D.Error&&this.ht(i.other,t.strength())},t.prototype.ht=function(t,i){var s=this.U.find(t);void 0!==s?this.H.insertRow(s.second,-i):this.H.insertSymbol(t,-i)},t.prototype.tt=t=>{for(var i=t.cells(),s=0,n=i.size();n>s;++s){var h=i.itemAt(s),r=h.first.type();if(r===D.Slack||r===D.Error)return h.first}return j},t.prototype.Z=function(t){return new L(t,this.L++)},t}();function _(t){return 0>t?1e-8>-t:1e-8>t}(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"})(D||(D={}));var L=function(){function t(t,i){this.T=i,this.rt=t}return t.prototype.id=function(){return this.T},t.prototype.type=function(){return this.rt},t}(),j=new L(D.Invalid,-1),N=function(){function t(t){void 0===t&&(t=0),this.ot=O(),this.F=t}return t.prototype.cells=function(){return this.ot},t.prototype.constant=function(){return this.F},t.prototype.isConstant=function(){return this.ot.empty()},t.prototype.allDummies=function(){for(var t=this.ot,i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==D.Dummy)return!1;return!0},t.prototype.copy=function(){var i=new t(this.F);return i.ot=this.ot.copy(),i},t.prototype.add=function(t){return this.F+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),_(this.ot.setDefault(t,(()=>0)).second+=i)&&this.ot.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this.F+=t.F*i;for(var s=t.ot,n=0,h=s.size();h>n;++n){var r=s.itemAt(n);this.insertSymbol(r.first,r.second*i)}},t.prototype.removeSymbol=function(t){this.ot.erase(t)},t.prototype.reverseSign=function(){this.F=-this.F;for(var t=this.ot,i=0,s=t.size();s>i;++i){var n=t.itemAt(i);n.second=-n.second}},t.prototype.solveFor=function(t){var i=this.ot,s=-1/i.erase(t).second;this.F*=s;for(var n=0,h=i.size();h>n;++n)i.itemAt(n).second*=s},t.prototype.solveForEx=function(t,i){this.insertSymbol(t,-1),this.solveFor(i)},t.prototype.coefficientFor=function(t){var i=this.ot.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.ot.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const X=Symbol("xSymbol"),Y=Symbol("ySymbol"),W=Symbol("widthSymbol"),q=Symbol("heightSymbol"),G=Symbol("addUIElementSymbol"),Q=Symbol("removeUIElementSymbol"),J=Symbol("addConstraintSymbol"),K=Symbol("removeUIConstraintSymbol"),Z=Symbol("addConstraintSymbol"),tt=Symbol("removeConstraintSymbol"),it=Symbol("addVariableSymbol"),st=Symbol("removeVariableSymbol"),nt=Symbol("suggestVariableSymbol"),ht=Symbol("disableConstraintSymbol"),rt=Symbol("enableConstraintSymbol"),ot=Symbol("needsRecalculation"),et=Symbol("renderSymbol"),ut=Symbol("clickSymbol"),lt=Symbol("sortSymbol");var at;function dt(t){return null!==t&&Object.values(at).some((i=>i===t))}function ct(t){return null!=t?t:at.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(at||(at={}));class vt{constructor(t,i){this.layer=t,this.name="",this.layer[J](this,i)}destroy(){this.layer[K](this)}}const ft=1e3;var wt,gt,pt,mt,yt;function bt(t){return null!==t&&Object.values(wt).some((i=>i===t))}function xt(t){return null!=t?t:wt.P0}function Ct(t){switch(t){case wt.P0:return z.create(ft,ft,ft);case wt.P1:return z.create(100,0,0);case wt.P2:return z.create(10,0,0);case wt.P3:return z.create(0,100,0);case wt.P4:return z.create(0,10,0);case wt.P5:return z.create(0,0,100);case wt.P6:return z.create(0,0,10);case wt.P7:return z.create(0,0,1);default:return z.create(ft,ft,ft)}}function St(t){return null!==t&&Object.values(gt).some((i=>i===t))}function Et(t){return null!=t?t:gt.EQUAL}function kt(t){switch(t){case gt.EQUAL:return U.Eq;case gt.LESS:return U.Le;case gt.GREATER:return U.Ge;default:return U.Eq}}(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"})(wt||(wt={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(gt||(gt={}));class Mt extends vt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={height:null!==(s=null==i?void 0:i.height)&&void 0!==s?s:t.height,power:xt(null==i?void 0:i.power),rule:Et(null==i?void 0:i.rule),orientation:ct(null==i?void 0:i.orientation)},this.options.orientation!==at.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.options.orientation!==at.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[rt](t){this.options.orientation!==at.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new V(new $(this.element[q]),kt(this.options.rule),this.options.height,Ct(this.options.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class Tt{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 n=this.t.get(i);void 0===n?this.t.set(i,new Map([[t,s]])):n.has(t)||n.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 Ot{constructor(){this.o=new Map}on(t,i,s,n=0){return this.h(t,!1,n,i,s),this}once(t,i,s,n=0){return this.h(t,!0,n,i,s),this}off(t,i,s){const n=this.o.get(t);if(void 0===n)return this;n.u&&(n.u=!1,n.v=n.v.slice());const h=n.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];n.l.remove(i.et,i.p)}return this}{const r=h.length;if(h[0].et===i&&h[0].p===s)return 1===r?this.o.delete(t):h.shift(),this;const o=r-1;if(h[o].et===i&&h[o].p===s)return h.pop(),this;if(10>r||h[0].M===h[o].M)for(let t=1;o>t;t++){const n=h[t];if(n.et===i&&n.p===s)return h.splice(t,1),this}else{const t=n.l.getPriority(i,s);if(void 0===t)return this;let r=0,o=h.length-1;for(;o>=r;){const i=r+o>>>1;t>h[i].M?r=i+1:o=i-1}const e=r;for(o=h.length-1;o>=r;){const i=r+o>>>1;h[i].M>t?o=i-1:r=i+1}const u=o;for(let t=e;u>=t;t++)if(h[t].et===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 n=s.v;let h=!1;for(let t=0;n.length>t;t++){const s=n[t];s.et.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===n&&(r.u=!1);const o=r.v;if(h){let i=0;for(let t=0;o.length>t;t++){const s=o[t];s.m?r.l.remove(s.et,s.p):o[i++]=s}0===i?this.o.delete(t):o.length=i}return!0}h(t,i,s,n,h){let r=this.o.get(t);if(void 0===r)return void this.o.set(t,{v:[{et:n,p:h,M:s,k:i,m:!1}],u:!1,l:new Tt(n,h,s)});if(r.l.has(n,h))throw Error("Event listener already exists");r.l.insert(n,h,s);const o={et:n,p:h,M:s,k:i,m:!1};r.u&&(r.u=!1,r.v=r.v.slice());{const t=r.v,i=o.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(o);if(t[0].M>=i)return void t.unshift(o);{let s=0,n=t.length;for(;n>s;){const h=s+n>>>1;i>t[h].M?s=h+1:n=h}t.splice(s,0,o)}}}}class It extends Ot{constructor(i,s,n,h){super(),this.layer=i,this.object=h,this[pt]=new A("x"),this[mt]=new A("y"),this[yt]=!1,this.name=t.generateUUID(),this.object&&(this.object.matrixAutoUpdate=!1),this.layer[G](this,h),this.layer[it](this,this[X],Ct(wt.P7)),this.layer[it](this,this[Y],Ct(wt.P7)),this[X].setValue(s),this[Y].setValue(n),this.layer[nt](this,this[X],s),this.layer[nt](this,this[Y],n)}get x(){return this[X].value()}get y(){return this[Y].value()}get zIndex(){var t,i;return null!==(i=null===(t=this.object)||void 0===t?void 0:t.position.z)&&void 0!==i?i:0}get needsRecalculation(){return this[ot]}set x(t){this.layer[nt](this,this[X],t)}set y(t){this.layer[nt](this,this[Y],t)}set zIndex(t){this.object&&this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[lt](),this.object.updateMatrix())}destroy(){this.layer[st](this,this[Y]),this.layer[st](this,this[X]),this.layer[Q](this)}[(pt=X,mt=Y,yt=ot,et)](t,i){this.render(t,i)}applyTransformations(){this[ot]&&(this.object&&this.object.updateMatrix(),this[ot]=!1)}}const Ft=new i,At=new s,Bt=new n,$t=new n,Pt=new n,Ut=new n,zt=new n,Dt=new h,Vt=.5;class Rt{constructor(){this.x=0,this.y=0,this.anchorX=Vt,this.anchorY=Vt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=!1}}class Ht{constructor(t,i){this.raw=t,this.owner=i}get x(){return this.raw.x}get y(){return this.raw.y}get anchorX(){return this.raw.anchorX}get anchorY(){return this.raw.anchorY}get scaleX(){return this.raw.scaleX}get scaleY(){return this.raw.scaleY}get angle(){return t.radToDeg(this.raw.rotation)}get rotation(){return this.raw.rotation}set x(t){t!==this.raw.x&&(this.raw.x=t,this.raw.needsRecalculation=!0)}set y(t){t!==this.raw.y&&(this.raw.y=t,this.raw.needsRecalculation=!0)}set anchorX(t){t!==this.raw.anchorX&&(this.raw.anchorX=t,this.raw.needsRecalculation=!0)}set anchorY(t){t!==this.raw.anchorY&&(this.raw.anchorY=t,this.raw.needsRecalculation=!0)}set scaleX(t){t!==this.raw.scaleX&&(this.raw.scaleX=t,this.raw.needsRecalculation=!0)}set scaleY(t){t!==this.raw.scaleY&&(this.raw.scaleY=t,this.raw.needsRecalculation=!0)}set angle(i){const s=t.degToRad(i);s!==this.raw.rotation&&(this.raw.rotation=s,this.raw.needsRecalculation=!0)}set rotation(t){t!==this.raw.rotation&&(this.raw.rotation=t,this.raw.needsRecalculation=!0)}setAnchorByGlobalPosition(t,i){const s=(t-this.owner.x)/this.owner.width,n=(i-this.owner.y)/this.owner.height;s===this.raw.anchorX&&n===this.raw.anchorY||(this.raw.anchorX=s,this.raw.anchorY=n,this.raw.needsRecalculation=!0)}reset(){0===this.raw.x&&0===this.raw.y&&this.raw.anchorX===Vt&&this.raw.anchorY===Vt&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Vt,this.raw.anchorY=Vt,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=!0)}}var _t,Lt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(_t||(_t={})),(t=>{t[t.NORMAL=0]="NORMAL",t[t.ADDITIVE=1]="ADDITIVE",t[t.SUBTRACTIVE=2]="SUBTRACTIVE",t[t.MULTIPLY=3]="MULTIPLY",t[t.SCREEN=4]="SCREEN"})(Lt||(Lt={}));class jt extends r{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new o(1,1,1)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}setTexture(t){this.uniforms.map.value=t,this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setBlending(t){switch(t){case Lt.ADDITIVE:this.blending=f;break;case Lt.SUBTRACTIVE:this.blending=v;break;case Lt.MULTIPLY:this.blending=c;break;case Lt.SCREEN:this.blending=u,this.blendEquation=l,this.blendSrc=a,this.blendDst=d;break;default:this.blending=e}}}const Nt=new w(1,1).translate(.5,.5,0),Xt=new g,Yt=new p(Nt);Xt.add(Yt);class Wt{constructor(t=0,i=0){this.paddingHorizontalInternal=t,this.paddingVerticalInternal=i,this.camera=new m(-1,1,1,-1,0,1),this.updateCameraTransform()}get paddingHorizontal(){return this.paddingHorizontalInternal}get paddingVertical(){return this.paddingVerticalInternal}set paddingHorizontal(t){this.paddingHorizontalInternal!==t&&(this.paddingHorizontalInternal=t,this.updateCameraTransform())}set paddingVertical(t){this.paddingVerticalInternal!==t&&(this.paddingVerticalInternal=t,this.updateCameraTransform())}render(t,i){Yt.material=i,t.render(Xt,this.camera)}updateCameraTransform(){this.camera.left=-this.paddingHorizontalInternal,this.camera.right=1+this.paddingHorizontalInternal,this.camera.bottom=-this.paddingVerticalInternal,this.camera.top=1+this.paddingVerticalInternal,this.camera.updateProjectionMatrix()}}class qt{constructor(){this.passes=[],this.defaultMaterial=new jt,this.screen=new Wt,this.needsUpdateInternal=!1,this.paddingHasChangedInternal=!1,this.paddingInternal=0;const t={format:C,minFilter:x,magFilter:x,type:b,depthBuffer:!1,stencilBuffer:!1};this.fromRenderTarget=new y(1,1,t),this.toRenderTarget=new y(1,1,t),this.fromRenderTarget.texture.generateMipmaps=!1,this.toRenderTarget.texture.generateMipmaps=!1}get needsUpdate(){return this.needsUpdateInternal&&this.hasValuablePasses()||this.hasPassesNeedingUpdate()}get paddingHasChanged(){return this.paddingHasChangedInternal}get padding(){return this.paddingInternal}requestUpdate(){this.needsUpdateInternal=!0}compose(t,i,s,n,h=!0){const r=this.hasValuablePasses();if(!(this.needsUpdateInternal&&r||this.hasPassesNeedingUpdate()))return r||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=!1,r?this.defaultMaterial:n;const o=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==o,this.paddingInternal=o;const e=i+2*o,u=s+2*o;this.fromRenderTarget.setSize(e,u),this.toRenderTarget.setSize(e,u),this.setScreenPadding(i,s,o),t.setClearColor(0,0),t.setRenderTarget(this.toRenderTarget),t.clear(!0,!1,!1);const l=n.blending;h&&(n.blending=S),this.screen.render(t,n),n.blending=l;const a={width:i,height:s,padding:o};for(let i=0;this.passes.length>i;i++){const s=this.passes[i];(s.needsUpdate||s.isValuable)&&(this.reverseRenderTargets(),t.setRenderTarget(this.toRenderTarget),t.clear(!0,!1,!1),this.passes[i].render(t,this.fromRenderTarget.texture,a))}return this.needsUpdateInternal=!1,this.defaultMaterial.setTexture(this.toRenderTarget.texture),this.defaultMaterial}destroy(){this.fromRenderTarget.dispose(),this.toRenderTarget.dispose()}hasValuablePasses(){return this.passes.some((t=>t.isValuable))}hasPassesNeedingUpdate(){return this.passes.some((t=>t.needsUpdate))}calculatePadding(){return this.passes.reduce(((t,i)=>Math.max(t,i.padding)),0)}setScreenPadding(t,i,s){this.screen.paddingHorizontal=s/t,this.screen.paddingVertical=s/i}reverseRenderTargets(){const t=this.fromRenderTarget;this.fromRenderTarget=this.toRenderTarget,this.toRenderTarget=t}}class Gt{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var Qt,Jt,Kt,Zt,ti,ii,si,ni,hi,ri;(t=>{t.CLICK="click"})(ii||(ii={}));class oi extends Ot{constructor(i,s,n,h,r,o){super(),this.layer=i,this.object=s,this[Qt]=new A("x"),this[Jt]=new A("y"),this[Kt]=new A("width"),this[Zt]=new A("height"),this[ti]=!1,this.name=t.generateUUID(),this.microInternal=new Rt,this.composerInternal=new qt,this.modeInternal=_t.VISIBLE,this.micro=new Ht(this.microInternal,this),this.composer=new Gt(this.composerInternal),this.object.matrixAutoUpdate=!1,this.layer[G](this,this.object),this.layer[it](this,this[X],Ct(wt.P7)),this.layer[it](this,this[Y],Ct(wt.P7)),this.layer[it](this,this[W],Ct(wt.P5)),this.layer[it](this,this[q],Ct(wt.P5)),this[X].setValue(n),this[Y].setValue(h),this[W].setValue(r),this[q].setValue(o),this.layer[nt](this,this[X],n),this.layer[nt](this,this[Y],h),this.layer[nt](this,this[W],r),this.layer[nt](this,this[q],o)}get x(){return this[X].value()}get y(){return this[Y].value()}get width(){return this[W].value()}get height(){return this[q].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[ot]}set x(t){this.layer[nt](this,this[X],t)}set y(t){this.layer[nt](this,this[Y],t)}set width(t){this.layer[nt](this,this[W],t)}set height(t){this.layer[nt](this,this[q],t)}set zIndex(t){this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[lt](),this.object.updateMatrix())}set mode(t){this.modeInternal=t,this.object.visible=t!==_t.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[st](this,this[q]),this.layer[st](this,this[W]),this.layer[st](this,this[Y]),this.layer[st](this,this[X]),this.layer[Q](this)}[(Qt=X,Jt=Y,Kt=W,Zt=q,ti=ot,et)](t,i){this.render(t,i)}[ut](t,i){return this.click(t,i)}applyTransformations(){(this[ot]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,n,h,r,o)=>{const e=this.x-o,u=this.y-o,l=this.width+2*o,a=this.height+2*o,d=e+l*i.anchorX,c=u+a*i.anchorY,v=Bt.set(1,0,-d,0,1,-c,0,0,1),f=$t.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=Pt.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=Ut.set(1,0,i.x+d,0,1,i.y+c,0,0,1),p=zt.multiplyMatrices(g,w).multiply(f).multiply(v),m=Dt.set(e,u,1).applyMatrix3(p);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=l*i.scaleX,t.scale.y=a*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this.object.updateMatrix(),this[ot]=!1,this.microInternal.needsRecalculation=!1)}click(t,i){return this.mode===_t.INTERACTIVE&&(this.applyTransformations(),s=this.x,n=this.y,h=this.width,r=this.height,Ft.set(t,i),At.min.set(s,n),At.max.set(h,r).add(At.min),!!At.containsPoint(Ft)&&(this.emit(ii.CLICK,this),!0));var s,n,h,r}}const ei=new o(0);var ui,li,ai;(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.CLICK="click"})(ui||(ui={}));class di extends Ot{constructor(){super(...arguments),this.mode=_t.VISIBLE,this[si]=new A,this[ni]=new A,this[hi]=new A,this[ri]=new A,this.scene=new g,this.camera=new m,this.solver=new H,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=at.PORTRAIT,this.needsRecalculation=!1}get orientation(){return this.orientationPrivate}get width(){return this[W].value()}get height(){return this[q].value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(si=X,ni=Y,hi=W,ri=q,G)](t,i,s){if(this.elements.has(t))throw Error("Element already added");if(this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i){const t=null!=s?s:this.scene.children.length;i.position.z=t,i.renderOrder=t,this.scene.add(i),this[lt]()}}[Q](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),i.object&&this.scene.remove(i.object)}[J](t,i){if(this.constraints.has(t))throw Error("Constraint already added");for(const s of i){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(i.constraints.has(t))throw Error("Something went wrong");i.constraints.add(t)}this.constraints.set(t,{elements:i,variables:new Map,constraints:new Set})}[K](t){const i=this.constraints.get(t);if(void 0===i)throw Error("Constraint not found");if(i.variables.size>0)throw Error("Variables should be removed before removing constraint");if(i.constraints.size>0)throw Error("Constraints should be removed before removing constraint");for(const s of i.elements){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(!i.constraints.has(t))throw Error("Something went wrong");i.constraints.delete(t)}this.constraints.delete(t)}[Z](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before adding constraint you need to add it's owner");if(n.constraints.has(i))throw Error("Constraint already exists");n.constraints.add(i);try{null===(s=this.solver)||void 0===s||s.addConstraint(i)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[tt](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before removing constraint you need to add it's owner");if(!n.constraints.has(i))throw Error("Constraint not found");n.constraints.delete(i);try{null===(s=this.solver)||void 0===s||s.removeConstraint(i)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[it](t,i,s){var n;const h=t instanceof oi||t instanceof It?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before adding variable you need to add it's owner");if(h.variables.has(i))throw Error("Variable already exists");h.variables.set(i,{strength:s,suggestedValue:i.value()});try{null===(n=this.solver)||void 0===n||n.addEditVariable(i,s)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[st](t,i){var s;const n=t instanceof oi||t instanceof It?this.elements.get(t):this.constraints.get(t);if(void 0===n)throw Error("Before removing variable you need to add it's owner");if(!n.variables.has(i))throw Error("Variable does not exist");n.variables.delete(i);try{null===(s=this.solver)||void 0===s||s.removeEditVariable(i)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}[nt](t,i,s){var n;const h=t instanceof oi||t instanceof It?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before suggesting variable you need to add it's owner");const r=h.variables.get(i);if(!r)throw Error("Variable does not exist");if(r.suggestedValue!==s){r.suggestedValue=s;try{null===(n=this.solver)||void 0===n||n.suggestValue(i,s)}catch(t){this.rebuildSolver()}this.needsRecalculation=!0}}[lt](){this.scene.children.sort(((t,i)=>t.position.z-i.position.z));for(let t=0;this.scene.children.length>t;t++){const i=this.scene.children[t];i.position.z=t,i.renderOrder=t}this.camera.position.set(0,0,this.scene.children.length+1),this.camera.near=1,this.camera.far=this.scene.children.length+1+1,this.camera.updateProjectionMatrix(),this.camera.updateMatrix()}render(t,i){var s;if(this.mode===_t.HIDDEN)return;const n=t.getRenderTarget(),h=t.getClearColor(ei),r=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=!1,null===(s=this.solver)||void 0===s||s.updateVariables();for(const t of this.elements.keys())t[ot]=!0}for(const s of this.elements.keys())s[et](t,i);t.setRenderTarget(n),t.setClearColor(h),t.setClearAlpha(r),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==_t.INTERACTIVE)return;this.emit(ui.CLICK,this,t,i);const s=[...this.elements.keys()].filter((t=>t instanceof oi)).filter((t=>t.mode===_t.INTERACTIVE)).sort(((t,i)=>t.zIndex-i.zIndex));for(const n of s)if(n[ut](t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=!0}applyCameraSize(t,i){this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){var s,n,h,r,o,e,u,l;this.constraintX&&(null===(s=this.solver)||void 0===s||s.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(null===(n=this.solver)||void 0===n||n.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(null===(h=this.solver)||void 0===h||h.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(null===(r=this.solver)||void 0===r||r.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new V(new $(this[X]),U.Eq,0,z.required),this.constraintY=new V(new $(this[Y]),U.Eq,0,z.required),this.constraintW=new V(new $(this[W]),U.Eq,t,z.required),this.constraintH=new V(new $(this[q]),U.Eq,i,z.required),null===(o=this.solver)||void 0===o||o.addConstraint(this.constraintX),null===(e=this.solver)||void 0===e||e.addConstraint(this.constraintY),null===(u=this.solver)||void 0===u||u.addConstraint(this.constraintW),null===(l=this.solver)||void 0===l||l.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?at.LANDSCAPE:at.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t[rt](this.orientationPrivate);for(const t of this.constraints.keys())t[ht](this.orientationPrivate);this.solver=new H;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i);this.emit(ui.ORIENTATION_CHANGED,this,this.orientation)}}rebuildSolver(){try{this.solver=void 0,this.solver=new H;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i)}catch(t){throw t}}}function ci(t,i){if((t instanceof di?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function vi(t,i,s){if(0>=t||0>=i)throw Error(null!=s?s:`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class fi extends vt{constructor(t,i,s){var n,h,r;ci(t,i),super(i.layer,new Set(t instanceof oi||t instanceof It?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(h=null==s?void 0:s.anchorTwo)&&void 0!==h?h:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:xt(null==s?void 0:s.power),rule:Et(null==s?void 0:s.rule),orientation:ct(null==s?void 0:s.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof oi||this.elementOne instanceof di?new $(this.elementOne[X]).plus(new $(this.elementOne[W]).multiply(this.parameters.anchorOne)):new $(this.elementOne[X]),i=this.elementTwo instanceof oi?new $(this.elementTwo[X]).plus(new $(this.elementTwo[W]).multiply(this.parameters.anchorTwo)):new $(this.elementTwo[X]);this.constraint=new V(i.minus(t),kt(this.parameters.rule),this.parameters.distance,Ct(this.parameters.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class wi extends vt{constructor(t,i,s){var n;ci(t,i),super(i.layer,new Set(t instanceof oi?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:xt(null==s?void 0:s.power),rule:Et(null==s?void 0:s.rule),orientation:ct(null==s?void 0:s.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new $(this.elementOne[W]).multiply(this.parameters.proportion),i=new $(this.elementTwo[W]);this.constraint=new V(t.minus(i),kt(this.parameters.rule),0,Ct(this.parameters.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class gi extends vt{constructor(t,i,s){var n,h,r;ci(t,i),super(i.layer,new Set(t instanceof oi||t instanceof It?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(h=null==s?void 0:s.anchorTwo)&&void 0!==h?h:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:xt(null==s?void 0:s.power),rule:Et(null==s?void 0:s.rule),orientation:ct(null==s?void 0:s.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof oi||this.elementOne instanceof di?new $(this.elementOne[Y]).plus(new $(this.elementOne[q]).multiply(this.parameters.anchorOne)):new $(this.elementOne[Y]),i=this.elementTwo instanceof oi?new $(this.elementTwo[Y]).plus(new $(this.elementTwo[q]).multiply(this.parameters.anchorTwo)):new $(this.elementTwo[Y]);this.constraint=new V(i.minus(t),kt(this.parameters.rule),this.parameters.distance,Ct(this.parameters.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class pi extends vt{constructor(t,i,s){var n;ci(t,i),super(i.layer,new Set(t instanceof oi?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:xt(null==s?void 0:s.power),rule:Et(null==s?void 0:s.rule),orientation:ct(null==s?void 0:s.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new $(this.elementOne[q]).multiply(this.parameters.proportion),i=new $(this.elementTwo[q]);this.constraint=new V(t.minus(i),kt(this.parameters.rule),0,Ct(this.parameters.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class mi extends vt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={width:null!==(s=null==i?void 0:i.width)&&void 0!==s?s:t.width,power:xt(null==i?void 0:i.power),rule:Et(null==i?void 0:i.rule),orientation:ct(null==i?void 0:i.orientation)},this.options.orientation!==at.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.options.orientation!==at.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[rt](t){this.options.orientation!==at.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new V(new $(this.element[W]),kt(this.options.rule),this.options.width,Ct(this.options.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class yi{static size(t,i={}){var s,n,h,r,o,e,u,l;return{x:new mi(t,{width:null===(s=i.size)||void 0===s?void 0:s.x,power:null===(n=i.power)||void 0===n?void 0:n.x,rule:null===(h=i.rule)||void 0===h?void 0:h.x,orientation:null===(r=i.orientation)||void 0===r?void 0:r.x}),y:new Mt(t,{height:null===(o=i.size)||void 0===o?void 0:o.y,power:null===(e=i.power)||void 0===e?void 0:e.y,rule:null===(u=i.rule)||void 0===u?void 0:u.y,orientation:null===(l=i.orientation)||void 0===l?void 0:l.y})}}static distance(t,i,s={}){var n,h,r,o,e,u,l,a,d,c,v,f;return{x:new fi(t,i,{anchorOne:null===(n=s.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(h=s.anchorTwo)||void 0===h?void 0:h.x,distance:null===(r=s.distance)||void 0===r?void 0:r.x,power:null===(o=s.power)||void 0===o?void 0:o.x,rule:null===(e=s.rule)||void 0===e?void 0:e.x,orientation:null===(u=s.orientation)||void 0===u?void 0:u.x}),y:new gi(t,i,{anchorOne:null===(l=s.anchorOne)||void 0===l?void 0:l.y,anchorTwo:null===(a=s.anchorTwo)||void 0===a?void 0:a.y,distance:null===(d=s.distance)||void 0===d?void 0:d.y,power:null===(c=s.power)||void 0===c?void 0:c.y,rule:null===(v=s.rule)||void 0===v?void 0:v.y,orientation:null===(f=s.orientation)||void 0===f?void 0:f.y})}}static proportion(t,i,s={}){var n,h,r,o,e,u,l,a;return{x:new wi(t,i,{proportion:null===(n=s.proportion)||void 0===n?void 0:n.x,power:null===(h=s.power)||void 0===h?void 0:h.x,rule:null===(r=s.rule)||void 0===r?void 0:r.x,orientation:null===(o=s.orientation)||void 0===o?void 0:o.x}),y:new pi(t,i,{proportion:null===(e=s.proportion)||void 0===e?void 0:e.y,power:null===(u=s.power)||void 0===u?void 0:u.y,rule:null===(l=s.rule)||void 0===l?void 0:l.y,orientation:null===(a=s.orientation)||void 0===a?void 0:a.y})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(li||(li={}));class bi{static build(t,i,s,n={}){var h;const r=null!==(h=n.direction)&&void 0!==h?h:li.FROM_LEFT_TOP,o=[],e=[];o.push(new fi(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new fi(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const u=r===li.FROM_LEFT_TOP?1:0,l=r===li.FROM_LEFT_TOP?0:1;return e.push(new gi(t,i,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation}),new gi(t,s,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:o,verticalDistances:e}}}class xi{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:fi,proportionConstraint:wi,centerDistanceConstraint:gi})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:gi,proportionConstraint:pi,centerDistanceConstraint:fi})}static buildStack(t,i,s){const n=[],h=[],r=[];for(let o=0;t.length-1>o;o++){const e=t[o],u=t[o+1];n.push(new s.distanceConstraint(e,u,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),!1!==i.keepProportions&&h.push(new s.proportionConstraint(e,u,{power:i.power,orientation:i.orientation})),!1!==i.keepAlignment&&r.push(new s.centerDistanceConstraint(e,u,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:h,alignmentConstraints:r}}}class Ci extends vt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.parameters={aspect:null!==(s=null==i?void 0:i.aspect)&&void 0!==s?s:this.element.width/this.element.height,power:xt(null==i?void 0:i.power),rule:Et(null==i?void 0:i.rule),orientation:ct(null==i?void 0:i.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new $(this.element[W]).plus(new $(this.element[q]).multiply(-this.parameters.aspect));this.constraint=new V(t,kt(this.parameters.rule),0,Ct(this.parameters.power)),this.layer[Z](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[tt](this,this.constraint),this.constraint=void 0)}}class Si extends vt{constructor(t,i,s){var n,h,r;ci(t,i),super(i.layer,new Set(t instanceof oi?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={isStrict:null===(n=null==s?void 0:s.isStrict)||void 0===n||n,horizontalAnchor:null!==(h=null==s?void 0:s.horizontalAnchor)&&void 0!==h?h:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ct(null==s?void 0:s.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new V(new $(this.elementOne[X]).plus(new $(this.elementOne[W]).multiply(this.parameters.horizontalAnchor)),U.Eq,new $(this.elementTwo[X]).plus(new $(this.elementTwo[W]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new V(new $(this.elementOne[Y]).plus(new $(this.elementOne[q]).multiply(this.parameters.verticalAnchor)),U.Eq,new $(this.elementTwo[Y]).plus(new $(this.elementTwo[q]).multiply(this.parameters.verticalAnchor))),this.constraintW=new V(new $(this.elementOne[W]),U.Le,new $(this.elementTwo[W])),this.constraintH=new V(new $(this.elementOne[q]),U.Le,new $(this.elementTwo[q])),this.layer[Z](this,this.constraintX),this.layer[Z](this,this.constraintY),this.layer[Z](this,this.constraintW),this.layer[Z](this,this.constraintH),this.parameters.isStrict||(this.constraintStrict=new V(new $(this.elementOne[q]),U.Eq,new $(this.elementTwo[q]),z.strong),this.layer[Z](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[tt](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[tt](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[tt](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[tt](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[tt](this,this.constraintStrict),this.constraintStrict=void 0)}}class Ei extends vt{constructor(t,i,s){var n,h,r;super(i.layer,new Set(t instanceof oi?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,ci(t,i),this.parameters={isStrict:null===(n=null==s?void 0:s.isStrict)||void 0===n||n,horizontalAnchor:null!==(h=null==s?void 0:s.horizontalAnchor)&&void 0!==h?h:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ct(null==s?void 0:s.orientation)},this.parameters.orientation!==at.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[ht](t){this.parameters.orientation!==at.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[rt](t){this.parameters.orientation!==at.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new V(new $(this.elementOne[X]).plus(new $(this.elementOne[W]).multiply(this.parameters.horizontalAnchor)),U.Eq,new $(this.elementTwo[X]).plus(new $(this.elementTwo[W]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new V(new $(this.elementOne[Y]).plus(new $(this.elementOne[q]).multiply(this.parameters.verticalAnchor)),U.Eq,new $(this.elementTwo[Y]).plus(new $(this.elementTwo[q]).multiply(this.parameters.verticalAnchor))),this.constraintW=new V(new $(this.elementOne[W]),U.Ge,new $(this.elementTwo[W])),this.constraintH=new V(new $(this.elementOne[q]),U.Ge,new $(this.elementTwo[q])),this.layer[Z](this,this.constraintX),this.layer[Z](this,this.constraintY),this.layer[Z](this,this.constraintW),this.layer[Z](this,this.constraintH),!1!==this.parameters.isStrict&&(this.constraintStrict=new V(new $(this.elementOne[q]),U.Eq,new $(this.elementTwo[q]),z.strong),this.layer[Z](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[tt](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[tt](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[tt](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[tt](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[tt](this,this.constraintStrict),this.constraintStrict=void 0)}}class ki extends oi{constructor(t,i=100,s=100){super(t,new E,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class Mi extends oi{constructor(t,i){var s,n;const h=null===(s=i.image)||void 0===s?void 0:s.width,r=null===(n=i.image)||void 0===n?void 0:n.height;vi(h,r,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${h}) or height (${r}). Image dimensions must be non-zero positive numbers.`);const o=new jt(i);super(t,new p(Nt,o),0,0,h,r),this.blendingInternal=Lt.NORMAL,this.material=o,this.textureInternal=i,this.applyTransformations()}get texture(){return this.textureInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}get blending(){return this.blendingInternal}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set blending(t){this.blendingInternal=t,this.material.setBlending(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.textureInternal.image.width,this.textureInternal.image.height,this.material),this.applyTransformations()}}class Ti extends r{constructor(t,i){super({uniforms:k.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new o(1,1,1)},foregroundColor:{value:new o(1,1,1)},color:{value:new o(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},opacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}getProgress(){return this.uniforms.progress.value}getBackgroundTexture(){return this.uniforms.background.value}getForegroundTexture(){return this.uniforms.foreground.value}getBackgroundColor(){return this.uniforms.color.value.getHex()}getForegroundColor(){return this.uniforms.color.value.getHex()}getColor(){return this.uniforms.color.value.getHex()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.value}getOpacity(){return this.uniforms.opacity.value}getAngle(){return this.uniforms.angle.value}getIsForwardDirection(){return 1===this.uniforms.direction.value}setProgress(t){this.uniforms.progress.value=t,this.uniformsNeedUpdate=!0}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=!0}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=!0}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=!0}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=!0}}class Oi extends oi{constructor(i,s,n={}){var h,r,o,e,u,l;const a=null===(h=s.image)||void 0===h?void 0:h.width,d=null===(r=s.image)||void 0===r?void 0:r.height;vi(a,d,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${a}) or height (${d}). Image dimensions must be non-zero positive numbers.`);const c=null===(e=null===(o=n.textureBackground)||void 0===o?void 0:o.image)||void 0===e?void 0:e.width,v=null===(l=null===(u=n.textureBackground)||void 0===u?void 0:u.image)||void 0===l?void 0:l.height;n.textureBackground&&vi(c,v,`Invalid image dimensions - texture "${n.textureBackground.name||"unnamed"}" has invalid width (${c}) or height (${v}). Image dimensions must be non-zero positive numbers.`);const f=new Ti(s,n.textureBackground),w=new p(Nt,f);n.progress&&f.setProgress(n.progress),n.isForegroundDirection&&f.setIsForwardDirection(n.isForegroundDirection),n.angle&&f.setAngle(t.degToRad(n.angle)),n.color&&f.setColor(n.color),n.opacity&&f.setOpacity(n.opacity),n.backgroundColor&&f.setBackgroundColor(n.backgroundColor),n.foregroundColor&&f.setForegroundColor(n.foregroundColor),n.backgroundOpacity&&f.setBackgroundOpacity(n.backgroundOpacity),n.foregroundOpacity&&f.setForegroundOpacity(n.foregroundOpacity);const g=null!=c?c:a,m=null!=d?d:v;super(i,w,0,0,g,m),this.material=f,this.imageWidth=g,this.imageHeight=m,this.applyTransformations()}get progress(){return this.material.getProgress()}get backgroundTexture(){return this.material.getBackgroundTexture()}get foregroundTexture(){return this.material.getForegroundTexture()}get backgroundColor(){return this.material.getBackgroundColor()}get foregroundColor(){return this.material.getForegroundColor()}get color(){return this.material.getColor()}get backgroundOpacity(){return this.material.getBackgroundOpacity()}get foregroundOpacity(){return this.material.getForegroundOpacity()}get opacity(){return this.material.getOpacity()}get angle(){return t.radToDeg(this.material.getAngle())}get isForwardDirection(){return this.material.getIsForwardDirection()}set progress(t){this.material.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.material.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.material.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.material.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.material.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set angle(i){this.material.setAngle(t.degToRad(i)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.material.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.imageWidth,this.imageHeight,this.material),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(ai||(ai={}));const Ii=ai.PROPERTY_CHANGED;class Fi extends oi{constructor(t,i={}){var s,n,h,r,o,e,u,l,a,d;const c=null!==(s=i.resolutionFactor)&&void 0!==s?s:.5;if(.1>c||c>8)throw Error(`Invalid resolution factor: ${c}. Must be between 0.1 and 8.`);const v=null!==(n=i.width)&&void 0!==n?n:512,f=null!==(h=i.height)&&void 0!==h?h:512;vi(v,f,`Invalid width or height: ${v}x${f}. Must be positive.`);const w=new y(v*c,f*c,{format:C,minFilter:x,magFilter:x,type:b,depthBuffer:null===(r=i.useDepth)||void 0===r||r,stencilBuffer:!1}),m=new jt(w.texture);super(t,new p(Nt,m),0,0,v,f),this.needsRenderInternal=!1,this.sceneInternal=null!==(o=i.scene)&&void 0!==o?o:new g,this.cameraInternal=null!==(e=i.camera)&&void 0!==e?e:new M(75,v/f,.1,100),this.resolutionFactorInternal=c,this.updateModeInternal=null!==(u=i.updateBehavior)&&void 0!==u?u:Ii,null!==(l=i.renderedByDefault)&&void 0!==l&&l&&(this.needsRenderInternal=!0),this.clearColorInternal=null!==(a=i.clearColor)&&void 0!==a?a:0,this.clearAlphaInternal=null!==(d=i.clearAlpha)&&void 0!==d?d:0,this.renderTarget=w,this.material=m,this.applyTransformations()}get needsRender(){return this.needsRenderInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}get scene(){return this.sceneInternal}get camera(){return this.cameraInternal}get clearColor(){return this.clearColorInternal}get clearAlpha(){return this.clearAlphaInternal}get resolutionFactor(){return this.resolutionFactorInternal}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.sceneInternal!==t&&(this.sceneInternal=t,this.updateModeInternal===ai.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===ai.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===ai.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===ai.PROPERTY_CHANGED&&this.requestRender())}set resolutionFactor(t){this.resolutionFactorInternal!==t&&(this.resolutionFactorInternal=t,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),this.updateModeInternal===ai.PROPERTY_CHANGED&&this.requestRender())}destroy(){this.material.dispose(),this.renderTarget.dispose(),super.destroy()}requestRender(){this.needsRenderInternal=!0,this.composerInternal.requestUpdate()}render(t){(this.needsRenderInternal||this.updateModeInternal===ai.ALWAYS)&&(this.needsRenderInternal=!1,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),t.setClearColor(this.clearColorInternal,this.clearAlpha),t.setRenderTarget(this.renderTarget),t.clear(!0,!0,!1),t.render(this.sceneInternal,this.cameraInternal)),this.object.material=this.composerInternal.compose(t,this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal,this.material),this.applyTransformations()}}function Ai(t,i){var s,n,h,r,o,e,u,l,a,d,c,v,f,w,g,p,m,y,b,x,C,S,E,k,M,T,O,I;const F=Math.max(null!==(n=null!==(s=null==t?void 0:t.fontSize)&&void 0!==s?s:null==i?void 0:i.fontSize)&&void 0!==n?n:16,1),A=null!==(r=null!==(h=null==t?void 0:t.lineHeight)&&void 0!==h?h:null==i?void 0:i.lineHeight)&&void 0!==r?r:1.2*F,B=Math.max(null!==(e=null!==(o=null==t?void 0:t.shadowBlur)&&void 0!==o?o:null==i?void 0:i.shadowBlur)&&void 0!==e?e:0,0),$=Math.max(null!==(l=null!==(u=null==t?void 0:t.strokeWidth)&&void 0!==u?u:null==i?void 0:i.strokeWidth)&&void 0!==l?l:0,0);return{color:null!==(d=null!==(a=null==t?void 0:t.color)&&void 0!==a?a:null==i?void 0:i.color)&&void 0!==d?d:"#000000",fontFamily:null!==(v=null!==(c=null==t?void 0:t.fontFamily)&&void 0!==c?c:null==i?void 0:i.fontFamily)&&void 0!==v?v:"Arial",fontSize:F,fontStyle:null!==(w=null!==(f=null==t?void 0:t.fontStyle)&&void 0!==f?f:null==i?void 0:i.fontStyle)&&void 0!==w?w:"normal",fontWeight:null!==(p=null!==(g=null==t?void 0:t.fontWeight)&&void 0!==g?g:null==i?void 0:i.fontWeight)&&void 0!==p?p:"normal",lineHeight:A,enableShadow:null!==(y=null!==(m=null==t?void 0:t.enableShadow)&&void 0!==m?m:null==i?void 0:i.enableShadow)&&void 0!==y&&y,shadowOffsetX:null!==(x=null!==(b=null==t?void 0:t.shadowOffsetX)&&void 0!==b?b:null==i?void 0:i.shadowOffsetX)&&void 0!==x?x:0,shadowOffsetY:null!==(S=null!==(C=null==t?void 0:t.shadowOffsetY)&&void 0!==C?C:null==i?void 0:i.shadowOffsetY)&&void 0!==S?S:0,shadowBlur:B,shadowColor:null!==(k=null!==(E=null==t?void 0:t.shadowColor)&&void 0!==E?E:null==i?void 0:i.shadowColor)&&void 0!==k?k:"transparent",enableStroke:null!==(T=null!==(M=null==t?void 0:t.enableStroke)&&void 0!==M?M:null==i?void 0:i.enableStroke)&&void 0!==T&&T,strokeColor:null!==(I=null!==(O=null==t?void 0:t.strokeColor)&&void 0!==O?O:null==i?void 0:i.strokeColor)&&void 0!==I?I:"transparent",strokeWidth:$}}function Bi(t){return t.match(/\S+|\s|\n/g)||[]}function $i(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const n=t.measureText(i),h=n.width,r=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(h),height:r,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Pi(t,i,s,n,h){h.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,n.enableShadow&&(h.shadowOffsetX=n.shadowOffsetX,h.shadowOffsetY=n.shadowOffsetY,h.shadowBlur=n.shadowBlur,h.shadowColor=n.shadowColor),n.enableStroke&&(h.strokeStyle=n.strokeColor,h.lineWidth=n.strokeWidth,h.strokeText(s,t,i)),h.fillStyle=n.color,h.fillText(s,t,i)}class Ui extends oi{constructor(t,i,s={}){var n;const h=document.createElement("canvas"),r=h.getContext("2d");if(!r)throw Error("Failed to create canvas context");const o=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,n=i?t:t.text,h=Ai(i?void 0:t.style,s.defaultStyle);for(const t of Bi(n)){const i=$i(r,t,h);o.push({text:t,style:h,metrics:i})}}const u=((t,i)=>{const s=[];let n=[],h=0,r=0,o=0,e=0;for(const u of i)"\n"!==u.text?h+u.metrics.width>t&&0!==n.length?(s.push({chunks:n,width:h,height:r,baseline:o,lineHeight:e}),n=[u],h=u.metrics.width,r=u.metrics.height,o=u.metrics.baseline,e=u.metrics.lineHeight):(n.push(u),h+=u.metrics.width,r=Math.max(r,u.metrics.height),o=Math.max(o,u.metrics.baseline),e=Math.max(e,u.metrics.lineHeight)):(n.length>0&&s.push({chunks:n,width:h,height:r,baseline:o,lineHeight:e}),n=[],h=0,r=0,o=0,e=0);return n.length>0&&s.push({chunks:n,width:h,height:r,baseline:o,lineHeight:e}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,o),l=(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 n=t[i];s+=0===i?n.height:n.lineHeight,i===t.length-1&&(s+=n.baseline)}return{width:i,height:s}})(u),a=(t=>{var i,s,n,h;return"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(null!==(i=null==t?void 0:t.left)&&void 0!==i?i:0,0),right:Math.max(null!==(s=null==t?void 0:t.right)&&void 0!==s?s:0,0),top:Math.max(null!==(n=null==t?void 0:t.top)&&void 0!==n?n:0,0),bottom:Math.max(null!==(h=null==t?void 0:t.bottom)&&void 0!==h?h:0,0)}})(s.padding);h.width=l.width+a.left+a.right,h.height=l.height+a.top+a.bottom;const d=new T(h),c=new jt(d);super(t,new p(Nt,c),0,0,l.width,l.height),this.suggestedAspect=0,this.material=c,this.texture=d,this.canvas=h,this.context=r,this.textBlockSize=l,this.padding=a,((t,i,s,n)=>{let h=this.padding.top;for(let t=0;s.length>t;t++){const r=s[t];let o=i;h+=0===t?r.height:r.lineHeight;for(const t of r.chunks)Pi(o,h,t.text,t.style,n),o+=t.metrics.width}})(0,this.padding.left,u,this.context),this.texture.needsUpdate=!0,this.applyTransformations()}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),this.texture.dispose(),this.canvas.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.suggestedAspect!==t&&(this.suggestedAspect=t,this.height=this.width/((this.textBlockSize.width+this.padding.left+this.padding.right)/(this.textBlockSize.height+this.padding.top+this.padding.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.texture.image.width,this.texture.image.height,this.material),this.applyTransformations()}}class zi extends di{constructor(){super(),this.targetScreenHeight=1920,this.onResize=()=>{const t=this.calculateScale();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.onClick=t=>{if(this.mode!==_t.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,n=i?i.bottom-t.clientY:window.innerHeight-t.clientY,h=this.calculateScale();this.clickInternal(s*h,n*h)},window.addEventListener("resize",this.onResize),window.addEventListener("pointerdown",this.onClick),this.onResize()}get tergetScreenHeight(){return this.targetScreenHeight}set tergetScreenHeight(t){this.targetScreenHeight=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.onResize),window.removeEventListener("pointerdown",this.onClick),super.destroy()}render(t,i){t.clear(!1,!0,!0),super.render(t,i)}calculateScale(){var t;return(null!==(t=this.tergetScreenHeight)&&void 0!==t?t:window.innerHeight)/window.innerHeight}}function Di(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}class Vi{}export{It as UIAnchor,Ci as UIAspectConstraint,Lt as UIBlending,vt as UIConstraint,yi as UIConstraint2DBuilder,bi as UIConstraintContainerBuilder,li as UIConstraintContainerDirection,wt as UIConstraintPower,gt as UIConstraintRule,xi as UIConstraintStackBuilder,Si as UICoverConstraint,ki as UIDummy,oi as UIElement,ii as UIElementEvent,Ei as UIFitConstraint,zi as UIFullScreenLayer,Wt as UIFullScreenQuad,Mt as UIHeightConstraint,fi as UIHorizontalDistanceConstraint,wi as UIHorizontalProportionConstraint,Mi as UIImage,di as UILayer,ui as UILayerEvent,_t as UIMode,at as UIOrientation,Vi as UIPass,Oi as UIProgress,Fi as UIScene,ai as UISceneUpdateMode,Ui as UIText,gi as UIVerticalDistanceConstraint,pi as UIVerticalProportionConstraint,mi as UIWidthConstraint,Z as addConstraintSymbol,J as addUIConstraintSymbol,G as addUIElementSymbol,it as addVariableSymbol,ut as clickSymbol,Ct as convertPowerToStrength,kt as convertRuleToOperator,ht as disableConstraintSymbol,rt as enableConstraintSymbol,q as heightSymbol,bt as isUIConstraintPower,St as isUIConstraintRule,dt as isUIOrientation,Di as isUITextSpan,ot as needsRecalculation,tt as removeConstraintSymbol,K as removeUIConstraintSymbol,Q as removeUIElementSymbol,st as removeVariableSymbol,et as renderSymbol,ct as resolveOrientation,xt as resolvePower,Et as resolveRule,lt as sortSymbol,nt as suggestVariableSymbol,W as widthSymbol,X as xSymbol,Y as ySymbol};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|