site/node_modules/mathjax-full/js/output/common/Wrappers/mrow.js

170 lines
6.6 KiB
JavaScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonInferredMrowMixin = exports.CommonMrowMixin = void 0;
var BBox_js_1 = require("../../../util/BBox.js");
function CommonMrowMixin(Base) {
return (function (_super) {
__extends(class_1, _super);
function class_1() {
var e_1, _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
_this.stretchChildren();
try {
for (var _b = __values(_this.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
if (child.bbox.pwidth) {
_this.bbox.pwidth = BBox_js_1.BBox.fullWidth;
break;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
return _this;
}
Object.defineProperty(class_1.prototype, "fixesPWidth", {
get: function () {
return false;
},
enumerable: false,
configurable: true
});
class_1.prototype.stretchChildren = function () {
var e_2, _a, e_3, _b, e_4, _c;
var stretchy = [];
try {
for (var _d = __values(this.childNodes), _e = _d.next(); !_e.done; _e = _d.next()) {
var child = _e.value;
if (child.canStretch(1)) {
stretchy.push(child);
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
}
finally { if (e_2) throw e_2.error; }
}
var count = stretchy.length;
var nodeCount = this.childNodes.length;
if (count && nodeCount > 1) {
var H = 0, D = 0;
var all = (count > 1 && count === nodeCount);
try {
for (var _f = __values(this.childNodes), _g = _f.next(); !_g.done; _g = _f.next()) {
var child = _g.value;
var noStretch = (child.stretch.dir === 0);
if (all || noStretch) {
var _h = child.getOuterBBox(noStretch), h = _h.h, d = _h.d, rscale = _h.rscale;
h *= rscale;
d *= rscale;
if (h > H)
H = h;
if (d > D)
D = d;
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
}
finally { if (e_3) throw e_3.error; }
}
try {
for (var stretchy_1 = __values(stretchy), stretchy_1_1 = stretchy_1.next(); !stretchy_1_1.done; stretchy_1_1 = stretchy_1.next()) {
var child = stretchy_1_1.value;
child.coreMO().getStretchedVariant([H, D]);
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (stretchy_1_1 && !stretchy_1_1.done && (_c = stretchy_1.return)) _c.call(stretchy_1);
}
finally { if (e_4) throw e_4.error; }
}
}
};
return class_1;
}(Base));
}
exports.CommonMrowMixin = CommonMrowMixin;
function CommonInferredMrowMixin(Base) {
return (function (_super) {
__extends(class_2, _super);
function class_2() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_2.prototype.getScale = function () {
this.bbox.scale = this.parent.bbox.scale;
this.bbox.rscale = 1;
};
return class_2;
}(Base));
}
exports.CommonInferredMrowMixin = CommonInferredMrowMixin;
//# sourceMappingURL=mrow.js.map