laymur 0.1.73 → 0.2.1

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.
Files changed (90) hide show
  1. package/README.md +367 -0
  2. package/dist/builders/UIConstraint2DBuilder.d.ts +130 -0
  3. package/dist/composer/UIComposer.d.ts +0 -0
  4. package/dist/composer/UIFullscreenQuad.d.ts +0 -0
  5. package/dist/composer/UIPass.d.ts +0 -0
  6. package/dist/constraints/UIAspectConstraint.d.ts +60 -0
  7. package/dist/constraints/UIConstraint.d.ts +29 -0
  8. package/dist/constraints/UICoverConstraint.d.ts +0 -0
  9. package/dist/constraints/UICustomConstraint.d.ts +60 -0
  10. package/dist/constraints/UIFitConstraint.d.ts +0 -0
  11. package/dist/constraints/UIHeightConstraint.d.ts +49 -0
  12. package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +94 -0
  13. package/dist/constraints/UIHorizontalProportionConstraint.d.ts +67 -0
  14. package/dist/constraints/UISingleParameterConstraint.d.ts +108 -0
  15. package/dist/constraints/UIVerticalDistanceConstraint.d.ts +94 -0
  16. package/dist/constraints/UIVerticalProportionConstraint.d.ts +67 -0
  17. package/dist/constraints/UIWidthConstraint.d.ts +49 -0
  18. package/dist/elements/UIAnchor.d.ts +78 -0
  19. package/dist/elements/UIDummy.d.ts +72 -0
  20. package/dist/elements/UIElement.d.ts +121 -0
  21. package/dist/elements/UIImage.d.ts +88 -0
  22. package/dist/elements/UINineSline.d.ts +0 -0
  23. package/dist/elements/UIProgress.d.ts +39 -0
  24. package/dist/elements/UIScene.d.ts +199 -0
  25. package/dist/elements/UIText.d.ts +157 -0
  26. package/dist/index.d.ts +29 -31
  27. package/dist/index.js +3320 -3251
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.min.js +1 -1
  30. package/dist/index.min.js.map +1 -1
  31. package/dist/layers/UIFullscreenLayer.d.ts +112 -0
  32. package/dist/layers/UILayer.d.ts +144 -0
  33. package/dist/materials/UIInstancedMaterial.d.ts +0 -0
  34. package/dist/materials/UIMaterial.d.ts +13 -0
  35. package/dist/materials/UINineSliceMaterial.d.ts +0 -0
  36. package/dist/{Materials → materials}/UIProgressMaterial.d.ts +0 -4
  37. package/dist/miscellaneous/UIExpression.d.ts +117 -0
  38. package/dist/miscellaneous/UIMicro.d.ts +130 -0
  39. package/dist/{Miscellaneous → miscellaneous}/UIOrientation.d.ts +2 -9
  40. package/dist/miscellaneous/UIPriority.d.ts +56 -0
  41. package/dist/miscellaneous/UIRelation.d.ts +43 -0
  42. package/dist/miscellaneous/UITextPadding.d.ts +7 -0
  43. package/dist/miscellaneous/UITextSpan.d.ts +6 -0
  44. package/dist/miscellaneous/UITextStyle.d.ts +18 -0
  45. package/dist/miscellaneous/asserts.d.ts +112 -0
  46. package/dist/miscellaneous/textInterfaces.d.ts +19 -0
  47. package/dist/miscellaneous/textTools.d.ts +12 -0
  48. package/dist/scalable/UIScalableMesh.d.ts +16 -0
  49. package/dist/scalable/UIScalablePlaneMesh.d.ts +14 -0
  50. package/dist/wrappers/UISceneWrapper.d.ts +18 -0
  51. package/dist/wrappers/UISolverWrapper.d.ts +29 -0
  52. package/package.json +3 -3
  53. package/dist/Builders/UIConstraint2DBuilder.d.ts +0 -42
  54. package/dist/Builders/UIConstraintContainerBuilder.d.ts +0 -20
  55. package/dist/Builders/UIConstraintStackBuilder.d.ts +0 -24
  56. package/dist/Constraints/UIAspectConstraint.d.ts +0 -56
  57. package/dist/Constraints/UIConstraint.d.ts +0 -32
  58. package/dist/Constraints/UIConstraintPower.d.ts +0 -57
  59. package/dist/Constraints/UIConstraintRule.d.ts +0 -46
  60. package/dist/Constraints/UICoverConstraint.d.ts +0 -72
  61. package/dist/Constraints/UIFitConstraint.d.ts +0 -72
  62. package/dist/Constraints/UIHeightConstraint.d.ts +0 -55
  63. package/dist/Constraints/UIHorizontalDistanceConstraint.d.ts +0 -63
  64. package/dist/Constraints/UIHorizontalProportionConstraint.d.ts +0 -58
  65. package/dist/Constraints/UIVerticalDistanceConstraint.d.ts +0 -63
  66. package/dist/Constraints/UIVerticalProportionConstraint.d.ts +0 -58
  67. package/dist/Constraints/UIWidthConstraint.d.ts +0 -55
  68. package/dist/Elements/UIAnchor.d.ts +0 -66
  69. package/dist/Elements/UIDummy.d.ts +0 -21
  70. package/dist/Elements/UIElement.d.ts +0 -134
  71. package/dist/Elements/UIImage.d.ts +0 -57
  72. package/dist/Elements/UIProgress.d.ts +0 -127
  73. package/dist/Elements/UIScene.d.ts +0 -141
  74. package/dist/Elements/UIText.d.ts +0 -76
  75. package/dist/Layers/UIFullScreenLayer.d.ts +0 -13
  76. package/dist/Layers/UILayer.d.ts +0 -68
  77. package/dist/Materials/UIMaterial.d.ts +0 -13
  78. package/dist/Miscellaneous/UIBlending.d.ts +0 -7
  79. package/dist/Miscellaneous/UIMicro.d.ts +0 -176
  80. package/dist/Miscellaneous/UITextInterfaces.d.ts +0 -49
  81. package/dist/Miscellaneous/asserts.d.ts +0 -5
  82. package/dist/Miscellaneous/math.d.ts +0 -1
  83. package/dist/Miscellaneous/microTransformationTools.d.ts +0 -3
  84. package/dist/Miscellaneous/symbols.d.ts +0 -1
  85. package/dist/Miscellaneous/textTools.d.ts +0 -9
  86. package/dist/Passes/UIComposer.d.ts +0 -114
  87. package/dist/Passes/UIFullScreenQuad.d.ts +0 -51
  88. package/dist/Passes/UIPass.d.ts +0 -43
  89. /package/dist/{Miscellaneous → miscellaneous}/UIMode.d.ts +0 -0
  90. /package/dist/{Miscellaneous → miscellaneous}/threeInstances.d.ts +0 -0
package/dist/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as h,Vector3 as r,ShaderMaterial as n,Color as e,AddEquation as o,SrcAlphaFactor as a,OneMinusSrcAlphaFactor as c,NormalBlending as u,CustomBlending as d,OneMinusDstColorFactor as f,OneFactor as l,MultiplyBlending as w,SubtractiveBlending as v,AdditiveBlending as g,PlaneGeometry as p,Scene as m,Mesh as y,OrthographicCamera as b,WebGLRenderTarget as x,UnsignedByteType as C,LinearFilter as S,RGBAFormat as E,NoBlending as k,Object3D as M,UniformsUtils as T,PerspectiveCamera as O,CanvasTexture as I}from"three";function _(){return new F}var F=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var h=new A(t,i());return this.index[t.id()]=this.array.length,this.array.push(h),h}return this.array[s]},t.prototype.insert=function(t,i){var s=new A(t,i),h=this.index[t.id()];return void 0===h?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[h]=s,s},t.prototype.erase=function(t){var i=this.index[t.id()];if(void 0!==i){this.index[t.id()]=void 0;var s=this.array[i],h=this.array.pop();return s!==h&&(this.array[i]=h,this.index[h.first.id()]=i),s}},t.prototype.copy=function(){for(var i=new t,s=0;this.array.length>s;s++){var h=this.array[s].copy();i.array[s]=h,i.index[h.first.id()]=s}return i},t}(),A=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),B=function(){function t(t){void 0===t&&(t=""),this.C=0,this.S=null,this.T=$++,this.O=t}return t.prototype.id=function(){return this.T},t.prototype.name=function(){return this.O},t.prototype.setName=function(t){this.O=t},t.prototype.context=function(){return this.S},t.prototype.setContext=function(t){this.S=t},t.prototype.value=function(){return this.C},t.prototype.setValue=function(t){this.C=t},t.prototype.plus=function(t){return new P(this,t)},t.prototype.minus=function(t){return new P(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new P([t,this])},t.prototype.divide=function(t){return new P([1/t,this])},t.prototype.toJSON=function(){return{name:this.O,value:this.C}},t.prototype.toString=function(){return this.S+"["+this.O+":"+this.C+"]"},t}(),$=0,P=function(){function t(){var t=U(arguments);this.I=t.terms,this._=t.constant}return t.prototype.terms=function(){return this.I},t.prototype.constant=function(){return this._},t.prototype.value=function(){for(var t=this._,i=0,s=this.I.size();s>i;i++){var h=this.I.itemAt(i);t+=h.first.value()*h.second}return t},t.prototype.plus=function(i){return new t(this,i)},t.prototype.minus=function(i){return new t(this,"number"==typeof i?-i:[-1,i])},t.prototype.multiply=function(i){return new t([i,this])},t.prototype.divide=function(i){return new t([1/i,this])},t.prototype.isConstant=function(){return 0==this.I.size()},t.prototype.toString=function(){var t=this.I.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this._||(t+=" + "),t+this._},t}();function U(t){for(var i=0,s=()=>0,h=_(),r=0,n=t.length;n>r;++r){var e=t[r];if("number"==typeof e)i+=e;else if(e instanceof B)h.setDefault(e,s).second+=1;else if(e instanceof P){i+=e.constant();for(var o=0,a=(f=e.terms()).size();a>o;o++){var c=f.itemAt(o);h.setDefault(c.first,s).second+=c.second}}else{if(!(e instanceof Array))throw Error("invalid Expression argument: "+e);if(2!==e.length)throw Error("array must have length 2");var u=e[0],d=e[1];if("number"!=typeof u)throw Error("array item 0 must be a number");if(d instanceof B)h.setDefault(d,s).second+=u;else{if(!(d instanceof P))throw Error("array item 1 must be a variable or expression");var f;for(i+=d.constant()*u,o=0,a=(f=d.terms()).size();a>o;o++)c=f.itemAt(o),h.setDefault(c.first,s).second+=c.second*u}}}return{terms:h,constant:i}}var z,D=(()=>{function t(){}return t.create=(t,i,s,h)=>{void 0===h&&(h=1);var r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*h)),(r+=1e3*Math.max(0,Math.min(1e3,i*h)))+Math.max(0,Math.min(1e3,s*h))},t.clip=i=>Math.max(0,Math.min(t.required,i)),t.required=t.create(1e3,1e3,1e3),t.strong=t.create(1,0,0),t.medium=t.create(0,1,0),t.weak=t.create(0,0,1),t})();(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(z||(z={}));var V,R=function(){function t(t,i,s,h){void 0===h&&(h=D.required),this.T=H++,this.F=i,this.A=D.clip(h),this.B=void 0===s&&t instanceof P?t:t.minus(s)}return t.prototype.id=function(){return this.T},t.prototype.expression=function(){return this.B},t.prototype.op=function(){return this.F},t.prototype.strength=function(){return this.A},t.prototype.toString=function(){return this.B+" "+["<=",">=","="][this.F]+" 0 ("+this.A+")"},t}(),H=0,L=function(){function t(){this.$=_(),this.P=_(),this.U=_(),this.D=_(),this.V=[],this.R=new Y,this.H=null,this.L=0}return t.prototype.createConstraint=function(t,i,s,h){void 0===h&&(h=D.required);var r=new R(t,i,s,h);return this.addConstraint(r),r},t.prototype.addConstraint=function(t){if(void 0!==this.$.find(t))throw Error("duplicate constraint");var i=this.j(t),s=i.row,h=i.tag,r=this.N(s,h);if(r.type()===V.Invalid&&s.allDummies()){if(!j(s.constant()))throw Error("unsatisfiable constraint");r=h.marker}if(r.type()===V.Invalid){if(!this.X(s))throw Error("unsatisfiable constraint")}else s.solveFor(r),this.Y(r,s),this.P.insert(r,s);this.$.insert(t,h),this.W(this.R)},t.prototype.removeConstraint=function(t){var i=this.$.erase(t);if(void 0===i)throw Error("unknown constraint");this.q(t,i.second);var s=i.second.marker,h=this.P.erase(s);if(void 0===h){var r=this.G(s);if(r.type()===V.Invalid)throw Error("failed to find leaving row");(h=this.P.erase(r)).second.solveForEx(r,s),this.Y(s,h.second)}this.W(this.R)},t.prototype.hasConstraint=function(t){return this.$.contains(t)},t.prototype.addEditVariable=function(t,i){if(void 0!==this.D.find(t))throw Error("duplicate edit variable");if((i=D.clip(i))===D.required)throw Error("bad required strength");var s=new P(t),h=new R(s,z.Eq,void 0,i);this.addConstraint(h);var r=this.$.find(h).second;this.D.insert(t,{tag:r,constraint:h,constant:0})},t.prototype.removeEditVariable=function(t){var i=this.D.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)},t.prototype.hasEditVariable=function(t){return this.D.contains(t)},t.prototype.suggestValue=function(t,i){var s=this.D.find(t);if(void 0===s)throw Error("unknown edit variable");var h=this.P,r=s.second,n=i-r.constant;r.constant=i;var e=r.tag.marker,o=h.find(e);if(void 0!==o)return 0>o.second.add(-n)&&this.V.push(e),void this.J();var a=r.tag.other;if(void 0!==(o=h.find(a)))return 0>o.second.add(n)&&this.V.push(a),void this.J();for(var c=0,u=h.size();u>c;++c){var d=h.itemAt(c),f=d.second,l=f.coefficientFor(e);0!==l&&0>f.add(n*l)&&d.first.type()!==V.External&&this.V.push(d.first)}this.J()},t.prototype.updateVariables=function(){for(var t=this.U,i=this.P,s=0,h=t.size();h>s;++s){var r=t.itemAt(s),n=i.find(r.second);r.first.setValue(void 0!==n?n.second.constant():0)}},t.prototype.K=function(t){var i=this;return this.U.setDefault(t,()=>i.Z(V.External)).second},t.prototype.j=function(t){for(var i=t.expression(),s=new Y(i.constant()),h=i.terms(),r=0,n=h.size();n>r;++r){var e=h.itemAt(r);if(!j(e.second)){var o=this.K(e.first),a=this.P.find(o);void 0!==a?s.insertRow(a.second,e.second):s.insertSymbol(o,e.second)}}var c=this.R,u=t.strength(),d={marker:X,other:X};switch(t.op()){case z.Le:case z.Ge:var f=t.op()===z.Le?1:-1,l=this.Z(V.Slack);if(d.marker=l,s.insertSymbol(l,f),D.required>u){var w=this.Z(V.Error);d.other=w,s.insertSymbol(w,-f),c.insertSymbol(w,u)}break;case z.Eq:if(D.required>u){var v=this.Z(V.Error),g=this.Z(V.Error);d.marker=v,d.other=g,s.insertSymbol(v,-1),s.insertSymbol(g,1),c.insertSymbol(v,u),c.insertSymbol(g,u)}else{var p=this.Z(V.Dummy);d.marker=p,s.insertSymbol(p)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:d}},t.prototype.N=(t,i)=>{for(var s=t.cells(),h=0,r=s.size();r>h;++h){var n=s.itemAt(h);if(n.first.type()===V.External)return n.first}var e=i.marker.type();return e!==V.Slack&&e!==V.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type())!==V.Slack&&e!==V.Error||t.coefficientFor(i.other)>=0?X:i.other:i.marker},t.prototype.X=function(t){var i=this.Z(V.Slack);this.P.insert(i,t.copy()),this.H=t.copy(),this.W(this.H);var s=j(this.H.constant());this.H=null;var h=this.P.erase(i);if(void 0!==h){var r=h.second;if(r.isConstant())return s;var n=this.tt(r);if(n.type()===V.Invalid)return!1;r.solveForEx(i,n),this.Y(n,r),this.P.insert(n,r)}for(var e=this.P,o=0,a=e.size();a>o;++o)e.itemAt(o).second.removeSymbol(i);return this.R.removeSymbol(i),s},t.prototype.Y=function(t,i){for(var s=this.P,h=0,r=s.size();r>h;++h){var n=s.itemAt(h);n.second.substitute(t,i),0>n.second.constant()&&n.first.type()!==V.External&&this.V.push(n.first)}this.R.substitute(t,i),this.H&&this.H.substitute(t,i)},t.prototype.W=function(t){for(;;){var i=this.it(t);if(i.type()===V.Invalid)return;var s=this.st(i);if(s.type()===V.Invalid)throw Error("the objective is unbounded");var h=this.P.erase(s).second;h.solveForEx(s,i),this.Y(i,h),this.P.insert(i,h)}},t.prototype.J=function(){for(var t=this.P,i=this.V;0!==i.length;){var s=i.pop(),h=t.find(s);if(void 0!==h&&0>h.second.constant()){var r=this.ht(h.second);if(r.type()===V.Invalid)throw Error("dual optimize failed");var n=h.second;t.erase(s),n.solveForEx(s,r),this.Y(r,n),t.insert(r,n)}}},t.prototype.it=t=>{for(var i=t.cells(),s=0,h=i.size();h>s;++s){var r=i.itemAt(s),n=r.first;if(0>r.second&&n.type()!==V.Dummy)return n}return X},t.prototype.ht=function(t){for(var i=Number.MAX_VALUE,s=X,h=t.cells(),r=0,n=h.size();n>r;++r){var e=h.itemAt(r),o=e.first,a=e.second;if(a>0&&o.type()!==V.Dummy){var c=this.R.coefficientFor(o)/a;i>c&&(i=c,s=o)}}return s},t.prototype.st=function(t){for(var i=Number.MAX_VALUE,s=X,h=this.P,r=0,n=h.size();n>r;++r){var e=h.itemAt(r),o=e.first;if(o.type()!==V.External){var a=e.second,c=a.coefficientFor(t);if(0>c){var u=-a.constant()/c;i>u&&(i=u,s=o)}}}return s},t.prototype.G=function(t){for(var i=Number.MAX_VALUE,s=i,h=i,r=X,n=r,e=r,o=r,a=this.P,c=0,u=a.size();u>c;++c){var d=a.itemAt(c),f=d.second,l=f.coefficientFor(t);if(0!==l){var w=d.first;if(w.type()===V.External)o=w;else if(0>l)s>(v=-f.constant()/l)&&(s=v,n=w);else{var v;h>(v=f.constant()/l)&&(h=v,e=w)}}}return n!==r?n:e!==r?e:o},t.prototype.q=function(t,i){i.marker.type()===V.Error&&this.rt(i.marker,t.strength()),i.other.type()===V.Error&&this.rt(i.other,t.strength())},t.prototype.rt=function(t,i){var s=this.P.find(t);void 0!==s?this.R.insertRow(s.second,-i):this.R.insertSymbol(t,-i)},t.prototype.tt=t=>{for(var i=t.cells(),s=0,h=i.size();h>s;++s){var r=i.itemAt(s),n=r.first.type();if(n===V.Slack||n===V.Error)return r.first}return X},t.prototype.Z=function(t){return new N(t,this.L++)},t}();function j(t){return 0>t?1e-8>-t:1e-8>t}(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})(V||(V={}));var N=function(){function t(t,i){this.T=i,this.nt=t}return t.prototype.id=function(){return this.T},t.prototype.type=function(){return this.nt},t}(),X=new N(V.Invalid,-1),Y=function(){function t(t){void 0===t&&(t=0),this.et=_(),this._=t}return t.prototype.cells=function(){return this.et},t.prototype.constant=function(){return this._},t.prototype.isConstant=function(){return this.et.empty()},t.prototype.allDummies=function(){for(var t=this.et,i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==V.Dummy)return!1;return!0},t.prototype.copy=function(){var i=new t(this._);return i.et=this.et.copy(),i},t.prototype.add=function(t){return this._+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),j(this.et.setDefault(t,()=>0).second+=i)&&this.et.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this._+=t._*i;for(var s=t.et,h=0,r=s.size();r>h;++h){var n=s.itemAt(h);this.insertSymbol(n.first,n.second*i)}},t.prototype.removeSymbol=function(t){this.et.erase(t)},t.prototype.reverseSign=function(){this._=-this._;for(var t=this.et,i=0,s=t.size();s>i;++i){var h=t.itemAt(i);h.second=-h.second}},t.prototype.solveFor=function(t){var i=this.et,s=-1/i.erase(t).second;this._*=s;for(var h=0,r=i.size();r>h;++h)i.itemAt(h).second*=s},t.prototype.solveForEx=function(t,i){this.insertSymbol(t,-1),this.solveFor(i)},t.prototype.coefficientFor=function(t){var i=this.et.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.et.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const W=Symbol("xSymbol"),q=Symbol("ySymbol"),G=Symbol("widthSymbol"),Q=Symbol("heightSymbol"),J=Symbol("addUIElementSymbol"),K=Symbol("removeUIElementSymbol"),Z=Symbol("addConstraintSymbol"),tt=Symbol("removeUIConstraintSymbol"),it=Symbol("addConstraintSymbol"),st=Symbol("removeConstraintSymbol"),ht=Symbol("addVariableSymbol"),rt=Symbol("removeVariableSymbol"),nt=Symbol("suggestVariableSymbol"),et=Symbol("disableConstraintSymbol"),ot=Symbol("enableConstraintSymbol"),at=Symbol("needsRecalculation"),ct=Symbol("renderSymbol"),ut=Symbol("clickSymbol"),dt=Symbol("sortSymbol");var ft;function lt(t){return null!==t&&Object.values(ft).some(i=>i===t)}function wt(t){return t??ft.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(ft||(ft={}));class vt{constructor(t,i){this.layer=t,this.name="",this.layer[Z](this,i)}destroy(){this.layer[tt](this)}}const gt=1e3;var pt,mt,yt,bt,xt;function Ct(t){return null!==t&&Object.values(pt).some(i=>i===t)}function St(t){return t??pt.P0}function Et(t){switch(t){case pt.P0:return D.create(gt,gt,gt);case pt.P1:return D.create(100,0,0);case pt.P2:return D.create(10,0,0);case pt.P3:return D.create(0,100,0);case pt.P4:return D.create(0,10,0);case pt.P5:return D.create(0,0,100);case pt.P6:return D.create(0,0,10);case pt.P7:return D.create(0,0,1);default:return D.create(gt,gt,gt)}}function kt(t){return null!==t&&Object.values(mt).some(i=>i===t)}function Mt(t){return t??mt.EQUAL}function Tt(t){switch(t){case mt.EQUAL:return z.Eq;case mt.LESS:return z.Le;case mt.GREATER:return z.Ge;default:return z.Eq}}(t=>{t[t.P0=0]="P0",t[t.P1=1]="P1",t[t.P2=2]="P2",t[t.P3=3]="P3",t[t.P4=4]="P4",t[t.P5=5]="P5",t[t.P6=6]="P6",t[t.P7=7]="P7"})(pt||(pt={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(mt||(mt={}));class Ot extends vt{constructor(t,i){super(t.layer,new Set([t])),this.ot=t,this.ct={height:i?.height??t.height,power:St(i?.power),rule:Mt(i?.rule),orientation:wt(i?.orientation)},this.ct.orientation!==ft.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.ct.orientation!==ft.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}[ot](t){this.ct.orientation!==ft.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.ut=new R(new P(this.ot[Q]),Tt(this.ct.rule),this.ct.height,Et(this.ct.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class It{constructor(t,i,s=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,s):this.t.set(i,new Map([[t,s]])))}insert(t,i,s=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,s)}const h=this.t.get(i);void 0===h?this.t.set(i,new Map([[t,s]])):h.has(t)||h.set(t,s)}remove(t,i){if(void 0===i)return void this.i.delete(t);const s=this.t.get(i);void 0!==s&&(s.delete(t),0===s.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const s=this.t.get(i);return void 0!==s&&s.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const s=this.t.get(i);return void 0!==s?s.get(t):void 0}}class _t{constructor(){this.o=new Map}on(t,i,s,h=0){return this.h(t,!1,h,i,s),this}once(t,i,s,h=0){return this.h(t,!0,h,i,s),this}off(t,i,s){const h=this.o.get(t);if(void 0===h)return this;h.u&&(h.u=!1,h.v=h.v.slice());const r=h.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];h.l.remove(i.dt,i.p)}return this}{const n=r.length;if(r[0].dt===i&&r[0].p===s)return 1===n?this.o.delete(t):r.shift(),this;const e=n-1;if(r[e].dt===i&&r[e].p===s)return r.pop(),this;if(10>n||r[0].M===r[e].M)for(let t=1;e>t;t++){const h=r[t];if(h.dt===i&&h.p===s)return r.splice(t,1),this}else{const t=h.l.getPriority(i,s);if(void 0===t)return this;let n=0,e=r.length-1;for(;e>=n;){const i=n+e>>>1;t>r[i].M?n=i+1:e=i-1}const o=n;for(e=r.length-1;e>=n;){const i=n+e>>>1;r[i].M>t?e=i-1:n=i+1}const a=e;for(let t=o;a>=t;t++)if(r[t].dt===i&&r[t].p===s)return r.splice(t,1),this}}return this}emit(t,...i){const s=this.o.get(t);if(void 0===s)return!1;if(0===s.v.length)return!1;s.u?s.v=s.v.slice():s.u=!0;const h=s.v;let r=!1;for(let t=0;h.length>t;t++){const s=h[t];s.dt.apply(s.p,i),s.k&&(r=!0,s.m=!0)}const n=this.o.get(t);if(void 0===n)return!0;n.v===h&&(n.u=!1);const e=n.v;if(r){let i=0;for(let t=0;e.length>t;t++){const s=e[t];s.m?n.l.remove(s.dt,s.p):e[i++]=s}0===i?this.o.delete(t):e.length=i}return!0}h(t,i,s,h,r){let n=this.o.get(t);if(void 0===n)return void this.o.set(t,{v:[{dt:h,p:r,M:s,k:i,m:!1}],u:!1,l:new It(h,r,s)});if(n.l.has(h,r))throw Error("Event listener already exists");n.l.insert(h,r,s);const e={dt:h,p:r,M:s,k:i,m:!1};n.u&&(n.u=!1,n.v=n.v.slice());{const t=n.v,i=e.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(e);if(t[0].M>=i)return void t.unshift(e);{let s=0,h=t.length;for(;h>s;){const r=s+h>>>1;i>t[r].M?s=r+1:h=r}t.splice(s,0,e)}}}}class Ft extends _t{constructor(i,s,h,r){super(),this.layer=i,this.object=r,this[yt]=new B("x"),this[bt]=new B("y"),this[xt]=!1,this.name=t.generateUUID(),this.object&&(this.object.matrixAutoUpdate=!1),this.layer[J](this,r),this.layer[ht](this,this[W],Et(pt.P7)),this.layer[ht](this,this[q],Et(pt.P7)),this[W].setValue(s),this[q].setValue(h),this.layer[nt](this,this[W],s),this.layer[nt](this,this[q],h)}get x(){return this[W].value()}get y(){return this[q].value()}get zIndex(){return this.object?.position.z??0}get needsRecalculation(){return this[at]}set x(t){this.layer[nt](this,this[W],t)}set y(t){this.layer[nt](this,this[q],t)}set zIndex(t){this.object&&this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[dt](),this.object.updateMatrix())}destroy(){this.layer[rt](this,this[q]),this.layer[rt](this,this[W]),this.layer[K](this)}[(yt=W,bt=q,xt=at,ct)](t,i){this.render(t,i)}applyTransformations(){this[at]&&(this.object&&this.object.updateMatrix(),this[at]=!1)}}const At=new i,Bt=new s,$t=new h,Pt=new h,Ut=new h,zt=new h,Dt=new h,Vt=new r,Rt=.5;class Ht{constructor(){this.x=0,this.y=0,this.anchorX=Rt,this.anchorY=Rt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=!1}}class Lt{constructor(t,i){this.ft=t,this.lt=i}get x(){return this.ft.x}get y(){return this.ft.y}get anchorX(){return this.ft.anchorX}get anchorY(){return this.ft.anchorY}get scaleX(){return this.ft.scaleX}get scaleY(){return this.ft.scaleY}get angle(){return t.radToDeg(this.ft.rotation)}get rotation(){return this.ft.rotation}set x(t){t!==this.ft.x&&(this.ft.x=t,this.ft.needsRecalculation=!0)}set y(t){t!==this.ft.y&&(this.ft.y=t,this.ft.needsRecalculation=!0)}set anchorX(t){t!==this.ft.anchorX&&(this.ft.anchorX=t,this.ft.needsRecalculation=!0)}set anchorY(t){t!==this.ft.anchorY&&(this.ft.anchorY=t,this.ft.needsRecalculation=!0)}set scaleX(t){t!==this.ft.scaleX&&(this.ft.scaleX=t,this.ft.needsRecalculation=!0)}set scaleY(t){t!==this.ft.scaleY&&(this.ft.scaleY=t,this.ft.needsRecalculation=!0)}set angle(i){const s=t.degToRad(i);s!==this.ft.rotation&&(this.ft.rotation=s,this.ft.needsRecalculation=!0)}set rotation(t){t!==this.ft.rotation&&(this.ft.rotation=t,this.ft.needsRecalculation=!0)}setAnchorByGlobalPosition(t,i){const s=(t-this.lt.x)/this.lt.width,h=(i-this.lt.y)/this.lt.height;s===this.ft.anchorX&&h===this.ft.anchorY||(this.ft.anchorX=s,this.ft.anchorY=h,this.ft.needsRecalculation=!0)}reset(){0===this.ft.x&&0===this.ft.y&&this.ft.anchorX===Rt&&this.ft.anchorY===Rt&&1===this.ft.scaleX&&1===this.ft.scaleY&&0===this.ft.rotation||(this.ft.x=0,this.ft.y=0,this.ft.anchorX=Rt,this.ft.anchorY=Rt,this.ft.scaleX=1,this.ft.scaleY=1,this.ft.rotation=0,this.ft.needsRecalculation=!0)}}var jt,Nt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(jt||(jt={})),(t=>{t[t.NORMAL=0]="NORMAL",t[t.ADDITIVE=1]="ADDITIVE",t[t.SUBTRACTIVE=2]="SUBTRACTIVE",t[t.MULTIPLY=3]="MULTIPLY",t[t.SCREEN=4]="SCREEN"})(Nt||(Nt={}));class Xt extends n{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new e(1,1,1)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}setTexture(t){this.uniforms.map.value=t,this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setBlending(t){switch(this.premultipliedAlpha=!1,this.blendEquation=o,this.blendSrc=a,this.blendDst=c,t){case Nt.ADDITIVE:this.blending=g;break;case Nt.SUBTRACTIVE:this.blending=v;break;case Nt.MULTIPLY:this.blending=w,this.premultipliedAlpha=!0;break;case Nt.SCREEN:this.blending=d,this.blendEquation=o,this.blendSrc=f,this.blendDst=l;break;default:this.blending=u}this.needsUpdate=!0}}const Yt=new p(1,1).translate(.5,.5,0),Wt=new m,qt=new y(Yt);Wt.add(qt);class Gt{constructor(t=0,i=0){this.wt=t,this.vt=i,this.gt=new b(-1,1,1,-1,0,1),this.yt()}get paddingHorizontal(){return this.wt}get paddingVertical(){return this.vt}set paddingHorizontal(t){this.wt!==t&&(this.wt=t,this.yt())}set paddingVertical(t){this.vt!==t&&(this.vt=t,this.yt())}render(t,i){qt.material=i,t.render(Wt,this.gt)}yt(){this.gt.left=-this.wt,this.gt.right=1+this.wt,this.gt.bottom=-this.vt,this.gt.top=1+this.vt,this.gt.updateProjectionMatrix()}}class Qt{constructor(){this.passes=[],this.bt=new Xt,this.xt=new Gt,this.Ct=!1,this.St=!1,this.Et=0;const t={format:E,minFilter:S,magFilter:S,type:C,depthBuffer:!1,stencilBuffer:!1};this.kt=new x(1,1,t),this.Mt=new x(1,1,t),this.kt.texture.generateMipmaps=!1,this.Mt.texture.generateMipmaps=!1}get needsUpdate(){return this.Ct&&this.Tt()||this.Ot()}get paddingHasChanged(){return this.St}get padding(){return this.Et}requestUpdate(){this.Ct=!0}compose(t,i,s,h,r=!0){const n=this.Tt();if(!(this.Ct&&n||this.Ot()))return n||(this.St=0!==this.Et,this.Et=0),this.Ct=!1,n?this.bt:h;const e=this.It();this.St=this.Et!==e,this.Et=e;const o=i+2*e,a=s+2*e;this.kt.setSize(o,a),this.Mt.setSize(o,a),this._t(i,s,e),t.setClearColor(0,0),t.setRenderTarget(this.Mt),t.clear(!0,!1,!1);const c=h.blending;r&&(h.blending=k),this.xt.render(t,h),h.blending=c;const u={width:i,height:s,padding:e};for(let i=0;this.passes.length>i;i++){const s=this.passes[i];(s.needsUpdate||s.isValuable)&&(this.Ft(),t.setRenderTarget(this.Mt),t.clear(!0,!1,!1),this.passes[i].render(t,this.kt.texture,u))}return this.Ct=!1,this.bt.setTexture(this.Mt.texture),this.bt}destroy(){this.kt.dispose(),this.Mt.dispose()}Tt(){return this.passes.some(t=>t.isValuable)}Ot(){return this.passes.some(t=>t.needsUpdate)}It(){return this.passes.reduce((t,i)=>Math.max(t,i.padding),0)}_t(t,i,s){this.xt.paddingHorizontal=s/t,this.xt.paddingVertical=s/i}Ft(){const t=this.kt;this.kt=this.Mt,this.Mt=t}}class Jt{constructor(t){this.ft=t}get passes(){return this.ft.passes}}var Kt,Zt,ti,ii,si,hi,ri,ni,ei,oi;(t=>{t.CLICK="click"})(hi||(hi={}));class ai extends _t{constructor(i,s,h,r,n,e){super(),this.layer=i,this.object=s,this[Kt]=new B("x"),this[Zt]=new B("y"),this[ti]=new B("width"),this[ii]=new B("height"),this[si]=!1,this.name=t.generateUUID(),this.microInternal=new Ht,this.composerInternal=new Qt,this.modeInternal=jt.VISIBLE,this.micro=new Lt(this.microInternal,this),this.composer=new Jt(this.composerInternal),this.object.matrixAutoUpdate=!1,this.layer[J](this,this.object),this.layer[ht](this,this[W],Et(pt.P7)),this.layer[ht](this,this[q],Et(pt.P7)),this.layer[ht](this,this[G],Et(pt.P5)),this.layer[ht](this,this[Q],Et(pt.P5)),this[W].setValue(h),this[q].setValue(r),this[G].setValue(n),this[Q].setValue(e),this.layer[nt](this,this[W],h),this.layer[nt](this,this[q],r),this.layer[nt](this,this[G],n),this.layer[nt](this,this[Q],e)}get x(){return this[W].value()}get y(){return this[q].value()}get width(){return this[G].value()}get height(){return this[Q].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[at]}set x(t){this.layer[nt](this,this[W],t)}set y(t){this.layer[nt](this,this[q],t)}set width(t){this.layer[nt](this,this[G],t)}set height(t){this.layer[nt](this,this[Q],t)}set zIndex(t){this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[dt](),this.object.updateMatrix())}set mode(t){this.modeInternal=t,this.object.visible=t!==jt.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[rt](this,this[Q]),this.layer[rt](this,this[G]),this.layer[rt](this,this[q]),this.layer[rt](this,this[W]),this.layer[K](this)}[(Kt=W,Zt=q,ti=G,ii=Q,si=at,ct)](t,i){this.render(t,i)}[ut](t,i){return this.click(t,i)}applyTransformations(){(this[at]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,h,r,n,e)=>{const o=this.x-e,a=this.y-e,c=this.width+2*e,u=this.height+2*e,d=o+c*i.anchorX,f=a+u*i.anchorY,l=$t.set(1,0,-d,0,1,-f,0,0,1),w=Pt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),v=Ut.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=zt.set(1,0,i.x+d,0,1,i.y+f,0,0,1),p=Dt.multiplyMatrices(g,v).multiply(w).multiply(l),m=Vt.set(o,a,1).applyMatrix3(p);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=c*i.scaleX,t.scale.y=u*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this.object.updateMatrix(),this[at]=!1,this.microInternal.needsRecalculation=!1)}click(t,i){return this.mode===jt.INTERACTIVE&&(this.applyTransformations(),s=this.x,h=this.y,r=this.width,n=this.height,At.set(t,i),Bt.min.set(s,h),Bt.max.set(r,n).add(Bt.min),!!Bt.containsPoint(At)&&(this.emit(hi.CLICK,this),!0));var s,h,r,n}}const ci=new e(0);var ui,di,fi;(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.CLICK="click"})(ui||(ui={}));class li extends _t{constructor(){super(...arguments),this.mode=jt.VISIBLE,this[ri]=new B,this[ni]=new B,this[ei]=new B,this[oi]=new B,this.scene=new m,this.camera=new b,this.solver=new L,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=ft.PORTRAIT,this.needsRecalculation=!1}get orientation(){return this.orientationPrivate}get width(){return this[G].value()}get height(){return this[Q].value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(ri=W,ni=q,ei=G,oi=Q,J)](t,i,s){if(this.elements.has(t))throw Error("Element already added");if(this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i){const t=s??this.scene.children.length;i.position.z=t,i.renderOrder=t,this.scene.add(i),this[dt]()}}[K](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),i.object&&this.scene.remove(i.object)}[Z](t,i){if(this.constraints.has(t))throw Error("Constraint already added");for(const s of i){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(i.constraints.has(t))throw Error("Something went wrong");i.constraints.add(t)}this.constraints.set(t,{elements:i,variables:new Map,constraints:new Set})}[tt](t){const i=this.constraints.get(t);if(void 0===i)throw Error("Constraint not found");if(i.variables.size>0)throw Error("Variables should be removed before removing constraint");if(i.constraints.size>0)throw Error("Constraints should be removed before removing constraint");for(const s of i.elements){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(!i.constraints.has(t))throw Error("Something went wrong");i.constraints.delete(t)}this.constraints.delete(t)}[it](t,i){const s=this.constraints.get(t);if(void 0===s)throw Error("Before adding constraint you need to add it's owner");if(s.constraints.has(i))throw Error("Constraint already exists");s.constraints.add(i);try{this.solver?.addConstraint(i)}catch{this.At()}this.needsRecalculation=!0}[st](t,i){const s=this.constraints.get(t);if(void 0===s)throw Error("Before removing constraint you need to add it's owner");if(!s.constraints.has(i))throw Error("Constraint not found");s.constraints.delete(i);try{this.solver?.removeConstraint(i)}catch{this.At()}this.needsRecalculation=!0}[ht](t,i,s){const h=t instanceof ai||t instanceof Ft?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before adding variable you need to add it's owner");if(h.variables.has(i))throw Error("Variable already exists");h.variables.set(i,{strength:s,suggestedValue:i.value()});try{this.solver?.addEditVariable(i,s)}catch{this.At()}this.needsRecalculation=!0}[rt](t,i){const s=t instanceof ai||t instanceof Ft?this.elements.get(t):this.constraints.get(t);if(void 0===s)throw Error("Before removing variable you need to add it's owner");if(!s.variables.has(i))throw Error("Variable does not exist");s.variables.delete(i);try{this.solver?.removeEditVariable(i)}catch{this.At()}this.needsRecalculation=!0}[nt](t,i,s){const h=t instanceof ai||t instanceof Ft?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before suggesting variable you need to add it's owner");const r=h.variables.get(i);if(!r)throw Error("Variable does not exist");if(r.suggestedValue!==s){r.suggestedValue=s;try{this.solver?.suggestValue(i,s)}catch{this.At()}this.needsRecalculation=!0}}[dt](){this.scene.children.sort((t,i)=>t.position.z-i.position.z);for(let t=0;this.scene.children.length>t;t++){const i=this.scene.children[t];i.position.z=t,i.renderOrder=t}this.camera.position.set(0,0,this.scene.children.length+1),this.camera.near=1,this.camera.far=this.scene.children.length+1+1,this.camera.updateProjectionMatrix(),this.camera.updateMatrix()}render(t,i){if(this.mode===jt.HIDDEN)return;const s=t.getRenderTarget(),h=t.getClearColor(ci),r=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=!1,this.solver?.updateVariables();for(const t of this.elements.keys())t[at]=!0}for(const s of this.elements.keys())s[ct](t,i);t.setRenderTarget(s),t.setClearColor(h),t.setClearAlpha(r),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==jt.INTERACTIVE)return;this.emit(ui.CLICK,this,t,i);const s=[...this.elements.keys()].filter(t=>t instanceof ai).filter(t=>t.mode===jt.INTERACTIVE).sort((t,i)=>t.zIndex-i.zIndex);for(const h of s)if(h[ut](t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=!0}applyCameraSize(t,i){this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){this.constraintX&&(this.solver?.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(this.solver?.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(this.solver?.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(this.solver?.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new R(new P(this[W]),z.Eq,0,D.required),this.constraintY=new R(new P(this[q]),z.Eq,0,D.required),this.constraintW=new R(new P(this[G]),z.Eq,t,D.required),this.constraintH=new R(new P(this[Q]),z.Eq,i,D.required),this.solver?.addConstraint(this.constraintX),this.solver?.addConstraint(this.constraintY),this.solver?.addConstraint(this.constraintW),this.solver?.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?ft.LANDSCAPE:ft.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t[ot](this.orientationPrivate);for(const t of this.constraints.keys())t[et](this.orientationPrivate);this.solver=new L;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i);this.emit(ui.ORIENTATION_CHANGED,this,this.orientation)}}At(){try{this.solver=void 0,this.solver=new L;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i)}catch(t){throw t}}}function wi(t,i){if((t instanceof li?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function vi(t,i,s){if(0>=t||0>=i)throw Error(s??`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class gi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai||t instanceof Ft?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={anchorOne:s?.anchorOne??.5,anchorTwo:s?.anchorTwo??.5,distance:s?.distance??0,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=this.Bt instanceof ai||this.Bt instanceof li?new P(this.Bt[W]).plus(new P(this.Bt[G]).multiply(this.Pt.anchorOne)):new P(this.Bt[W]),i=this.$t instanceof ai?new P(this.$t[W]).plus(new P(this.$t[G]).multiply(this.Pt.anchorTwo)):new P(this.$t[W]);this.ut=new R(i.minus(t),Tt(this.Pt.rule),this.Pt.distance,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class pi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={proportion:s?.proportion??1,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=new P(this.Bt[G]).multiply(this.Pt.proportion),i=new P(this.$t[G]);this.ut=new R(t.minus(i),Tt(this.Pt.rule),0,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class mi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai||t instanceof Ft?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={anchorOne:s?.anchorOne??.5,anchorTwo:s?.anchorTwo??.5,distance:s?.distance??0,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=this.Bt instanceof ai||this.Bt instanceof li?new P(this.Bt[q]).plus(new P(this.Bt[Q]).multiply(this.Pt.anchorOne)):new P(this.Bt[q]),i=this.$t instanceof ai?new P(this.$t[q]).plus(new P(this.$t[Q]).multiply(this.Pt.anchorTwo)):new P(this.$t[q]);this.ut=new R(i.minus(t),Tt(this.Pt.rule),this.Pt.distance,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class yi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={proportion:s?.proportion??1,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=new P(this.Bt[Q]).multiply(this.Pt.proportion),i=new P(this.$t[Q]);this.ut=new R(t.minus(i),Tt(this.Pt.rule),0,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class bi extends vt{constructor(t,i){super(t.layer,new Set([t])),this.ot=t,this.ct={width:i?.width??t.width,power:St(i?.power),rule:Mt(i?.rule),orientation:wt(i?.orientation)},this.ct.orientation!==ft.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.ct.orientation!==ft.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}[ot](t){this.ct.orientation!==ft.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.ut=new R(new P(this.ot[G]),Tt(this.ct.rule),this.ct.width,Et(this.ct.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class xi{static size(t,i={}){return{x:new bi(t,{width:i.size?.x,power:i.power?.x,rule:i.rule?.x,orientation:i.orientation?.x}),y:new Ot(t,{height:i.size?.y,power:i.power?.y,rule:i.rule?.y,orientation:i.orientation?.y})}}static distance(t,i,s={}){return{x:new gi(t,i,{anchorOne:s.anchorOne?.x,anchorTwo:s.anchorTwo?.x,distance:s.distance?.x,power:s.power?.x,rule:s.rule?.x,orientation:s.orientation?.x}),y:new mi(t,i,{anchorOne:s.anchorOne?.y,anchorTwo:s.anchorTwo?.y,distance:s.distance?.y,power:s.power?.y,rule:s.rule?.y,orientation:s.orientation?.y})}}static proportion(t,i,s={}){return{x:new pi(t,i,{proportion:s.proportion?.x,power:s.power?.x,rule:s.rule?.x,orientation:s.orientation?.x}),y:new yi(t,i,{proportion:s.proportion?.y,power:s.power?.y,rule:s.rule?.y,orientation:s.orientation?.y})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(di||(di={}));class Ci{static build(t,i,s,h={}){const r=h.direction??di.FROM_LEFT_TOP,n=[],e=[];n.push(new gi(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:h.power,orientation:h.orientation}),new gi(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:h.power,orientation:h.orientation}));const o=r===di.FROM_LEFT_TOP?1:0,a=r===di.FROM_LEFT_TOP?0:1;return e.push(new mi(t,i,{anchorOne:o,anchorTwo:o,distance:0,power:h.power,orientation:h.orientation}),new mi(t,s,{anchorOne:a,anchorTwo:a,distance:0,power:h.power,orientation:h.orientation})),{horizontalDistances:n,verticalDistances:e}}}class Si{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:gi,proportionConstraint:pi,centerDistanceConstraint:mi})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:mi,proportionConstraint:yi,centerDistanceConstraint:gi})}static buildStack(t,i,s){const h=[],r=[],n=[];for(let e=0;t.length-1>e;e++){const o=t[e],a=t[e+1];h.push(new s.distanceConstraint(o,a,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),!1!==i.keepProportions&&r.push(new s.proportionConstraint(o,a,{power:i.power,orientation:i.orientation})),!1!==i.keepAlignment&&n.push(new s.centerDistanceConstraint(o,a,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:h,proportionConstraints:r,alignmentConstraints:n}}}class Ei extends vt{constructor(t,i){super(t.layer,new Set([t])),this.ot=t,this.Pt={aspect:i?.aspect??this.ot.width/this.ot.height,power:St(i?.power),rule:Mt(i?.rule),orientation:wt(i?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=new P(this.ot[G]).plus(new P(this.ot[Q]).multiply(-this.Pt.aspect));this.ut=new R(t,Tt(this.Pt.rule),0,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class ki extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={isStrict:s?.isStrict??!0,horizontalAnchor:s?.horizontalAnchor??.5,verticalAnchor:s?.verticalAnchor??.5,orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){this.Ut=new R(new P(this.Bt[W]).plus(new P(this.Bt[G]).multiply(this.Pt.horizontalAnchor)),z.Eq,new P(this.$t[W]).plus(new P(this.$t[G]).multiply(this.Pt.horizontalAnchor))),this.zt=new R(new P(this.Bt[q]).plus(new P(this.Bt[Q]).multiply(this.Pt.verticalAnchor)),z.Eq,new P(this.$t[q]).plus(new P(this.$t[Q]).multiply(this.Pt.verticalAnchor))),this.Dt=new R(new P(this.Bt[G]),z.Le,new P(this.$t[G])),this.Vt=new R(new P(this.Bt[Q]),z.Le,new P(this.$t[Q])),this.layer[it](this,this.Ut),this.layer[it](this,this.zt),this.layer[it](this,this.Dt),this.layer[it](this,this.Vt),this.Pt.isStrict||(this.Rt=new R(new P(this.Bt[Q]),z.Eq,new P(this.$t[Q]),D.strong),this.layer[it](this,this.Rt))}destroyConstraints(){this.Ut&&(this.layer[st](this,this.Ut),this.Ut=void 0),this.zt&&(this.layer[st](this,this.zt),this.zt=void 0),this.Dt&&(this.layer[st](this,this.Dt),this.Dt=void 0),this.Vt&&(this.layer[st](this,this.Vt),this.Vt=void 0),this.Rt&&(this.layer[st](this,this.Rt),this.Rt=void 0)}}class Mi extends vt{constructor(t,i,s){super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,wi(t,i),this.Pt={isStrict:s?.isStrict??!0,horizontalAnchor:s?.horizontalAnchor??.5,verticalAnchor:s?.verticalAnchor??.5,orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){this.Ut=new R(new P(this.Bt[W]).plus(new P(this.Bt[G]).multiply(this.Pt.horizontalAnchor)),z.Eq,new P(this.$t[W]).plus(new P(this.$t[G]).multiply(this.Pt.horizontalAnchor))),this.zt=new R(new P(this.Bt[q]).plus(new P(this.Bt[Q]).multiply(this.Pt.verticalAnchor)),z.Eq,new P(this.$t[q]).plus(new P(this.$t[Q]).multiply(this.Pt.verticalAnchor))),this.Dt=new R(new P(this.Bt[G]),z.Ge,new P(this.$t[G])),this.Vt=new R(new P(this.Bt[Q]),z.Ge,new P(this.$t[Q])),this.layer[it](this,this.Ut),this.layer[it](this,this.zt),this.layer[it](this,this.Dt),this.layer[it](this,this.Vt),!1!==this.Pt.isStrict&&(this.Rt=new R(new P(this.Bt[Q]),z.Eq,new P(this.$t[Q]),D.strong),this.layer[it](this,this.Rt))}destroyConstraints(){this.Ut&&(this.layer[st](this,this.Ut),this.Ut=void 0),this.zt&&(this.layer[st](this,this.zt),this.zt=void 0),this.Dt&&(this.layer[st](this,this.Dt),this.Dt=void 0),this.Vt&&(this.layer[st](this,this.Vt),this.Vt=void 0),this.Rt&&(this.layer[st](this,this.Rt),this.Rt=void 0)}}class Ti extends ai{constructor(t,i=100,s=100){super(t,new M,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class Oi extends ai{constructor(t,i){const s=i.image?.width,h=i.image?.height;vi(s,h,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${s}) or height (${h}). Image dimensions must be non-zero positive numbers.`);const r=new Xt(i);super(t,new y(Yt,r),0,0,s,h),this.Ht=Nt.NORMAL,this.Lt=r,this.jt=i,this.applyTransformations()}get texture(){return this.jt}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}get blending(){return this.Ht}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set blending(t){this.Ht=t,this.Lt.setBlending(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.jt.image.width,this.jt.image.height,this.Lt),this.applyTransformations()}}class Ii extends n{constructor(t,i){super({uniforms:T.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new e(1,1,1)},foregroundColor:{value:new e(1,1,1)},color:{value:new e(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},opacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}getProgress(){return this.uniforms.progress.value}getBackgroundTexture(){return this.uniforms.background.value}getForegroundTexture(){return this.uniforms.foreground.value}getBackgroundColor(){return this.uniforms.color.value.getHex()}getForegroundColor(){return this.uniforms.color.value.getHex()}getColor(){return this.uniforms.color.value.getHex()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.value}getOpacity(){return this.uniforms.opacity.value}getAngle(){return this.uniforms.angle.value}getIsForwardDirection(){return 1===this.uniforms.direction.value}setProgress(t){this.uniforms.progress.value=t,this.uniformsNeedUpdate=!0}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=!0}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=!0}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=!0}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=!0}}class _i extends ai{constructor(i,s,h={}){const r=s.image?.width,n=s.image?.height;vi(r,n,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${r}) or height (${n}). Image dimensions must be non-zero positive numbers.`);const e=h.textureBackground?.image?.width,o=h.textureBackground?.image?.height;h.textureBackground&&vi(e,o,`Invalid image dimensions - texture "${h.textureBackground.name||"unnamed"}" has invalid width (${e}) or height (${o}). Image dimensions must be non-zero positive numbers.`);const a=new Ii(s,h.textureBackground),c=new y(Yt,a);h.progress&&a.setProgress(h.progress),h.isForegroundDirection&&a.setIsForwardDirection(h.isForegroundDirection),h.angle&&a.setAngle(t.degToRad(h.angle)),h.color&&a.setColor(h.color),h.opacity&&a.setOpacity(h.opacity),h.backgroundColor&&a.setBackgroundColor(h.backgroundColor),h.foregroundColor&&a.setForegroundColor(h.foregroundColor),h.backgroundOpacity&&a.setBackgroundOpacity(h.backgroundOpacity),h.foregroundOpacity&&a.setForegroundOpacity(h.foregroundOpacity);const u=e??r,d=n??o;super(i,c,0,0,u,d),this.Lt=a,this.Nt=u,this.Xt=d,this.applyTransformations()}get progress(){return this.Lt.getProgress()}get backgroundTexture(){return this.Lt.getBackgroundTexture()}get foregroundTexture(){return this.Lt.getForegroundTexture()}get backgroundColor(){return this.Lt.getBackgroundColor()}get foregroundColor(){return this.Lt.getForegroundColor()}get color(){return this.Lt.getColor()}get backgroundOpacity(){return this.Lt.getBackgroundOpacity()}get foregroundOpacity(){return this.Lt.getForegroundOpacity()}get opacity(){return this.Lt.getOpacity()}get angle(){return t.radToDeg(this.Lt.getAngle())}get isForwardDirection(){return this.Lt.getIsForwardDirection()}set progress(t){this.Lt.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.Lt.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.Lt.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.Lt.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.Lt.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set angle(i){this.Lt.setAngle(t.degToRad(i)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.Lt.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.Nt,this.Xt,this.Lt),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(fi||(fi={}));const Fi=fi.PROPERTY_CHANGED;class Ai extends ai{constructor(t,i={}){const s=i.resolutionFactor??.5;if(.1>s||s>8)throw Error(`Invalid resolution factor: ${s}. Must be between 0.1 and 8.`);const h=i.width??512,r=i.height??512;vi(h,r,`Invalid width or height: ${h}x${r}. Must be positive.`);const n=new x(h*s,r*s,{format:E,minFilter:S,magFilter:S,type:C,depthBuffer:i.useDepth??!0,stencilBuffer:!1}),e=new Xt(n.texture);super(t,new y(Yt,e),0,0,h,r),this.Yt=!1,this.Wt=i.scene??new m,this.qt=i.camera??new O(75,h/r,.1,100),this.Gt=s,this.Qt=i.updateBehavior??Fi,i.renderedByDefault&&(this.Yt=!0),this.Jt=i.clearColor??0,this.Kt=i.clearAlpha??0,this.Zt=n,this.Lt=e,this.applyTransformations()}get needsRender(){return this.Yt}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}get scene(){return this.Wt}get camera(){return this.qt}get clearColor(){return this.Jt}get clearAlpha(){return this.Kt}get resolutionFactor(){return this.Gt}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.Wt!==t&&(this.Wt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.qt!==t&&(this.qt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.Jt!==t&&(this.Jt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.Kt!==t&&(this.Kt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set resolutionFactor(t){this.Gt!==t&&(this.Gt=t,this.Zt.setSize(this.width*this.Gt,this.height*this.Gt),this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}destroy(){this.Lt.dispose(),this.Zt.dispose(),super.destroy()}requestRender(){this.Yt=!0,this.composerInternal.requestUpdate()}render(t){(this.Yt||this.Qt===fi.ALWAYS)&&(this.Yt=!1,this.Zt.setSize(this.width*this.Gt,this.height*this.Gt),t.setClearColor(this.Jt,this.clearAlpha),t.setRenderTarget(this.Zt),t.clear(!0,!0,!1),t.render(this.Wt,this.qt)),this.object.material=this.composerInternal.compose(t,this.width*this.Gt,this.height*this.Gt,this.Lt),this.applyTransformations()}}function Bi(t,i){const s=Math.max(t?.fontSize??i?.fontSize??16,1),h=t?.lineHeight??i?.lineHeight??1.2*s,r=Math.max(t?.shadowBlur??i?.shadowBlur??0,0),n=Math.max(t?.strokeWidth??i?.strokeWidth??0,0);return{color:t?.color??i?.color??"#000000",fontFamily:t?.fontFamily??i?.fontFamily??"Arial",fontSize:s,fontStyle:t?.fontStyle??i?.fontStyle??"normal",fontWeight:t?.fontWeight??i?.fontWeight??"normal",lineHeight:h,enableShadow:t?.enableShadow??i?.enableShadow??!1,shadowOffsetX:t?.shadowOffsetX??i?.shadowOffsetX??0,shadowOffsetY:t?.shadowOffsetY??i?.shadowOffsetY??0,shadowBlur:r,shadowColor:t?.shadowColor??i?.shadowColor??"transparent",enableStroke:t?.enableStroke??i?.enableStroke??!1,strokeColor:t?.strokeColor??i?.strokeColor??"transparent",strokeWidth:n}}function $i(t){return t.match(/\S+|\s|\n/g)||[]}function Pi(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const h=t.measureText(i),r=h.width,n=Math.ceil(h.actualBoundingBoxAscent+h.actualBoundingBoxDescent);return{width:Math.ceil(r),height:n,baseline:h.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ui(t,i,s,h,r){r.font=`${h.fontStyle} ${h.fontWeight} ${h.fontSize}px ${h.fontFamily}`,h.enableShadow&&(r.shadowOffsetX=h.shadowOffsetX,r.shadowOffsetY=h.shadowOffsetY,r.shadowBlur=h.shadowBlur,r.shadowColor=h.shadowColor),h.enableStroke&&(r.strokeStyle=h.strokeColor,r.lineWidth=h.strokeWidth,r.strokeText(s,t,i)),r.fillStyle=h.color,r.fillText(s,t,i)}class zi extends ai{constructor(t,i,s={}){const h=document.createElement("canvas"),r=h.getContext("2d");if(!r)throw Error("Failed to create canvas context");const n=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,h=i?t:t.text,e=Bi(i?void 0:t.style,s.defaultStyle);for(const t of $i(h)){const i=Pi(r,t,e);n.push({text:t,style:e,metrics:i})}}const o=((t,i)=>{const s=[];let h=[],r=0,n=0,e=0,o=0;for(const a of i)"\n"!==a.text?r+a.metrics.width>t&&0!==h.length?(s.push({chunks:h,width:r,height:n,baseline:e,lineHeight:o}),h=[a],r=a.metrics.width,n=a.metrics.height,e=a.metrics.baseline,o=a.metrics.lineHeight):(h.push(a),r+=a.metrics.width,n=Math.max(n,a.metrics.height),e=Math.max(e,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(h.length>0&&s.push({chunks:h,width:r,height:n,baseline:e,lineHeight:o}),h=[],r=0,n=0,e=0,o=0);return h.length>0&&s.push({chunks:h,width:r,height:n,baseline:e,lineHeight:o}),s})(s.maxWidth??1024,n),a=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let s=0;for(let i=0;t.length>i;i++){const h=t[i];s+=0===i?h.height:h.lineHeight,i===t.length-1&&(s+=h.baseline)}return{width:i,height:s}})(o),c=(t=>"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(t?.left??0,0),right:Math.max(t?.right??0,0),top:Math.max(t?.top??0,0),bottom:Math.max(t?.bottom??0,0)})(s.padding);h.width=a.width+c.left+c.right,h.height=a.height+c.top+c.bottom;const u=new I(h),d=new Xt(u);super(t,new y(Yt,d),0,0,a.width,a.height),this.ti=0,this.Lt=d,this.ii=u,this.si=h,this.hi=r,this.ri=a,this.ni=c,((t,i,s,h)=>{let r=this.ni.top;for(let t=0;s.length>t;t++){const n=s[t];let e=i;r+=0===t?n.height:n.lineHeight;for(const t of n.chunks)Ui(e,r,t.text,t.style,h),e+=t.metrics.width}})(0,this.ni.left,o,this.hi),this.ii.needsUpdate=!0,this.applyTransformations()}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),this.ii.dispose(),this.si.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.ti!==t&&(this.ti=t,this.height=this.width/((this.ri.width+this.ni.left+this.ni.right)/(this.ri.height+this.ni.top+this.ni.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.ii.image.width,this.ii.image.height,this.Lt),this.applyTransformations()}}class Di extends li{constructor(){super(),this.ei=1920,this.oi=()=>{const t=this.ai();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.ci=t=>{if(this.mode!==jt.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,h=i?i.bottom-t.clientY:window.innerHeight-t.clientY,r=this.ai();this.clickInternal(s*r,h*r)},window.addEventListener("resize",this.oi),window.addEventListener("pointerdown",this.ci),this.oi()}get tergetScreenHeight(){return this.ei}set tergetScreenHeight(t){this.ei=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.oi),window.removeEventListener("pointerdown",this.ci),super.destroy()}render(t,i){t.clear(!1,!0,!0),super.render(t,i)}ai(){return(this.tergetScreenHeight??window.innerHeight)/window.innerHeight}}function Vi(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}class Ri{}export{Ft as UIAnchor,Ei as UIAspectConstraint,Nt as UIBlending,vt as UIConstraint,xi as UIConstraint2DBuilder,Ci as UIConstraintContainerBuilder,di as UIConstraintContainerDirection,pt as UIConstraintPower,mt as UIConstraintRule,Si as UIConstraintStackBuilder,ki as UICoverConstraint,Ti as UIDummy,ai as UIElement,hi as UIElementEvent,Mi as UIFitConstraint,Di as UIFullScreenLayer,Gt as UIFullScreenQuad,Ot as UIHeightConstraint,gi as UIHorizontalDistanceConstraint,pi as UIHorizontalProportionConstraint,Oi as UIImage,li as UILayer,ui as UILayerEvent,jt as UIMode,ft as UIOrientation,Ri as UIPass,_i as UIProgress,Ai as UIScene,fi as UISceneUpdateMode,zi as UIText,mi as UIVerticalDistanceConstraint,yi as UIVerticalProportionConstraint,bi as UIWidthConstraint,it as addConstraintSymbol,Z as addUIConstraintSymbol,J as addUIElementSymbol,ht as addVariableSymbol,ut as clickSymbol,Et as convertPowerToStrength,Tt as convertRuleToOperator,et as disableConstraintSymbol,ot as enableConstraintSymbol,Q as heightSymbol,Ct as isUIConstraintPower,kt as isUIConstraintRule,lt as isUIOrientation,Vi as isUITextSpan,at as needsRecalculation,st as removeConstraintSymbol,tt as removeUIConstraintSymbol,K as removeUIElementSymbol,rt as removeVariableSymbol,ct as renderSymbol,wt as resolveOrientation,St as resolvePower,Mt as resolveRule,dt as sortSymbol,nt as suggestVariableSymbol,G as widthSymbol,W as xSymbol,q as ySymbol};
1
+ import{Scene as t,OrthographicCamera as i,MathUtils as s,ShaderMaterial as e,Color as r,PlaneGeometry as n,Mesh as h,UniformsUtils as o,WebGLRenderTarget as a,UnsignedByteType as u,LinearFilter as l,RGBAFormat as c,PerspectiveCamera as d,CanvasTexture as f}from"three";class g{constructor(t=0,i){this.constant=t,this._=i?new Map(i):new Map}static plus(t,i){const s=new g(t.constant+i.constant,Array.from(t._.entries()));for(const[t,e]of i._)s.plus(t,e);return s}static minus(t,i){const s=new g(t.constant-i.constant,Array.from(t._.entries()));for(const[t,e]of i._)s.minus(t,e);return s}plus(t,i){return this._.set(t,(this._.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,s]of this._)this._.set(i,s*t);return this}divide(t){return this.multiply(1/t)}hasTerm(t){return this._.has(t)}copy(t){this.constant=t.constant,this._.clear();for(const[i,s]of t._)this._.set(i,s);return this}clone(){return new g(this.constant,Array.from(this._.entries()))}prepareTermsInternal(){return Array.from(this._.entries())}}class p{constructor(t,i,s=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,s):this.t.set(i,new Map([[t,s]])))}insert(t,i,s=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,s)}const e=this.t.get(i);void 0===e?this.t.set(i,new Map([[t,s]])):e.has(t)||e.set(t,s)}remove(t,i){if(void 0===i)return void this.i.delete(t);const s=this.t.get(i);void 0!==s&&(s.delete(t),0===s.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const s=this.t.get(i);return void 0!==s&&s.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const s=this.t.get(i);return void 0!==s?s.get(t):void 0}}class w{constructor(){this.o=new Map}on(t,i,s,e=0){return this.h(t,!1,e,i,s),this}once(t,i,s,e=0){return this.h(t,!0,e,i,s),this}off(t,i,s){const e=this.o.get(t);if(void 0===e)return this;e.u&&(e.u=!1,e.v=e.v.slice());const r=e.v;if(0===r.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;r.length>t;t++){const i=r[t];e.l.remove(i.C,i.p)}return this}{const n=r.length;if(r[0].C===i&&r[0].p===s)return 1===n?this.o.delete(t):r.shift(),this;const h=n-1;if(r[h].C===i&&r[h].p===s)return r.pop(),this;if(10>n||r[0].M===r[h].M)for(let t=1;h>t;t++){const e=r[t];if(e.C===i&&e.p===s)return r.splice(t,1),this}else{const t=e.l.getPriority(i,s);if(void 0===t)return this;let n=0,h=r.length-1;for(;h>=n;){const i=n+h>>>1;t>r[i].M?n=i+1:h=i-1}const o=n;for(h=r.length-1;h>=n;){const i=n+h>>>1;r[i].M>t?h=i-1:n=i+1}const a=h;for(let t=o;a>=t;t++)if(r[t].C===i&&r[t].p===s)return r.splice(t,1),this}}return this}emit(t,...i){const s=this.o.get(t);if(void 0===s)return!1;if(0===s.v.length)return!1;s.u?s.v=s.v.slice():s.u=!0;const e=s.v;let r=!1;for(let t=0;e.length>t;t++){const s=e[t];s.C.apply(s.p,i),s.k&&(r=!0,s.m=!0)}const n=this.o.get(t);if(void 0===n)return!0;n.v===e&&(n.u=!1);const h=n.v;if(r){let i=0;for(let t=0;h.length>t;t++){const s=h[t];s.m?n.l.remove(s.C,s.p):h[i++]=s}0===i?this.o.delete(t):h.length=i}return!0}h(t,i,s,e,r){let n=this.o.get(t);if(void 0===n)return void this.o.set(t,{v:[{C:e,p:r,M:s,k:i,m:!1}],u:!1,l:new p(e,r,s)});if(n.l.has(e,r))throw Error("Event listener already exists");n.l.insert(e,r,s);const h={C:e,p:r,M:s,k:i,m:!1};n.u&&(n.u=!1,n.v=n.v.slice());{const t=n.v,i=h.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(h);if(t[0].M>=i)return void t.unshift(h);{let s=0,e=t.length;for(;e>s;){const r=s+e>>>1;i>t[r].M?s=r+1:e=r}t.splice(s,0,h)}}}}var v,m;function y(t){return t??m.ALWAYS}function b(){return new x}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(v||(v={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(m||(m={}));class x{index={};array=[];size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const s=this.index[t.id()];if(void 0===s){const s=new E(t,i());return this.index[t.id()]=this.array.length,this.array.push(s),s}return this.array[s]}insert(t,i){const s=new E(t,i),e=this.index[t.id()];return void 0===e?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[e]=s,s}erase(t){const i=this.index[t.id()];if(void 0===i)return;this.index[t.id()]=void 0;const s=this.array[i],e=this.array.pop();return s!==e&&(this.array[i]=e,this.index[e.first.id()]=i),s}copy(){const t=new x;for(let i=0;this.array.length>i;i++){const s=this.array[i].copy();t.array[i]=s,t.index[s.first.id()]=i}return t}}class E{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new E(this.first,this.second)}}class _{constructor(t=""){this.I=t}id(){return this.S}name(){return this.I}setName(t){this.I=t}context(){return this.U}setContext(t){this.U=t}value(){return this.A}setValue(t){this.A=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.I,value:this.A}}toString(){return this.U+"["+this.I+":"+this.A+"]"}I;A=0;U=null;S=C++}let C=0;class I{constructor(){let t=(t=>{let i=0,s=()=>0,e=b();for(let r=0,n=t.length;n>r;++r){let n=t[r];if("number"==typeof n)i+=n;else if(n instanceof _)e.setDefault(n,s).second+=1;else if(n instanceof I){i+=n.constant();let t=n.terms();for(let i=0,r=t.size();r>i;i++){let r=t.itemAt(i);e.setDefault(r.first,s).second+=r.second}}else{if(!(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 _)e.setDefault(r,s).second+=t;else{if(!(r instanceof I))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);e.setDefault(r.first,s).second+=r.second*t}}}}}}return{terms:e,constant:i}})(arguments);this.T=t.terms,this.V=t.constant}terms(){return this.T}constant(){return this.V}value(){let t=this.V;for(let i=0,s=this.T.size();s>i;i++){let s=this.T.itemAt(i);t+=s.first.value()*s.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.T.size()}toString(){let t=this.T.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.V||(t+=" + "),t+=this.V,t}T;V}class k{static create(t,i,s,e=1){let r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*e)),r+=1e3*Math.max(0,Math.min(1e3,i*e)),r+=Math.max(0,Math.min(1e3,s*e)),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 M;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(M||(M={}));class S{constructor(t,i,s,e=k.required){this.F=i,this.O=k.clip(e),this.P=void 0===s&&t instanceof I?t:t.minus(s)}id(){return this.S}expression(){return this.P}op(){return this.F}strength(){return this.O}toString(){return this.P+" "+["<=",">=","="][this.F]+" 0 ("+this.O+")"}P;F;O;S=U++}let U=0;class A{maxIterations=1e3;constructor(){}createConstraint(t,i,s,e=k.required){let r=new S(t,i,s,e);return this.addConstraint(r),r}addConstraint(t){if(void 0!==this.H.find(t))throw Error("duplicate constraint");let i=this.B(t),s=i.row,e=i.tag,r=this.L(s,e);if(r.type()===V.Invalid&&s.allDummies()){if(!T(s.constant()))throw Error("unsatisfiable constraint");r=e.marker}if(r.type()===V.Invalid){if(!this.D(s))throw Error("unsatisfiable constraint")}else s.solveFor(r),this.R(r,s),this.$.insert(r,s);this.H.insert(t,e),this.j(this.N)}removeConstraint(t){let i=this.H.erase(t);if(void 0===i)throw Error("unknown constraint");this.W(t,i.second);let s=i.second.marker,e=this.$.erase(s);if(void 0===e){let t=this.q(s);if(t.type()===V.Invalid)throw Error("failed to find leaving row");e=this.$.erase(t),e.second.solveForEx(t,s),this.R(s,e.second)}this.j(this.N)}hasConstraint(t){return this.H.contains(t)}getConstraints(){return this.H.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 s=new I(t),e=new S(s,M.Eq,void 0,i);this.addConstraint(e);let r=this.H.find(e).second;this.X.insert(t,{tag:r,constraint:e,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 s=this.X.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this.$,r=s.second,n=i-r.constant;r.constant=i;let h=r.tag.marker,o=e.find(h);if(void 0!==o)return 0>o.second.add(-n)&&this.Y.push(h),void this.G();let a=r.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(n)&&this.Y.push(a),void this.G();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t),s=i.second,r=s.coefficientFor(h);0!==r&&0>s.add(n*r)&&i.first.type()!==V.External&&this.Y.push(i.first)}this.G()}updateVariables(){let t=this.Z,i=this.$;for(let s=0,e=t.size();e>s;++s){let e=t.itemAt(s),r=i.find(e.second);e.first.setValue(void 0!==r?r.second.constant():0)}}J(t){return this.Z.setDefault(t,()=>this.K(V.External)).second}B(t){let i=t.expression(),s=new P(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!T(i.second)){let t=this.J(i.first),e=this.$.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let r=this.N,n=t.strength(),h={marker:O,other:O};switch(t.op()){case M.Le:case M.Ge:{let i=t.op()===M.Le?1:-1,e=this.K(V.Slack);if(h.marker=e,s.insertSymbol(e,i),k.required>n){let t=this.K(V.Error);h.other=t,s.insertSymbol(t,-i),r.insertSymbol(t,n)}break}case M.Eq:if(k.required>n){let t=this.K(V.Error),i=this.K(V.Error);h.marker=t,h.other=i,s.insertSymbol(t,-1),s.insertSymbol(i,1),r.insertSymbol(t,n),r.insertSymbol(i,n)}else{let t=this.K(V.Dummy);h.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:h}}L(t,i){let s=t.cells();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t);if(i.first.type()===V.External)return i.first}let e=i.marker.type();return e!==V.Slack&&e!==V.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==V.Slack&&e!==V.Error||t.coefficientFor(i.other)>=0?O:i.other):i.marker}D(t){let i=this.K(V.Slack);this.$.insert(i,t.copy()),this.tt=t.copy(),this.j(this.tt);let s=T(this.tt.constant());this.tt=null;let e=this.$.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let r=this.it(t);if(r.type()===V.Invalid)return!1;t.solveForEx(i,r),this.R(r,t),this.$.insert(r,t)}let r=this.$;for(let t=0,s=r.size();s>t;++t)r.itemAt(t).second.removeSymbol(i);return this.N.removeSymbol(i),s}R(t,i){let s=this.$;for(let e=0,r=s.size();r>e;++e){let r=s.itemAt(e);r.second.substitute(t,i),0>r.second.constant()&&r.first.type()!==V.External&&this.Y.push(r.first)}this.N.substitute(t,i),this.tt&&this.tt.substitute(t,i)}j(t){let i=0;for(;this.maxIterations>i;){let s=this.st(t);if(s.type()===V.Invalid)return;let e=this.et(s);if(e.type()===V.Invalid)throw Error("the objective is unbounded");let r=this.$.erase(e).second;r.solveForEx(e,s),this.R(s,r),this.$.insert(s,r),i++}throw Error("solver iterations exceeded")}G(){let t=this.$,i=this.Y;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this.rt(e.second);if(i.type()===V.Invalid)throw Error("dual optimize failed");let r=e.second;t.erase(s),r.solveForEx(s,i),this.R(i,r),t.insert(i,r)}}}st(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first;if(0>s.second&&e.type()!==V.Dummy)return e}return O}rt(t){let i=Number.MAX_VALUE,s=O,e=t.cells();for(let t=0,r=e.size();r>t;++t){let r=e.itemAt(t),n=r.first,h=r.second;if(h>0&&n.type()!==V.Dummy){let t=this.N.coefficientFor(n)/h;i>t&&(i=t,s=n)}}return s}et(t){let i=Number.MAX_VALUE,s=O,e=this.$;for(let r=0,n=e.size();n>r;++r){let n=e.itemAt(r),h=n.first;if(h.type()!==V.External){let e=n.second,r=e.coefficientFor(t);if(0>r){let t=-e.constant()/r;i>t&&(i=t,s=h)}}}return s}q(t){let i=Number.MAX_VALUE,s=i,e=i,r=O,n=r,h=r,o=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)o=c;else if(0>l){let t=-u.constant()/l;s>t&&(s=t,n=c)}else{let t=u.constant()/l;e>t&&(e=t,h=c)}}return n!==r?n:h!==r?h:o}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 s=this.$.find(t);void 0!==s?this.N.insertRow(s.second,-i):this.N.insertSymbol(t,-i)}it(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first.type();if(e===V.Slack||e===V.Error)return s.first}return O}K(t){return new F(t,this.ht++)}H=(()=>b())();$=(()=>b())();Z=(()=>b())();X=(()=>b())();Y=[];N=new P;tt=null;ht=0}function T(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 F{constructor(t,i){this.S=i,this.ot=t}id(){return this.S}type(){return this.ot}S;ot}let O=new F(V.Invalid,-1);class P{constructor(t=0){this.V=t}cells(){return this.ut}constant(){return this.V}isConstant(){return this.ut.empty()}allDummies(){let t=this.ut;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==V.Dummy)return!1;return!0}copy(){let t=new P(this.V);return t.ut=this.ut.copy(),t}add(t){return this.V+=t}insertSymbol(t,i=1){T(this.ut.setDefault(t,()=>0).second+=i)&&this.ut.erase(t)}insertRow(t,i=1){this.V+=t.V*i;let s=t.ut;for(let t=0,e=s.size();e>t;++t){let e=s.itemAt(t);this.insertSymbol(e.first,e.second*i)}}removeSymbol(t){this.ut.erase(t)}reverseSign(){this.V=-this.V;let t=this.ut;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this.ut,s=-1/i.erase(t).second;this.V*=s;for(let t=0,e=i.size();e>t;++t)i.itemAt(t).second*=s}solveForEx(t,i){this.insertSymbol(t,-1),this.solveFor(i)}coefficientFor(t){let i=this.ut.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this.ut.erase(t);void 0!==s&&this.insertRow(i,s.second)}ut=b();V}const H=1e3;var B,L,D,R;function $(t){switch(t){case B.P0:return k.create(H,H,H);case B.P1:return k.create(100,0,0);case B.P2:return k.create(10,0,0);case B.P3:return k.create(0,100,0);case B.P4:return k.create(0,10,0);case B.P5:return k.create(0,0,100);case B.P6:return k.create(0,0,10);case B.P7:return k.create(0,0,1);default:throw Error("Invalid priority: "+t)}}function z(t){return t??B.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"})(B||(B={}));class j{constructor(s,e){this.lt=new t,this.ct=new Map,this.dt=new i(0,s,e,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 s=this.ct.get(t);if(void 0===s)throw Error("Element not found");this.lt.remove(s),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 s=this.ct.get(t);if(void 0===s)throw Error("Element not found");s.renderOrder=i}setVisibility(t,i){const s=this.ct.get(t);if(void 0===s)throw Error("Element not found");s.visible=i}getSortedVisibleElements(){return Array.from(this.ct.keys()).sort((t,i)=>this.getZIndex(t)-this.getZIndex(i))}render(t,i){for(const[s,e]of this.ct){const r=s.micro,n=Math.cos(r.rotation),h=Math.sin(r.rotation),o=s.width*r.scaleX,a=s.height*r.scaleY,u=r.anchorX*o,l=r.anchorY*a,c=u*h+l*n;e.position.x=s.x+r.x-(u*n-l*h),e.position.y=s.y+r.y-c,e.scale.x=o,e.scale.y=a,e.rotation.z=r.rotation,s.onBeforeRenderInternal(t,i)}t.render(this.lt,this.dt)}}function N(t){switch(t){case L.EQUAL:return M.Eq;case L.LESS_THAN:return M.Le;case L.GREATER_THAN:return M.Ge;default:throw Error("Invalid relation: "+t)}}function W(t){return t??L.EQUAL}(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(L||(L={}));class q{constructor(){this.ft=new A,this.gt=!1,this.wt=new Map,this.vt=0,this.yt=new Map,this.bt=0}createVariable(t,i){const s=this.vt++,e=new _;if(i===B.P0){const r={variable:e,priority:i,value:t};this.wt.set(s,r),r.constraint=this.xt(new g(0,[[s,1]]),new g(t),L.EQUAL,i),this.ft.addConstraint(r.constraint)}else this.wt.set(s,{variable:e,priority:i,value:t}),this.ft.addEditVariable(e,$(i)),this.ft.suggestValue(e,t);return this.gt=!0,s}removeVariable(t){const i=this.wt.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`);i.constraint?this.ft.removeConstraint(i.constraint):this.ft.removeEditVariable(i.variable),this.wt.delete(t),this.gt=!0}suggestVariableValue(t,i){const s=this.wt.get(t);if(void 0===s)throw Error(`Variable ${t} does not exist`);s.value!==i&&(s.value=i,s.constraint?s.constraint=this.Et(s.constraint,(new g).plus(t,1),new g(s.value),L.EQUAL,s.priority):this.ft.suggestValue(s.variable,i),this.gt=!0)}setVariablePriority(t,i){const s=this.wt.get(t);if(void 0===s)throw Error(`Variable ${t} does not exist`);i!==s.priority&&(s.priority=i,s.constraint?s.constraint=this.Et(s.constraint,(new g).plus(t,1),new g(s.value),L.EQUAL,s.priority):this._t(t,s),this.gt=!0)}readVariableValue(t){const i=this.wt.get(t);if(void 0===i)throw Error(`Variable ${t} does not exist`);return this.gt&&(this.ft.updateVariables(),this.gt=!1),i.variable.value()}createConstraint(t,i,s,e,r){const n=this.bt++,h=this.xt(t,i,s,e);return this.yt.set(n,{constraint:h,lhs:t.clone(),rhs:i.clone(),priority:e,relation:s,enabled:r}),this.ft.addConstraint(h),this.gt=!0,n}removeConstraint(t){const i=this.yt.get(t);if(void 0===i)throw Error(`Constraint ${t} does not exist`);this.ft.removeConstraint(i.constraint),this.yt.delete(t),this.gt=!0}setConstraintLHS(t,i){const s=this.yt.get(t);if(void 0===s)throw Error(`Constraint ${t} does not exist`);s.lhs.copy(i),this.Ct(s),this.gt=!0}setConstraintRHS(t,i){const s=this.yt.get(t);if(void 0===s)throw Error(`Constraint ${t} does not exist`);s.rhs.copy(i),this.Ct(s),this.gt=!0}setConstraintRelation(t,i){const s=this.yt.get(t);if(void 0===s)throw Error(`Constraint ${t} does not exist`);s.relation=i,this.Ct(s),this.gt=!0}setConstraintPriority(t,i){const s=this.yt.get(t);if(void 0===s)throw Error(`Constraint ${t} does not exist`);s.priority=i,this.Ct(s),this.gt=!0}setConstraintEnabled(t,i){const s=this.yt.get(t);if(void 0===s)throw Error(`Constraint ${t} does not exist`);if(i!==s.enabled){s.enabled=i;try{s.enabled?this.ft.addConstraint(s.constraint):this.ft.removeConstraint(s.constraint)}catch{this.It()}this.gt=!0}}kt(t){return new I(...t.prepareTermsInternal().map(([t,i])=>{const s=this.wt.get(t);if(void 0===s)throw Error(`Variable ${t} does not exist`);return[i,s.variable]}),t.constant)}_t(t,i){let s=!1;const e=[];for(const i of this.yt.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){if(!s)try{this.ft.removeConstraint(i.constraint)}catch{s=!0}e.push(i)}this.ft.removeEditVariable(i.variable),this.ft.addEditVariable(i.variable,$(i.priority));for(const t of e)t.constraint=new S(this.kt(t.lhs),N(t.relation),this.kt(t.rhs),$(t.priority));if(!s)for(const t of e)try{this.ft.addConstraint(t.constraint)}catch{s=!0;break}s&&this.It()}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,s,e,r){let n=!1;try{this.ft.removeConstraint(t)}catch{n=!0}const h=this.xt(i,s,e,r);if(!n)try{this.ft.addConstraint(h)}catch{n=!0}return n&&this.It(),h}xt(t,i,s,e){return new S(this.kt(t),N(s),this.kt(i),$(e))}It(){this.ft=new A;for(const t of this.wt.values())this.ft.addEditVariable(t.variable,t.priority),this.ft.suggestValue(t.variable,t.value);for(const t of this.yt.values())this.ft.addConstraint(t.constraint)}}(t=>{t.ORIENTATION_CHANGE="orientation_change",t.MODE_CHANGE="mode_change"})(D||(D={}));class X extends w{constructor(t,i){super(),this.name="",this.solverWrapper=new q,this.modeInternal=v.VISIBLE,this.sceneWrapper=new j(t,i),this.xVariable=this.solverWrapper.createVariable(0,B.P0),this.yVariable=this.solverWrapper.createVariable(0,B.P0),this.wVariable=this.solverWrapper.createVariable(t,B.P0),this.hVariable=this.solverWrapper.createVariable(i,B.P0),this.orientationInternal=t>i?m.HORIZONTAL:m.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(D.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 s=t>i?m.HORIZONTAL:m.VERTICAL;s!==this.orientationInternal&&(this.orientationInternal=s,this.emit(D.ORIENTATION_CHANGE,this.orientationInternal,this))}renderInternal(t,i){this.mode!==v.HIDDEN&&this.sceneWrapper.render(t,i)}clickInternal(t,i){if(this.mode===v.INTERACTIVE)for(const s of this.sceneWrapper.getSortedVisibleElements())if(s.onClickInternal(t,i))return}getSolverWrapperInternal(){return this.solverWrapper}getSceneWrapperInternal(){return this.sceneWrapper}}class Y{constructor(t){this.layer=t,this.name="",this.solverWrapper=this.layer.getSolverWrapperInternal()}}class G extends Y{constructor(t,i,s,e){super(t),this.Mt=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.priorityInternal=z(i),this.relationInternal=W(s),this.orientationInternal=y(e),this.layer.on(D.ORIENTATION_CHANGE,this.Mt)}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.Mt())}destroy(){this.layer.off(D.ORIENTATION_CHANGE,this.Mt),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.orientationInternal===m.ALWAYS||this.orientationInternal===this.layer.orientation}}class Z extends G{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.St=t,this.Ut=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new g(0,[[this.St.hVariable,1]]),new g(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 g(t)))}}function J(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof X}function Q(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable}function K(t){return"object"==typeof t&&null!==t&&"wVariable"in t&&"number"==typeof t.wVariable&&"hVariable"in t&&"number"==typeof t.hVariable}function tt(t,i,s){if(t instanceof X&&i instanceof X)throw Error(s+": layer cannot be snapped to another layer");let e,r;if(!(t instanceof X||J(t)))throw Error(s+": A must be a UILayer or a UIPointElement");if(e=t instanceof X?t:t.layer,!(i instanceof X||J(i)))throw Error(s+": B must be a UILayer or a UIPointElement");if(r=i instanceof X?i:i.layer,e!==r)throw Error(s+": elements must be on the same layer");return e}function it(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 st(t,i){if(it(t,i),1e-6>t)throw Error(i+": value must be greater than or equal to 0.000001")}function et(t,i){if(it(t,i),0>t)throw Error(i+": value must be greater than or equal to 0")}class rt extends G{constructor(t,i,s={}){super(tt(t,i,"UIHorizontalDistanceConstraint"),s.priority,s.relation,s.orientation),this.At=t,this.Tt=i,this.Vt=s.anchorA??.5,this.Ft=s.anchorB??.5,this.Ot=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Pt(),new g(this.Ot),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get distance(){return this.Ot}get anchorA(){return this.Vt}get anchorB(){return this.Ft}set distance(t){this.Ot!==t&&(this.Ot=t,this.solverWrapper.setConstraintRHS(this.constraint,new g(this.Ot)))}set anchorA(t){this.Vt!==t&&(this.Vt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Pt()))}set anchorB(t){this.Ft!==t&&(this.Ft=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Pt()))}Pt(){let t,i;if(K(this.At))t=new g(0,[[this.At.xVariable,1],[this.At.wVariable,this.Vt]]);else{if(!Q(this.At))throw Error("A is not a valid element type");t=(new g).plus(this.At.xVariable,1)}if(K(this.Tt))i=new g(0,[[this.Tt.xVariable,1],[this.Tt.wVariable,this.Ft]]);else{if(!Q(this.Tt))throw Error("B is not a valid element type");i=(new g).plus(this.Tt.xVariable,1)}return g.minus(i,t)}}class nt extends G{constructor(t,i,s={}){super(tt(t,i,"UIHorizontalProportionConstraint"),s.priority,s.relation,s.orientation),this.At=t,this.Tt=i,this.Ht=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(this.Pt(),new g(0),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get proportion(){return this.Ht}set proportion(t){this.Ht!==t&&(this.Ht=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Pt()))}Pt(){return g.minus(new g(0,[[this.At.wVariable,this.Ht]]),new g(0,[[this.Tt.wVariable,1]]))}}class ht extends G{constructor(t,i,s={}){super(tt(t,i,"UIVerticalDistanceConstraint"),s.priority,s.relation,s.orientation),this.At=t,this.Tt=i,this.Vt=s.anchorA??.5,this.Ft=s.anchorB??.5,this.Ot=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Pt(),new g(this.Ot),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get distance(){return this.Ot}get anchorA(){return this.Vt}get anchorB(){return this.Ft}set distance(t){this.Ot!==t&&(this.Ot=t,this.solverWrapper.setConstraintRHS(this.constraint,new g(this.Ot)))}set anchorA(t){this.Vt!==t&&(this.Vt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Pt()))}set anchorB(t){this.Ft!==t&&(this.Ft=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Pt()))}Pt(){let t,i;if(K(this.At))t=new g(0,[[this.At.yVariable,1],[this.At.hVariable,this.Vt]]);else{if(!Q(this.At))throw Error("A is not a valid element type");t=(new g).plus(this.At.yVariable,1)}if(K(this.Tt))i=new g(0,[[this.Tt.yVariable,1],[this.Tt.hVariable,this.Ft]]);else{if(!Q(this.Tt))throw Error("B is not a valid element type");i=(new g).plus(this.Tt.yVariable,1)}return g.minus(i,t)}}class ot extends G{constructor(t,i,s={}){super(tt(t,i,"UIVerticalProportionConstraint"),s.priority,s.relation,s.orientation),this.At=t,this.Tt=i,this.Ht=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(this.Pt(),new g(0),this.relationInternal,this.priorityInternal,this.isConstraintEnabled())}get proportion(){return this.Ht}set proportion(t){this.Ht!==t&&(this.Ht=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Pt()))}Pt(){return g.minus(new g(0,[[this.At.hVariable,this.Ht]]),new g(0,[[this.Tt.hVariable,1]]))}}class at extends G{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.St=t,this.Bt=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new g(0,[[this.St.wVariable,1]]),new g(this.Bt),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.Bt}set width(t){this.Bt!==t&&(this.Bt=t,this.solverWrapper.setConstraintRHS(this.constraint,new g(t)))}}class ut{static size(t,i={}){return{h:new at(t,{width:i.size?.h,priority:i.priority?.h,relation:i.relation?.h,orientation:i.orientation?.h}),v:new Z(t,{height:i.size?.v,priority:i.priority?.v,relation:i.relation?.v,orientation:i.orientation?.v})}}static distance(t,i,s={}){return{h:new rt(t,i,{anchorA:s.anchorA?.h,anchorB:s.anchorB?.h,distance:s.distance?.h,priority:s.priority?.h,relation:s.relation?.h,orientation:s.orientation?.h}),v:new ht(t,i,{anchorA:s.anchorA?.v,anchorB:s.anchorB?.v,distance:s.distance?.v,priority:s.priority?.v,relation:s.relation?.v,orientation:s.orientation?.v})}}static proportion(t,i,s={}){return{h:new nt(t,i,{proportion:s.proportion?.h,priority:s.priority?.h,relation:s.relation?.h,orientation:s.orientation?.h}),v:new ot(t,i,{proportion:s.proportion?.v,priority:s.priority?.v,relation:s.relation?.v,orientation:s.orientation?.v})}}}class lt extends G{constructor(t,i={}){super(t.layer,i.priority,i.relation,i.orientation),this.St=t,this.Lt=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Pt(),new g(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.Pt()))}Pt(){return new g(0,[[this.St.wVariable,1],[this.St.hVariable,-this.Lt]])}}class ct extends G{constructor(t,i,s,e={}){super(t,e.priority,e.relation,e.orientation),this.Dt=i,this.Rt=s,this.constraint=this.solverWrapper.createConstraint(this.Dt,this.Rt,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.Dt}get rhs(){return this.Rt}setLHS(t){this.Dt=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Dt)}setRHS(t){this.Rt=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Rt)}}class dt extends w{constructor(t,i,s){it(i,"UIAnchor x"),it(s,"UIAnchor y"),super(),this.layer=t,this.name="",this.solverWrapper=this.layer.getSolverWrapperInternal(),this.xVariable=this.solverWrapper.createVariable(i,B.P7),this.yVariable=this.solverWrapper.createVariable(s,B.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){it(t,"UIAnchor x"),this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){it(t,"UIAnchor y"),this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}class ft extends dt{constructor(t,i,s,e=100,r=100){st(e,"UIDummy width"),st(r,"UIDummy height"),super(t,i,s),this.wVariable=this.solverWrapper.createVariable(e,B.P6),this.hVariable=this.solverWrapper.createVariable(r,B.P6)}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}set width(t){st(t,"UIDummy width"),this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){st(t,"UIDummy height"),this.solverWrapper.suggestVariableValue(this.hVariable,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),super.destroy()}}class gt{constructor(){this.$t=0,this.zt=0,this.jt=0,this.Nt=0,this.Wt=1,this.qt=1,this.Xt=0,this.gt=!1}get x(){return this.$t}get y(){return this.zt}get anchorX(){return this.jt}get anchorY(){return this.Nt}get scaleX(){return this.Wt}get scaleY(){return this.qt}get size(){return Math.max(this.Wt,this.qt)}get angle(){return s.radToDeg(this.Xt)}get rotation(){return this.Xt}set x(t){t!==this.$t&&(this.$t=t,this.gt=!0)}set y(t){t!==this.zt&&(this.zt=t,this.gt=!0)}set anchorX(t){t!==this.jt&&(this.jt=t,this.gt=!0)}set anchorY(t){t!==this.Nt&&(this.Nt=t,this.gt=!0)}set scaleX(t){t!==this.Wt&&(this.Wt=t,this.gt=!0)}set scaleY(t){t!==this.qt&&(this.qt=t,this.gt=!0)}set size(t){t===this.Wt&&t===this.qt||(this.Wt=t,this.qt=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)}reset(){0===this.$t&&0===this.zt&&0===this.jt&&0===this.Nt&&1===this.Wt&&1===this.qt&&0===this.Xt||(this.$t=0,this.zt=0,this.jt=0,this.Nt=0,this.Wt=1,this.qt=1,this.Xt=0,this.gt=!0)}getRecalculationRequiredInternal(){return this.gt}resetRecalculationRequiredInternal(){this.gt=!1}}(t=>{t.CLICK="click"})(R||(R={}));class pt extends dt{constructor(t,i,s,e,r,n){st(e,"UIElement width"),st(r,"UIElement height"),super(t,i,s),this.object=n,this.micro=new gt,this.modeInternal=v.VISIBLE,this.sceneWrapper=this.layer.getSceneWrapperInternal(),this.sceneWrapper.insertObject(this,this.object),this.wVariable=this.solverWrapper.createVariable(e,B.P6),this.hVariable=this.solverWrapper.createVariable(r,B.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){st(t,"UIElement width"),this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){st(t,"UIElement height"),this.solverWrapper.suggestVariableValue(this.hVariable,t)}set zIndex(t){it(t,"UIElement zIndex"),this.sceneWrapper.setZIndex(this,t)}set mode(t){t!==this.modeInternal&&(this.modeInternal=t,this.sceneWrapper.setVisibility(this,t!==v.HIDDEN))}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.sceneWrapper.removeObject(this),super.destroy()}onClickInternal(t,i){const s=this.modeInternal===v.INTERACTIVE&&t>this.x&&this.x+this.width>t&&i>this.y&&this.y+this.height>i;return s&&this.emit(R.CLICK,t,i,this),s}onBeforeRenderInternal(t,i){}}const wt=.75;class vt extends e{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new r(1,1,1)},alphaTest:{value:wt}},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:wt,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?wt:0,this.needsUpdate=!0,this.uniformsNeedUpdate=!0),this}}const mt=new n(1,1).translate(.5,.5,0);class yt extends pt{constructor(t,i,s=0,e=0){const r=i.image.width,n=i.image.height,o=new vt(i);super(t,s,e,r,n,new h(mt,o)),this.Yt=o,this.Gt=i}get texture(){return this.Gt}get color(){return this.Yt.getColor()}get opacity(){return this.Yt.getOpacity()}get transparency(){return this.Yt.getTransparency()}set texture(t){const i=t.image.width,s=t.image.height;st(i,"UIImage texture width"),st(s,"UIImage texture height"),this.Yt.setTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,s)}set color(t){this.Yt.setColor(t)}set opacity(t){this.Yt.setOpacity(t)}set transparency(t){this.Yt.setTransparency(t)}destroy(){this.Yt.dispose(),super.destroy()}}class bt extends e{constructor(t,i){super({uniforms:o.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new r(1,1,1)},foregroundColor:{value:new r(1,1,1)},color:{value:new r(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 xt extends pt{constructor(t,i,e={}){const r=i.image?.width,n=i.image?.height;st(r,"UIProgress foreground texture width"),st(n,"UIProgress foreground texture height");const o=e.textureBackground?.image?.width,a=e.textureBackground?.image?.height;e.textureBackground&&(st(o,"UIProgress background texture width"),st(a,"UIProgress background texture height"));const u=new bt(i,e.textureBackground),l=new h(mt,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,n??a,l),this.Yt=u}get progress(){return this.Yt.getProgress()}get backgroundTexture(){return this.Yt.getBackgroundTexture()}get foregroundTexture(){return this.Yt.getForegroundTexture()}get backgroundColor(){return this.Yt.getBackgroundColor()}get foregroundColor(){return this.Yt.getForegroundColor()}get backgroundOpacity(){return this.Yt.getBackgroundOpacity()}get foregroundOpacity(){return this.Yt.getForegroundOpacity()}get angle(){return s.radToDeg(this.Yt.getAngle())}get isForwardDirection(){return this.Yt.getIsForwardDirection()}set progress(t){this.Yt.setProgress(t)}set backgroundTexture(t){if(t){const i=t.image.height;st(t.image.width,"UIElement background texture width"),st(i,"UIElement background texture height")}this.Yt.setBackgroundTexture(t)}set foregroundTexture(t){const i=t.image.width,s=t.image.height;st(i,"UIImage texture width"),st(s,"UIImage texture height"),this.Yt.setForegroundTexture(t),this.solverWrapper.suggestVariableValue(this.wVariable,i),this.solverWrapper.suggestVariableValue(this.hVariable,s)}set backgroundColor(t){this.Yt.setBackgroundColor(t)}set foregroundColor(t){this.Yt.setForegroundColor(t)}set backgroundOpacity(t){this.Yt.setBackgroundOpacity(t)}set foregroundOpacity(t){this.Yt.setForegroundOpacity(t)}set angle(t){this.Yt.setAngle(s.degToRad(t))}set isForwardDirection(t){this.Yt.setIsForwardDirection(t)}destroy(){this.Yt.dispose(),super.destroy()}}var Et;(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"})(Et||(Et={}));const _t=Et.PROPERTY_CHANGED;class Ct extends pt{constructor(i,s={}){const e=s.resolutionFactor??.5;if(.1>e||e>2)throw Error(`Invalid resolution factor: ${e}. Must be between 0.1 and 2.`);const r=s.width??512,n=s.height??512,o=new a(r*e,n*e,{format:c,minFilter:l,magFilter:l,type:u,depthBuffer:s.enableDepthBuffer??!0,stencilBuffer:!1}),f=new vt(o.texture);super(i,0,0,r,n,new h(mt,f)),this.Zt=!0,this.Jt=!1,this.Qt=!1,this.Yt=f,this.Kt=o,this.ti=s.scene??new t,this.ii=s.camera??new d(75,r/n,.1,100),this.si=e,this.ei=s.updateMode??_t,this.ri=s.clearColor??0,this.ni=s.clearAlpha??0,s.updateMode===Et.PROPERTY_CHANGED&&(this.Qt=!0)}get color(){return this.Yt.getColor()}get opacity(){return this.Yt.getOpacity()}get transparency(){return this.Yt.getTransparency()}get scene(){return this.ti}get camera(){return this.ii}get updateMode(){return this.ei}get resolutionFactor(){return this.si}get clearColor(){return this.ri}get clearAlpha(){return this.ni}set color(t){this.Yt.setColor(t)}set opacity(t){this.Yt.setOpacity(t)}set transparency(t){this.Yt.setTransparency(t)}set scene(t){this.ti!==t&&(this.ti=t,this.Jt=!0)}set camera(t){this.ii!==t&&(this.ii=t,this.Jt=!0)}set updateMode(t){this.ei!==t&&(this.ei=t,this.Jt=!0)}set resolutionFactor(t){this.si!==t&&(this.si=t,this.Kt.setSize(this.width*this.si,this.height*this.si),this.Jt=!0)}set clearColor(t){this.ri!==t&&(this.ri=t,this.Jt=!0)}set clearAlpha(t){this.ni!==t&&(this.ni=t,this.Jt=!0)}destroy(){this.Yt.dispose(),this.Kt.dispose(),super.destroy()}requestRender(){this.Qt=!0}onBeforeRenderInternal(t){(this.ei===Et.EACH_FRAME||this.ei===Et.EACH_SECOND_FRAME&&this.Zt||this.ei===Et.PROPERTY_CHANGED&&this.Jt||this.ei===Et.MANUAL&&this.Qt)&&(this.Qt=!1,this.Jt=!1,this.Zt=!this.Zt,this.Kt.setSize(this.width*this.si,this.height*this.si),t.setClearColor(this.ri,this.clearAlpha),t.setRenderTarget(this.Kt),t.clear(!0,!0,!1),t.render(this.ti,this.ii))}}function It(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 kt(t,i){const s=t?.fontSize??i?.fontSize??16;st(s,"Font size");const e=t?.fontWeight??i?.fontWeight??"normal";"number"==typeof e&&st(e,"Font weight");const r=t?.lineHeight??i?.lineHeight??1.2*s;it(r,"Line height");const n=t?.shadowOffsetX??i?.shadowOffsetX??0;et(n,"Shadow offset X");const h=t?.shadowOffsetY??i?.shadowOffsetY??0;et(h,"Shadow offset Y");const o=t?.shadowBlur??i?.shadowBlur??0;et(o,"Shadow blur");const a=t?.strokeWidth??i?.strokeWidth??0;return et(a,"Stroke width"),{color:t?.color??i?.color??"#000000",fontFamily:t?.fontFamily??i?.fontFamily??"Arial",fontSize:s,fontStyle:t?.fontStyle??i?.fontStyle??"normal",fontWeight:e,lineHeight:r,enableShadow:t?.enableShadow??i?.enableShadow??!1,shadowOffsetX:n,shadowOffsetY:h,shadowBlur:o,shadowColor:t?.shadowColor??i?.shadowColor??"transparent",enableStroke:t?.enableStroke??i?.enableStroke??!1,strokeColor:t?.strokeColor??i?.strokeColor??"#000000",strokeWidth:a}}function Mt(t){return t.match(/\S+|\s|\n/g)??[]}function St(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const e=t.measureText(i);return{width:Math.ceil(e.width),height:Math.ceil(e.actualBoundingBoxAscent+e.actualBoundingBoxDescent),baseline:e.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ut(t,i,s,e,r){r.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize}px ${e.fontFamily}`,e.enableShadow&&(r.shadowOffsetX=e.shadowOffsetX,r.shadowOffsetY=e.shadowOffsetY,r.shadowBlur=e.shadowBlur,r.shadowColor=e.shadowColor),e.enableStroke&&(r.strokeStyle=e.strokeColor,r.lineWidth=e.strokeWidth,r.strokeText(s,t,i)),r.fillStyle=e.color,r.fillText(s,t,i)}function At(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,s="right"in t&&"number"==typeof t.right?t.right:0,e="top"in t&&"number"==typeof t.top?t.top:0,r="bottom"in t&&"number"==typeof t.bottom?t.bottom:0;return et(i,"Padding left"),et(s,"Padding right"),et(e,"Padding top"),et(r,"Padding bottom"),{left:i,right:s,top:e,bottom:r}}return{left:0,right:0,top:0,bottom:0}}class Tt extends pt{constructor(t,i,s={},e=0,r=0){const n=document.createElement("canvas"),o=n.getContext("2d");if(!o)throw Error("Failed to create canvas context");const a=new f(n),u=new vt(a);super(t,e,r,2,2,new h(mt,u)),this.hi=1,this.oi=1,this.Yt=u,this.ai=a,this.ui=n,this.li=o,this.ci=i,this.di=s.maxWidth??1024,this.fi=At(s.padding),this.gi=s.commonStyle??{},this.pi()}get color(){return this.Yt.getColor()}get opacity(){return this.Yt.getOpacity()}get transparency(){return this.Yt.getTransparency()}get content(){return this.ci}get maxWidth(){return this.di}get padding(){return this.fi}get commonStyle(){return this.gi}set color(t){this.Yt.setColor(t)}set opacity(t){this.Yt.setOpacity(t)}set transparency(t){this.Yt.setTransparency(t)}set content(t){this.ci=t,this.pi()}set maxWidth(t){this.di=t,this.pi()}set padding(t){this.fi=t,this.pi()}set commonStyle(t){this.gi=t,this.pi()}destroy(){this.Yt.dispose(),this.ai.dispose(),this.ui.remove(),super.destroy()}onBeforeRenderInternal(t,i){this.oi!==this.width/this.height&&(this.oi=this.hi,this.height=this.width/this.hi)}pi(){const{lines:t,size:i}=((t,i,s,e)=>{const r=[];for(const s of Array.isArray(i)?i:[i]){const i="string"==typeof s,n=i?s:s.text,h=kt(i?void 0:s.style,e);for(const i of Mt(n)){const s=St(t,i,h);r.push({text:i,style:h,metrics:s})}}const n=((t,i)=>{const s=[];let e=[],r=0,n=0,h=0,o=0;for(const a of i)"\n"!==a.text?r+a.metrics.width>t&&0!==e.length?(s.push({chunks:e,width:r,height:n,baseline:h,lineHeight:o}),e=[a],r=a.metrics.width,n=a.metrics.height,h=a.metrics.baseline,o=a.metrics.lineHeight):(e.push(a),r+=a.metrics.width,n=Math.max(n,a.metrics.height),h=Math.max(h,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(e.length>0&&s.push({chunks:e,width:r,height:n,baseline:h,lineHeight:o}),e=[],r=0,n=0,h=0,o=0);return e.length>0&&s.push({chunks:e,width:r,height:n,baseline:h,lineHeight:o}),s})(s,r),h=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let s=0;for(let i=0;t.length>i;i++){const e=t[i];s+=0===i?e.height:e.lineHeight,i===t.length-1&&(s+=e.baseline)}return{width:i,height:s}})(n);return{lines:n,size:h}})(this.li,this.content,this.di,this.gi);this.ui.width=i.width+this.fi.left+this.fi.right,this.ui.height=i.height+this.fi.top+this.fi.bottom,this.hi=(i.width+this.fi.left+this.fi.right)/(i.height+this.fi.top+this.fi.bottom),((t,i,s,e)=>{let r=this.fi.top;for(let t=0;s.length>t;t++){const n=s[t];let h=i;r+=0===t?n.height:n.lineHeight;for(const t of n.chunks)Ut(h,r,t.text,t.style,e),h+=t.metrics.width}})(0,this.fi.left,t,this.li),this.ai.needsUpdate=!0}}class Vt extends X{constructor(t,i){void 0!==t&&st(t,"UIFullscreenLayer.fixedWidth"),void 0!==i&&st(i,"UIFullscreenLayer.fixedHeight"),super(1,1),this.wi=()=>{const t=this.mi();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.yi=t=>{const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,e=i?i.bottom-t.clientY:window.innerHeight-t.clientY,r=this.mi();this.clickInternal(s*r,e*r)},this.bi=t,this.xi=i,window.addEventListener("resize",this.wi),window.addEventListener("pointerdown",this.yi),this.wi()}get fixedWidth(){return this.bi}get fixedHeight(){return this.xi}set fixedWidth(t){void 0!==t&&st(t,"UIFullscreenLayer.fixedWidth"),t!==this.bi&&(this.bi=t,this.wi())}set fixedHeight(t){void 0!==t&&st(t,"UIFullscreenLayer.fixedHeight"),t!==this.xi&&(this.xi=t,this.wi())}destroy(){window.removeEventListener("resize",this.wi),window.removeEventListener("pointerdown",this.yi)}render(t,i){it(i,"UIFullscreenLayer.deltaTime"),t.clear(!1,!0,!0),super.renderInternal(t,i)}mi(){return this.orientation===m.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 Ft(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text&&(!("style"in t)||It(t.style))}export{dt as UIAnchor,lt as UIAspectConstraint,Y as UIConstraint,ut as UIConstraint2DBuilder,ct as UICustomConstraint,ft as UIDummy,pt as UIElement,R as UIElementEvent,g as UIExpression,Vt as UIFullscreenLayer,Z as UIHeightConstraint,rt as UIHorizontalDistanceConstraint,nt as UIHorizontalProportionConstraint,yt as UIImage,X as UILayer,D as UILayerEvent,gt as UIMicro,v as UIMode,m as UIOrientation,B as UIPriority,xt as UIProgress,L as UIRelation,Ct as UIScene,Et as UISceneUpdateMode,G as UISingleParameterConstraint,Tt as UIText,ht as UIVerticalDistanceConstraint,ot as UIVerticalProportionConstraint,at as UIWidthConstraint,$ as convertPriority,N as convertRelation,Ft as isUITextSpan,It as isUITextStyle,y as resolveOrientation,At as resolvePadding,z as resolvePriority,W as resolveRelation,kt as resolveTextStyle};
2
2
  //# sourceMappingURL=index.min.js.map