laymur 0.1.60 → 0.1.62

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.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/kiwi.js/es/maptype.js","../node_modules/kiwi.js/es/variable.js","../node_modules/kiwi.js/es/expression.js","../node_modules/kiwi.js/es/strength.js","../node_modules/kiwi.js/es/constraint.js","../node_modules/kiwi.js/es/solver.js","../src/Miscellaneous/symbols.ts","../src/Miscellaneous/UIOrientation.ts","../src/Constraints/UIConstraint.ts","../src/Constraints/UIConstraintPower.ts","../src/Constraints/UIConstraintRule.ts","../src/Constraints/UIHeightConstraint.ts","../node_modules/eventail/dist/index.js","../src/Elements/UIAnchor.ts","../src/Miscellaneous/math.ts","../src/Miscellaneous/microTransformationTools.ts","../src/Miscellaneous/UIMicro.ts","../src/Miscellaneous/UIMode.ts","../src/Materials/UIMaterial.ts","../src/Miscellaneous/threeInstances.ts","../src/Passes/UIFullScreenQuad.ts","../src/Passes/UIComposer.ts","../src/Elements/UIElement.ts","../src/Layers/UILayer.ts","../src/Builders/UIConstraintContainerBuilder.ts","../src/Elements/UIScene.ts","../src/Miscellaneous/asserts.ts","../src/Constraints/UIHorizontalDistanceConstraint.ts","../src/Constraints/UIHorizontalProportionConstraint.ts","../src/Constraints/UIVerticalDistanceConstraint.ts","../src/Constraints/UIVerticalProportionConstraint.ts","../src/Constraints/UIWidthConstraint.ts","../src/Builders/UIConstraint2DBuilder.ts","../src/Builders/UIConstraintStackBuilder.ts","../src/Constraints/UIAspectConstraint.ts","../src/Constraints/UICoverConstraint.ts","../src/Constraints/UIFitConstraint.ts","../src/Elements/UIDummy.ts","../src/Elements/UIImage.ts","../src/Materials/UIProgressMaterial.ts","../src/Elements/UIProgress.ts","../src/Miscellaneous/textTools.ts","../src/Elements/UIText.ts","../src/Layers/UIFullScreenLayer.ts","../src/Layers/UIManualLayer.ts","../src/Passes/UIPass.ts"],"sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nexport function createMap() {\n return new IndexedMap();\n}\nvar IndexedMap = /** @class */ (function () {\n function IndexedMap() {\n this.index = {};\n this.array = [];\n }\n /**\n * Returns the number of items in the array.\n */\n IndexedMap.prototype.size = function () {\n return this.array.length;\n };\n /**\n * Returns true if the array is empty.\n */\n IndexedMap.prototype.empty = function () {\n return this.array.length === 0;\n };\n /**\n * Returns the item at the given array index.\n *\n * @param index The integer index of the desired item.\n */\n IndexedMap.prototype.itemAt = function (index) {\n return this.array[index];\n };\n /**\n * Returns true if the key is in the array, false otherwise.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.contains = function (key) {\n return this.index[key.id()] !== undefined;\n };\n /**\n * Returns the pair associated with the given key, or undefined.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.find = function (key) {\n var i = this.index[key.id()];\n return i === undefined ? undefined : this.array[i];\n };\n /**\n * Returns the pair associated with the key if it exists.\n *\n * If the key does not exist, a new pair will be created and\n * inserted using the value created by the given factory.\n *\n * @param key The key to locate in the array.\n * @param factory The function which creates the default value.\n */\n IndexedMap.prototype.setDefault = function (key, factory) {\n var i = this.index[key.id()];\n if (i === undefined) {\n var pair = new Pair(key, factory());\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n return pair;\n }\n else {\n return this.array[i];\n }\n };\n /**\n * Insert the pair into the array and return the pair.\n *\n * This will overwrite any existing entry in the array.\n *\n * @param key The key portion of the pair.\n * @param value The value portion of the pair.\n */\n IndexedMap.prototype.insert = function (key, value) {\n var pair = new Pair(key, value);\n var i = this.index[key.id()];\n if (i === undefined) {\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n }\n else {\n this.array[i] = pair;\n }\n return pair;\n };\n /**\n * Removes and returns the pair for the given key, or undefined.\n *\n * @param key The key to remove from the map.\n */\n IndexedMap.prototype.erase = function (key) {\n var i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n var pair = this.array[i];\n var last = this.array.pop();\n if (pair !== last) {\n this.array[i] = last;\n this.index[last.first.id()] = i;\n }\n return pair;\n };\n /**\n * Create a copy of this associative array.\n */\n IndexedMap.prototype.copy = function () {\n var copy = new IndexedMap();\n for (var i = 0; i < this.array.length; i++) {\n var pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n };\n return IndexedMap;\n}());\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nvar Pair = /** @class */ (function () {\n /**\n * Construct a new Pair object.\n *\n * @param first The first item of the pair.\n * @param second The second item of the pair.\n */\n function Pair(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n Pair.prototype.copy = function () { return new Pair(this.first, this.second); };\n return Pair;\n}());\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nvar Variable = /** @class */ (function () {\n function Variable(name) {\n if (name === void 0) { name = \"\"; }\n this._value = 0.0;\n this._context = null;\n this._id = VarId++;\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n Variable.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n Variable.prototype.name = function () {\n return this._name;\n };\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n Variable.prototype.setName = function (name) {\n this._name = name;\n };\n /**\n * Returns the user context object of the variable.\n * @private\n */\n Variable.prototype.context = function () {\n return this._context;\n };\n /**\n * Set the user context object of the variable.\n * @private\n */\n Variable.prototype.setContext = function (context) {\n this._context = context;\n };\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n Variable.prototype.value = function () {\n return this._value;\n };\n /**\n * Set the value of the variable.\n * @private\n */\n Variable.prototype.setValue = function (value) {\n this._value = value;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the variable.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Variable.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the variable.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Variable.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Variable.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Variable.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n Variable.prototype.toJSON = function () {\n return {\n name: this._name,\n value: this._value,\n };\n };\n Variable.prototype.toString = function () {\n return this._context + \"[\" + this._name + \":\" + this._value + \"]\";\n };\n return Variable;\n}());\nexport { Variable };\n/**\n * The internal variable id counter.\n * @private\n */\nvar VarId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { createMap } from \"./maptype\";\nimport { Variable } from \"./variable\";\n/**\n * An expression of variable terms and a constant.\n *\n * The constructor accepts an arbitrary number of parameters,\n * each of which must be one of the following types:\n * - number\n * - Variable\n * - Expression\n * - 2-tuple of [number, Variable|Expression]\n *\n * The parameters are summed. The tuples are multiplied.\n *\n * @class\n * @param {...(number|Variable|Expression|Array)} args\n */\nvar Expression = /** @class */ (function () {\n function Expression() {\n var parsed = parseArgs(arguments);\n this._terms = parsed.terms;\n this._constant = parsed.constant;\n }\n /**\n * Returns the mapping of terms in the expression.\n *\n * This *must* be treated as const.\n * @private\n */\n Expression.prototype.terms = function () {\n return this._terms;\n };\n /**\n * Returns the constant of the expression.\n * @private\n */\n Expression.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns the computed value of the expression.\n *\n * @private\n * @return {Number} computed value of the expression\n */\n Expression.prototype.value = function () {\n var result = this._constant;\n for (var i = 0, n = this._terms.size(); i < n; i++) {\n var pair = this._terms.itemAt(i);\n result += pair.first.value() * pair.second;\n }\n return result;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the expression.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Expression.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the expression.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Expression.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Expression.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Expression.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n Expression.prototype.isConstant = function () {\n return this._terms.size() == 0;\n };\n Expression.prototype.toString = function () {\n var result = this._terms.array.map(function (pair) {\n return (pair.second + \"*\" + pair.first.toString());\n }).join(\" + \");\n if (!this.isConstant() && this._constant !== 0) {\n result += \" + \";\n }\n result += this._constant;\n return result;\n };\n return Expression;\n}());\nexport { Expression };\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n var constant = 0.0;\n var factory = function () { return 0.0; };\n var terms = createMap();\n for (var i = 0, n = args.length; i < n; ++i) {\n var item = args[i];\n if (typeof item === \"number\") {\n constant += item;\n }\n else if (item instanceof Variable) {\n terms.setDefault(item, factory).second += 1.0;\n }\n else if (item instanceof Expression) {\n constant += item.constant();\n var terms2 = item.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second;\n }\n }\n else if (item instanceof Array) {\n if (item.length !== 2) {\n throw new Error(\"array must have length 2\");\n }\n var value = item[0];\n var value2 = item[1];\n if (typeof value !== \"number\") {\n throw new Error(\"array item 0 must be a number\");\n }\n if (value2 instanceof Variable) {\n terms.setDefault(value2, factory).second += value;\n }\n else if (value2 instanceof Expression) {\n constant += (value2.constant() * value);\n var terms2 = value2.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += (termPair.second * value);\n }\n }\n else {\n throw new Error(\"array item 1 must be a variable or expression\");\n }\n }\n else {\n throw new Error(\"invalid Expression argument: \" + item);\n }\n }\n return { terms: terms, constant: constant };\n}\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\n/**\n * @class Strength\n */\nvar Strength = /** @class */ (function () {\n function Strength() {\n }\n /**\n * Create a new symbolic strength.\n *\n * @param a strong\n * @param b medium\n * @param c weak\n * @param [w] weight\n * @return strength\n */\n Strength.create = function (a, b, c, w) {\n if (w === void 0) { w = 1.0; }\n var result = 0.0;\n result += Math.max(0.0, Math.min(1000.0, a * w)) * 1000000.0;\n result += Math.max(0.0, Math.min(1000.0, b * w)) * 1000.0;\n result += Math.max(0.0, Math.min(1000.0, c * w));\n return result;\n };\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n Strength.clip = function (value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n };\n /**\n * The 'required' symbolic strength.\n */\n Strength.required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n Strength.strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n Strength.medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n Strength.weak = Strength.create(0.0, 0.0, 1.0);\n return Strength;\n}());\nexport { Strength };\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\nimport { Strength } from \"./strength\";\n/**\n * An enum defining the linear constraint operators.\n *\n * |Value|Operator|Description|\n * |----|-----|-----|\n * |`Le`|<=|Less than equal|\n * |`Ge`|>=|Greater than equal|\n * |`Eq`|==|Equal|\n *\n * @enum {Number}\n */\nexport var Operator;\n(function (Operator) {\n Operator[Operator[\"Le\"] = 0] = \"Le\";\n Operator[Operator[\"Ge\"] = 1] = \"Ge\";\n Operator[Operator[\"Eq\"] = 2] = \"Eq\";\n})(Operator || (Operator = {}));\n/**\n * A linear constraint equation.\n *\n * A constraint equation is composed of an expression, an operator,\n * and a strength. The RHS of the equation is implicitly zero.\n *\n * @class\n * @param {Expression} expression The constraint expression (LHS).\n * @param {Operator} operator The equation operator.\n * @param {Expression} [rhs] Right hand side of the expression.\n * @param {Number} [strength=Strength.required] The strength of the constraint.\n */\nvar Constraint = /** @class */ (function () {\n function Constraint(expression, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n this._id = CnId++;\n this._operator = operator;\n this._strength = Strength.clip(strength);\n if ((rhs === undefined) && (expression instanceof Expression)) {\n this._expression = expression;\n }\n else {\n this._expression = expression.minus(rhs);\n }\n }\n /**\n * Returns the unique id number of the constraint.\n * @private\n */\n Constraint.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n Constraint.prototype.expression = function () {\n return this._expression;\n };\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n Constraint.prototype.op = function () {\n return this._operator;\n };\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n Constraint.prototype.strength = function () {\n return this._strength;\n };\n Constraint.prototype.toString = function () {\n return this._expression.toString() + \" \" + [\"<=\", \">=\", \"=\"][this._operator] + \" 0 (\" + this._strength.toString() + \")\";\n };\n return Constraint;\n}());\nexport { Constraint };\n/**\n * The internal constraint id counter.\n * @private\n */\nvar CnId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Constraint, Operator } from \"./constraint\";\nimport { Expression } from \"./expression\";\nimport { createMap } from \"./maptype\";\nimport { Strength } from \"./strength\";\n/**\n * The constraint solver class.\n *\n * @class\n */\nvar Solver = /** @class */ (function () {\n /**\n * Construct a new Solver.\n */\n function Solver() {\n this._cnMap = createCnMap();\n this._rowMap = createRowMap();\n this._varMap = createVarMap();\n this._editMap = createEditMap();\n this._infeasibleRows = [];\n this._objective = new Row();\n this._artificial = null;\n this._idTick = 0;\n }\n /**\n * Creates and add a constraint to the solver.\n *\n * @param {Expression|Variable} lhs Left hand side of the expression\n * @param {Operator} operator Operator\n * @param {Expression|Variable|Number} rhs Right hand side of the expression\n * @param {Number} [strength=Strength.required] Strength\n */\n Solver.prototype.createConstraint = function (lhs, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n var cn = new Constraint(lhs, operator, rhs, strength);\n this.addConstraint(cn);\n return cn;\n };\n /**\n * Add a constraint to the solver.\n *\n * @param {Constraint} constraint Constraint to add to the solver\n */\n Solver.prototype.addConstraint = function (constraint) {\n var cnPair = this._cnMap.find(constraint);\n if (cnPair !== undefined) {\n throw new Error(\"duplicate constraint\");\n }\n // Creating a row causes symbols to be reserved for the variables\n // in the constraint. If this method exits with an exception,\n // then its possible those variables will linger in the var map.\n // Since its likely that those variables will be used in other\n // constraints and since exceptional conditions are uncommon,\n // i'm not too worried about aggressive cleanup of the var map.\n var data = this._createRow(constraint);\n var row = data.row;\n var tag = data.tag;\n var subject = this._chooseSubject(row, tag);\n // If chooseSubject couldnt find a valid entering symbol, one\n // last option is available if the entire row is composed of\n // dummy variables. If the constant of the row is zero, then\n // this represents redundant constraints and the new dummy\n // marker can enter the basis. If the constant is non-zero,\n // then it represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid && row.allDummies()) {\n if (!nearZero(row.constant())) {\n throw new Error(\"unsatisfiable constraint\");\n }\n else {\n subject = tag.marker;\n }\n }\n // If an entering symbol still isn't found, then the row must\n // be added using an artificial variable. If that fails, then\n // the row represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid) {\n if (!this._addWithArtificialVariable(row)) {\n throw new Error(\"unsatisfiable constraint\");\n }\n }\n else {\n row.solveFor(subject);\n this._substitute(subject, row);\n this._rowMap.insert(subject, row);\n }\n this._cnMap.insert(constraint, tag);\n // Optimizing after each constraint is added performs less\n // aggregate work due to a smaller average system size. It\n // also ensures the solver remains in a consistent state.\n this._optimize(this._objective);\n };\n /**\n * Remove a constraint from the solver.\n *\n * @param {Constraint} constraint Constraint to remove from the solver\n */\n Solver.prototype.removeConstraint = function (constraint) {\n var cnPair = this._cnMap.erase(constraint);\n if (cnPair === undefined) {\n throw new Error(\"unknown constraint\");\n }\n // Remove the error effects from the objective function\n // *before* pivoting, or substitutions into the objective\n // will lead to incorrect solver results.\n this._removeConstraintEffects(constraint, cnPair.second);\n // If the marker is basic, simply drop the row. Otherwise,\n // pivot the marker into the basis and then drop the row.\n var marker = cnPair.second.marker;\n var rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n var leaving = this._getMarkerLeavingSymbol(marker);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"failed to find leaving row\");\n }\n rowPair = this._rowMap.erase(leaving);\n rowPair.second.solveForEx(leaving, marker);\n this._substitute(marker, rowPair.second);\n }\n // Optimizing after each constraint is removed ensures that the\n // solver remains consistent. It makes the solver api easier to\n // use at a small tradeoff for speed.\n this._optimize(this._objective);\n };\n /**\n * Test whether the solver contains the constraint.\n *\n * @param {Constraint} constraint Constraint to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasConstraint = function (constraint) {\n return this._cnMap.contains(constraint);\n };\n /**\n * Add an edit variable to the solver.\n *\n * @param {Variable} variable Edit variable to add to the solver\n * @param {Number} strength Strength, should be less than `Strength.required`\n */\n Solver.prototype.addEditVariable = function (variable, strength) {\n var editPair = this._editMap.find(variable);\n if (editPair !== undefined) {\n throw new Error(\"duplicate edit variable\");\n }\n strength = Strength.clip(strength);\n if (strength === Strength.required) {\n throw new Error(\"bad required strength\");\n }\n var expr = new Expression(variable);\n var cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n var tag = this._cnMap.find(cn).second;\n var info = { tag: tag, constraint: cn, constant: 0.0 };\n this._editMap.insert(variable, info);\n };\n /**\n * Remove an edit variable from the solver.\n *\n * @param {Variable} variable Edit variable to remove from the solver\n */\n Solver.prototype.removeEditVariable = function (variable) {\n var editPair = this._editMap.erase(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n this.removeConstraint(editPair.second.constraint);\n };\n /**\n * Test whether the solver contains the edit variable.\n *\n * @param {Variable} variable Edit variable to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasEditVariable = function (variable) {\n return this._editMap.contains(variable);\n };\n /**\n * Suggest the value of an edit variable.\n *\n * @param {Variable} variable Edit variable to suggest a value for\n * @param {Number} value Suggested value\n */\n Solver.prototype.suggestValue = function (variable, value) {\n var editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n var rows = this._rowMap;\n var info = editPair.second;\n var delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n var marker = info.tag.marker;\n var rowPair = rows.find(marker);\n if (rowPair !== undefined) {\n if (rowPair.second.add(-delta) < 0.0) {\n this._infeasibleRows.push(marker);\n }\n this._dualOptimize();\n return;\n }\n // Check next if the negative error variable is basic.\n var other = info.tag.other;\n rowPair = rows.find(other);\n if (rowPair !== undefined) {\n if (rowPair.second.add(delta) < 0.0) {\n this._infeasibleRows.push(other);\n }\n this._dualOptimize();\n return;\n }\n // Otherwise update each row where the error variables exist.\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var rowPair_1 = rows.itemAt(i);\n var row = rowPair_1.second;\n var coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 &&\n rowPair_1.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair_1.first);\n }\n }\n this._dualOptimize();\n };\n /**\n * Update the values of the variables.\n */\n Solver.prototype.updateVariables = function () {\n var vars = this._varMap;\n var rows = this._rowMap;\n for (var i = 0, n = vars.size(); i < n; ++i) {\n var pair = vars.itemAt(i);\n var rowPair = rows.find(pair.second);\n if (rowPair !== undefined) {\n pair.first.setValue(rowPair.second.constant());\n }\n else {\n pair.first.setValue(0.0);\n }\n }\n };\n /**\n * Get the symbol for the given variable.\n *\n * If a symbol does not exist for the variable, one will be created.\n * @private\n */\n Solver.prototype._getVarSymbol = function (variable) {\n var _this = this;\n var factory = function () { return _this._makeSymbol(SymbolType.External); };\n return this._varMap.setDefault(variable, factory).second;\n };\n /**\n * Create a new Row object for the given constraint.\n *\n * The terms in the constraint will be converted to cells in the row.\n * Any term in the constraint with a coefficient of zero is ignored.\n * This method uses the `_getVarSymbol` method to get the symbol for\n * the variables added to the row. If the symbol for a given cell\n * variable is basic, the cell variable will be substituted with the\n * basic row.\n *\n * The necessary slack and error variables will be added to the row.\n * If the constant for the row is negative, the sign for the row\n * will be inverted so the constant becomes positive.\n *\n * Returns the created Row and the tag for tracking the constraint.\n * @private\n */\n Solver.prototype._createRow = function (constraint) {\n var expr = constraint.expression();\n var row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n var terms = expr.terms();\n for (var i = 0, n = terms.size(); i < n; ++i) {\n var termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n var symbol = this._getVarSymbol(termPair.first);\n var basicPair = this._rowMap.find(symbol);\n if (basicPair !== undefined) {\n row.insertRow(basicPair.second, termPair.second);\n }\n else {\n row.insertSymbol(symbol, termPair.second);\n }\n }\n }\n // Add the necessary slack, error, and dummy variables.\n var objective = this._objective;\n var strength = constraint.strength();\n var tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge:\n {\n var coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n var slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n var error = this._makeSymbol(SymbolType.Error);\n tag.other = error;\n row.insertSymbol(error, -coeff);\n objective.insertSymbol(error, strength);\n }\n break;\n }\n case Operator.Eq:\n {\n if (strength < Strength.required) {\n var errplus = this._makeSymbol(SymbolType.Error);\n var errminus = this._makeSymbol(SymbolType.Error);\n tag.marker = errplus;\n tag.other = errminus;\n row.insertSymbol(errplus, -1.0); // v = eplus - eminus\n row.insertSymbol(errminus, 1.0); // v - eplus + eminus = 0\n objective.insertSymbol(errplus, strength);\n objective.insertSymbol(errminus, strength);\n }\n else {\n var dummy = this._makeSymbol(SymbolType.Dummy);\n tag.marker = dummy;\n row.insertSymbol(dummy);\n }\n break;\n }\n }\n // Ensure the row has a positive constant.\n if (row.constant() < 0.0) {\n row.reverseSign();\n }\n return { row: row, tag: tag };\n };\n /**\n * Choose the subject for solving for the row.\n *\n * This method will choose the best subject for using as the solve\n * target for the row. An invalid symbol will be returned if there\n * is no valid target.\n *\n * The symbols are chosen according to the following precedence:\n *\n * 1) The first symbol representing an external variable.\n * 2) A negative slack or error tag variable.\n *\n * If a subject cannot be found, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._chooseSubject = function (row, tag) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n var type = tag.marker.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.marker) < 0.0) {\n return tag.marker;\n }\n }\n type = tag.other.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.other) < 0.0) {\n return tag.other;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Add the row to the tableau using an artificial variable.\n *\n * This will return false if the constraint cannot be satisfied.\n *\n * @private\n */\n Solver.prototype._addWithArtificialVariable = function (row) {\n // Create and add the artificial variable to the tableau.\n var art = this._makeSymbol(SymbolType.Slack);\n this._rowMap.insert(art, row.copy());\n this._artificial = row.copy();\n // Optimize the artificial objective. This is successful\n // only if the artificial objective is optimized to zero.\n this._optimize(this._artificial);\n var success = nearZero(this._artificial.constant());\n this._artificial = null;\n // If the artificial variable is basic, pivot the row so that\n // it becomes non-basic. If the row is constant, exit early.\n var pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n var basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n var entering = this._anyPivotableSymbol(basicRow);\n if (entering.type() === SymbolType.Invalid) {\n return false; // unsatisfiable (will this ever happen?)\n }\n basicRow.solveForEx(art, entering);\n this._substitute(entering, basicRow);\n this._rowMap.insert(entering, basicRow);\n }\n // Remove the artificial variable from the tableau.\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n rows.itemAt(i).second.removeSymbol(art);\n }\n this._objective.removeSymbol(art);\n return success;\n };\n /**\n * Substitute the parametric symbol with the given row.\n *\n * This method will substitute all instances of the parametric symbol\n * in the tableau and the objective function with the given row.\n *\n * @private\n */\n Solver.prototype._substitute = function (symbol, row) {\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 &&\n pair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(pair.first);\n }\n }\n this._objective.substitute(symbol, row);\n if (this._artificial) {\n this._artificial.substitute(symbol, row);\n }\n };\n /**\n * Optimize the system for the given objective function.\n *\n * This method performs iterations of Phase 2 of the simplex method\n * until the objective function reaches a minimum.\n *\n * @private\n */\n Solver.prototype._optimize = function (objective) {\n while (true) {\n var entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n var leaving = this._getLeavingSymbol(entering);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"the objective is unbounded\");\n }\n // pivot the entering symbol into the basis\n var row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n }\n };\n /**\n * Optimize the system using the dual of the simplex method.\n *\n * The current state of the system should be such that the objective\n * function is optimal, but not feasible. This method will perform\n * an iteration of the dual simplex method to make the solution both\n * optimal and feasible.\n *\n * @private\n */\n Solver.prototype._dualOptimize = function () {\n var rows = this._rowMap;\n var infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n var leaving = infeasible.pop();\n var pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n var entering = this._getDualEnteringSymbol(pair.second);\n if (entering.type() === SymbolType.Invalid) {\n throw new Error(\"dual optimize failed\");\n }\n // pivot the entering symbol into the basis\n var row = pair.second;\n rows.erase(leaving);\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n rows.insert(entering, row);\n }\n }\n };\n /**\n * Compute the entering variable for a pivot operation.\n *\n * This method will return first symbol in the objective function which\n * is non-dummy and has a coefficient less than zero. If no symbol meets\n * the criteria, it means the objective function is at a minimum, and an\n * invalid symbol is returned.\n *\n * @private\n */\n Solver.prototype._getEnteringSymbol = function (objective) {\n var cells = objective.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n if (pair.second < 0.0 && symbol.type() !== SymbolType.Dummy) {\n return symbol;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Compute the entering symbol for the dual optimize operation.\n *\n * This method will return the symbol in the row which has a positive\n * coefficient and yields the minimum ratio for its respective symbol\n * in the objective function. The provided row *must* be infeasible.\n * If no symbol is found which meats the criteria, an invalid symbol\n * is returned.\n *\n * @private\n */\n Solver.prototype._getDualEnteringSymbol = function (row) {\n var ratio = Number.MAX_VALUE;\n var entering = INVALID_SYMBOL;\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n var c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n var coeff = this._objective.coefficientFor(symbol);\n var r = coeff / c;\n if (r < ratio) {\n ratio = r;\n entering = symbol;\n }\n }\n }\n return entering;\n };\n /**\n * Compute the symbol for pivot exit row.\n *\n * This method will return the symbol for the exit row in the row\n * map. If no appropriate exit symbol is found, an invalid symbol\n * will be returned. This indicates that the objective function is\n * unbounded.\n *\n * @private\n */\n Solver.prototype._getLeavingSymbol = function (entering) {\n var ratio = Number.MAX_VALUE;\n var found = INVALID_SYMBOL;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n var row = pair.second;\n var temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n var temp_ratio = -row.constant() / temp;\n if (temp_ratio < ratio) {\n ratio = temp_ratio;\n found = symbol;\n }\n }\n }\n }\n return found;\n };\n /**\n * Compute the leaving symbol for a marker variable.\n *\n * This method will return a symbol corresponding to a basic row\n * which holds the given marker variable. The row will be chosen\n * according to the following precedence:\n *\n * 1) The row with a restricted basic varible and a negative coefficient\n * for the marker with the smallest ratio of -constant / coefficient.\n *\n * 2) The row with a restricted basic variable and the smallest ratio\n * of constant / coefficient.\n *\n * 3) The last unrestricted row which contains the marker.\n *\n * If the marker does not exist in any row, an invalid symbol will be\n * returned. This indicates an internal solver error since the marker\n * *should* exist somewhere in the tableau.\n *\n * @private\n */\n Solver.prototype._getMarkerLeavingSymbol = function (marker) {\n var dmax = Number.MAX_VALUE;\n var r1 = dmax;\n var r2 = dmax;\n var invalid = INVALID_SYMBOL;\n var first = invalid;\n var second = invalid;\n var third = invalid;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var row = pair.second;\n var c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n var symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n var r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n var r = row.constant() / c;\n if (r < r2) {\n r2 = r;\n second = symbol;\n }\n }\n }\n if (first !== invalid) {\n return first;\n }\n if (second !== invalid) {\n return second;\n }\n return third;\n };\n /**\n * Remove the effects of a constraint on the objective function.\n *\n * @private\n */\n Solver.prototype._removeConstraintEffects = function (cn, tag) {\n if (tag.marker.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.marker, cn.strength());\n }\n if (tag.other.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.other, cn.strength());\n }\n };\n /**\n * Remove the effects of an error marker on the objective function.\n *\n * @private\n */\n Solver.prototype._removeMarkerEffects = function (marker, strength) {\n var pair = this._rowMap.find(marker);\n if (pair !== undefined) {\n this._objective.insertRow(pair.second, -strength);\n }\n else {\n this._objective.insertSymbol(marker, -strength);\n }\n };\n /**\n * Get the first Slack or Error symbol in the row.\n *\n * If no such symbol is present, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._anyPivotableSymbol = function (row) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var type = pair.first.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n return pair.first;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Returns a new Symbol of the given type.\n *\n * @private\n */\n Solver.prototype._makeSymbol = function (type) {\n return new Symbol(type, this._idTick++);\n };\n return Solver;\n}());\nexport { Solver };\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n var eps = 1.0e-8;\n return value < 0.0 ? -value < eps : value < eps;\n}\n/**\n * An internal function for creating a constraint map.\n * @private\n */\nfunction createCnMap() {\n return createMap();\n}\n/**\n * An internal function for creating a row map.\n * @private\n */\nfunction createRowMap() {\n return createMap();\n}\n/**\n * An internal function for creating a variable map.\n * @private\n */\nfunction createVarMap() {\n return createMap();\n}\n/**\n * An internal function for creating an edit map.\n * @private\n */\nfunction createEditMap() {\n return createMap();\n}\n/**\n * An enum defining the available symbol types.\n * @private\n */\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Invalid\"] = 0] = \"Invalid\";\n SymbolType[SymbolType[\"External\"] = 1] = \"External\";\n SymbolType[SymbolType[\"Slack\"] = 2] = \"Slack\";\n SymbolType[SymbolType[\"Error\"] = 3] = \"Error\";\n SymbolType[SymbolType[\"Dummy\"] = 4] = \"Dummy\";\n})(SymbolType || (SymbolType = {}));\n/**\n * An internal class representing a symbol in the solver.\n * @private\n */\nvar Symbol = /** @class */ (function () {\n /**\n * Construct a new Symbol\n *\n * @param [type] The type of the symbol.\n * @param [id] The unique id number of the symbol.\n */\n function Symbol(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n Symbol.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the type of the symbol.\n */\n Symbol.prototype.type = function () {\n return this._type;\n };\n return Symbol;\n}());\n/**\n * A static invalid symbol\n * @private\n */\nvar INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nvar Row = /** @class */ (function () {\n /**\n * Construct a new Row.\n */\n function Row(constant) {\n if (constant === void 0) { constant = 0.0; }\n this._cellMap = createMap();\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n Row.prototype.cells = function () {\n return this._cellMap;\n };\n /**\n * Returns the constant for the row.\n */\n Row.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns true if the row is a constant value.\n */\n Row.prototype.isConstant = function () {\n return this._cellMap.empty();\n };\n /**\n * Returns true if the Row has all dummy symbols.\n */\n Row.prototype.allDummies = function () {\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() !== SymbolType.Dummy) {\n return false;\n }\n }\n return true;\n };\n /**\n * Create a copy of the row.\n */\n Row.prototype.copy = function () {\n var theCopy = new Row(this._constant);\n theCopy._cellMap = this._cellMap.copy();\n return theCopy;\n };\n /**\n * Add a constant value to the row constant.\n *\n * Returns the new value of the constant.\n */\n Row.prototype.add = function (value) {\n return this._constant += value;\n };\n /**\n * Insert the symbol into the row with the given coefficient.\n *\n * If the symbol already exists in the row, the coefficient\n * will be added to the existing coefficient. If the resulting\n * coefficient is zero, the symbol will be removed from the row.\n */\n Row.prototype.insertSymbol = function (symbol, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n var pair = this._cellMap.setDefault(symbol, function () { return 0.0; });\n if (nearZero(pair.second += coefficient)) {\n this._cellMap.erase(symbol);\n }\n };\n /**\n * Insert a row into this row with a given coefficient.\n *\n * The constant and the cells of the other row will be\n * multiplied by the coefficient and added to this row. Any\n * cell with a resulting coefficient of zero will be removed\n * from the row.\n */\n Row.prototype.insertRow = function (other, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n this._constant += other._constant * coefficient;\n var cells = other._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n };\n /**\n * Remove a symbol from the row.\n */\n Row.prototype.removeSymbol = function (symbol) {\n this._cellMap.erase(symbol);\n };\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n Row.prototype.reverseSign = function () {\n this._constant = -this._constant;\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n pair.second = -pair.second;\n }\n };\n /**\n * Solve the row for the given symbol.\n *\n * This method assumes the row is of the form\n * a * x + b * y + c = 0 and (assuming solve for x) will modify\n * the row to represent the right hand side of\n * x = -b/a * y - c / a. The target symbol will be removed from\n * the row, and the constant and other cells will be multiplied\n * by the negative inverse of the target coefficient.\n *\n * The given symbol *must* exist in the row.\n */\n Row.prototype.solveFor = function (symbol) {\n var cells = this._cellMap;\n var pair = cells.erase(symbol);\n var coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n cells.itemAt(i).second *= coeff;\n }\n };\n /**\n * Solve the row for the given symbols.\n *\n * This method assumes the row is of the form\n * x = b * y + c and will solve the row such that\n * y = x / b - c / b. The rhs symbol will be removed from the\n * row, the lhs added, and the result divided by the negative\n * inverse of the rhs coefficient.\n *\n * The lhs symbol *must not* exist in the row, and the rhs\n * symbol must* exist in the row.\n */\n Row.prototype.solveForEx = function (lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n };\n /**\n * Returns the coefficient for the given symbol.\n */\n Row.prototype.coefficientFor = function (symbol) {\n var pair = this._cellMap.find(symbol);\n return pair !== undefined ? pair.second : 0.0;\n };\n /**\n * Substitute a symbol with the data from another row.\n *\n * Given a row of the form a * x + b and a substitution of the\n * form x = 3 * y + c the row will be updated to reflect the\n * expression 3 * a * y + a * c + b.\n *\n * If the symbol does not exist in the row, this is a no-op.\n */\n Row.prototype.substitute = function (symbol, row) {\n var pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n };\n return Row;\n}());\n","/** @internal */\nexport const xSymbol = Symbol(\"xSymbol\");\n\n/** @internal */\nexport const ySymbol = Symbol(\"ySymbol\");\n\n/** @internal */\nexport const widthSymbol = Symbol(\"widthSymbol\");\n\n/** @internal */\nexport const heightSymbol = Symbol(\"heightSymbol\");\n\n/** @internal */\nexport const addUIElementSymbol = Symbol(\"addUIElementSymbol\");\n\n/** @internal */\nexport const removeUIElementSymbol = Symbol(\"removeUIElementSymbol\");\n\n/** @internal */\nexport const addUIConstraintSymbol = Symbol(\"addConstraintSymbol\");\n\n/** @internal */\nexport const removeUIConstraintSymbol = Symbol(\"removeUIConstraintSymbol\");\n\n/** @internal */\nexport const addConstraintSymbol = Symbol(\"addConstraintSymbol\");\n\n/** @internal */\nexport const removeConstraintSymbol = Symbol(\"removeConstraintSymbol\");\n\n/** @internal */\nexport const addVariableSymbol = Symbol(\"addVariableSymbol\");\n\n/** @internal */\nexport const removeVariableSymbol = Symbol(\"removeVariableSymbol\");\n\n/** @internal */\nexport const suggestVariableSymbol = Symbol(\"suggestVariableSymbol\");\n\n/** @internal */\nexport const disableConstraintSymbol = Symbol(\"disableConstraintSymbol\");\n\n/** @internal */\nexport const enableConstraintSymbol = Symbol(\"enableConstraintSymbol\");\n\n/** @internal */\nexport const needsRecalculation = Symbol(\"needsRecalculation\");\n\n/** @internal */\nexport const renderSymbol = Symbol(\"renderSymbol\");\n\n/** @internal */\nexport const clickSymbol = Symbol(\"clickSymbol\");\n\n/** @internal */\nexport const sortSymbol = Symbol(\"sortSymbol\");\n","/**\n * Defines the screen orientation states for UI constraints.\n * \n * This enum is used to specify when certain UI constraints should be active\n * based on the current device/screen orientation.\n */\nexport enum UIOrientation {\n /**\n * Indicates a landscape orientation (width > height).\n * Constraints using this value will only be active in landscape mode.\n */\n LANDSCAPE,\n \n /**\n * Indicates a portrait orientation (height > width).\n * Constraints using this value will only be active in portrait mode.\n */\n PORTRAIT,\n \n /**\n * Indicates that the constraint should always be active,\n * regardless of screen orientation.\n */\n ALWAYS,\n}\n\n/**\n * Type guard to check if a value is a valid UIOrientation.\n * \n * @param obj - The value to check\n * @returns True if the value is a valid UIOrientation enum value\n */\nexport function isUIOrientation(obj: unknown): obj is UIOrientation {\n return obj !== null && Object.values(UIOrientation).some((v) => v === obj);\n}\n\n/**\n * Resolves an optional orientation to a definite value.\n * \n * @param orientation - The orientation to resolve, or undefined\n * @returns The provided orientation, or ALWAYS if none was provided\n */\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","import type { UIAnchor } from \"../Elements/UIAnchor\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n addUIConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeUIConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\n/**\n * Abstract base class for all UI constraints in the system.\n *\n * Constraints control the layout of UI elements by establishing relationships\n * between their properties (position, size) and other elements or the screen.\n *\n * The constraint system uses Kiwi.js under the hood for solving the constraint system.\n * Each constraint adds specific rules to the solver that determine element positioning.\n */\nexport abstract class UIConstraint {\n /**\n * Optional identifier for the constraint.\n * Useful for debugging and identifying constraints.\n */\n public name = \"\";\n\n /**\n * Creates a new UI constraint.\n *\n * @param layer - The UI layer that will manage this constraint\n * @param elements - The set of UI elements affected by this constraint\n */\n constructor(\n public readonly layer: UILayer,\n elements: Set<UIElement | UIAnchor>,\n ) {\n this.layer[addUIConstraintSymbol](this, elements);\n }\n\n /**\n * Destroys the constraint, removing it from the layer and solver.\n * This should be called when the constraint is no longer needed.\n */\n public destroy(): void {\n this.layer[removeUIConstraintSymbol](this);\n }\n\n /**\n * Internal method called when the constraint should be disabled.\n * Typically called when the screen orientation changes and the\n * constraint is not applicable for the current orientation.\n *\n * @param orientation - The current UI orientation\n * @internal\n */\n public abstract [disableConstraintSymbol](orientation: UIOrientation): void;\n\n /**\n * Internal method called when the constraint should be enabled.\n * Typically called when the screen orientation changes and the\n * constraint becomes applicable for the current orientation.\n *\n * @param orientation - The current UI orientation\n * @internal\n */\n public abstract [enableConstraintSymbol](orientation: UIOrientation): void;\n}\n","import { Strength } from \"kiwi.js\";\n\n/**\n * Priority values for constraint strength calculation.\n * Higher values indicate stronger constraint enforcement.\n */\nconst HIGH_PRIORITY = 1000;\n/**\n * Medium priority value for constraint strength calculation.\n */\nconst MEDIUM_PRIORITY = 100;\n/**\n * Low priority value for constraint strength calculation.\n */\nconst LOW_PRIORITY = 10;\n\n/**\n * Defines the strength/priority levels for UI constraints.\n * \n * Constraints with higher power (lower index) take precedence over\n * those with lower power when the constraint solver can't satisfy all constraints.\n * \n * The enum values map to different strength configurations in the Kiwi.js solver:\n * - P0: Highest priority, \"required\" constraint that must be satisfied\n * - P1-P7: Decreasing levels of priority\n */\nexport enum UIConstraintPower {\n /** Highest priority - must be satisfied (required constraint) */\n P0,\n /** Very high priority */\n P1,\n /** High priority */\n P2,\n /** Medium-high priority */\n P3,\n /** Medium priority */\n P4,\n /** Medium-low priority */\n P5,\n /** Low priority */\n P6,\n /** Lowest priority */\n P7,\n}\n\n/**\n * Type guard to check if a value is a valid UIConstraintPower.\n * \n * @param obj - The value to check\n * @returns True if the value is a valid UIConstraintPower enum value\n */\nexport function isUIConstraintPower(obj: unknown): obj is UIConstraintPower {\n return (\n obj !== null && Object.values(UIConstraintPower).some((v) => v === obj)\n );\n}\n\n/**\n * Resolves an optional power level to a definite value.\n * \n * @param power - The constraint power to resolve, or undefined\n * @returns The provided power level, or P0 (highest) if none was provided\n */\nexport function resolvePower(power?: UIConstraintPower): UIConstraintPower {\n return power ?? UIConstraintPower.P0;\n}\n\n/**\n * Converts a UIConstraintPower enum value to a Kiwi.js strength value.\n * \n * The Kiwi.js constraint solver uses a three-tiered strength system.\n * This function maps our power levels to appropriate strength values:\n * \n * - P0: Maximum strength in all tiers (required constraint)\n * - P1-P2: Varying strengths in the first tier\n * - P3-P4: Varying strengths in the second tier\n * - P5-P7: Varying strengths in the third tier\n * \n * @param power - The constraint power to convert, or undefined\n * @returns A Kiwi.js strength value corresponding to the power level\n */\nexport function convertPowerToStrength(power?: UIConstraintPower): number {\n switch (power) {\n case UIConstraintPower.P0:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIConstraintPower.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIConstraintPower.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIConstraintPower.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIConstraintPower.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIConstraintPower.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIConstraintPower.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIConstraintPower.P7:\n return Strength.create(0, 0, 1);\n default:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n }\n}\n","import { Operator } from \"kiwi.js\";\n\n/**\n * Defines the type of relationship between values in a constraint.\n * \n * Maps directly to Kiwi.js Operators for the constraint solver.\n * Used to specify whether values should be equal, less than, or greater than each other.\n */\nexport enum UIConstraintRule {\n /**\n * Values must be equal (x = y).\n * Creates an equality constraint in the solver.\n */\n EQUAL = Operator.Eq,\n \n /**\n * Left value must be less than or equal to right value (x ≤ y).\n * Creates an inequality constraint in the solver.\n */\n LESS = Operator.Le,\n \n /**\n * Left value must be greater than or equal to right value (x ≥ y).\n * Creates an inequality constraint in the solver.\n */\n GREATER = Operator.Ge,\n}\n\n/**\n * Type guard to check if a value is a valid UIConstraintRule.\n * \n * @param obj - The value to check\n * @returns True if the value is a valid UIConstraintRule enum value\n */\nexport function isUIConstraintRule(obj: unknown): obj is UIConstraintRule {\n return obj !== null && Object.values(UIConstraintRule).some((v) => v === obj);\n}\n\n/**\n * Resolves an optional rule to a definite value.\n * \n * @param rule - The constraint rule to resolve, or undefined\n * @returns The provided rule, or EQUAL if none was provided\n */\nexport function resolveRule(rule?: UIConstraintRule): UIConstraintRule {\n return rule ?? UIConstraintRule.EQUAL;\n}\n\n/**\n * Converts a UIConstraintRule to the corresponding Kiwi.js Operator.\n * This function provides a safe way to convert between our enum and Kiwi's enum.\n * \n * @param rule - The constraint rule to convert, or undefined\n * @returns The corresponding Kiwi.js Operator value\n */\nexport function convertRuleToOperator(rule?: UIConstraintRule): Operator {\n switch (rule) {\n case UIConstraintRule.EQUAL:\n return Operator.Eq;\n case UIConstraintRule.LESS:\n return Operator.Le;\n case UIConstraintRule.GREATER:\n return Operator.Ge;\n default:\n return Operator.Eq;\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for height constraints.\n */\nexport interface UIHeightOptions {\n /** The fixed height value to constrain the element to */\n height: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific height for a UI element.\n *\n * This constraint can be configured to require an exact height\n * or set minimum/maximum height limits using different rules.\n */\nexport class UIHeightConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly options: UIHeightOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new height constraint.\n *\n * @param element - The UI element to constrain\n * @param options - Configuration options\n */\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIHeightOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n height: options?.height ?? element.height,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the height constraint to the constraint solver.\n *\n * Creates a constraint that enforces the element's height based\n * on the specified rule (equal to, less than, or greater than).\n *\n */\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[heightSymbol]),\n convertRuleToOperator(this.options.rule),\n this.options.height,\n convertPowerToStrength(this.options.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the height constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","/**\n * Default priority value for event listeners.\n * Lower values indicate higher priority.\n */\nconst DEFAULT_PRIORITY = 100;\n/**\n * A priority-based event emitter implementation.\n * The name \"Eventail\" is a combination of \"event\" + \"tail\", reflecting its queue-like nature.\n *\n * Features:\n * - Priority-based event listeners\n * - Context binding support\n * - One-time event listeners\n * - Type-safe event handling\n *\n * @example\n * ```typescript\n * const emitter = new Eventail();\n *\n * // Regular event listener\n * emitter.on('event', (data) => console.log(data));\n *\n * // One-time event listener with high priority\n * emitter.once('event', callback, context, 50);\n *\n * // Remove specific listener\n * emitter.off('event', callback);\n * ```\n */\nclass Eventail {\n constructor() {\n /** Map storing event listeners for each event type */\n this.listeners = new Map();\n }\n /**\n * Adds an event listener for the specified event type.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.on('data', (value) => console.log(value));\n * emitter.on('error', handleError, this, 50);\n * ```\n */\n on(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, false);\n return this;\n }\n /**\n * Adds a one-time event listener that will be removed after first execution.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.once('init', () => console.log('Initialized'));\n * ```\n */\n once(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, true);\n return this;\n }\n /**\n * Removes event listener(s) from the specified event type.\n *\n * @param type - The event type to remove listener(s) from\n * @param callback - Optional callback to remove specific listener\n * @param context - Optional context to match when removing\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * // Remove all listeners for 'data' event\n * emitter.off('data');\n *\n * // Remove specific listener\n * emitter.off('data', callback);\n *\n * // Remove listener with specific context\n * emitter.off('data', callback, context);\n * ```\n */\n off(type, callback, context) {\n const current = this.listeners.get(type);\n if (!current) {\n return this;\n }\n if (!callback) {\n this.listeners.delete(type);\n return this;\n }\n const filtered = current.filter((l) => l.callback !== callback ||\n (context !== undefined && l.context !== context));\n filtered.length\n ? this.listeners.set(type, filtered)\n : this.listeners.delete(type);\n return this;\n }\n /**\n * Emits an event, triggering all registered listeners in priority order.\n * Protected method to allow extension in derived classes.\n *\n * @param type - The event type to emit\n * @param args - Arguments to pass to the listeners\n * @returns Boolean indicating if the event had listeners\n *\n * @example\n * ```typescript\n * class MyEmitter extends Eventail {\n * public trigger(type: string, ...args: unknown[]) {\n * return this.emit(type, ...args);\n * }\n * }\n * ```\n */\n emit(type, ...args) {\n const current = this.listeners.get(type);\n if (!(current === null || current === void 0 ? void 0 : current.length)) {\n return false;\n }\n for (const listener of [...current]) {\n listener.callback.apply(listener.context, args);\n if (listener.once) {\n this.off(type, listener.callback, listener.context);\n }\n }\n return true;\n }\n /**\n * Internal method to add a new event listener with the specified configuration.\n * Maintains priority order and prevents duplicate listeners.\n *\n * @param type - Event type\n * @param callback - Event callback\n * @param context - Callback context\n * @param priority - Event priority\n * @param once - Whether it's a one-time listener\n * @throws {Error} If the listener already exists\n */\n addListener(type, callback, context, priority, once) {\n let list = this.listeners.get(type);\n if (!list) {\n list = [];\n this.listeners.set(type, list);\n }\n if (list.some((l) => l.callback === callback && l.context === context)) {\n throw new Error(\"Event listener already exists\");\n }\n const event = { callback, context, priority, once };\n let i = 0;\n while (i < list.length && list[i].priority <= priority) {\n i++;\n }\n list.splice(i, 0, event);\n }\n}\n\nexport { DEFAULT_PRIORITY, Eventail };\n//# sourceMappingURL=index.js.map\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { Object3D, WebGLRenderer } from \"three\";\nimport { MathUtils } from \"three\";\nimport {\n convertPowerToStrength,\n UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n addUIElementSymbol,\n addVariableSymbol,\n needsRecalculation,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n sortSymbol,\n suggestVariableSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\n\nexport abstract class UIAnchor extends Eventail {\n /** X position variable for constraint system */\n public [xSymbol] = new Variable(\"x\");\n\n /** Y position variable for constraint system */\n public [ySymbol] = new Variable(\"y\");\n\n /** Flag indicating whether the element needs recalculation */\n public [needsRecalculation] = false;\n\n /** Unique identifier for the element */\n public name = MathUtils.generateUUID();\n\n /**\n * Creates a new UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param x - Initial x position\n * @param y - Initial y position\n */\n constructor(\n public readonly layer: UILayer,\n x: number,\n y: number,\n protected readonly object?: Object3D,\n ) {\n super();\n\n if (this.object) {\n this.object.matrixAutoUpdate = false;\n }\n\n this.layer[addUIElementSymbol](this, object);\n\n this.layer[addVariableSymbol](\n this,\n this[xSymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[ySymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n\n this[xSymbol].setValue(x);\n this[ySymbol].setValue(y);\n\n this.layer[suggestVariableSymbol](this, this[xSymbol], x);\n this.layer[suggestVariableSymbol](this, this[ySymbol], y);\n }\n\n /** Gets the current x position of the anchor */\n public get x(): number {\n return this[xSymbol].value();\n }\n\n /** Gets the current y position of the anchor */\n public get y(): number {\n return this[ySymbol].value();\n }\n\n /** Gets the current z-index (depth) of the element */\n public get zIndex(): number {\n return this.object?.position.z ?? 0;\n }\n\n /** Gets whether the element needs recalculation */\n protected get needsRecalculation(): boolean {\n return this[needsRecalculation];\n }\n\n /**\n * Sets the x position of the element\n * @param value - New x position\n */\n public set x(value: number) {\n this.layer[suggestVariableSymbol](this, this[xSymbol], value);\n }\n\n /**\n * Sets the y position of the element\n * @param value - New y position\n */\n public set y(value: number) {\n this.layer[suggestVariableSymbol](this, this[ySymbol], value);\n }\n\n /**\n * Sets the z-index (depth) of the element\n * @param value - New z-index\n */\n public set zIndex(value: number) {\n if (this.object && this.object.renderOrder !== value) {\n this.object.position.z = value;\n this.object.renderOrder = value;\n this.layer[sortSymbol]();\n this.object.updateMatrix();\n }\n }\n\n /**\n * Destroys the anchor, cleaning up all resources and removing it from the layer.\n * This should be called when the anchor is no longer needed.\n */\n public destroy(): void {\n this.layer[removeVariableSymbol](this, this[ySymbol]);\n this.layer[removeVariableSymbol](this, this[xSymbol]);\n this.layer[removeUIElementSymbol](this);\n }\n\n /**\n * Internal method called by the rendering system to render this element.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n * @internal\n */\n public [renderSymbol](renderer: WebGLRenderer, deltaTime: number): void {\n this.render(renderer, deltaTime);\n }\n\n /**\n * Applies transformations to the underlying Three.js object.\n * This is called when the element's position, size, or other properties change.\n */\n protected applyTransformations(): void {\n if (this[needsRecalculation]) {\n if (this.object) {\n this.object.updateMatrix();\n }\n this[needsRecalculation] = false;\n }\n }\n\n /**\n * Renders the element.\n * This must be implemented by concrete subclasses.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n */\n protected abstract render(renderer: WebGLRenderer, deltaTime: number): void;\n}\n","import { Box2, Vector2 } from \"three\";\n\nconst tempVector2 = new Vector2();\nconst tempBox2 = new Box2();\n\nexport function testElement(\n elementX: number,\n elementY: number,\n elementWidth: number,\n elementHeight: number,\n xClick: number,\n yClick: number,\n): boolean {\n tempVector2.set(xClick, yClick);\n\n tempBox2.min.set(elementX, elementY);\n tempBox2.max.set(elementWidth, elementHeight).add(tempBox2.min);\n return tempBox2.containsPoint(tempVector2);\n}\n","import { Matrix3, Vector3, type Object3D } from \"three\";\nimport type { UIMicroInternal } from \"./UIMicro\";\n\nconst tempMatrixA = new Matrix3();\nconst tempMatrixB = new Matrix3();\nconst tempMatrixC = new Matrix3();\nconst tempMatrixD = new Matrix3();\nconst tempMatrixE = new Matrix3();\nconst tempVectorA = new Vector3();\n\nexport function applyMicroTransformations(\n object: Object3D,\n micro: UIMicroInternal,\n x: number,\n y: number,\n width: number,\n height: number,\n padding: number,\n): void {\n const realX = x - padding;\n const realY = y - padding;\n const realWidth = width + padding * 2;\n const realHeight = height + padding * 2;\n\n const anchorOffsetX = realWidth * micro.anchorX;\n const anchorOffsetY = realHeight * micro.anchorY;\n const centerX = realX + anchorOffsetX;\n const centerY = realY + anchorOffsetY;\n\n const translateToCenter = tempMatrixA.set(\n 1,\n 0,\n -centerX,\n 0,\n 1,\n -centerY,\n 0,\n 0,\n 1,\n );\n\n const scale = tempMatrixB.set(\n micro.scaleX,\n 0,\n 0,\n 0,\n micro.scaleY,\n 0,\n 0,\n 0,\n 1,\n );\n\n const rotation = tempMatrixC.set(\n Math.cos(micro.rotation),\n -Math.sin(micro.rotation),\n 0,\n Math.sin(micro.rotation),\n Math.cos(micro.rotation),\n 0,\n 0,\n 0,\n 1,\n );\n\n const translateFinal = tempMatrixD.set(\n 1,\n 0,\n micro.x + centerX,\n 0,\n 1,\n micro.y + centerY,\n 0,\n 0,\n 1,\n );\n\n const finalMatrix = tempMatrixE\n .multiplyMatrices(translateFinal, rotation)\n .multiply(scale)\n .multiply(translateToCenter);\n\n const point = tempVectorA.set(realX, realY, 1).applyMatrix3(finalMatrix);\n\n object.position.x = point.x;\n object.position.y = point.y;\n object.rotation.z = micro.rotation;\n object.scale.x = realWidth * micro.scaleX;\n object.scale.y = realHeight * micro.scaleY;\n}\n","import { MathUtils } from \"three\";\nimport type { UIElement } from \"../Elements/UIElement\";\n\n/**\n * Default position offset value (0)\n */\nconst DEFAULT_POSITION = 0;\n/**\n * Default anchor point value (0.5 = centered)\n */\nconst DEFAULT_ANCHOR = 0.5;\n/**\n * Default scale value (1 = no scaling)\n */\nconst DEFAULT_SCALE = 1;\n/**\n * Default rotation value in radians (0 = no rotation)\n */\nconst DEFAULT_ROTATION = 0;\n\n/**\n * Internal implementation of micro-transformations for UI elements.\n * Stores the raw transformation values and recalculation flag.\n *\n */\nexport class UIMicroInternal {\n /** X-axis offset from element position */\n public x = DEFAULT_POSITION;\n /** Y-axis offset from element position */\n public y = DEFAULT_POSITION;\n /** X-axis anchor point (0-1) where transformations are applied */\n public anchorX = DEFAULT_ANCHOR;\n /** Y-axis anchor point (0-1) where transformations are applied */\n public anchorY = DEFAULT_ANCHOR;\n /** X-axis scaling factor */\n public scaleX = DEFAULT_SCALE;\n /** Y-axis scaling factor */\n public scaleY = DEFAULT_SCALE;\n /** Rotation in radians */\n public rotation = DEFAULT_ROTATION;\n /** Flag indicating whether transformations need to be recalculated */\n public needsRecalculation = false;\n}\n\n/**\n * Provides fine-grained transformations for UI elements.\n *\n * Micro-transformations allow for detailed positioning, scaling, and rotation\n * adjustments relative to an element's base position and dimensions.\n * These transformations are applied on top of the standard element positioning\n * and can be used for effects like pivoting, offsetting, and animation.\n */\nexport class UIMicro {\n /**\n * Creates a new micro-transformation interface.\n *\n * @param raw - The internal state object that stores transformation values\n * @param owner - The UI element that owns these transformations\n */\n constructor(\n private readonly raw: UIMicroInternal,\n private readonly owner: UIElement,\n ) {}\n\n /**\n * Gets the X-axis offset from the element's position.\n */\n public get x(): number {\n return this.raw.x;\n }\n\n /**\n * Gets the Y-axis offset from the element's position.\n */\n public get y(): number {\n return this.raw.y;\n }\n\n /**\n * Gets the X-axis anchor point (0-1) where transformations are applied.\n *\n * - 0.0 = left edge\n * - 0.5 = center (default)\n * - 1.0 = right edge\n */\n public get anchorX(): number {\n return this.raw.anchorX;\n }\n\n /**\n * Gets the Y-axis anchor point (0-1) where transformations are applied.\n *\n * - 0.0 = top edge\n * - 0.5 = center (default)\n * - 1.0 = bottom edge\n */\n public get anchorY(): number {\n return this.raw.anchorY;\n }\n\n /**\n * Gets the X-axis scaling factor.\n *\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public get scaleX(): number {\n return this.raw.scaleX;\n }\n\n /**\n * Gets the Y-axis scaling factor.\n *\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public get scaleY(): number {\n return this.raw.scaleY;\n }\n\n /**\n * Gets the rotation in degrees.\n * Converted from the internal radians value.\n */\n public get angle(): number {\n return MathUtils.radToDeg(this.raw.rotation);\n }\n\n /**\n * Gets the rotation in radians.\n */\n public get rotation(): number {\n return this.raw.rotation;\n }\n\n /**\n * Sets the X-axis offset from the element's position.\n *\n * @param value - X offset in pixels\n */\n public set x(value: number) {\n if (value !== this.raw.x) {\n this.raw.x = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the Y-axis offset from the element's position.\n *\n * @param value - Y offset in pixels\n */\n public set y(value: number) {\n if (value !== this.raw.y) {\n this.raw.y = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the X-axis anchor point where transformations are applied.\n *\n * @param value - X anchor (0-1):\n * - 0.0 = left edge\n * - 0.5 = center (default)\n * - 1.0 = right edge\n */\n public set anchorX(value: number) {\n if (value !== this.raw.anchorX) {\n this.raw.anchorX = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the Y-axis anchor point where transformations are applied.\n *\n * @param value - Y anchor (0-1):\n * - 0.0 = top edge\n * - 0.5 = center (default)\n * - 1.0 = bottom edge\n */\n public set anchorY(value: number) {\n if (value !== this.raw.anchorY) {\n this.raw.anchorY = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the X-axis scaling factor.\n *\n * @param value - X scale factor:\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public set scaleX(value: number) {\n if (value !== this.raw.scaleX) {\n this.raw.scaleX = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the Y-axis scaling factor.\n *\n * @param value - Y scale factor:\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public set scaleY(value: number) {\n if (value !== this.raw.scaleY) {\n this.raw.scaleY = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the rotation in degrees.\n * Automatically converts to radians for internal storage.\n *\n * @param value - Rotation angle in degrees\n */\n public set angle(value: number) {\n const convertedValue = MathUtils.degToRad(value);\n if (convertedValue !== this.raw.rotation) {\n this.raw.rotation = convertedValue;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the rotation in radians.\n *\n * @param value - Rotation angle in radians\n */\n public set rotation(value: number) {\n if (value !== this.raw.rotation) {\n this.raw.rotation = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the anchor point based on global coordinates relative to the element.\n * Converts the global position to a normalized anchor point (0-1 range).\n *\n * This is useful for setting the pivot point to a specific position,\n * such as making an element rotate around a particular point.\n *\n * @param x - Global X coordinate to set as anchor\n * @param y - Global Y coordinate to set as anchor\n */\n public setAnchorByGlobalPosition(x: number, y: number): void {\n const deltaX = x - this.owner.x;\n const deltaY = y - this.owner.y;\n const newAnchorX = deltaX / this.owner.width;\n const newAnchorY = deltaY / this.owner.height;\n\n if (newAnchorX !== this.raw.anchorX || newAnchorY !== this.raw.anchorY) {\n this.raw.anchorX = newAnchorX;\n this.raw.anchorY = newAnchorY;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Resets all micro-transformations to their default values.\n *\n * Default values:\n * - Position (x, y): 0\n * - Anchor (anchorX, anchorY): 0.5 (centered)\n * - Scale (scaleX, scaleY): 1.0 (original size)\n * - Rotation: 0 (no rotation)\n *\n * Only triggers recalculation if any values were changed.\n */\n public reset(): void {\n if (\n this.raw.x !== DEFAULT_POSITION ||\n this.raw.y !== DEFAULT_POSITION ||\n this.raw.anchorX !== DEFAULT_ANCHOR ||\n this.raw.anchorY !== DEFAULT_ANCHOR ||\n this.raw.scaleX !== DEFAULT_SCALE ||\n this.raw.scaleY !== DEFAULT_SCALE ||\n this.raw.rotation !== DEFAULT_ROTATION\n ) {\n this.raw.x = DEFAULT_POSITION;\n this.raw.y = DEFAULT_POSITION;\n this.raw.anchorX = DEFAULT_ANCHOR;\n this.raw.anchorY = DEFAULT_ANCHOR;\n this.raw.scaleX = DEFAULT_SCALE;\n this.raw.scaleY = DEFAULT_SCALE;\n this.raw.rotation = DEFAULT_ROTATION;\n this.raw.needsRecalculation = true;\n }\n }\n}\n","/**\n * Defines the visibility and interactivity state of UI elements.\n * \n * UI elements can be in one of three states:\n * - Hidden: Element is not visible and does not receive input\n * - Visible: Element is visible but does not receive input\n * - Interactive: Element is visible and can receive input events\n */\nexport enum UIMode {\n /**\n * Element is not rendered and does not receive input events.\n * Equivalent to setting `display: none` in CSS.\n */\n HIDDEN,\n\n /**\n * Element is rendered but does not receive input events.\n * Equivalent to setting `pointer-events: none` in CSS.\n */\n VISIBLE,\n\n /**\n * Element is rendered and can receive input events.\n * This is the fully active state for UI elements.\n */\n INTERACTIVE,\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial } from \"three\";\n\nexport class UIMaterial extends ShaderMaterial {\n constructor(map?: Texture) {\n super({\n uniforms: {\n map: { value: map },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\n },\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\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 `,\n transparent: true,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: false,\n });\n }\n\n public getTexture(): Texture | undefined {\n return this.uniforms.map.value;\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public setTexture(value: Texture | undefined): void {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setOpacity(value: number): void {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n}\n","import { PlaneGeometry } from \"three\";\n\nconst GEOMETRY_SIZE = 1;\nconst GEOMETRY_OFFSET = 0.5;\n\nexport const geometry = new PlaneGeometry(\n GEOMETRY_SIZE,\n GEOMETRY_SIZE,\n).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);\n","import type { Material, WebGLRenderer } from \"three\";\nimport { Mesh, OrthographicCamera, Scene } from \"three\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\n\n/**\n * Shared scene and mesh used by all UIFullScreenQuad instances\n * This optimization avoids creating multiple meshes for rendering quads\n */\nconst scene = new Scene();\nconst mesh = new Mesh(geometry);\nscene.add(mesh);\n\n/**\n * Utility class for rendering a full-screen quad with optional padding\n * Used by the UI composition system to render passes\n */\nexport class UIFullScreenQuad {\n /**\n * Orthographic camera configured for device coordinates\n * Adjusted when padding changes to ensure correct rendering with padding\n */\n private readonly camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n /**\n * Creates a new UIFullScreenQuad\n *\n * @param paddingHorizontalInternal - Initial horizontal padding\n * @param paddingVerticalInternal - Initial vertical padding\n */\n constructor(\n private paddingHorizontalInternal = 0,\n private paddingVerticalInternal = 0,\n ) {\n this.updateCameraTransform();\n }\n\n /**\n * Gets the current horizontal padding\n */\n public get paddingHorizontal(): number {\n return this.paddingHorizontalInternal;\n }\n\n /**\n * Gets the current vertical padding\n */\n public get paddingVertical(): number {\n return this.paddingVerticalInternal;\n }\n\n /**\n * Sets the horizontal padding\n * Updates the camera projection when changed\n */\n public set paddingHorizontal(value: number) {\n if (this.paddingHorizontalInternal !== value) {\n this.paddingHorizontalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n /**\n * Sets the vertical padding\n * Updates the camera projection when changed\n */\n public set paddingVertical(value: number) {\n if (this.paddingVerticalInternal !== value) {\n this.paddingVerticalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n /**\n * Renders the fullscreen quad with the provided material\n *\n * @param renderer - The WebGL renderer to use\n * @param material - The material to apply to the fullscreen quad\n */\n public render(renderer: WebGLRenderer, material: Material): void {\n mesh.material = material;\n renderer.render(scene, this.camera);\n }\n\n /**\n * Updates the camera projection matrix to account for padding\n * Expands the camera frustum to include the padded area\n */\n private updateCameraTransform(): void {\n this.camera.left = -this.paddingHorizontalInternal;\n this.camera.right = 1 + this.paddingHorizontalInternal;\n this.camera.bottom = -this.paddingVerticalInternal;\n this.camera.top = 1 + this.paddingVerticalInternal;\n this.camera.updateProjectionMatrix();\n }\n}\n","import type { Material, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n NoBlending,\n RGBAFormat,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { UIFullScreenQuad } from \"./UIFullScreenQuad\";\nimport type { UIPass } from \"./UIPass\";\n\n/**\n * UI composition system for applying post-processing effects to rendered UI\n * The system manages render targets and passes to create complex visual effects\n */\n\n/**\n * Internal implementation of the UI composition system\n * Handles the actual rendering and composition of passes\n */\nexport class UIComposerInternal {\n /** Collection of all registered composition passes */\n public readonly passes: UIPass[] = [];\n\n /** Source render target used during ping-pong rendering */\n private fromRenderTarget: WebGLRenderTarget;\n /** Destination render target used during ping-pong rendering */\n private toRenderTarget: WebGLRenderTarget;\n\n /** Default material used to render the final result */\n private readonly defaultMaterial = new UIMaterial();\n /** Full-screen quad used for rendering */\n private readonly screen = new UIFullScreenQuad();\n\n /** Whether the composition needs to be updated */\n private needsUpdateInternal = false;\n /** Whether the padding has changed since last frame */\n private paddingHasChangedInternal = false;\n /** Current padding value in pixels */\n private paddingInternal = 0;\n\n /**\n * Creates a new UI composer with initial render targets\n */\n constructor() {\n const parameters = {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: false,\n stencilBuffer: false,\n };\n this.fromRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n this.toRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n this.fromRenderTarget.texture.generateMipmaps = false;\n this.toRenderTarget.texture.generateMipmaps = false;\n }\n\n /**\n * Whether the composition needs to be updated in the next frame\n * True when either the composer or any valuable passes need update\n */\n public get needsUpdate(): boolean {\n return (\n (this.needsUpdateInternal && this.hasValuablePasses()) ||\n this.hasPassesNeedingUpdate()\n );\n }\n\n /**\n * Whether the padding has changed since the last frame\n * Used to trigger layout updates when padding changes\n */\n public get paddingHasChanged(): boolean {\n return this.paddingHasChangedInternal;\n }\n\n /**\n * Current padding in pixels used for the composition\n * Calculated as the maximum padding required by all passes\n */\n public get padding(): number {\n return this.paddingInternal;\n }\n\n /**\n * Requests an update for the next frame\n * Will trigger a re-composition of all passes\n */\n public requestUpdate(): void {\n this.needsUpdateInternal = true;\n }\n\n /**\n * Composes all registered passes to create the final result\n * \n * @param renderer - WebGL renderer to use for composition\n * @param width - Width of the render target in pixels\n * @param height - Height of the render target in pixels\n * @param material - Input material containing the initial texture\n * @param canOverrideBlending - Whether blending can be overridden on the input material\n * @returns Material to use for rendering the composed result\n */\n public compose(\n renderer: WebGLRenderer,\n width: number,\n height: number,\n material: Material,\n canOverrideBlending = true,\n ): Material {\n const hasValuablePasses = this.hasValuablePasses();\n if (\n (!this.needsUpdateInternal || !hasValuablePasses) &&\n !this.hasPassesNeedingUpdate()\n ) {\n if (!hasValuablePasses) {\n this.paddingHasChangedInternal = this.paddingInternal !== 0;\n this.paddingInternal = 0;\n }\n this.needsUpdateInternal = false;\n return hasValuablePasses ? this.defaultMaterial : material;\n }\n\n const padding = this.calculatePadding();\n this.paddingHasChangedInternal = this.paddingInternal !== padding;\n this.paddingInternal = padding;\n\n const widthWithPadding = width + padding * 2;\n const heightWithPadding = height + padding * 2;\n\n this.fromRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.toRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.setScreenPadding(width, height, padding);\n\n renderer.setClearColor(0x000000, 0);\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n\n const originalBlending = material.blending;\n if (canOverrideBlending) {\n material.blending = NoBlending;\n }\n this.screen.render(renderer, material);\n material.blending = originalBlending;\n\n const options = { width, height, padding };\n\n for (let i = 0; i < this.passes.length; i++) {\n const pass = this.passes[i];\n if (pass.needsUpdate || pass.isValuable) {\n this.reverseRenderTargets();\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n this.passes[i].render(renderer, this.fromRenderTarget.texture, options);\n }\n }\n\n this.needsUpdateInternal = false;\n this.defaultMaterial.setTexture(this.toRenderTarget.texture);\n return this.defaultMaterial;\n }\n\n /**\n * Cleans up resources used by the composer\n * Should be called when the composer is no longer needed\n */\n public destroy(): void {\n this.fromRenderTarget.dispose();\n this.toRenderTarget.dispose();\n }\n\n /**\n * Checks if any passes are valuable (contribute meaningful effects)\n * @returns True if at least one pass is valuable\n */\n private hasValuablePasses(): boolean {\n return this.passes.some((p) => p.isValuable);\n }\n\n /**\n * Checks if any passes need an update\n * @returns True if at least one pass needs update\n */\n private hasPassesNeedingUpdate(): boolean {\n return this.passes.some((p) => p.needsUpdate);\n }\n\n /**\n * Calculates the maximum padding required by all passes\n * @returns Maximum padding value in pixels\n */\n private calculatePadding(): number {\n return this.passes.reduce((a, p) => Math.max(a, p.padding), 0);\n }\n\n /**\n * Updates the screen quad's padding based on dimensions\n * \n * @param width - Width of the render target in pixels\n * @param height - Height of the render target in pixels\n * @param padding - Padding value in pixels\n */\n private setScreenPadding(\n width: number,\n height: number,\n padding: number,\n ): void {\n this.screen.paddingHorizontal = padding / width;\n this.screen.paddingVertical = padding / height;\n }\n\n /**\n * Swaps the from and to render targets\n * Used for ping-pong rendering between passes\n */\n private reverseRenderTargets(): void {\n const fromRenderTarget = this.fromRenderTarget;\n this.fromRenderTarget = this.toRenderTarget;\n this.toRenderTarget = fromRenderTarget;\n }\n}\n\n/**\n * Public interface for the UI composition system\n * Provides a simplified API for managing UI passes\n */\nexport class UIComposer {\n /**\n * Creates a new UI composer\n * \n * @param raw - Internal implementation that handles actual rendering\n */\n constructor(private readonly raw: UIComposerInternal) {}\n\n /**\n * Collection of all registered composition passes\n * Add passes to this collection to apply effects to the UI\n */\n public get passes(): UIPass[] {\n return this.raw.passes;\n }\n}\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { WebGLRenderer } from \"three\";\nimport { MathUtils, type Object3D } from \"three\";\nimport {\n convertPowerToStrength,\n UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { testElement } from \"../Miscellaneous/math\";\nimport { applyMicroTransformations } from \"../Miscellaneous/microTransformationTools\";\nimport {\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n heightSymbol,\n needsRecalculation,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n sortSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIMicro, UIMicroInternal } from \"../Miscellaneous/UIMicro\";\nimport { UIMode } from \"../Miscellaneous/UIMode\";\nimport { UIComposer, UIComposerInternal } from \"../Passes/UIComposer\";\n\n/**\n * Events that can be emitted by UI elements.\n */\nexport enum UIElementEvent {\n /** Triggered when an interactive element is clicked */\n CLICK = \"click\",\n}\n\n/**\n * Abstract base class for all UI elements in the system.\n * Provides core functionality for positioning, sizing, and rendering UI elements.\n *\n * Each UI element has:\n * - Position (x, y) and size (width, height) variables\n * - Layer management integration\n * - Event handling capabilities\n * - Micro transformations support\n * - Rendering capabilities\n */\nexport abstract class UIElement extends Eventail {\n /** X position variable for constraint system */\n public [xSymbol] = new Variable(\"x\");\n\n /** Y position variable for constraint system */\n public [ySymbol] = new Variable(\"y\");\n\n /** Width variable for constraint system */\n public [widthSymbol] = new Variable(\"width\");\n\n /** Height variable for constraint system */\n public [heightSymbol] = new Variable(\"height\");\n\n /** Flag indicating whether the element needs recalculation */\n public [needsRecalculation] = false;\n\n /** Unique identifier for the element */\n public name = MathUtils.generateUUID();\n\n /** Micro transformation interface for the element */\n public readonly micro: UIMicro;\n\n /** Composer interface for the element */\n public readonly composer: UIComposer;\n\n /** Internal micro transformation implementation */\n protected readonly microInternal = new UIMicroInternal();\n\n /** Internal composer implementation */\n protected readonly composerInternal = new UIComposerInternal();\n\n /** Current visibility/interactivity mode */\n protected modeInternal = UIMode.VISIBLE;\n\n /**\n * Creates a new UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param object - The Three.js object that represents this element\n * @param x - Initial x position\n * @param y - Initial y position\n * @param width - Initial width\n * @param height - Initial height\n */\n constructor(\n public readonly layer: UILayer,\n protected readonly object: Object3D,\n x: number,\n y: number,\n width: number,\n height: number,\n ) {\n super();\n this.micro = new UIMicro(this.microInternal, this);\n this.composer = new UIComposer(this.composerInternal);\n\n this.object.matrixAutoUpdate = false;\n\n this.layer[addUIElementSymbol](this, this.object);\n\n this.layer[addVariableSymbol](\n this,\n this[xSymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[ySymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[widthSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n this.layer[addVariableSymbol](\n this,\n this[heightSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n\n this[xSymbol].setValue(x);\n this[ySymbol].setValue(y);\n this[widthSymbol].setValue(width);\n this[heightSymbol].setValue(height);\n\n this.layer[suggestVariableSymbol](this, this[xSymbol], x);\n this.layer[suggestVariableSymbol](this, this[ySymbol], y);\n this.layer[suggestVariableSymbol](this, this[widthSymbol], width);\n this.layer[suggestVariableSymbol](this, this[heightSymbol], height);\n }\n\n /** Gets the current x position of the element */\n public get x(): number {\n return this[xSymbol].value();\n }\n\n /** Gets the current y position of the element */\n public get y(): number {\n return this[ySymbol].value();\n }\n\n /** Gets the current width of the element */\n public get width(): number {\n return this[widthSymbol].value();\n }\n\n /** Gets the current height of the element */\n public get height(): number {\n return this[heightSymbol].value();\n }\n\n /** Gets the current z-index (depth) of the element */\n public get zIndex(): number {\n return this.object.position.z;\n }\n\n /** Gets the current visibility/interactivity mode of the element */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /** Gets whether the element needs recalculation */\n protected get needsRecalculation(): boolean {\n return this[needsRecalculation];\n }\n\n /**\n * Sets the x position of the element\n * @param value - New x position\n */\n public set x(value: number) {\n this.layer[suggestVariableSymbol](this, this[xSymbol], value);\n }\n\n /**\n * Sets the y position of the element\n * @param value - New y position\n */\n public set y(value: number) {\n this.layer[suggestVariableSymbol](this, this[ySymbol], value);\n }\n\n /**\n * Sets the width of the element\n * @param value - New width\n */\n public set width(value: number) {\n this.layer[suggestVariableSymbol](this, this[widthSymbol], value);\n }\n\n /**\n * Sets the height of the element\n * @param value - New height\n */\n public set height(value: number) {\n this.layer[suggestVariableSymbol](this, this[heightSymbol], value);\n }\n\n /**\n * Sets the z-index (depth) of the element\n * @param value - New z-index\n */\n public set zIndex(value: number) {\n if (this.object.renderOrder !== value) {\n this.object.position.z = value;\n this.object.renderOrder = value;\n this.layer[sortSymbol]();\n this.object.updateMatrix();\n }\n }\n\n /**\n * Sets the visibility/interactivity mode of the element\n * @param value - New UI mode\n */\n public set mode(value: UIMode) {\n this.modeInternal = value;\n this.object.visible = value !== UIMode.HIDDEN;\n }\n\n /**\n * Destroys the element, cleaning up all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public destroy(): void {\n this.composerInternal.destroy();\n this.layer[removeVariableSymbol](this, this[heightSymbol]);\n this.layer[removeVariableSymbol](this, this[widthSymbol]);\n this.layer[removeVariableSymbol](this, this[ySymbol]);\n this.layer[removeVariableSymbol](this, this[xSymbol]);\n this.layer[removeUIElementSymbol](this);\n }\n\n /**\n * Internal method called by the rendering system to render this element.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n * @internal\n */\n public [renderSymbol](renderer: WebGLRenderer, deltaTime: number): void {\n this.render(renderer, deltaTime);\n }\n\n /**\n * Internal method called by the event system to handle clicks on this element.\n *\n * @param x - X coordinate of the click\n * @param y - Y coordinate of the click\n * @returns Whether the click was handled by this element\n * @internal\n */\n public [clickSymbol](x: number, y: number): boolean {\n return this.click(x, y);\n }\n\n /**\n * Applies transformations to the underlying Three.js object.\n * This is called when the element's position, size, or other properties change.\n */\n protected applyTransformations(): void {\n if (\n this[needsRecalculation] ||\n this.microInternal.needsRecalculation ||\n this.composerInternal.paddingHasChanged\n ) {\n applyMicroTransformations(\n this.object,\n this.microInternal,\n this.x,\n this.y,\n this.width,\n this.height,\n this.composerInternal.padding,\n );\n\n this.object.updateMatrix();\n\n this[needsRecalculation] = false;\n this.microInternal.needsRecalculation = false;\n }\n }\n\n /**\n * Handles click events on this element.\n *\n * @param x - X coordinate of the click\n * @param y - Y coordinate of the click\n * @returns Whether the click was handled by this element\n */\n protected click(x: number, y: number): boolean {\n if (this.mode !== UIMode.INTERACTIVE) {\n return false;\n }\n\n this.applyTransformations();\n if (testElement(this.x, this.y, this.width, this.height, x, y)) {\n this.emit(UIElementEvent.CLICK, this);\n return true;\n }\n\n return false;\n }\n\n /**\n * Renders the element.\n * This must be implemented by concrete subclasses.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n */\n protected abstract render(renderer: WebGLRenderer, deltaTime: number): void;\n}\n","import { Eventail } from \"eventail\";\nimport {\n Constraint,\n Expression,\n Operator,\n Solver,\n Strength,\n Variable,\n} from \"kiwi.js\";\nimport type { Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIConstraint } from \"../Constraints/UIConstraint\";\nimport { UIAnchor } from \"../Elements/UIAnchor\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n addUIConstraintSymbol,\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n needsRecalculation,\n removeConstraintSymbol,\n removeUIConstraintSymbol,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n sortSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIMode } from \"../Miscellaneous/UIMode\";\nimport { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nconst clearColor = new Color(0x000000);\n\ninterface VariableDescription {\n strength: number;\n suggestedValue: number;\n}\n\ninterface UIElementDescription {\n object?: Object3D;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<UIConstraint>;\n}\n\ninterface UIConstraintDescription {\n elements: Set<UIElement | UIAnchor>;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<Constraint>;\n}\n\nexport enum UILayerEvent {\n ORIENTATION_CHANGED = \"orientationChanged\",\n}\n\nexport abstract class UILayer extends Eventail {\n public mode = UIMode.VISIBLE;\n\n public readonly [xSymbol]: Variable = new Variable();\n public readonly [ySymbol]: Variable = new Variable();\n public readonly [widthSymbol]: Variable = new Variable();\n public readonly [heightSymbol]: Variable = new Variable();\n\n protected readonly scene = new Scene();\n protected readonly camera = new OrthographicCamera();\n protected solver? = new Solver();\n\n protected elements = new Map<UIElement | UIAnchor, UIElementDescription>();\n protected constraints = new Map<UIConstraint, UIConstraintDescription>();\n\n protected constraintX?: Constraint;\n protected constraintY?: Constraint;\n protected constraintW?: Constraint;\n protected constraintH?: Constraint;\n\n protected orientationPrivate = UIOrientation.PORTRAIT;\n protected needsRecalculation = false;\n\n public get orientation(): UIOrientation {\n return this.orientationPrivate;\n }\n\n public get width(): number {\n return this[widthSymbol].value();\n }\n\n public get height(): number {\n return this[heightSymbol].value();\n }\n\n public destroy(): void {\n this.solver = undefined;\n for (const constraint of this.constraints.keys()) {\n constraint.destroy();\n }\n for (const element of this.elements.keys()) {\n element.destroy();\n }\n }\n\n public [addUIElementSymbol](\n element: UIElement | UIAnchor,\n object?: Object3D,\n renderOrder?: number,\n ): void {\n if (this.elements.has(element)) {\n throw new Error(\"Element already added\");\n }\n\n this.elements.set(element, {\n object,\n variables: new Map(),\n constraints: new Set(),\n });\n\n if (object) {\n const zIndex = renderOrder ?? this.scene.children.length;\n\n object.position.z = zIndex;\n object.renderOrder = zIndex;\n\n this.scene.add(object);\n this[sortSymbol]();\n }\n }\n\n public [removeUIElementSymbol](element: UIElement | UIAnchor): void {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing element\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\"Constraints should be removed before removing element\");\n }\n\n this.elements.delete(element);\n if (dependencies.object) {\n this.scene.remove(dependencies.object);\n }\n }\n\n public [addUIConstraintSymbol](\n constraint: UIConstraint,\n elements: Set<UIElement | UIAnchor>,\n ): void {\n if (this.constraints.has(constraint)) {\n throw new Error(\"Constraint already added\");\n }\n\n for (const element of elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.add(constraint);\n }\n\n this.constraints.set(constraint, {\n elements,\n variables: new Map(),\n constraints: new Set(),\n });\n }\n\n public [removeUIConstraintSymbol](constraint: UIConstraint): void {\n const dependencies = this.constraints.get(constraint);\n if (dependencies === undefined) {\n throw new Error(\"Constraint not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing constraint\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\n \"Constraints should be removed before removing constraint\",\n );\n }\n\n for (const element of dependencies.elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.delete(constraint);\n }\n\n this.constraints.delete(constraint);\n }\n\n public [addConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before adding constraint you need to add it's owner\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint already exists\");\n }\n\n dependencies.constraints.add(constraint);\n this.solver?.addConstraint(constraint);\n this.needsRecalculation = true;\n }\n\n public [removeConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before removing constraint you need to add it's owner\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint not found\");\n }\n\n dependencies.constraints.delete(constraint);\n this.solver?.removeConstraint(constraint);\n this.needsRecalculation = true;\n }\n\n public [addVariableSymbol](\n owner: UIElement | UIAnchor | UIConstraint,\n variable: Variable,\n strength: number,\n ): void {\n const dependencies =\n owner instanceof UIElement || owner instanceof UIAnchor\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before adding variable you need to add it's owner\");\n }\n\n if (dependencies.variables.has(variable)) {\n throw new Error(\"Variable already exists\");\n }\n\n dependencies.variables.set(variable, {\n strength,\n suggestedValue: variable.value(),\n });\n this.solver?.addEditVariable(variable, strength);\n this.needsRecalculation = true;\n }\n\n public [removeVariableSymbol](\n owner: UIElement | UIAnchor | UIConstraint,\n variable: Variable,\n ): void {\n const dependencies =\n owner instanceof UIElement || owner instanceof UIAnchor\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before removing variable you need to add it's owner\");\n }\n\n if (!dependencies.variables.has(variable)) {\n throw new Error(\"Variable does not exist\");\n }\n\n dependencies.variables.delete(variable);\n this.solver?.removeEditVariable(variable);\n this.needsRecalculation = true;\n }\n\n public [suggestVariableSymbol](\n owner: UIElement | UIAnchor | UIConstraint,\n variable: Variable,\n value: number,\n ): void {\n const dependencies =\n owner instanceof UIElement || owner instanceof UIAnchor\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before suggesting variable you need to add it's owner\");\n }\n\n const description = dependencies.variables.get(variable);\n\n if (!description) {\n throw new Error(\"Variable does not exist\");\n }\n\n if (description.suggestedValue !== value) {\n description.suggestedValue = value;\n this.solver?.suggestValue(variable, value);\n this.needsRecalculation = true;\n }\n }\n\n public [sortSymbol](): void {\n this.scene.children.sort(\n (a: Object3D, b: Object3D) => a.position.z - b.position.z,\n );\n\n for (let i = 0; i < this.scene.children.length; i++) {\n const child = this.scene.children[i];\n child.position.z = i;\n child.renderOrder = i;\n }\n\n const gap = 1;\n\n this.camera.position.set(0, 0, this.scene.children.length + gap);\n this.camera.near = 1;\n this.camera.far = this.scene.children.length + gap + gap;\n this.camera.updateProjectionMatrix();\n this.camera.updateMatrix();\n }\n\n public render(renderer: WebGLRenderer, deltaTime: number): void {\n if (this.mode === UIMode.HIDDEN) {\n return;\n }\n\n const originalRenderTarget = renderer.getRenderTarget();\n const originalClearColor = renderer.getClearColor(clearColor);\n const originalClearAlpha = renderer.getClearAlpha();\n\n if (this.needsRecalculation) {\n this.needsRecalculation = false;\n this.solver?.updateVariables();\n\n for (const element of this.elements.keys()) {\n element[needsRecalculation] = true;\n }\n }\n\n for (const element of this.elements.keys()) {\n element[renderSymbol](renderer, deltaTime);\n }\n\n renderer.setRenderTarget(originalRenderTarget);\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.render(this.scene, this.camera);\n }\n\n protected clickInternal(x: number, y: number): void {\n if (this.mode !== UIMode.INTERACTIVE) {\n return;\n }\n\n const elements = [...this.elements.keys()]\n .filter((e: UIElement | UIAnchor) => e instanceof UIElement)\n .filter((e: UIElement) => e.mode === UIMode.INTERACTIVE)\n .sort((a: UIElement, b: UIElement) => a.zIndex - b.zIndex);\n\n for (const element of elements) {\n if (element[clickSymbol](x, y)) {\n break;\n }\n }\n }\n\n protected resizeInternal(width: number, height: number): void {\n this.applyCameraSize(width, height);\n this.rebuildLayerConstraints(width, height);\n this.updateOrientation(width, height);\n this.needsRecalculation = true;\n }\n\n protected applyCameraSize(width: number, height: number): void {\n this.camera.bottom = 0;\n this.camera.left = 0;\n this.camera.right = width;\n this.camera.top = height;\n this.camera.updateProjectionMatrix();\n }\n\n protected rebuildLayerConstraints(width: number, height: number): void {\n if (this.constraintX) {\n this.solver?.removeConstraint(this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.solver?.removeConstraint(this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.solver?.removeConstraint(this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.solver?.removeConstraint(this.constraintH);\n this.constraintH = undefined;\n }\n\n this.constraintX = new Constraint(\n new Expression(this[xSymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintY = new Constraint(\n new Expression(this[ySymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintW = new Constraint(\n new Expression(this[widthSymbol]),\n Operator.Eq,\n width,\n Strength.required,\n );\n\n this.constraintH = new Constraint(\n new Expression(this[heightSymbol]),\n Operator.Eq,\n height,\n Strength.required,\n );\n\n this.solver?.addConstraint(this.constraintX);\n this.solver?.addConstraint(this.constraintY);\n this.solver?.addConstraint(this.constraintW);\n this.solver?.addConstraint(this.constraintH);\n }\n\n protected updateOrientation(width: number, height: number): void {\n const lastOrientation = this.orientationPrivate;\n this.orientationPrivate =\n width > height ? UIOrientation.LANDSCAPE : UIOrientation.PORTRAIT;\n\n if (lastOrientation !== this.orientationPrivate) {\n this.solver = undefined;\n\n for (const constraint of this.constraints.keys()) {\n constraint[enableConstraintSymbol](this.orientationPrivate);\n }\n for (const constraint of this.constraints.keys()) {\n constraint[disableConstraintSymbol](this.orientationPrivate);\n }\n\n this.solver = new Solver();\n const descriptions = [\n ...this.elements.values(),\n ...this.constraints.values(),\n ];\n\n for (const description of descriptions) {\n for (const [key, value] of description.variables.entries()) {\n this.solver.addEditVariable(key, value.strength);\n this.solver.suggestValue(key, value.suggestedValue);\n }\n }\n\n if (this.constraintX) {\n this.solver.addConstraint(this.constraintX);\n }\n if (this.constraintY) {\n this.solver.addConstraint(this.constraintY);\n }\n if (this.constraintW) {\n this.solver.addConstraint(this.constraintW);\n }\n if (this.constraintH) {\n this.solver.addConstraint(this.constraintH);\n }\n\n for (const dependency of this.constraints.values()) {\n for (const constraint of dependency.constraints.values()) {\n this.solver.addConstraint(constraint);\n }\n }\n\n this.emit(UILayerEvent.ORIENTATION_CHANGED, this, this.orientation);\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport enum UIConstraintContainerDirection {\n FROM_LEFT_TOP,\n FROM_LEFT_BOTTOM,\n}\n\nexport interface UIConstraintContainerBuilderOptions {\n direction: UIConstraintContainerDirection;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport class UIConstraintContainerBuilder {\n public static build(\n container: UIElement,\n elementOne: UIElement,\n elementTwo: UIElement,\n options: Partial<UIConstraintContainerBuilderOptions> = {},\n ): {\n horizontalDistances: UIHorizontalDistanceConstraint[];\n verticalDistances: UIVerticalDistanceConstraint[];\n } {\n const direction =\n options.direction ?? UIConstraintContainerDirection.FROM_LEFT_TOP;\n\n const horizontalDistances: UIHorizontalDistanceConstraint[] = [];\n const verticalDistances: UIVerticalDistanceConstraint[] = [];\n\n horizontalDistances.push(\n new UIHorizontalDistanceConstraint(container, elementOne, {\n anchorOne: 0,\n anchorTwo: 0,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIHorizontalDistanceConstraint(container, elementTwo, {\n anchorOne: 1,\n anchorTwo: 1,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n const anchorOne =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 1 : 0;\n const anchorTwo =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 0 : 1;\n\n verticalDistances.push(\n new UIVerticalDistanceConstraint(container, elementOne, {\n anchorOne: anchorOne,\n anchorTwo: anchorOne,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIVerticalDistanceConstraint(container, elementTwo, {\n anchorOne: anchorTwo,\n anchorTwo: anchorTwo,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n return {\n horizontalDistances,\n verticalDistances,\n };\n }\n}\n","import type { Camera, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n Mesh,\n PerspectiveCamera,\n RGBAFormat,\n Scene,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Defines when a UIScene should be rendered/updated.\n */\nexport enum UISceneUpdateMode {\n /** Scene is rendered on every frame */\n ALWAYS = \"always\",\n /** Scene is rendered when any property changes */\n PROPERTY_CHANGED = \"property_changed\",\n /** Scene is only rendered when explicitly requested */\n MANUAL = \"manual\",\n}\n\n/** Default factor for reducing render target resolution (0.5 = half resolution) */\nconst DEFAULT_RESOLUTION_FACTOR = 0.5;\n/** Minimum allowed resolution factor */\nconst MIN_RESOLUTION_FACTOR = 0.1;\n/** Maximum allowed resolution factor */\nconst MAX_RESOLUTION_FACTOR = 8;\n/** Default width for the scene if not specified */\nconst DEFAULT_WIDTH = 512;\n/** Default height for the scene if not specified */\nconst DEFAULT_HEIGHT = 512;\n/** Default field of view for the perspective camera in degrees */\nconst DEFAULT_FOV = 75;\n/** Default near plane distance for the perspective camera */\nconst DEFAULT_NEAR = 0.1;\n/** Default far plane distance for the perspective camera */\nconst DEFAULT_FAR = 100;\n/** Default update mode for the scene */\nconst DEFAULT_UPDATE_MODE = UISceneUpdateMode.PROPERTY_CHANGED;\n/** Default clear color (black) */\nconst DEFAULT_CLEAR_COLOR = 0x000000;\n/** Default clear alpha (fully transparent) */\nconst DEFAULT_CLEAR_ALPHA = 0;\n/** Whether the scene is rendered immediately by default */\nconst DEFAULT_RENDERED_BY_DEFAULT = false;\n/** Whether to use a depth buffer by default */\nconst DEFAULT_USE_DEPTH = true;\n\n/**\n * Options for customizing the UIScene element.\n */\nexport interface UISceneOptions {\n /** Three.js scene to render */\n scene: Scene;\n /** Camera to use for rendering the scene */\n camera: Camera;\n /** Width of the scene viewport in pixels */\n width: number;\n /** Height of the scene viewport in pixels */\n height: number;\n /** Resolution scaling factor for performance optimization */\n resolutionFactor: number;\n /** Whether the scene should be rendered immediately after creation */\n renderedByDefault: boolean;\n /** Whether to use a depth buffer for rendering */\n useDepth: boolean;\n /** Color to clear the scene with before rendering */\n clearColor: number;\n /** Alpha value for the clear color (0-1) */\n clearAlpha: number;\n /** When the scene should be automatically re-rendered */\n updateBehavior: UISceneUpdateMode;\n}\n\n/**\n * A UI element that renders a Three.js scene as a texture.\n * This allows 3D content to be integrated into the 2D UI system.\n */\nexport class UIScene extends UIElement {\n /** Material used to render the scene's render target */\n private readonly material: UIMaterial;\n /** WebGL render target where the scene is rendered */\n private readonly renderTarget: WebGLRenderTarget;\n\n /** Color to clear the scene with before rendering */\n private clearColorInternal: number;\n /** Alpha value for the clear color */\n private clearAlphaInternal: number;\n\n /** Whether the scene needs to be re-rendered on the next frame */\n private needsRenderInternal = false;\n /** When the scene should be automatically re-rendered */\n private readonly updateModeInternal: UISceneUpdateMode;\n /** Resolution scaling factor for performance optimization */\n private resolutionFactorInternal: number;\n\n /** The Three.js scene being rendered */\n private sceneInternal: Scene;\n /** The camera used for rendering the scene */\n private cameraInternal: Camera;\n\n /**\n * Creates a new scene UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param options - Options to customize the scene\n * @throws Error if resolution factor is out of valid range or dimensions are invalid\n */\n constructor(layer: UILayer, options: Partial<UISceneOptions> = {}) {\n const resolutionFactor =\n options.resolutionFactor ?? DEFAULT_RESOLUTION_FACTOR;\n\n if (\n resolutionFactor < MIN_RESOLUTION_FACTOR ||\n resolutionFactor > MAX_RESOLUTION_FACTOR\n ) {\n throw new Error(\n `Invalid resolution factor: ${resolutionFactor}. Must be between ${MIN_RESOLUTION_FACTOR} and ${MAX_RESOLUTION_FACTOR}.`,\n );\n }\n\n const width = options.width ?? DEFAULT_WIDTH;\n const height = options.height ?? DEFAULT_HEIGHT;\n\n assertSize(\n width,\n height,\n `Invalid width or height: ${width}x${height}. Must be positive.`,\n );\n\n const renderTarget = new WebGLRenderTarget(\n width * resolutionFactor,\n height * resolutionFactor,\n {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: options.useDepth ?? DEFAULT_USE_DEPTH,\n stencilBuffer: false,\n },\n );\n\n const material = new UIMaterial(renderTarget.texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.sceneInternal = options.scene ?? new Scene();\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n DEFAULT_FOV,\n width / height,\n DEFAULT_NEAR,\n DEFAULT_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n\n this.updateModeInternal = options.updateBehavior ?? DEFAULT_UPDATE_MODE;\n\n if (options.renderedByDefault ?? DEFAULT_RENDERED_BY_DEFAULT) {\n this.needsRenderInternal = true;\n }\n\n this.clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;\n this.clearAlphaInternal = options.clearAlpha ?? DEFAULT_CLEAR_ALPHA;\n\n this.renderTarget = renderTarget;\n this.material = material;\n\n this.applyTransformations();\n }\n\n /** Gets whether the scene needs to be re-rendered on the next frame */\n public get needsRender(): boolean {\n return this.needsRenderInternal;\n }\n\n /** Gets the color tint applied to the rendered scene */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the rendered scene */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /** Gets the Three.js scene being rendered */\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n /** Gets the camera used for rendering the scene */\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n /** Gets the color used to clear the scene before rendering */\n public get clearColor(): number {\n return this.clearColorInternal;\n }\n\n /** Gets the alpha value for the clear color */\n public get clearAlpha(): number {\n return this.clearAlphaInternal;\n }\n\n /** Gets the resolution scaling factor */\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n /**\n * Sets the color tint applied to the rendered scene\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the rendered scene\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the Three.js scene to be rendered\n * @param value - Scene to render\n */\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the camera used for rendering the scene\n * @param value - Camera to use\n */\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the color used to clear the scene before rendering\n * @param value - Clear color in hexadecimal format\n */\n public set clearColor(value: number) {\n if (this.clearColorInternal !== value) {\n this.clearColorInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the alpha value for the clear color\n * @param value - Alpha value between 0 (transparent) and 1 (opaque)\n */\n public set clearAlpha(value: number) {\n if (this.clearAlphaInternal !== value) {\n this.clearAlphaInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the resolution scaling factor\n * @param value - Resolution factor (e.g., 0.5 for half resolution)\n */\n public set resolutionFactor(value: number) {\n if (this.resolutionFactorInternal !== value) {\n this.resolutionFactorInternal = value;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Destroys the scene element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n this.renderTarget.dispose();\n super.destroy();\n }\n\n /**\n * Requests that the scene be re-rendered on the next frame.\n * This is used when the scene is in MANUAL update mode or when properties change.\n */\n public requestRender(): void {\n this.needsRenderInternal = true;\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Renders the scene element.\n * This will render the Three.js scene to a texture if needed,\n * then apply that texture to the mesh.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n if (\n this.needsRenderInternal ||\n this.updateModeInternal === UISceneUpdateMode.ALWAYS\n ) {\n this.needsRenderInternal = false;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n renderer.setClearColor(this.clearColorInternal, this.clearAlpha);\n renderer.setRenderTarget(this.renderTarget);\n renderer.clear(true, true, false);\n renderer.render(this.sceneInternal, this.cameraInternal);\n }\n\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type { UIAnchor } from \"../Elements/UIAnchor\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\n\nexport function assertSameLayer(\n elementOne: UIElement | UIAnchor | UILayer,\n elementTwo: UIElement | UIAnchor,\n message?: string,\n): void {\n if (\n (elementOne instanceof UILayer ? elementOne : elementOne.layer) !==\n elementTwo.layer\n ) {\n throw new Error(\n message ??\n `Elements must be on the same layer - element \"${elementTwo.constructor.name}\" cannot interact with elements from a different layer`,\n );\n }\n}\n\nexport function assertSize(\n width: number,\n height: number,\n message?: string,\n): void {\n if (width <= 0 || height <= 0) {\n throw new Error(\n message ??\n `Invalid dimensions: width (${width}) and height (${height}) must both be positive numbers greater than 0`,\n );\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIAnchor } from \"../Elements/UIAnchor\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Default anchor value (0.5 = center) for horizontal distance constraint\n */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for horizontal distance constraints.\n */\nexport interface UIHorizontalDistanceOptions {\n /** Horizontal anchor point (0-1) for the first element */\n anchorOne: number;\n /** Horizontal anchor point (0-1) for the second element */\n anchorTwo: number;\n /** The target distance between the two elements' anchor points */\n distance: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific horizontal distance between two UI elements.\n *\n * This constraint measures the distance between two anchor points on the x-axis\n * and ensures it matches (or is less/greater than) the specified distance value.\n */\nexport class UIHorizontalDistanceConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIHorizontalDistanceOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new horizontal distance constraint.\n *\n * @param elementOne - The first element or layer\n * @param elementTwo - The second element\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UIAnchor | UILayer,\n private readonly elementTwo: UIElement | UIAnchor,\n parameters?: Partial<UIHorizontalDistanceOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement || elementOne instanceof UIAnchor\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? DEFAULT_ANCHOR,\n anchorTwo: parameters?.anchorTwo ?? DEFAULT_ANCHOR,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the horizontal distance constraint to the constraint solver.\n *\n * Creates a constraint that enforces the distance between anchor points\n * on the x-axis of two elements based on the specified rule.\n *\n */\n protected buildConstraints(): void {\n const expressionOne =\n this.elementOne instanceof UIElement || this.elementOne instanceof UILayer\n ? new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n )\n : new Expression(this.elementOne[xSymbol]);\n\n const expressionTwo =\n this.elementTwo instanceof UIElement\n ? new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n )\n : new Expression(this.elementTwo[xSymbol]);\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the horizontal distance constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for horizontal proportion constraints.\n */\nexport interface UIHorizontalProportionOptions {\n /** The proportion ratio between elements' widths */\n proportion: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a proportional relationship between the widths of two elements.\n *\n * This constraint ensures that the width of one element is proportionally\n * related to the width of another element by a specified ratio.\n */\nexport class UIHorizontalProportionConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIHorizontalProportionOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new horizontal proportion constraint.\n *\n * @param elementOne - The reference element or layer\n * @param elementTwo - The element to constrain proportionally\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIHorizontalProportionOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the horizontal proportion constraint to the constraint solver.\n *\n * Creates a constraint expression in the form: (elementOne.width * proportion) - elementTwo.width = 0\n * This ensures the width ratio between elements matches the specified proportion.\n *\n */\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.proportion,\n );\n const expressionTwo = new Expression(this.elementTwo[widthSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the horizontal proportion constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIAnchor } from \"../Elements/UIAnchor\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Default anchor value (0.5 = center) for vertical distance constraint\n */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for vertical distance constraints.\n */\nexport interface UIVerticalDistanceOptions {\n /** Vertical anchor point (0-1) for the first element */\n anchorOne: number;\n /** Vertical anchor point (0-1) for the second element */\n anchorTwo: number;\n /** The target distance between the two elements' anchor points */\n distance: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific vertical distance between two UI elements.\n *\n * This constraint measures the distance between two anchor points on the y-axis\n * and ensures it matches (or is less/greater than) the specified distance value.\n */\nexport class UIVerticalDistanceConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIVerticalDistanceOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new vertical distance constraint.\n *\n * @param elementOne - The first element or layer\n * @param elementTwo - The second element\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UIAnchor | UILayer,\n private readonly elementTwo: UIElement | UIAnchor,\n parameters?: Partial<UIVerticalDistanceOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement || elementOne instanceof UIAnchor\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? DEFAULT_ANCHOR,\n anchorTwo: parameters?.anchorTwo ?? DEFAULT_ANCHOR,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the vertical distance constraint to the constraint solver.\n *\n * Creates a constraint that enforces the distance between anchor points\n * on the y-axis of two elements based on the specified rule.\n *\n */\n protected buildConstraints(): void {\n const expressionOne =\n this.elementOne instanceof UIElement || this.elementOne instanceof UILayer\n ? new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n )\n : new Expression(this.elementOne[ySymbol]);\n\n const expressionTwo =\n this.elementTwo instanceof UIElement\n ? new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n )\n : new Expression(this.elementTwo[ySymbol]);\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the vertical distance constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for vertical proportion constraints.\n */\nexport interface UIVerticalProportionOptions {\n /** The proportion ratio between elements' heights */\n proportion: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a proportional relationship between the heights of two elements.\n *\n * This constraint ensures that the height of one element is proportionally\n * related to the height of another element by a specified ratio.\n */\nexport class UIVerticalProportionConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIVerticalProportionOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new vertical proportion constraint.\n *\n * @param elementOne - The reference element or layer\n * @param elementTwo - The element to constrain proportionally\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIVerticalProportionOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the vertical proportion constraint to the constraint solver.\n *\n * Creates a constraint expression in the form: (elementOne.height * proportion) - elementTwo.height = 0\n * This ensures the height ratio between elements matches the specified proportion.\n *\n */\n protected buildConstraints(): void {\n const expressionOne = new Expression(\n this.elementOne[heightSymbol],\n ).multiply(this.parameters.proportion);\n const expressionTwo = new Expression(this.elementTwo[heightSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the vertical proportion constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for width constraints.\n */\nexport interface UIWidthOptions {\n /** The fixed width value to constrain the element to */\n width: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific width for a UI element.\n *\n * This constraint can be configured to require an exact width\n * or set minimum/maximum width limits using different rules.\n */\nexport class UIWidthConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly options: UIWidthOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new width constraint.\n *\n * @param element - The UI element to constrain\n * @param options - Configuration options\n */\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIWidthOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n width: options?.width ?? element.width,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the width constraint to the constraint solver.\n *\n * Creates a constraint that enforces the element's width based\n * on the specified rule (equal to, less than, or greater than).\n *\n */\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[widthSymbol]),\n convertRuleToOperator(this.options.rule),\n this.options.width,\n convertPowerToStrength(this.options.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the width constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIConstraintRule } from \"../Constraints/UIConstraintRule\";\nimport { UIHeightConstraint } from \"../Constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../Constraints/UIWidthConstraint\";\nimport type { UIAnchor } from \"../Elements/UIAnchor\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIType2D<T> {\n x?: T;\n y?: T;\n}\n\ninterface UIConstraint2DOptions {\n power: UIType2D<UIConstraintPower>;\n rule: UIType2D<UIConstraintRule>;\n orientation: UIType2D<UIOrientation>;\n}\n\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n size: UIType2D<number>;\n}\n\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n anchorOne: UIType2D<number>;\n anchorTwo: UIType2D<number>;\n distance: UIType2D<number>;\n}\n\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n proportion: UIType2D<number>;\n}\n\nexport interface UIConstraint2DResult<TX, TY> {\n x: TX;\n y: TY;\n}\n\nexport class UIConstraint2DBuilder {\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions>,\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n return {\n x: new UIWidthConstraint(element, {\n width: options.size?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIHeightConstraint(element, {\n height: options.size?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n\n public static distance(\n elementOne: UIElement | UIAnchor | UILayer,\n elementTwo: UIElement | UIAnchor,\n options: Partial<UIConstraintSize2DOptions>,\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n return {\n x: new UIHorizontalDistanceConstraint(elementOne, elementTwo, {\n anchorOne: options.anchorOne?.x,\n anchorTwo: options.anchorTwo?.x,\n distance: options.distance?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIVerticalDistanceConstraint(elementOne, elementTwo, {\n anchorOne: options.anchorOne?.y,\n anchorTwo: options.anchorTwo?.y,\n distance: options.distance?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n\n public static proportion(\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options: Partial<UIConstraintProportion2DOptions>,\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n return {\n x: new UIHorizontalProportionConstraint(elementOne, elementTwo, {\n proportion: options.proportion?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIVerticalProportionConstraint(elementOne, elementTwo, {\n proportion: options.proportion?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIHorizontalDistanceOptions } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport type { UIHorizontalProportionOptions } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport type { UIVerticalDistanceOptions } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIVerticalProportionOptions } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIConstraintStackBuilderOptions {\n distance: number;\n keepProportions: boolean;\n keepAlignment: boolean;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport interface UIConstraintStackBuilderResult<\n TDistance,\n TProportion,\n TCenter,\n> {\n distanceConstraints: TDistance[];\n proportionConstraints: TProportion[];\n alignmentConstraints: TCenter[];\n}\n\ninterface ConstraintConstructors<TDistance, TProportion, TCenter> {\n distanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TDistance;\n proportionConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalProportionOptions | UIVerticalProportionOptions>\n | undefined,\n ) => TProportion;\n centerDistanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TCenter;\n}\n\nexport class UIConstraintStackBuilder {\n public static buildHorizontal(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIHorizontalDistanceConstraint,\n UIHorizontalProportionConstraint,\n UIVerticalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIHorizontalDistanceConstraint,\n proportionConstraint: UIHorizontalProportionConstraint,\n centerDistanceConstraint: UIVerticalDistanceConstraint,\n });\n }\n\n public static buildVertical(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIVerticalDistanceConstraint,\n UIVerticalProportionConstraint,\n UIHorizontalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIVerticalDistanceConstraint,\n proportionConstraint: UIVerticalProportionConstraint,\n centerDistanceConstraint: UIHorizontalDistanceConstraint,\n });\n }\n\n private static buildStack<TDistance, TProportion, TCenter>(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n constructors: ConstraintConstructors<TDistance, TProportion, TCenter>,\n ): UIConstraintStackBuilderResult<TDistance, TProportion, TCenter> {\n const distances: TDistance[] = [];\n const proportions: TProportion[] = [];\n const centers: TCenter[] = [];\n\n for (let i = 0; i < elements.length - 1; i++) {\n const element = elements[i];\n const nextElement = elements[i + 1];\n\n distances.push(\n new constructors.distanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: options.distance,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n if (options.keepProportions !== false) {\n proportions.push(\n new constructors.proportionConstraint(element, nextElement, {\n power: options.power,\n orientation: options.orientation,\n }),\n );\n }\n\n if (options.keepAlignment !== false) {\n centers.push(\n new constructors.centerDistanceConstraint(element, nextElement, {\n power: options.power,\n anchorOne: 0,\n anchorTwo: 0,\n orientation: options.orientation,\n }),\n );\n }\n }\n\n return {\n distanceConstraints: distances,\n proportionConstraints: proportions,\n alignmentConstraints: centers,\n };\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for aspect ratio constraints.\n */\nexport interface UIAspectOptions {\n /** The aspect ratio to maintain (width / height) */\n aspect: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that maintains a specific aspect ratio for a UI element.\n *\n * The aspect ratio is defined as width divided by height (w/h).\n * This constraint ensures that an element maintains its proportions\n * during layout calculations.\n */\nexport class UIAspectConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIAspectOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new aspect ratio constraint.\n *\n * @param element - The UI element to constrain\n * @param parameters - Configuration options\n */\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIAspectOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n aspect: parameters?.aspect ?? this.element.width / this.element.height,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param newOrientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param newOrientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the aspect ratio constraint to the constraint solver.\n *\n * Creates a constraint expression in the form: width - (height * aspect) = 0\n * This ensures that width/height = aspect.\n *\n */\n protected buildConstraints(): void {\n const expression = new Expression(this.element[widthSymbol]).plus(\n new Expression(this.element[heightSymbol]).multiply(\n -this.parameters.aspect,\n ),\n );\n\n this.constraint = new Constraint(\n expression,\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the aspect ratio constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\n/**\n * Default anchor value (0.5 = center) for cover constraint alignment\n */\n\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for cover constraints.\n */\nexport interface UICoverOptions {\n /** Whether to force equal height (true) or allow stretching (false) */\n isStrict: boolean;\n /** Horizontal anchor point (0-1) for alignment between elements */\n horizontalAnchor: number;\n /** Vertical anchor point (0-1) for alignment between elements */\n verticalAnchor: number;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that makes an element cover another element or layer.\n *\n * The covering element will:\n * - Be aligned with the covered element using the specified anchors\n * - Have at least the same width and height as the covered element\n * - Optionally maintain strict proportions\n *\n * This is similar to CSS's \"cover\" object-fit behavior.\n */\nexport class UICoverConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UICoverOptions;\n\n /** Constraint for X-axis alignment */\n private constraintX?: Constraint;\n /** Constraint for Y-axis alignment */\n private constraintY?: Constraint;\n /** Constraint for width relationship */\n private constraintW?: Constraint;\n /** Constraint for height relationship */\n private constraintH?: Constraint;\n /** Optional constraint for maintaining strict proportions */\n private constraintStrict?: Constraint;\n\n /**\n * Creates a new cover constraint.\n *\n * @param elementOne - The element or layer to be covered (the reference)\n * @param elementTwo - The element that will cover the reference\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UICoverOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? DEFAULT_ANCHOR,\n verticalAnchor: parameters?.verticalAnchor ?? DEFAULT_ANCHOR,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the cover constraints to the constraint solver.\n *\n * Creates five constraints:\n * 1. X alignment between the elements\n * 2. Y alignment between the elements\n * 3. Width covering (elementTwo width ≥ elementOne width)\n * 4. Height covering (elementTwo height ≥ elementOne height)\n * 5. Optional strict proportions (if isStrict = false)\n *\n */\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (!this.parameters.isStrict) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n /**\n * Removes all cover constraints from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\n/**\n * Default anchor value (0.5 = center) for fit constraint alignment\n */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for fit constraints.\n */\nexport interface UIFitOptions {\n /** Whether to force equal height (true) or allow stretching (false) */\n isStrict: boolean;\n /** Horizontal anchor point (0-1) for alignment between elements */\n horizontalAnchor: number;\n /** Vertical anchor point (0-1) for alignment between elements */\n verticalAnchor: number;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that makes an element fit within another element or layer.\n *\n * The fitting element will:\n * - Be aligned with the container element using the specified anchors\n * - Have at most the same width and height as the container element\n * - Optionally maintain strict proportions\n *\n * This is similar to CSS's \"contain\" object-fit behavior.\n */\nexport class UIFitConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIFitOptions;\n\n /** Constraint for X-axis alignment */\n private constraintX?: Constraint;\n /** Constraint for Y-axis alignment */\n private constraintY?: Constraint;\n\n /** Constraint for width relationship */\n private constraintW?: Constraint;\n /** Constraint for height relationship */\n private constraintH?: Constraint;\n\n /** Optional constraint for maintaining strict proportions */\n private constraintStrict?: Constraint;\n\n /**\n * Creates a new fit constraint.\n *\n * @param elementOne - The element or layer that contains the fitting element (the container)\n * @param elementTwo - The element that will fit within the container\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIFitOptions>,\n ) {\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n assertSameLayer(elementOne, elementTwo);\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? DEFAULT_ANCHOR,\n verticalAnchor: parameters?.verticalAnchor ?? DEFAULT_ANCHOR,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the fit constraints to the constraint solver.\n *\n * Creates five constraints:\n * 1. X alignment between the elements\n * 2. Y alignment between the elements\n * 3. Width fitting (elementTwo width ≤ elementOne width)\n * 4. Height fitting (elementTwo height ≤ elementOne height)\n * 5. Optional strict proportions (if isStrict = true)\n *\n */\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (this.parameters.isStrict !== false) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n /**\n * Removes all fit constraints from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import { Object3D } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Default size for dummy elements when no dimensions are specified\n */\nconst DEFAULT_DUMMY_SIZE = 100;\n\n/**\n * A minimal UI element with no visual representation.\n * Used as a placeholder, spacer, or container for other elements.\n */\nexport class UIDummy extends UIElement {\n /**\n * Creates a new dummy UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param width - Width of the dummy element (defaults to DEFAULT_DUMMY_SIZE)\n * @param height - Height of the dummy element (defaults to DEFAULT_DUMMY_SIZE)\n */\n constructor(\n layer: UILayer,\n width = DEFAULT_DUMMY_SIZE,\n height = DEFAULT_DUMMY_SIZE,\n ) {\n super(layer, new Object3D(), 0, 0, width, height);\n this.applyTransformations();\n }\n\n /**\n * Renders the dummy element.\n * Since dummies have no visual representation, this only applies transformations.\n */\n protected override render(): void {\n this.applyTransformations();\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * A UI element that displays an image texture.\n * Renders a textured mesh using the provided texture.\n */\n\nexport class UIImage extends UIElement {\n /** Material used to render the image */\n private readonly material: UIMaterial;\n\n /** The texture displayed by this image */\n private readonly textureInternal: Texture;\n\n /**\n * Creates a new image UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param texture - The texture to display\n * @throws Error if the texture has invalid dimensions\n */\n constructor(layer: UILayer, texture: Texture) {\n const width = texture.image?.width;\n const height = texture.image?.height;\n\n assertSize(\n width,\n height,\n `Invalid image dimensions - texture \"${texture.name || \"unnamed\"}\" has invalid width (${width}) or height (${height}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.material = material;\n this.textureInternal = texture;\n\n this.applyTransformations();\n }\n\n /** Gets the texture displayed by this image */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /** Gets the color tint applied to the image */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the image */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Sets the color tint applied to the image\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the image\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Destroys the image element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n /**\n * Renders the image element.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.textureInternal.image.width,\n this.textureInternal.image.height,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIProgressMaterial extends ShaderMaterial {\n constructor(foregroundTexture: Texture, backgroundTexture?: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n background: { value: backgroundTexture },\n foreground: { value: foregroundTexture },\n progress: { value: 1 },\n backgroundColor: { value: new Color(1, 1, 1) },\n foregroundColor: { value: new Color(1, 1, 1) },\n color: { value: new Color(1, 1, 1) },\n backgroundOpacity: { value: 1 },\n foregroundOpacity: { value: 1 },\n opacity: { value: 1 },\n angle: { value: 0 },\n direction: { value: 1 },\n },\n ]),\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\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 `,\n transparent: true,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: false,\n });\n }\n\n public getProgress(): number {\n return this.uniforms.progress.value;\n }\n\n public getBackgroundTexture(): Texture | undefined {\n return this.uniforms.background.value;\n }\n\n public getForegroundTexture(): Texture {\n return this.uniforms.foreground.value;\n }\n\n public getBackgroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getForegroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getBackgroundOpacity(): number {\n return this.uniforms.backgroundOpacity.value;\n }\n\n public getForegroundOpacity(): number {\n return this.uniforms.foregroundOpacity.value;\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public getAngle(): number {\n return this.uniforms.angle.value;\n }\n\n public getIsForwardDirection(): boolean {\n return this.uniforms.direction.value === 1;\n }\n\n public setProgress(value: number): void {\n this.uniforms.progress.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundTexture(value: Texture | undefined): void {\n this.uniforms.background.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundTexture(value: Texture): void {\n this.uniforms.foreground.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundOpacity(value: number): void {\n this.uniforms.backgroundOpacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundOpacity(value: number): void {\n this.uniforms.foregroundOpacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setOpacity(value: number): void {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setAngle(value: number): void {\n this.uniforms.angle.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setIsForwardDirection(value: boolean): void {\n this.uniforms.direction.value = value ? 1 : -1;\n this.uniformsNeedUpdate = true;\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { MathUtils, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIProgressMaterial } from \"../Materials/UIProgressMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Options for customizing the UIProgress element.\n */\n\nexport interface UIProgressOptions {\n /** Optional background texture to display behind the progress indicator */\n textureBackground: Texture;\n /** Progress value from 0 to 1 */\n progress: number;\n /** Whether progress increases in the direction specified by angle (true) or opposite to it (false) */\n isForegroundDirection: boolean;\n /** Angle in degrees specifying the direction of progress */\n angle: number;\n /** Overall color tint applied to both textures */\n color: number;\n /** Overall opacity applied to both textures */\n opacity: number;\n /** Color tint applied to the background texture */\n backgroundColor: number;\n /** Color tint applied to the foreground texture */\n foregroundColor: number;\n /** Opacity of the background texture */\n backgroundOpacity: number;\n /** Opacity of the foreground texture */\n foregroundOpacity: number;\n}\n\n/**\n * A UI element that displays a progress indicator.\n * Can be used for loading bars, health bars, sliders, etc.\n */\n\nexport class UIProgress extends UIElement {\n /** Material used to render the progress indicator */\n private readonly material: UIProgressMaterial;\n /** Width of the underlying image texture */\n private readonly imageWidth: number;\n /** Height of the underlying image texture */\n private readonly imageHeight: number;\n\n /**\n * Creates a new progress UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param textureForeground - The texture to use for the progress indicator\n * @param options - Options to customize the progress indicator\n * @throws Error if either texture has invalid dimensions\n */\n constructor(\n layer: UILayer,\n textureForeground: Texture,\n options: Partial<UIProgressOptions> = {},\n ) {\n const foregroundWidth = textureForeground.image?.width;\n const foregroundHeight = textureForeground.image?.height;\n\n assertSize(\n foregroundWidth,\n foregroundHeight,\n `Invalid image dimensions - texture \"${textureForeground.name || \"unnamed\"}\" has invalid width (${foregroundWidth}) or height (${foregroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const backgroundWidth = options.textureBackground?.image?.width;\n const backgroundHeight = options.textureBackground?.image?.height;\n\n if (options.textureBackground) {\n assertSize(\n backgroundWidth,\n backgroundHeight,\n `Invalid image dimensions - texture \"${options.textureBackground.name || \"unnamed\"}\" has invalid width (${backgroundWidth}) or height (${backgroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n }\n\n const material = new UIProgressMaterial(\n textureForeground,\n options.textureBackground,\n );\n const object = new Mesh(geometry, material);\n\n if (options.progress) {\n material.setProgress(options.progress);\n }\n\n if (options.isForegroundDirection) {\n material.setIsForwardDirection(options.isForegroundDirection);\n }\n\n if (options.angle) {\n material.setAngle(MathUtils.degToRad(options.angle));\n }\n\n if (options.color) {\n material.setColor(options.color);\n }\n\n if (options.opacity) {\n material.setOpacity(options.opacity);\n }\n\n if (options.backgroundColor) {\n material.setBackgroundColor(options.backgroundColor);\n }\n\n if (options.foregroundColor) {\n material.setForegroundColor(options.foregroundColor);\n }\n\n if (options.backgroundOpacity) {\n material.setBackgroundOpacity(options.backgroundOpacity);\n }\n\n if (options.foregroundOpacity) {\n material.setForegroundOpacity(options.foregroundOpacity);\n }\n\n const imageWidth = backgroundWidth ?? foregroundWidth;\n const imageHeight = foregroundHeight ?? backgroundHeight;\n\n super(layer, object, 0, 0, imageWidth, imageHeight);\n\n this.material = material;\n this.imageWidth = imageWidth;\n this.imageHeight = imageHeight;\n\n this.applyTransformations();\n }\n\n /** Gets the current progress value (0 to 1) */\n public get progress(): number {\n return this.material.getProgress();\n }\n\n /** Gets the background texture if one was provided */\n public get backgroundTexture(): Texture | undefined {\n return this.material.getBackgroundTexture();\n }\n\n /** Gets the foreground texture used for the progress indicator */\n public get foregroundTexture(): Texture {\n return this.material.getForegroundTexture();\n }\n\n /** Gets the color tint applied to the background texture */\n public get backgroundColor(): number {\n return this.material.getBackgroundColor();\n }\n\n /** Gets the color tint applied to the foreground texture */\n public get foregroundColor(): number {\n return this.material.getForegroundColor();\n }\n\n /** Gets the overall color tint applied to both textures */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the background texture */\n public get backgroundOpacity(): number {\n return this.material.getBackgroundOpacity();\n }\n\n /** Gets the opacity of the foreground texture */\n public get foregroundOpacity(): number {\n return this.material.getForegroundOpacity();\n }\n\n /** Gets the overall opacity applied to both textures */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /** Gets the angle in degrees specifying the direction of progress */\n public get angle(): number {\n return MathUtils.radToDeg(this.material.getAngle());\n }\n\n /** Gets whether progress increases in the direction specified by angle (true) or opposite to it (false) */\n public get isForwardDirection(): boolean {\n return this.material.getIsForwardDirection();\n }\n\n /**\n * Sets the progress value\n * @param value - Progress value between 0 (empty) and 1 (full)\n */\n public set progress(value: number) {\n this.material.setProgress(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the color tint applied to the background texture\n * @param value - Color in hexadecimal format\n */\n public set backgroundColor(value: number) {\n this.material.setBackgroundColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the color tint applied to the foreground texture\n * @param value - Color in hexadecimal format\n */\n public set foregroundColor(value: number) {\n this.material.setForegroundColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the overall color tint applied to both textures\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the background texture\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set backgroundOpacity(value: number) {\n this.material.setBackgroundOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the foreground texture\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set foregroundOpacity(value: number) {\n this.material.setForegroundOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the overall opacity applied to both textures\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the angle specifying the direction of progress\n * @param value - Angle in degrees\n */\n public set angle(value: number) {\n this.material.setAngle(MathUtils.degToRad(value));\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets whether progress increases in the direction specified by angle\n * @param value - true to increase in the direction of angle, false for opposite\n */\n public set isForwardDirection(value: boolean) {\n this.material.setIsForwardDirection(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Destroys the progress element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n /**\n * Renders the progress element.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.imageWidth,\n this.imageHeight,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type {\n UIChunkMetrics,\n UITextChunk,\n UITextLine,\n UITextPadding,\n UITextSize,\n UITextStyle,\n} from \"./UITextInterfaces\";\n\nexport function resolvePadding(\n padding?: Partial<UITextPadding> | number,\n): UITextPadding {\n if (typeof padding === \"number\") {\n return {\n left: padding,\n right: padding,\n top: padding,\n bottom: padding,\n };\n }\n return {\n left: Math.max(padding?.left ?? 0, 0),\n right: Math.max(padding?.right ?? 0, 0),\n top: Math.max(padding?.top ?? 0, 0),\n bottom: Math.max(padding?.bottom ?? 0, 0),\n };\n}\n\nexport function resolveTextStyle(\n currentStyle?: Partial<UITextStyle>,\n baseStyle?: Partial<UITextStyle>,\n): UITextStyle {\n const fontSize = Math.max(\n currentStyle?.fontSize ?? baseStyle?.fontSize ?? 16,\n 1,\n );\n const lineHeight =\n currentStyle?.lineHeight ?? baseStyle?.lineHeight ?? fontSize * 1.2;\n const shadowBlur = Math.max(\n currentStyle?.shadowBlur ?? baseStyle?.shadowBlur ?? 0,\n 0,\n );\n const strokeWidth = Math.max(\n currentStyle?.strokeWidth ?? baseStyle?.strokeWidth ?? 0,\n 0,\n );\n return {\n color: currentStyle?.color ?? baseStyle?.color ?? \"#000000\",\n fontFamily: currentStyle?.fontFamily ?? baseStyle?.fontFamily ?? \"Arial\",\n fontSize,\n fontStyle: currentStyle?.fontStyle ?? baseStyle?.fontStyle ?? \"normal\",\n fontWeight: currentStyle?.fontWeight ?? baseStyle?.fontWeight ?? \"normal\",\n lineHeight,\n\n enableShadow:\n currentStyle?.enableShadow ?? baseStyle?.enableShadow ?? false,\n shadowOffsetX: currentStyle?.shadowOffsetX ?? baseStyle?.shadowOffsetX ?? 0,\n shadowOffsetY: currentStyle?.shadowOffsetY ?? baseStyle?.shadowOffsetY ?? 0,\n shadowBlur,\n shadowColor:\n currentStyle?.shadowColor ?? baseStyle?.shadowColor ?? \"transparent\",\n\n enableStroke:\n currentStyle?.enableStroke ?? baseStyle?.enableStroke ?? false,\n strokeColor:\n currentStyle?.strokeColor ?? baseStyle?.strokeColor ?? \"transparent\",\n strokeWidth,\n };\n}\n\nexport function splitText(text: string): string[] {\n return text.match(/\\S+|\\s|\\n/g) || [];\n}\n\nexport function measureTextChunk(\n context: CanvasRenderingContext2D,\n chunk: string,\n style: UITextStyle,\n): UIChunkMetrics {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (chunk === \"\\n\") {\n return {\n width: Math.ceil(0),\n height: style.lineHeight,\n baseline: 0,\n lineHeight: style.lineHeight,\n };\n }\n\n const metrics = context.measureText(chunk);\n const width = metrics.width;\n\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width: Math.ceil(width),\n height: height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: style.lineHeight,\n };\n}\n\nexport function wrapTextLines(\n maxWidth: number,\n chunks: UITextChunk[],\n): UITextLine[] {\n const lines: UITextLine[] = [];\n let currentLine: UITextChunk[] = [];\n let currentWidth = 0;\n let currentHeight = 0;\n let currentBaseline = 0;\n let currentLineHeight = 0;\n\n for (const chunk of chunks) {\n if (chunk.text === \"\\n\") {\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n currentLine = [];\n currentWidth = 0;\n currentHeight = 0;\n currentBaseline = 0;\n currentLineHeight = 0;\n continue;\n }\n\n if (\n currentWidth + chunk.metrics.width <= maxWidth ||\n currentLine.length === 0\n ) {\n currentLine.push(chunk);\n currentWidth += chunk.metrics.width;\n currentHeight = Math.max(currentHeight, chunk.metrics.height);\n currentBaseline = Math.max(currentBaseline, chunk.metrics.baseline);\n currentLineHeight = Math.max(currentLineHeight, chunk.metrics.lineHeight);\n } else {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n currentLine = [chunk];\n currentWidth = chunk.metrics.width;\n currentHeight = chunk.metrics.height;\n currentBaseline = chunk.metrics.baseline;\n currentLineHeight = chunk.metrics.lineHeight;\n }\n }\n\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n\n return lines;\n}\n\nexport function calculateTextBlockSize(lines: UITextLine[]): UITextSize {\n if (lines.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const maxLineWidth = Math.max(...lines.map((line) => line.width));\n\n let totalHeight = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (i === 0) {\n totalHeight += line.height;\n } else {\n totalHeight += line.lineHeight;\n }\n\n if (i === lines.length - 1) {\n totalHeight += line.baseline;\n }\n }\n\n return {\n width: maxLineWidth,\n height: totalHeight,\n };\n}\n\nexport function renderText(\n x: number,\n y: number,\n text: string,\n style: UITextStyle,\n context: CanvasRenderingContext2D,\n): void {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (style.enableShadow) {\n context.shadowOffsetX = style.shadowOffsetX;\n context.shadowOffsetY = style.shadowOffsetY;\n context.shadowBlur = style.shadowBlur;\n context.shadowColor = style.shadowColor;\n }\n\n if (style.enableStroke) {\n context.strokeStyle = style.strokeColor;\n context.lineWidth = style.strokeWidth;\n context.strokeText(text, x, y);\n }\n\n context.fillStyle = style.color;\n context.fillText(text, x, y);\n}\n\nexport function renderTextLines(\n paddingTop: number,\n paddingLeft: number,\n lines: UITextLine[],\n context: CanvasRenderingContext2D,\n): void {\n let currentY = paddingTop;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n let currentX = paddingLeft;\n currentY += i === 0 ? line.height : line.lineHeight;\n\n for (const chunk of line.chunks) {\n renderText(currentX, currentY, chunk.text, chunk.style, context);\n currentX += chunk.metrics.width;\n }\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport { CanvasTexture, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport {\n calculateTextBlockSize,\n measureTextChunk,\n renderTextLines,\n resolvePadding,\n resolveTextStyle,\n splitText,\n wrapTextLines,\n} from \"../Miscellaneous/textTools\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport type {\n UITextChunk,\n UITextPadding,\n UITextSize,\n UITextSpan,\n UITextStyle,\n} from \"../Miscellaneous/UITextInterfaces\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Options for customizing the UIText element.\n */\nexport interface UITextOptions {\n /** Maximum width of the text block before wrapping occurs */\n maxWidth: number;\n /** Padding around the text */\n padding: Partial<UITextPadding>;\n /** Default style to apply to text spans that don't specify their own style */\n defaultStyle: Partial<UITextStyle>;\n}\n\n/** Default maximum line width for text if not otherwise specified */\nconst DEFAULT_LINE_SIZE = 1024;\n\n/**\n * A UI element that displays formatted text.\n * Renders text to a canvas and displays it as a texture on a mesh.\n */\nexport class UIText extends UIElement {\n /** Material used to render the text */\n private readonly material: UIMaterial;\n /** Texture containing the rendered text */\n private readonly texture: CanvasTexture;\n\n /** Canvas element used to render the text */\n private readonly canvas: HTMLCanvasElement;\n /** 2D rendering context for the canvas */\n private readonly context: CanvasRenderingContext2D;\n\n /** Size of the text block without padding */\n private readonly textBlockSize: UITextSize;\n /** Padding values applied around the text */\n private readonly padding: UITextPadding;\n /** Cached aspect ratio for performance optimization */\n private suggestedAspect = 0;\n\n /**\n * Creates a new text UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param spans - Text content to display, either as a string, text span, or array of text spans/strings\n * @param parameters - Options to customize the text rendering\n * @throws Error if canvas context creation fails\n */\n constructor(\n layer: UILayer,\n spans: (UITextSpan | string)[] | UITextSpan | string,\n parameters: Partial<UITextOptions> = {},\n ) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\"Failed to create canvas context\");\n }\n\n const chunks: UITextChunk[] = [];\n const processedSpans = Array.isArray(spans) ? spans : [spans];\n\n for (const span of processedSpans) {\n const isSpanString = typeof span === \"string\";\n const spanText = isSpanString ? span : span.text;\n const style = resolveTextStyle(\n isSpanString ? undefined : span.style,\n parameters.defaultStyle,\n );\n\n for (const text of splitText(spanText)) {\n const metrics = measureTextChunk(context, text, style);\n chunks.push({ text, style, metrics });\n }\n }\n\n const wrappedLines = wrapTextLines(\n parameters.maxWidth ?? DEFAULT_LINE_SIZE,\n chunks,\n );\n const textBlockSize = calculateTextBlockSize(wrappedLines);\n\n const padding = resolvePadding(parameters.padding);\n\n canvas.width = textBlockSize.width + padding.left + padding.right;\n canvas.height = textBlockSize.height + padding.top + padding.bottom;\n\n const texture = new CanvasTexture(canvas);\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, textBlockSize.width, textBlockSize.height);\n\n this.material = material;\n this.texture = texture;\n\n this.canvas = canvas;\n this.context = context;\n\n this.textBlockSize = textBlockSize;\n this.padding = padding;\n\n renderTextLines(\n this.padding.top,\n this.padding.left,\n wrappedLines,\n this.context,\n );\n\n this.texture.needsUpdate = true;\n this.applyTransformations();\n }\n\n /** Gets the color tint applied to the text */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the text */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Sets the color tint applied to the text\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the text\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Destroys the text element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n this.texture.dispose();\n this.canvas.remove();\n super.destroy();\n }\n\n /**\n * Applies transformations to the text element, ensuring the aspect ratio\n * matches the rendered text to prevent distortion.\n *\n * This overrides the base implementation to maintain the correct aspect ratio.\n */\n public override applyTransformations(): void {\n super.applyTransformations();\n\n const currentAspect = this.width / this.height;\n if (this.suggestedAspect !== currentAspect) {\n this.suggestedAspect = currentAspect;\n\n const targetAspect =\n (this.textBlockSize.width + this.padding.left + this.padding.right) /\n (this.textBlockSize.height + this.padding.top + this.padding.bottom);\n\n this.height = this.width / targetAspect;\n }\n }\n\n /**\n * Renders the text element.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.texture.image.width,\n this.texture.image.height,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import { UIMode } from \"../Miscellaneous/UIMode\";\nimport { UILayer } from \"./UILayer\";\n\nconst DEFAULT_SCREEN_HEIGHT = 1920;\n\nexport class UIFullScreenLayer extends UILayer {\n private targetScreenHeight?: number = DEFAULT_SCREEN_HEIGHT;\n\n constructor() {\n super();\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"pointerdown\", this.onClick);\n this.onResize();\n }\n\n public get tergetScreenHeight(): number | undefined {\n return this.targetScreenHeight;\n }\n\n public set tergetScreenHeight(value: number | undefined) {\n this.targetScreenHeight = value;\n this.resizeInternal(window.innerWidth, window.innerHeight);\n }\n\n public override destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"pointerdown\", this.onClick);\n super.destroy();\n }\n\n private calculateScale(): number {\n const targetHeight = this.tergetScreenHeight ?? window.innerHeight;\n return targetHeight / window.innerHeight;\n }\n\n private readonly onResize = (): void => {\n const scale = this.calculateScale();\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n private readonly onClick = (event: PointerEvent): void => {\n if (this.mode !== UIMode.INTERACTIVE) {\n return;\n }\n\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\n const offsetX = rect ? event.clientX - rect.left : event.clientX;\n const offsetY = rect\n ? rect.bottom - event.clientY\n : window.innerHeight - event.clientY;\n\n const scale = this.calculateScale();\n this.clickInternal(offsetX * scale, offsetY * scale);\n };\n}\n","import { UILayer } from \"./UILayer\";\n\nexport class UIManualLayer extends UILayer {\n public click(x: number, y: number): void {\n this.clickInternal(x, y);\n }\n\n public resize(width: number, height: number): void {\n this.resizeInternal(width, height);\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\n\n/**\n * Options passed to a UIPass when rendering\n */\nexport interface UIPassRenderOptions {\n /** Width of the render target in pixels (without padding) */\n width: number;\n /** Height of the render target in pixels (without padding) */\n height: number;\n /** Current padding used for the render target */\n padding: number;\n}\n\n/**\n * Abstract base class for all UI composition passes\n * \n * UI passes are used to apply post-processing effects to the rendered UI\n * Each pass can be chained together in a UIComposer to create complex effects\n */\nexport abstract class UIPass {\n /**\n * The amount of padding in pixels this pass requires\n * The compositor will use the maximum padding value from all passes\n */\n public abstract get padding(): number;\n \n /**\n * Whether this pass needs to be updated in the next frame\n * Set to true when properties change to trigger a re-render\n */\n public abstract get needsUpdate(): boolean;\n \n /**\n * Whether this pass contributes a meaningful effect\n * Passes that are not valuable may be skipped during composition\n */\n public abstract get isValuable(): boolean;\n \n /**\n * Renders this pass\n * \n * @param renderer - The WebGL renderer to use\n * @param texture - The input texture from the previous pass\n * @param parameters - Render options including dimensions and padding\n */\n public abstract render(\n renderer: WebGLRenderer,\n texture: Texture,\n parameters: UIPassRenderOptions,\n ): void;\n}\n"],"names":["createMap","IndexedMap","this","index","array","prototype","size","length","empty","itemAt","contains","key","undefined","id","find","i","setDefault","factory","pair","Pair","push","insert","value","erase","last","pop","first","copy","second","Variable","name","_value","_context","_id","VarId","_name","setName","context","setContext","setValue","plus","Expression","minus","multiply","coefficient","divide","toJSON","toString","parsed","parseArgs","arguments","_terms","terms","_constant","constant","result","n","isConstant","map","join","args","item","j","k","terms2","termPair","Array","Error","value2","Operator","Strength","create","a","b","c","w","Math","max","min","clip","required","strong","medium","weak","SymbolType","Constraint","expression","operator","rhs","strength","CnId","_operator","_strength","_expression","op","Solver","_cnMap","_rowMap","_varMap","_editMap","_infeasibleRows","_objective","Row","_artificial","_idTick","createConstraint","lhs","cn","addConstraint","constraint","data","_createRow","row","tag","subject","_chooseSubject","type","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_optimize","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","addEditVariable","variable","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_dualOptimize","other","rowPair_1","coeff","coefficientFor","External","updateVariables","vars","_getVarSymbol","_this","_makeSymbol","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","r","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_type","_cellMap","theCopy","xSymbol","ySymbol","widthSymbol","heightSymbol","addUIElementSymbol","removeUIElementSymbol","addUIConstraintSymbol","removeUIConstraintSymbol","addConstraintSymbol","removeConstraintSymbol","addVariableSymbol","removeVariableSymbol","suggestVariableSymbol","disableConstraintSymbol","enableConstraintSymbol","needsRecalculation","renderSymbol","clickSymbol","sortSymbol","UIOrientation","isUIOrientation","obj","Object","values","some","v","resolveOrientation","orientation","ALWAYS","UIConstraint","constructor","layer","elements","destroy","HIGH_PRIORITY","UIConstraintPower","UIConstraintRule","isUIConstraintPower","resolvePower","power","P0","convertPowerToStrength","P1","P2","P3","P4","P5","P6","P7","isUIConstraintRule","resolveRule","rule","EQUAL","convertRuleToOperator","LESS","GREATER","UIHeightConstraint","element","options","super","Set","height","_a","buildConstraints","destroyConstraints","Eventail","listeners","Map","on","callback","priority","addListener","once","off","current","get","delete","filtered","filter","l","set","emit","listener","apply","list","event","splice","UIAnchor","x","y","object","_b","_c","MathUtils","generateUUID","matrixAutoUpdate","zIndex","_e","_d","position","z","renderOrder","updateMatrix","renderer","deltaTime","render","applyTransformations","tempVector2","Vector2","tempBox2","Box2","tempMatrixA","Matrix3","tempMatrixB","tempMatrixC","tempMatrixD","tempMatrixE","tempVectorA","Vector3","DEFAULT_ANCHOR","UIMicroInternal","anchorX","anchorY","scaleX","scaleY","rotation","UIMicro","raw","owner","angle","radToDeg","convertedValue","degToRad","setAnchorByGlobalPosition","newAnchorX","width","newAnchorY","reset","UIMode","UIMaterial","ShaderMaterial","uniforms","opacity","color","Color","vertexShader","fragmentShader","transparent","lights","fog","depthWrite","depthTest","getTexture","getColor","getHex","getOpacity","setTexture","uniformsNeedUpdate","setColor","setHex","setOpacity","geometry","PlaneGeometry","translate","scene","Scene","mesh","Mesh","UIFullScreenQuad","paddingHorizontalInternal","paddingVerticalInternal","camera","OrthographicCamera","updateCameraTransform","paddingHorizontal","paddingVertical","material","left","right","bottom","top","updateProjectionMatrix","UIComposerInternal","passes","defaultMaterial","screen","needsUpdateInternal","paddingHasChangedInternal","paddingInternal","parameters","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","stencilBuffer","fromRenderTarget","WebGLRenderTarget","toRenderTarget","texture","generateMipmaps","needsUpdate","hasValuablePasses","hasPassesNeedingUpdate","paddingHasChanged","padding","requestUpdate","compose","canOverrideBlending","calculatePadding","widthWithPadding","heightWithPadding","setSize","setScreenPadding","setClearColor","setRenderTarget","clear","originalBlending","blending","NoBlending","pass","isValuable","reverseRenderTargets","dispose","p","reduce","UIComposer","UIElementEvent","UIElement","microInternal","composerInternal","modeInternal","VISIBLE","micro","composer","mode","visible","HIDDEN","click","realX","realY","realWidth","realHeight","centerX","centerY","translateToCenter","scale","cos","sin","translateFinal","finalMatrix","multiplyMatrices","point","applyMatrix3","applyMicroTransformations","INTERACTIVE","elementX","elementY","elementWidth","elementHeight","containsPoint","CLICK","clearColor","UILayerEvent","UIConstraintContainerDirection","UISceneUpdateMode","UILayer","solver","constraints","orientationPrivate","PORTRAIT","keys","has","variables","children","dependencies","remove","suggestedValue","description","sort","child","near","far","originalRenderTarget","getRenderTarget","originalClearColor","getClearColor","originalClearAlpha","getClearAlpha","setClearAlpha","clickInternal","e","resizeInternal","applyCameraSize","rebuildLayerConstraints","updateOrientation","constraintX","constraintY","_f","constraintW","_g","constraintH","_h","_j","_k","_l","_m","lastOrientation","LANDSCAPE","descriptions","entries","dependency","ORIENTATION_CHANGED","assertSameLayer","elementOne","elementTwo","assertSize","message","UIHorizontalDistanceConstraint","anchorOne","anchorTwo","distance","expressionOne","expressionTwo","UIHorizontalProportionConstraint","proportion","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","UIConstraint2DBuilder","UIConstraintContainerBuilder","build","container","direction","FROM_LEFT_TOP","horizontalDistances","verticalDistances","UIConstraintStackBuilder","buildHorizontal","buildStack","distanceConstraint","proportionConstraint","centerDistanceConstraint","buildVertical","constructors","distances","proportions","centers","nextElement","keepProportions","keepAlignment","distanceConstraints","proportionConstraints","alignmentConstraints","UIAspectConstraint","aspect","newOrientation","UICoverConstraint","isStrict","horizontalAnchor","verticalAnchor","constraintStrict","UIFitConstraint","UIDummy","Object3D","UIImage","image","textureInternal","UIProgressMaterial","foregroundTexture","backgroundTexture","UniformsUtils","merge","background","foreground","progress","backgroundColor","foregroundColor","backgroundOpacity","foregroundOpacity","getProgress","getBackgroundTexture","getForegroundTexture","getBackgroundColor","getForegroundColor","getBackgroundOpacity","getForegroundOpacity","getAngle","getIsForwardDirection","setProgress","setBackgroundTexture","setForegroundTexture","setBackgroundColor","setForegroundColor","setBackgroundOpacity","setForegroundOpacity","setAngle","setIsForwardDirection","UIProgress","textureForeground","foregroundWidth","foregroundHeight","backgroundWidth","textureBackground","backgroundHeight","isForegroundDirection","imageWidth","imageHeight","isForwardDirection","DEFAULT_UPDATE_MODE","PROPERTY_CHANGED","UIScene","resolutionFactor","renderTarget","useDepth","needsRenderInternal","sceneInternal","cameraInternal","PerspectiveCamera","resolutionFactorInternal","updateModeInternal","updateBehavior","renderedByDefault","clearColorInternal","clearAlphaInternal","clearAlpha","needsRender","requestRender","resolveTextStyle","currentStyle","baseStyle","fontSize","lineHeight","shadowBlur","strokeWidth","fontFamily","fontStyle","_p","_o","fontWeight","_r","_q","enableShadow","_t","_s","shadowOffsetX","_v","_u","shadowOffsetY","_x","_w","shadowColor","_z","_y","enableStroke","_1","_0","strokeColor","_3","_2","splitText","text","match","measureTextChunk","chunk","style","font","baseline","metrics","measureText","ceil","actualBoundingBoxAscent","actualBoundingBoxDescent","renderText","strokeStyle","lineWidth","strokeText","fillStyle","fillText","UIText","spans","canvas","document","createElement","getContext","chunks","processedSpans","isArray","span","isSpanString","spanText","defaultStyle","wrappedLines","maxWidth","lines","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","wrapTextLines","textBlockSize","maxLineWidth","line","totalHeight","calculateTextBlockSize","resolvePadding","CanvasTexture","suggestedAspect","paddingTop","paddingLeft","currentY","currentX","renderTextLines","currentAspect","UIFullScreenLayer","targetScreenHeight","onResize","calculateScale","window","innerWidth","innerHeight","onClick","rect","target","HTMLElement","getBoundingClientRect","offsetX","clientX","offsetY","clientY","addEventListener","tergetScreenHeight","removeEventListener","UIManualLayer","resize","UIPass"],"mappings":"4VAOO,SAASA,IACZ,OAAO,IAAIC,CACf,CACA,IAAIA,EAA4B,WAC5B,SAASA,IACLC,KAAKC,MAAQ,CAAE,EACfD,KAAKE,MAAQ,EACrB,CA8GI,OA1GAH,EAAWI,UAAUC,KAAO,WACxB,OAAOJ,KAAKE,MAAMG,MACrB,EAIDN,EAAWI,UAAUG,MAAQ,WACzB,OAA6B,IAAtBN,KAAKE,MAAMG,MACrB,EAMDN,EAAWI,UAAUI,OAAS,SAAUN,GACpC,OAAOD,KAAKE,MAAMD,EACrB,EAMDF,EAAWI,UAAUK,SAAW,SAAUC,GACtC,YAAgCC,IAAzBV,KAAKC,MAAMQ,EAAIE,KACzB,EAMDZ,EAAWI,UAAUS,KAAO,SAAUH,GAClC,IAAII,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,YAAaD,IAANG,OAAkBH,EAAYV,KAAKE,MAAMW,EACnD,EAUDd,EAAWI,UAAUW,WAAa,SAAUL,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KAAK2e,cAAc6O,EAAUzR,EAAO2R,EAAU3R,EAAM,EA9CpDiR,OAAOY,iBAAiB,SAAU5tB,KAAK8sB,UACvCE,OAAOY,iBAAiB,cAAe5tB,KAAKmtB,SAC5CntB,KAAK8sB,WAGP,sBAAWe,GACT,OAAO7tB,KAAK6sB,mBAGd,sBAAWgB,CAAmBzsB,GAC5BpB,KAAK6sB,mBAAqBzrB,EAC1BpB,KAAK6e,eAAemO,OAAOC,WAAYD,OAAOE,aAGhC,OAAA1e,GACdwe,OAAOc,oBAAoB,SAAU9tB,KAAK8sB,UAC1CE,OAAOc,oBAAoB,cAAe9tB,KAAKmtB,SAC/Cjd,MAAM1B,UAGA,cAAAue,SAEN,OADgD,QAA3B1c,EAAArQ,KAAK6tB,0BAAsB,IAAAxd,EAAAA,EAAA2c,OAAOE,aACjCF,OAAOE,aC9B3B,MAAOa,WAAsB5Q,GAC1B,KAAA5B,CAAMxJ,EAAWC,GACtBhS,KAAK2e,cAAc5M,EAAGC,GAGjB,MAAAgc,CAAOlZ,EAAe1E,GAC3BpQ,KAAK6e,eAAe/J,EAAO1E,UCYT6d","x_google_ignoreList":[0,1,2,3,4,5,12]}
1
+ {"version":3,"file":"index.js","sources":["../node_modules/kiwi.js/es/maptype.js","../node_modules/kiwi.js/es/variable.js","../node_modules/kiwi.js/es/expression.js","../node_modules/kiwi.js/es/strength.js","../node_modules/kiwi.js/es/constraint.js","../node_modules/kiwi.js/es/solver.js","../src/Miscellaneous/symbols.ts","../src/Miscellaneous/UIOrientation.ts","../src/Constraints/UIConstraint.ts","../src/Constraints/UIConstraintPower.ts","../src/Constraints/UIConstraintRule.ts","../src/Constraints/UIHeightConstraint.ts","../node_modules/eventail/dist/index.js","../src/Elements/UIAnchor.ts","../src/Miscellaneous/math.ts","../src/Miscellaneous/microTransformationTools.ts","../src/Miscellaneous/UIMicro.ts","../src/Miscellaneous/UIMode.ts","../src/Materials/UIMaterial.ts","../src/Miscellaneous/threeInstances.ts","../src/Passes/UIFullScreenQuad.ts","../src/Passes/UIComposer.ts","../src/Elements/UIElement.ts","../src/Layers/UILayer.ts","../src/Builders/UIConstraintContainerBuilder.ts","../src/Elements/UIScene.ts","../src/Miscellaneous/asserts.ts","../src/Constraints/UIHorizontalDistanceConstraint.ts","../src/Constraints/UIHorizontalProportionConstraint.ts","../src/Constraints/UIVerticalDistanceConstraint.ts","../src/Constraints/UIVerticalProportionConstraint.ts","../src/Constraints/UIWidthConstraint.ts","../src/Builders/UIConstraint2DBuilder.ts","../src/Builders/UIConstraintStackBuilder.ts","../src/Constraints/UIAspectConstraint.ts","../src/Constraints/UICoverConstraint.ts","../src/Constraints/UIFitConstraint.ts","../src/Elements/UIDummy.ts","../src/Elements/UIImage.ts","../src/Materials/UIProgressMaterial.ts","../src/Elements/UIProgress.ts","../src/Miscellaneous/textTools.ts","../src/Elements/UIText.ts","../src/Layers/UIFullScreenLayer.ts","../src/Passes/UIPass.ts"],"sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nexport function createMap() {\n return new IndexedMap();\n}\nvar IndexedMap = /** @class */ (function () {\n function IndexedMap() {\n this.index = {};\n this.array = [];\n }\n /**\n * Returns the number of items in the array.\n */\n IndexedMap.prototype.size = function () {\n return this.array.length;\n };\n /**\n * Returns true if the array is empty.\n */\n IndexedMap.prototype.empty = function () {\n return this.array.length === 0;\n };\n /**\n * Returns the item at the given array index.\n *\n * @param index The integer index of the desired item.\n */\n IndexedMap.prototype.itemAt = function (index) {\n return this.array[index];\n };\n /**\n * Returns true if the key is in the array, false otherwise.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.contains = function (key) {\n return this.index[key.id()] !== undefined;\n };\n /**\n * Returns the pair associated with the given key, or undefined.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.find = function (key) {\n var i = this.index[key.id()];\n return i === undefined ? undefined : this.array[i];\n };\n /**\n * Returns the pair associated with the key if it exists.\n *\n * If the key does not exist, a new pair will be created and\n * inserted using the value created by the given factory.\n *\n * @param key The key to locate in the array.\n * @param factory The function which creates the default value.\n */\n IndexedMap.prototype.setDefault = function (key, factory) {\n var i = this.index[key.id()];\n if (i === undefined) {\n var pair = new Pair(key, factory());\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n return pair;\n }\n else {\n return this.array[i];\n }\n };\n /**\n * Insert the pair into the array and return the pair.\n *\n * This will overwrite any existing entry in the array.\n *\n * @param key The key portion of the pair.\n * @param value The value portion of the pair.\n */\n IndexedMap.prototype.insert = function (key, value) {\n var pair = new Pair(key, value);\n var i = this.index[key.id()];\n if (i === undefined) {\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n }\n else {\n this.array[i] = pair;\n }\n return pair;\n };\n /**\n * Removes and returns the pair for the given key, or undefined.\n *\n * @param key The key to remove from the map.\n */\n IndexedMap.prototype.erase = function (key) {\n var i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n var pair = this.array[i];\n var last = this.array.pop();\n if (pair !== last) {\n this.array[i] = last;\n this.index[last.first.id()] = i;\n }\n return pair;\n };\n /**\n * Create a copy of this associative array.\n */\n IndexedMap.prototype.copy = function () {\n var copy = new IndexedMap();\n for (var i = 0; i < this.array.length; i++) {\n var pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n };\n return IndexedMap;\n}());\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nvar Pair = /** @class */ (function () {\n /**\n * Construct a new Pair object.\n *\n * @param first The first item of the pair.\n * @param second The second item of the pair.\n */\n function Pair(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n Pair.prototype.copy = function () { return new Pair(this.first, this.second); };\n return Pair;\n}());\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nvar Variable = /** @class */ (function () {\n function Variable(name) {\n if (name === void 0) { name = \"\"; }\n this._value = 0.0;\n this._context = null;\n this._id = VarId++;\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n Variable.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n Variable.prototype.name = function () {\n return this._name;\n };\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n Variable.prototype.setName = function (name) {\n this._name = name;\n };\n /**\n * Returns the user context object of the variable.\n * @private\n */\n Variable.prototype.context = function () {\n return this._context;\n };\n /**\n * Set the user context object of the variable.\n * @private\n */\n Variable.prototype.setContext = function (context) {\n this._context = context;\n };\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n Variable.prototype.value = function () {\n return this._value;\n };\n /**\n * Set the value of the variable.\n * @private\n */\n Variable.prototype.setValue = function (value) {\n this._value = value;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the variable.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Variable.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the variable.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Variable.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Variable.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Variable.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n Variable.prototype.toJSON = function () {\n return {\n name: this._name,\n value: this._value,\n };\n };\n Variable.prototype.toString = function () {\n return this._context + \"[\" + this._name + \":\" + this._value + \"]\";\n };\n return Variable;\n}());\nexport { Variable };\n/**\n * The internal variable id counter.\n * @private\n */\nvar VarId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { createMap } from \"./maptype\";\nimport { Variable } from \"./variable\";\n/**\n * An expression of variable terms and a constant.\n *\n * The constructor accepts an arbitrary number of parameters,\n * each of which must be one of the following types:\n * - number\n * - Variable\n * - Expression\n * - 2-tuple of [number, Variable|Expression]\n *\n * The parameters are summed. The tuples are multiplied.\n *\n * @class\n * @param {...(number|Variable|Expression|Array)} args\n */\nvar Expression = /** @class */ (function () {\n function Expression() {\n var parsed = parseArgs(arguments);\n this._terms = parsed.terms;\n this._constant = parsed.constant;\n }\n /**\n * Returns the mapping of terms in the expression.\n *\n * This *must* be treated as const.\n * @private\n */\n Expression.prototype.terms = function () {\n return this._terms;\n };\n /**\n * Returns the constant of the expression.\n * @private\n */\n Expression.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns the computed value of the expression.\n *\n * @private\n * @return {Number} computed value of the expression\n */\n Expression.prototype.value = function () {\n var result = this._constant;\n for (var i = 0, n = this._terms.size(); i < n; i++) {\n var pair = this._terms.itemAt(i);\n result += pair.first.value() * pair.second;\n }\n return result;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the expression.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Expression.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the expression.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Expression.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Expression.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Expression.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n Expression.prototype.isConstant = function () {\n return this._terms.size() == 0;\n };\n Expression.prototype.toString = function () {\n var result = this._terms.array.map(function (pair) {\n return (pair.second + \"*\" + pair.first.toString());\n }).join(\" + \");\n if (!this.isConstant() && this._constant !== 0) {\n result += \" + \";\n }\n result += this._constant;\n return result;\n };\n return Expression;\n}());\nexport { Expression };\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n var constant = 0.0;\n var factory = function () { return 0.0; };\n var terms = createMap();\n for (var i = 0, n = args.length; i < n; ++i) {\n var item = args[i];\n if (typeof item === \"number\") {\n constant += item;\n }\n else if (item instanceof Variable) {\n terms.setDefault(item, factory).second += 1.0;\n }\n else if (item instanceof Expression) {\n constant += item.constant();\n var terms2 = item.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second;\n }\n }\n else if (item instanceof Array) {\n if (item.length !== 2) {\n throw new Error(\"array must have length 2\");\n }\n var value = item[0];\n var value2 = item[1];\n if (typeof value !== \"number\") {\n throw new Error(\"array item 0 must be a number\");\n }\n if (value2 instanceof Variable) {\n terms.setDefault(value2, factory).second += value;\n }\n else if (value2 instanceof Expression) {\n constant += (value2.constant() * value);\n var terms2 = value2.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += (termPair.second * value);\n }\n }\n else {\n throw new Error(\"array item 1 must be a variable or expression\");\n }\n }\n else {\n throw new Error(\"invalid Expression argument: \" + item);\n }\n }\n return { terms: terms, constant: constant };\n}\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\n/**\n * @class Strength\n */\nvar Strength = /** @class */ (function () {\n function Strength() {\n }\n /**\n * Create a new symbolic strength.\n *\n * @param a strong\n * @param b medium\n * @param c weak\n * @param [w] weight\n * @return strength\n */\n Strength.create = function (a, b, c, w) {\n if (w === void 0) { w = 1.0; }\n var result = 0.0;\n result += Math.max(0.0, Math.min(1000.0, a * w)) * 1000000.0;\n result += Math.max(0.0, Math.min(1000.0, b * w)) * 1000.0;\n result += Math.max(0.0, Math.min(1000.0, c * w));\n return result;\n };\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n Strength.clip = function (value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n };\n /**\n * The 'required' symbolic strength.\n */\n Strength.required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n Strength.strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n Strength.medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n Strength.weak = Strength.create(0.0, 0.0, 1.0);\n return Strength;\n}());\nexport { Strength };\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\nimport { Strength } from \"./strength\";\n/**\n * An enum defining the linear constraint operators.\n *\n * |Value|Operator|Description|\n * |----|-----|-----|\n * |`Le`|<=|Less than equal|\n * |`Ge`|>=|Greater than equal|\n * |`Eq`|==|Equal|\n *\n * @enum {Number}\n */\nexport var Operator;\n(function (Operator) {\n Operator[Operator[\"Le\"] = 0] = \"Le\";\n Operator[Operator[\"Ge\"] = 1] = \"Ge\";\n Operator[Operator[\"Eq\"] = 2] = \"Eq\";\n})(Operator || (Operator = {}));\n/**\n * A linear constraint equation.\n *\n * A constraint equation is composed of an expression, an operator,\n * and a strength. The RHS of the equation is implicitly zero.\n *\n * @class\n * @param {Expression} expression The constraint expression (LHS).\n * @param {Operator} operator The equation operator.\n * @param {Expression} [rhs] Right hand side of the expression.\n * @param {Number} [strength=Strength.required] The strength of the constraint.\n */\nvar Constraint = /** @class */ (function () {\n function Constraint(expression, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n this._id = CnId++;\n this._operator = operator;\n this._strength = Strength.clip(strength);\n if ((rhs === undefined) && (expression instanceof Expression)) {\n this._expression = expression;\n }\n else {\n this._expression = expression.minus(rhs);\n }\n }\n /**\n * Returns the unique id number of the constraint.\n * @private\n */\n Constraint.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n Constraint.prototype.expression = function () {\n return this._expression;\n };\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n Constraint.prototype.op = function () {\n return this._operator;\n };\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n Constraint.prototype.strength = function () {\n return this._strength;\n };\n Constraint.prototype.toString = function () {\n return this._expression.toString() + \" \" + [\"<=\", \">=\", \"=\"][this._operator] + \" 0 (\" + this._strength.toString() + \")\";\n };\n return Constraint;\n}());\nexport { Constraint };\n/**\n * The internal constraint id counter.\n * @private\n */\nvar CnId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Constraint, Operator } from \"./constraint\";\nimport { Expression } from \"./expression\";\nimport { createMap } from \"./maptype\";\nimport { Strength } from \"./strength\";\n/**\n * The constraint solver class.\n *\n * @class\n */\nvar Solver = /** @class */ (function () {\n /**\n * Construct a new Solver.\n */\n function Solver() {\n this._cnMap = createCnMap();\n this._rowMap = createRowMap();\n this._varMap = createVarMap();\n this._editMap = createEditMap();\n this._infeasibleRows = [];\n this._objective = new Row();\n this._artificial = null;\n this._idTick = 0;\n }\n /**\n * Creates and add a constraint to the solver.\n *\n * @param {Expression|Variable} lhs Left hand side of the expression\n * @param {Operator} operator Operator\n * @param {Expression|Variable|Number} rhs Right hand side of the expression\n * @param {Number} [strength=Strength.required] Strength\n */\n Solver.prototype.createConstraint = function (lhs, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n var cn = new Constraint(lhs, operator, rhs, strength);\n this.addConstraint(cn);\n return cn;\n };\n /**\n * Add a constraint to the solver.\n *\n * @param {Constraint} constraint Constraint to add to the solver\n */\n Solver.prototype.addConstraint = function (constraint) {\n var cnPair = this._cnMap.find(constraint);\n if (cnPair !== undefined) {\n throw new Error(\"duplicate constraint\");\n }\n // Creating a row causes symbols to be reserved for the variables\n // in the constraint. If this method exits with an exception,\n // then its possible those variables will linger in the var map.\n // Since its likely that those variables will be used in other\n // constraints and since exceptional conditions are uncommon,\n // i'm not too worried about aggressive cleanup of the var map.\n var data = this._createRow(constraint);\n var row = data.row;\n var tag = data.tag;\n var subject = this._chooseSubject(row, tag);\n // If chooseSubject couldnt find a valid entering symbol, one\n // last option is available if the entire row is composed of\n // dummy variables. If the constant of the row is zero, then\n // this represents redundant constraints and the new dummy\n // marker can enter the basis. If the constant is non-zero,\n // then it represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid && row.allDummies()) {\n if (!nearZero(row.constant())) {\n throw new Error(\"unsatisfiable constraint\");\n }\n else {\n subject = tag.marker;\n }\n }\n // If an entering symbol still isn't found, then the row must\n // be added using an artificial variable. If that fails, then\n // the row represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid) {\n if (!this._addWithArtificialVariable(row)) {\n throw new Error(\"unsatisfiable constraint\");\n }\n }\n else {\n row.solveFor(subject);\n this._substitute(subject, row);\n this._rowMap.insert(subject, row);\n }\n this._cnMap.insert(constraint, tag);\n // Optimizing after each constraint is added performs less\n // aggregate work due to a smaller average system size. It\n // also ensures the solver remains in a consistent state.\n this._optimize(this._objective);\n };\n /**\n * Remove a constraint from the solver.\n *\n * @param {Constraint} constraint Constraint to remove from the solver\n */\n Solver.prototype.removeConstraint = function (constraint) {\n var cnPair = this._cnMap.erase(constraint);\n if (cnPair === undefined) {\n throw new Error(\"unknown constraint\");\n }\n // Remove the error effects from the objective function\n // *before* pivoting, or substitutions into the objective\n // will lead to incorrect solver results.\n this._removeConstraintEffects(constraint, cnPair.second);\n // If the marker is basic, simply drop the row. Otherwise,\n // pivot the marker into the basis and then drop the row.\n var marker = cnPair.second.marker;\n var rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n var leaving = this._getMarkerLeavingSymbol(marker);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"failed to find leaving row\");\n }\n rowPair = this._rowMap.erase(leaving);\n rowPair.second.solveForEx(leaving, marker);\n this._substitute(marker, rowPair.second);\n }\n // Optimizing after each constraint is removed ensures that the\n // solver remains consistent. It makes the solver api easier to\n // use at a small tradeoff for speed.\n this._optimize(this._objective);\n };\n /**\n * Test whether the solver contains the constraint.\n *\n * @param {Constraint} constraint Constraint to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasConstraint = function (constraint) {\n return this._cnMap.contains(constraint);\n };\n /**\n * Add an edit variable to the solver.\n *\n * @param {Variable} variable Edit variable to add to the solver\n * @param {Number} strength Strength, should be less than `Strength.required`\n */\n Solver.prototype.addEditVariable = function (variable, strength) {\n var editPair = this._editMap.find(variable);\n if (editPair !== undefined) {\n throw new Error(\"duplicate edit variable\");\n }\n strength = Strength.clip(strength);\n if (strength === Strength.required) {\n throw new Error(\"bad required strength\");\n }\n var expr = new Expression(variable);\n var cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n var tag = this._cnMap.find(cn).second;\n var info = { tag: tag, constraint: cn, constant: 0.0 };\n this._editMap.insert(variable, info);\n };\n /**\n * Remove an edit variable from the solver.\n *\n * @param {Variable} variable Edit variable to remove from the solver\n */\n Solver.prototype.removeEditVariable = function (variable) {\n var editPair = this._editMap.erase(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n this.removeConstraint(editPair.second.constraint);\n };\n /**\n * Test whether the solver contains the edit variable.\n *\n * @param {Variable} variable Edit variable to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasEditVariable = function (variable) {\n return this._editMap.contains(variable);\n };\n /**\n * Suggest the value of an edit variable.\n *\n * @param {Variable} variable Edit variable to suggest a value for\n * @param {Number} value Suggested value\n */\n Solver.prototype.suggestValue = function (variable, value) {\n var editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n var rows = this._rowMap;\n var info = editPair.second;\n var delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n var marker = info.tag.marker;\n var rowPair = rows.find(marker);\n if (rowPair !== undefined) {\n if (rowPair.second.add(-delta) < 0.0) {\n this._infeasibleRows.push(marker);\n }\n this._dualOptimize();\n return;\n }\n // Check next if the negative error variable is basic.\n var other = info.tag.other;\n rowPair = rows.find(other);\n if (rowPair !== undefined) {\n if (rowPair.second.add(delta) < 0.0) {\n this._infeasibleRows.push(other);\n }\n this._dualOptimize();\n return;\n }\n // Otherwise update each row where the error variables exist.\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var rowPair_1 = rows.itemAt(i);\n var row = rowPair_1.second;\n var coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 &&\n rowPair_1.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair_1.first);\n }\n }\n this._dualOptimize();\n };\n /**\n * Update the values of the variables.\n */\n Solver.prototype.updateVariables = function () {\n var vars = this._varMap;\n var rows = this._rowMap;\n for (var i = 0, n = vars.size(); i < n; ++i) {\n var pair = vars.itemAt(i);\n var rowPair = rows.find(pair.second);\n if (rowPair !== undefined) {\n pair.first.setValue(rowPair.second.constant());\n }\n else {\n pair.first.setValue(0.0);\n }\n }\n };\n /**\n * Get the symbol for the given variable.\n *\n * If a symbol does not exist for the variable, one will be created.\n * @private\n */\n Solver.prototype._getVarSymbol = function (variable) {\n var _this = this;\n var factory = function () { return _this._makeSymbol(SymbolType.External); };\n return this._varMap.setDefault(variable, factory).second;\n };\n /**\n * Create a new Row object for the given constraint.\n *\n * The terms in the constraint will be converted to cells in the row.\n * Any term in the constraint with a coefficient of zero is ignored.\n * This method uses the `_getVarSymbol` method to get the symbol for\n * the variables added to the row. If the symbol for a given cell\n * variable is basic, the cell variable will be substituted with the\n * basic row.\n *\n * The necessary slack and error variables will be added to the row.\n * If the constant for the row is negative, the sign for the row\n * will be inverted so the constant becomes positive.\n *\n * Returns the created Row and the tag for tracking the constraint.\n * @private\n */\n Solver.prototype._createRow = function (constraint) {\n var expr = constraint.expression();\n var row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n var terms = expr.terms();\n for (var i = 0, n = terms.size(); i < n; ++i) {\n var termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n var symbol = this._getVarSymbol(termPair.first);\n var basicPair = this._rowMap.find(symbol);\n if (basicPair !== undefined) {\n row.insertRow(basicPair.second, termPair.second);\n }\n else {\n row.insertSymbol(symbol, termPair.second);\n }\n }\n }\n // Add the necessary slack, error, and dummy variables.\n var objective = this._objective;\n var strength = constraint.strength();\n var tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge:\n {\n var coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n var slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n var error = this._makeSymbol(SymbolType.Error);\n tag.other = error;\n row.insertSymbol(error, -coeff);\n objective.insertSymbol(error, strength);\n }\n break;\n }\n case Operator.Eq:\n {\n if (strength < Strength.required) {\n var errplus = this._makeSymbol(SymbolType.Error);\n var errminus = this._makeSymbol(SymbolType.Error);\n tag.marker = errplus;\n tag.other = errminus;\n row.insertSymbol(errplus, -1.0); // v = eplus - eminus\n row.insertSymbol(errminus, 1.0); // v - eplus + eminus = 0\n objective.insertSymbol(errplus, strength);\n objective.insertSymbol(errminus, strength);\n }\n else {\n var dummy = this._makeSymbol(SymbolType.Dummy);\n tag.marker = dummy;\n row.insertSymbol(dummy);\n }\n break;\n }\n }\n // Ensure the row has a positive constant.\n if (row.constant() < 0.0) {\n row.reverseSign();\n }\n return { row: row, tag: tag };\n };\n /**\n * Choose the subject for solving for the row.\n *\n * This method will choose the best subject for using as the solve\n * target for the row. An invalid symbol will be returned if there\n * is no valid target.\n *\n * The symbols are chosen according to the following precedence:\n *\n * 1) The first symbol representing an external variable.\n * 2) A negative slack or error tag variable.\n *\n * If a subject cannot be found, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._chooseSubject = function (row, tag) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n var type = tag.marker.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.marker) < 0.0) {\n return tag.marker;\n }\n }\n type = tag.other.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.other) < 0.0) {\n return tag.other;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Add the row to the tableau using an artificial variable.\n *\n * This will return false if the constraint cannot be satisfied.\n *\n * @private\n */\n Solver.prototype._addWithArtificialVariable = function (row) {\n // Create and add the artificial variable to the tableau.\n var art = this._makeSymbol(SymbolType.Slack);\n this._rowMap.insert(art, row.copy());\n this._artificial = row.copy();\n // Optimize the artificial objective. This is successful\n // only if the artificial objective is optimized to zero.\n this._optimize(this._artificial);\n var success = nearZero(this._artificial.constant());\n this._artificial = null;\n // If the artificial variable is basic, pivot the row so that\n // it becomes non-basic. If the row is constant, exit early.\n var pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n var basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n var entering = this._anyPivotableSymbol(basicRow);\n if (entering.type() === SymbolType.Invalid) {\n return false; // unsatisfiable (will this ever happen?)\n }\n basicRow.solveForEx(art, entering);\n this._substitute(entering, basicRow);\n this._rowMap.insert(entering, basicRow);\n }\n // Remove the artificial variable from the tableau.\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n rows.itemAt(i).second.removeSymbol(art);\n }\n this._objective.removeSymbol(art);\n return success;\n };\n /**\n * Substitute the parametric symbol with the given row.\n *\n * This method will substitute all instances of the parametric symbol\n * in the tableau and the objective function with the given row.\n *\n * @private\n */\n Solver.prototype._substitute = function (symbol, row) {\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 &&\n pair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(pair.first);\n }\n }\n this._objective.substitute(symbol, row);\n if (this._artificial) {\n this._artificial.substitute(symbol, row);\n }\n };\n /**\n * Optimize the system for the given objective function.\n *\n * This method performs iterations of Phase 2 of the simplex method\n * until the objective function reaches a minimum.\n *\n * @private\n */\n Solver.prototype._optimize = function (objective) {\n while (true) {\n var entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n var leaving = this._getLeavingSymbol(entering);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"the objective is unbounded\");\n }\n // pivot the entering symbol into the basis\n var row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n }\n };\n /**\n * Optimize the system using the dual of the simplex method.\n *\n * The current state of the system should be such that the objective\n * function is optimal, but not feasible. This method will perform\n * an iteration of the dual simplex method to make the solution both\n * optimal and feasible.\n *\n * @private\n */\n Solver.prototype._dualOptimize = function () {\n var rows = this._rowMap;\n var infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n var leaving = infeasible.pop();\n var pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n var entering = this._getDualEnteringSymbol(pair.second);\n if (entering.type() === SymbolType.Invalid) {\n throw new Error(\"dual optimize failed\");\n }\n // pivot the entering symbol into the basis\n var row = pair.second;\n rows.erase(leaving);\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n rows.insert(entering, row);\n }\n }\n };\n /**\n * Compute the entering variable for a pivot operation.\n *\n * This method will return first symbol in the objective function which\n * is non-dummy and has a coefficient less than zero. If no symbol meets\n * the criteria, it means the objective function is at a minimum, and an\n * invalid symbol is returned.\n *\n * @private\n */\n Solver.prototype._getEnteringSymbol = function (objective) {\n var cells = objective.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n if (pair.second < 0.0 && symbol.type() !== SymbolType.Dummy) {\n return symbol;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Compute the entering symbol for the dual optimize operation.\n *\n * This method will return the symbol in the row which has a positive\n * coefficient and yields the minimum ratio for its respective symbol\n * in the objective function. The provided row *must* be infeasible.\n * If no symbol is found which meats the criteria, an invalid symbol\n * is returned.\n *\n * @private\n */\n Solver.prototype._getDualEnteringSymbol = function (row) {\n var ratio = Number.MAX_VALUE;\n var entering = INVALID_SYMBOL;\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n var c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n var coeff = this._objective.coefficientFor(symbol);\n var r = coeff / c;\n if (r < ratio) {\n ratio = r;\n entering = symbol;\n }\n }\n }\n return entering;\n };\n /**\n * Compute the symbol for pivot exit row.\n *\n * This method will return the symbol for the exit row in the row\n * map. If no appropriate exit symbol is found, an invalid symbol\n * will be returned. This indicates that the objective function is\n * unbounded.\n *\n * @private\n */\n Solver.prototype._getLeavingSymbol = function (entering) {\n var ratio = Number.MAX_VALUE;\n var found = INVALID_SYMBOL;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n var row = pair.second;\n var temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n var temp_ratio = -row.constant() / temp;\n if (temp_ratio < ratio) {\n ratio = temp_ratio;\n found = symbol;\n }\n }\n }\n }\n return found;\n };\n /**\n * Compute the leaving symbol for a marker variable.\n *\n * This method will return a symbol corresponding to a basic row\n * which holds the given marker variable. The row will be chosen\n * according to the following precedence:\n *\n * 1) The row with a restricted basic varible and a negative coefficient\n * for the marker with the smallest ratio of -constant / coefficient.\n *\n * 2) The row with a restricted basic variable and the smallest ratio\n * of constant / coefficient.\n *\n * 3) The last unrestricted row which contains the marker.\n *\n * If the marker does not exist in any row, an invalid symbol will be\n * returned. This indicates an internal solver error since the marker\n * *should* exist somewhere in the tableau.\n *\n * @private\n */\n Solver.prototype._getMarkerLeavingSymbol = function (marker) {\n var dmax = Number.MAX_VALUE;\n var r1 = dmax;\n var r2 = dmax;\n var invalid = INVALID_SYMBOL;\n var first = invalid;\n var second = invalid;\n var third = invalid;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var row = pair.second;\n var c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n var symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n var r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n var r = row.constant() / c;\n if (r < r2) {\n r2 = r;\n second = symbol;\n }\n }\n }\n if (first !== invalid) {\n return first;\n }\n if (second !== invalid) {\n return second;\n }\n return third;\n };\n /**\n * Remove the effects of a constraint on the objective function.\n *\n * @private\n */\n Solver.prototype._removeConstraintEffects = function (cn, tag) {\n if (tag.marker.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.marker, cn.strength());\n }\n if (tag.other.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.other, cn.strength());\n }\n };\n /**\n * Remove the effects of an error marker on the objective function.\n *\n * @private\n */\n Solver.prototype._removeMarkerEffects = function (marker, strength) {\n var pair = this._rowMap.find(marker);\n if (pair !== undefined) {\n this._objective.insertRow(pair.second, -strength);\n }\n else {\n this._objective.insertSymbol(marker, -strength);\n }\n };\n /**\n * Get the first Slack or Error symbol in the row.\n *\n * If no such symbol is present, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._anyPivotableSymbol = function (row) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var type = pair.first.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n return pair.first;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Returns a new Symbol of the given type.\n *\n * @private\n */\n Solver.prototype._makeSymbol = function (type) {\n return new Symbol(type, this._idTick++);\n };\n return Solver;\n}());\nexport { Solver };\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n var eps = 1.0e-8;\n return value < 0.0 ? -value < eps : value < eps;\n}\n/**\n * An internal function for creating a constraint map.\n * @private\n */\nfunction createCnMap() {\n return createMap();\n}\n/**\n * An internal function for creating a row map.\n * @private\n */\nfunction createRowMap() {\n return createMap();\n}\n/**\n * An internal function for creating a variable map.\n * @private\n */\nfunction createVarMap() {\n return createMap();\n}\n/**\n * An internal function for creating an edit map.\n * @private\n */\nfunction createEditMap() {\n return createMap();\n}\n/**\n * An enum defining the available symbol types.\n * @private\n */\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Invalid\"] = 0] = \"Invalid\";\n SymbolType[SymbolType[\"External\"] = 1] = \"External\";\n SymbolType[SymbolType[\"Slack\"] = 2] = \"Slack\";\n SymbolType[SymbolType[\"Error\"] = 3] = \"Error\";\n SymbolType[SymbolType[\"Dummy\"] = 4] = \"Dummy\";\n})(SymbolType || (SymbolType = {}));\n/**\n * An internal class representing a symbol in the solver.\n * @private\n */\nvar Symbol = /** @class */ (function () {\n /**\n * Construct a new Symbol\n *\n * @param [type] The type of the symbol.\n * @param [id] The unique id number of the symbol.\n */\n function Symbol(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n Symbol.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the type of the symbol.\n */\n Symbol.prototype.type = function () {\n return this._type;\n };\n return Symbol;\n}());\n/**\n * A static invalid symbol\n * @private\n */\nvar INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nvar Row = /** @class */ (function () {\n /**\n * Construct a new Row.\n */\n function Row(constant) {\n if (constant === void 0) { constant = 0.0; }\n this._cellMap = createMap();\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n Row.prototype.cells = function () {\n return this._cellMap;\n };\n /**\n * Returns the constant for the row.\n */\n Row.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns true if the row is a constant value.\n */\n Row.prototype.isConstant = function () {\n return this._cellMap.empty();\n };\n /**\n * Returns true if the Row has all dummy symbols.\n */\n Row.prototype.allDummies = function () {\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() !== SymbolType.Dummy) {\n return false;\n }\n }\n return true;\n };\n /**\n * Create a copy of the row.\n */\n Row.prototype.copy = function () {\n var theCopy = new Row(this._constant);\n theCopy._cellMap = this._cellMap.copy();\n return theCopy;\n };\n /**\n * Add a constant value to the row constant.\n *\n * Returns the new value of the constant.\n */\n Row.prototype.add = function (value) {\n return this._constant += value;\n };\n /**\n * Insert the symbol into the row with the given coefficient.\n *\n * If the symbol already exists in the row, the coefficient\n * will be added to the existing coefficient. If the resulting\n * coefficient is zero, the symbol will be removed from the row.\n */\n Row.prototype.insertSymbol = function (symbol, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n var pair = this._cellMap.setDefault(symbol, function () { return 0.0; });\n if (nearZero(pair.second += coefficient)) {\n this._cellMap.erase(symbol);\n }\n };\n /**\n * Insert a row into this row with a given coefficient.\n *\n * The constant and the cells of the other row will be\n * multiplied by the coefficient and added to this row. Any\n * cell with a resulting coefficient of zero will be removed\n * from the row.\n */\n Row.prototype.insertRow = function (other, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n this._constant += other._constant * coefficient;\n var cells = other._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n };\n /**\n * Remove a symbol from the row.\n */\n Row.prototype.removeSymbol = function (symbol) {\n this._cellMap.erase(symbol);\n };\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n Row.prototype.reverseSign = function () {\n this._constant = -this._constant;\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n pair.second = -pair.second;\n }\n };\n /**\n * Solve the row for the given symbol.\n *\n * This method assumes the row is of the form\n * a * x + b * y + c = 0 and (assuming solve for x) will modify\n * the row to represent the right hand side of\n * x = -b/a * y - c / a. The target symbol will be removed from\n * the row, and the constant and other cells will be multiplied\n * by the negative inverse of the target coefficient.\n *\n * The given symbol *must* exist in the row.\n */\n Row.prototype.solveFor = function (symbol) {\n var cells = this._cellMap;\n var pair = cells.erase(symbol);\n var coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n cells.itemAt(i).second *= coeff;\n }\n };\n /**\n * Solve the row for the given symbols.\n *\n * This method assumes the row is of the form\n * x = b * y + c and will solve the row such that\n * y = x / b - c / b. The rhs symbol will be removed from the\n * row, the lhs added, and the result divided by the negative\n * inverse of the rhs coefficient.\n *\n * The lhs symbol *must not* exist in the row, and the rhs\n * symbol must* exist in the row.\n */\n Row.prototype.solveForEx = function (lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n };\n /**\n * Returns the coefficient for the given symbol.\n */\n Row.prototype.coefficientFor = function (symbol) {\n var pair = this._cellMap.find(symbol);\n return pair !== undefined ? pair.second : 0.0;\n };\n /**\n * Substitute a symbol with the data from another row.\n *\n * Given a row of the form a * x + b and a substitution of the\n * form x = 3 * y + c the row will be updated to reflect the\n * expression 3 * a * y + a * c + b.\n *\n * If the symbol does not exist in the row, this is a no-op.\n */\n Row.prototype.substitute = function (symbol, row) {\n var pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n };\n return Row;\n}());\n","/** @internal */\nexport const xSymbol = Symbol(\"xSymbol\");\n\n/** @internal */\nexport const ySymbol = Symbol(\"ySymbol\");\n\n/** @internal */\nexport const widthSymbol = Symbol(\"widthSymbol\");\n\n/** @internal */\nexport const heightSymbol = Symbol(\"heightSymbol\");\n\n/** @internal */\nexport const addUIElementSymbol = Symbol(\"addUIElementSymbol\");\n\n/** @internal */\nexport const removeUIElementSymbol = Symbol(\"removeUIElementSymbol\");\n\n/** @internal */\nexport const addUIConstraintSymbol = Symbol(\"addConstraintSymbol\");\n\n/** @internal */\nexport const removeUIConstraintSymbol = Symbol(\"removeUIConstraintSymbol\");\n\n/** @internal */\nexport const addConstraintSymbol = Symbol(\"addConstraintSymbol\");\n\n/** @internal */\nexport const removeConstraintSymbol = Symbol(\"removeConstraintSymbol\");\n\n/** @internal */\nexport const addVariableSymbol = Symbol(\"addVariableSymbol\");\n\n/** @internal */\nexport const removeVariableSymbol = Symbol(\"removeVariableSymbol\");\n\n/** @internal */\nexport const suggestVariableSymbol = Symbol(\"suggestVariableSymbol\");\n\n/** @internal */\nexport const disableConstraintSymbol = Symbol(\"disableConstraintSymbol\");\n\n/** @internal */\nexport const enableConstraintSymbol = Symbol(\"enableConstraintSymbol\");\n\n/** @internal */\nexport const needsRecalculation = Symbol(\"needsRecalculation\");\n\n/** @internal */\nexport const renderSymbol = Symbol(\"renderSymbol\");\n\n/** @internal */\nexport const clickSymbol = Symbol(\"clickSymbol\");\n\n/** @internal */\nexport const sortSymbol = Symbol(\"sortSymbol\");\n","/**\n * Defines the screen orientation states for UI constraints.\n * \n * This enum is used to specify when certain UI constraints should be active\n * based on the current device/screen orientation.\n */\nexport enum UIOrientation {\n /**\n * Indicates a landscape orientation (width > height).\n * Constraints using this value will only be active in landscape mode.\n */\n LANDSCAPE,\n \n /**\n * Indicates a portrait orientation (height > width).\n * Constraints using this value will only be active in portrait mode.\n */\n PORTRAIT,\n \n /**\n * Indicates that the constraint should always be active,\n * regardless of screen orientation.\n */\n ALWAYS,\n}\n\n/**\n * Type guard to check if a value is a valid UIOrientation.\n * \n * @param obj - The value to check\n * @returns True if the value is a valid UIOrientation enum value\n */\nexport function isUIOrientation(obj: unknown): obj is UIOrientation {\n return obj !== null && Object.values(UIOrientation).some((v) => v === obj);\n}\n\n/**\n * Resolves an optional orientation to a definite value.\n * \n * @param orientation - The orientation to resolve, or undefined\n * @returns The provided orientation, or ALWAYS if none was provided\n */\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","import type { UIAnchor } from \"../Elements/UIAnchor\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n addUIConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeUIConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\n/**\n * Abstract base class for all UI constraints in the system.\n *\n * Constraints control the layout of UI elements by establishing relationships\n * between their properties (position, size) and other elements or the screen.\n *\n * The constraint system uses Kiwi.js under the hood for solving the constraint system.\n * Each constraint adds specific rules to the solver that determine element positioning.\n */\nexport abstract class UIConstraint {\n /**\n * Optional identifier for the constraint.\n * Useful for debugging and identifying constraints.\n */\n public name = \"\";\n\n /**\n * Creates a new UI constraint.\n *\n * @param layer - The UI layer that will manage this constraint\n * @param elements - The set of UI elements affected by this constraint\n */\n constructor(\n public readonly layer: UILayer,\n elements: Set<UIElement | UIAnchor>,\n ) {\n this.layer[addUIConstraintSymbol](this, elements);\n }\n\n /**\n * Destroys the constraint, removing it from the layer and solver.\n * This should be called when the constraint is no longer needed.\n */\n public destroy(): void {\n this.layer[removeUIConstraintSymbol](this);\n }\n\n /**\n * Internal method called when the constraint should be disabled.\n * Typically called when the screen orientation changes and the\n * constraint is not applicable for the current orientation.\n *\n * @param orientation - The current UI orientation\n * @internal\n */\n public abstract [disableConstraintSymbol](orientation: UIOrientation): void;\n\n /**\n * Internal method called when the constraint should be enabled.\n * Typically called when the screen orientation changes and the\n * constraint becomes applicable for the current orientation.\n *\n * @param orientation - The current UI orientation\n * @internal\n */\n public abstract [enableConstraintSymbol](orientation: UIOrientation): void;\n}\n","import { Strength } from \"kiwi.js\";\n\n/**\n * Priority values for constraint strength calculation.\n * Higher values indicate stronger constraint enforcement.\n */\nconst HIGH_PRIORITY = 1000;\n/**\n * Medium priority value for constraint strength calculation.\n */\nconst MEDIUM_PRIORITY = 100;\n/**\n * Low priority value for constraint strength calculation.\n */\nconst LOW_PRIORITY = 10;\n\n/**\n * Defines the strength/priority levels for UI constraints.\n * \n * Constraints with higher power (lower index) take precedence over\n * those with lower power when the constraint solver can't satisfy all constraints.\n * \n * The enum values map to different strength configurations in the Kiwi.js solver:\n * - P0: Highest priority, \"required\" constraint that must be satisfied\n * - P1-P7: Decreasing levels of priority\n */\nexport enum UIConstraintPower {\n /** Highest priority - must be satisfied (required constraint) */\n P0,\n /** Very high priority */\n P1,\n /** High priority */\n P2,\n /** Medium-high priority */\n P3,\n /** Medium priority */\n P4,\n /** Medium-low priority */\n P5,\n /** Low priority */\n P6,\n /** Lowest priority */\n P7,\n}\n\n/**\n * Type guard to check if a value is a valid UIConstraintPower.\n * \n * @param obj - The value to check\n * @returns True if the value is a valid UIConstraintPower enum value\n */\nexport function isUIConstraintPower(obj: unknown): obj is UIConstraintPower {\n return (\n obj !== null && Object.values(UIConstraintPower).some((v) => v === obj)\n );\n}\n\n/**\n * Resolves an optional power level to a definite value.\n * \n * @param power - The constraint power to resolve, or undefined\n * @returns The provided power level, or P0 (highest) if none was provided\n */\nexport function resolvePower(power?: UIConstraintPower): UIConstraintPower {\n return power ?? UIConstraintPower.P0;\n}\n\n/**\n * Converts a UIConstraintPower enum value to a Kiwi.js strength value.\n * \n * The Kiwi.js constraint solver uses a three-tiered strength system.\n * This function maps our power levels to appropriate strength values:\n * \n * - P0: Maximum strength in all tiers (required constraint)\n * - P1-P2: Varying strengths in the first tier\n * - P3-P4: Varying strengths in the second tier\n * - P5-P7: Varying strengths in the third tier\n * \n * @param power - The constraint power to convert, or undefined\n * @returns A Kiwi.js strength value corresponding to the power level\n */\nexport function convertPowerToStrength(power?: UIConstraintPower): number {\n switch (power) {\n case UIConstraintPower.P0:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIConstraintPower.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIConstraintPower.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIConstraintPower.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIConstraintPower.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIConstraintPower.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIConstraintPower.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIConstraintPower.P7:\n return Strength.create(0, 0, 1);\n default:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n }\n}\n","import { Operator } from \"kiwi.js\";\n\n/**\n * Defines the type of relationship between values in a constraint.\n * \n * Maps directly to Kiwi.js Operators for the constraint solver.\n * Used to specify whether values should be equal, less than, or greater than each other.\n */\nexport enum UIConstraintRule {\n /**\n * Values must be equal (x = y).\n * Creates an equality constraint in the solver.\n */\n EQUAL = Operator.Eq,\n \n /**\n * Left value must be less than or equal to right value (x ≤ y).\n * Creates an inequality constraint in the solver.\n */\n LESS = Operator.Le,\n \n /**\n * Left value must be greater than or equal to right value (x ≥ y).\n * Creates an inequality constraint in the solver.\n */\n GREATER = Operator.Ge,\n}\n\n/**\n * Type guard to check if a value is a valid UIConstraintRule.\n * \n * @param obj - The value to check\n * @returns True if the value is a valid UIConstraintRule enum value\n */\nexport function isUIConstraintRule(obj: unknown): obj is UIConstraintRule {\n return obj !== null && Object.values(UIConstraintRule).some((v) => v === obj);\n}\n\n/**\n * Resolves an optional rule to a definite value.\n * \n * @param rule - The constraint rule to resolve, or undefined\n * @returns The provided rule, or EQUAL if none was provided\n */\nexport function resolveRule(rule?: UIConstraintRule): UIConstraintRule {\n return rule ?? UIConstraintRule.EQUAL;\n}\n\n/**\n * Converts a UIConstraintRule to the corresponding Kiwi.js Operator.\n * This function provides a safe way to convert between our enum and Kiwi's enum.\n * \n * @param rule - The constraint rule to convert, or undefined\n * @returns The corresponding Kiwi.js Operator value\n */\nexport function convertRuleToOperator(rule?: UIConstraintRule): Operator {\n switch (rule) {\n case UIConstraintRule.EQUAL:\n return Operator.Eq;\n case UIConstraintRule.LESS:\n return Operator.Le;\n case UIConstraintRule.GREATER:\n return Operator.Ge;\n default:\n return Operator.Eq;\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for height constraints.\n */\nexport interface UIHeightOptions {\n /** The fixed height value to constrain the element to */\n height: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific height for a UI element.\n *\n * This constraint can be configured to require an exact height\n * or set minimum/maximum height limits using different rules.\n */\nexport class UIHeightConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly options: UIHeightOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new height constraint.\n *\n * @param element - The UI element to constrain\n * @param options - Configuration options\n */\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIHeightOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n height: options?.height ?? element.height,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the height constraint to the constraint solver.\n *\n * Creates a constraint that enforces the element's height based\n * on the specified rule (equal to, less than, or greater than).\n *\n */\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[heightSymbol]),\n convertRuleToOperator(this.options.rule),\n this.options.height,\n convertPowerToStrength(this.options.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the height constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","/**\n * Default priority value for event listeners.\n * Lower values indicate higher priority.\n */\nconst DEFAULT_PRIORITY = 100;\n/**\n * A priority-based event emitter implementation.\n * The name \"Eventail\" is a combination of \"event\" + \"tail\", reflecting its queue-like nature.\n *\n * Features:\n * - Priority-based event listeners\n * - Context binding support\n * - One-time event listeners\n * - Type-safe event handling\n *\n * @example\n * ```typescript\n * const emitter = new Eventail();\n *\n * // Regular event listener\n * emitter.on('event', (data) => console.log(data));\n *\n * // One-time event listener with high priority\n * emitter.once('event', callback, context, 50);\n *\n * // Remove specific listener\n * emitter.off('event', callback);\n * ```\n */\nclass Eventail {\n constructor() {\n /** Map storing event listeners for each event type */\n this.listeners = new Map();\n }\n /**\n * Adds an event listener for the specified event type.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.on('data', (value) => console.log(value));\n * emitter.on('error', handleError, this, 50);\n * ```\n */\n on(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, false);\n return this;\n }\n /**\n * Adds a one-time event listener that will be removed after first execution.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.once('init', () => console.log('Initialized'));\n * ```\n */\n once(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, true);\n return this;\n }\n /**\n * Removes event listener(s) from the specified event type.\n *\n * @param type - The event type to remove listener(s) from\n * @param callback - Optional callback to remove specific listener\n * @param context - Optional context to match when removing\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * // Remove all listeners for 'data' event\n * emitter.off('data');\n *\n * // Remove specific listener\n * emitter.off('data', callback);\n *\n * // Remove listener with specific context\n * emitter.off('data', callback, context);\n * ```\n */\n off(type, callback, context) {\n const current = this.listeners.get(type);\n if (!current) {\n return this;\n }\n if (!callback) {\n this.listeners.delete(type);\n return this;\n }\n const filtered = current.filter((l) => l.callback !== callback ||\n (context !== undefined && l.context !== context));\n filtered.length\n ? this.listeners.set(type, filtered)\n : this.listeners.delete(type);\n return this;\n }\n /**\n * Emits an event, triggering all registered listeners in priority order.\n * Protected method to allow extension in derived classes.\n *\n * @param type - The event type to emit\n * @param args - Arguments to pass to the listeners\n * @returns Boolean indicating if the event had listeners\n *\n * @example\n * ```typescript\n * class MyEmitter extends Eventail {\n * public trigger(type: string, ...args: unknown[]) {\n * return this.emit(type, ...args);\n * }\n * }\n * ```\n */\n emit(type, ...args) {\n const current = this.listeners.get(type);\n if (!(current === null || current === void 0 ? void 0 : current.length)) {\n return false;\n }\n for (const listener of [...current]) {\n listener.callback.apply(listener.context, args);\n if (listener.once) {\n this.off(type, listener.callback, listener.context);\n }\n }\n return true;\n }\n /**\n * Internal method to add a new event listener with the specified configuration.\n * Maintains priority order and prevents duplicate listeners.\n *\n * @param type - Event type\n * @param callback - Event callback\n * @param context - Callback context\n * @param priority - Event priority\n * @param once - Whether it's a one-time listener\n * @throws {Error} If the listener already exists\n */\n addListener(type, callback, context, priority, once) {\n let list = this.listeners.get(type);\n if (!list) {\n list = [];\n this.listeners.set(type, list);\n }\n if (list.some((l) => l.callback === callback && l.context === context)) {\n throw new Error(\"Event listener already exists\");\n }\n const event = { callback, context, priority, once };\n let i = 0;\n while (i < list.length && list[i].priority <= priority) {\n i++;\n }\n list.splice(i, 0, event);\n }\n}\n\nexport { DEFAULT_PRIORITY, Eventail };\n//# sourceMappingURL=index.js.map\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { Object3D, WebGLRenderer } from \"three\";\nimport { MathUtils } from \"three\";\nimport {\n convertPowerToStrength,\n UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n addUIElementSymbol,\n addVariableSymbol,\n needsRecalculation,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n sortSymbol,\n suggestVariableSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\n\nexport abstract class UIAnchor extends Eventail {\n /** X position variable for constraint system */\n public [xSymbol] = new Variable(\"x\");\n\n /** Y position variable for constraint system */\n public [ySymbol] = new Variable(\"y\");\n\n /** Flag indicating whether the element needs recalculation */\n public [needsRecalculation] = false;\n\n /** Unique identifier for the element */\n public name = MathUtils.generateUUID();\n\n /**\n * Creates a new UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param x - Initial x position\n * @param y - Initial y position\n */\n constructor(\n public readonly layer: UILayer,\n x: number,\n y: number,\n protected readonly object?: Object3D,\n ) {\n super();\n\n if (this.object) {\n this.object.matrixAutoUpdate = false;\n }\n\n this.layer[addUIElementSymbol](this, object);\n\n this.layer[addVariableSymbol](\n this,\n this[xSymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[ySymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n\n this[xSymbol].setValue(x);\n this[ySymbol].setValue(y);\n\n this.layer[suggestVariableSymbol](this, this[xSymbol], x);\n this.layer[suggestVariableSymbol](this, this[ySymbol], y);\n }\n\n /** Gets the current x position of the anchor */\n public get x(): number {\n return this[xSymbol].value();\n }\n\n /** Gets the current y position of the anchor */\n public get y(): number {\n return this[ySymbol].value();\n }\n\n /** Gets the current z-index (depth) of the element */\n public get zIndex(): number {\n return this.object?.position.z ?? 0;\n }\n\n /** Gets whether the element needs recalculation */\n protected get needsRecalculation(): boolean {\n return this[needsRecalculation];\n }\n\n /**\n * Sets the x position of the element\n * @param value - New x position\n */\n public set x(value: number) {\n this.layer[suggestVariableSymbol](this, this[xSymbol], value);\n }\n\n /**\n * Sets the y position of the element\n * @param value - New y position\n */\n public set y(value: number) {\n this.layer[suggestVariableSymbol](this, this[ySymbol], value);\n }\n\n /**\n * Sets the z-index (depth) of the element\n * @param value - New z-index\n */\n public set zIndex(value: number) {\n if (this.object && this.object.renderOrder !== value) {\n this.object.position.z = value;\n this.object.renderOrder = value;\n this.layer[sortSymbol]();\n this.object.updateMatrix();\n }\n }\n\n /**\n * Destroys the anchor, cleaning up all resources and removing it from the layer.\n * This should be called when the anchor is no longer needed.\n */\n public destroy(): void {\n this.layer[removeVariableSymbol](this, this[ySymbol]);\n this.layer[removeVariableSymbol](this, this[xSymbol]);\n this.layer[removeUIElementSymbol](this);\n }\n\n /**\n * Internal method called by the rendering system to render this element.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n * @internal\n */\n public [renderSymbol](renderer: WebGLRenderer, deltaTime: number): void {\n this.render(renderer, deltaTime);\n }\n\n /**\n * Applies transformations to the underlying Three.js object.\n * This is called when the element's position, size, or other properties change.\n */\n protected applyTransformations(): void {\n if (this[needsRecalculation]) {\n if (this.object) {\n this.object.updateMatrix();\n }\n this[needsRecalculation] = false;\n }\n }\n\n /**\n * Renders the element.\n * This must be implemented by concrete subclasses.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n */\n protected abstract render(renderer: WebGLRenderer, deltaTime: number): void;\n}\n","import { Box2, Vector2 } from \"three\";\n\nconst tempVector2 = new Vector2();\nconst tempBox2 = new Box2();\n\nexport function testElement(\n elementX: number,\n elementY: number,\n elementWidth: number,\n elementHeight: number,\n xClick: number,\n yClick: number,\n): boolean {\n tempVector2.set(xClick, yClick);\n\n tempBox2.min.set(elementX, elementY);\n tempBox2.max.set(elementWidth, elementHeight).add(tempBox2.min);\n return tempBox2.containsPoint(tempVector2);\n}\n","import { Matrix3, Vector3, type Object3D } from \"three\";\nimport type { UIMicroInternal } from \"./UIMicro\";\n\nconst tempMatrixA = new Matrix3();\nconst tempMatrixB = new Matrix3();\nconst tempMatrixC = new Matrix3();\nconst tempMatrixD = new Matrix3();\nconst tempMatrixE = new Matrix3();\nconst tempVectorA = new Vector3();\n\nexport function applyMicroTransformations(\n object: Object3D,\n micro: UIMicroInternal,\n x: number,\n y: number,\n width: number,\n height: number,\n padding: number,\n): void {\n const realX = x - padding;\n const realY = y - padding;\n const realWidth = width + padding * 2;\n const realHeight = height + padding * 2;\n\n const anchorOffsetX = realWidth * micro.anchorX;\n const anchorOffsetY = realHeight * micro.anchorY;\n const centerX = realX + anchorOffsetX;\n const centerY = realY + anchorOffsetY;\n\n const translateToCenter = tempMatrixA.set(\n 1,\n 0,\n -centerX,\n 0,\n 1,\n -centerY,\n 0,\n 0,\n 1,\n );\n\n const scale = tempMatrixB.set(\n micro.scaleX,\n 0,\n 0,\n 0,\n micro.scaleY,\n 0,\n 0,\n 0,\n 1,\n );\n\n const rotation = tempMatrixC.set(\n Math.cos(micro.rotation),\n -Math.sin(micro.rotation),\n 0,\n Math.sin(micro.rotation),\n Math.cos(micro.rotation),\n 0,\n 0,\n 0,\n 1,\n );\n\n const translateFinal = tempMatrixD.set(\n 1,\n 0,\n micro.x + centerX,\n 0,\n 1,\n micro.y + centerY,\n 0,\n 0,\n 1,\n );\n\n const finalMatrix = tempMatrixE\n .multiplyMatrices(translateFinal, rotation)\n .multiply(scale)\n .multiply(translateToCenter);\n\n const point = tempVectorA.set(realX, realY, 1).applyMatrix3(finalMatrix);\n\n object.position.x = point.x;\n object.position.y = point.y;\n object.rotation.z = micro.rotation;\n object.scale.x = realWidth * micro.scaleX;\n object.scale.y = realHeight * micro.scaleY;\n}\n","import { MathUtils } from \"three\";\nimport type { UIElement } from \"../Elements/UIElement\";\n\n/**\n * Default position offset value (0)\n */\nconst DEFAULT_POSITION = 0;\n/**\n * Default anchor point value (0.5 = centered)\n */\nconst DEFAULT_ANCHOR = 0.5;\n/**\n * Default scale value (1 = no scaling)\n */\nconst DEFAULT_SCALE = 1;\n/**\n * Default rotation value in radians (0 = no rotation)\n */\nconst DEFAULT_ROTATION = 0;\n\n/**\n * Internal implementation of micro-transformations for UI elements.\n * Stores the raw transformation values and recalculation flag.\n *\n */\nexport class UIMicroInternal {\n /** X-axis offset from element position */\n public x = DEFAULT_POSITION;\n /** Y-axis offset from element position */\n public y = DEFAULT_POSITION;\n /** X-axis anchor point (0-1) where transformations are applied */\n public anchorX = DEFAULT_ANCHOR;\n /** Y-axis anchor point (0-1) where transformations are applied */\n public anchorY = DEFAULT_ANCHOR;\n /** X-axis scaling factor */\n public scaleX = DEFAULT_SCALE;\n /** Y-axis scaling factor */\n public scaleY = DEFAULT_SCALE;\n /** Rotation in radians */\n public rotation = DEFAULT_ROTATION;\n /** Flag indicating whether transformations need to be recalculated */\n public needsRecalculation = false;\n}\n\n/**\n * Provides fine-grained transformations for UI elements.\n *\n * Micro-transformations allow for detailed positioning, scaling, and rotation\n * adjustments relative to an element's base position and dimensions.\n * These transformations are applied on top of the standard element positioning\n * and can be used for effects like pivoting, offsetting, and animation.\n */\nexport class UIMicro {\n /**\n * Creates a new micro-transformation interface.\n *\n * @param raw - The internal state object that stores transformation values\n * @param owner - The UI element that owns these transformations\n */\n constructor(\n private readonly raw: UIMicroInternal,\n private readonly owner: UIElement,\n ) {}\n\n /**\n * Gets the X-axis offset from the element's position.\n */\n public get x(): number {\n return this.raw.x;\n }\n\n /**\n * Gets the Y-axis offset from the element's position.\n */\n public get y(): number {\n return this.raw.y;\n }\n\n /**\n * Gets the X-axis anchor point (0-1) where transformations are applied.\n *\n * - 0.0 = left edge\n * - 0.5 = center (default)\n * - 1.0 = right edge\n */\n public get anchorX(): number {\n return this.raw.anchorX;\n }\n\n /**\n * Gets the Y-axis anchor point (0-1) where transformations are applied.\n *\n * - 0.0 = top edge\n * - 0.5 = center (default)\n * - 1.0 = bottom edge\n */\n public get anchorY(): number {\n return this.raw.anchorY;\n }\n\n /**\n * Gets the X-axis scaling factor.\n *\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public get scaleX(): number {\n return this.raw.scaleX;\n }\n\n /**\n * Gets the Y-axis scaling factor.\n *\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public get scaleY(): number {\n return this.raw.scaleY;\n }\n\n /**\n * Gets the rotation in degrees.\n * Converted from the internal radians value.\n */\n public get angle(): number {\n return MathUtils.radToDeg(this.raw.rotation);\n }\n\n /**\n * Gets the rotation in radians.\n */\n public get rotation(): number {\n return this.raw.rotation;\n }\n\n /**\n * Sets the X-axis offset from the element's position.\n *\n * @param value - X offset in pixels\n */\n public set x(value: number) {\n if (value !== this.raw.x) {\n this.raw.x = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the Y-axis offset from the element's position.\n *\n * @param value - Y offset in pixels\n */\n public set y(value: number) {\n if (value !== this.raw.y) {\n this.raw.y = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the X-axis anchor point where transformations are applied.\n *\n * @param value - X anchor (0-1):\n * - 0.0 = left edge\n * - 0.5 = center (default)\n * - 1.0 = right edge\n */\n public set anchorX(value: number) {\n if (value !== this.raw.anchorX) {\n this.raw.anchorX = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the Y-axis anchor point where transformations are applied.\n *\n * @param value - Y anchor (0-1):\n * - 0.0 = top edge\n * - 0.5 = center (default)\n * - 1.0 = bottom edge\n */\n public set anchorY(value: number) {\n if (value !== this.raw.anchorY) {\n this.raw.anchorY = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the X-axis scaling factor.\n *\n * @param value - X scale factor:\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public set scaleX(value: number) {\n if (value !== this.raw.scaleX) {\n this.raw.scaleX = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the Y-axis scaling factor.\n *\n * @param value - Y scale factor:\n * - 1.0 = normal size (default)\n * - > 1.0 = enlarged\n * - < 1.0 = reduced\n */\n public set scaleY(value: number) {\n if (value !== this.raw.scaleY) {\n this.raw.scaleY = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the rotation in degrees.\n * Automatically converts to radians for internal storage.\n *\n * @param value - Rotation angle in degrees\n */\n public set angle(value: number) {\n const convertedValue = MathUtils.degToRad(value);\n if (convertedValue !== this.raw.rotation) {\n this.raw.rotation = convertedValue;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the rotation in radians.\n *\n * @param value - Rotation angle in radians\n */\n public set rotation(value: number) {\n if (value !== this.raw.rotation) {\n this.raw.rotation = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Sets the anchor point based on global coordinates relative to the element.\n * Converts the global position to a normalized anchor point (0-1 range).\n *\n * This is useful for setting the pivot point to a specific position,\n * such as making an element rotate around a particular point.\n *\n * @param x - Global X coordinate to set as anchor\n * @param y - Global Y coordinate to set as anchor\n */\n public setAnchorByGlobalPosition(x: number, y: number): void {\n const deltaX = x - this.owner.x;\n const deltaY = y - this.owner.y;\n const newAnchorX = deltaX / this.owner.width;\n const newAnchorY = deltaY / this.owner.height;\n\n if (newAnchorX !== this.raw.anchorX || newAnchorY !== this.raw.anchorY) {\n this.raw.anchorX = newAnchorX;\n this.raw.anchorY = newAnchorY;\n this.raw.needsRecalculation = true;\n }\n }\n\n /**\n * Resets all micro-transformations to their default values.\n *\n * Default values:\n * - Position (x, y): 0\n * - Anchor (anchorX, anchorY): 0.5 (centered)\n * - Scale (scaleX, scaleY): 1.0 (original size)\n * - Rotation: 0 (no rotation)\n *\n * Only triggers recalculation if any values were changed.\n */\n public reset(): void {\n if (\n this.raw.x !== DEFAULT_POSITION ||\n this.raw.y !== DEFAULT_POSITION ||\n this.raw.anchorX !== DEFAULT_ANCHOR ||\n this.raw.anchorY !== DEFAULT_ANCHOR ||\n this.raw.scaleX !== DEFAULT_SCALE ||\n this.raw.scaleY !== DEFAULT_SCALE ||\n this.raw.rotation !== DEFAULT_ROTATION\n ) {\n this.raw.x = DEFAULT_POSITION;\n this.raw.y = DEFAULT_POSITION;\n this.raw.anchorX = DEFAULT_ANCHOR;\n this.raw.anchorY = DEFAULT_ANCHOR;\n this.raw.scaleX = DEFAULT_SCALE;\n this.raw.scaleY = DEFAULT_SCALE;\n this.raw.rotation = DEFAULT_ROTATION;\n this.raw.needsRecalculation = true;\n }\n }\n}\n","/**\n * Defines the visibility and interactivity state of UI elements.\n * \n * UI elements can be in one of three states:\n * - Hidden: Element is not visible and does not receive input\n * - Visible: Element is visible but does not receive input\n * - Interactive: Element is visible and can receive input events\n */\nexport enum UIMode {\n /**\n * Element is not rendered and does not receive input events.\n * Equivalent to setting `display: none` in CSS.\n */\n HIDDEN,\n\n /**\n * Element is rendered but does not receive input events.\n * Equivalent to setting `pointer-events: none` in CSS.\n */\n VISIBLE,\n\n /**\n * Element is rendered and can receive input events.\n * This is the fully active state for UI elements.\n */\n INTERACTIVE,\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial } from \"three\";\n\nexport class UIMaterial extends ShaderMaterial {\n constructor(map?: Texture) {\n super({\n uniforms: {\n map: { value: map },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\n },\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\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 `,\n transparent: true,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: false,\n });\n }\n\n public getTexture(): Texture | undefined {\n return this.uniforms.map.value;\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public setTexture(value: Texture | undefined): void {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setOpacity(value: number): void {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n}\n","import { PlaneGeometry } from \"three\";\n\nconst GEOMETRY_SIZE = 1;\nconst GEOMETRY_OFFSET = 0.5;\n\nexport const geometry = new PlaneGeometry(\n GEOMETRY_SIZE,\n GEOMETRY_SIZE,\n).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);\n","import type { Material, WebGLRenderer } from \"three\";\nimport { Mesh, OrthographicCamera, Scene } from \"three\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\n\n/**\n * Shared scene and mesh used by all UIFullScreenQuad instances\n * This optimization avoids creating multiple meshes for rendering quads\n */\nconst scene = new Scene();\nconst mesh = new Mesh(geometry);\nscene.add(mesh);\n\n/**\n * Utility class for rendering a full-screen quad with optional padding\n * Used by the UI composition system to render passes\n */\nexport class UIFullScreenQuad {\n /**\n * Orthographic camera configured for device coordinates\n * Adjusted when padding changes to ensure correct rendering with padding\n */\n private readonly camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n /**\n * Creates a new UIFullScreenQuad\n *\n * @param paddingHorizontalInternal - Initial horizontal padding\n * @param paddingVerticalInternal - Initial vertical padding\n */\n constructor(\n private paddingHorizontalInternal = 0,\n private paddingVerticalInternal = 0,\n ) {\n this.updateCameraTransform();\n }\n\n /**\n * Gets the current horizontal padding\n */\n public get paddingHorizontal(): number {\n return this.paddingHorizontalInternal;\n }\n\n /**\n * Gets the current vertical padding\n */\n public get paddingVertical(): number {\n return this.paddingVerticalInternal;\n }\n\n /**\n * Sets the horizontal padding\n * Updates the camera projection when changed\n */\n public set paddingHorizontal(value: number) {\n if (this.paddingHorizontalInternal !== value) {\n this.paddingHorizontalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n /**\n * Sets the vertical padding\n * Updates the camera projection when changed\n */\n public set paddingVertical(value: number) {\n if (this.paddingVerticalInternal !== value) {\n this.paddingVerticalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n /**\n * Renders the fullscreen quad with the provided material\n *\n * @param renderer - The WebGL renderer to use\n * @param material - The material to apply to the fullscreen quad\n */\n public render(renderer: WebGLRenderer, material: Material): void {\n mesh.material = material;\n renderer.render(scene, this.camera);\n }\n\n /**\n * Updates the camera projection matrix to account for padding\n * Expands the camera frustum to include the padded area\n */\n private updateCameraTransform(): void {\n this.camera.left = -this.paddingHorizontalInternal;\n this.camera.right = 1 + this.paddingHorizontalInternal;\n this.camera.bottom = -this.paddingVerticalInternal;\n this.camera.top = 1 + this.paddingVerticalInternal;\n this.camera.updateProjectionMatrix();\n }\n}\n","import type { Material, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n NoBlending,\n RGBAFormat,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { UIFullScreenQuad } from \"./UIFullScreenQuad\";\nimport type { UIPass } from \"./UIPass\";\n\n/**\n * UI composition system for applying post-processing effects to rendered UI\n * The system manages render targets and passes to create complex visual effects\n */\n\n/**\n * Internal implementation of the UI composition system\n * Handles the actual rendering and composition of passes\n */\nexport class UIComposerInternal {\n /** Collection of all registered composition passes */\n public readonly passes: UIPass[] = [];\n\n /** Source render target used during ping-pong rendering */\n private fromRenderTarget: WebGLRenderTarget;\n /** Destination render target used during ping-pong rendering */\n private toRenderTarget: WebGLRenderTarget;\n\n /** Default material used to render the final result */\n private readonly defaultMaterial = new UIMaterial();\n /** Full-screen quad used for rendering */\n private readonly screen = new UIFullScreenQuad();\n\n /** Whether the composition needs to be updated */\n private needsUpdateInternal = false;\n /** Whether the padding has changed since last frame */\n private paddingHasChangedInternal = false;\n /** Current padding value in pixels */\n private paddingInternal = 0;\n\n /**\n * Creates a new UI composer with initial render targets\n */\n constructor() {\n const parameters = {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: false,\n stencilBuffer: false,\n };\n this.fromRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n this.toRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n this.fromRenderTarget.texture.generateMipmaps = false;\n this.toRenderTarget.texture.generateMipmaps = false;\n }\n\n /**\n * Whether the composition needs to be updated in the next frame\n * True when either the composer or any valuable passes need update\n */\n public get needsUpdate(): boolean {\n return (\n (this.needsUpdateInternal && this.hasValuablePasses()) ||\n this.hasPassesNeedingUpdate()\n );\n }\n\n /**\n * Whether the padding has changed since the last frame\n * Used to trigger layout updates when padding changes\n */\n public get paddingHasChanged(): boolean {\n return this.paddingHasChangedInternal;\n }\n\n /**\n * Current padding in pixels used for the composition\n * Calculated as the maximum padding required by all passes\n */\n public get padding(): number {\n return this.paddingInternal;\n }\n\n /**\n * Requests an update for the next frame\n * Will trigger a re-composition of all passes\n */\n public requestUpdate(): void {\n this.needsUpdateInternal = true;\n }\n\n /**\n * Composes all registered passes to create the final result\n * \n * @param renderer - WebGL renderer to use for composition\n * @param width - Width of the render target in pixels\n * @param height - Height of the render target in pixels\n * @param material - Input material containing the initial texture\n * @param canOverrideBlending - Whether blending can be overridden on the input material\n * @returns Material to use for rendering the composed result\n */\n public compose(\n renderer: WebGLRenderer,\n width: number,\n height: number,\n material: Material,\n canOverrideBlending = true,\n ): Material {\n const hasValuablePasses = this.hasValuablePasses();\n if (\n (!this.needsUpdateInternal || !hasValuablePasses) &&\n !this.hasPassesNeedingUpdate()\n ) {\n if (!hasValuablePasses) {\n this.paddingHasChangedInternal = this.paddingInternal !== 0;\n this.paddingInternal = 0;\n }\n this.needsUpdateInternal = false;\n return hasValuablePasses ? this.defaultMaterial : material;\n }\n\n const padding = this.calculatePadding();\n this.paddingHasChangedInternal = this.paddingInternal !== padding;\n this.paddingInternal = padding;\n\n const widthWithPadding = width + padding * 2;\n const heightWithPadding = height + padding * 2;\n\n this.fromRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.toRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.setScreenPadding(width, height, padding);\n\n renderer.setClearColor(0x000000, 0);\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n\n const originalBlending = material.blending;\n if (canOverrideBlending) {\n material.blending = NoBlending;\n }\n this.screen.render(renderer, material);\n material.blending = originalBlending;\n\n const options = { width, height, padding };\n\n for (let i = 0; i < this.passes.length; i++) {\n const pass = this.passes[i];\n if (pass.needsUpdate || pass.isValuable) {\n this.reverseRenderTargets();\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n this.passes[i].render(renderer, this.fromRenderTarget.texture, options);\n }\n }\n\n this.needsUpdateInternal = false;\n this.defaultMaterial.setTexture(this.toRenderTarget.texture);\n return this.defaultMaterial;\n }\n\n /**\n * Cleans up resources used by the composer\n * Should be called when the composer is no longer needed\n */\n public destroy(): void {\n this.fromRenderTarget.dispose();\n this.toRenderTarget.dispose();\n }\n\n /**\n * Checks if any passes are valuable (contribute meaningful effects)\n * @returns True if at least one pass is valuable\n */\n private hasValuablePasses(): boolean {\n return this.passes.some((p) => p.isValuable);\n }\n\n /**\n * Checks if any passes need an update\n * @returns True if at least one pass needs update\n */\n private hasPassesNeedingUpdate(): boolean {\n return this.passes.some((p) => p.needsUpdate);\n }\n\n /**\n * Calculates the maximum padding required by all passes\n * @returns Maximum padding value in pixels\n */\n private calculatePadding(): number {\n return this.passes.reduce((a, p) => Math.max(a, p.padding), 0);\n }\n\n /**\n * Updates the screen quad's padding based on dimensions\n * \n * @param width - Width of the render target in pixels\n * @param height - Height of the render target in pixels\n * @param padding - Padding value in pixels\n */\n private setScreenPadding(\n width: number,\n height: number,\n padding: number,\n ): void {\n this.screen.paddingHorizontal = padding / width;\n this.screen.paddingVertical = padding / height;\n }\n\n /**\n * Swaps the from and to render targets\n * Used for ping-pong rendering between passes\n */\n private reverseRenderTargets(): void {\n const fromRenderTarget = this.fromRenderTarget;\n this.fromRenderTarget = this.toRenderTarget;\n this.toRenderTarget = fromRenderTarget;\n }\n}\n\n/**\n * Public interface for the UI composition system\n * Provides a simplified API for managing UI passes\n */\nexport class UIComposer {\n /**\n * Creates a new UI composer\n * \n * @param raw - Internal implementation that handles actual rendering\n */\n constructor(private readonly raw: UIComposerInternal) {}\n\n /**\n * Collection of all registered composition passes\n * Add passes to this collection to apply effects to the UI\n */\n public get passes(): UIPass[] {\n return this.raw.passes;\n }\n}\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { WebGLRenderer } from \"three\";\nimport { MathUtils, type Object3D } from \"three\";\nimport {\n convertPowerToStrength,\n UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { testElement } from \"../Miscellaneous/math\";\nimport { applyMicroTransformations } from \"../Miscellaneous/microTransformationTools\";\nimport {\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n heightSymbol,\n needsRecalculation,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n sortSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIMicro, UIMicroInternal } from \"../Miscellaneous/UIMicro\";\nimport { UIMode } from \"../Miscellaneous/UIMode\";\nimport { UIComposer, UIComposerInternal } from \"../Passes/UIComposer\";\n\n/**\n * Events that can be emitted by UI elements.\n */\nexport enum UIElementEvent {\n /** Triggered when an interactive element is clicked */\n CLICK = \"click\",\n}\n\n/**\n * Abstract base class for all UI elements in the system.\n * Provides core functionality for positioning, sizing, and rendering UI elements.\n *\n * Each UI element has:\n * - Position (x, y) and size (width, height) variables\n * - Layer management integration\n * - Event handling capabilities\n * - Micro transformations support\n * - Rendering capabilities\n */\nexport abstract class UIElement extends Eventail {\n /** X position variable for constraint system */\n public [xSymbol] = new Variable(\"x\");\n\n /** Y position variable for constraint system */\n public [ySymbol] = new Variable(\"y\");\n\n /** Width variable for constraint system */\n public [widthSymbol] = new Variable(\"width\");\n\n /** Height variable for constraint system */\n public [heightSymbol] = new Variable(\"height\");\n\n /** Flag indicating whether the element needs recalculation */\n public [needsRecalculation] = false;\n\n /** Unique identifier for the element */\n public name = MathUtils.generateUUID();\n\n /** Micro transformation interface for the element */\n public readonly micro: UIMicro;\n\n /** Composer interface for the element */\n public readonly composer: UIComposer;\n\n /** Internal micro transformation implementation */\n protected readonly microInternal = new UIMicroInternal();\n\n /** Internal composer implementation */\n protected readonly composerInternal = new UIComposerInternal();\n\n /** Current visibility/interactivity mode */\n protected modeInternal = UIMode.VISIBLE;\n\n /**\n * Creates a new UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param object - The Three.js object that represents this element\n * @param x - Initial x position\n * @param y - Initial y position\n * @param width - Initial width\n * @param height - Initial height\n */\n constructor(\n public readonly layer: UILayer,\n protected readonly object: Object3D,\n x: number,\n y: number,\n width: number,\n height: number,\n ) {\n super();\n this.micro = new UIMicro(this.microInternal, this);\n this.composer = new UIComposer(this.composerInternal);\n\n this.object.matrixAutoUpdate = false;\n\n this.layer[addUIElementSymbol](this, this.object);\n\n this.layer[addVariableSymbol](\n this,\n this[xSymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[ySymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[widthSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n this.layer[addVariableSymbol](\n this,\n this[heightSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n\n this[xSymbol].setValue(x);\n this[ySymbol].setValue(y);\n this[widthSymbol].setValue(width);\n this[heightSymbol].setValue(height);\n\n this.layer[suggestVariableSymbol](this, this[xSymbol], x);\n this.layer[suggestVariableSymbol](this, this[ySymbol], y);\n this.layer[suggestVariableSymbol](this, this[widthSymbol], width);\n this.layer[suggestVariableSymbol](this, this[heightSymbol], height);\n }\n\n /** Gets the current x position of the element */\n public get x(): number {\n return this[xSymbol].value();\n }\n\n /** Gets the current y position of the element */\n public get y(): number {\n return this[ySymbol].value();\n }\n\n /** Gets the current width of the element */\n public get width(): number {\n return this[widthSymbol].value();\n }\n\n /** Gets the current height of the element */\n public get height(): number {\n return this[heightSymbol].value();\n }\n\n /** Gets the current z-index (depth) of the element */\n public get zIndex(): number {\n return this.object.position.z;\n }\n\n /** Gets the current visibility/interactivity mode of the element */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /** Gets whether the element needs recalculation */\n protected get needsRecalculation(): boolean {\n return this[needsRecalculation];\n }\n\n /**\n * Sets the x position of the element\n * @param value - New x position\n */\n public set x(value: number) {\n this.layer[suggestVariableSymbol](this, this[xSymbol], value);\n }\n\n /**\n * Sets the y position of the element\n * @param value - New y position\n */\n public set y(value: number) {\n this.layer[suggestVariableSymbol](this, this[ySymbol], value);\n }\n\n /**\n * Sets the width of the element\n * @param value - New width\n */\n public set width(value: number) {\n this.layer[suggestVariableSymbol](this, this[widthSymbol], value);\n }\n\n /**\n * Sets the height of the element\n * @param value - New height\n */\n public set height(value: number) {\n this.layer[suggestVariableSymbol](this, this[heightSymbol], value);\n }\n\n /**\n * Sets the z-index (depth) of the element\n * @param value - New z-index\n */\n public set zIndex(value: number) {\n if (this.object.renderOrder !== value) {\n this.object.position.z = value;\n this.object.renderOrder = value;\n this.layer[sortSymbol]();\n this.object.updateMatrix();\n }\n }\n\n /**\n * Sets the visibility/interactivity mode of the element\n * @param value - New UI mode\n */\n public set mode(value: UIMode) {\n this.modeInternal = value;\n this.object.visible = value !== UIMode.HIDDEN;\n }\n\n /**\n * Destroys the element, cleaning up all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public destroy(): void {\n this.composerInternal.destroy();\n this.layer[removeVariableSymbol](this, this[heightSymbol]);\n this.layer[removeVariableSymbol](this, this[widthSymbol]);\n this.layer[removeVariableSymbol](this, this[ySymbol]);\n this.layer[removeVariableSymbol](this, this[xSymbol]);\n this.layer[removeUIElementSymbol](this);\n }\n\n /**\n * Internal method called by the rendering system to render this element.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n * @internal\n */\n public [renderSymbol](renderer: WebGLRenderer, deltaTime: number): void {\n this.render(renderer, deltaTime);\n }\n\n /**\n * Internal method called by the event system to handle clicks on this element.\n *\n * @param x - X coordinate of the click\n * @param y - Y coordinate of the click\n * @returns Whether the click was handled by this element\n * @internal\n */\n public [clickSymbol](x: number, y: number): boolean {\n return this.click(x, y);\n }\n\n /**\n * Applies transformations to the underlying Three.js object.\n * This is called when the element's position, size, or other properties change.\n */\n protected applyTransformations(): void {\n if (\n this[needsRecalculation] ||\n this.microInternal.needsRecalculation ||\n this.composerInternal.paddingHasChanged\n ) {\n applyMicroTransformations(\n this.object,\n this.microInternal,\n this.x,\n this.y,\n this.width,\n this.height,\n this.composerInternal.padding,\n );\n\n this.object.updateMatrix();\n\n this[needsRecalculation] = false;\n this.microInternal.needsRecalculation = false;\n }\n }\n\n /**\n * Handles click events on this element.\n *\n * @param x - X coordinate of the click\n * @param y - Y coordinate of the click\n * @returns Whether the click was handled by this element\n */\n protected click(x: number, y: number): boolean {\n if (this.mode !== UIMode.INTERACTIVE) {\n return false;\n }\n\n this.applyTransformations();\n if (testElement(this.x, this.y, this.width, this.height, x, y)) {\n this.emit(UIElementEvent.CLICK, this);\n return true;\n }\n\n return false;\n }\n\n /**\n * Renders the element.\n * This must be implemented by concrete subclasses.\n *\n * @param renderer - The WebGL renderer\n * @param deltaTime - Time elapsed since the last frame\n */\n protected abstract render(renderer: WebGLRenderer, deltaTime: number): void;\n}\n","import { Eventail } from \"eventail\";\nimport {\n Constraint,\n Expression,\n Operator,\n Solver,\n Strength,\n Variable,\n} from \"kiwi.js\";\nimport type { Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIConstraint } from \"../Constraints/UIConstraint\";\nimport { UIAnchor } from \"../Elements/UIAnchor\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n addUIConstraintSymbol,\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n needsRecalculation,\n removeConstraintSymbol,\n removeUIConstraintSymbol,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n sortSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIMode } from \"../Miscellaneous/UIMode\";\nimport { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nconst clearColor = new Color(0x000000);\n\ninterface VariableDescription {\n strength: number;\n suggestedValue: number;\n}\n\ninterface UIElementDescription {\n object?: Object3D;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<UIConstraint>;\n}\n\ninterface UIConstraintDescription {\n elements: Set<UIElement | UIAnchor>;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<Constraint>;\n}\n\nexport enum UILayerEvent {\n ORIENTATION_CHANGED = \"orientationChanged\",\n}\n\nexport abstract class UILayer extends Eventail {\n public mode = UIMode.VISIBLE;\n\n public readonly [xSymbol]: Variable = new Variable();\n public readonly [ySymbol]: Variable = new Variable();\n public readonly [widthSymbol]: Variable = new Variable();\n public readonly [heightSymbol]: Variable = new Variable();\n\n protected readonly scene = new Scene();\n protected readonly camera = new OrthographicCamera();\n protected solver? = new Solver();\n\n protected elements = new Map<UIElement | UIAnchor, UIElementDescription>();\n protected constraints = new Map<UIConstraint, UIConstraintDescription>();\n\n protected constraintX?: Constraint;\n protected constraintY?: Constraint;\n protected constraintW?: Constraint;\n protected constraintH?: Constraint;\n\n protected orientationPrivate = UIOrientation.PORTRAIT;\n protected needsRecalculation = false;\n\n public get orientation(): UIOrientation {\n return this.orientationPrivate;\n }\n\n public get width(): number {\n return this[widthSymbol].value();\n }\n\n public get height(): number {\n return this[heightSymbol].value();\n }\n\n public destroy(): void {\n this.solver = undefined;\n for (const constraint of this.constraints.keys()) {\n constraint.destroy();\n }\n for (const element of this.elements.keys()) {\n element.destroy();\n }\n }\n\n public [addUIElementSymbol](\n element: UIElement | UIAnchor,\n object?: Object3D,\n renderOrder?: number,\n ): void {\n if (this.elements.has(element)) {\n throw new Error(\"Element already added\");\n }\n\n this.elements.set(element, {\n object,\n variables: new Map(),\n constraints: new Set(),\n });\n\n if (object) {\n const zIndex = renderOrder ?? this.scene.children.length;\n\n object.position.z = zIndex;\n object.renderOrder = zIndex;\n\n this.scene.add(object);\n this[sortSymbol]();\n }\n }\n\n public [removeUIElementSymbol](element: UIElement | UIAnchor): void {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing element\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\"Constraints should be removed before removing element\");\n }\n\n this.elements.delete(element);\n if (dependencies.object) {\n this.scene.remove(dependencies.object);\n }\n }\n\n public [addUIConstraintSymbol](\n constraint: UIConstraint,\n elements: Set<UIElement | UIAnchor>,\n ): void {\n if (this.constraints.has(constraint)) {\n throw new Error(\"Constraint already added\");\n }\n\n for (const element of elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.add(constraint);\n }\n\n this.constraints.set(constraint, {\n elements,\n variables: new Map(),\n constraints: new Set(),\n });\n }\n\n public [removeUIConstraintSymbol](constraint: UIConstraint): void {\n const dependencies = this.constraints.get(constraint);\n if (dependencies === undefined) {\n throw new Error(\"Constraint not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing constraint\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\n \"Constraints should be removed before removing constraint\",\n );\n }\n\n for (const element of dependencies.elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.delete(constraint);\n }\n\n this.constraints.delete(constraint);\n }\n\n public [addConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before adding constraint you need to add it's owner\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint already exists\");\n }\n\n dependencies.constraints.add(constraint);\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.rebuildSolver();\n }\n this.needsRecalculation = true;\n }\n\n public [removeConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before removing constraint you need to add it's owner\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint not found\");\n }\n\n dependencies.constraints.delete(constraint);\n try {\n this.solver?.removeConstraint(constraint);\n } catch {\n this.rebuildSolver();\n }\n this.needsRecalculation = true;\n }\n\n public [addVariableSymbol](\n owner: UIElement | UIAnchor | UIConstraint,\n variable: Variable,\n strength: number,\n ): void {\n const dependencies =\n owner instanceof UIElement || owner instanceof UIAnchor\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before adding variable you need to add it's owner\");\n }\n\n if (dependencies.variables.has(variable)) {\n throw new Error(\"Variable already exists\");\n }\n\n dependencies.variables.set(variable, {\n strength,\n suggestedValue: variable.value(),\n });\n\n try {\n this.solver?.addEditVariable(variable, strength);\n } catch {\n this.rebuildSolver();\n }\n this.needsRecalculation = true;\n }\n\n public [removeVariableSymbol](\n owner: UIElement | UIAnchor | UIConstraint,\n variable: Variable,\n ): void {\n const dependencies =\n owner instanceof UIElement || owner instanceof UIAnchor\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before removing variable you need to add it's owner\");\n }\n\n if (!dependencies.variables.has(variable)) {\n throw new Error(\"Variable does not exist\");\n }\n\n dependencies.variables.delete(variable);\n try {\n this.solver?.removeEditVariable(variable);\n } catch {\n this.rebuildSolver();\n }\n this.needsRecalculation = true;\n }\n\n public [suggestVariableSymbol](\n owner: UIElement | UIAnchor | UIConstraint,\n variable: Variable,\n value: number,\n ): void {\n const dependencies =\n owner instanceof UIElement || owner instanceof UIAnchor\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before suggesting variable you need to add it's owner\");\n }\n\n const description = dependencies.variables.get(variable);\n\n if (!description) {\n throw new Error(\"Variable does not exist\");\n }\n\n if (description.suggestedValue !== value) {\n description.suggestedValue = value;\n try {\n this.solver?.suggestValue(variable, value);\n } catch {\n this.rebuildSolver();\n }\n this.needsRecalculation = true;\n }\n }\n\n public [sortSymbol](): void {\n this.scene.children.sort(\n (a: Object3D, b: Object3D) => a.position.z - b.position.z,\n );\n\n for (let i = 0; i < this.scene.children.length; i++) {\n const child = this.scene.children[i];\n child.position.z = i;\n child.renderOrder = i;\n }\n\n const gap = 1;\n\n this.camera.position.set(0, 0, this.scene.children.length + gap);\n this.camera.near = 1;\n this.camera.far = this.scene.children.length + gap + gap;\n this.camera.updateProjectionMatrix();\n this.camera.updateMatrix();\n }\n\n public render(renderer: WebGLRenderer, deltaTime: number): void {\n if (this.mode === UIMode.HIDDEN) {\n return;\n }\n\n const originalRenderTarget = renderer.getRenderTarget();\n const originalClearColor = renderer.getClearColor(clearColor);\n const originalClearAlpha = renderer.getClearAlpha();\n\n if (this.needsRecalculation) {\n this.needsRecalculation = false;\n this.solver?.updateVariables();\n\n for (const element of this.elements.keys()) {\n element[needsRecalculation] = true;\n }\n }\n\n for (const element of this.elements.keys()) {\n element[renderSymbol](renderer, deltaTime);\n }\n\n renderer.setRenderTarget(originalRenderTarget);\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.render(this.scene, this.camera);\n }\n\n protected clickInternal(x: number, y: number): void {\n if (this.mode !== UIMode.INTERACTIVE) {\n return;\n }\n\n const elements = [...this.elements.keys()]\n .filter((e: UIElement | UIAnchor) => e instanceof UIElement)\n .filter((e: UIElement) => e.mode === UIMode.INTERACTIVE)\n .sort((a: UIElement, b: UIElement) => a.zIndex - b.zIndex);\n\n for (const element of elements) {\n if (element[clickSymbol](x, y)) {\n break;\n }\n }\n }\n\n protected resizeInternal(width: number, height: number): void {\n this.applyCameraSize(width, height);\n this.rebuildLayerConstraints(width, height);\n this.updateOrientation(width, height);\n this.needsRecalculation = true;\n }\n\n protected applyCameraSize(width: number, height: number): void {\n this.camera.bottom = 0;\n this.camera.left = 0;\n this.camera.right = width;\n this.camera.top = height;\n this.camera.updateProjectionMatrix();\n }\n\n protected rebuildLayerConstraints(width: number, height: number): void {\n if (this.constraintX) {\n this.solver?.removeConstraint(this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.solver?.removeConstraint(this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.solver?.removeConstraint(this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.solver?.removeConstraint(this.constraintH);\n this.constraintH = undefined;\n }\n\n this.constraintX = new Constraint(\n new Expression(this[xSymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintY = new Constraint(\n new Expression(this[ySymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintW = new Constraint(\n new Expression(this[widthSymbol]),\n Operator.Eq,\n width,\n Strength.required,\n );\n\n this.constraintH = new Constraint(\n new Expression(this[heightSymbol]),\n Operator.Eq,\n height,\n Strength.required,\n );\n\n this.solver?.addConstraint(this.constraintX);\n this.solver?.addConstraint(this.constraintY);\n this.solver?.addConstraint(this.constraintW);\n this.solver?.addConstraint(this.constraintH);\n }\n\n protected updateOrientation(width: number, height: number): void {\n const lastOrientation = this.orientationPrivate;\n this.orientationPrivate =\n width > height ? UIOrientation.LANDSCAPE : UIOrientation.PORTRAIT;\n\n if (lastOrientation !== this.orientationPrivate) {\n this.solver = undefined;\n\n for (const constraint of this.constraints.keys()) {\n constraint[enableConstraintSymbol](this.orientationPrivate);\n }\n for (const constraint of this.constraints.keys()) {\n constraint[disableConstraintSymbol](this.orientationPrivate);\n }\n\n this.solver = new Solver();\n const descriptions = [\n ...this.elements.values(),\n ...this.constraints.values(),\n ];\n\n for (const description of descriptions) {\n for (const [key, value] of description.variables.entries()) {\n this.solver.addEditVariable(key, value.strength);\n this.solver.suggestValue(key, value.suggestedValue);\n }\n }\n\n if (this.constraintX) {\n this.solver.addConstraint(this.constraintX);\n }\n if (this.constraintY) {\n this.solver.addConstraint(this.constraintY);\n }\n if (this.constraintW) {\n this.solver.addConstraint(this.constraintW);\n }\n if (this.constraintH) {\n this.solver.addConstraint(this.constraintH);\n }\n\n for (const dependency of this.constraints.values()) {\n for (const constraint of dependency.constraints.values()) {\n this.solver.addConstraint(constraint);\n }\n }\n\n this.emit(UILayerEvent.ORIENTATION_CHANGED, this, this.orientation);\n }\n }\n\n private rebuildSolver(): void {\n try {\n this.solver = undefined;\n\n this.solver = new Solver();\n const descriptions = [\n ...this.elements.values(),\n ...this.constraints.values(),\n ];\n\n for (const description of descriptions) {\n for (const [key, value] of description.variables.entries()) {\n this.solver.addEditVariable(key, value.strength);\n this.solver.suggestValue(key, value.suggestedValue);\n }\n }\n\n if (this.constraintX) {\n this.solver.addConstraint(this.constraintX);\n }\n if (this.constraintY) {\n this.solver.addConstraint(this.constraintY);\n }\n if (this.constraintW) {\n this.solver.addConstraint(this.constraintW);\n }\n if (this.constraintH) {\n this.solver.addConstraint(this.constraintH);\n }\n\n for (const dependency of this.constraints.values()) {\n for (const constraint of dependency.constraints.values()) {\n this.solver.addConstraint(constraint);\n }\n }\n } catch (error) {\n throw error;\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport enum UIConstraintContainerDirection {\n FROM_LEFT_TOP,\n FROM_LEFT_BOTTOM,\n}\n\nexport interface UIConstraintContainerBuilderOptions {\n direction: UIConstraintContainerDirection;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport class UIConstraintContainerBuilder {\n public static build(\n container: UIElement,\n elementOne: UIElement,\n elementTwo: UIElement,\n options: Partial<UIConstraintContainerBuilderOptions> = {},\n ): {\n horizontalDistances: UIHorizontalDistanceConstraint[];\n verticalDistances: UIVerticalDistanceConstraint[];\n } {\n const direction =\n options.direction ?? UIConstraintContainerDirection.FROM_LEFT_TOP;\n\n const horizontalDistances: UIHorizontalDistanceConstraint[] = [];\n const verticalDistances: UIVerticalDistanceConstraint[] = [];\n\n horizontalDistances.push(\n new UIHorizontalDistanceConstraint(container, elementOne, {\n anchorOne: 0,\n anchorTwo: 0,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIHorizontalDistanceConstraint(container, elementTwo, {\n anchorOne: 1,\n anchorTwo: 1,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n const anchorOne =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 1 : 0;\n const anchorTwo =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 0 : 1;\n\n verticalDistances.push(\n new UIVerticalDistanceConstraint(container, elementOne, {\n anchorOne: anchorOne,\n anchorTwo: anchorOne,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIVerticalDistanceConstraint(container, elementTwo, {\n anchorOne: anchorTwo,\n anchorTwo: anchorTwo,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n return {\n horizontalDistances,\n verticalDistances,\n };\n }\n}\n","import type { Camera, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n Mesh,\n PerspectiveCamera,\n RGBAFormat,\n Scene,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Defines when a UIScene should be rendered/updated.\n */\nexport enum UISceneUpdateMode {\n /** Scene is rendered on every frame */\n ALWAYS = \"always\",\n /** Scene is rendered when any property changes */\n PROPERTY_CHANGED = \"property_changed\",\n /** Scene is only rendered when explicitly requested */\n MANUAL = \"manual\",\n}\n\n/** Default factor for reducing render target resolution (0.5 = half resolution) */\nconst DEFAULT_RESOLUTION_FACTOR = 0.5;\n/** Minimum allowed resolution factor */\nconst MIN_RESOLUTION_FACTOR = 0.1;\n/** Maximum allowed resolution factor */\nconst MAX_RESOLUTION_FACTOR = 8;\n/** Default width for the scene if not specified */\nconst DEFAULT_WIDTH = 512;\n/** Default height for the scene if not specified */\nconst DEFAULT_HEIGHT = 512;\n/** Default field of view for the perspective camera in degrees */\nconst DEFAULT_FOV = 75;\n/** Default near plane distance for the perspective camera */\nconst DEFAULT_NEAR = 0.1;\n/** Default far plane distance for the perspective camera */\nconst DEFAULT_FAR = 100;\n/** Default update mode for the scene */\nconst DEFAULT_UPDATE_MODE = UISceneUpdateMode.PROPERTY_CHANGED;\n/** Default clear color (black) */\nconst DEFAULT_CLEAR_COLOR = 0x000000;\n/** Default clear alpha (fully transparent) */\nconst DEFAULT_CLEAR_ALPHA = 0;\n/** Whether the scene is rendered immediately by default */\nconst DEFAULT_RENDERED_BY_DEFAULT = false;\n/** Whether to use a depth buffer by default */\nconst DEFAULT_USE_DEPTH = true;\n\n/**\n * Options for customizing the UIScene element.\n */\nexport interface UISceneOptions {\n /** Three.js scene to render */\n scene: Scene;\n /** Camera to use for rendering the scene */\n camera: Camera;\n /** Width of the scene viewport in pixels */\n width: number;\n /** Height of the scene viewport in pixels */\n height: number;\n /** Resolution scaling factor for performance optimization */\n resolutionFactor: number;\n /** Whether the scene should be rendered immediately after creation */\n renderedByDefault: boolean;\n /** Whether to use a depth buffer for rendering */\n useDepth: boolean;\n /** Color to clear the scene with before rendering */\n clearColor: number;\n /** Alpha value for the clear color (0-1) */\n clearAlpha: number;\n /** When the scene should be automatically re-rendered */\n updateBehavior: UISceneUpdateMode;\n}\n\n/**\n * A UI element that renders a Three.js scene as a texture.\n * This allows 3D content to be integrated into the 2D UI system.\n */\nexport class UIScene extends UIElement {\n /** Material used to render the scene's render target */\n private readonly material: UIMaterial;\n /** WebGL render target where the scene is rendered */\n private readonly renderTarget: WebGLRenderTarget;\n\n /** Color to clear the scene with before rendering */\n private clearColorInternal: number;\n /** Alpha value for the clear color */\n private clearAlphaInternal: number;\n\n /** Whether the scene needs to be re-rendered on the next frame */\n private needsRenderInternal = false;\n /** When the scene should be automatically re-rendered */\n private readonly updateModeInternal: UISceneUpdateMode;\n /** Resolution scaling factor for performance optimization */\n private resolutionFactorInternal: number;\n\n /** The Three.js scene being rendered */\n private sceneInternal: Scene;\n /** The camera used for rendering the scene */\n private cameraInternal: Camera;\n\n /**\n * Creates a new scene UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param options - Options to customize the scene\n * @throws Error if resolution factor is out of valid range or dimensions are invalid\n */\n constructor(layer: UILayer, options: Partial<UISceneOptions> = {}) {\n const resolutionFactor =\n options.resolutionFactor ?? DEFAULT_RESOLUTION_FACTOR;\n\n if (\n resolutionFactor < MIN_RESOLUTION_FACTOR ||\n resolutionFactor > MAX_RESOLUTION_FACTOR\n ) {\n throw new Error(\n `Invalid resolution factor: ${resolutionFactor}. Must be between ${MIN_RESOLUTION_FACTOR} and ${MAX_RESOLUTION_FACTOR}.`,\n );\n }\n\n const width = options.width ?? DEFAULT_WIDTH;\n const height = options.height ?? DEFAULT_HEIGHT;\n\n assertSize(\n width,\n height,\n `Invalid width or height: ${width}x${height}. Must be positive.`,\n );\n\n const renderTarget = new WebGLRenderTarget(\n width * resolutionFactor,\n height * resolutionFactor,\n {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: options.useDepth ?? DEFAULT_USE_DEPTH,\n stencilBuffer: false,\n },\n );\n\n const material = new UIMaterial(renderTarget.texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.sceneInternal = options.scene ?? new Scene();\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n DEFAULT_FOV,\n width / height,\n DEFAULT_NEAR,\n DEFAULT_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n\n this.updateModeInternal = options.updateBehavior ?? DEFAULT_UPDATE_MODE;\n\n if (options.renderedByDefault ?? DEFAULT_RENDERED_BY_DEFAULT) {\n this.needsRenderInternal = true;\n }\n\n this.clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;\n this.clearAlphaInternal = options.clearAlpha ?? DEFAULT_CLEAR_ALPHA;\n\n this.renderTarget = renderTarget;\n this.material = material;\n\n this.applyTransformations();\n }\n\n /** Gets whether the scene needs to be re-rendered on the next frame */\n public get needsRender(): boolean {\n return this.needsRenderInternal;\n }\n\n /** Gets the color tint applied to the rendered scene */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the rendered scene */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /** Gets the Three.js scene being rendered */\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n /** Gets the camera used for rendering the scene */\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n /** Gets the color used to clear the scene before rendering */\n public get clearColor(): number {\n return this.clearColorInternal;\n }\n\n /** Gets the alpha value for the clear color */\n public get clearAlpha(): number {\n return this.clearAlphaInternal;\n }\n\n /** Gets the resolution scaling factor */\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n /**\n * Sets the color tint applied to the rendered scene\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the rendered scene\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the Three.js scene to be rendered\n * @param value - Scene to render\n */\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the camera used for rendering the scene\n * @param value - Camera to use\n */\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the color used to clear the scene before rendering\n * @param value - Clear color in hexadecimal format\n */\n public set clearColor(value: number) {\n if (this.clearColorInternal !== value) {\n this.clearColorInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the alpha value for the clear color\n * @param value - Alpha value between 0 (transparent) and 1 (opaque)\n */\n public set clearAlpha(value: number) {\n if (this.clearAlphaInternal !== value) {\n this.clearAlphaInternal = value;\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Sets the resolution scaling factor\n * @param value - Resolution factor (e.g., 0.5 for half resolution)\n */\n public set resolutionFactor(value: number) {\n if (this.resolutionFactorInternal !== value) {\n this.resolutionFactorInternal = value;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n if (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.requestRender();\n }\n }\n }\n\n /**\n * Destroys the scene element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n this.renderTarget.dispose();\n super.destroy();\n }\n\n /**\n * Requests that the scene be re-rendered on the next frame.\n * This is used when the scene is in MANUAL update mode or when properties change.\n */\n public requestRender(): void {\n this.needsRenderInternal = true;\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Renders the scene element.\n * This will render the Three.js scene to a texture if needed,\n * then apply that texture to the mesh.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n if (\n this.needsRenderInternal ||\n this.updateModeInternal === UISceneUpdateMode.ALWAYS\n ) {\n this.needsRenderInternal = false;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n renderer.setClearColor(this.clearColorInternal, this.clearAlpha);\n renderer.setRenderTarget(this.renderTarget);\n renderer.clear(true, true, false);\n renderer.render(this.sceneInternal, this.cameraInternal);\n }\n\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type { UIAnchor } from \"../Elements/UIAnchor\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\n\nexport function assertSameLayer(\n elementOne: UIElement | UIAnchor | UILayer,\n elementTwo: UIElement | UIAnchor,\n message?: string,\n): void {\n if (\n (elementOne instanceof UILayer ? elementOne : elementOne.layer) !==\n elementTwo.layer\n ) {\n throw new Error(\n message ??\n `Elements must be on the same layer - element \"${elementTwo.constructor.name}\" cannot interact with elements from a different layer`,\n );\n }\n}\n\nexport function assertSize(\n width: number,\n height: number,\n message?: string,\n): void {\n if (width <= 0 || height <= 0) {\n throw new Error(\n message ??\n `Invalid dimensions: width (${width}) and height (${height}) must both be positive numbers greater than 0`,\n );\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIAnchor } from \"../Elements/UIAnchor\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Default anchor value (0.5 = center) for horizontal distance constraint\n */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for horizontal distance constraints.\n */\nexport interface UIHorizontalDistanceOptions {\n /** Horizontal anchor point (0-1) for the first element */\n anchorOne: number;\n /** Horizontal anchor point (0-1) for the second element */\n anchorTwo: number;\n /** The target distance between the two elements' anchor points */\n distance: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific horizontal distance between two UI elements.\n *\n * This constraint measures the distance between two anchor points on the x-axis\n * and ensures it matches (or is less/greater than) the specified distance value.\n */\nexport class UIHorizontalDistanceConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIHorizontalDistanceOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new horizontal distance constraint.\n *\n * @param elementOne - The first element or layer\n * @param elementTwo - The second element\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UIAnchor | UILayer,\n private readonly elementTwo: UIElement | UIAnchor,\n parameters?: Partial<UIHorizontalDistanceOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement || elementOne instanceof UIAnchor\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? DEFAULT_ANCHOR,\n anchorTwo: parameters?.anchorTwo ?? DEFAULT_ANCHOR,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the horizontal distance constraint to the constraint solver.\n *\n * Creates a constraint that enforces the distance between anchor points\n * on the x-axis of two elements based on the specified rule.\n *\n */\n protected buildConstraints(): void {\n const expressionOne =\n this.elementOne instanceof UIElement || this.elementOne instanceof UILayer\n ? new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n )\n : new Expression(this.elementOne[xSymbol]);\n\n const expressionTwo =\n this.elementTwo instanceof UIElement\n ? new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n )\n : new Expression(this.elementTwo[xSymbol]);\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the horizontal distance constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for horizontal proportion constraints.\n */\nexport interface UIHorizontalProportionOptions {\n /** The proportion ratio between elements' widths */\n proportion: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a proportional relationship between the widths of two elements.\n *\n * This constraint ensures that the width of one element is proportionally\n * related to the width of another element by a specified ratio.\n */\nexport class UIHorizontalProportionConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIHorizontalProportionOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new horizontal proportion constraint.\n *\n * @param elementOne - The reference element or layer\n * @param elementTwo - The element to constrain proportionally\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIHorizontalProportionOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the horizontal proportion constraint to the constraint solver.\n *\n * Creates a constraint expression in the form: (elementOne.width * proportion) - elementTwo.width = 0\n * This ensures the width ratio between elements matches the specified proportion.\n *\n */\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.proportion,\n );\n const expressionTwo = new Expression(this.elementTwo[widthSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the horizontal proportion constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIAnchor } from \"../Elements/UIAnchor\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Default anchor value (0.5 = center) for vertical distance constraint\n */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for vertical distance constraints.\n */\nexport interface UIVerticalDistanceOptions {\n /** Vertical anchor point (0-1) for the first element */\n anchorOne: number;\n /** Vertical anchor point (0-1) for the second element */\n anchorTwo: number;\n /** The target distance between the two elements' anchor points */\n distance: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific vertical distance between two UI elements.\n *\n * This constraint measures the distance between two anchor points on the y-axis\n * and ensures it matches (or is less/greater than) the specified distance value.\n */\nexport class UIVerticalDistanceConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIVerticalDistanceOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new vertical distance constraint.\n *\n * @param elementOne - The first element or layer\n * @param elementTwo - The second element\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UIAnchor | UILayer,\n private readonly elementTwo: UIElement | UIAnchor,\n parameters?: Partial<UIVerticalDistanceOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement || elementOne instanceof UIAnchor\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? DEFAULT_ANCHOR,\n anchorTwo: parameters?.anchorTwo ?? DEFAULT_ANCHOR,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the vertical distance constraint to the constraint solver.\n *\n * Creates a constraint that enforces the distance between anchor points\n * on the y-axis of two elements based on the specified rule.\n *\n */\n protected buildConstraints(): void {\n const expressionOne =\n this.elementOne instanceof UIElement || this.elementOne instanceof UILayer\n ? new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n )\n : new Expression(this.elementOne[ySymbol]);\n\n const expressionTwo =\n this.elementTwo instanceof UIElement\n ? new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n )\n : new Expression(this.elementTwo[ySymbol]);\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the vertical distance constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for vertical proportion constraints.\n */\nexport interface UIVerticalProportionOptions {\n /** The proportion ratio between elements' heights */\n proportion: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a proportional relationship between the heights of two elements.\n *\n * This constraint ensures that the height of one element is proportionally\n * related to the height of another element by a specified ratio.\n */\nexport class UIVerticalProportionConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIVerticalProportionOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new vertical proportion constraint.\n *\n * @param elementOne - The reference element or layer\n * @param elementTwo - The element to constrain proportionally\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIVerticalProportionOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the vertical proportion constraint to the constraint solver.\n *\n * Creates a constraint expression in the form: (elementOne.height * proportion) - elementTwo.height = 0\n * This ensures the height ratio between elements matches the specified proportion.\n *\n */\n protected buildConstraints(): void {\n const expressionOne = new Expression(\n this.elementOne[heightSymbol],\n ).multiply(this.parameters.proportion);\n const expressionTwo = new Expression(this.elementTwo[heightSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the vertical proportion constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for width constraints.\n */\nexport interface UIWidthOptions {\n /** The fixed width value to constrain the element to */\n width: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that enforces a specific width for a UI element.\n *\n * This constraint can be configured to require an exact width\n * or set minimum/maximum width limits using different rules.\n */\nexport class UIWidthConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly options: UIWidthOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new width constraint.\n *\n * @param element - The UI element to constrain\n * @param options - Configuration options\n */\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIWidthOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n width: options?.width ?? element.width,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the width constraint to the constraint solver.\n *\n * Creates a constraint that enforces the element's width based\n * on the specified rule (equal to, less than, or greater than).\n *\n */\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[widthSymbol]),\n convertRuleToOperator(this.options.rule),\n this.options.width,\n convertPowerToStrength(this.options.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the width constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIConstraintRule } from \"../Constraints/UIConstraintRule\";\nimport { UIHeightConstraint } from \"../Constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../Constraints/UIWidthConstraint\";\nimport type { UIAnchor } from \"../Elements/UIAnchor\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIType2D<T> {\n x?: T;\n y?: T;\n}\n\ninterface UIConstraint2DOptions {\n power: UIType2D<UIConstraintPower>;\n rule: UIType2D<UIConstraintRule>;\n orientation: UIType2D<UIOrientation>;\n}\n\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n size: UIType2D<number>;\n}\n\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n anchorOne: UIType2D<number>;\n anchorTwo: UIType2D<number>;\n distance: UIType2D<number>;\n}\n\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n proportion: UIType2D<number>;\n}\n\nexport interface UIConstraint2DResult<TX, TY> {\n x: TX;\n y: TY;\n}\n\nexport class UIConstraint2DBuilder {\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions>,\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n return {\n x: new UIWidthConstraint(element, {\n width: options.size?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIHeightConstraint(element, {\n height: options.size?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n\n public static distance(\n elementOne: UIElement | UIAnchor | UILayer,\n elementTwo: UIElement | UIAnchor,\n options: Partial<UIConstraintSize2DOptions>,\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n return {\n x: new UIHorizontalDistanceConstraint(elementOne, elementTwo, {\n anchorOne: options.anchorOne?.x,\n anchorTwo: options.anchorTwo?.x,\n distance: options.distance?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIVerticalDistanceConstraint(elementOne, elementTwo, {\n anchorOne: options.anchorOne?.y,\n anchorTwo: options.anchorTwo?.y,\n distance: options.distance?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n\n public static proportion(\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options: Partial<UIConstraintProportion2DOptions>,\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n return {\n x: new UIHorizontalProportionConstraint(elementOne, elementTwo, {\n proportion: options.proportion?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIVerticalProportionConstraint(elementOne, elementTwo, {\n proportion: options.proportion?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIHorizontalDistanceOptions } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport type { UIHorizontalProportionOptions } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport type { UIVerticalDistanceOptions } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIVerticalProportionOptions } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIConstraintStackBuilderOptions {\n distance: number;\n keepProportions: boolean;\n keepAlignment: boolean;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport interface UIConstraintStackBuilderResult<\n TDistance,\n TProportion,\n TCenter,\n> {\n distanceConstraints: TDistance[];\n proportionConstraints: TProportion[];\n alignmentConstraints: TCenter[];\n}\n\ninterface ConstraintConstructors<TDistance, TProportion, TCenter> {\n distanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TDistance;\n proportionConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalProportionOptions | UIVerticalProportionOptions>\n | undefined,\n ) => TProportion;\n centerDistanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TCenter;\n}\n\nexport class UIConstraintStackBuilder {\n public static buildHorizontal(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIHorizontalDistanceConstraint,\n UIHorizontalProportionConstraint,\n UIVerticalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIHorizontalDistanceConstraint,\n proportionConstraint: UIHorizontalProportionConstraint,\n centerDistanceConstraint: UIVerticalDistanceConstraint,\n });\n }\n\n public static buildVertical(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIVerticalDistanceConstraint,\n UIVerticalProportionConstraint,\n UIHorizontalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIVerticalDistanceConstraint,\n proportionConstraint: UIVerticalProportionConstraint,\n centerDistanceConstraint: UIHorizontalDistanceConstraint,\n });\n }\n\n private static buildStack<TDistance, TProportion, TCenter>(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n constructors: ConstraintConstructors<TDistance, TProportion, TCenter>,\n ): UIConstraintStackBuilderResult<TDistance, TProportion, TCenter> {\n const distances: TDistance[] = [];\n const proportions: TProportion[] = [];\n const centers: TCenter[] = [];\n\n for (let i = 0; i < elements.length - 1; i++) {\n const element = elements[i];\n const nextElement = elements[i + 1];\n\n distances.push(\n new constructors.distanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: options.distance,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n if (options.keepProportions !== false) {\n proportions.push(\n new constructors.proportionConstraint(element, nextElement, {\n power: options.power,\n orientation: options.orientation,\n }),\n );\n }\n\n if (options.keepAlignment !== false) {\n centers.push(\n new constructors.centerDistanceConstraint(element, nextElement, {\n power: options.power,\n anchorOne: 0,\n anchorTwo: 0,\n orientation: options.orientation,\n }),\n );\n }\n }\n\n return {\n distanceConstraints: distances,\n proportionConstraints: proportions,\n alignmentConstraints: centers,\n };\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\n/**\n * Configuration options for aspect ratio constraints.\n */\nexport interface UIAspectOptions {\n /** The aspect ratio to maintain (width / height) */\n aspect: number;\n /** Priority level for this constraint */\n power: UIConstraintPower;\n /** Rule for the constraint relationship (equal, less than, greater than) */\n rule: UIConstraintRule;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that maintains a specific aspect ratio for a UI element.\n *\n * The aspect ratio is defined as width divided by height (w/h).\n * This constraint ensures that an element maintains its proportions\n * during layout calculations.\n */\nexport class UIAspectConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIAspectOptions;\n /** The Kiwi.js constraint object */\n private constraint?: Constraint;\n\n /**\n * Creates a new aspect ratio constraint.\n *\n * @param element - The UI element to constrain\n * @param parameters - Configuration options\n */\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIAspectOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n aspect: parameters?.aspect ?? this.element.width / this.element.height,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param newOrientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param newOrientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the aspect ratio constraint to the constraint solver.\n *\n * Creates a constraint expression in the form: width - (height * aspect) = 0\n * This ensures that width/height = aspect.\n *\n */\n protected buildConstraints(): void {\n const expression = new Expression(this.element[widthSymbol]).plus(\n new Expression(this.element[heightSymbol]).multiply(\n -this.parameters.aspect,\n ),\n );\n\n this.constraint = new Constraint(\n expression,\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n /**\n * Removes the aspect ratio constraint from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\n/**\n * Default anchor value (0.5 = center) for cover constraint alignment\n */\n\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for cover constraints.\n */\nexport interface UICoverOptions {\n /** Whether to force equal height (true) or allow stretching (false) */\n isStrict: boolean;\n /** Horizontal anchor point (0-1) for alignment between elements */\n horizontalAnchor: number;\n /** Vertical anchor point (0-1) for alignment between elements */\n verticalAnchor: number;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that makes an element cover another element or layer.\n *\n * The covering element will:\n * - Be aligned with the covered element using the specified anchors\n * - Have at least the same width and height as the covered element\n * - Optionally maintain strict proportions\n *\n * This is similar to CSS's \"cover\" object-fit behavior.\n */\nexport class UICoverConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UICoverOptions;\n\n /** Constraint for X-axis alignment */\n private constraintX?: Constraint;\n /** Constraint for Y-axis alignment */\n private constraintY?: Constraint;\n /** Constraint for width relationship */\n private constraintW?: Constraint;\n /** Constraint for height relationship */\n private constraintH?: Constraint;\n /** Optional constraint for maintaining strict proportions */\n private constraintStrict?: Constraint;\n\n /**\n * Creates a new cover constraint.\n *\n * @param elementOne - The element or layer to be covered (the reference)\n * @param elementTwo - The element that will cover the reference\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UICoverOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? DEFAULT_ANCHOR,\n verticalAnchor: parameters?.verticalAnchor ?? DEFAULT_ANCHOR,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the cover constraints to the constraint solver.\n *\n * Creates five constraints:\n * 1. X alignment between the elements\n * 2. Y alignment between the elements\n * 3. Width covering (elementTwo width ≥ elementOne width)\n * 4. Height covering (elementTwo height ≥ elementOne height)\n * 5. Optional strict proportions (if isStrict = false)\n *\n */\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (!this.parameters.isStrict) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n /**\n * Removes all cover constraints from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\n/**\n * Default anchor value (0.5 = center) for fit constraint alignment\n */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for fit constraints.\n */\nexport interface UIFitOptions {\n /** Whether to force equal height (true) or allow stretching (false) */\n isStrict: boolean;\n /** Horizontal anchor point (0-1) for alignment between elements */\n horizontalAnchor: number;\n /** Vertical anchor point (0-1) for alignment between elements */\n verticalAnchor: number;\n /** Screen orientation when this constraint should be active */\n orientation: UIOrientation;\n}\n\n/**\n * Constraint that makes an element fit within another element or layer.\n *\n * The fitting element will:\n * - Be aligned with the container element using the specified anchors\n * - Have at most the same width and height as the container element\n * - Optionally maintain strict proportions\n *\n * This is similar to CSS's \"contain\" object-fit behavior.\n */\nexport class UIFitConstraint extends UIConstraint {\n /** The configuration options for this constraint */\n private readonly parameters: UIFitOptions;\n\n /** Constraint for X-axis alignment */\n private constraintX?: Constraint;\n /** Constraint for Y-axis alignment */\n private constraintY?: Constraint;\n\n /** Constraint for width relationship */\n private constraintW?: Constraint;\n /** Constraint for height relationship */\n private constraintH?: Constraint;\n\n /** Optional constraint for maintaining strict proportions */\n private constraintStrict?: Constraint;\n\n /**\n * Creates a new fit constraint.\n *\n * @param elementOne - The element or layer that contains the fitting element (the container)\n * @param elementTwo - The element that will fit within the container\n * @param parameters - Configuration options\n */\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIFitOptions>,\n ) {\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n assertSameLayer(elementOne, elementTwo);\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? DEFAULT_ANCHOR,\n verticalAnchor: parameters?.verticalAnchor ?? DEFAULT_ANCHOR,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Destroys this constraint, removing it from the constraint system.\n */\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n /**\n * Internal method to disable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n /**\n * Internal method to enable this constraint when orientation changes.\n *\n * @param orientation - The new screen orientation\n * @internal\n */\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n /**\n * Builds and adds the fit constraints to the constraint solver.\n *\n * Creates five constraints:\n * 1. X alignment between the elements\n * 2. Y alignment between the elements\n * 3. Width fitting (elementTwo width ≤ elementOne width)\n * 4. Height fitting (elementTwo height ≤ elementOne height)\n * 5. Optional strict proportions (if isStrict = true)\n *\n */\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (this.parameters.isStrict !== false) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n /**\n * Removes all fit constraints from the constraint solver.\n *\n */\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import { Object3D } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Default size for dummy elements when no dimensions are specified\n */\nconst DEFAULT_DUMMY_SIZE = 100;\n\n/**\n * A minimal UI element with no visual representation.\n * Used as a placeholder, spacer, or container for other elements.\n */\nexport class UIDummy extends UIElement {\n /**\n * Creates a new dummy UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param width - Width of the dummy element (defaults to DEFAULT_DUMMY_SIZE)\n * @param height - Height of the dummy element (defaults to DEFAULT_DUMMY_SIZE)\n */\n constructor(\n layer: UILayer,\n width = DEFAULT_DUMMY_SIZE,\n height = DEFAULT_DUMMY_SIZE,\n ) {\n super(layer, new Object3D(), 0, 0, width, height);\n this.applyTransformations();\n }\n\n /**\n * Renders the dummy element.\n * Since dummies have no visual representation, this only applies transformations.\n */\n protected override render(): void {\n this.applyTransformations();\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * A UI element that displays an image texture.\n * Renders a textured mesh using the provided texture.\n */\n\nexport class UIImage extends UIElement {\n /** Material used to render the image */\n private readonly material: UIMaterial;\n\n /** The texture displayed by this image */\n private readonly textureInternal: Texture;\n\n /**\n * Creates a new image UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param texture - The texture to display\n * @throws Error if the texture has invalid dimensions\n */\n constructor(layer: UILayer, texture: Texture) {\n const width = texture.image?.width;\n const height = texture.image?.height;\n\n assertSize(\n width,\n height,\n `Invalid image dimensions - texture \"${texture.name || \"unnamed\"}\" has invalid width (${width}) or height (${height}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.material = material;\n this.textureInternal = texture;\n\n this.applyTransformations();\n }\n\n /** Gets the texture displayed by this image */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /** Gets the color tint applied to the image */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the image */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Sets the color tint applied to the image\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the image\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Destroys the image element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n /**\n * Renders the image element.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.textureInternal.image.width,\n this.textureInternal.image.height,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIProgressMaterial extends ShaderMaterial {\n constructor(foregroundTexture: Texture, backgroundTexture?: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n background: { value: backgroundTexture },\n foreground: { value: foregroundTexture },\n progress: { value: 1 },\n backgroundColor: { value: new Color(1, 1, 1) },\n foregroundColor: { value: new Color(1, 1, 1) },\n color: { value: new Color(1, 1, 1) },\n backgroundOpacity: { value: 1 },\n foregroundOpacity: { value: 1 },\n opacity: { value: 1 },\n angle: { value: 0 },\n direction: { value: 1 },\n },\n ]),\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\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 `,\n transparent: true,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: false,\n });\n }\n\n public getProgress(): number {\n return this.uniforms.progress.value;\n }\n\n public getBackgroundTexture(): Texture | undefined {\n return this.uniforms.background.value;\n }\n\n public getForegroundTexture(): Texture {\n return this.uniforms.foreground.value;\n }\n\n public getBackgroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getForegroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getBackgroundOpacity(): number {\n return this.uniforms.backgroundOpacity.value;\n }\n\n public getForegroundOpacity(): number {\n return this.uniforms.foregroundOpacity.value;\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public getAngle(): number {\n return this.uniforms.angle.value;\n }\n\n public getIsForwardDirection(): boolean {\n return this.uniforms.direction.value === 1;\n }\n\n public setProgress(value: number): void {\n this.uniforms.progress.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundTexture(value: Texture | undefined): void {\n this.uniforms.background.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundTexture(value: Texture): void {\n this.uniforms.foreground.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundOpacity(value: number): void {\n this.uniforms.backgroundOpacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundOpacity(value: number): void {\n this.uniforms.foregroundOpacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setOpacity(value: number): void {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setAngle(value: number): void {\n this.uniforms.angle.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setIsForwardDirection(value: boolean): void {\n this.uniforms.direction.value = value ? 1 : -1;\n this.uniformsNeedUpdate = true;\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { MathUtils, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIProgressMaterial } from \"../Materials/UIProgressMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Options for customizing the UIProgress element.\n */\n\nexport interface UIProgressOptions {\n /** Optional background texture to display behind the progress indicator */\n textureBackground: Texture;\n /** Progress value from 0 to 1 */\n progress: number;\n /** Whether progress increases in the direction specified by angle (true) or opposite to it (false) */\n isForegroundDirection: boolean;\n /** Angle in degrees specifying the direction of progress */\n angle: number;\n /** Overall color tint applied to both textures */\n color: number;\n /** Overall opacity applied to both textures */\n opacity: number;\n /** Color tint applied to the background texture */\n backgroundColor: number;\n /** Color tint applied to the foreground texture */\n foregroundColor: number;\n /** Opacity of the background texture */\n backgroundOpacity: number;\n /** Opacity of the foreground texture */\n foregroundOpacity: number;\n}\n\n/**\n * A UI element that displays a progress indicator.\n * Can be used for loading bars, health bars, sliders, etc.\n */\n\nexport class UIProgress extends UIElement {\n /** Material used to render the progress indicator */\n private readonly material: UIProgressMaterial;\n /** Width of the underlying image texture */\n private readonly imageWidth: number;\n /** Height of the underlying image texture */\n private readonly imageHeight: number;\n\n /**\n * Creates a new progress UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param textureForeground - The texture to use for the progress indicator\n * @param options - Options to customize the progress indicator\n * @throws Error if either texture has invalid dimensions\n */\n constructor(\n layer: UILayer,\n textureForeground: Texture,\n options: Partial<UIProgressOptions> = {},\n ) {\n const foregroundWidth = textureForeground.image?.width;\n const foregroundHeight = textureForeground.image?.height;\n\n assertSize(\n foregroundWidth,\n foregroundHeight,\n `Invalid image dimensions - texture \"${textureForeground.name || \"unnamed\"}\" has invalid width (${foregroundWidth}) or height (${foregroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const backgroundWidth = options.textureBackground?.image?.width;\n const backgroundHeight = options.textureBackground?.image?.height;\n\n if (options.textureBackground) {\n assertSize(\n backgroundWidth,\n backgroundHeight,\n `Invalid image dimensions - texture \"${options.textureBackground.name || \"unnamed\"}\" has invalid width (${backgroundWidth}) or height (${backgroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n }\n\n const material = new UIProgressMaterial(\n textureForeground,\n options.textureBackground,\n );\n const object = new Mesh(geometry, material);\n\n if (options.progress) {\n material.setProgress(options.progress);\n }\n\n if (options.isForegroundDirection) {\n material.setIsForwardDirection(options.isForegroundDirection);\n }\n\n if (options.angle) {\n material.setAngle(MathUtils.degToRad(options.angle));\n }\n\n if (options.color) {\n material.setColor(options.color);\n }\n\n if (options.opacity) {\n material.setOpacity(options.opacity);\n }\n\n if (options.backgroundColor) {\n material.setBackgroundColor(options.backgroundColor);\n }\n\n if (options.foregroundColor) {\n material.setForegroundColor(options.foregroundColor);\n }\n\n if (options.backgroundOpacity) {\n material.setBackgroundOpacity(options.backgroundOpacity);\n }\n\n if (options.foregroundOpacity) {\n material.setForegroundOpacity(options.foregroundOpacity);\n }\n\n const imageWidth = backgroundWidth ?? foregroundWidth;\n const imageHeight = foregroundHeight ?? backgroundHeight;\n\n super(layer, object, 0, 0, imageWidth, imageHeight);\n\n this.material = material;\n this.imageWidth = imageWidth;\n this.imageHeight = imageHeight;\n\n this.applyTransformations();\n }\n\n /** Gets the current progress value (0 to 1) */\n public get progress(): number {\n return this.material.getProgress();\n }\n\n /** Gets the background texture if one was provided */\n public get backgroundTexture(): Texture | undefined {\n return this.material.getBackgroundTexture();\n }\n\n /** Gets the foreground texture used for the progress indicator */\n public get foregroundTexture(): Texture {\n return this.material.getForegroundTexture();\n }\n\n /** Gets the color tint applied to the background texture */\n public get backgroundColor(): number {\n return this.material.getBackgroundColor();\n }\n\n /** Gets the color tint applied to the foreground texture */\n public get foregroundColor(): number {\n return this.material.getForegroundColor();\n }\n\n /** Gets the overall color tint applied to both textures */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the background texture */\n public get backgroundOpacity(): number {\n return this.material.getBackgroundOpacity();\n }\n\n /** Gets the opacity of the foreground texture */\n public get foregroundOpacity(): number {\n return this.material.getForegroundOpacity();\n }\n\n /** Gets the overall opacity applied to both textures */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /** Gets the angle in degrees specifying the direction of progress */\n public get angle(): number {\n return MathUtils.radToDeg(this.material.getAngle());\n }\n\n /** Gets whether progress increases in the direction specified by angle (true) or opposite to it (false) */\n public get isForwardDirection(): boolean {\n return this.material.getIsForwardDirection();\n }\n\n /**\n * Sets the progress value\n * @param value - Progress value between 0 (empty) and 1 (full)\n */\n public set progress(value: number) {\n this.material.setProgress(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the color tint applied to the background texture\n * @param value - Color in hexadecimal format\n */\n public set backgroundColor(value: number) {\n this.material.setBackgroundColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the color tint applied to the foreground texture\n * @param value - Color in hexadecimal format\n */\n public set foregroundColor(value: number) {\n this.material.setForegroundColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the overall color tint applied to both textures\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the background texture\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set backgroundOpacity(value: number) {\n this.material.setBackgroundOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the foreground texture\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set foregroundOpacity(value: number) {\n this.material.setForegroundOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the overall opacity applied to both textures\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the angle specifying the direction of progress\n * @param value - Angle in degrees\n */\n public set angle(value: number) {\n this.material.setAngle(MathUtils.degToRad(value));\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets whether progress increases in the direction specified by angle\n * @param value - true to increase in the direction of angle, false for opposite\n */\n public set isForwardDirection(value: boolean) {\n this.material.setIsForwardDirection(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Destroys the progress element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n /**\n * Renders the progress element.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.imageWidth,\n this.imageHeight,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type {\n UIChunkMetrics,\n UITextChunk,\n UITextLine,\n UITextPadding,\n UITextSize,\n UITextStyle,\n} from \"./UITextInterfaces\";\n\nexport function resolvePadding(\n padding?: Partial<UITextPadding> | number,\n): UITextPadding {\n if (typeof padding === \"number\") {\n return {\n left: padding,\n right: padding,\n top: padding,\n bottom: padding,\n };\n }\n return {\n left: Math.max(padding?.left ?? 0, 0),\n right: Math.max(padding?.right ?? 0, 0),\n top: Math.max(padding?.top ?? 0, 0),\n bottom: Math.max(padding?.bottom ?? 0, 0),\n };\n}\n\nexport function resolveTextStyle(\n currentStyle?: Partial<UITextStyle>,\n baseStyle?: Partial<UITextStyle>,\n): UITextStyle {\n const fontSize = Math.max(\n currentStyle?.fontSize ?? baseStyle?.fontSize ?? 16,\n 1,\n );\n const lineHeight =\n currentStyle?.lineHeight ?? baseStyle?.lineHeight ?? fontSize * 1.2;\n const shadowBlur = Math.max(\n currentStyle?.shadowBlur ?? baseStyle?.shadowBlur ?? 0,\n 0,\n );\n const strokeWidth = Math.max(\n currentStyle?.strokeWidth ?? baseStyle?.strokeWidth ?? 0,\n 0,\n );\n return {\n color: currentStyle?.color ?? baseStyle?.color ?? \"#000000\",\n fontFamily: currentStyle?.fontFamily ?? baseStyle?.fontFamily ?? \"Arial\",\n fontSize,\n fontStyle: currentStyle?.fontStyle ?? baseStyle?.fontStyle ?? \"normal\",\n fontWeight: currentStyle?.fontWeight ?? baseStyle?.fontWeight ?? \"normal\",\n lineHeight,\n\n enableShadow:\n currentStyle?.enableShadow ?? baseStyle?.enableShadow ?? false,\n shadowOffsetX: currentStyle?.shadowOffsetX ?? baseStyle?.shadowOffsetX ?? 0,\n shadowOffsetY: currentStyle?.shadowOffsetY ?? baseStyle?.shadowOffsetY ?? 0,\n shadowBlur,\n shadowColor:\n currentStyle?.shadowColor ?? baseStyle?.shadowColor ?? \"transparent\",\n\n enableStroke:\n currentStyle?.enableStroke ?? baseStyle?.enableStroke ?? false,\n strokeColor:\n currentStyle?.strokeColor ?? baseStyle?.strokeColor ?? \"transparent\",\n strokeWidth,\n };\n}\n\nexport function splitText(text: string): string[] {\n return text.match(/\\S+|\\s|\\n/g) || [];\n}\n\nexport function measureTextChunk(\n context: CanvasRenderingContext2D,\n chunk: string,\n style: UITextStyle,\n): UIChunkMetrics {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (chunk === \"\\n\") {\n return {\n width: Math.ceil(0),\n height: style.lineHeight,\n baseline: 0,\n lineHeight: style.lineHeight,\n };\n }\n\n const metrics = context.measureText(chunk);\n const width = metrics.width;\n\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width: Math.ceil(width),\n height: height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: style.lineHeight,\n };\n}\n\nexport function wrapTextLines(\n maxWidth: number,\n chunks: UITextChunk[],\n): UITextLine[] {\n const lines: UITextLine[] = [];\n let currentLine: UITextChunk[] = [];\n let currentWidth = 0;\n let currentHeight = 0;\n let currentBaseline = 0;\n let currentLineHeight = 0;\n\n for (const chunk of chunks) {\n if (chunk.text === \"\\n\") {\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n currentLine = [];\n currentWidth = 0;\n currentHeight = 0;\n currentBaseline = 0;\n currentLineHeight = 0;\n continue;\n }\n\n if (\n currentWidth + chunk.metrics.width <= maxWidth ||\n currentLine.length === 0\n ) {\n currentLine.push(chunk);\n currentWidth += chunk.metrics.width;\n currentHeight = Math.max(currentHeight, chunk.metrics.height);\n currentBaseline = Math.max(currentBaseline, chunk.metrics.baseline);\n currentLineHeight = Math.max(currentLineHeight, chunk.metrics.lineHeight);\n } else {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n currentLine = [chunk];\n currentWidth = chunk.metrics.width;\n currentHeight = chunk.metrics.height;\n currentBaseline = chunk.metrics.baseline;\n currentLineHeight = chunk.metrics.lineHeight;\n }\n }\n\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n\n return lines;\n}\n\nexport function calculateTextBlockSize(lines: UITextLine[]): UITextSize {\n if (lines.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const maxLineWidth = Math.max(...lines.map((line) => line.width));\n\n let totalHeight = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (i === 0) {\n totalHeight += line.height;\n } else {\n totalHeight += line.lineHeight;\n }\n\n if (i === lines.length - 1) {\n totalHeight += line.baseline;\n }\n }\n\n return {\n width: maxLineWidth,\n height: totalHeight,\n };\n}\n\nexport function renderText(\n x: number,\n y: number,\n text: string,\n style: UITextStyle,\n context: CanvasRenderingContext2D,\n): void {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (style.enableShadow) {\n context.shadowOffsetX = style.shadowOffsetX;\n context.shadowOffsetY = style.shadowOffsetY;\n context.shadowBlur = style.shadowBlur;\n context.shadowColor = style.shadowColor;\n }\n\n if (style.enableStroke) {\n context.strokeStyle = style.strokeColor;\n context.lineWidth = style.strokeWidth;\n context.strokeText(text, x, y);\n }\n\n context.fillStyle = style.color;\n context.fillText(text, x, y);\n}\n\nexport function renderTextLines(\n paddingTop: number,\n paddingLeft: number,\n lines: UITextLine[],\n context: CanvasRenderingContext2D,\n): void {\n let currentY = paddingTop;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n let currentX = paddingLeft;\n currentY += i === 0 ? line.height : line.lineHeight;\n\n for (const chunk of line.chunks) {\n renderText(currentX, currentY, chunk.text, chunk.style, context);\n currentX += chunk.metrics.width;\n }\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport { CanvasTexture, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport {\n calculateTextBlockSize,\n measureTextChunk,\n renderTextLines,\n resolvePadding,\n resolveTextStyle,\n splitText,\n wrapTextLines,\n} from \"../Miscellaneous/textTools\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport type {\n UITextChunk,\n UITextPadding,\n UITextSize,\n UITextSpan,\n UITextStyle,\n} from \"../Miscellaneous/UITextInterfaces\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Options for customizing the UIText element.\n */\nexport interface UITextOptions {\n /** Maximum width of the text block before wrapping occurs */\n maxWidth: number;\n /** Padding around the text */\n padding: Partial<UITextPadding>;\n /** Default style to apply to text spans that don't specify their own style */\n defaultStyle: Partial<UITextStyle>;\n}\n\n/** Default maximum line width for text if not otherwise specified */\nconst DEFAULT_LINE_SIZE = 1024;\n\n/**\n * A UI element that displays formatted text.\n * Renders text to a canvas and displays it as a texture on a mesh.\n */\nexport class UIText extends UIElement {\n /** Material used to render the text */\n private readonly material: UIMaterial;\n /** Texture containing the rendered text */\n private readonly texture: CanvasTexture;\n\n /** Canvas element used to render the text */\n private readonly canvas: HTMLCanvasElement;\n /** 2D rendering context for the canvas */\n private readonly context: CanvasRenderingContext2D;\n\n /** Size of the text block without padding */\n private readonly textBlockSize: UITextSize;\n /** Padding values applied around the text */\n private readonly padding: UITextPadding;\n /** Cached aspect ratio for performance optimization */\n private suggestedAspect = 0;\n\n /**\n * Creates a new text UI element.\n *\n * @param layer - The UI layer that contains this element\n * @param spans - Text content to display, either as a string, text span, or array of text spans/strings\n * @param parameters - Options to customize the text rendering\n * @throws Error if canvas context creation fails\n */\n constructor(\n layer: UILayer,\n spans: (UITextSpan | string)[] | UITextSpan | string,\n parameters: Partial<UITextOptions> = {},\n ) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\"Failed to create canvas context\");\n }\n\n const chunks: UITextChunk[] = [];\n const processedSpans = Array.isArray(spans) ? spans : [spans];\n\n for (const span of processedSpans) {\n const isSpanString = typeof span === \"string\";\n const spanText = isSpanString ? span : span.text;\n const style = resolveTextStyle(\n isSpanString ? undefined : span.style,\n parameters.defaultStyle,\n );\n\n for (const text of splitText(spanText)) {\n const metrics = measureTextChunk(context, text, style);\n chunks.push({ text, style, metrics });\n }\n }\n\n const wrappedLines = wrapTextLines(\n parameters.maxWidth ?? DEFAULT_LINE_SIZE,\n chunks,\n );\n const textBlockSize = calculateTextBlockSize(wrappedLines);\n\n const padding = resolvePadding(parameters.padding);\n\n canvas.width = textBlockSize.width + padding.left + padding.right;\n canvas.height = textBlockSize.height + padding.top + padding.bottom;\n\n const texture = new CanvasTexture(canvas);\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, textBlockSize.width, textBlockSize.height);\n\n this.material = material;\n this.texture = texture;\n\n this.canvas = canvas;\n this.context = context;\n\n this.textBlockSize = textBlockSize;\n this.padding = padding;\n\n renderTextLines(\n this.padding.top,\n this.padding.left,\n wrappedLines,\n this.context,\n );\n\n this.texture.needsUpdate = true;\n this.applyTransformations();\n }\n\n /** Gets the color tint applied to the text */\n public get color(): number {\n return this.material.getColor();\n }\n\n /** Gets the opacity of the text */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Sets the color tint applied to the text\n * @param value - Color in hexadecimal format\n */\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Sets the opacity of the text\n * @param value - Opacity value between 0 (transparent) and 1 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n /**\n * Destroys the text element, disposing of all resources and removing it from the layer.\n * This should be called when the element is no longer needed.\n */\n public override destroy(): void {\n this.material.dispose();\n this.texture.dispose();\n this.canvas.remove();\n super.destroy();\n }\n\n /**\n * Applies transformations to the text element, ensuring the aspect ratio\n * matches the rendered text to prevent distortion.\n *\n * This overrides the base implementation to maintain the correct aspect ratio.\n */\n public override applyTransformations(): void {\n super.applyTransformations();\n\n const currentAspect = this.width / this.height;\n if (this.suggestedAspect !== currentAspect) {\n this.suggestedAspect = currentAspect;\n\n const targetAspect =\n (this.textBlockSize.width + this.padding.left + this.padding.right) /\n (this.textBlockSize.height + this.padding.top + this.padding.bottom);\n\n this.height = this.width / targetAspect;\n }\n }\n\n /**\n * Renders the text element.\n *\n * @param renderer - The WebGL renderer\n */\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.texture.image.width,\n this.texture.image.height,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport { UIMode } from \"../Miscellaneous/UIMode\";\nimport { UILayer } from \"./UILayer\";\n\nconst DEFAULT_SCREEN_HEIGHT = 1920;\n\nexport class UIFullScreenLayer extends UILayer {\n private targetScreenHeight?: number = DEFAULT_SCREEN_HEIGHT;\n\n constructor() {\n super();\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"pointerdown\", this.onClick);\n this.onResize();\n }\n\n public get tergetScreenHeight(): number | undefined {\n return this.targetScreenHeight;\n }\n\n public set tergetScreenHeight(value: number | undefined) {\n this.targetScreenHeight = value;\n this.resizeInternal(window.innerWidth, window.innerHeight);\n }\n\n public override destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"pointerdown\", this.onClick);\n super.destroy();\n }\n\n public override render(renderer: WebGLRenderer, deltaTime: number): void {\n renderer.clear(false, true, true);\n super.render(renderer, deltaTime);\n }\n\n private calculateScale(): number {\n const targetHeight = this.tergetScreenHeight ?? window.innerHeight;\n return targetHeight / window.innerHeight;\n }\n\n private readonly onResize = (): void => {\n const scale = this.calculateScale();\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n private readonly onClick = (event: PointerEvent): void => {\n if (this.mode !== UIMode.INTERACTIVE) {\n return;\n }\n\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\n const offsetX = rect ? event.clientX - rect.left : event.clientX;\n const offsetY = rect\n ? rect.bottom - event.clientY\n : window.innerHeight - event.clientY;\n\n const scale = this.calculateScale();\n this.clickInternal(offsetX * scale, offsetY * scale);\n };\n}\n","import type { Texture, WebGLRenderer } from \"three\";\n\n/**\n * Options passed to a UIPass when rendering\n */\nexport interface UIPassRenderOptions {\n /** Width of the render target in pixels (without padding) */\n width: number;\n /** Height of the render target in pixels (without padding) */\n height: number;\n /** Current padding used for the render target */\n padding: number;\n}\n\n/**\n * Abstract base class for all UI composition passes\n * \n * UI passes are used to apply post-processing effects to the rendered UI\n * Each pass can be chained together in a UIComposer to create complex effects\n */\nexport abstract class UIPass {\n /**\n * The amount of padding in pixels this pass requires\n * The compositor will use the maximum padding value from all passes\n */\n public abstract get padding(): number;\n \n /**\n * Whether this pass needs to be updated in the next frame\n * Set to true when properties change to trigger a re-render\n */\n public abstract get needsUpdate(): boolean;\n \n /**\n * Whether this pass contributes a meaningful effect\n * Passes that are not valuable may be skipped during composition\n */\n public abstract get isValuable(): boolean;\n \n /**\n * Renders this pass\n * \n * @param renderer - The WebGL renderer to use\n * @param texture - The input texture from the previous pass\n * @param parameters - Render options including dimensions and padding\n */\n public abstract render(\n renderer: WebGLRenderer,\n texture: Texture,\n parameters: UIPassRenderOptions,\n ): void;\n}\n"],"names":["createMap","IndexedMap","this","index","array","prototype","size","length","empty","itemAt","contains","key","undefined","id","find","i","setDefault","factory","pair","Pair","push","insert","value","erase","last","pop","first","copy","second","Variable","name","_value","_context","_id","VarId","_name","setName","context","setContext","setValue","plus","Expression","minus","multiply","coefficient","divide","toJSON","toString","parsed","parseArgs","arguments","_terms","terms","_constant","constant","result","n","isConstant","map","join","args","item","j","k","terms2","termPair","Array","Error","value2","Operator","Strength","create","a","b","c","w","Math","max","min","clip","required","strong","medium","weak","SymbolType","Constraint","expression","operator","rhs","strength","CnId","_operator","_strength","_expression","op","Solver","_cnMap","_rowMap","_varMap","_editMap","_infeasibleRows","_objective","Row","_artificial","_idTick","createConstraint","lhs","cn","addConstraint","constraint","data","_createRow","row","tag","subject","_chooseSubject","type","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_optimize","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","addEditVariable","variable","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_dualOptimize","other","rowPair_1","coeff","coefficientFor","External","updateVariables","vars","_getVarSymbol","_this","_makeSymbol","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","r","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_type","_cellMap","theCopy","xSymbol","ySymbol","widthSymbol","heightSymbol","addUIElementSymbol","removeUIElementSymbol","addUIConstraintSymbol","removeUIConstraintSymbol","addConstraintSymbol","removeConstraintSymbol","addVariableSymbol","removeVariableSymbol","suggestVariableSymbol","disableConstraintSymbol","enableConstraintSymbol","needsRecalculation","renderSymbol","clickSymbol","sortSymbol","UIOrientation","isUIOrientation","obj","Object","values","some","v","resolveOrientation","orientation","ALWAYS","UIConstraint","constructor","layer","elements","destroy","HIGH_PRIORITY","UIConstraintPower","UIConstraintRule","isUIConstraintPower","resolvePower","power","P0","convertPowerToStrength","P1","P2","P3","P4","P5","P6","P7","isUIConstraintRule","resolveRule","rule","EQUAL","convertRuleToOperator","LESS","GREATER","UIHeightConstraint","element","options","super","Set","height","_a","buildConstraints","destroyConstraints","Eventail","listeners","Map","on","callback","priority","addListener","once","off","current","get","delete","filtered","filter","l","set","emit","listener","apply","list","event","splice","UIAnchor","x","y","object","_b","_c","MathUtils","generateUUID","matrixAutoUpdate","zIndex","_e","_d","position","z","renderOrder","updateMatrix","renderer","deltaTime","render","applyTransformations","tempVector2","Vector2","tempBox2","Box2","tempMatrixA","Matrix3","tempMatrixB","tempMatrixC","tempMatrixD","tempMatrixE","tempVectorA","Vector3","DEFAULT_ANCHOR","UIMicroInternal","anchorX","anchorY","scaleX","scaleY","rotation","UIMicro","raw","owner","angle","radToDeg","convertedValue","degToRad","setAnchorByGlobalPosition","newAnchorX","width","newAnchorY","reset","UIMode","UIMaterial","ShaderMaterial","uniforms","opacity","color","Color","vertexShader","fragmentShader","transparent","lights","fog","depthWrite","depthTest","getTexture","getColor","getHex","getOpacity","setTexture","uniformsNeedUpdate","setColor","setHex","setOpacity","geometry","PlaneGeometry","translate","scene","Scene","mesh","Mesh","UIFullScreenQuad","paddingHorizontalInternal","paddingVerticalInternal","camera","OrthographicCamera","updateCameraTransform","paddingHorizontal","paddingVertical","material","left","right","bottom","top","updateProjectionMatrix","UIComposerInternal","passes","defaultMaterial","screen","needsUpdateInternal","paddingHasChangedInternal","paddingInternal","parameters","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","stencilBuffer","fromRenderTarget","WebGLRenderTarget","toRenderTarget","texture","generateMipmaps","needsUpdate","hasValuablePasses","hasPassesNeedingUpdate","paddingHasChanged","padding","requestUpdate","compose","canOverrideBlending","calculatePadding","widthWithPadding","heightWithPadding","setSize","setScreenPadding","setClearColor","setRenderTarget","clear","originalBlending","blending","NoBlending","pass","isValuable","reverseRenderTargets","dispose","p","reduce","UIComposer","UIElementEvent","UIElement","microInternal","composerInternal","modeInternal","VISIBLE","micro","composer","mode","visible","HIDDEN","click","realX","realY","realWidth","realHeight","centerX","centerY","translateToCenter","scale","cos","sin","translateFinal","finalMatrix","multiplyMatrices","point","applyMatrix3","applyMicroTransformations","INTERACTIVE","elementX","elementY","elementWidth","elementHeight","containsPoint","CLICK","clearColor","UILayerEvent","UIConstraintContainerDirection","UISceneUpdateMode","UILayer","solver","constraints","orientationPrivate","PORTRAIT","keys","has","variables","children","dependencies","remove","_f","rebuildSolver","suggestedValue","description","sort","child","near","far","originalRenderTarget","getRenderTarget","originalClearColor","getClearColor","originalClearAlpha","getClearAlpha","setClearAlpha","clickInternal","e","resizeInternal","applyCameraSize","rebuildLayerConstraints","updateOrientation","constraintX","constraintY","constraintW","_g","constraintH","_h","_j","_k","_l","_m","lastOrientation","LANDSCAPE","descriptions","entries","dependency","ORIENTATION_CHANGED","assertSameLayer","elementOne","elementTwo","assertSize","message","UIHorizontalDistanceConstraint","anchorOne","anchorTwo","distance","expressionOne","expressionTwo","UIHorizontalProportionConstraint","proportion","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","UIConstraint2DBuilder","UIConstraintContainerBuilder","build","container","direction","FROM_LEFT_TOP","horizontalDistances","verticalDistances","UIConstraintStackBuilder","buildHorizontal","buildStack","distanceConstraint","proportionConstraint","centerDistanceConstraint","buildVertical","constructors","distances","proportions","centers","nextElement","keepProportions","keepAlignment","distanceConstraints","proportionConstraints","alignmentConstraints","UIAspectConstraint","aspect","newOrientation","UICoverConstraint","isStrict","horizontalAnchor","verticalAnchor","constraintStrict","UIFitConstraint","UIDummy","Object3D","UIImage","image","textureInternal","UIProgressMaterial","foregroundTexture","backgroundTexture","UniformsUtils","merge","background","foreground","progress","backgroundColor","foregroundColor","backgroundOpacity","foregroundOpacity","getProgress","getBackgroundTexture","getForegroundTexture","getBackgroundColor","getForegroundColor","getBackgroundOpacity","getForegroundOpacity","getAngle","getIsForwardDirection","setProgress","setBackgroundTexture","setForegroundTexture","setBackgroundColor","setForegroundColor","setBackgroundOpacity","setForegroundOpacity","setAngle","setIsForwardDirection","UIProgress","textureForeground","foregroundWidth","foregroundHeight","backgroundWidth","textureBackground","backgroundHeight","isForegroundDirection","imageWidth","imageHeight","isForwardDirection","DEFAULT_UPDATE_MODE","PROPERTY_CHANGED","UIScene","resolutionFactor","renderTarget","useDepth","needsRenderInternal","sceneInternal","cameraInternal","PerspectiveCamera","resolutionFactorInternal","updateModeInternal","updateBehavior","renderedByDefault","clearColorInternal","clearAlphaInternal","clearAlpha","needsRender","requestRender","resolveTextStyle","currentStyle","baseStyle","fontSize","lineHeight","shadowBlur","strokeWidth","fontFamily","fontStyle","_p","_o","fontWeight","_r","_q","enableShadow","_t","_s","shadowOffsetX","_v","_u","shadowOffsetY","_x","_w","shadowColor","_z","_y","enableStroke","_1","_0","strokeColor","_3","_2","splitText","text","match","measureTextChunk","chunk","style","font","baseline","metrics","measureText","ceil","actualBoundingBoxAscent","actualBoundingBoxDescent","renderText","strokeStyle","lineWidth","strokeText","fillStyle","fillText","UIText","spans","canvas","document","createElement","getContext","chunks","processedSpans","isArray","span","isSpanString","spanText","defaultStyle","wrappedLines","maxWidth","lines","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","wrapTextLines","textBlockSize","maxLineWidth","line","totalHeight","calculateTextBlockSize","resolvePadding","CanvasTexture","suggestedAspect","paddingTop","paddingLeft","currentY","currentX","renderTextLines","currentAspect","UIFullScreenLayer","targetScreenHeight","onResize","calculateScale","window","innerWidth","innerHeight","onClick","rect","target","HTMLElement","getBoundingClientRect","offsetX","clientX","offsetY","clientY","addEventListener","tergetScreenHeight","removeEventListener","UIPass"],"mappings":"4VAOO,SAASA,IACZ,OAAO,IAAIC,CACf,CACA,IAAIA,EAA4B,WAC5B,SAASA,IACLC,KAAKC,MAAQ,CAAE,EACfD,KAAKE,MAAQ,EACrB,CA8GI,OA1GAH,EAAWI,UAAUC,KAAO,WACxB,OAAOJ,KAAKE,MAAMG,MACrB,EAIDN,EAAWI,UAAUG,MAAQ,WACzB,OAA6B,IAAtBN,KAAKE,MAAMG,MACrB,EAMDN,EAAWI,UAAUI,OAAS,SAAUN,GACpC,OAAOD,KAAKE,MAAMD,EACrB,EAMDF,EAAWI,UAAUK,SAAW,SAAUC,GACtC,YAAgCC,IAAzBV,KAAKC,MAAMQ,EAAIE,KACzB,EAMDZ,EAAWI,UAAUS,KAAO,SAAUH,GAClC,IAAII,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,YAAaD,IAANG,OAAkBH,EAAYV,KAAKE,MAAMW,EACnD,EAUDd,EAAWI,UAAUW,WAAa,SAAUL,EAAKM,GAC7C,IAAIF,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,QAAUD,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