laymur 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Color as t,Scene as i,OrthographicCamera as e,MathUtils as s,ShaderMaterial as r,PlaneGeometry as n,Mesh as o,Vector2 as h,Vector4 as a,UniformsUtils as u,WebGLRenderTarget as l,UnsignedByteType as c,LinearFilter as d,RGBAFormat as f,PerspectiveCamera as g,CanvasTexture as p}from"three";class v{constructor(t=0,i){this.constant=t,this.C=i?new Map(i):new Map}static plus(t,i){const e=new v(t.constant+i.constant,Array.from(t.C.entries()));for(const[t,s]of i.C)e.plus(t,s);return e}static minus(t,i){const e=new v(t.constant-i.constant,Array.from(t.C.entries()));for(const[t,s]of i.C)e.minus(t,s);return e}plus(t,i){return this.C.set(t,(this.C.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,e]of this.C)this.C.set(i,e*t);return this}divide(t){return this.multiply(1/t)}hasTerm(t){return this.C.has(t)}copy(t){this.constant=t.constant,this.C.clear();for(const[i,e]of t.C)this.C.set(i,e);return this}clone(){return new v(this.constant,Array.from(this.C.entries()))}prepareTermsInternal(){return Array.from(this.C.entries())}}class w{constructor(t,i,e=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,e):this.t.set(i,new Map([[t,e]])))}insert(t,i,e=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,e)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,e]])):s.has(t)||s.set(t,e)}remove(t,i){if(void 0===i)return void this.i.delete(t);const e=this.t.get(i);void 0!==e&&(e.delete(t),0===e.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const e=this.t.get(i);return void 0!==e&&e.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const e=this.t.get(i);return void 0!==e?e.get(t):void 0}}class m{constructor(){this.o=new Map}on(t,i,e,s=0){return this.h(t,!1,s,i,e),this}once(t,i,e,s=0){return this.h(t,!0,s,i,e),this}off(t,i,e){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=!1,s.v=s.v.slice());const r=s.v;if(0===r.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;r.length>t;t++){const i=r[t];s.l.remove(i._,i.p)}return this}{const n=r.length;if(r[0]._===i&&r[0].p===e)return 1===n?this.o.delete(t):r.shift(),this;const o=n-1;if(r[o]._===i&&r[o].p===e)return r.pop(),this;if(10>n||r[0].M===r[o].M)for(let t=1;o>t;t++){const s=r[t];if(s._===i&&s.p===e)return r.splice(t,1),this}else{const t=s.l.getPriority(i,e);if(void 0===t)return this;let n=0,o=r.length-1;for(;o>=n;){const i=n+o>>>1;t>r[i].M?n=i+1:o=i-1}const h=n;for(o=r.length-1;o>=n;){const i=n+o>>>1;r[i].M>t?o=i-1:n=i+1}const a=o;for(let t=h;a>=t;t++)if(r[t]._===i&&r[t].p===e)return r.splice(t,1),this}}return this}emit(t,...i){const e=this.o.get(t);if(void 0===e)return!1;if(0===e.v.length)return!1;e.u?e.v=e.v.slice():e.u=!0;const s=e.v;let r=!1;for(let t=0;s.length>t;t++){const e=s[t];e._.apply(e.p,i),e.k&&(r=!0,e.m=!0)}const n=this.o.get(t);if(void 0===n)return!0;n.v===s&&(n.u=!1);const o=n.v;if(r){let i=0;for(let t=0;o.length>t;t++){const e=o[t];e.m?n.l.remove(e._,e.p):o[i++]=e}0===i?this.o.delete(t):o.length=i}return!0}h(t,i,e,s,r){let n=this.o.get(t);if(void 0===n)return void this.o.set(t,{v:[{_:s,p:r,M:e,k:i,m:!1}],u:!1,l:new w(s,r,e)});if(n.l.has(s,r))throw Error("Event listener already exists");n.l.insert(s,r,e);const o={_:s,p:r,M:e,k:i,m:!1};n.u&&(n.u=!1,n.v=n.v.slice());{const t=n.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 e=0,s=t.length;for(;s>e;){const r=e+s>>>1;i>t[r].M?e=r+1:s=r}t.splice(e,0,o)}}}}var y,b;function x(t){return t??b.ALWAYS}function E(){return new C}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(y||(y={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(b||(b={}));class C{index={};array=[];size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const e=this.index[t.id()];if(void 0===e){const e=new _(t,i());return this.index[t.id()]=this.array.length,this.array.push(e),e}return this.array[e]}insert(t,i){const e=new _(t,i),s=this.index[t.id()];return void 0===s?(this.index[t.id()]=this.array.length,this.array.push(e)):this.array[s]=e,e}erase(t){const i=this.index[t.id()];if(void 0===i)return;this.index[t.id()]=void 0;const e=this.array[i],s=this.array.pop();return e!==s&&(this.array[i]=s,this.index[s.first.id()]=i),e}copy(){const t=new C;for(let i=0;this.array.length>i;i++){const e=this.array[i].copy();t.array[i]=e,t.index[e.first.id()]=i}return t}}class _{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new _(this.first,this.second)}}class I{constructor(t=""){this.I=t}id(){return this.S}name(){return this.I}setName(t){this.I=t}context(){return this.B}setContext(t){this.B=t}value(){return this.U}setValue(t){this.U=t}plus(t){return new B(this,t)}minus(t){return new B(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new B([t,this])}divide(t){return new B([1/t,this])}toJSON(){return{name:this.I,value:this.U}}toString(){return this.B+"["+this.I+":"+this.U+"]"}I;U=0;B=null;S=S++}let S=0;class B{constructor(){let t=(t=>{let i=0,e=()=>0,s=E();for(let r=0,n=t.length;n>r;++r){let n=t[r];if("number"==typeof n)i+=n;else if(n instanceof I)s.setDefault(n,e).second+=1;else if(n instanceof B){i+=n.constant();let t=n.terms();for(let i=0,r=t.size();r>i;i++){let r=t.itemAt(i);s.setDefault(r.first,e).second+=r.second}}else{if(!(n instanceof Array))throw Error("invalid Expression argument: "+n);{if(2!==n.length)throw Error("array must have length 2");let t=n[0],r=n[1];if("number"!=typeof t)throw Error("array item 0 must be a number");if(r instanceof I)s.setDefault(r,e).second+=t;else{if(!(r instanceof B))throw Error("array item 1 must be a variable or expression");{i+=r.constant()*t;let n=r.terms();for(let i=0,r=n.size();r>i;i++){let r=n.itemAt(i);s.setDefault(r.first,e).second+=r.second*t}}}}}}return{terms:s,constant:i}})(arguments);this.A=t.terms,this.T=t.constant}terms(){return this.A}constant(){return this.T}value(){let t=this.T;for(let i=0,e=this.A.size();e>i;i++){let e=this.A.itemAt(i);t+=e.first.value()*e.second}return t}plus(t){return new B(this,t)}minus(t){return new B(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new B([t,this])}divide(t){return new B([1/t,this])}isConstant(){return 0==this.A.size()}toString(){let t=this.A.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.T||(t+=" + "),t+=this.T,t}A;T}class k{static create(t,i,e,s=1){let r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*s)),r+=1e3*Math.max(0,Math.min(1e3,i*s)),r+=Math.max(0,Math.min(1e3,e*s)),r}static required=k.create(1e3,1e3,1e3);static strong=k.create(1,0,0);static medium=k.create(0,1,0);static weak=k.create(0,0,1);static clip(t){return Math.max(0,Math.min(k.required,t))}}var U;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(U||(U={}));class M{constructor(t,i,e,s=k.required){this.P=i,this.V=k.clip(s),this.O=void 0===e&&t instanceof B?t:t.minus(e)}id(){return this.S}expression(){return this.O}op(){return this.P}strength(){return this.V}toString(){return this.O+" "+["<=",">=","="][this.P]+" 0 ("+this.V+")"}O;P;V;S=A++}let A=0;class T{maxIterations=1e3;constructor(){}createConstraint(t,i,e,s=k.required){let r=new M(t,i,e,s);return this.addConstraint(r),r}addConstraint(t){if(void 0!==this.R.find(t))throw Error("duplicate constraint");let i=this.F(t),e=i.row,s=i.tag,r=this.L(e,s);if(r.type()===V.Invalid&&e.allDummies()){if(!P(e.constant()))throw Error("unsatisfiable constraint");r=s.marker}if(r.type()===V.Invalid){if(!this.H(e))throw Error("unsatisfiable constraint")}else e.solveFor(r),this.D(r,e),this.$.insert(r,e);this.R.insert(t,s),this.N(this.j)}removeConstraint(t){let i=this.R.erase(t);if(void 0===i)throw Error("unknown constraint");this.W(t,i.second);let e=i.second.marker,s=this.$.erase(e);if(void 0===s){let t=this.q(e);if(t.type()===V.Invalid)throw Error("failed to find leaving row");s=this.$.erase(t),s.second.solveForEx(t,e),this.D(e,s.second)}this.N(this.j)}hasConstraint(t){return this.R.contains(t)}getConstraints(){return this.R.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.X.find(t))throw Error("duplicate edit variable");if((i=k.clip(i))===k.required)throw Error("bad required strength");let e=new B(t),s=new M(e,U.Eq,void 0,i);this.addConstraint(s);let r=this.R.find(s).second;this.X.insert(t,{tag:r,constraint:s,constant:0})}removeEditVariable(t){let i=this.X.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.X.contains(t)}suggestValue(t,i){let e=this.X.find(t);if(void 0===e)throw Error("unknown edit variable");let s=this.$,r=e.second,n=i-r.constant;r.constant=i;let o=r.tag.marker,h=s.find(o);if(void 0!==h)return 0>h.second.add(-n)&&this.Y.push(o),void this.G();let a=r.tag.other;if(h=s.find(a),void 0!==h)return 0>h.second.add(n)&&this.Y.push(a),void this.G();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t),e=i.second,r=e.coefficientFor(o);0!==r&&0>e.add(n*r)&&i.first.type()!==V.External&&this.Y.push(i.first)}this.G()}updateVariables(){let t=this.Z,i=this.$;for(let e=0,s=t.size();s>e;++e){let s=t.itemAt(e),r=i.find(s.second);s.first.setValue(void 0!==r?r.second.constant():0)}}J(t){return this.Z.setDefault(t,()=>this.K(V.External)).second}F(t){let i=t.expression(),e=new F(i.constant()),s=i.terms();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t);if(!P(i.second)){let t=this.J(i.first),s=this.$.find(t);void 0!==s?e.insertRow(s.second,i.second):e.insertSymbol(t,i.second)}}let r=this.j,n=t.strength(),o={marker:R,other:R};switch(t.op()){case U.Le:case U.Ge:{let i=t.op()===U.Le?1:-1,s=this.K(V.Slack);if(o.marker=s,e.insertSymbol(s,i),k.required>n){let t=this.K(V.Error);o.other=t,e.insertSymbol(t,-i),r.insertSymbol(t,n)}break}case U.Eq:if(k.required>n){let t=this.K(V.Error),i=this.K(V.Error);o.marker=t,o.other=i,e.insertSymbol(t,-1),e.insertSymbol(i,1),r.insertSymbol(t,n),r.insertSymbol(i,n)}else{let t=this.K(V.Dummy);o.marker=t,e.insertSymbol(t)}}return 0>e.constant()&&e.reverseSign(),{row:e,tag:o}}L(t,i){let e=t.cells();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(i.first.type()===V.External)return i.first}let s=i.marker.type();return s!==V.Slack&&s!==V.Error||t.coefficientFor(i.marker)>=0?(s=i.other.type(),s!==V.Slack&&s!==V.Error||t.coefficientFor(i.other)>=0?R:i.other):i.marker}H(t){let i=this.K(V.Slack);this.$.insert(i,t.copy()),this.tt=t.copy(),this.N(this.tt);let e=P(this.tt.constant());this.tt=null;let s=this.$.erase(i);if(void 0!==s){let t=s.second;if(t.isConstant())return e;let r=this.it(t);if(r.type()===V.Invalid)return!1;t.solveForEx(i,r),this.D(r,t),this.$.insert(r,t)}let r=this.$;for(let t=0,e=r.size();e>t;++t)r.itemAt(t).second.removeSymbol(i);return this.j.removeSymbol(i),e}D(t,i){let e=this.$;for(let s=0,r=e.size();r>s;++s){let r=e.itemAt(s);r.second.substitute(t,i),0>r.second.constant()&&r.first.type()!==V.External&&this.Y.push(r.first)}this.j.substitute(t,i),this.tt&&this.tt.substitute(t,i)}N(t){let i=0;for(;this.maxIterations>i;){let e=this.et(t);if(e.type()===V.Invalid)return;let s=this.st(e);if(s.type()===V.Invalid)throw Error("the objective is unbounded");let r=this.$.erase(s).second;r.solveForEx(s,e),this.D(e,r),this.$.insert(e,r),i++}throw Error("solver iterations exceeded")}G(){let t=this.$,i=this.Y;for(;0!==i.length;){let e=i.pop(),s=t.find(e);if(void 0!==s&&0>s.second.constant()){let i=this.rt(s.second);if(i.type()===V.Invalid)throw Error("dual optimize failed");let r=s.second;t.erase(e),r.solveForEx(e,i),this.D(i,r),t.insert(i,r)}}}et(t){let i=t.cells();for(let t=0,e=i.size();e>t;++t){let e=i.itemAt(t),s=e.first;if(0>e.second&&s.type()!==V.Dummy)return s}return R}rt(t){let i=Number.MAX_VALUE,e=R,s=t.cells();for(let t=0,r=s.size();r>t;++t){let r=s.itemAt(t),n=r.first,o=r.second;if(o>0&&n.type()!==V.Dummy){let t=this.j.coefficientFor(n)/o;i>t&&(i=t,e=n)}}return e}st(t){let i=Number.MAX_VALUE,e=R,s=this.$;for(let r=0,n=s.size();n>r;++r){let n=s.itemAt(r),o=n.first;if(o.type()!==V.External){let s=n.second,r=s.coefficientFor(t);if(0>r){let t=-s.constant()/r;i>t&&(i=t,e=o)}}}return e}q(t){let i=Number.MAX_VALUE,e=i,s=i,r=R,n=r,o=r,h=r,a=this.$;for(let i=0,r=a.size();r>i;++i){let r=a.itemAt(i),u=r.second,l=u.coefficientFor(t);if(0===l)continue;let c=r.first;if(c.type()===V.External)h=c;else if(0>l){let t=-u.constant()/l;e>t&&(e=t,n=c)}else{let t=u.constant()/l;s>t&&(s=t,o=c)}}return n!==r?n:o!==r?o:h}W(t,i){i.marker.type()===V.Error&&this.nt(i.marker,t.strength()),i.other.type()===V.Error&&this.nt(i.other,t.strength())}nt(t,i){let e=this.$.find(t);void 0!==e?this.j.insertRow(e.second,-i):this.j.insertSymbol(t,-i)}it(t){let i=t.cells();for(let t=0,e=i.size();e>t;++t){let e=i.itemAt(t),s=e.first.type();if(s===V.Slack||s===V.Error)return e.first}return R}K(t){return new O(t,this.ot++)}R=(()=>E())();$=(()=>E())();Z=(()=>E())();X=(()=>E())();Y=[];j=new F;tt=null;ot=0}function P(t){return 0>t?1e-8>-t:1e-8>t}var V;(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"})(V||(V={}));class O{constructor(t,i){this.S=i,this.ht=t}id(){return this.S}type(){return this.ht}S;ht}let R=new O(V.Invalid,-1);class F{constructor(t=0){this.T=t}cells(){return this.ut}constant(){return this.T}isConstant(){return this.ut.empty()}allDummies(){let t=this.ut;for(let i=0,e=t.size();e>i;++i)if(t.itemAt(i).first.type()!==V.Dummy)return!1;return!0}copy(){let t=new F(this.T);return t.ut=this.ut.copy(),t}add(t){return this.T+=t}insertSymbol(t,i=1){P(this.ut.setDefault(t,()=>0).second+=i)&&this.ut.erase(t)}insertRow(t,i=1){this.T+=t.T*i;let e=t.ut;for(let t=0,s=e.size();s>t;++t){let s=e.itemAt(t);this.insertSymbol(s.first,s.second*i)}}removeSymbol(t){this.ut.erase(t)}reverseSign(){this.T=-this.T;let t=this.ut;for(let i=0,e=t.size();e>i;++i){let e=t.itemAt(i);e.second=-e.second}}solveFor(t){let i=this.ut,e=-1/i.erase(t).second;this.T*=e;for(let t=0,s=i.size();s>t;++t)i.itemAt(t).second*=e}solveForEx(t,i){this.insertSymbol(t,-1),this.solveFor(i)}coefficientFor(t){let i=this.ut.find(t);return void 0!==i?i.second:0}substitute(t,i){let e=this.ut.erase(t);void 0!==e&&this.insertRow(i,e.second)}ut=E();T}const z=1e3;var L,H;function D(t){switch(t){case L.P0:return k.create(z,z,z);case L.P1:return k.create(100,0,0);case L.P2:return k.create(10,0,0);case L.P3:return k.create(0,100,0);case L.P4:return k.create(0,10,0);case L.P5:return k.create(0,0,100);case L.P6:return k.create(0,0,10);case L.P7:return k.create(0,0,1);default:throw Error("Invalid priority: "+t)}}function $(t){return t??L.P0}(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"})(L||(L={})),(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(H||(H={}));const N=new t;class j{constructor(t,s){this.lt=new i,this.ct=new Map,this.dt=new e(0,t,s,0,-1,1)}insertObject(t,i){if(this.ct.has(t))throw Error("Element already exists");this.ct.set(t,i),this.lt.add(i)}replaceObject(t,i){const e=this.ct.get(t);if(void 0===e)throw Error("Element not found");this.lt.remove(e),this.lt.add(i),this.ct.set(t,i)}removeObject(t){const i=this.ct.get(t);if(void 0===i)throw Error("Element not found");this.lt.remove(i),this.ct.delete(t)}resize(t,i){this.dt.right=t,this.dt.top=i,this.dt.updateProjectionMatrix()}getVisibility(t){const i=this.ct.get(t);if(void 0===i)throw Error("Element not found");return i.visible}getZIndex(t){const i=this.ct.get(t);if(void 0===i)throw Error("Element not found");return i.renderOrder}setZIndex(t,i){const e=this.ct.get(t);if(void 0===e)throw Error("Element not found");e.renderOrder=i}setVisibility(t,i){const e=this.ct.get(t);if(void 0===e)throw Error("Element not found");e.visible=i}getSortedVisibleElements(){return Array.from(this.ct.keys()).sort((t,i)=>this.getZIndex(t)-this.getZIndex(i))}render(t,i){const e=t.getRenderTarget(),s=t.getClearColor(N),r=t.getClearAlpha(),n=t.autoClear,o=t.autoClearColor,h=t.autoClearDepth,a=t.autoClearStencil;t.autoClear=!1,t.autoClearColor=!1,t.autoClearDepth=!1,t.autoClearStencil=!1,t.setClearColor(0,1);for(const[e,s]of this.ct){const r=e.micro,n=e.width*r.scaleX,o=e.height*r.scaleY,h=r.anchorX*n,a=r.anchorY*o,u=Math.cos(r.rotation),l=Math.sin(r.rotation),c=h*u-a*l,d=h*l+a*u;if(r.anchorMode===H.POSITION_ROTATION_SCALE)s.position.x=e.x+r.x-c,s.position.y=e.y+r.y-d;else{const t=r.anchorY*e.height;s.position.x=e.x+r.anchorX*e.width-c+r.x,s.position.y=e.y+t-d+r.y}s.scale.x=n,s.scale.y=o,s.rotation.z=r.rotation,e.onBeforeRenderInternal(t,i)}t.clear(!1,!0,!0),t.render(this.lt,this.dt),t.setRenderTarget(e),t.setClearColor(s),t.setClearAlpha(r),t.autoClear=n,t.autoClearColor=o,t.autoClearDepth=h,t.autoClearStencil=a}}var W,q;function X(t){switch(t){case W.EQUAL:return U.Eq;case W.LESS_THAN:return U.Le;case W.GREATER_THAN:return U.Ge;default:throw Error("Invalid relation: "+t)}}function Y(t){return t??W.EQUAL}(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(W||(W={}));class G{constructor(){this.ft=new T,this.gt=!1,this.vt=new Map,this.wt=0,this.yt=new Map,this.bt=0}createVariable(t,i){const e=this.wt++,s=new I;if(i===L.P0){const r={variable:s,priority:i,value:t};this.vt.set(e,r),r.constraint=this.xt(new v(0,[[e,1]]),new v(t),W.EQUAL,i);try{this.ft?.addConstraint(r.constraint)}catch{this.ft=void 0}}else{this.vt.set(e,{variable:s,priority:i,value:t});try{this.ft?.addEditVariable(s,D(i)),this.ft?.suggestValue(s,t)}catch{this.ft=void 0}}return this.gt=!0,e}removeVariable(t){const i=this.vt.get(t);if(void 0===i)throw Error(`Variable ${t} does not exist`);for(const i of this.yt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error(`Variable ${t} is used in constraint`);try{i.constraint?this.ft?.removeConstraint(i.constraint):this.ft?.removeEditVariable(i.variable)}catch{this.ft=void 0}this.vt.delete(t),this.gt=!0}suggestVariableValue(t,i){const e=this.vt.get(t);if(void 0===e)throw Error(`Variable ${t} does not exist`);e.value!==i&&(e.value=i,e.constraint?e.constraint=this.Et(e.constraint,(new v).plus(t,1),new v(e.value),W.EQUAL,e.priority):this.ft?.suggestValue(e.variable,i),this.gt=!0)}setVariablePriority(t,i){const e=this.vt.get(t);if(void 0===e)throw Error(`Variable ${t} does not exist`);if(i!==e.priority){if(e.priority=i,e.priority===L.P0){const i=(new v).plus(t,1),s=new v(e.value);e.constraint=this.xt(i,s,W.EQUAL,e.priority);try{this.ft?.addConstraint(e.constraint)}catch{this.ft=void 0}}else{if(e.constraint)try{this.ft?.removeConstraint(e.constraint)}catch{this.ft=void 0}e.constraint=void 0,this.Ct(t,e)}this.gt=!0}}readVariableValue(t){const i=this.vt.get(t);if(void 0===i)throw Error(`Variable ${t} does not exist`);return void 0===this.ft&&this._t(),this.gt&&(this.ft?.updateVariables(),this.gt=!1),i.variable.value()}createConstraint(t,i,e,s,r){const n=this.bt++,o=this.xt(t,i,e,s);if(this.yt.set(n,{constraint:o,lhs:t.clone(),rhs:i.clone(),priority:s,relation:e,enabled:r}),r){try{this.ft?.addConstraint(o)}catch{this.ft=void 0}this.gt=!0}return n}removeConstraint(t){const i=this.yt.get(t);if(void 0===i)throw Error(`Constraint ${t} does not exist`);if(i.enabled)try{this.ft?.removeConstraint(i.constraint)}catch{this.ft=void 0}this.yt.delete(t),this.gt=!0}setConstraintLHS(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.lhs.copy(i),this.It(e),this.gt=!0}setConstraintRHS(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.rhs.copy(i),this.It(e),this.gt=!0}setConstraintRelation(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.relation=i,this.It(e),this.gt=!0}setConstraintPriority(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.priority=i,this.It(e),this.gt=!0}setConstraintEnabled(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);if(i!==e.enabled){e.enabled=i;try{e.enabled?this.ft?.addConstraint(e.constraint):this.ft?.removeConstraint(e.constraint)}catch{this.ft=void 0}this.gt=!0}}Ct(t,i){const e=[];for(const i of this.yt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{this.ft?.removeConstraint(i.constraint)}catch{this.ft=void 0}e.push(i)}this.ft?.removeEditVariable(i.variable),this.ft?.addEditVariable(i.variable,D(i.priority));for(const t of e)t.constraint=this.xt(t.lhs,t.rhs,t.relation,t.priority);for(const t of e)try{this.ft?.addConstraint(t.constraint)}catch{this.ft=void 0;break}}It(t){t.constraint=t.enabled?this.Et(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.xt(t.lhs,t.rhs,t.relation,t.priority)}Et(t,i,e,s,r){try{this.ft?.removeConstraint(t)}catch{this.ft=void 0}const n=this.xt(i,e,s,r);try{this.ft?.addConstraint(n)}catch{this.ft=void 0}return n}xt(t,i,e,s){return new M(this.St(t),X(e),this.St(i),D(s))}St(t){return new B(...t.prepareTermsInternal().map(([t,i])=>{const e=this.vt.get(t);if(void 0===e)throw Error(`Variable ${t} does not exist`);return[i,e.variable]}),t.constant)}_t(){if(this.ft)throw Error("Solver already exists");this.ft=new T;for(const t of this.vt.values())t.constraint?this.ft.addConstraint(t.constraint):(this.ft.addEditVariable(t.variable,D(t.priority)),this.ft.suggestValue(t.variable,t.value));for(const t of this.yt.values())t.enabled&&this.ft.addConstraint(t.constraint);this.gt=!0}}(t=>{t.ORIENTATION_CHANGE="orientation_change",t.MODE_CHANGE="mode_change"})(q||(q={}));class Z extends m{constructor(t,i){super(),this.name="",this.solverWrapper=new G,this.modeInternal=y.VISIBLE,this.sceneWrapper=new j(t,i),this.xVariable=this.solverWrapper.createVariable(0,L.P0),this.yVariable=this.solverWrapper.createVariable(0,L.P0),this.wVariable=this.solverWrapper.createVariable(t,L.P0),this.hVariable=this.solverWrapper.createVariable(i,L.P0),this.orientationInternal=t>i?b.HORIZONTAL:b.VERTICAL}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get mode(){return this.modeInternal}get orientation(){return this.orientationInternal}set mode(t){t!==this.modeInternal&&(this.modeInternal=t,this.emit(q.MODE_CHANGE,this.modeInternal,this))}resizeInternal(t,i){this.solverWrapper.suggestVariableValue(this.wVariable,t),this.solverWrapper.suggestVariableValue(this.hVariable,i),this.sceneWrapper.resize(t,i);const e=t>i?b.HORIZONTAL:b.VERTICAL;e!==this.orientationInternal&&(this.orientationInternal=e,this.emit(q.ORIENTATION_CHANGE,this.orientationInternal,this))}renderInternal(t,i){this.mode!==y.HIDDEN&&this.sceneWrapper.render(t,i)}clickInternal(t,i){if(this.mode===y.INTERACTIVE)for(const e of this.sceneWrapper.getSortedVisibleElements())if(e.onClickInternal(t,i))return}getSolverWrapperInternal(){return this.solverWrapper}getSceneWrapperInternal(){return this.sceneWrapper}}class Q{constructor(t){this.layer=t,this.name="",this.solverWrapper=this.layer.getSolverWrapperInternal()}}class J extends Q{constructor(t,i,e,s){super(t),this.Bt=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.priorityInternal=$(i),this.relationInternal=Y(e),this.orientationInternal=x(s),this.layer.on(q.ORIENTATION_CHANGE,this.Bt)}get priority(){return this.priorityInternal}get relation(){return this.relationInternal}get orientation(){return this.orientationInternal}set priority(t){t!==this.priorityInternal&&(this.priorityInternal=t,this.solverWrapper.setConstraintPriority(this.constraint,this.priorityInternal))}set relation(t){t!==this.relationInternal&&(this.relationInternal=t,this.solverWrapper.setConstraintRelation(this.constraint,this.relationInternal))}set orientation(t){t!==this.orientationInternal&&(this.orientationInternal=t,this.Bt())}destroy(){this.layer.off(q.ORIENTATION_CHANGE,this.Bt),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.orientationInternal===b.ALWAYS||this.orientationInternal===this.layer.orientation}}class K extends J{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.kt=t,this.Ut=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new v(0,[[this.kt.hVariable,1]]),new v(this.Ut),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Ut}set height(t){this.Ut!==t&&(this.Ut=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(t)))}}function tt(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof Z}function it(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function et(t){return"object"==typeof t&&null!==t&&"wVariable"in t&&"number"==typeof t.wVariable&&"hVariable"in t&&"number"==typeof t.hVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function st(t,i,e){if(t instanceof Z&&i instanceof Z)throw Error(e+": layer cannot be snapped to another layer");let s,r;if(!(t instanceof Z||tt(t)))throw Error(e+": A must be a UILayer or a UIPointElement");if(s=t instanceof Z?t:t.layer,!(i instanceof Z||tt(i)))throw Error(e+": B must be a UILayer or a UIPointElement");if(r=i instanceof Z?i:i.layer,s!==r)throw Error(e+": elements must be on the same layer");return s}function rt(t,i){if(!Number.isFinite(t))throw Error(i+": value must be a finite number");if(Math.abs(t)>Number.MAX_SAFE_INTEGER)throw Error(i+": value exceeds maximum safe integer range")}function nt(t,i){if(rt(t,i),1e-6>t)throw Error(i+": value must be greater than or equal to 0.000001")}function ot(t,i){if(rt(t,i),0>t)throw Error(i+": value must be greater than or equal to 0")}class ht extends J{constructor(t,i,e={}){super(st(t,i,"UIHorizontalDistanceConstraint"),e.priority,e.relation,e.orientation),this.Mt=t,this.At=i,this.Tt=e.anchorA??.5,this.Pt=e.anchorB??.5,this.Vt=e.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ot(),new v(this.Vt),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get distance(){return this.Vt}get anchorA(){return this.Tt}get anchorB(){return this.Pt}set distance(t){this.Vt!==t&&(this.Vt=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(this.Vt)))}set anchorA(t){this.Tt!==t&&(this.Tt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ot()))}set anchorB(t){this.Pt!==t&&(this.Pt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ot()))}Ot(){let t,i;if(et(this.Mt))t=new v(0,[[this.Mt.xVariable,1],[this.Mt.wVariable,this.Tt]]);else{if(!it(this.Mt))throw Error("A is not a valid element type");t=(new v).plus(this.Mt.xVariable,1)}if(et(this.At))i=new v(0,[[this.At.xVariable,1],[this.At.wVariable,this.Pt]]);else{if(!it(this.At))throw Error("B is not a valid element type");i=(new v).plus(this.At.xVariable,1)}return v.minus(i,t)}}class at extends J{constructor(t,i,e={}){super(st(t,i,"UIHorizontalProportionConstraint"),e.priority,e.relation,e.orientation),this.Mt=t,this.At=i,this.Rt=e.proportion??1,this.constraint=this.solverWrapper.createConstraint(new v(0),this.Ft(),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get proportion(){return this.Rt}set proportion(t){this.Rt!==t&&(this.Rt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Ft()))}Ft(){return v.minus(new v(0,[[this.Mt.wVariable,this.Rt]]),new v(0,[[this.At.wVariable,1]]))}}class ut extends J{constructor(t,i,e={}){super(st(t,i,"UIVerticalDistanceConstraint"),e.priority,e.relation,e.orientation),this.Mt=t,this.At=i,this.Tt=e.anchorA??.5,this.Pt=e.anchorB??.5,this.Vt=e.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ot(),new v(this.Vt),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get distance(){return this.Vt}get anchorA(){return this.Tt}get anchorB(){return this.Pt}set distance(t){this.Vt!==t&&(this.Vt=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(this.Vt)))}set anchorA(t){this.Tt!==t&&(this.Tt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ot()))}set anchorB(t){this.Pt!==t&&(this.Pt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ot()))}Ot(){let t,i;if(et(this.Mt))t=new v(0,[[this.Mt.yVariable,1],[this.Mt.hVariable,this.Tt]]);else{if(!it(this.Mt))throw Error("A is not a valid element type");t=(new v).plus(this.Mt.yVariable,1)}if(et(this.At))i=new v(0,[[this.At.yVariable,1],[this.At.hVariable,this.Pt]]);else{if(!it(this.At))throw Error("B is not a valid element type");i=(new v).plus(this.At.yVariable,1)}return v.minus(i,t)}}class lt extends J{constructor(t,i,e={}){super(st(t,i,"UIVerticalProportionConstraint"),e.priority,e.relation,e.orientation),this.Mt=t,this.At=i,this.Rt=e.proportion??1,this.constraint=this.solverWrapper.createConstraint(new v(0),this.Ft(),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get proportion(){return this.Rt}set proportion(t){this.Rt!==t&&(this.Rt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Ft()))}Ft(){return v.minus(new v(0,[[this.Mt.hVariable,this.Rt]]),new v(0,[[this.At.hVariable,1]]))}}class ct extends J{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.kt=t,this.zt=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new v(0,[[this.kt.wVariable,1]]),new v(this.zt),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.zt}set width(t){this.zt!==t&&(this.zt=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(t)))}}class dt{static size(t,i={}){return{h:new ct(t,{width:i.size?.h,priority:i.priority?.h,relation:i.relation?.h,orientation:i.orientation?.h}),v:new K(t,{height:i.size?.v,priority:i.priority?.v,relation:i.relation?.v,orientation:i.orientation?.v})}}static distance(t,i,e={}){return{h:new ht(t,i,{anchorA:e.anchorA?.h,anchorB:e.anchorB?.h,distance:e.distance?.h,priority:e.priority?.h,relation:e.relation?.h,orientation:e.orientation?.h}),v:new ut(t,i,{anchorA:e.anchorA?.v,anchorB:e.anchorB?.v,distance:e.distance?.v,priority:e.priority?.v,relation:e.relation?.v,orientation:e.orientation?.v})}}static proportion(t,i,e={}){return{h:new at(t,i,{proportion:e.proportion?.h,priority:e.priority?.h,relation:e.relation?.h,orientation:e.orientation?.h}),v:new lt(t,i,{proportion:e.proportion?.v,priority:e.priority?.v,relation:e.relation?.v,orientation:e.orientation?.v})}}}class ft extends J{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.kt=t,this.Lt=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Ot(),new v(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.Lt}set aspect(t){this.Lt!==t&&(this.Lt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ot()))}Ot(){return new v(0,[[this.kt.wVariable,1],[this.kt.hVariable,-this.Lt]])}}const gt=.5;class pt{static build(t,i,e={}){let s;return!0===e.keepActiveAspect&&(s=new ft(i,{orientation:e.orientation})),{activeAspectConstraint:s,xConstraint:new ht(t,i,{anchorA:e.anchorH??gt,anchorB:e.anchorH??gt,orientation:e.orientation}),yConstraint:new ut(t,i,{anchorA:e.anchorV??gt,anchorB:e.anchorV??gt,orientation:e.orientation}),widthConstraint:new at(t,i,{proportion:1,relation:W.GREATER_THAN,orientation:e.orientation}),heightConstraint:new lt(t,i,{proportion:1,priority:L.P1,orientation:e.orientation})}}}const vt=.5;class wt{static build(t,i,e={}){let s;return!0===e.keepActiveAspect&&(s=new ft(i,{orientation:e.orientation})),{activeAspectConstraint:s,xConstraint:new ht(t,i,{anchorA:e.anchorH??vt,anchorB:e.anchorH??vt,orientation:e.orientation}),yConstraint:new ut(t,i,{anchorA:e.anchorV??vt,anchorB:e.anchorV??vt,orientation:e.orientation}),widthConstraint:new at(t,i,{proportion:1,relation:W.LESS_THAN,orientation:e.orientation}),heightConstraint:new lt(t,i,{proportion:1,priority:L.P1,orientation:e.orientation})}}}class mt extends J{constructor(t,i,e,s={}){super(t,s.priority,s.relation,s.orientation),this.Ht=i,this.Dt=e,this.constraint=this.solverWrapper.createConstraint(this.Ht,this.Dt,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.Ht}get rhs(){return this.Dt}setLHS(t){this.Ht=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ht)}setRHS(t){this.Dt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Dt)}}class yt extends m{constructor(t,i,e){rt(i,"UIAnchor x"),rt(e,"UIAnchor y"),super(),this.layer=t,this.name="",this.solverWrapper=this.layer.getSolverWrapperInternal(),this.xVariable=this.solverWrapper.createVariable(i,L.P7),this.yVariable=this.solverWrapper.createVariable(e,L.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){rt(t,"UIAnchor x"),this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){rt(t,"UIAnchor y"),this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}class bt extends yt{constructor(t,i,e,s=100,r=100){nt(s,"UIDummy width"),nt(r,"UIDummy height"),super(t,i,e),this.wVariable=this.solverWrapper.createVariable(s,L.P6),this.hVariable=this.solverWrapper.createVariable(r,L.P6)}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}set width(t){nt(t,"UIDummy width"),this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){nt(t,"UIDummy height"),this.solverWrapper.suggestVariableValue(this.hVariable,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),super.destroy()}}const xt=.5;class Et{constructor(){this.$t=0,this.Nt=0,this.jt=xt,this.Wt=xt,this.qt=1,this.Xt=1,this.Yt=0,this.Gt=H.ROTATION_SCALE,this.gt=!1}get x(){return this.$t}get y(){return this.Nt}get anchorX(){return this.jt}get anchorY(){return this.Wt}get scaleX(){return this.qt}get scaleY(){return this.Xt}get size(){return Math.max(this.qt,this.Xt)}get angle(){return s.radToDeg(this.Yt)}get anchorMode(){return this.Gt}get rotation(){return this.Yt}set x(t){t!==this.$t&&(this.$t=t,this.gt=!0)}set y(t){t!==this.Nt&&(this.Nt=t,this.gt=!0)}set anchorX(t){t!==this.jt&&(this.jt=t,this.gt=!0)}set anchorY(t){t!==this.Wt&&(this.Wt=t,this.gt=!0)}set scaleX(t){t!==this.qt&&(this.qt=t,this.gt=!0)}set scaleY(t){t!==this.Xt&&(this.Xt=t,this.gt=!0)}set size(t){t===this.qt&&t===this.Xt||(this.qt=t,this.Xt=t,this.gt=!0)}set angle(t){const i=s.degToRad(t);i!==this.Yt&&(this.Yt=i,this.gt=!0)}set rotation(t){t!==this.Yt&&(this.Yt=t,this.gt=!0)}set anchorMode(t){t!==this.Gt&&(this.Gt=t,this.gt=!0)}reset(){0===this.$t&&0===this.Nt&&this.jt===xt&&this.Wt===xt&&1===this.qt&&1===this.Xt&&0===this.Yt||(this.$t=0,this.Nt=0,this.jt=xt,this.Wt=xt,this.qt=1,this.Xt=1,this.Yt=0,this.gt=!0)}getRecalculationRequiredInternal(){return this.gt}resetRecalculationRequiredInternal(){this.gt=!1}}var Ct;(t=>{t.CLICK="click"})(Ct||(Ct={}));class _t extends yt{constructor(t,i,e,s,r,n){nt(s,"UIElement width"),nt(r,"UIElement height"),super(t,i,e),this.object=n,this.micro=new Et,this.modeInternal=y.VISIBLE,this.sceneWrapper=this.layer.getSceneWrapperInternal(),this.sceneWrapper.insertObject(this,this.object),this.wVariable=this.solverWrapper.createVariable(s,L.P6),this.hVariable=this.solverWrapper.createVariable(r,L.P6)}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get zIndex(){return this.sceneWrapper.getZIndex(this)}get mode(){return this.modeInternal}set width(t){nt(t,"UIElement width"),this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){nt(t,"UIElement height"),this.solverWrapper.suggestVariableValue(this.hVariable,t)}set zIndex(t){rt(t,"UIElement zIndex"),this.sceneWrapper.setZIndex(this,t)}set mode(t){t!==this.modeInternal&&(this.modeInternal=t,this.sceneWrapper.setVisibility(this,t!==y.HIDDEN))}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.sceneWrapper.removeObject(this),super.destroy()}onClickInternal(t,i){const e=this.modeInternal===y.INTERACTIVE&&t>this.x&&this.x+this.width>t&&i>this.y&&this.y+this.height>i;return e&&this.emit(Ct.CLICK,t,i,this),e}onBeforeRenderInternal(t,i){}}const It=.75;class St extends r{constructor(i){super({uniforms:{map:{value:i},opacity:{value:1},color:{value:new t(1,1,1)},alphaTest:{value:It}},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 uniform float alphaTest;\n varying vec2 vUv;\n\n void main() {\n vec4 diffuseColor = texture2D(map, vUv);\n #include <alphatest_fragment>\n gl_FragColor = vec4(diffuseColor.rgb * color, diffuseColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:!1,alphaTest:It,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}getTransparency(){return this.transparent}setTexture(t){return this.uniforms.map.value=t,this.uniformsNeedUpdate=!0,this}setColor(t){return this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0,this}setOpacity(t){return this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0,this}setTransparency(t){return this.transparent!==t&&(this.transparent=t,this.uniforms.alphaTest.value=t?0:It,this.needsUpdate=!0,this.uniformsNeedUpdate=!0),this}}const Bt=new n(1,1).translate(.5,.5,0);class kt extends _t{constructor(t,i,e=0,s=0){const r=i.image.width,n=i.image.height,h=new St(i);super(t,e,s,r,n,new o(Bt,h)),this.Zt=h,this.Qt=i}get texture(){return this.Qt}get color(){return this.Zt.getColor()}get opacity(){return this.Zt.getOpacity()}get transparency(){return this.Zt.getTransparency()}set texture(t){const i=t.image.width,e=t.image.height;nt(i,"UIImage texture width"),nt(e,"UIImage texture height"),this.Zt.setTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,e)}set color(t){this.Zt.setColor(t)}set opacity(t){this.Zt.setOpacity(t)}set transparency(t){this.Zt.setTransparency(t)}destroy(){this.Zt.dispose(),super.destroy()}}const Ut=.25;class Mt extends r{constructor(i){super({uniforms:{map:{value:i},color:{value:new t(16777215)},opacity:{value:1},alphaTest:{value:.025},sliceBorders:{value:new a(Ut,Ut,Ut,Ut)},atlasRect:{value:new a(0,0,1,1)},quadSize:{value:new h(1,1)},textureSize:{value:new h(i.image.width,i.image.height)}},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 vec3 color;\n uniform float opacity;\n uniform float alphaTest;\n uniform vec4 sliceBorders;\n uniform vec4 atlasRect;\n uniform vec2 quadSize;\n uniform vec2 textureSize;\n varying vec2 vUv;\n\n vec2 calcNineSliceUV(vec2 uv) {\n vec2 localUV = uv;\n\n float left = sliceBorders.x;\n float right = sliceBorders.y;\n float top = sliceBorders.z;\n float bottom = sliceBorders.w;\n\n vec2 texPx = textureSize * atlasRect.zw;\n\n float leftPx = left * texPx.x;\n float rightPx = right * texPx.x;\n float topPx = top * texPx.y;\n float bottomPx = bottom * texPx.y;\n\n float lB = leftPx / quadSize.x;\n float rB = 1.0 - (rightPx / quadSize.x);\n float tB = topPx / quadSize.y;\n float bB = 1.0 - (bottomPx / quadSize.y);\n\n float regionL = step(uv.x, lB);\n float regionR = step(rB, uv.x);\n float regionM = 1.0 - regionL - regionR;\n\n float xL = uv.x * (left / lB);\n float xR = 1.0 - right + ((uv.x - rB) / (1.0 - rB)) * right;\n float xM = left + ((uv.x - lB) / (rB - lB)) * (1.0 - left - right);\n\n localUV.x = regionL * xL + regionM * xM + regionR * xR;\n\n float regionT = step(uv.y, tB);\n float regionBtm = step(bB, uv.y);\n float regionC = 1.0 - regionT - regionBtm;\n\n float yT = uv.y * (top / tB);\n float yB = 1.0 - bottom + ((uv.y - bB) / (1.0 - bB)) * bottom;\n float yC = top + ((uv.y - tB) / (bB - tB)) * (1.0 - top - bottom);\n\n localUV.y = regionT * yT + regionC * yC + regionBtm * yB;\n\n return atlasRect.xy + localUV * atlasRect.zw;\n }\n\n void main() {\n vec2 uv = calcNineSliceUV(vUv);\n vec4 texel = texture2D(map, uv);\n if (texel.a < alphaTest) discard;\n gl_FragColor = vec4(texel.rgb * color, texel.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:!1,alphaTest:.025,lights:!1,fog:!1,depthWrite:!0,depthTest:!0})}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}getTransparency(){return this.transparent}setSliceBorders(t,i,e,s){return this.uniforms.sliceBorders.value.set(t,i,e,s),this.uniformsNeedUpdate=!0,this}setQuadSize(t,i){return this.uniforms.quadSize.value.set(t,i),this.uniformsNeedUpdate=!0,this}setAtlasRect(t,i,e,s){return this.uniforms.atlasRect.value.set(t,i,e,s),this.uniformsNeedUpdate=!0,this}setColor(t){return this.uniforms.color.value.copy(t),this.uniformsNeedUpdate=!0,this}setOpacity(t){return this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0,this}}class At extends _t{constructor(t,i,e=0,s=0){const r=i.image.width,n=i.image.height,h=new Mt(i);super(t,e,s,r,n,new o(Bt,h)),this.Zt=h,this.Qt=i}destroy(){this.Zt.dispose(),super.destroy()}onBeforeRenderInternal(t,i){this.Zt.setQuadSize(this.width*this.micro.scaleX,this.height*this.micro.scaleY)}}class Tt extends r{constructor(i,e){super({uniforms:u.merge([{background:{value:e},foreground:{value:i},progress:{value:1},backgroundColor:{value:new t(1,1,1)},foregroundColor:{value:new t(1,1,1)},color:{value:new t(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()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.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}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.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 Pt extends _t{constructor(t,i,e={}){const r=i.image?.width,n=i.image?.height;nt(r,"UIProgress foreground texture width"),nt(n,"UIProgress foreground texture height");const h=e.textureBackground?.image?.width,a=e.textureBackground?.image?.height;e.textureBackground&&(nt(h,"UIProgress background texture width"),nt(a,"UIProgress background texture height"));const u=new Tt(i,e.textureBackground),l=new o(Bt,u);void 0!==e.progress&&u.setProgress(e.progress),void 0!==e.isForegroundDirection&&u.setIsForwardDirection(e.isForegroundDirection),void 0!==e.angle&&u.setAngle(s.degToRad(e.angle)),void 0!==e.backgroundColor&&u.setBackgroundColor(e.backgroundColor),void 0!==e.foregroundColor&&u.setForegroundColor(e.foregroundColor),void 0!==e.backgroundOpacity&&u.setBackgroundOpacity(e.backgroundOpacity),void 0!==e.foregroundOpacity&&u.setForegroundOpacity(e.foregroundOpacity),super(t,e.x??0,e.y??0,h??r,n??a,l),this.Zt=u}get progress(){return this.Zt.getProgress()}get backgroundTexture(){return this.Zt.getBackgroundTexture()}get foregroundTexture(){return this.Zt.getForegroundTexture()}get backgroundColor(){return this.Zt.getBackgroundColor()}get foregroundColor(){return this.Zt.getForegroundColor()}get backgroundOpacity(){return this.Zt.getBackgroundOpacity()}get foregroundOpacity(){return this.Zt.getForegroundOpacity()}get angle(){return s.radToDeg(this.Zt.getAngle())}get isForwardDirection(){return this.Zt.getIsForwardDirection()}set progress(t){this.Zt.setProgress(t)}set backgroundTexture(t){if(t){const i=t.image.height;nt(t.image.width,"UIElement background texture width"),nt(i,"UIElement background texture height")}this.Zt.setBackgroundTexture(t)}set foregroundTexture(t){const i=t.image.width,e=t.image.height;nt(i,"UIImage texture width"),nt(e,"UIImage texture height"),this.Zt.setForegroundTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,e)}set backgroundColor(t){this.Zt.setBackgroundColor(t)}set foregroundColor(t){this.Zt.setForegroundColor(t)}set backgroundOpacity(t){this.Zt.setBackgroundOpacity(t)}set foregroundOpacity(t){this.Zt.setForegroundOpacity(t)}set angle(t){this.Zt.setAngle(s.degToRad(t))}set isForwardDirection(t){this.Zt.setIsForwardDirection(t)}destroy(){this.Zt.dispose(),super.destroy()}}var Vt;(t=>{t[t.EACH_FRAME=1]="EACH_FRAME",t[t.EACH_SECOND_FRAME=2]="EACH_SECOND_FRAME",t[t.PROPERTY_CHANGED=3]="PROPERTY_CHANGED",t[t.MANUAL=4]="MANUAL"})(Vt||(Vt={}));const Ot=Vt.PROPERTY_CHANGED;class Rt extends _t{constructor(t,e={}){const s=e.resolutionFactor??.5;if(.1>s||s>2)throw Error(`Invalid resolution factor: ${s}. Must be between 0.1 and 2.`);const r=e.width??512,n=e.height??512,h=new l(r*s,n*s,{format:f,minFilter:d,magFilter:d,type:c,depthBuffer:e.enableDepthBuffer??!0,stencilBuffer:!1}),a=new St(h.texture);super(t,0,0,r,n,new o(Bt,a)),this.Jt=!0,this.Kt=!1,this.ti=!1,this.Zt=a,this.ii=h,this.ei=e.scene??new i,this.si=e.camera??new g(75,r/n,.1,100),this.ri=s,this.ni=e.updateMode??Ot,this.oi=e.clearColor??0,this.hi=e.clearAlpha??0,e.updateMode===Vt.PROPERTY_CHANGED&&(this.ti=!0)}get color(){return this.Zt.getColor()}get opacity(){return this.Zt.getOpacity()}get transparency(){return this.Zt.getTransparency()}get scene(){return this.ei}get camera(){return this.si}get updateMode(){return this.ni}get resolutionFactor(){return this.ri}get clearColor(){return this.oi}get clearAlpha(){return this.hi}set color(t){this.Zt.setColor(t)}set opacity(t){this.Zt.setOpacity(t)}set transparency(t){this.Zt.setTransparency(t)}set scene(t){this.ei!==t&&(this.ei=t,this.Kt=!0)}set camera(t){this.si!==t&&(this.si=t,this.Kt=!0)}set updateMode(t){this.ni!==t&&(this.ni=t,this.Kt=!0)}set resolutionFactor(t){this.ri!==t&&(this.ri=t,this.ii.setSize(this.width*this.ri,this.height*this.ri),this.Kt=!0)}set clearColor(t){this.oi!==t&&(this.oi=t,this.Kt=!0)}set clearAlpha(t){this.hi!==t&&(this.hi=t,this.Kt=!0)}destroy(){this.Zt.dispose(),this.ii.dispose(),super.destroy()}requestRender(){this.ti=!0}onBeforeRenderInternal(t){(this.ni===Vt.EACH_FRAME||this.ni===Vt.EACH_SECOND_FRAME&&this.Jt||this.ni===Vt.PROPERTY_CHANGED&&this.Kt||this.ni===Vt.MANUAL&&this.ti)&&(this.ti=!1,this.Kt=!1,this.Jt=!this.Jt,this.ii.setSize(this.width*this.ri,this.height*this.ri),t.setClearColor(this.oi,this.clearAlpha),t.setRenderTarget(this.ii),t.clear(!0,!0,!1),t.render(this.ei,this.si))}}function Ft(t){return"object"==typeof t&&null!==t&&!("string"!=typeof t.color||"string"!=typeof t.fontFamily||"number"!=typeof t.fontSize||"normal"!==t.fontStyle&&"italic"!==t.fontStyle&&"oblique"!==t.fontStyle||"normal"!==t.fontWeight&&"bold"!==t.fontWeight&&"bolder"!==t.fontWeight&&"lighter"!==t.fontWeight&&"number"!=typeof t.fontWeight||"number"!=typeof t.lineHeight||"boolean"!=typeof t.enableShadow||"number"!=typeof t.shadowOffsetX||"number"!=typeof t.shadowOffsetY||"number"!=typeof t.shadowBlur||"string"!=typeof t.shadowColor||"boolean"!=typeof t.enableStroke||"string"!=typeof t.strokeColor||"number"!=typeof t.strokeWidth)}function zt(t,i){const e=t?.fontSize??i?.fontSize??16;nt(e,"Font size");const s=t?.fontWeight??i?.fontWeight??"normal";"number"==typeof s&&nt(s,"Font weight");const r=t?.lineHeight??i?.lineHeight??1.2*e;rt(r,"Line height");const n=t?.shadowOffsetX??i?.shadowOffsetX??0;ot(n,"Shadow offset X");const o=t?.shadowOffsetY??i?.shadowOffsetY??0;ot(o,"Shadow offset Y");const h=t?.shadowBlur??i?.shadowBlur??0;ot(h,"Shadow blur");const a=t?.strokeWidth??i?.strokeWidth??0;return ot(a,"Stroke width"),{color:t?.color??i?.color??"#000000",fontFamily:t?.fontFamily??i?.fontFamily??"Arial",fontSize:e,fontStyle:t?.fontStyle??i?.fontStyle??"normal",fontWeight:s,lineHeight:r,enableShadow:t?.enableShadow??i?.enableShadow??!1,shadowOffsetX:n,shadowOffsetY:o,shadowBlur:h,shadowColor:t?.shadowColor??i?.shadowColor??"transparent",enableStroke:t?.enableStroke??i?.enableStroke??!1,strokeColor:t?.strokeColor??i?.strokeColor??"#000000",strokeWidth:a}}function Lt(t){return t.match(/\S+|\s|\n/g)??[]}function Ht(t,i,e){if(t.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize}px ${e.fontFamily}`,"\n"===i)return{width:0,height:e.lineHeight,baseline:0,lineHeight:e.lineHeight};const s=t.measureText(i);return{width:Math.ceil(s.width),height:Math.ceil(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent),baseline:s.actualBoundingBoxDescent,lineHeight:e.lineHeight}}function Dt(t,i,e,s,r){r.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,s.enableShadow&&(r.shadowOffsetX=s.shadowOffsetX,r.shadowOffsetY=s.shadowOffsetY,r.shadowBlur=s.shadowBlur,r.shadowColor=s.shadowColor),s.enableStroke&&(r.strokeStyle=s.strokeColor,r.lineWidth=s.strokeWidth,r.strokeText(e,t,i)),r.fillStyle=s.color,r.fillText(e,t,i)}function $t(t){if("number"==typeof t)return{left:t,right:t,top:t,bottom:t};if("object"==typeof t&&null!==t){const i="left"in t&&"number"==typeof t.left?t.left:0,e="right"in t&&"number"==typeof t.right?t.right:0,s="top"in t&&"number"==typeof t.top?t.top:0,r="bottom"in t&&"number"==typeof t.bottom?t.bottom:0;return ot(i,"Padding left"),ot(e,"Padding right"),ot(s,"Padding top"),ot(r,"Padding bottom"),{left:i,right:e,top:s,bottom:r}}return{left:0,right:0,top:0,bottom:0}}class Nt extends _t{constructor(t,i,e={},s=0,r=0){const n=document.createElement("canvas"),h=n.getContext("2d");if(!h)throw Error("Failed to create canvas context");const a=new p(n),u=new St(a);super(t,s,r,2,2,new o(Bt,u)),this.ai=1,this.ui=1,this.Zt=u,this.li=a,this.ci=n,this.di=h,this.fi=i,this.gi=e.maxWidth??1024,this.pi=$t(e.padding),this.wi=e.commonStyle??{},this.mi()}get color(){return this.Zt.getColor()}get opacity(){return this.Zt.getOpacity()}get transparency(){return this.Zt.getTransparency()}get content(){return this.fi}get maxWidth(){return this.gi}get padding(){return this.pi}get commonStyle(){return this.wi}set color(t){this.Zt.setColor(t)}set opacity(t){this.Zt.setOpacity(t)}set transparency(t){this.Zt.setTransparency(t)}set content(t){this.fi=t,this.mi()}set maxWidth(t){this.gi=t,this.mi()}set padding(t){this.pi=t,this.mi()}set commonStyle(t){this.wi=t,this.mi()}destroy(){this.Zt.dispose(),this.li.dispose(),this.ci.remove(),super.destroy()}onBeforeRenderInternal(t,i){this.ui!==this.width/this.height&&(this.ui=this.ai,this.height=this.width/this.ai)}mi(){const{lines:t,size:i}=((t,i,e,s)=>{const r=[];for(const e of Array.isArray(i)?i:[i]){const i="string"==typeof e,n=i?e:e.text,o=zt(i?void 0:e.style,s);for(const i of Lt(n)){const e=Ht(t,i,o);r.push({text:i,style:o,metrics:e})}}const n=((t,i)=>{const e=[];let s=[],r=0,n=0,o=0,h=0;for(const a of i)"\n"!==a.text?r+a.metrics.width>t&&0!==s.length?(e.push({chunks:s,width:r,height:n,baseline:o,lineHeight:h}),s=[a],r=a.metrics.width,n=a.metrics.height,o=a.metrics.baseline,h=a.metrics.lineHeight):(s.push(a),r+=a.metrics.width,n=Math.max(n,a.metrics.height),o=Math.max(o,a.metrics.baseline),h=Math.max(h,a.metrics.lineHeight)):(s.length>0&&e.push({chunks:s,width:r,height:n,baseline:o,lineHeight:h}),s=[],r=0,n=0,o=0,h=0);return s.length>0&&e.push({chunks:s,width:r,height:n,baseline:o,lineHeight:h}),e})(e,r),o=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let e=0;for(let i=0;t.length>i;i++){const s=t[i];e+=0===i?s.height:s.lineHeight,i===t.length-1&&(e+=s.baseline)}return{width:i,height:e}})(n);return{lines:n,size:o}})(this.di,this.content,this.gi,this.wi);this.ci.width=i.width+this.pi.left+this.pi.right,this.ci.height=i.height+this.pi.top+this.pi.bottom,this.width=this.ci.width,this.height=this.ci.height,this.ai=(i.width+this.pi.left+this.pi.right)/(i.height+this.pi.top+this.pi.bottom),((t,i,e,s)=>{let r=this.pi.top;for(let t=0;e.length>t;t++){const n=e[t];let o=i;r+=0===t?n.height:n.lineHeight;for(const t of n.chunks)Dt(o,r,t.text,t.style,s),o+=t.metrics.width}})(0,this.pi.left,t,this.di),this.li.needsUpdate=!0}}class jt extends Z{constructor(t,i){void 0!==t&&nt(t,"UIFullscreenLayer.fixedWidth"),void 0!==i&&nt(i,"UIFullscreenLayer.fixedHeight"),super(1,1),this.yi=()=>{const t=this.bi();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.xi=t=>{const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,e=i?t.clientX-i.left:t.clientX,s=i?i.bottom-t.clientY:window.innerHeight-t.clientY,r=this.bi();this.clickInternal(e*r,s*r)},this.Ei=t,this.Ci=i,window.addEventListener("resize",this.yi),window.addEventListener("pointerdown",this.xi),this.yi()}get fixedWidth(){return this.Ei}get fixedHeight(){return this.Ci}set fixedWidth(t){void 0!==t&&nt(t,"UIFullscreenLayer.fixedWidth"),t!==this.Ei&&(this.Ei=t,this.yi())}set fixedHeight(t){void 0!==t&&nt(t,"UIFullscreenLayer.fixedHeight"),t!==this.Ci&&(this.Ci=t,this.yi())}destroy(){window.removeEventListener("resize",this.yi),window.removeEventListener("pointerdown",this.xi)}render(t,i){rt(i,"UIFullscreenLayer.deltaTime"),super.renderInternal(t,i)}bi(){return this.orientation===b.HORIZONTAL?void 0!==this.fixedWidth?this.fixedWidth/window.innerWidth:void 0!==this.fixedHeight?this.fixedHeight/window.innerHeight:1:void 0!==this.fixedHeight?this.fixedHeight/window.innerHeight:void 0!==this.fixedWidth?this.fixedWidth/window.innerWidth:1}}function Wt(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text&&(!("style"in t)||Ft(t.style))}export{yt as UIAnchor,H as UIAnchorMode,ft as UIAspectConstraint,Q as UIConstraint,dt as UIConstraint2DBuilder,pt as UICoverConstraintBuilder,mt as UICustomConstraint,bt as UIDummy,_t as UIElement,Ct as UIElementEvent,v as UIExpression,wt as UIFitConstraintBuilder,jt as UIFullscreenLayer,K as UIHeightConstraint,ht as UIHorizontalDistanceConstraint,at as UIHorizontalProportionConstraint,kt as UIImage,Z as UILayer,q as UILayerEvent,Et as UIMicro,y as UIMode,At as UINineSlice,b as UIOrientation,L as UIPriority,Pt as UIProgress,W as UIRelation,Rt as UIScene,Vt as UISceneUpdateMode,J as UISingleParameterConstraint,Nt as UIText,ut as UIVerticalDistanceConstraint,lt as UIVerticalProportionConstraint,ct as UIWidthConstraint,D as convertPriority,X as convertRelation,Wt as isUITextSpan,Ft as isUITextStyle,x as resolveOrientation,$t as resolvePadding,$ as resolvePriority,Y as resolveRelation,zt as resolveTextStyle};
1
+ import{Color as t,Scene as i,OrthographicCamera as e,MathUtils as s,ShaderMaterial as r,PlaneGeometry as h,Mesh as n,Vector2 as o,Vector4 as a,UniformsUtils as u,WebGLRenderTarget as l,UnsignedByteType as c,LinearFilter as d,RGBAFormat as f,PerspectiveCamera as g,CanvasTexture as p}from"three";class v{constructor(t=0,i){this.constant=t,this.S=i?new Map(i):new Map}static plus(t,i){const e=new v(t.constant+i.constant,Array.from(t.S.entries()));for(const[t,s]of i.S)e.plus(t,s);return e}static minus(t,i){const e=new v(t.constant-i.constant,Array.from(t.S.entries()));for(const[t,s]of i.S)e.minus(t,s);return e}plus(t,i){return this.S.set(t,(this.S.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,e]of this.S)this.S.set(i,e*t);return this}divide(t){return this.multiply(1/t)}hasTerm(t){return this.S.has(t)}copy(t){this.constant=t.constant,this.S.clear();for(const[i,e]of t.S)this.S.set(i,e);return this}clone(){return new v(this.constant,Array.from(this.S.entries()))}prepareTermsInternal(){return Array.from(this.S.entries())}}class w{constructor(t,i,e=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,e):this.t.set(i,new Map([[t,e]])))}insert(t,i,e=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,e)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,e]])):s.has(t)||s.set(t,e)}remove(t,i){if(void 0===i)return void this.i.delete(t);const e=this.t.get(i);void 0!==e&&(e.delete(t),0===e.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const e=this.t.get(i);return void 0!==e&&e.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const e=this.t.get(i);return void 0!==e?e.get(t):void 0}}class m{constructor(){this.o=new Map}on(t,i,e,s=0){return this.h(t,!1,s,i,e),this}once(t,i,e,s=0){return this.h(t,!0,s,i,e),this}off(t,i,e){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=!1,s.v=s.v.slice());const r=s.v;if(0===r.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;r.length>t;t++){const i=r[t];s.l.remove(i._,i.p)}return this}{const h=r.length;if(r[0]._===i&&r[0].p===e)return 1===h?this.o.delete(t):r.shift(),this;const n=h-1;if(r[n]._===i&&r[n].p===e)return r.pop(),this;if(10>h||r[0].M===r[n].M)for(let t=1;n>t;t++){const s=r[t];if(s._===i&&s.p===e)return r.splice(t,1),this}else{const t=s.l.getPriority(i,e);if(void 0===t)return this;let h=0,n=r.length-1;for(;n>=h;){const i=h+n>>>1;t>r[i].M?h=i+1:n=i-1}const o=h;for(n=r.length-1;n>=h;){const i=h+n>>>1;r[i].M>t?n=i-1:h=i+1}const a=n;for(let t=o;a>=t;t++)if(r[t]._===i&&r[t].p===e)return r.splice(t,1),this}}return this}emit(t,...i){const e=this.o.get(t);if(void 0===e)return!1;if(0===e.v.length)return!1;e.u?e.v=e.v.slice():e.u=!0;const s=e.v;let r=!1;for(let t=0;s.length>t;t++){const e=s[t];e._.apply(e.p,i),e.k&&(r=!0,e.m=!0)}const h=this.o.get(t);if(void 0===h)return!0;h.v===s&&(h.u=!1);const n=h.v;if(r){let i=0;for(let t=0;n.length>t;t++){const e=n[t];e.m?h.l.remove(e._,e.p):n[i++]=e}0===i?this.o.delete(t):n.length=i}return!0}h(t,i,e,s,r){let h=this.o.get(t);if(void 0===h)return void this.o.set(t,{v:[{_:s,p:r,M:e,k:i,m:!1}],u:!1,l:new w(s,r,e)});if(h.l.has(s,r))throw Error("Event listener already exists");h.l.insert(s,r,e);const n={_:s,p:r,M:e,k:i,m:!1};h.u&&(h.u=!1,h.v=h.v.slice());{const t=h.v,i=n.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(n);if(t[0].M>=i)return void t.unshift(n);{let e=0,s=t.length;for(;s>e;){const r=e+s>>>1;i>t[r].M?e=r+1:s=r}t.splice(e,0,n)}}}}var y,b;function x(t){return t??b.ALWAYS}function E(){return new S}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(y||(y={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(b||(b={}));class S{index={};array=[];size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const e=this.index[t.id()];if(void 0===e){const e=new _(t,i());return this.index[t.id()]=this.array.length,this.array.push(e),e}return this.array[e]}insert(t,i){const e=new _(t,i),s=this.index[t.id()];return void 0===s?(this.index[t.id()]=this.array.length,this.array.push(e)):this.array[s]=e,e}erase(t){const i=this.index[t.id()];if(void 0===i)return;this.index[t.id()]=void 0;const e=this.array[i],s=this.array.pop();return e!==s&&(this.array[i]=s,this.index[s.first.id()]=i),e}copy(){const t=new S;for(let i=0;this.array.length>i;i++){const e=this.array[i].copy();t.array[i]=e,t.index[e.first.id()]=i}return t}}class _{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new _(this.first,this.second)}}class C{constructor(t=""){this.C=t}id(){return this.B}name(){return this.C}setName(t){this.C=t}context(){return this.I}setContext(t){this.I=t}value(){return this.T}setValue(t){this.T=t}plus(t){return new I(this,t)}minus(t){return new I(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new I([t,this])}divide(t){return new I([1/t,this])}toJSON(){return{name:this.C,value:this.T}}toString(){return this.I+"["+this.C+":"+this.T+"]"}C;T=0;I=null;B=B++}let B=0;class I{constructor(){let t=(t=>{let i=0,e=()=>0,s=E();for(let r=0,h=t.length;h>r;++r){let h=t[r];if("number"==typeof h)i+=h;else if(h instanceof C)s.setDefault(h,e).second+=1;else if(h instanceof I){i+=h.constant();let t=h.terms();for(let i=0,r=t.size();r>i;i++){let r=t.itemAt(i);s.setDefault(r.first,e).second+=r.second}}else{if(!(h instanceof Array))throw Error("invalid Expression argument: "+h);{if(2!==h.length)throw Error("array must have length 2");let t=h[0],r=h[1];if("number"!=typeof t)throw Error("array item 0 must be a number");if(r instanceof C)s.setDefault(r,e).second+=t;else{if(!(r instanceof I))throw Error("array item 1 must be a variable or expression");{i+=r.constant()*t;let h=r.terms();for(let i=0,r=h.size();r>i;i++){let r=h.itemAt(i);s.setDefault(r.first,e).second+=r.second*t}}}}}}return{terms:s,constant:i}})(arguments);this.U=t.terms,this.A=t.constant}terms(){return this.U}constant(){return this.A}value(){let t=this.A;for(let i=0,e=this.U.size();e>i;i++){let e=this.U.itemAt(i);t+=e.first.value()*e.second}return t}plus(t){return new I(this,t)}minus(t){return new I(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new I([t,this])}divide(t){return new I([1/t,this])}isConstant(){return 0==this.U.size()}toString(){let t=this.U.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.A||(t+=" + "),t+=this.A,t}U;A}class M{static create(t,i,e,s=1){let r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*s)),r+=1e3*Math.max(0,Math.min(1e3,i*s)),r+=Math.max(0,Math.min(1e3,e*s)),r}static required=M.create(1e3,1e3,1e3);static strong=M.create(1,0,0);static medium=M.create(0,1,0);static weak=M.create(0,0,1);static clip(t){return Math.max(0,Math.min(M.required,t))}}var T;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(T||(T={}));class U{constructor(t,i,e,s=M.required){this.V=i,this.P=M.clip(s),this.L=void 0===e&&t instanceof I?t:t.minus(e)}id(){return this.B}expression(){return this.L}op(){return this.V}strength(){return this.P}toString(){return this.L+" "+["<=",">=","="][this.V]+" 0 ("+this.P+")"}L;V;P;B=A++}let A=0;class k{maxIterations=1e3;constructor(){}createConstraint(t,i,e,s=M.required){let r=new U(t,i,e,s);return this.addConstraint(r),r}addConstraint(t){if(void 0!==this.R.find(t))throw Error("duplicate constraint");let i=this.O(t),e=i.row,s=i.tag,r=this.F(e,s);if(r.type()===P.Invalid&&e.allDummies()){if(!V(e.constant()))throw Error("unsatisfiable constraint");r=s.marker}if(r.type()===P.Invalid){if(!this.H(e))throw Error("unsatisfiable constraint")}else e.solveFor(r),this.D(r,e),this.N.insert(r,e);this.R.insert(t,s),this.$(this.W)}removeConstraint(t){let i=this.R.erase(t);if(void 0===i)throw Error("unknown constraint");this.j(t,i.second);let e=i.second.marker,s=this.N.erase(e);if(void 0===s){let t=this.q(e);if(t.type()===P.Invalid)throw Error("failed to find leaving row");s=this.N.erase(t),s.second.solveForEx(t,e),this.D(e,s.second)}this.$(this.W)}hasConstraint(t){return this.R.contains(t)}getConstraints(){return this.R.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.Y.find(t))throw Error("duplicate edit variable");if((i=M.clip(i))===M.required)throw Error("bad required strength");let e=new I(t),s=new U(e,T.Eq,void 0,i);this.addConstraint(s);let r=this.R.find(s).second;this.Y.insert(t,{tag:r,constraint:s,constant:0})}removeEditVariable(t){let i=this.Y.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.Y.contains(t)}suggestValue(t,i){let e=this.Y.find(t);if(void 0===e)throw Error("unknown edit variable");let s=this.N,r=e.second,h=i-r.constant;r.constant=i;let n=r.tag.marker,o=s.find(n);if(void 0!==o)return 0>o.second.add(-h)&&this.X.push(n),void this.G();let a=r.tag.other;if(o=s.find(a),void 0!==o)return 0>o.second.add(h)&&this.X.push(a),void this.G();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t),e=i.second,r=e.coefficientFor(n);0!==r&&0>e.add(h*r)&&i.first.type()!==P.External&&this.X.push(i.first)}this.G()}updateVariables(){let t=this.Z,i=this.N;for(let e=0,s=t.size();s>e;++e){let s=t.itemAt(e),r=i.find(s.second);s.first.setValue(void 0!==r?r.second.constant():0)}}J(t){return this.Z.setDefault(t,()=>this.K(P.External)).second}O(t){let i=t.expression(),e=new R(i.constant()),s=i.terms();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t);if(!V(i.second)){let t=this.J(i.first),s=this.N.find(t);void 0!==s?e.insertRow(s.second,i.second):e.insertSymbol(t,i.second)}}let r=this.W,h=t.strength(),n={marker:L,other:L};switch(t.op()){case T.Le:case T.Ge:{let i=t.op()===T.Le?1:-1,s=this.K(P.Slack);if(n.marker=s,e.insertSymbol(s,i),M.required>h){let t=this.K(P.Error);n.other=t,e.insertSymbol(t,-i),r.insertSymbol(t,h)}break}case T.Eq:if(M.required>h){let t=this.K(P.Error),i=this.K(P.Error);n.marker=t,n.other=i,e.insertSymbol(t,-1),e.insertSymbol(i,1),r.insertSymbol(t,h),r.insertSymbol(i,h)}else{let t=this.K(P.Dummy);n.marker=t,e.insertSymbol(t)}}return 0>e.constant()&&e.reverseSign(),{row:e,tag:n}}F(t,i){let e=t.cells();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(i.first.type()===P.External)return i.first}let s=i.marker.type();return s!==P.Slack&&s!==P.Error||t.coefficientFor(i.marker)>=0?(s=i.other.type(),s!==P.Slack&&s!==P.Error||t.coefficientFor(i.other)>=0?L:i.other):i.marker}H(t){let i=this.K(P.Slack);this.N.insert(i,t.copy()),this.tt=t.copy(),this.$(this.tt);let e=V(this.tt.constant());this.tt=null;let s=this.N.erase(i);if(void 0!==s){let t=s.second;if(t.isConstant())return e;let r=this.it(t);if(r.type()===P.Invalid)return!1;t.solveForEx(i,r),this.D(r,t),this.N.insert(r,t)}let r=this.N;for(let t=0,e=r.size();e>t;++t)r.itemAt(t).second.removeSymbol(i);return this.W.removeSymbol(i),e}D(t,i){let e=this.N;for(let s=0,r=e.size();r>s;++s){let r=e.itemAt(s);r.second.substitute(t,i),0>r.second.constant()&&r.first.type()!==P.External&&this.X.push(r.first)}this.W.substitute(t,i),this.tt&&this.tt.substitute(t,i)}$(t){let i=0;for(;this.maxIterations>i;){let e=this.et(t);if(e.type()===P.Invalid)return;let s=this.st(e);if(s.type()===P.Invalid)throw Error("the objective is unbounded");let r=this.N.erase(s).second;r.solveForEx(s,e),this.D(e,r),this.N.insert(e,r),i++}throw Error("solver iterations exceeded")}G(){let t=this.N,i=this.X;for(;0!==i.length;){let e=i.pop(),s=t.find(e);if(void 0!==s&&0>s.second.constant()){let i=this.rt(s.second);if(i.type()===P.Invalid)throw Error("dual optimize failed");let r=s.second;t.erase(e),r.solveForEx(e,i),this.D(i,r),t.insert(i,r)}}}et(t){let i=t.cells();for(let t=0,e=i.size();e>t;++t){let e=i.itemAt(t),s=e.first;if(0>e.second&&s.type()!==P.Dummy)return s}return L}rt(t){let i=Number.MAX_VALUE,e=L,s=t.cells();for(let t=0,r=s.size();r>t;++t){let r=s.itemAt(t),h=r.first,n=r.second;if(n>0&&h.type()!==P.Dummy){let t=this.W.coefficientFor(h)/n;i>t&&(i=t,e=h)}}return e}st(t){let i=Number.MAX_VALUE,e=L,s=this.N;for(let r=0,h=s.size();h>r;++r){let h=s.itemAt(r),n=h.first;if(n.type()!==P.External){let s=h.second,r=s.coefficientFor(t);if(0>r){let t=-s.constant()/r;i>t&&(i=t,e=n)}}}return e}q(t){let i=Number.MAX_VALUE,e=i,s=i,r=L,h=r,n=r,o=r,a=this.N;for(let i=0,r=a.size();r>i;++i){let r=a.itemAt(i),u=r.second,l=u.coefficientFor(t);if(0===l)continue;let c=r.first;if(c.type()===P.External)o=c;else if(0>l){let t=-u.constant()/l;e>t&&(e=t,h=c)}else{let t=u.constant()/l;s>t&&(s=t,n=c)}}return h!==r?h:n!==r?n:o}j(t,i){i.marker.type()===P.Error&&this.ht(i.marker,t.strength()),i.other.type()===P.Error&&this.ht(i.other,t.strength())}ht(t,i){let e=this.N.find(t);void 0!==e?this.W.insertRow(e.second,-i):this.W.insertSymbol(t,-i)}it(t){let i=t.cells();for(let t=0,e=i.size();e>t;++t){let e=i.itemAt(t),s=e.first.type();if(s===P.Slack||s===P.Error)return e.first}return L}K(t){return new z(t,this.nt++)}R=(()=>E())();N=(()=>E())();Z=(()=>E())();Y=(()=>E())();X=[];W=new R;tt=null;nt=0}function V(t){return 0>t?1e-8>-t:1e-8>t}var P;(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"})(P||(P={}));class z{constructor(t,i){this.B=i,this.ot=t}id(){return this.B}type(){return this.ot}B;ot}let L=new z(P.Invalid,-1);class R{constructor(t=0){this.A=t}cells(){return this.ut}constant(){return this.A}isConstant(){return this.ut.empty()}allDummies(){let t=this.ut;for(let i=0,e=t.size();e>i;++i)if(t.itemAt(i).first.type()!==P.Dummy)return!1;return!0}copy(){let t=new R(this.A);return t.ut=this.ut.copy(),t}add(t){return this.A+=t}insertSymbol(t,i=1){V(this.ut.setDefault(t,()=>0).second+=i)&&this.ut.erase(t)}insertRow(t,i=1){this.A+=t.A*i;let e=t.ut;for(let t=0,s=e.size();s>t;++t){let s=e.itemAt(t);this.insertSymbol(s.first,s.second*i)}}removeSymbol(t){this.ut.erase(t)}reverseSign(){this.A=-this.A;let t=this.ut;for(let i=0,e=t.size();e>i;++i){let e=t.itemAt(i);e.second=-e.second}}solveFor(t){let i=this.ut,e=-1/i.erase(t).second;this.A*=e;for(let t=0,s=i.size();s>t;++t)i.itemAt(t).second*=e}solveForEx(t,i){this.insertSymbol(t,-1),this.solveFor(i)}coefficientFor(t){let i=this.ut.find(t);return void 0!==i?i.second:0}substitute(t,i){let e=this.ut.erase(t);void 0!==e&&this.insertRow(i,e.second)}ut=E();A}const O=1e3;var F,H;function D(t){switch(t){case F.P0:return M.create(O,O,O);case F.P1:return M.create(100,0,0);case F.P2:return M.create(10,0,0);case F.P3:return M.create(0,100,0);case F.P4:return M.create(0,10,0);case F.P5:return M.create(0,0,100);case F.P6:return M.create(0,0,10);case F.P7:return M.create(0,0,1);default:throw Error("Invalid priority: "+t)}}function N(t){return t??F.P0}(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"})(F||(F={})),(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(H||(H={}));let $=new t,W=0,j=!1,q=!1,Y=!1,X=!1;class G{constructor(t,s){this.lt=new i,this.ct=new Map,this.dt=new e(0,t,s,0,-1,1)}insertObject(t,i){if(this.ct.has(t))throw Error("Element already exists");this.ct.set(t,i),this.lt.add(i)}replaceObject(t,i){const e=this.ct.get(t);if(void 0===e)throw Error("Element not found");this.lt.remove(e),this.lt.add(i),this.ct.set(t,i)}removeObject(t){const i=this.ct.get(t);if(void 0===i)throw Error("Element not found");this.lt.remove(i),this.ct.delete(t)}resize(t,i){this.dt.right=t,this.dt.top=i,this.dt.updateProjectionMatrix()}getVisibility(t){const i=this.ct.get(t);if(void 0===i)throw Error("Element not found");return i.visible}getZIndex(t){const i=this.ct.get(t);if(void 0===i)throw Error("Element not found");return i.renderOrder}setZIndex(t,i){const e=this.ct.get(t);if(void 0===e)throw Error("Element not found");e.renderOrder=i}setVisibility(t,i){const e=this.ct.get(t);if(void 0===e)throw Error("Element not found");e.visible=i}getSortedVisibleElements(){return Array.from(this.ct.keys()).sort((t,i)=>this.getZIndex(t)-this.getZIndex(i))}prepareRender(t){$=t.getClearColor($),W=t.getClearAlpha(),j=t.autoClear,q=t.autoClearColor,Y=t.autoClearDepth,X=t.autoClearStencil,t.autoClear=!1,t.autoClearColor=!1,t.autoClearDepth=!1,t.autoClearStencil=!1,t.setClearColor(0,1);for(const[t,i]of this.ct){const e=t.micro,s=t.width*e.scaleX,r=t.height*e.scaleY,h=e.anchorX*s,n=e.anchorY*r,o=Math.cos(e.rotation),a=Math.sin(e.rotation),u=h*o-n*a,l=h*a+n*o;if(e.anchorMode===H.POSITION_ROTATION_SCALE)i.position.x=t.x+e.x-u,i.position.y=t.y+e.y-l;else{const s=e.anchorY*t.height;i.position.x=t.x+e.anchorX*t.width-u+e.x,i.position.y=t.y+s-l+e.y}i.scale.x=s,i.scale.y=r,i.rotation.z=e.rotation}}render(t){t.clear(!1,!0,!0),t.render(this.lt,this.dt),t.setClearColor($),t.setClearAlpha(W),t.autoClear=j,t.autoClearColor=q,t.autoClearDepth=Y,t.autoClearStencil=X}}var Q,Z;function J(t){switch(t){case Q.EQUAL:return T.Eq;case Q.LESS_THAN:return T.Le;case Q.GREATER_THAN:return T.Ge;default:throw Error("Invalid relation: "+t)}}function K(t){return t??Q.EQUAL}(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(Q||(Q={}));class tt{constructor(){this.ft=new k,this.gt=!1,this.vt=new Map,this.wt=0,this.yt=new Map,this.bt=0}createVariable(t,i){const e=this.wt++,s=new C;if(i===F.P0){const r={variable:s,priority:i,value:t};this.vt.set(e,r),r.constraint=this.xt(new v(0,[[e,1]]),new v(t),Q.EQUAL,i);try{this.ft?.addConstraint(r.constraint)}catch{this.ft=void 0}}else{this.vt.set(e,{variable:s,priority:i,value:t});try{this.ft?.addEditVariable(s,D(i)),this.ft?.suggestValue(s,t)}catch{this.ft=void 0}}return this.gt=!0,e}removeVariable(t){const i=this.vt.get(t);if(void 0===i)throw Error(`Variable ${t} does not exist`);for(const i of this.yt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error(`Variable ${t} is used in constraint`);try{i.constraint?this.ft?.removeConstraint(i.constraint):this.ft?.removeEditVariable(i.variable)}catch{this.ft=void 0}this.vt.delete(t),this.gt=!0}suggestVariableValue(t,i){const e=this.vt.get(t);if(void 0===e)throw Error(`Variable ${t} does not exist`);e.value!==i&&(e.value=i,e.constraint?e.constraint=this.Et(e.constraint,(new v).plus(t,1),new v(e.value),Q.EQUAL,e.priority):this.ft?.suggestValue(e.variable,i),this.gt=!0)}setVariablePriority(t,i){const e=this.vt.get(t);if(void 0===e)throw Error(`Variable ${t} does not exist`);if(i!==e.priority){if(e.priority=i,e.priority===F.P0){const i=(new v).plus(t,1),s=new v(e.value);e.constraint=this.xt(i,s,Q.EQUAL,e.priority);try{this.ft?.addConstraint(e.constraint)}catch{this.ft=void 0}}else{if(e.constraint)try{this.ft?.removeConstraint(e.constraint)}catch{this.ft=void 0}e.constraint=void 0,this.St(t,e)}this.gt=!0}}readVariableValue(t){const i=this.vt.get(t);if(void 0===i)throw Error(`Variable ${t} does not exist`);return void 0===this.ft&&this._t(),this.gt&&(this.ft?.updateVariables(),this.gt=!1),i.variable.value()}createConstraint(t,i,e,s,r){const h=this.bt++,n=this.xt(t,i,e,s);if(this.yt.set(h,{constraint:n,lhs:t.clone(),rhs:i.clone(),priority:s,relation:e,enabled:r}),r){try{this.ft?.addConstraint(n)}catch{this.ft=void 0}this.gt=!0}return h}removeConstraint(t){const i=this.yt.get(t);if(void 0===i)throw Error(`Constraint ${t} does not exist`);if(i.enabled)try{this.ft?.removeConstraint(i.constraint)}catch{this.ft=void 0}this.yt.delete(t),this.gt=!0}setConstraintLHS(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.lhs.copy(i),this.Ct(e),this.gt=!0}setConstraintRHS(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.rhs.copy(i),this.Ct(e),this.gt=!0}setConstraintRelation(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.relation=i,this.Ct(e),this.gt=!0}setConstraintPriority(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);e.priority=i,this.Ct(e),this.gt=!0}setConstraintEnabled(t,i){const e=this.yt.get(t);if(void 0===e)throw Error(`Constraint ${t} does not exist`);if(i!==e.enabled){e.enabled=i;try{e.enabled?this.ft?.addConstraint(e.constraint):this.ft?.removeConstraint(e.constraint)}catch{this.ft=void 0}this.gt=!0}}St(t,i){const e=[];for(const i of this.yt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{this.ft?.removeConstraint(i.constraint)}catch{this.ft=void 0}e.push(i)}this.ft?.removeEditVariable(i.variable),this.ft?.addEditVariable(i.variable,D(i.priority));for(const t of e)t.constraint=this.xt(t.lhs,t.rhs,t.relation,t.priority);for(const t of e)try{this.ft?.addConstraint(t.constraint)}catch{this.ft=void 0;break}}Ct(t){t.constraint=t.enabled?this.Et(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.xt(t.lhs,t.rhs,t.relation,t.priority)}Et(t,i,e,s,r){try{this.ft?.removeConstraint(t)}catch{this.ft=void 0}const h=this.xt(i,e,s,r);try{this.ft?.addConstraint(h)}catch{this.ft=void 0}return h}xt(t,i,e,s){return new U(this.Bt(t),J(e),this.Bt(i),D(s))}Bt(t){return new I(...t.prepareTermsInternal().map(([t,i])=>{const e=this.vt.get(t);if(void 0===e)throw Error(`Variable ${t} does not exist`);return[i,e.variable]}),t.constant)}_t(){if(this.ft)throw Error("Solver already exists");this.ft=new k;for(const t of this.vt.values())t.constraint?this.ft.addConstraint(t.constraint):(this.ft.addEditVariable(t.variable,D(t.priority)),this.ft.suggestValue(t.variable,t.value));for(const t of this.yt.values())t.enabled&&this.ft.addConstraint(t.constraint);this.gt=!0}}(t=>{t.ORIENTATION_CHANGE="orientation_change",t.MODE_CHANGE="mode_change",t.WILL_RENDER="will_render"})(Z||(Z={}));class it extends m{constructor(t,i){super(),this.name="",this.solverWrapper=new tt,this.modeInternal=y.VISIBLE,this.sceneWrapper=new G(t,i),this.xVariable=this.solverWrapper.createVariable(0,F.P0),this.yVariable=this.solverWrapper.createVariable(0,F.P0),this.wVariable=this.solverWrapper.createVariable(t,F.P0),this.hVariable=this.solverWrapper.createVariable(i,F.P0),this.orientationInternal=t>i?b.HORIZONTAL:b.VERTICAL}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get mode(){return this.modeInternal}get orientation(){return this.orientationInternal}set mode(t){t!==this.modeInternal&&(this.modeInternal=t,this.emit(Z.MODE_CHANGE,this.modeInternal,this))}resizeInternal(t,i){this.solverWrapper.suggestVariableValue(this.wVariable,t),this.solverWrapper.suggestVariableValue(this.hVariable,i),this.sceneWrapper.resize(t,i);const e=t>i?b.HORIZONTAL:b.VERTICAL;e!==this.orientationInternal&&(this.orientationInternal=e,this.emit(Z.ORIENTATION_CHANGE,this.orientationInternal,this))}renderInternal(t,i){this.mode!==y.HIDDEN&&(this.sceneWrapper.prepareRender(t),this.emit(Z.WILL_RENDER,t,i,this),this.sceneWrapper.render(t))}clickInternal(t,i){if(this.mode===y.INTERACTIVE)for(const e of this.sceneWrapper.getSortedVisibleElements())if(e.onClickInternal(t,i))return}getSolverWrapperInternal(){return this.solverWrapper}getSceneWrapperInternal(){return this.sceneWrapper}}class et{constructor(t){this.layer=t,this.name="",this.solverWrapper=this.layer.getSolverWrapperInternal()}}class st extends et{constructor(t,i,e,s){super(t),this.It=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.priorityInternal=N(i),this.relationInternal=K(e),this.orientationInternal=x(s),this.layer.on(Z.ORIENTATION_CHANGE,this.It)}get priority(){return this.priorityInternal}get relation(){return this.relationInternal}get orientation(){return this.orientationInternal}set priority(t){t!==this.priorityInternal&&(this.priorityInternal=t,this.solverWrapper.setConstraintPriority(this.constraint,this.priorityInternal))}set relation(t){t!==this.relationInternal&&(this.relationInternal=t,this.solverWrapper.setConstraintRelation(this.constraint,this.relationInternal))}set orientation(t){t!==this.orientationInternal&&(this.orientationInternal=t,this.It())}destroy(){this.layer.off(Z.ORIENTATION_CHANGE,this.It),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.orientationInternal===b.ALWAYS||this.orientationInternal===this.layer.orientation}}class rt extends st{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.Mt=t,this.Tt=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new v(0,[[this.Mt.hVariable,1]]),new v(this.Tt),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Tt}set height(t){this.Tt!==t&&(this.Tt=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(t)))}}function ht(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof it}function nt(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function ot(t){return"object"==typeof t&&null!==t&&"wVariable"in t&&"number"==typeof t.wVariable&&"hVariable"in t&&"number"==typeof t.hVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function at(t,i,e){if(t instanceof it&&i instanceof it)throw Error(e+": layer cannot be snapped to another layer");let s,r;if(!(t instanceof it||ht(t)))throw Error(e+": A must be a UILayer or a UIPointElement");if(s=t instanceof it?t:t.layer,!(i instanceof it||ht(i)))throw Error(e+": B must be a UILayer or a UIPointElement");if(r=i instanceof it?i:i.layer,s!==r)throw Error(e+": elements must be on the same layer");return s}function ut(t,i){if(!Number.isFinite(t))throw Error(i+": value must be a finite number");if(Math.abs(t)>Number.MAX_SAFE_INTEGER)throw Error(i+": value exceeds maximum safe integer range")}function lt(t,i){if(ut(t,i),1e-6>t)throw Error(i+": value must be greater than or equal to 0.000001")}function ct(t,i){if(ut(t,i),0>t)throw Error(i+": value must be greater than or equal to 0")}class dt extends st{constructor(t,i,e={}){super(at(t,i,"UIHorizontalDistanceConstraint"),e.priority,e.relation,e.orientation),this.Ut=t,this.At=i,this.kt=e.anchorA??.5,this.Vt=e.anchorB??.5,this.Pt=e.distance??0,this.constraint=this.solverWrapper.createConstraint(this.zt(),new v(this.Pt),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get distance(){return this.Pt}get anchorA(){return this.kt}get anchorB(){return this.Vt}set distance(t){this.Pt!==t&&(this.Pt=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(this.Pt)))}set anchorA(t){this.kt!==t&&(this.kt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.zt()))}set anchorB(t){this.Vt!==t&&(this.Vt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.zt()))}zt(){let t,i;if(ot(this.Ut))t=new v(0,[[this.Ut.xVariable,1],[this.Ut.wVariable,this.kt]]);else{if(!nt(this.Ut))throw Error("A is not a valid element type");t=(new v).plus(this.Ut.xVariable,1)}if(ot(this.At))i=new v(0,[[this.At.xVariable,1],[this.At.wVariable,this.Vt]]);else{if(!nt(this.At))throw Error("B is not a valid element type");i=(new v).plus(this.At.xVariable,1)}return v.minus(i,t)}}class ft extends st{constructor(t,i,e={}){super(at(t,i,"UIHorizontalProportionConstraint"),e.priority,e.relation,e.orientation),this.Ut=t,this.At=i,this.Lt=e.proportion??1,this.constraint=this.solverWrapper.createConstraint(new v(0),this.Rt(),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get proportion(){return this.Lt}set proportion(t){this.Lt!==t&&(this.Lt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Rt()))}Rt(){return v.minus(new v(0,[[this.Ut.wVariable,this.Lt]]),new v(0,[[this.At.wVariable,1]]))}}class gt extends st{constructor(t,i,e={}){super(at(t,i,"UIVerticalDistanceConstraint"),e.priority,e.relation,e.orientation),this.Ut=t,this.At=i,this.kt=e.anchorA??.5,this.Vt=e.anchorB??.5,this.Pt=e.distance??0,this.constraint=this.solverWrapper.createConstraint(this.zt(),new v(this.Pt),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get distance(){return this.Pt}get anchorA(){return this.kt}get anchorB(){return this.Vt}set distance(t){this.Pt!==t&&(this.Pt=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(this.Pt)))}set anchorA(t){this.kt!==t&&(this.kt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.zt()))}set anchorB(t){this.Vt!==t&&(this.Vt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.zt()))}zt(){let t,i;if(ot(this.Ut))t=new v(0,[[this.Ut.yVariable,1],[this.Ut.hVariable,this.kt]]);else{if(!nt(this.Ut))throw Error("A is not a valid element type");t=(new v).plus(this.Ut.yVariable,1)}if(ot(this.At))i=new v(0,[[this.At.yVariable,1],[this.At.hVariable,this.Vt]]);else{if(!nt(this.At))throw Error("B is not a valid element type");i=(new v).plus(this.At.yVariable,1)}return v.minus(i,t)}}class pt extends st{constructor(t,i,e={}){super(at(t,i,"UIVerticalProportionConstraint"),e.priority,e.relation,e.orientation),this.Ut=t,this.At=i,this.Lt=e.proportion??1,this.constraint=this.solverWrapper.createConstraint(new v(0),this.Rt(),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get proportion(){return this.Lt}set proportion(t){this.Lt!==t&&(this.Lt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Rt()))}Rt(){return v.minus(new v(0,[[this.Ut.hVariable,this.Lt]]),new v(0,[[this.At.hVariable,1]]))}}class vt extends st{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.Mt=t,this.Ot=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new v(0,[[this.Mt.wVariable,1]]),new v(this.Ot),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.Ot}set width(t){this.Ot!==t&&(this.Ot=t,this.solverWrapper.setConstraintRHS(this.constraint,new v(t)))}}class wt{static size(t,i={}){return{h:new vt(t,{width:i.size?.h,priority:i.priority?.h,relation:i.relation?.h,orientation:i.orientation?.h}),v:new rt(t,{height:i.size?.v,priority:i.priority?.v,relation:i.relation?.v,orientation:i.orientation?.v})}}static distance(t,i,e={}){return{h:new dt(t,i,{anchorA:e.anchorA?.h,anchorB:e.anchorB?.h,distance:e.distance?.h,priority:e.priority?.h,relation:e.relation?.h,orientation:e.orientation?.h}),v:new gt(t,i,{anchorA:e.anchorA?.v,anchorB:e.anchorB?.v,distance:e.distance?.v,priority:e.priority?.v,relation:e.relation?.v,orientation:e.orientation?.v})}}static proportion(t,i,e={}){return{h:new ft(t,i,{proportion:e.proportion?.h,priority:e.priority?.h,relation:e.relation?.h,orientation:e.orientation?.h}),v:new pt(t,i,{proportion:e.proportion?.v,priority:e.priority?.v,relation:e.relation?.v,orientation:e.orientation?.v})}}}class mt extends st{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.Mt=t,this.Ft=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.zt(),new v(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.Ft}set aspect(t){this.Ft!==t&&(this.Ft=t,this.solverWrapper.setConstraintLHS(this.constraint,this.zt()))}zt(){return new v(0,[[this.Mt.wVariable,1],[this.Mt.hVariable,-this.Ft]])}}const yt=.5;class bt{static build(t,i,e={}){let s;return!0===e.keepActiveAspect&&(s=new mt(i,{orientation:e.orientation})),{activeAspectConstraint:s,xConstraint:new dt(t,i,{anchorA:e.anchorH??yt,anchorB:e.anchorH??yt,orientation:e.orientation}),yConstraint:new gt(t,i,{anchorA:e.anchorV??yt,anchorB:e.anchorV??yt,orientation:e.orientation}),widthConstraint:new ft(t,i,{proportion:1,relation:Q.GREATER_THAN,orientation:e.orientation}),heightConstraint:new pt(t,i,{proportion:1,priority:F.P1,orientation:e.orientation})}}}const xt=.5;class Et{static build(t,i,e={}){let s;return!0===e.keepActiveAspect&&(s=new mt(i,{orientation:e.orientation})),{activeAspectConstraint:s,xConstraint:new dt(t,i,{anchorA:e.anchorH??xt,anchorB:e.anchorH??xt,orientation:e.orientation}),yConstraint:new gt(t,i,{anchorA:e.anchorV??xt,anchorB:e.anchorV??xt,orientation:e.orientation}),widthConstraint:new ft(t,i,{proportion:1,relation:Q.LESS_THAN,orientation:e.orientation}),heightConstraint:new pt(t,i,{proportion:1,priority:F.P1,orientation:e.orientation})}}}class St extends st{constructor(t,i,e,s={}){super(t,s.priority,s.relation,s.orientation),this.Ht=i,this.Dt=e,this.constraint=this.solverWrapper.createConstraint(this.Ht,this.Dt,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.Ht}get rhs(){return this.Dt}setLHS(t){this.Ht=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ht)}setRHS(t){this.Dt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Dt)}}class _t extends m{constructor(t,i,e){ut(i,"UIAnchor x"),ut(e,"UIAnchor y"),super(),this.layer=t,this.name="",this.solverWrapper=this.layer.getSolverWrapperInternal(),this.xVariable=this.solverWrapper.createVariable(i,F.P7),this.yVariable=this.solverWrapper.createVariable(e,F.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){ut(t,"UIAnchor x"),this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){ut(t,"UIAnchor y"),this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}class Ct extends _t{constructor(t,i,e,s=100,r=100){lt(s,"UIDummy width"),lt(r,"UIDummy height"),super(t,i,e),this.wVariable=this.solverWrapper.createVariable(s,F.P6),this.hVariable=this.solverWrapper.createVariable(r,F.P6)}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}set width(t){lt(t,"UIDummy width"),this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){lt(t,"UIDummy height"),this.solverWrapper.suggestVariableValue(this.hVariable,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),super.destroy()}}const Bt=.5;class It{constructor(){this.Nt=0,this.$t=0,this.Wt=Bt,this.jt=Bt,this.qt=1,this.Yt=1,this.Xt=0,this.Gt=H.ROTATION_SCALE,this.gt=!1}get x(){return this.Nt}get y(){return this.$t}get anchorX(){return this.Wt}get anchorY(){return this.jt}get scaleX(){return this.qt}get scaleY(){return this.Yt}get size(){return Math.max(this.qt,this.Yt)}get angle(){return s.radToDeg(this.Xt)}get anchorMode(){return this.Gt}get rotation(){return this.Xt}set x(t){t!==this.Nt&&(this.Nt=t,this.gt=!0)}set y(t){t!==this.$t&&(this.$t=t,this.gt=!0)}set anchorX(t){t!==this.Wt&&(this.Wt=t,this.gt=!0)}set anchorY(t){t!==this.jt&&(this.jt=t,this.gt=!0)}set scaleX(t){t!==this.qt&&(this.qt=t,this.gt=!0)}set scaleY(t){t!==this.Yt&&(this.Yt=t,this.gt=!0)}set size(t){t===this.qt&&t===this.Yt||(this.qt=t,this.Yt=t,this.gt=!0)}set angle(t){const i=s.degToRad(t);i!==this.Xt&&(this.Xt=i,this.gt=!0)}set rotation(t){t!==this.Xt&&(this.Xt=t,this.gt=!0)}set anchorMode(t){t!==this.Gt&&(this.Gt=t,this.gt=!0)}reset(){0===this.Nt&&0===this.$t&&this.Wt===Bt&&this.jt===Bt&&1===this.qt&&1===this.Yt&&0===this.Xt||(this.Nt=0,this.$t=0,this.Wt=Bt,this.jt=Bt,this.qt=1,this.Yt=1,this.Xt=0,this.gt=!0)}getRecalculationRequiredInternal(){return this.gt}resetRecalculationRequiredInternal(){this.gt=!1}}var Mt;(t=>{t.CLICK="click"})(Mt||(Mt={}));class Tt extends _t{constructor(t,i,e,s,r,h){lt(s,"UIElement width"),lt(r,"UIElement height"),super(t,i,e),this.object=h,this.micro=new It,this.modeInternal=y.VISIBLE,this.sceneWrapper=this.layer.getSceneWrapperInternal(),this.sceneWrapper.insertObject(this,this.object),this.wVariable=this.solverWrapper.createVariable(s,F.P6),this.hVariable=this.solverWrapper.createVariable(r,F.P6)}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get zIndex(){return this.sceneWrapper.getZIndex(this)}get mode(){return this.modeInternal}set width(t){lt(t,"UIElement width"),this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){lt(t,"UIElement height"),this.solverWrapper.suggestVariableValue(this.hVariable,t)}set zIndex(t){ut(t,"UIElement zIndex"),this.sceneWrapper.setZIndex(this,t)}set mode(t){t!==this.modeInternal&&(this.modeInternal=t,this.sceneWrapper.setVisibility(this,t!==y.HIDDEN))}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.sceneWrapper.removeObject(this),super.destroy()}onClickInternal(t,i){const e=this.modeInternal===y.INTERACTIVE&&t>this.x&&this.x+this.width>t&&i>this.y&&this.y+this.height>i;return e&&this.emit(Mt.CLICK,t,i,this),e}}const Ut=.25;class At extends r{constructor(i){super({uniforms:{map:{value:i},opacity:{value:1},color:{value:new t(1,1,1)},alphaTest:{value:Ut}},vertexShader:"varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"uniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nuniform float alphaTest;\nvarying vec2 vUv;\n\nvoid main() {\n vec4 diffuseColor = texture2D(map, vUv);\n #include <alphatest_fragment>\n gl_FragColor = vec4(diffuseColor.rgb * color, diffuseColor.a * opacity);\n #include <colorspace_fragment>\n}\n",transparent:!1,alphaTest:Ut,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}getTransparency(){return this.transparent}setTexture(t){return this.uniforms.map.value=t,this.uniformsNeedUpdate=!0,this}setColor(t){return this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0,this}setOpacity(t){return this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0,this}setTransparency(t){return this.transparent!==t&&(this.transparent=t,this.uniforms.alphaTest.value=t?0:Ut,this.needsUpdate=!0,this.uniformsNeedUpdate=!0),this}}const kt=new h(1,1).translate(.5,.5,0);class Vt extends Tt{constructor(t,i,e=0,s=0){const r=i.image.width,h=i.image.height,o=new At(i);super(t,e,s,r,h,new n(kt,o)),this.Qt=o,this.Zt=i}get texture(){return this.Zt}get color(){return this.Qt.getColor()}get opacity(){return this.Qt.getOpacity()}get transparency(){return this.Qt.getTransparency()}set texture(t){const i=t.image.width,e=t.image.height;lt(i,"UIImage texture width"),lt(e,"UIImage texture height"),this.Qt.setTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,e)}set color(t){this.Qt.setColor(t)}set opacity(t){this.Qt.setOpacity(t)}set transparency(t){this.Qt.setTransparency(t)}destroy(){this.Qt.dispose(),super.destroy()}}var Pt="uniform sampler2D map;\nuniform vec3 color;\nuniform float opacity;\nuniform float alphaTest;\nuniform vec4 sliceBorders;\nuniform vec2 quadSize;\nuniform vec2 textureSize;\nvarying vec2 vUv;\n\nvec2 calculateNineSliceUV(vec2 uv) {\n vec2 localUV = uv;\n\n float left = sliceBorders.x;\n float right = sliceBorders.y;\n float top = sliceBorders.z;\n float bottom = sliceBorders.w;\n\n float leftPx = left * textureSize.x;\n float rightPx = right * textureSize.x;\n float topPx = top * textureSize.y;\n float bottomPx = bottom * textureSize.y;\n\n float lB = leftPx / quadSize.x;\n float rB = 1.0 - (rightPx / quadSize.x);\n float tB = topPx / quadSize.y;\n float bB = 1.0 - (bottomPx / quadSize.y);\n\n {\n float regionL = step(uv.x, lB);\n float regionR = step(rB, uv.x);\n float regionM = 1.0 - regionL - regionR;\n\n float xL = uv.x * (left / lB);\n float xR = 1.0 - right + ((uv.x - rB) / (1.0 - rB)) * right;\n float xM = left + ((uv.x - lB) / (rB - lB)) * (1.0 - left - right);\n\n localUV.x = regionL * xL + regionM * xM + regionR * xR;\n }\n\n {\n float regionT = step(uv.y, tB);\n float regionB = step(bB, uv.y);\n float regionC = 1.0 - regionT - regionB;\n\n float yT = uv.y * (top / tB);\n float yB = 1.0 - bottom + ((uv.y - bB) / (1.0 - bB)) * bottom;\n float yC = top + ((uv.y - tB) / (bB - tB)) * (1.0 - top - bottom);\n\n localUV.y = regionT * yT + regionC * yC + regionB * yB;\n }\n\n return localUV;\n}\n\nvoid main() {\n vec4 textureColor = texture2D(map, calculateNineSliceUV(vUv));\n if (textureColor.a < alphaTest) {\n discard;\n }\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n}\n",zt="varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";const Lt=.025;class Rt extends r{constructor(i){super({uniforms:{map:{value:i},color:{value:new t(16777215)},opacity:{value:1},alphaTest:{value:Lt},sliceBorders:{value:new a(0,0,0,0)},quadSize:{value:new o(1,1)},textureSize:{value:new o(i.image.width,i.image.height)}},vertexShader:zt,fragmentShader:Pt,transparent:!1,alphaTest:Lt,lights:!1,fog:!1,depthWrite:!0,depthTest:!0})}getSliceBorderLeft(){return this.uniforms.sliceBorders.value.x}getSliceBorderRight(){return this.uniforms.sliceBorders.value.y}getSliceBorderTop(){return this.uniforms.sliceBorders.value.z}getSliceBorderBottom(){return this.uniforms.sliceBorders.value.w}getQuadSize(){const t=this.uniforms.quadSize.value;return{w:t.x,h:t.y}}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}getTransparency(){return this.transparent}setSliceBorderLeft(t){return this.uniforms.sliceBorders.value.x=t,this.uniformsNeedUpdate=!0,this}setSliceBorderRight(t){return this.uniforms.sliceBorders.value.y=t,this.uniformsNeedUpdate=!0,this}setSliceBorderTop(t){return this.uniforms.sliceBorders.value.z=t,this.uniformsNeedUpdate=!0,this}setSliceBorderBottom(t){return this.uniforms.sliceBorders.value.w=t,this.uniformsNeedUpdate=!0,this}setSliceBorder(t,i,e,s){return this.uniforms.sliceBorders.value.set(t,i,e,s),this.uniformsNeedUpdate=!0,this}setQuadSize(t,i){return this.uniforms.quadSize.value.set(t,i),this.uniformsNeedUpdate=!0,this}setTexture(t){return this.uniforms.map.value=t,this.uniformsNeedUpdate=!0,this}setColor(t){return this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0,this}setOpacity(t){return this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0,this}setTransparency(t){return this.transparent!==t&&(this.transparent=t,this.uniforms.alphaTest.value=t?0:Lt,this.needsUpdate=!0,this.uniformsNeedUpdate=!0),this}}const Ot=.25;class Ft extends Tt{constructor(t,i,e={}){const s=i.image.width,r=i.image.height,h=new Rt(i),o=new n(kt,h);super(t,e.x??0,e.y??0,s,r,o),this.Jt=()=>{this.Qt.setQuadSize(this.width*this.micro.scaleX,this.height*this.micro.scaleY)},this.layer.on(Z.WILL_RENDER,this.Jt),this.Qt=h,this.Zt=i;const a=(t=>{if(null==t)return{left:Ot,right:Ot,top:Ot,bottom:Ot};if("number"==typeof t)return{left:t,right:t,top:t,bottom:t};if("object"==typeof t){if("horizontal"in t&&"vertical"in t){const i="number"==typeof t.horizontal?t.horizontal:Ot,e="number"==typeof t.vertical?t.vertical:Ot;return{left:i,right:i,top:e,bottom:e}}return{left:"number"==typeof t.left?t.left:Ot,right:"number"==typeof t.right?t.right:Ot,top:"number"==typeof t.top?t.top:Ot,bottom:"number"==typeof t.bottom?t.bottom:Ot}}return{left:Ot,right:Ot,top:Ot,bottom:Ot}})(e.sliceBorder);this.Qt.setSliceBorder(a.left,a.right,a.top,a.bottom)}get sliceBorderLeft(){return this.Qt.getSliceBorderLeft()}get sliceBorderRight(){return this.Qt.getSliceBorderRight()}get sliceBorderTop(){return this.Qt.getSliceBorderTop()}get sliceBorderBottom(){return this.Qt.getSliceBorderBottom()}get texture(){return this.Zt}get color(){return this.Qt.getColor()}get opacity(){return this.Qt.getOpacity()}get transparency(){return this.Qt.getTransparency()}set sliceBorderLeft(t){this.Qt.setSliceBorderLeft(t)}set sliceBorderRight(t){this.Qt.setSliceBorderRight(t)}set sliceBorderTop(t){this.Qt.setSliceBorderTop(t)}set sliceBorderBottom(t){this.Qt.setSliceBorderBottom(t)}set texture(t){const i=t.image.width,e=t.image.height;lt(i,"UINineSlice texture width"),lt(e,"UINineSlice texture height"),this.Qt.setTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,e)}set color(t){this.Qt.setColor(t)}set opacity(t){this.Qt.setOpacity(t)}set transparency(t){this.Qt.setTransparency(t)}setSliceBorders(t,i,e,s){this.Qt.setSliceBorder(t,i,e,s)}destroy(){this.layer.off(Z.WILL_RENDER,this.Jt),this.Qt.dispose(),super.destroy()}}class Ht extends r{constructor(i,e){super({uniforms:u.merge([{background:{value:e},foreground:{value:i},progress:{value:1},backgroundColor:{value:new t(1,1,1)},foregroundColor:{value:new t(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:zt,fragmentShader:Pt,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()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.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}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.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 Dt extends Tt{constructor(t,i,e={}){const r=i.image?.width,h=i.image?.height;lt(r,"UIProgress foreground texture width"),lt(h,"UIProgress foreground texture height");const o=e.textureBackground?.image?.width,a=e.textureBackground?.image?.height;e.textureBackground&&(lt(o,"UIProgress background texture width"),lt(a,"UIProgress background texture height"));const u=new Ht(i,e.textureBackground),l=new n(kt,u);void 0!==e.progress&&u.setProgress(e.progress),void 0!==e.isForegroundDirection&&u.setIsForwardDirection(e.isForegroundDirection),void 0!==e.angle&&u.setAngle(s.degToRad(e.angle)),void 0!==e.backgroundColor&&u.setBackgroundColor(e.backgroundColor),void 0!==e.foregroundColor&&u.setForegroundColor(e.foregroundColor),void 0!==e.backgroundOpacity&&u.setBackgroundOpacity(e.backgroundOpacity),void 0!==e.foregroundOpacity&&u.setForegroundOpacity(e.foregroundOpacity),super(t,e.x??0,e.y??0,o??r,h??a,l),this.Qt=u}get progress(){return this.Qt.getProgress()}get backgroundTexture(){return this.Qt.getBackgroundTexture()}get foregroundTexture(){return this.Qt.getForegroundTexture()}get backgroundColor(){return this.Qt.getBackgroundColor()}get foregroundColor(){return this.Qt.getForegroundColor()}get backgroundOpacity(){return this.Qt.getBackgroundOpacity()}get foregroundOpacity(){return this.Qt.getForegroundOpacity()}get angle(){return s.radToDeg(this.Qt.getAngle())}get isForwardDirection(){return this.Qt.getIsForwardDirection()}set progress(t){this.Qt.setProgress(t)}set backgroundTexture(t){if(t){const i=t.image.height;lt(t.image.width,"UIElement background texture width"),lt(i,"UIElement background texture height")}this.Qt.setBackgroundTexture(t)}set foregroundTexture(t){const i=t.image.width,e=t.image.height;lt(i,"UIImage texture width"),lt(e,"UIImage texture height"),this.Qt.setForegroundTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,e)}set backgroundColor(t){this.Qt.setBackgroundColor(t)}set foregroundColor(t){this.Qt.setForegroundColor(t)}set backgroundOpacity(t){this.Qt.setBackgroundOpacity(t)}set foregroundOpacity(t){this.Qt.setForegroundOpacity(t)}set angle(t){this.Qt.setAngle(s.degToRad(t))}set isForwardDirection(t){this.Qt.setIsForwardDirection(t)}destroy(){this.Qt.dispose(),super.destroy()}}var Nt;(t=>{t[t.EACH_FRAME=1]="EACH_FRAME",t[t.EACH_SECOND_FRAME=2]="EACH_SECOND_FRAME",t[t.PROPERTY_CHANGED=3]="PROPERTY_CHANGED",t[t.MANUAL=4]="MANUAL"})(Nt||(Nt={}));const $t=Nt.PROPERTY_CHANGED;class Wt extends Tt{constructor(t,e={}){const s=e.resolutionFactor??.5;if(.1>s||s>2)throw Error(`Invalid resolution factor: ${s}. Must be between 0.1 and 2.`);const r=e.width??512,h=e.height??512,o=new l(r*s,h*s,{format:f,minFilter:d,magFilter:d,type:c,depthBuffer:e.enableDepthBuffer??!0,stencilBuffer:!1}),a=new At(o.texture);super(t,0,0,r,h,new n(kt,a)),this.Kt=!0,this.ti=!1,this.ii=!1,this.Jt=t=>{(this.ei===Nt.EACH_FRAME||this.ei===Nt.EACH_SECOND_FRAME&&this.Kt||this.ei===Nt.PROPERTY_CHANGED&&this.ti||this.ei===Nt.MANUAL&&this.ii)&&(this.ii=!1,this.ti=!1,this.Kt=!this.Kt,this.si.setSize(this.width*this.ri,this.height*this.ri),t.setClearColor(this.hi,this.clearAlpha),t.setRenderTarget(this.si),t.clear(!0,!0,!1),t.render(this.ni,this.oi))},this.layer.on(Z.WILL_RENDER,this.Jt),this.Qt=a,this.si=o,this.ni=e.scene??new i,this.oi=e.camera??new g(75,r/h,.1,100),this.ri=s,this.ei=e.updateMode??$t,this.hi=e.clearColor??0,this.ai=e.clearAlpha??0,e.updateMode===Nt.PROPERTY_CHANGED&&(this.ii=!0)}get color(){return this.Qt.getColor()}get opacity(){return this.Qt.getOpacity()}get transparency(){return this.Qt.getTransparency()}get scene(){return this.ni}get camera(){return this.oi}get updateMode(){return this.ei}get resolutionFactor(){return this.ri}get clearColor(){return this.hi}get clearAlpha(){return this.ai}set color(t){this.Qt.setColor(t)}set opacity(t){this.Qt.setOpacity(t)}set transparency(t){this.Qt.setTransparency(t)}set scene(t){this.ni!==t&&(this.ni=t,this.ti=!0)}set camera(t){this.oi!==t&&(this.oi=t,this.ti=!0)}set updateMode(t){this.ei!==t&&(this.ei=t,this.ti=!0)}set resolutionFactor(t){this.ri!==t&&(this.ri=t,this.si.setSize(this.width*this.ri,this.height*this.ri),this.ti=!0)}set clearColor(t){this.hi!==t&&(this.hi=t,this.ti=!0)}set clearAlpha(t){this.ai!==t&&(this.ai=t,this.ti=!0)}destroy(){this.layer.off(Z.WILL_RENDER,this.Jt),this.Qt.dispose(),this.si.dispose(),super.destroy()}requestRender(){this.ii=!0}}function jt(t){return"object"==typeof t&&null!==t&&!("string"!=typeof t.color||"string"!=typeof t.fontFamily||"number"!=typeof t.fontSize||"normal"!==t.fontStyle&&"italic"!==t.fontStyle&&"oblique"!==t.fontStyle||"normal"!==t.fontWeight&&"bold"!==t.fontWeight&&"bolder"!==t.fontWeight&&"lighter"!==t.fontWeight&&"number"!=typeof t.fontWeight||"number"!=typeof t.lineHeight||"boolean"!=typeof t.enableShadow||"number"!=typeof t.shadowOffsetX||"number"!=typeof t.shadowOffsetY||"number"!=typeof t.shadowBlur||"string"!=typeof t.shadowColor||"boolean"!=typeof t.enableStroke||"string"!=typeof t.strokeColor||"number"!=typeof t.strokeWidth)}function qt(t,i){const e=t?.fontSize??i?.fontSize??16;lt(e,"Font size");const s=t?.fontWeight??i?.fontWeight??"normal";"number"==typeof s&&lt(s,"Font weight");const r=t?.lineHeight??i?.lineHeight??1.2*e;ut(r,"Line height");const h=t?.shadowOffsetX??i?.shadowOffsetX??0;ct(h,"Shadow offset X");const n=t?.shadowOffsetY??i?.shadowOffsetY??0;ct(n,"Shadow offset Y");const o=t?.shadowBlur??i?.shadowBlur??0;ct(o,"Shadow blur");const a=t?.strokeWidth??i?.strokeWidth??0;return ct(a,"Stroke width"),{color:t?.color??i?.color??"#000000",fontFamily:t?.fontFamily??i?.fontFamily??"Arial",fontSize:e,fontStyle:t?.fontStyle??i?.fontStyle??"normal",fontWeight:s,lineHeight:r,enableShadow:t?.enableShadow??i?.enableShadow??!1,shadowOffsetX:h,shadowOffsetY:n,shadowBlur:o,shadowColor:t?.shadowColor??i?.shadowColor??"transparent",enableStroke:t?.enableStroke??i?.enableStroke??!1,strokeColor:t?.strokeColor??i?.strokeColor??"#000000",strokeWidth:a}}function Yt(t){return t.match(/\S+|\s|\n/g)??[]}function Xt(t,i,e){if(t.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize}px ${e.fontFamily}`,"\n"===i)return{width:0,height:e.lineHeight,baseline:0,lineHeight:e.lineHeight};const s=t.measureText(i);return{width:Math.ceil(s.width),height:Math.ceil(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent),baseline:s.actualBoundingBoxDescent,lineHeight:e.lineHeight}}function Gt(t,i,e,s,r){r.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,s.enableShadow&&(r.shadowOffsetX=s.shadowOffsetX,r.shadowOffsetY=s.shadowOffsetY,r.shadowBlur=s.shadowBlur,r.shadowColor=s.shadowColor),s.enableStroke&&(r.strokeStyle=s.strokeColor,r.lineWidth=s.strokeWidth,r.strokeText(e,t,i)),r.fillStyle=s.color,r.fillText(e,t,i)}function Qt(t){if("number"==typeof t)return{left:t,right:t,top:t,bottom:t};if("object"==typeof t&&null!==t){const i="left"in t&&"number"==typeof t.left?t.left:0,e="right"in t&&"number"==typeof t.right?t.right:0,s="top"in t&&"number"==typeof t.top?t.top:0,r="bottom"in t&&"number"==typeof t.bottom?t.bottom:0;return ct(i,"Padding left"),ct(e,"Padding right"),ct(s,"Padding top"),ct(r,"Padding bottom"),{left:i,right:e,top:s,bottom:r}}return{left:0,right:0,top:0,bottom:0}}class Zt extends Tt{constructor(t,i,e={}){const s=document.createElement("canvas"),r=s.getContext("2d");if(!r)throw Error("Failed to create canvas context");const h=new p(s),o=new At(h),a=new n(kt,o);super(t,e.x??0,e.y??0,2,2,a),this.ui=1,this.li=1,this.Jt=()=>{this.li!==this.width/this.height&&(this.li=this.ui,this.height=this.width/this.ui)},this.layer.on(Z.WILL_RENDER,this.Jt),this.Qt=o,this.ci=h,this.di=s,this.fi=r,this.gi=i,this.pi=e.maxWidth??1024,this.wi=Qt(e.padding),this.mi=e.commonStyle??{},this.yi()}get color(){return this.Qt.getColor()}get opacity(){return this.Qt.getOpacity()}get transparency(){return this.Qt.getTransparency()}get content(){return this.gi}get maxWidth(){return this.pi}get padding(){return this.wi}get commonStyle(){return this.mi}set color(t){this.Qt.setColor(t)}set opacity(t){this.Qt.setOpacity(t)}set transparency(t){this.Qt.setTransparency(t)}set content(t){this.gi=t,this.yi()}set maxWidth(t){this.pi=t,this.yi()}set padding(t){this.wi=t,this.yi()}set commonStyle(t){this.mi=t,this.yi()}destroy(){this.layer.off(Z.WILL_RENDER,this.Jt),this.Qt.dispose(),this.ci.dispose(),this.di.remove(),super.destroy()}yi(){const{lines:t,size:i}=((t,i,e,s)=>{const r=[];for(const e of Array.isArray(i)?i:[i]){const i="string"==typeof e,h=i?e:e.text,n=qt(i?void 0:e.style,s);for(const i of Yt(h)){const e=Xt(t,i,n);r.push({text:i,style:n,metrics:e})}}const h=((t,i)=>{const e=[];let s=[],r=0,h=0,n=0,o=0;for(const a of i)"\n"!==a.text?r+a.metrics.width>t&&0!==s.length?(e.push({chunks:s,width:r,height:h,baseline:n,lineHeight:o}),s=[a],r=a.metrics.width,h=a.metrics.height,n=a.metrics.baseline,o=a.metrics.lineHeight):(s.push(a),r+=a.metrics.width,h=Math.max(h,a.metrics.height),n=Math.max(n,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(s.length>0&&e.push({chunks:s,width:r,height:h,baseline:n,lineHeight:o}),s=[],r=0,h=0,n=0,o=0);return s.length>0&&e.push({chunks:s,width:r,height:h,baseline:n,lineHeight:o}),e})(e,r),n=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let e=0;for(let i=0;t.length>i;i++){const s=t[i];e+=0===i?s.height:s.lineHeight,i===t.length-1&&(e+=s.baseline)}return{width:i,height:e}})(h);return{lines:h,size:n}})(this.fi,this.content,this.pi,this.mi);this.di.width=i.width+this.wi.left+this.wi.right,this.di.height=i.height+this.wi.top+this.wi.bottom,this.width=this.di.width,this.height=this.di.height,this.ui=(i.width+this.wi.left+this.wi.right)/(i.height+this.wi.top+this.wi.bottom),((t,i,e,s)=>{let r=this.wi.top;for(let t=0;e.length>t;t++){const h=e[t];let n=i;r+=0===t?h.height:h.lineHeight;for(const t of h.chunks)Gt(n,r,t.text,t.style,s),n+=t.metrics.width}})(0,this.wi.left,t,this.fi),this.ci.needsUpdate=!0}}class Jt extends it{constructor(t,i){void 0!==t&&lt(t,"UIFullscreenLayer.fixedWidth"),void 0!==i&&lt(i,"UIFullscreenLayer.fixedHeight"),super(1,1),this.bi=()=>{const t=this.xi();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.Ei=t=>{const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,e=i?t.clientX-i.left:t.clientX,s=i?i.bottom-t.clientY:window.innerHeight-t.clientY,r=this.xi();this.clickInternal(e*r,s*r)},this.Si=t,this._i=i,window.addEventListener("resize",this.bi),window.addEventListener("pointerdown",this.Ei),this.bi()}get fixedWidth(){return this.Si}get fixedHeight(){return this._i}set fixedWidth(t){void 0!==t&&lt(t,"UIFullscreenLayer.fixedWidth"),t!==this.Si&&(this.Si=t,this.bi())}set fixedHeight(t){void 0!==t&&lt(t,"UIFullscreenLayer.fixedHeight"),t!==this._i&&(this._i=t,this.bi())}destroy(){window.removeEventListener("resize",this.bi),window.removeEventListener("pointerdown",this.Ei)}render(t,i){ut(i,"UIFullscreenLayer.deltaTime"),super.renderInternal(t,i)}xi(){return this.orientation===b.HORIZONTAL?void 0!==this.fixedWidth?this.fixedWidth/window.innerWidth:void 0!==this.fixedHeight?this.fixedHeight/window.innerHeight:1:void 0!==this.fixedHeight?this.fixedHeight/window.innerHeight:void 0!==this.fixedWidth?this.fixedWidth/window.innerWidth:1}}function Kt(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text&&(!("style"in t)||jt(t.style))}export{_t as UIAnchor,H as UIAnchorMode,mt as UIAspectConstraint,et as UIConstraint,wt as UIConstraint2DBuilder,bt as UICoverConstraintBuilder,St as UICustomConstraint,Ct as UIDummy,Tt as UIElement,Mt as UIElementEvent,v as UIExpression,Et as UIFitConstraintBuilder,Jt as UIFullscreenLayer,rt as UIHeightConstraint,dt as UIHorizontalDistanceConstraint,ft as UIHorizontalProportionConstraint,Vt as UIImage,it as UILayer,Z as UILayerEvent,It as UIMicro,y as UIMode,Ft as UINineSlice,b as UIOrientation,F as UIPriority,Dt as UIProgress,Q as UIRelation,Wt as UIScene,Nt as UISceneUpdateMode,st as UISingleParameterConstraint,Zt as UIText,gt as UIVerticalDistanceConstraint,pt as UIVerticalProportionConstraint,vt as UIWidthConstraint,D as convertPriority,J as convertRelation,Kt as isUITextSpan,jt as isUITextStyle,x as resolveOrientation,Qt as resolvePadding,N as resolvePriority,K as resolveRelation,qt as resolveTextStyle};
2
2
  //# sourceMappingURL=index.min.js.map