laymur 0.1.58 → 0.1.59

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