n?A+=Z:E=!0,X>p-1E-6&&Xn&&(A+=Z):ia!=ma&&(man?(A+=Z,E=!0):ma>q&&Xq&&Xl.quality;g++){k=
+h*a[g];p=0;for(var m=e.length;pG.quality)continue;else E={fa:0,quality:1}}E=E||u.Rb(A,d[n.T][q.sa()],y,!0);E.quality>l.quality&&(l=E);break}k-=n}}for(b=e.length-1;0<=b;b--)e[b].le.yc=l};u.nd=function(a,b){function c(J){var K;return!(!J||J.mb||b&&(!b[(K=
+J.yc||{}).fa]||b.unite&&2===K.fa&&K.re&&K.se))}function d(J){if(J)for(var K=0,O=h.length;KMath.abs(k[0][0]-g)){g=k[1][0];1===g&&(c=++f<
+b.length?b[f].o():null,g=0);var m=k[0][1];if(1E-8>Math.abs(m-h)){p||(p=[e,m]);h=k[1][1];1===h&&(++e>=a.length&&(e=0),l=d[e]||a[e].o(),h=0);if(!c)return p[0]===e&&p[1]===h;continue}}break}return!1};t.prototype.wb=function(a){if("number"===typeof a){for(var b=this.U(),c=0,d=0,f=b.length;da)return g.wb(a-e)}if(0q;q++)r.hc(g[q],g[q+4],e[q+2],e[q],q,h,l,k);q=g;g=e;e=q}c=a[0];if(!c)return new F;for(var e=Array(6),g=c.la(d,Array(6)),h=g.slice(0,2),l=h.slice(),k=Array(2),
+p=1,m=a.length;pk;k+=2){var p=c[k],m=c[k+1];pf&&(f=p);mg&&(g=m)}}return new F(d,e,f-d,g-e)};t.qd=function(a,b,c,d){var f=new t;f.moveTo(a,b);f.lineTo(c,b);f.lineTo(c,d);f.lineTo(a,d);f.closePath();return f};ba(x,u);x.prototype.gb=function(a,b){var c=b,d=c[0];d&&"number"===typeof d[0]&&(c=[c]);for(d=
+b.length-1;0<=d;d--){var f=c[d];c!==b||f instanceof t||(c=I.slice(c));Array.isArray(f)?c[d]=new t({Fe:f,ca:!1}):f instanceof x&&(c.splice.apply(c,[d,1].concat(f.ac())),f.remove())}return B.prototype.gb.call(this,a,c)};x.prototype.reduce=function(a){for(var b=this.g.length-1;0<=b;b--){var c=this.g[b].reduce(a);c.ha()&&c.remove()}return this.g.length?B.prototype.reduce.call(this):(a=new t({ca:!1}),a.$a(this),a.Ub(this),this.remove(),a)};x.prototype.Yc=function(){for(var a=0,b=this.g.length;a>> 1;
+ allBounds[indices[mid]][coord] < value ? lo = mid + 1 : hi = mid;
+ }
+ return lo - 1;
+ }
+
+ const pri0 = sweepVertical ? 1 : 0;
+ const pri1 = pri0 + 2;
+ const sec0 = sweepVertical ? 0 : 1;
+ const sec1 = sec0 + 2;
+
+ const allIndicesByPri0 = new Array(allBounds.length);
+ for (let i = 0; i < allBounds.length; i++) {
+ allIndicesByPri0[i] = i;
+ }
+ allIndicesByPri0.sort(function (i1, i2) {
+ return allBounds[i1][pri0] - allBounds[i2][pri0];
+ });
+
+ const activeIndicesByPri1 = [];
+ const allCollisions = new Array(boundsA.length);
+ for (let i = 0; i < allBounds.length; i++) {
+ const curIndex = allIndicesByPri0[i];
+ const curBounds = allBounds[curIndex];
+ const origIndex = self ? curIndex : curIndex - boundsA.length;
+ const isCurrentA = curIndex < boundsA.length;
+ const isCurrentB = self || !isCurrentA;
+ let curCollisions = isCurrentA ? [] : null;
+
+ if (activeIndicesByPri1.length) {
+ const pruneCount = binarySearch(activeIndicesByPri1, pri1, curBounds[pri0] - tolerance) + 1;
+ activeIndicesByPri1.splice(0, pruneCount);
+ if (self && onlySweepAxisCollisions) {
+ curCollisions = curCollisions.concat(activeIndicesByPri1);
+ for (let j = 0; j < activeIndicesByPri1.length; j++) {
+ const activeIndex = activeIndicesByPri1[j];
+ allCollisions[activeIndex].push(origIndex);
+ }
+ } else {
+ for (let j = 0; j < activeIndicesByPri1.length; j++) {
+ const activeIndex = activeIndicesByPri1[j];
+ const activeBounds = allBounds[activeIndex];
+ const isActiveA = activeIndex < boundsA.length;
+ const isActiveB = self || activeIndex >= boundsA.length;
+ const isMatchingPairA = isCurrentA && isActiveB;
+ const isMatchingPairB = isCurrentB && isActiveA;
+ const hasBoundaryOverlap = (
+ curBounds[sec1] >= activeBounds[sec0] - tolerance &&
+ curBounds[sec0] <= activeBounds[sec1] + tolerance
+ );
+ const shouldCheckCollision = onlySweepAxisCollisions || (isMatchingPairA || isMatchingPairB) && hasBoundaryOverlap;
+ if (shouldCheckCollision) {
+ if (isMatchingPairA) {
+ curCollisions.push(self ? activeIndex : activeIndex - boundsA.length);
+ }
+ if (isMatchingPairB) {
+ allCollisions[activeIndex].push(origIndex);
+ }
+ }
+ }
+ }
+ }
+ if (isCurrentA) {
+ if (boundsA === boundsB) {
+ curCollisions.push(curIndex);
+ }
+ allCollisions[curIndex] = curCollisions;
+ }
+ if (activeIndicesByPri1.length) {
+ const curPri1 = curBounds[pri1];
+ const index = binarySearch(activeIndicesByPri1, pri1, curPri1);
+ activeIndicesByPri1.splice(index + 1, 0, curIndex);
+ } else {
+ activeIndicesByPri1.push(curIndex);
+ }
+ }
+ for (let i = 0; i < allCollisions.length; i++) {
+ const collisions = allCollisions[i];
+ if (collisions) {
+ collisions.sort(function (i1, i2) { return i1 - i2; });
+ }
+ }
+ return allCollisions;
+ },
+ };
+
+ const Numerical = new function () {
+
+ const abscissas = [
+ [0.5773502691896257645091488],
+ [0, 0.7745966692414833770358531],
+ [0.3399810435848562648026658, 0.8611363115940525752239465],
+ [0, 0.5384693101056830910363144, 0.9061798459386639927976269],
+ [0.2386191860831969086305017, 0.6612093864662645136613996, 0.9324695142031520278123016],
+ [0, 0.4058451513773971669066064, 0.7415311855993944398638648, 0.9491079123427585245261897],
+ [0.1834346424956498049394761, 0.5255324099163289858177390, 0.7966664774136267395915539, 0.9602898564975362316835609],
+ [0, 0.3242534234038089290385380, 0.6133714327005903973087020, 0.8360311073266357942994298, 0.9681602395076260898355762],
+ [0.1488743389816312108848260, 0.4333953941292471907992659, 0.6794095682990244062343274, 0.8650633666889845107320967, 0.9739065285171717200779640],
+ [0, 0.2695431559523449723315320, 0.5190961292068118159257257, 0.7301520055740493240934163, 0.8870625997680952990751578, 0.9782286581460569928039380],
+ [0.1252334085114689154724414, 0.3678314989981801937526915, 0.5873179542866174472967024, 0.7699026741943046870368938, 0.9041172563704748566784659, 0.9815606342467192506905491],
+ [0, 0.2304583159551347940655281, 0.4484927510364468528779129, 0.6423493394403402206439846, 0.8015780907333099127942065, 0.9175983992229779652065478, 0.9841830547185881494728294],
+ [0.1080549487073436620662447, 0.3191123689278897604356718, 0.5152486363581540919652907, 0.6872929048116854701480198, 0.8272013150697649931897947, 0.9284348836635735173363911, 0.9862838086968123388415973],
+ [0, 0.2011940939974345223006283, 0.3941513470775633698972074, 0.5709721726085388475372267, 0.7244177313601700474161861, 0.8482065834104272162006483, 0.9372733924007059043077589, 0.9879925180204854284895657],
+ [0.0950125098376374401853193, 0.2816035507792589132304605, 0.4580167776572273863424194, 0.6178762444026437484466718, 0.7554044083550030338951012, 0.8656312023878317438804679, 0.9445750230732325760779884, 0.9894009349916499325961542]
+ ];
+
+ const weights = [
+ [1],
+ [0.8888888888888888888888889, 0.5555555555555555555555556],
+ [0.6521451548625461426269361, 0.3478548451374538573730639],
+ [0.5688888888888888888888889, 0.4786286704993664680412915, 0.2369268850561890875142640],
+ [0.4679139345726910473898703, 0.3607615730481386075698335, 0.1713244923791703450402961],
+ [0.4179591836734693877551020, 0.3818300505051189449503698, 0.2797053914892766679014678, 0.1294849661688696932706114],
+ [0.3626837833783619829651504, 0.3137066458778872873379622, 0.2223810344533744705443560, 0.1012285362903762591525314],
+ [0.3302393550012597631645251, 0.3123470770400028400686304, 0.2606106964029354623187429, 0.1806481606948574040584720, 0.0812743883615744119718922],
+ [0.2955242247147528701738930, 0.2692667193099963550912269, 0.2190863625159820439955349, 0.1494513491505805931457763, 0.0666713443086881375935688],
+ [0.2729250867779006307144835, 0.2628045445102466621806889, 0.2331937645919904799185237, 0.1862902109277342514260976, 0.1255803694649046246346943, 0.0556685671161736664827537],
+ [0.2491470458134027850005624, 0.2334925365383548087608499, 0.2031674267230659217490645, 0.1600783285433462263346525, 0.1069393259953184309602547, 0.0471753363865118271946160],
+ [0.2325515532308739101945895, 0.2262831802628972384120902, 0.2078160475368885023125232, 0.1781459807619457382800467, 0.1388735102197872384636018, 0.0921214998377284479144218, 0.0404840047653158795200216],
+ [0.2152638534631577901958764, 0.2051984637212956039659241, 0.1855383974779378137417166, 0.1572031671581935345696019, 0.1215185706879031846894148, 0.0801580871597602098056333, 0.0351194603317518630318329],
+ [0.2025782419255612728806202, 0.1984314853271115764561183, 0.1861610000155622110268006, 0.1662692058169939335532009, 0.1395706779261543144478048, 0.1071592204671719350118695, 0.0703660474881081247092674, 0.0307532419961172683546284],
+ [0.1894506104550684962853967, 0.1826034150449235888667637, 0.1691565193950025381893121, 0.1495959888165767320815017, 0.1246289712555338720524763, 0.0951585116824927848099251, 0.0622535239386478928628438, 0.0271524594117540948517806]
+ ];
+
+ const EPSILON = 1e-12;
+ const MACHINE_EPSILON = 1.12e-16;
+
+ const log2 = function (x) { return Math.log(x) * Math.LOG2E; }
+ const clamp = function (value, min, max) { return value < min ? min : value > max ? max : value; }
+
+ function getDiscriminant(a, b, c) {
+ function split(v) {
+ const x = v * 134217729;
+ const y = v - x;
+ const hi = y + x;
+ const lo = v - hi;
+ return [hi, lo];
+ }
+
+ let D = b * b - a * c;
+ const E = b * b + a * c;
+ if (Math.abs(D) * 3 < E) {
+ const ad = split(a);
+ const bd = split(b);
+ const cd = split(c);
+ const p = b * b;
+ const dp = (bd[0] * bd[0] - p + 2 * bd[0] * bd[1]) + bd[1] * bd[1];
+ const q = a * c;
+ const dq = (ad[0] * cd[0] - q + ad[0] * cd[1] + ad[1] * cd[0]) + ad[1] * cd[1];
+ D = (p - q) + (dp - dq);
+ }
+ return D;
+ }
+
+ function getNormalizationFactor() {
+ const norm = Math.max.apply(Math, arguments);
+ return norm && (norm < 1e-8 || norm > 1e8) ? Math.pow(2, -Math.round(log2(norm))) : 0;
+ }
+
+ return {
+ EPSILON: EPSILON,
+ MACHINE_EPSILON: MACHINE_EPSILON,
+ CURVETIME_EPSILON: 1e-8,
+ GEOMETRIC_EPSILON: 1e-7,
+
+ isZero: function (val) { return val >= -EPSILON && val <= EPSILON; },
+
+ isMachineZero: function (val) { return val >= -MACHINE_EPSILON && val <= MACHINE_EPSILON; },
+
+ clamp: clamp,
+
+ integrate: function (f, a, b, n) {
+ const x = abscissas[n - 2];
+ const w = weights[n - 2];
+ const A = (b - a) * 0.5;
+ const B = A + a;
+ const m = (n + 1) >> 1;
+ let i = 0;
+ let sum = n & 1 ? w[i++] * f(B) : 0;
+ while (i < m) {
+ const Ax = A * x[i];
+ sum += w[i++] * (f(B + Ax) + f(B - Ax));
+ }
+ return A * sum;
+ },
+
+ findRoot: function (f, df, x, a, b, n, tolerance) {
+ for (let i = 0; i < n; i++) {
+ const fx = f(x);
+ const dx = fx / df(x);
+ const nx = x - dx;
+ if (Math.abs(dx) < tolerance) { x = nx; break; }
+ if (fx > 0) {
+ b = x; x = nx <= a ? (a + b) * 0.5 : nx;
+ } else { a = x; x = nx >= b ? (a + b) * 0.5 : nx; }
+ }
+ return clamp(x, a, b);
+ },
+
+ solveQuadratic: function (a, b, c, roots, min, max) {
+ let x1;
+ let x2 = Infinity;
+ if (Math.abs(a) < EPSILON) {
+ if (Math.abs(b) < EPSILON)
+ return Math.abs(c) < EPSILON ? -1 : 0;
+ x1 = -c / b;
+ } else {
+ b *= -0.5;
+ let D = getDiscriminant(a, b, c);
+ if (D && Math.abs(D) < MACHINE_EPSILON) {
+ const f = getNormalizationFactor(Math.abs(a), Math.abs(b), Math.abs(c));
+ if (f) {
+ a *= f;
+ b *= f;
+ c *= f;
+ D = getDiscriminant(a, b, c);
+ }
+ }
+ if (D >= -MACHINE_EPSILON) {
+ const Q = D < 0 ? 0 : Math.sqrt(D);
+ const R = b + (b < 0 ? -Q : Q);
+ x1 = (R === 0) ? c / a : R / a;
+ x2 = (R === 0) ? -x1 : c / R;
+ }
+ }
+ let count = 0;
+ const boundless = min == null;
+ const minB = min - EPSILON;
+ const maxB = max + EPSILON;
+ if (isFinite(x1) && (boundless || x1 > minB && x1 < maxB))
+ roots[count++] = boundless ? x1 : clamp(x1, min, max);
+ if (x2 !== x1 && isFinite(x2) && (boundless || x2 > minB && x2 < maxB))
+ roots[count++] = boundless ? x2 : clamp(x2, min, max);
+ return count;
+ },
+
+ solveCubic: function (a, b, c, d, roots, min, max) {
+ const f = getNormalizationFactor(Math.abs(a), Math.abs(b), Math.abs(c), Math.abs(d));
+ if (f) {
+ a *= f;
+ b *= f;
+ c *= f;
+ d *= f;
+ }
+
+ let x, b1, c2, qd, q;
+
+ function evaluate(x0) {
+ x = x0;
+ const tmp = a * x;
+ b1 = tmp + b;
+ c2 = b1 * x + c;
+ qd = (tmp + b1) * x + c2;
+ q = c2 * x + d;
+ }
+
+ if (Math.abs(a) < EPSILON) {
+ a = b;
+ b1 = c;
+ c2 = d;
+ x = Infinity;
+ } else if (Math.abs(d) < EPSILON) {
+ b1 = b;
+ c2 = c;
+ x = 0;
+ } else {
+ evaluate(-(b / a) / 3);
+ const t = q / a;
+ const r = Math.pow(Math.abs(t), 1 / 3);
+ const s = t < 0 ? -1 : 1;
+ const td = -qd / a;
+ const rd = td > 0 ? 1.324717957244746 * Math.max(r, Math.sqrt(td)) : r;
+ let x0 = x - s * rd;
+ if (x0 !== x) {
+ do {
+ evaluate(x0);
+ x0 = qd === 0 ? x : x - q / qd / (1 + MACHINE_EPSILON);
+ } while (s * x0 > s * x);
+ if (Math.abs(a) * x * x > Math.abs(d / x)) {
+ c2 = -d / x;
+ b1 = (c2 - c) / x;
+ }
+ }
+ }
+ let count = Numerical.solveQuadratic(a, b1, c2, roots, min, max);
+ const boundless = min == null;
+ const isUniqueRoot = (count === 0 || count > 0 && x !== roots[0] && x !== roots[1]);
+ const isWithinBounds = boundless || x > min - EPSILON && x < max + EPSILON;
+ if (isFinite(x) && isUniqueRoot && isWithinBounds)
+ roots[count++] = boundless ? x : clamp(x, min, max);
+ return count;
+ },
+ };
+ };
+
+ const UID = {
+ id: 1,
+ pools: {},
+
+ get: function (name) {
+ if (name) {
+ let pool = this.pools[name];
+ if (!pool)
+ pool = this.pools[name] = { _id: 1 };
+ return pool._id++;
+ } else {
+ return this.id++;
+ }
+ }
+ };
+
+ const Base = function () { };
+
+ Base.each = function (obj, iter, bind) {
+ if (obj) {
+ const descriptor = Object.getOwnPropertyDescriptor(obj, 'length');
+ const forIn = function (iter, bind) {
+ for (let i in this) {
+ if (this.hasOwnProperty(i))
+ iter.call(bind, this[i], i, this);
+ }
+ };
+ const iterFunction = descriptor && typeof descriptor.value === 'number' ? Array.prototype.forEach : forIn;
+ iterFunction.call(obj, iter, bind = bind || obj);
+ }
+ return bind;
+ };
+ Base.isPlainObject = function (obj) {
+ const ctor = obj != null && obj.constructor;
+ return ctor && (ctor === Object || ctor === Base || ctor.name === 'Object');
+ };
+ Base.pick = function (a, b) {
+ return a !== undefined ? a : b;
+ };
+ Base.slice = function (list, begin, end) {
+ return Array.prototype.slice.call(list, begin, end);
+ };
+ Base.equals = function (obj1, obj2) {
+ if (obj1 === obj2)
+ return true;
+ if (obj1 && obj1.equals)
+ return obj1.equals(obj2);
+ if (obj2 && obj2.equals)
+ return obj2.equals(obj1);
+ if (obj1 && obj2
+ && typeof obj1 === 'object' && typeof obj2 === 'object') {
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
+ let length = obj1.length;
+ if (length !== obj2.length)
+ return false;
+ while (length--) {
+ if (!Base.equals(obj1[length], obj2[length]))
+ return false;
+ }
+ } else {
+ const keys = Object.keys(obj1);
+ let length = keys.length;
+ if (length !== Object.keys(obj2).length)
+ return false;
+ while (length--) {
+ const key = keys[length];
+ if (!(obj2.hasOwnProperty(key) && Base.equals(obj1[key], obj2[key])))
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ };
+ Base.read = function (list, start, options, amount) {
+ if (this === Base) {
+ const value = list[list.__index = start || list.__index || 0];
+ list.__index++;
+ return value;
+ }
+ const readIndex = this === Point || this === Rectangle;
+ const begin = start || readIndex && list.__index || 0;
+ let obj = list[begin];
+ amount = amount || list.length - begin;
+ if (obj instanceof this || options && options.readNull && obj == null && amount <= 1) {
+ if (readIndex) { list.__index = begin + 1; }
+ return obj && options && options.clone ? obj.clone() : obj;
+ }
+ obj = Object.create(this.prototype);
+ if (readIndex)
+ obj.__read = true;
+ obj = obj.initialize.apply(obj, begin > 0 || begin + amount < list.length
+ ? Base.slice(list, begin, begin + amount)
+ : list) || obj;
+ if (readIndex) {
+ list.__index = begin + obj.__read;
+ obj.__read = undefined;
+ }
+ return obj;
+ };
+ Base.readList = function (list, start, options, amount) {
+ const res = [];
+ const begin = start || 0;
+ const end = amount ? begin + amount : list.length;
+ for (let i = begin; i < end; i++) {
+ const entry = list[i];
+ res.push(Array.isArray(entry) ? this.read(entry, 0, options) : this.read(list, i, options, 1));
+ }
+ return res;
+ };
+ Base.filter = function (dest, source, exclude, prioritize) {
+ let processed;
+
+ function handleKey(key) {
+ if (!(exclude && key in exclude) && !(processed && key in processed)) {
+ const value = source[key];
+ if (value !== undefined) dest[key] = value;
+ }
+ }
+
+ if (prioritize) {
+ const keys = {};
+ for (let i = 0, l = prioritize.length; i < l; i++) {
+ const key = prioritize[i];
+ if (key in source) {
+ handleKey(key);
+ keys[key] = true;
+ }
+ }
+ processed = keys;
+ }
+
+ Object.keys(source).forEach(handleKey);
+ return dest;
+ };
+ Base.isPlainValue = function (obj, asString) {
+ return Base.isPlainObject(obj) || Array.isArray(obj) || asString && typeof obj === 'string';
+ };
+ Base.splice = function (list, items, index, remove) {
+ const amount = items && items.length;
+ const append = index === undefined;
+ index = append ? list.length : index;
+ if (index > list.length)
+ index = list.length;
+ for (let i = 0; i < amount; i++)
+ items[i]._index = index + i;
+ if (append) {
+ list.push.apply(list, items);
+ return [];
+ } else {
+ const args = [index, remove];
+ if (items)
+ args.push.apply(args, items);
+ const removed = list.splice.apply(list, args);
+ for (let i = 0, l = removed.length; i < l; i++)
+ removed[i]._index = undefined;
+ for (let i = index + amount, l = list.length; i < l; i++)
+ list[i]._index = i;
+ return removed;
+ }
+ };
+ function isRealNumber(n) {
+ return typeof n === "number" && !isNaN(n) && isFinite(n);
+ }
+
+ const Point = function (arg0, arg1, owner) {
+ const type = typeof arg0;
+ const isReading = this.__read;
+ let readCount = 0;
+
+ if (type === 'number') {
+ const hasY = typeof arg1 === 'number';
+ this._set(arg0, hasY ? arg1 : arg0);
+ if (isReading) { readCount = hasY ? 2 : 1; }
+ } else if (type === 'undefined' || arg0 === null) {
+ this._set(0, 0);
+ if (isReading) { readCount = arg0 === null ? 1 : 0; }
+ } else {
+ readCount = 1;
+ if (Array.isArray(arg0)) {
+ this._set(+arg0[0], +(arg0.length > 1 ? arg0[1] : arg0[0]));
+ } else if (isRealNumber(arg0.x)) {
+ this._set(arg0.x || 0, arg0.y || 0);
+ } else {
+ this._set(0, 0);
+ readCount = 0;
+ }
+ }
+
+ if (isReading) { this.__read = readCount; }
+ if (owner) this._owner = owner;
+ return this;
+ };
+ InitClassWithStatics(Point, Base);
+
+ Point.prototype.set = Point;
+ Point.prototype._set = function (x, y) {
+ this.x = x;
+ this.y = y;
+ if (this._owner) this._owner._changed(this);
+ return this;
+ };
+ Point.prototype.getX = function () {
+ return this.x;
+ };
+ Point.prototype.getY = function () {
+ return this.y;
+ };
+ Point.prototype.equals = function (point) {
+ return this === point || point && (
+ this.x === point.x && this.y === point.y ||
+ Array.isArray(point) && this.x === point[0] && this.y === point[1]
+ );
+ };
+ Point.prototype.clone = function () {
+ return new Point(this.x, this.y);
+ };
+ Point.prototype.getLength = function () {
+ return Math.sqrt(this.x * this.x + this.y * this.y);
+ };
+ Point.prototype.getAngle = function () {
+ return this.getAngleInRadians.apply(this, arguments) * 180 / Math.PI;
+ };
+ Point.prototype.getAngleInRadians = function () {
+ if (!arguments.length) {
+ return this.isZero()
+ ? this._angle || 0
+ : this._angle = Math.atan2(this.y, this.x);
+ } else {
+ const point = Point.read(arguments);
+ const div = this.getLength() * point.getLength();
+ if (Numerical.isZero(div)) {
+ return NaN;
+ } else {
+ const a = this.dot(point) / div;
+ return Math.acos(a < -1 ? -1 : a > 1 ? 1 : a);
+ }
+ }
+ };
+ Point.prototype.getDistance = function () {
+ const point = Point.read(arguments);
+ const x = point.x - this.x;
+ const y = point.y - this.y;
+ const d = x * x + y * y;
+ const squared = Base.read(arguments);
+ return squared ? d : Math.sqrt(d);
+ };
+ Point.prototype.normalize = function (length) {
+ if (length === undefined)
+ length = 1;
+ const current = this.getLength();
+ const scale = current !== 0 ? length / current : 0;
+ const point = new Point(this.x * scale, this.y * scale);
+ if (scale >= 0)
+ point._angle = this._angle;
+ return point;
+ };
+ Point.prototype.rotate = function (angle, center) {
+ if (angle === 0)
+ return this.clone();
+ angle = angle * Math.PI / 180;
+ let point = center ? this.subtract(center) : this;
+ const sin = Math.sin(angle);
+ const cos = Math.cos(angle);
+ point = new Point(
+ point.x * cos - point.y * sin,
+ point.x * sin + point.y * cos
+ );
+ return center ? point.add(center) : point;
+ };
+ Point.prototype.transform = function (matrix) {
+ return matrix ? matrix._transformPoint(this) : this;
+ };
+ Point.prototype.add = function () {
+ const point = Point.read(arguments);
+ return new Point(this.x + point.x, this.y + point.y);
+ };
+ Point.prototype.subtract = function () {
+ const point = Point.read(arguments);
+ return new Point(this.x - point.x, this.y - point.y);
+ };
+ Point.prototype.multiply = function () {
+ const point = Point.read(arguments);
+ return new Point(this.x * point.x, this.y * point.y);
+ };
+ Point.prototype.divide = function () {
+ const point = Point.read(arguments);
+ return new Point(this.x / point.x, this.y / point.y);
+ };
+ Point.prototype.negate = function () {
+ return new Point(-this.x, -this.y);
+ };
+ Point.prototype.isInside = function () {
+ return Rectangle.read(arguments).contains(this);
+ };
+ Point.prototype.isClose = function () {
+ const point = Point.read(arguments);
+ const tolerance = Base.read(arguments);
+ return this.getDistance(point) <= tolerance;
+ };
+ Point.prototype.isCollinear = function () {
+ const point = Point.read(arguments);
+ return Point.isCollinear(this.x, this.y, point.x, point.y);
+ };
+ Point.prototype.isOrthogonal = function () {
+ const point = Point.read(arguments);
+ return Point.isOrthogonal(this.x, this.y, point.x, point.y);
+ };
+ Point.prototype.isZero = function () {
+ return Numerical.isZero(this.x) && Numerical.isZero(this.y);
+ };
+ Point.prototype.isNaN = function () {
+ return isNaN(this.x) || isNaN(this.y);
+ };
+ Point.prototype.dot = function () {
+ const point = Point.read(arguments);
+ return this.x * point.x + this.y * point.y;
+ };
+ Point.prototype.cross = function () {
+ const point = Point.read(arguments);
+ return this.x * point.y - this.y * point.x;
+ };
+
+ Point.isCollinear = function (x1, y1, x2, y2) {
+ return Math.abs(x1 * y2 - y1 * x2)
+ <= Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)) * 1e-8;
+ };
+ Point.isOrthogonal = function (x1, y1, x2, y2) {
+ return Math.abs(x1 * x2 + y1 * y2)
+ <= Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)) * 1e-8;
+ };
+
+ const Rectangle = function (arg0, arg1, arg2, arg3) {
+ const type = typeof arg0;
+ let read;
+ if (type === 'number') {
+ this._set(arg0, arg1, arg2, arg3);
+ read = 4;
+ } else if (type === 'undefined' || arg0 === null) {
+ this._set(0, 0, 0, 0);
+ read = arg0 === null ? 1 : 0;
+ }
+ if (this.__read) { this.__read = read; }
+ return this;
+ };
+ InitClassWithStatics(Rectangle, Base);
+
+ Rectangle.prototype._set = function (x, y, width, height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ return this;
+ };
+ Rectangle.prototype.clone = function () {
+ return new Rectangle(this.x, this.y, this.width, this.height);
+ };
+ Rectangle.prototype.equals = function (rect) {
+ const rt = Base.isPlainValue(rect) ? Rectangle.read(arguments) : rect;
+ return rt === this || rt
+ && this.x === rt.x
+ && this.y === rt.y
+ && this.width === rt.width
+ && this.height === rt.height;
+ };
+ Rectangle.prototype.getPoint = function (_dontLink) {
+ return new Point(this.x, this.y, this);
+ };
+ Rectangle.prototype.getLeft = Rectangle.prototype.getX = function () {
+ return this.x;
+ };
+ Rectangle.prototype.getTop = Rectangle.prototype.getY = function () {
+ return this.y;
+ };
+ Rectangle.prototype.getRight = function () {
+ return this.x + this.width;
+ };
+ Rectangle.prototype.getBottom = function () {
+ return this.y + this.height;
+ };
+ Rectangle.prototype.getWidth = function () {
+ return this.width;
+ };
+ Rectangle.prototype.getHeight = function () {
+ return this.height;
+ };
+ Rectangle.prototype.getCenterX = function () {
+ return this.getLeft() + this.getWidth() / 2;
+ };
+ Rectangle.prototype.getCenterY = function () {
+ return this.getTop() + this.getHeight() / 2;
+ };
+ Rectangle.prototype.getCenter = function (_dontLink) {
+ return new Point(this.getCenterX(), this.getCenterY());
+ };
+ Rectangle.prototype.getTopLeft = function (_dontLink) {
+ return new Point(this.getLeft(), this.getTop());
+ };
+ Rectangle.prototype.getArea = function () {
+ return this.width * this.height;
+ };
+ Rectangle.prototype.isEmpty = function () {
+ return this.width === 0 || this.height === 0;
+ };
+ Rectangle.prototype.contains = function (arg) {
+ return arg && arg.width !== undefined || (Array.isArray(arg) ? arg : arguments).length === 4
+ ? this._containsRectangle(Rectangle.read(arguments))
+ : this._containsPoint(Point.read(arguments));
+ };
+ Rectangle.prototype._containsPoint = function (point) {
+ const x = point.x;
+ const y = point.y;
+ return x >= this.x && y >= this.y
+ && x <= this.x + this.width
+ && y <= this.y + this.height;
+ };
+ Rectangle.prototype._containsRectangle = function (rect) {
+ const x = rect.x;
+ const y = rect.y;
+ return x >= this.x && y >= this.y
+ && x + rect.width <= this.x + this.width
+ && y + rect.height <= this.y + this.height;
+ };
+ Rectangle.prototype.intersects = function () {
+ const rect = Rectangle.read(arguments);
+ const epsilon = Base.read(arguments) || 0;
+ return rect.x + rect.width > this.x - epsilon
+ && rect.y + rect.height > this.y - epsilon
+ && rect.x < this.x + this.width + epsilon
+ && rect.y < this.y + this.height + epsilon;
+ };
+
+ const Matrix = function (arg, _dontNotify) {
+ const count = arguments.length;
+ if (count >= 6) {
+ this._set.apply(this, arguments);
+ } else if (count === 1 || count === 2) {
+ if (arg instanceof Matrix) {
+ this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty, _dontNotify);
+ } else if (Array.isArray(arg)) {
+ this._set.apply(this, _dontNotify ? arg.concat([_dontNotify]) : arg);
+ }
+ } else if (!count) {
+ this.reset();
+ }
+ return this;
+ };
+ InitClassWithStatics(Matrix, Base);
+
+ Matrix.prototype.set = Matrix;
+ Matrix.prototype._set = function (a, b, c, d, tx, ty, _dontNotify) {
+ this._a = a;
+ this._b = b;
+ this._c = c;
+ this._d = d;
+ this._tx = tx;
+ this._ty = ty;
+ if (!_dontNotify)
+ this._changed();
+ return this;
+ };
+ Matrix.prototype._changed = function () {
+ if (this._owner) {
+ if (this._owner._applyMatrix) {
+ this._owner.transform(null, true);
+ } else {
+ this._owner._changed(25);
+ }
+ }
+ };
+ Matrix.prototype.clone = function () {
+ return new Matrix(this._a, this._b, this._c, this._d, this._tx, this._ty);
+ };
+ Matrix.prototype.equals = function (mx) {
+ return mx === this || mx
+ && this._a === mx._a
+ && this._b === mx._b
+ && this._c === mx._c
+ && this._d === mx._d
+ && this._tx === mx._tx
+ && this._ty === mx._ty;
+ };
+ Matrix.prototype.reset = function (_dontNotify) {
+ this._a = this._d = 1;
+ this._b = this._c = this._tx = this._ty = 0;
+ if (!_dontNotify)
+ this._changed();
+ return this;
+ };
+ Matrix.prototype.apply = function (recursively, _setApplyMatrix) {
+ if (!this._owner) { return false; }
+ this._owner.transform(null, Base.pick(recursively, true), _setApplyMatrix);
+ return this.isIdentity();
+ };
+ Matrix.prototype.translate = function () {
+ const point = Point.read(arguments);
+ this._tx += point.x * this._a + point.y * this._c;
+ this._ty += point.x * this._b + point.y * this._d;
+ this._changed();
+ return this;
+ };
+ Matrix.prototype.scale = function () {
+ const scale = Point.read(arguments);
+ const center = Point.read(arguments, 0, { readNull: true });
+ if (center) { this.translate(center); }
+ this._a *= scale.x;
+ this._b *= scale.x;
+ this._c *= scale.y;
+ this._d *= scale.y;
+ if (center) { this.translate(center.negate()); }
+ this._changed();
+ return this;
+ };
+ Matrix.prototype.rotate = function (angle) {
+ angle *= Math.PI / 180;
+ const center = Point.read(arguments, 1);
+ const cos = Math.cos(angle);
+ const sin = Math.sin(angle);
+ const tx = center.x - center.x * cos + center.y * sin;
+ const ty = center.y - center.x * sin - center.y * cos;
+ const a = this._a, b = this._b, c = this._c, d = this._d;
+ this._a = cos * a + sin * c;
+ this._b = cos * b + sin * d;
+ this._c = -sin * a + cos * c;
+ this._d = -sin * b + cos * d;
+ this._tx += tx * a + ty * c;
+ this._ty += tx * b + ty * d;
+ this._changed();
+ return this;
+ };
+ Matrix.prototype.shear = function () {
+ const shear = Point.read(arguments);
+ const center = Point.read(arguments, 0, { readNull: true });
+ if (center) { this.translate(center); }
+ const a = this._a, b = this._b;
+ this._a += shear.y * this._c;
+ this._b += shear.y * this._d;
+ this._c += shear.x * a;
+ this._d += shear.x * b;
+ if (center) { this.translate(center.negate()); }
+ this._changed();
+ return this;
+ };
+ Matrix.prototype.skew = function () {
+ const skew = Point.read(arguments);
+ const center = Point.read(arguments, 0, { readNull: true });
+ const toRadians = Math.PI / 180;
+ const shear = new Point(Math.tan(skew.x * toRadians), Math.tan(skew.y * toRadians));
+ return this.shear(shear, center);
+ };
+ Matrix.prototype.append = function (mx, _dontNotify) {
+ if (mx) {
+ const a1 = this._a, b1 = this._b, c1 = this._c, d1 = this._d;
+ const a2 = mx._a, b2 = mx._c, c2 = mx._b, d2 = mx._d;
+ const tx2 = mx._tx, ty2 = mx._ty;
+ this._a = a2 * a1 + c2 * c1;
+ this._c = b2 * a1 + d2 * c1;
+ this._b = a2 * b1 + c2 * d1;
+ this._d = b2 * b1 + d2 * d1;
+ this._tx += tx2 * a1 + ty2 * c1;
+ this._ty += tx2 * b1 + ty2 * d1;
+ if (!_dontNotify)
+ this._changed();
+ }
+ return this;
+ };
+ Matrix.prototype.prepend = function (mx, _dontNotify) {
+ if (mx) {
+ const a1 = this._a, b1 = this._b, c1 = this._c, d1 = this._d;
+ const a2 = mx._a, b2 = mx._c, c2 = mx._b, d2 = mx._d;
+ const tx1 = this._tx, ty1 = this._ty;
+ const tx2 = mx._tx, ty2 = mx._ty;
+ this._a = a2 * a1 + b2 * b1;
+ this._c = a2 * c1 + b2 * d1;
+ this._b = c2 * a1 + d2 * b1;
+ this._d = c2 * c1 + d2 * d1;
+ this._tx = a2 * tx1 + b2 * ty1 + tx2;
+ this._ty = c2 * tx1 + d2 * ty1 + ty2;
+ if (!_dontNotify)
+ this._changed();
+ }
+ return this;
+ };
+ Matrix.prototype.appended = function (mx) {
+ return this.clone().append(mx);
+ };
+ Matrix.prototype.prepended = function (mx) {
+ return this.clone().prepend(mx);
+ };
+ Matrix.prototype._orNullIfIdentity = function () {
+ return this.isIdentity() ? null : this;
+ };
+ Matrix.prototype.isIdentity = function () {
+ return this._a === 1 && this._b === 0 && this._c === 0 && this._d === 1
+ && this._tx === 0 && this._ty === 0;
+ };
+ Matrix.prototype.isInvertible = function () {
+ const det = this._a * this._d - this._c * this._b;
+ return det && !isNaN(det) && isFinite(this._tx) && isFinite(this._ty);
+ };
+ Matrix.prototype.transform = function (src, dst, count) {
+ return arguments.length < 3
+ ? this._transformPoint(Point.read(arguments))
+ : this._transformCoordinates(src, dst, count);
+ };
+ Matrix.prototype._transformPoint = function (point, dest, _dontNotify) {
+ if (!dest)
+ dest = new Point();
+ return dest._set(
+ point.x * this._a + point.y * this._c + this._tx,
+ point.x * this._b + point.y * this._d + this._ty,
+ _dontNotify
+ );
+ };
+ Matrix.prototype._transformCoordinates = function (src, dst, count) {
+ for (let i = 0, max = 2 * count; i < max; i += 2) {
+ const x = src[i];
+ const y = src[i + 1];
+ dst[i] = x * this._a + y * this._c + this._tx;
+ dst[i + 1] = x * this._b + y * this._d + this._ty;
+ }
+ return dst;
+ };
+ Matrix.prototype._transformCorners = function (rect) {
+ const x1 = rect.x;
+ const y1 = rect.y;
+ const x2 = x1 + rect.width;
+ const y2 = y1 + rect.height;
+ const coords = [x1, y1, x2, y1, x2, y2, x1, y2];
+ return this._transformCoordinates(coords, coords, 4);
+ };
+ Matrix.prototype._transformBounds = function (bounds, dest, _dontNotify) {
+ const coords = this._transformCorners(bounds);
+ const min = coords.slice(0, 2);
+ const max = min.slice();
+ for (let i = 2; i < 8; i++) {
+ const val = coords[i];
+ const j = i & 1;
+ if (val < min[j]) {
+ min[j] = val;
+ } else if (val > max[j]) {
+ max[j] = val;
+ }
+ }
+ if (!dest)
+ dest = new Rectangle();
+ return dest._set(min[0], min[1], max[0] - min[0], max[1] - min[1], _dontNotify);
+ };
+ Matrix.prototype._inverseTransform = function (point, dest, _dontNotify) {
+ const a = this._a, b = this._b, c = this._c, d = this._d;
+ const tx = this._tx, ty = this._ty;
+ const det = a * d - b * c;
+ let res = null;
+ if (det && !isNaN(det) && isFinite(tx) && isFinite(ty)) {
+ const x = point.x - this._tx;
+ const y = point.y - this._ty;
+ if (!dest)
+ dest = new Point();
+ res = dest._set(
+ (x * d - y * c) / det,
+ (y * a - x * b) / det,
+ _dontNotify
+ );
+ }
+ return res;
+ };
+ Matrix.prototype.decompose = function () {
+ const a = this._a, b = this._b, c = this._c, d = this._d;
+ const det = a * d - b * c;
+ const degrees = 180 / Math.PI;
+ let rotate, scale, skew;
+ if (a !== 0 || b !== 0) {
+ const r = Math.sqrt(a * a + b * b);
+ rotate = Math.acos(a / r) * (b > 0 ? 1 : -1);
+ scale = [r, det / r];
+ skew = [Math.atan2(a * c + b * d, r * r), 0];
+ } else if (c !== 0 || d !== 0) {
+ const s = Math.sqrt(c * c + d * d);
+ rotate = Math.asin(c / s) * (d > 0 ? 1 : -1);
+ scale = [det / s, s];
+ skew = [0, Math.atan2(a * c + b * d, s * s)];
+ } else {
+ rotate = 0;
+ skew = scale = [0, 0];
+ }
+ return {
+ translation: this.getTranslation(),
+ rotation: rotate * degrees,
+ scaling: new Point(scale),
+ skewing: new Point(skew[0] * degrees, skew[1] * degrees)
+ };
+ };
+ Matrix.prototype.getValues = function () {
+ return [this._a, this._b, this._c, this._d, this._tx, this._ty];
+ };
+ Matrix.prototype.getTranslation = function () {
+ return new Point(this._tx, this._ty);
+ };
+ Matrix.prototype.getRotation = function () {
+ return this.decompose().rotation;
+ };
+
+ const Line = function Line(arg0, arg1, arg2, arg3, arg4) {
+ let asVector = false;
+ if (arguments.length >= 4) {
+ this._px = arg0;
+ this._py = arg1;
+ this._vx = arg2;
+ this._vy = arg3;
+ asVector = arg4;
+ } else {
+ this._px = arg0.x;
+ this._py = arg0.y;
+ this._vx = arg1.x;
+ this._vy = arg1.y;
+ asVector = arg2;
+ }
+ if (!asVector) {
+ this._vx -= this._px;
+ this._vy -= this._py;
+ }
+ };
+ InitClassWithStatics(Line, Base);
+
+ Line.prototype.getPoint = function () {
+ return new Point(this._px, this._py);
+ };
+ Line.prototype.getVector = function () {
+ return new Point(this._vx, this._vy);
+ };
+ Line.prototype.getLength = function () {
+ return this.getVector().getLength();
+ };
+ Line.prototype.intersect = function (line, isInfinite) {
+ return Line.intersect(
+ this._px, this._py, this._vx, this._vy,
+ line._px, line._py, line._vx, line._vy,
+ true, isInfinite);
+ };
+ Line.prototype.getSide = function (point, isInfinite) {
+ return Line.getSide(
+ this._px, this._py, this._vx, this._vy,
+ point.x, point.y, true, isInfinite);
+ };
+ Line.prototype.getDistance = function (point) {
+ return Math.abs(this.getSignedDistance(point));
+ };
+ Line.prototype.getSignedDistance = function (point) {
+ return Line.getSignedDistance(this._px, this._py, this._vx, this._vy,
+ point.x, point.y, true);
+ };
+ Line.prototype.isCollinear = function (line) {
+ return Point.isCollinear(this._vx, this._vy, line._vx, line._vy);
+ };
+ Line.prototype.isOrthogonal = function (line) {
+ return Point.isOrthogonal(this._vx, this._vy, line._vx, line._vy);
+ };
+
+ Line.intersect = function (p1x, p1y, v1x, v1y, p2x, p2y, v2x, v2y, asVector,
+ isInfinite) {
+ if (!asVector) {
+ v1x -= p1x;
+ v1y -= p1y;
+ v2x -= p2x;
+ v2y -= p2y;
+ }
+ const cross = v1x * v2y - v1y * v2x;
+ if (!Numerical.isMachineZero(cross)) {
+ const dx = p1x - p2x;
+ const dy = p1y - p2y;
+ let u1 = (v2x * dy - v2y * dx) / cross;
+ let u2 = (v1x * dy - v1y * dx) / cross;
+ const uMin = -Numerical.EPSILON;
+ const uMax = 1 + Numerical.EPSILON;
+ if (isInfinite || uMin < u1 && u1 < uMax && uMin < u2 && u2 < uMax) {
+ if (!isInfinite) {
+ u1 = u1 <= 0 ? 0 : u1 >= 1 ? 1 : u1;
+ }
+ return new Point(p1x + u1 * v1x, p1y + u1 * v1y);
+ }
+ }
+ };
+ Line.getSide = function (px, py, vx, vy, x, y, asVector, isInfinite) {
+ if (!asVector) {
+ vx -= px;
+ vy -= py;
+ }
+ const v2x = x - px;
+ const v2y = y - py;
+ let ccw = v2x * vy - v2y * vx;
+ if (!isInfinite && Numerical.isMachineZero(ccw)) {
+ ccw = (v2x * vx + v2x * vx) / (vx * vx + vy * vy);
+ if (ccw >= 0 && ccw <= 1) {
+ ccw = 0;
+ }
+ }
+ return ccw < 0 ? -1 : ccw > 0 ? 1 : 0;
+ };
+ Line.getSignedDistance = function (px, py, vx, vy, x, y, asVector) {
+ if (!asVector) {
+ vx -= px;
+ vy -= py;
+ }
+ return vx === 0 ? (vy > 0 ? x - px : px - x)
+ : vy === 0 ? (vx < 0 ? y - py : py - y)
+ : ((x - px) * vy - (y - py) * vx) / (
+ vy > vx
+ ? vy * Math.sqrt(1 + (vx * vx) / (vy * vy))
+ : vx * Math.sqrt(1 + (vy * vy) / (vx * vx))
+ );
+ };
+ Line.getDistance = function (px, py, vx, vy, x, y, asVector) {
+ return Math.abs(Line.getSignedDistance(px, py, vx, vy, x, y, asVector));
+ };
+
+ const Item = function () { };
+ InitClassWithStatics(Item, Base);
+
+ Item.prototype._applyMatrix = true;
+ Item.prototype._canApplyMatrix = true;
+ Item.prototype._pivot = null;
+ Item.prototype._initialize = function (props, point) {
+ const hasProps = props && Base.isPlainObject(props);
+ const isInternal = hasProps && props.internal === true;
+ const matrix = this._matrix = new Matrix();
+ const settings = {
+ applyMatrix: true,
+ };
+ this._id = isInternal ? null : UID.get();
+ this._parent = this._index = null;
+ this._applyMatrix = this._canApplyMatrix && settings.applyMatrix;
+ if (point)
+ matrix.translate(point);
+ matrix._owner = this;
+ return hasProps;
+ };
+ Item.prototype._changed = function (flags) {
+ if (flags & 8) {
+ this._bounds = this._position = this._decomposed = undefined;
+ }
+ if (flags & 16) {
+ this._globalMatrix = undefined;
+ }
+ if (this._parent && (flags & 72)) {
+ Item._clearBoundsCache(this._parent);
+ }
+ if (flags & 2) {
+ Item._clearBoundsCache(this);
+ }
+ };
+ Item.prototype.getPosition = function (_dontLink) {
+ const position = this._position || (this._position = this._getPositionFromBounds());
+ return new Point(position.x, position.y, this);
+ };
+ Item.prototype.setPosition = function () {
+ this.translate(Point.read(arguments).subtract(this.getPosition(true)));
+ };
+ Item.prototype._getPositionFromBounds = function (bounds) {
+ return this._pivot
+ ? this._matrix._transformPoint(this._pivot)
+ : (bounds || this.getBounds()).getCenter(true);
+ };
+ Item.prototype.setPivot = function () {
+ this._pivot = Point.read(arguments, 0, { clone: true, readNull: true });
+ this._position = undefined;
+ };
+ Item.prototype.getBounds = function (matrix) {
+ const opts = Object.assign({}, matrix);
+ opts.cacheItem = this;
+ const rect = this._getCachedBounds(false, opts).rect;
+ return !!arguments.length
+ ? rect
+ : new Rectangle(rect.x, rect.y, rect.width, rect.height);
+ };
+ Item.prototype.setBounds = function () {
+ const rect = Rectangle.read(arguments);
+ let bounds = this.getBounds();
+ const matrix = new Matrix();
+ let center = rect.getCenter();
+ matrix.translate(center);
+ if (rect.width != bounds.width || rect.height != bounds.height) {
+ if (!this._matrix.isInvertible()) {
+ this._matrix.set(this._matrix._backup || new Matrix().translate(this._matrix.getTranslation()));
+ bounds = this.getBounds();
+ }
+ matrix.scale(
+ bounds.width !== 0 ? rect.width / bounds.width : 0,
+ bounds.height !== 0 ? rect.height / bounds.height : 0);
+ }
+ center = bounds.getCenter();
+ matrix.translate(-center.x, -center.y);
+ this.transform(matrix);
+ };
+ Item.prototype._getBounds = function (matrix, options) {
+ if (!this._children || !this._children.length) {
+ return new Rectangle();
+ }
+ Item._updateBoundsCache(this, options.cacheItem);
+ return Item._getBounds(this._children, matrix, options);
+ };
+ Item.prototype._getBoundsCacheKey = function (options, internal) {
+ return [
+ options.stroke ? 1 : 0,
+ options.handle ? 1 : 0,
+ internal ? 1 : 0
+ ].join('');
+ };
+ Item.prototype._getCachedBounds = function (matrix, options, noInternal) {
+ matrix = matrix && matrix._orNullIfIdentity();
+ const isInternal = options.internal && !noInternal;
+ const cacheItem = options.cacheItem;
+ const _matrix = isInternal ? null : this._matrix._orNullIfIdentity();
+ const cacheKey = cacheItem && (!matrix || matrix.equals(_matrix)) && this._getBoundsCacheKey(options, isInternal);
+ Item._updateBoundsCache(this._parent, cacheItem);
+ let cached;
+ if (cacheKey && this._bounds && cacheKey in this._bounds) {
+ cached = this._bounds[cacheKey];
+ return {
+ rect: cached.rect.clone(),
+ nonscaling: cached.nonscaling
+ };
+ }
+ const res = this._getBounds(matrix || _matrix, options);
+ const rect = res.rect || res;
+ const nonscaling = res.nonscaling;
+ if (cacheKey) {
+ if (!this._bounds) {
+ this._bounds = this._bounds = {};
+ }
+ cached = this._bounds[cacheKey] = {
+ rect: rect.clone(),
+ nonscaling: nonscaling,
+ internal: isInternal
+ };
+ }
+ return {
+ rect: rect,
+ nonscaling: nonscaling
+ };
+ };
+ Item.prototype._decompose = function () {
+ return this._applyMatrix
+ ? null
+ : this._decomposed || (this._decomposed = this._matrix.decompose());
+ };
+ Item.prototype.getRotation = function () {
+ const decomposed = this._decompose();
+ return decomposed ? decomposed.rotation : 0;
+ };
+ Item.prototype.setApplyMatrix = function (apply) {
+ if (this._applyMatrix = this._canApplyMatrix && !!apply)
+ this.transform(null, true);
+ };
+ Item.prototype._getOwner = Item.prototype.getParent = function () {
+ return this._parent;
+ };
+ Item.prototype.getChildren = function () {
+ return this._children;
+ };
+ Item.prototype.setChildren = function (items) {
+ this.removeChildren();
+ this.addChildren(items);
+ };
+ Item.prototype.getFirstChild = function () {
+ return this._children && this._children[0] || null;
+ };
+ Item.prototype.getLastChild = function () {
+ return this._children && this._children[this._children.length - 1]
+ || null;
+ };
+ Item.prototype.getNextSibling = function () {
+ const owner = this._getOwner();
+ return owner && owner._children[this._index + 1] || null;
+ };
+ Item.prototype.getPreviousSibling = function () {
+ const owner = this._getOwner();
+ return owner && owner._children[this._index - 1] || null;
+ };
+ Item.prototype.getIndex = function () {
+ return this._index;
+ };
+ Item.prototype.equals = function (item) {
+ return item === this || item
+ && this._matrix.equals(item._matrix)
+ && this._equals(item);
+ };
+ Item.prototype._equals = function (item) {
+ return Base.equals(this._children, item._children);
+ };
+ Item.prototype.clone = function (options) {
+ const copy = new this.constructor({ insert: false });
+ if (this._children)
+ copy.copyAttributes(this);
+
+ const deep = Base.pick(options ? options.deep : undefined, true);
+ if (!this._children || deep)
+ copy.copyContent(this);
+
+ if (!this._children)
+ copy.copyAttributes(this);
+
+ const shouldInsert = Base.pick(options ? options.insert : undefined, options === undefined || options === true);
+ if (shouldInsert)
+ copy.insertAbove(this);
+ return copy;
+ };
+ Item.prototype.copyContent = function (source) {
+ for (let i = 0, l = source._children && source._children.length; i < l; i++) {
+ this.addChild(source._children[i].clone(false), true);
+ }
+ };
+ Item.prototype.copyAttributes = function (source, excludeMatrix) {
+ if (!excludeMatrix)
+ this._matrix.set(source._matrix, true);
+ this.setApplyMatrix(source._applyMatrix);
+ this.setPivot(source._pivot);
+ const data = source._data;
+ this._data = data ? Object.assign(new data.constructor(), data) : null;
+ };
+ Item.prototype.contains = function () {
+ return (
+ this._matrix.isInvertible() &&
+ !!this._contains(this._matrix._inverseTransform(Point.read(arguments)))
+ );
+ };
+ Item.prototype._contains = function (point) {
+ if (this._children) {
+ for (let i = this._children.length - 1; i >= 0; i--) {
+ if (this._children[i].contains(point))
+ return true;
+ }
+ return false;
+ }
+ return point.isInside(this.getInternalBounds());
+ };
+ Item.prototype.isInside = function () {
+ return Rectangle.read(arguments).contains(this.getBounds());
+ };
+ Item.prototype.addChild = function (item) {
+ return this.insertChild(undefined, item);
+ };
+ Item.prototype.insertChild = function (index, item) {
+ const res = item ? this.insertChildren(index, [item]) : null;
+ return res && res[0];
+ };
+ Item.prototype.addChildren = function (items) {
+ return this.insertChildren(this._children.length, items);
+ };
+ Item.prototype.insertChildren = function (index, items) {
+ if (this._children && items && items.length > 0) {
+ items = Base.slice(items);
+ const inserted = {};
+ for (let i = items.length - 1; i >= 0; i--) {
+ const item = items[i],
+ id = item && item._id;
+ if (!item || inserted[id]) {
+ items.splice(i, 1);
+ } else {
+ item._remove(false, true);
+ inserted[id] = true;
+ }
+ }
+ Base.splice(this._children, items, index, 0);
+ for (let i = 0, l = items.length; i < l; i++) {
+ const item = items[i];
+ item._parent = this;
+ }
+ this._changed(11);
+ } else {
+ items = null;
+ }
+ return items;
+ };
+ Item.prototype._insertAt = function (item, offset) {
+ const owner = item && item._getOwner(),
+ res = item !== this && owner ? this : null;
+ if (res) {
+ res._remove(false, true);
+ owner._insertChild(item._index + offset, res);
+ }
+ return res;
+ };
+ Item.prototype._insertChild = function(index, item) {
+ var res = item ? this.insertChildren(index, [item]) : null;
+ return res && res[0];
+ };
+ Item.prototype.insertAbove = function (item) {
+ return this._insertAt(item, 1);
+ };
+ Item.prototype.insertBelow = function (item) {
+ return this._insertAt(item, 0);
+ };
+ Item.prototype.reduce = function (options) {
+ if (this._children && this._children.length === 1) {
+ const child = this._children[0].reduce(options);
+ if (this._parent) {
+ child.insertAbove(this);
+ this.remove();
+ } else {
+ child.remove();
+ }
+ return child;
+ }
+ return this;
+ };
+ Item.prototype._remove = function (notifySelf, notifyParent) {
+ const owner = this._getOwner();
+ if (owner) {
+ if (this._index != null) {
+ Base.splice(owner._children, null, this._index, 1);
+ }
+ if (notifyParent)
+ owner._changed(11, this);
+ this._parent = null;
+ return true;
+ }
+ return false;
+ };
+ Item.prototype.remove = function () {
+ return this._remove(true, true);
+ };
+ Item.prototype.replaceWith = function (item) {
+ const ok = item && item.insertBelow(this);
+ if (ok) { this.remove(); }
+ return ok;
+ };
+ Item.prototype.clear = Item.prototype.removeChildren = function (start, end) {
+ if (!this._children) { return null; }
+ start = start || 0;
+ end = Base.pick(end, this._children.length);
+ const removed = Base.splice(this._children, null, start, end - start);
+ for (let i = removed.length - 1; i >= 0; i--) {
+ removed[i]._remove(true, false);
+ }
+ if (removed.length > 0)
+ this._changed(11);
+ return removed;
+ };
+ Item.prototype.isEmpty = function (recursively) {
+ const numChildren = this._children ? this._children.length : 0;
+ if (recursively) {
+ for (let i = 0; i < numChildren; i++) {
+ if (!this._children[i].isEmpty(recursively)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return !numChildren;
+ };
+ Item.prototype._getOrder = function (item) {
+ function getList(item) {
+ const list = [];
+ do {
+ list.unshift(item);
+ } while (item = item._parent);
+ return list;
+ }
+ const list1 = getList(this);
+ const list2 = getList(item);
+ for (let i = 0, l = Math.min(list1.length, list2.length); i < l; i++) {
+ if (list1[i] != list2[i]) {
+ return list1[i]._index < list2[i]._index ? 1 : -1;
+ }
+ }
+ return 0;
+ };
+ Item.prototype.translate = function () {
+ const mx = new Matrix();
+ return this.transform(mx.translate.apply(mx, arguments));
+ };
+ Item.prototype.transform = function (matrix, _applyRecursively, _setApplyMatrix) {
+ const _matrix = this._matrix;
+ const transformMatrix = matrix && !matrix.isIdentity();
+ let applyMatrix = (
+ _setApplyMatrix && this._canApplyMatrix ||
+ this._applyMatrix && (transformMatrix || !_matrix.isIdentity() || _applyRecursively && this._children)
+ );
+ if (!transformMatrix && !applyMatrix) { return this; }
+ if (transformMatrix) {
+ if (!matrix.isInvertible() && _matrix.isInvertible())
+ _matrix._backup = _matrix.getValues();
+ _matrix.prepend(matrix, true);
+ }
+
+ if (applyMatrix && (applyMatrix = this._transformContent(_matrix, _applyRecursively, _setApplyMatrix))) {
+ if (this._pivot)
+ _matrix._transformPoint(this._pivot, this._pivot, true);
+ _matrix.reset(true);
+ if (_setApplyMatrix && this._canApplyMatrix)
+ this._applyMatrix = true;
+ }
+ const bounds = this._bounds;
+ const position = this._position;
+ if (transformMatrix || applyMatrix) {
+ this._changed(25);
+ }
+ const decomp = transformMatrix && bounds && matrix.decompose();
+ if (decomp && decomp.skewing.isZero() && decomp.rotation % 90 === 0) {
+ for (let key in bounds) {
+ const cache = bounds[key];
+ if (cache.nonscaling) {
+ delete bounds[key];
+ } else if (applyMatrix || !cache.internal) {
+ matrix._transformBounds(cache.rect, cache.rect);
+ }
+ }
+ this._bounds = bounds;
+ const cached = bounds['000'];
+ if (cached) {
+ this._position = this._getPositionFromBounds(cached.rect);
+ }
+ } else if (transformMatrix && position && this._pivot) {
+ this._position = matrix._transformPoint(position, position);
+ }
+ return this;
+ };
+ Item.prototype._transformContent = function (matrix, applyRecursively, setApplyMatrix) {
+ const children = this._children;
+ if (children) {
+ for (let i = 0, l = children.length; i < l; i++) {
+ children[i].transform(matrix, applyRecursively, setApplyMatrix);
+ }
+ return true;
+ }
+ };
+
+ Item._updateBoundsCache = function (parent, item) {
+ if (parent && item) {
+ const id = item._id;
+ const ref = parent._boundsCache = parent._boundsCache || { ids: {}, list: [] };
+ if (!ref.ids[id]) {
+ ref.list.push(item);
+ ref.ids[id] = item;
+ }
+ }
+ };
+ Item._clearBoundsCache = function (item) {
+ const cache = item._boundsCache;
+ if (cache) {
+ item._bounds = item._position = item._boundsCache = undefined;
+ for (let i = 0, list = cache.list, l = list.length; i < l; i++) {
+ const other = list[i];
+ if (other !== item) {
+ other._bounds = other._position = undefined;
+ if (other._boundsCache)
+ Item._clearBoundsCache(other);
+ }
+ }
+ }
+ };
+ Item._getBounds = function (items, matrix, options) {
+ let x1 = Infinity;
+ let x2 = -x1;
+ let y1 = x1;
+ let y2 = x2;
+ let nonscaling = false;
+ options = options || {};
+ for (let i = 0, l = items.length; i < l; i++) {
+ const item = items[i];
+ if (!item.isEmpty(true)) {
+ const bounds = item._getCachedBounds(matrix && matrix.appended(item._matrix), options, true);
+ x1 = Math.min(bounds.rect.x, x1);
+ y1 = Math.min(bounds.rect.y, y1);
+ x2 = Math.max(bounds.rect.x + bounds.rect.width, x2);
+ y2 = Math.max(bounds.rect.y + bounds.rect.height, y2);
+ if (bounds.nonscaling)
+ nonscaling = true;
+ }
+ }
+ return {
+ rect: isFinite(x1)
+ ? new Rectangle(x1, y1, x2 - x1, y2 - y1)
+ : new Rectangle(),
+ nonscaling: nonscaling
+ };
+ };
+
+ const Segment = function (arg0, arg1, arg2, arg3, arg4, arg5) {
+ for (let i = 0, l = arguments.length; i < l; i++) {
+ const src = arguments[i];
+ if (src)
+ Object.assign(this, src);
+ }
+ const count = arguments.length;
+ let point, handleIn, handleOut;
+ if (count > 0) {
+ if (arg0 == null || typeof arg0 === 'object') {
+ if (count === 1 && arg0 && arg0.point) {
+ point = arg0.point;
+ handleIn = arg0.handleIn;
+ handleOut = arg0.handleOut;
+ } else {
+ point = arg0;
+ handleIn = arg1;
+ handleOut = arg2;
+ }
+ } else {
+ point = [arg0, arg1];
+ handleIn = arg2 !== undefined ? [arg2, arg3] : null;
+ handleOut = arg4 !== undefined ? [arg4, arg5] : null;
+ }
+ }
+ this._point = new Point(point, this);
+ this._handleIn = new Point(handleIn, this);
+ this._handleOut = new Point(handleOut, this);
+ };
+ InitClassWithStatics(Segment, Base);
+
+ Segment.prototype._changed = function (point) {
+ if (!this._path) { return; }
+
+ const curves = this._path._curves;
+ const index = this._index;
+ let curve;
+ if (curves) {
+ if ((!point || point === this._point || point === this._handleIn) && (curve = index > 0 ? curves[index - 1] : this._path._closed ? curves[curves.length - 1] : null))
+ curve._changed();
+ if ((!point || point === this._point || point === this._handleOut) && (curve = curves[index]))
+ curve._changed();
+ }
+ this._path._changed(41);
+ };
+ Segment.prototype.getPoint = function () {
+ return this._point;
+ };
+ Segment.prototype.getHandleIn = function () {
+ return this._handleIn;
+ };
+ Segment.prototype.setHandleIn = function () {
+ this._handleIn.set(Point.read(arguments));
+ };
+ Segment.prototype.getHandleOut = function () {
+ return this._handleOut;
+ };
+ Segment.prototype.setHandleOut = function () {
+ const newPoint = Point.read(arguments)
+ this._handleOut.set(newPoint);
+ };
+ Segment.prototype.hasHandles = function () {
+ return !this._handleIn.isZero() || !this._handleOut.isZero();
+ };
+ Segment.prototype.isSmooth = function () {
+ return !this._handleIn.isZero() && !this._handleOut.isZero() && this._handleIn.isCollinear(this._handleOut);
+ };
+ Segment.prototype.clearHandles = function () {
+ this._handleIn._set(0, 0);
+ this._handleOut._set(0, 0);
+ };
+ Segment.prototype.getIndex = function () {
+ return this._index !== undefined ? this._index : null;
+ };
+ Segment.prototype.getPath = function () {
+ return this._path || null;
+ };
+ Segment.prototype.getCurve = function () {
+ const path = this._path;
+ let index = this._index;
+ if (path) {
+ if (index > 0 && !path._closed
+ && index === path._segments.length - 1)
+ index--;
+ return path.getCurves()[index] || null;
+ }
+ return null;
+ };
+ Segment.prototype.getLocation = function () {
+ const curve = this.getCurve();
+ return curve ? new CurveLocation(curve, this === curve._segment1 ? 0 : 1) : null;
+ };
+ Segment.prototype.getNext = function () {
+ const segments = this._path && this._path._segments;
+ return segments && (segments[this._index + 1] || this._path._closed && segments[0]) || null;
+ };
+ Segment.prototype.getPrevious = function () {
+ const segments = this._path && this._path._segments;
+ return segments && (segments[this._index - 1] || this._path._closed && segments[segments.length - 1]) || null;
+ };
+ Segment.prototype.isFirst = function () {
+ return !this._index;
+ };
+ Segment.prototype.isLast = function () {
+ return this._path && this._index === this._path._segments.length - 1 || false;
+ };
+ Segment.prototype.reverse = function () {
+ const handleIn = this._handleIn;
+ const handleOut = this._handleOut;
+ const tmp = handleIn.clone();
+ handleIn.set(handleOut);
+ handleOut.set(tmp);
+ };
+ Segment.prototype.reversed = function () {
+ return new Segment(this._point, this._handleOut, this._handleIn);
+ };
+ Segment.prototype.remove = function () {
+ return this._path ? !!this._path.removeSegment(this._index) : false;
+ };
+ Segment.prototype.clone = function () {
+ return new Segment(this._point, this._handleIn, this._handleOut);
+ };
+ Segment.prototype.equals = function (segment) {
+ return segment === this || segment
+ && this._point.equals(segment._point)
+ && this._handleIn.equals(segment._handleIn)
+ && this._handleOut.equals(segment._handleOut)
+ || false;
+ };
+ Segment.prototype.transform = function (matrix) {
+ this._transformCoordinates(matrix, new Array(6), true);
+ this._changed();
+ };
+ Segment.prototype._transformCoordinates = function (matrix, coords, change) {
+ const handleIn = !change || !this._handleIn.isZero() ? this._handleIn : null;
+ const handleOut = !change || !this._handleOut.isZero() ? this._handleOut : null;
+ let x = this._point.getX();
+ let y = this._point.getY();
+ let i = 2;
+ coords[0] = x;
+ coords[1] = y;
+ if (handleIn) {
+ coords[i++] = handleIn.getX() + x;
+ coords[i++] = handleIn.getY() + y;
+ }
+ if (handleOut) {
+ coords[i++] = handleOut.getX() + x;
+ coords[i++] = handleOut.getY() + y;
+ }
+ if (matrix) {
+ matrix._transformCoordinates(coords, coords, i / 2);
+ x = coords[0];
+ y = coords[1];
+ if (change) {
+ this._point.x = x;
+ this._point.y = y;
+ i = 2;
+ if (handleIn) {
+ handleIn.x = coords[i++] - x;
+ handleIn.y = coords[i++] - y;
+ }
+ if (handleOut) {
+ handleOut.x = coords[i++] - x;
+ handleOut.y = coords[i++] - y;
+ }
+ } else {
+ if (!handleIn) {
+ coords[i++] = x;
+ coords[i++] = y;
+ }
+ if (!handleOut) {
+ coords[i++] = x;
+ coords[i++] = y;
+ }
+ }
+ }
+ return coords;
+ };
+
+ const Curve = function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
+ const count = arguments.length;
+ let seg1, seg2;
+ let point1, point2;
+ let handle1, handle2;
+ if (count === 3) {
+ this._path = arg0;
+ seg1 = arg1;
+ seg2 = arg2;
+ } else if (!count) {
+ seg1 = new Segment();
+ seg2 = new Segment();
+ } else if (count === 1) {
+ if (arg0.segment1) {
+ seg1 = new Segment(arg0.segment1);
+ seg2 = new Segment(arg0.segment2);
+ } else if (arg0.point1) {
+ point1 = arg0.point1;
+ handle1 = arg0.handle1;
+ handle2 = arg0.handle2;
+ point2 = arg0.point2;
+ } else if (Array.isArray(arg0)) {
+ point1 = [arg0[0], arg0[1]];
+ point2 = [arg0[6], arg0[7]];
+ handle1 = [arg0[2] - arg0[0], arg0[3] - arg0[1]];
+ handle2 = [arg0[4] - arg0[6], arg0[5] - arg0[7]];
+ }
+ } else if (count === 2) {
+ seg1 = new Segment(arg0);
+ seg2 = new Segment(arg1);
+ } else if (count === 4) {
+ point1 = arg0;
+ handle1 = arg1;
+ handle2 = arg2;
+ point2 = arg3;
+ } else if (count === 8) {
+ point1 = [arg0, arg1];
+ point2 = [arg6, arg7];
+ handle1 = [arg2 - arg0, arg3 - arg1];
+ handle2 = [arg4 - arg6, arg5 - arg7];
+ }
+ this._segment1 = seg1 || new Segment(point1, null, handle1);
+ this._segment2 = seg2 || new Segment(point2, handle2, null);
+ };
+ InitClassWithStatics(Curve, Base);
+
+ Curve.prototype._changed = function () {
+ this._length = this._bounds = undefined;
+ };
+ Curve.prototype.clone = function () {
+ return new Curve(this._segment1, this._segment2);
+ };
+ Curve.prototype.classify = function () {
+ return Curve.classify(this.getValues());
+ };
+ Curve.prototype.remove = function () {
+ let removed = false;
+ if (this._path) {
+ const segment2 = this._segment2;
+ const handleOut = segment2._handleOut;
+ removed = segment2.remove();
+ if (removed)
+ this._segment1._handleOut.set(handleOut);
+ }
+ return removed;
+ };
+ Curve.prototype.getPoint1 = function () {
+ return this._segment1._point;
+ };
+ Curve.prototype.getPoint2 = function () {
+ return this._segment2._point;
+ };
+ Curve.prototype.getSegment1 = function () {
+ return this._segment1;
+ };
+ Curve.prototype.getSegment2 = function () {
+ return this._segment2;
+ };
+ Curve.prototype.getPath = function () {
+ return this._path;
+ };
+ Curve.prototype.getIndex = function () {
+ return this._segment1._index;
+ };
+ Curve.prototype.getNext = function () {
+ const curves = this._path && this._path._curves;
+ return curves && (curves[this._segment1._index + 1]
+ || this._path._closed && curves[0]) || null;
+ };
+ Curve.prototype.getPrevious = function () {
+ const curves = this._path && this._path._curves;
+ return curves && (curves[this._segment1._index - 1]
+ || this._path._closed && curves[curves.length - 1]) || null;
+ };
+ Curve.prototype.isFirst = function () {
+ return !this._segment1._index;
+ };
+ Curve.prototype.isLast = function () {
+ const path = this._path;
+ return path && this._segment1._index === path._curves.length - 1
+ || false;
+ };
+ Curve.prototype.getValues = function (matrix) {
+ return Curve.getValues(this._segment1, this._segment2, matrix);
+ };
+ Curve.prototype.getLength = function () {
+ if (this._length == null)
+ this._length = Curve.getLength(this.getValues(), 0, 1);
+ return this._length;
+ };
+ Curve.prototype.getArea = function () {
+ return Curve.getArea(this.getValues());
+ };
+ Curve.prototype.getLine = function () {
+ return new Line(this._segment1._point, this._segment2._point);
+ };
+ Curve.prototype.getPart = function (from, to) {
+ return new Curve(Curve.getPart(this.getValues(), from, to));
+ };
+ Curve.prototype.getPartLength = function (from, to) {
+ return Curve.getLength(this.getValues(), from, to);
+ };
+ Curve.prototype.divideAtTime = function (time, _setHandles) {
+ const tMin = 1e-8, tMax = 1 - tMin;
+ let res = null;
+ if (time >= tMin && time <= tMax) {
+ const parts = Curve.subdivide(this.getValues(), time);
+ const left = parts[0];
+ const right = parts[1];
+ const setHandles = _setHandles || this.hasHandles();
+ const seg1 = this._segment1;
+ const seg2 = this._segment2;
+ const path = this._path;
+ if (setHandles) {
+ seg1._handleOut._set(left[2] - left[0], left[3] - left[1]);
+ seg2._handleIn._set(right[4] - right[6], right[5] - right[7]);
+ }
+ const x = left[6];
+ const y = left[7];
+ const segment = new Segment(new Point(x, y),
+ setHandles && new Point(left[4] - x, left[5] - y),
+ setHandles && new Point(right[2] - x, right[3] - y)
+ );
+ if (path) {
+ path.insert(seg1._index + 1, segment);
+ res = this.getNext();
+ } else {
+ this._segment2 = segment;
+ this._changed();
+ res = new Curve(segment, seg2);
+ }
+ }
+ return res;
+ };
+ Curve.prototype.divide = function (offset, isTime) {
+ return this.divideAtTime(offset === undefined ? 0.5 : isTime ? offset
+ : this.getTimeAt(offset));
+ };
+ Curve.prototype.reversed = function () {
+ return new Curve(this._segment2.reversed(), this._segment1.reversed());
+ };
+ Curve.prototype.clearHandles = function () {
+ this._segment1._handleOut._set(0, 0);
+ this._segment2._handleIn._set(0, 0);
+ };
+ Curve.prototype.hasHandles = function () {
+ return !this._segment1._handleOut.isZero()
+ || !this._segment2._handleIn.isZero();
+ };
+ Curve.prototype.hasLength = function (epsilon) {
+ return (!this.getPoint1().equals(this.getPoint2()) || this.hasHandles())
+ && this.getLength() > (epsilon || 0);
+ };
+ Curve.prototype.isCollinear = function (curve) {
+ return curve && this.isStraight() && curve.isStraight()
+ && this.getLine().isCollinear(curve.getLine());
+ };
+ Curve.prototype.isStraight = function (epsilon) {
+ const test = function (p1, h1, h2, p2) {
+ if (h1.isZero() && h2.isZero()) {
+ return true;
+ } else {
+ const v = p2.subtract(p1);
+ if (v.isZero()) { return false; }
+ if (v.isCollinear(h1) && v.isCollinear(h2)) {
+ const l = new Line(p1, p2);
+ const epsilon = 1e-7;
+ if (l.getDistance(p1.add(h1)) < epsilon && l.getDistance(p2.add(h2)) < epsilon) {
+ const div = v.dot(v);
+ const s1 = v.dot(h1) / div;
+ const s2 = v.dot(h2) / div;
+ return s1 >= 0 && s1 <= 1 && s2 <= 0 && s2 >= -1;
+ }
+ }
+ }
+ return false;
+ }
+ return test(this._segment1._point, this._segment1._handleOut, this._segment2._handleIn, this._segment2._point, epsilon);
+ };
+ Curve.prototype.getLocationAt = function (offset, _isTime) {
+ return this.getLocationAtTime(_isTime ? offset : this.getTimeAt(offset));
+ };
+ Curve.prototype.getLocationAtTime = function (t) {
+ return t != null && t >= 0 && t <= 1
+ ? new CurveLocation(this, t)
+ : null;
+ };
+ Curve.prototype.getTimeAt = function (offset, start) {
+ return Curve.getTimeAt(this.getValues(), offset, start);
+ };
+ Curve.prototype.getTimesWithTangent = function () {
+ const tangent = Point.read(arguments);
+ return !tangent.isZero() ? Curve.getTimesWithTangent(this.getValues(), tangent) : [];
+ };
+ Curve.prototype.getTimeOf = function () {
+ return Curve.getTimeOf(this.getValues(), Point.read(arguments));
+ };
+ Curve.prototype.getNearestLocation = function () {
+ const point = Point.read(arguments);
+ const values = this.getValues();
+ const t = Curve.getNearestTime(values, point);
+ const pt = Curve.getPoint(values, t);
+ return new CurveLocation(this, t, pt, null, point.getDistance(pt));
+ };
+ Curve.prototype.getNearestPoint = function () {
+ const loc = this.getNearestLocation.apply(this, arguments);
+ return loc ? loc.getPoint() : loc;
+ };
+ Curve.prototype.getPointAt = function (location, _isTime) {
+ const values = this.getValues();
+ return Curve.getPoint(values, _isTime ? location : Curve.getTimeAt(values, location));
+ };
+ Curve.prototype.getPointAtTime = function (time) {
+ return Curve.getPoint(this.getValues(), time);
+ };
+ Curve.prototype.getTangentAt = function (location, _isTime) {
+ const values = this.getValues();
+ return Curve.getTangent(values, _isTime ? location : Curve.getTimeAt(values, location));
+ };
+ Curve.prototype.getTangentAtTime = function (time) {
+ return Curve.getTangent(this.getValues(), time);
+ };
+ Curve.prototype.getNormalAt = function (location, _isTime) {
+ const values = this.getValues();
+ return Curve.getNormal(values, _isTime ? location : Curve.getTimeAt(values, location));
+ };
+ Curve.prototype.getNormalAtTime = function (time) {
+ return Curve.getNormal(this.getValues(), time);
+ };
+ Curve.prototype.getWeightedTangentAt = function (location) {
+ const values = this.getValues();
+ return Curve.getWeightedTangent(values, location);
+ };
+ Curve.prototype.getWeightedNormalAt = function (location) {
+ const values = this.getValues();
+ return Curve.getWeightedNormal(values, location);
+ };
+ Curve.prototype.getCurvatureAt = function (location) {
+ const values = this.getValues();
+ return Curve.getCurvature(values, location);
+ };
+ Curve.prototype.getIntersections = function (curve) {
+ const v1 = this.getValues();
+ const v2 = curve && curve !== this && curve.getValues();
+ return v2
+ ? Curve.getCurveIntersections(v1, v2, this, curve, [])
+ : Curve.getSelfIntersection(v1, this, []);
+ };
+
+ Curve.getValues = function (segment1, segment2, matrix, straight) {
+ const p1 = segment1._point;
+ const h1 = segment1._handleOut;
+ const h2 = segment2._handleIn;
+ const p2 = segment2._point;
+ const x1 = p1.x;
+ const y1 = p1.y;
+ const x2 = p2.x;
+ const y2 = p2.y;
+ const values = straight
+ ? [x1, y1, x1, y1, x2, y2, x2, y2]
+ : [x1, y1, x1 + h1.getX(), y1 + h1.getY(), x2 + h2.getX(), y2 + h2.getY(), x2, y2];
+ if (matrix) { matrix._transformCoordinates(values, values, 4); }
+ return values;
+ };
+ Curve.subdivide = function (v, t) {
+ if (t === undefined) { t = 0.5; }
+ const x0 = v[0], y0 = v[1];
+ const x1 = v[2], y1 = v[3];
+ const x2 = v[4], y2 = v[5];
+ const x3 = v[6], y3 = v[7];
+ const u = 1 - t;
+ const x4 = u * x0 + t * x1;
+ const y4 = u * y0 + t * y1;
+ const x5 = u * x1 + t * x2;
+ const y5 = u * y1 + t * y2;
+ const x6 = u * x2 + t * x3;
+ const y6 = u * y2 + t * y3;
+ const x7 = u * x4 + t * x5;
+ const y7 = u * y4 + t * y5;
+ const x8 = u * x5 + t * x6;
+ const y8 = u * y5 + t * y6;
+ const x9 = u * x7 + t * x8;
+ const y9 = u * y7 + t * y8;
+ return [
+ [x0, y0, x4, y4, x7, y7, x9, y9],
+ [x9, y9, x8, y8, x6, y6, x3, y3]
+ ];
+ };
+ Curve.getMonoCurves = function (v, dir) {
+ const curves = [];
+ const io = dir ? 0 : 1;
+ const o0 = v[io + 0];
+ const o1 = v[io + 2];
+ const o2 = v[io + 4];
+ const o3 = v[io + 6];
+ if ((o0 >= o1) === (o1 >= o2) && (o1 >= o2) === (o2 >= o3) || Curve.isStraight(v)) {
+ curves.push(v);
+ } else {
+ const a = 3 * (o1 - o2) - o0 + o3;
+ const b = 2 * (o0 + o2) - 4 * o1;
+ const c = o1 - o0;
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+ const roots = [];
+ const n = Numerical.solveQuadratic(a, b, c, roots, tMin, tMax);
+ if (!n) {
+ curves.push(v);
+ } else {
+ roots.sort();
+ let t = roots[0];
+ let parts = Curve.subdivide(v, t);
+ curves.push(parts[0]);
+ if (n > 1) {
+ t = (roots[1] - t) / (1 - t);
+ parts = Curve.subdivide(parts[1], t);
+ curves.push(parts[0]);
+ }
+ curves.push(parts[1]);
+ }
+ }
+ return curves;
+ };
+ Curve.solveCubic = function (v, coord, val, roots, min, max) {
+ const v0 = v[coord];
+ const v1 = v[coord + 2];
+ const v2 = v[coord + 4];
+ const v3 = v[coord + 6];
+ let res = 0;
+ if (!(v0 < val && v3 < val && v1 < val && v2 < val || v0 > val && v3 > val && v1 > val && v2 > val)) {
+ const c = 3 * (v1 - v0);
+ const b = 3 * (v2 - v1) - c;
+ const a = v3 - v0 - c - b;
+ res = Numerical.solveCubic(a, b, c, v0 - val, roots, min, max);
+ }
+ return res;
+ };
+ Curve.getTimeOf = function (v, point) {
+ const p0 = new Point(v[0], v[1]);
+ const p3 = new Point(v[6], v[7]);
+ const t = point.isClose(p0, Numerical.EPSILON) ? 0
+ : point.isClose(p3, Numerical.EPSILON) ? 1
+ : null;
+ if (t === null) {
+ const coords = [point.x, point.y];
+ const roots = [];
+ for (let c = 0; c < 2; c++) {
+ const count = Curve.solveCubic(v, c, coords[c], roots, 0, 1);
+ for (let i = 0; i < count; i++) {
+ const u = roots[i];
+ if (point.isClose(Curve.getPoint(v, u), Numerical.GEOMETRIC_EPSILON))
+ return u;
+ }
+ }
+ }
+ return point.isClose(p0, Numerical.GEOMETRIC_EPSILON) ? 0
+ : point.isClose(p3, Numerical.GEOMETRIC_EPSILON) ? 1
+ : null;
+ };
+ Curve.getNearestTime = function (v, point) {
+ if (Curve.isStraight(v)) {
+ const x0 = v[0], y0 = v[1];
+ const x3 = v[6], y3 = v[7];
+ const vx = x3 - x0, vy = y3 - y0;
+ const det = vx * vx + vy * vy;
+ if (det === 0) { return 0; }
+
+ const u = ((point.x - x0) * vx + (point.y - y0) * vy) / det;
+ return u < Numerical.EPSILON ? 0
+ : u > 0.999999999999 ? 1
+ : Curve.getTimeOf(v, new Point(x0 + u * vx, y0 + u * vy));
+ }
+
+ const count = 100;
+ let minDist = Infinity;
+ let minT = 0;
+
+ function refine(t) {
+ if (t >= 0 && t <= 1) {
+ const dist = point.getDistance(Curve.getPoint(v, t), true);
+ if (dist < minDist) {
+ minDist = dist;
+ minT = t;
+ return true;
+ }
+ }
+ }
+
+ for (let i = 0; i <= count; i++)
+ refine(i / count);
+
+ let step = 1 / (count * 2);
+ while (step > 1e-8) {
+ if (!refine(minT - step) && !refine(minT + step))
+ step /= 2;
+ }
+ return minT;
+ };
+ Curve.getPart = function (v, from, to) {
+ const flip = from > to;
+ if (flip) {
+ const tmp = from;
+ from = to;
+ to = tmp;
+ }
+ if (from > 0)
+ v = Curve.subdivide(v, from)[1];
+ if (to < 1)
+ v = Curve.subdivide(v, (to - from) / (1 - from))[0];
+ return flip ? [v[6], v[7], v[4], v[5], v[2], v[3], v[0], v[1]] : v;
+ };
+ Curve.getArea = function (v) {
+ const x0 = v[0], y0 = v[1];
+ const x1 = v[2], y1 = v[3];
+ const x2 = v[4], y2 = v[5];
+ const x3 = v[6], y3 = v[7];
+ return 3 * ((y3 - y0) * (x1 + x2) - (x3 - x0) * (y1 + y2)
+ + y1 * (x0 - x2) - x1 * (y0 - y2)
+ + y3 * (x2 + x0 / 3) - x3 * (y2 + y0 / 3)) / 20;
+ };
+ Curve.getBounds = function (v) {
+ const min = v.slice(0, 2);
+ const max = min.slice();
+ const roots = [0, 0];
+ for (let i = 0; i < 2; i++)
+ Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6], i, 0, min, max, roots);
+ return new Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
+ };
+ Curve._addBounds = function (v0, v1, v2, v3, coord, padding, min, max, roots) {
+ function add(value, padding) {
+ const left = value - padding;
+ const right = value + padding;
+ if (left < min[coord])
+ min[coord] = left;
+ if (right > max[coord])
+ max[coord] = right;
+ }
+
+ padding /= 2;
+ const minPad = min[coord] + padding;
+ const maxPad = max[coord] - padding;
+ if (v0 < minPad || v1 < minPad || v2 < minPad || v3 < minPad ||
+ v0 > maxPad || v1 > maxPad || v2 > maxPad || v3 > maxPad) {
+ if (v1 < v0 != v1 < v3 && v2 < v0 != v2 < v3) {
+ add(v0, 0);
+ add(v3, 0);
+ } else {
+ const a = 3 * (v1 - v2) - v0 + v3;
+ const b = 2 * (v0 + v2) - 4 * v1;
+ const c = v1 - v0;
+ const count = Numerical.solveQuadratic(a, b, c, roots);
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+ add(v3, 0);
+ for (let i = 0; i < count; i++) {
+ const t = roots[i];
+ const u = 1 - t;
+ if (tMin <= t && t <= tMax)
+ add(u * u * u * v0
+ + 3 * u * u * t * v1
+ + 3 * u * t * t * v2
+ + t * t * t * v3,
+ padding
+ );
+ }
+ }
+ }
+ };
+ Curve.isStraight = function (v, epsilon) {
+ const x0 = v[0];
+ const y0 = v[1];
+ const x3 = v[6];
+ const y3 = v[7];
+
+ function test(p1, h1, h2, p2) {
+ if (h1.isZero() && h2.isZero()) {
+ return true;
+ } else {
+ const v = p2.subtract(p1);
+ if (v.isZero()) { return false; }
+
+ if (v.isCollinear(h1) && v.isCollinear(h2)) {
+ const l = new Line(p1, p2);
+ if (l.getDistance(p1.add(h1)) < Numerical.GEOMETRIC_EPSILON &&
+ l.getDistance(p2.add(h2)) < Numerical.GEOMETRIC_EPSILON) {
+ const div = v.dot(v);
+ const s1 = v.dot(h1) / div;
+ const s2 = v.dot(h2) / div;
+ return s1 >= 0 && s1 <= 1 && s2 <= 0 && s2 >= -1;
+ }
+ }
+ }
+ return false;
+ };
+
+ return test(
+ new Point(x0, y0),
+ new Point(v[2] - x0, v[3] - y0),
+ new Point(v[4] - x3, v[5] - y3),
+ new Point(x3, y3), epsilon);
+ };
+ Curve.getLengthIntegrand = function (v) {
+ const x0 = v[0], y0 = v[1];
+ const x1 = v[2], y1 = v[3];
+ const x2 = v[4], y2 = v[5];
+ const x3 = v[6], y3 = v[7];
+
+ const ax = 9 * (x1 - x2) + 3 * (x3 - x0);
+ const bx = 6 * (x0 + x2) - 12 * x1;
+ const cx = 3 * (x1 - x0);
+
+ const ay = 9 * (y1 - y2) + 3 * (y3 - y0);
+ const by = 6 * (y0 + y2) - 12 * y1;
+ const cy = 3 * (y1 - y0);
+
+ return function (t) {
+ const dx = (ax * t + bx) * t + cx;
+ const dy = (ay * t + by) * t + cy;
+ return Math.sqrt(dx * dx + dy * dy);
+ };
+ };
+ Curve.getIterations = function (a, b) {
+ return Math.max(2, Math.min(16, Math.ceil(Math.abs(b - a) * 32)));
+ };
+ Curve.evaluate = function (v, t, type, normalized) {
+ if (t == null || t < 0 || t > 1) { return null; }
+
+ let x0 = v[0];
+ let y0 = v[1];
+ let x1 = v[2];
+ let y1 = v[3];
+ let x2 = v[4];
+ let y2 = v[5];
+ let x3 = v[6];
+ let y3 = v[7];
+ if (Numerical.isZero(x1 - x0) && Numerical.isZero(y1 - y0)) {
+ x1 = x0;
+ y1 = y0;
+ }
+ if (Numerical.isZero(x2 - x3) && Numerical.isZero(y2 - y3)) {
+ x2 = x3;
+ y2 = y3;
+ }
+ const cx = 3 * (x1 - x0);
+ const bx = 3 * (x2 - x1) - cx;
+ const ax = x3 - x0 - cx - bx;
+ const cy = 3 * (y1 - y0);
+ const by = 3 * (y2 - y1) - cy;
+ const ay = y3 - y0 - cy - by;
+ let x, y;
+ if (type === 0) {
+ x = t === 0
+ ? x0
+ : t === 1
+ ? x3
+ : ((ax * t + bx) * t + cx) * t + x0;
+ y = t === 0
+ ? y0
+ : t === 1
+ ? y3
+ : ((ay * t + by) * t + cy) * t + y0;
+ } else {
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+ if (t < tMin) {
+ x = cx;
+ y = cy;
+ } else if (t > tMax) {
+ x = 3 * (x3 - x2);
+ y = 3 * (y3 - y2);
+ } else {
+ x = (3 * ax * t + 2 * bx) * t + cx;
+ y = (3 * ay * t + 2 * by) * t + cy;
+ }
+ if (normalized) {
+ if (x === 0 && y === 0 && (t < tMin || t > tMax)) {
+ x = x2 - x1;
+ y = y2 - y1;
+ }
+ const len = Math.sqrt(x * x + y * y);
+ if (len) {
+ x /= len;
+ y /= len;
+ }
+ }
+ if (type === 3) {
+ const _x2 = 6 * ax * t + 2 * bx;
+ const _y2 = 6 * ay * t + 2 * by;
+ const d = Math.pow(x * x + y * y, 3 / 2);
+
+ x = d !== 0 ? (x * _y2 - y * _x2) / d : 0;
+ y = 0;
+ }
+ }
+ return type === 2 ? new Point(y, -x) : new Point(x, y);
+ };
+ Curve.classify = function (v) {
+ const x0 = v[0], y0 = v[1];
+ const x1 = v[2], y1 = v[3];
+ const x2 = v[4], y2 = v[5];
+ const x3 = v[6], y3 = v[7];
+ const a1 = x0 * (y3 - y2) + y0 * (x2 - x3) + x3 * y2 - y3 * x2;
+ const a2 = x1 * (y0 - y3) + y1 * (x3 - x0) + x0 * y3 - y0 * x3;
+ const a3 = x2 * (y1 - y0) + y2 * (x0 - x1) + x1 * y0 - y1 * x0;
+ let d3 = 3 * a3;
+ let d2 = d3 - a2;
+ let d1 = d2 - a2 + a1;
+ const l = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
+ const s = l !== 0 ? 1 / l : 0;
+ d1 *= s;
+ d2 *= s;
+ d3 *= s;
+
+ function type(type, t1, t2) {
+ const hasRoots = t1 !== undefined;
+ let t1Ok = hasRoots && t1 > 0 && t1 < 1;
+ let t2Ok = hasRoots && t2 > 0 && t2 < 1;
+ if (hasRoots && (!(t1Ok || t2Ok) || type === CURVE_TYPES.loop && !(t1Ok && t2Ok))) {
+ type = CURVE_TYPES.arc;
+ t1Ok = t2Ok = false;
+ }
+ return {
+ type: type,
+ roots: t1Ok || t2Ok
+ ? t1Ok && t2Ok
+ ? t1 < t2
+ ? [t1, t2]
+ : [t2, t1]
+ : [t1Ok ? t1 : t2]
+ : null
+ };
+ }
+
+ if (Numerical.isZero(d1)) {
+ return Numerical.isZero(d2)
+ ? type(Numerical.isZero(d3) ? CURVE_TYPES.line : CURVE_TYPES.quadratic)
+ : type(CURVE_TYPES.serpentine, d3 / (3 * d2));
+ }
+
+ const d = 3 * d2 * d2 - 4 * d1 * d3;
+ if (Numerical.isZero(d)) {
+ return type(CURVE_TYPES.cusp, d2 / (2 * d1));
+ }
+
+ const f1 = d > 0 ? Math.sqrt(d / 3) : Math.sqrt(-d);
+ const f2 = 2 * d1;
+ return type(d > 0 ? CURVE_TYPES.serpentine : CURVE_TYPES.loop, (d2 + f1) / f2, (d2 - f1) / f2);
+ };
+ Curve.getLength = function (v, a, b, ds) {
+ if (a === undefined) { a = 0; }
+ if (b === undefined) { b = 1; }
+
+ if (Curve.isStraight(v)) {
+ let c = v;
+ if (b < 1) {
+ c = Curve.subdivide(c, b)[0];
+ a /= b;
+ }
+ if (a > 0) {
+ c = Curve.subdivide(c, a)[1];
+ }
+ const dx = c[6] - c[0];
+ const dy = c[7] - c[1];
+ return Math.sqrt(dx * dx + dy * dy);
+ }
+ return Numerical.integrate(ds || Curve.getLengthIntegrand(v), a, b, Curve.getIterations(a, b));
+ };
+ Curve.getTimeAt = function (v, offset, start) {
+ if (start === undefined) { start = offset < 0 ? 1 : 0; }
+ if (offset === 0) { return start; }
+
+ const forward = offset > 0;
+ const a = forward ? start : 0;
+ const b = forward ? 1 : start;
+ const ds = Curve.getLengthIntegrand(v);
+ const rangeLength = Curve.getLength(v, a, b, ds);
+ const diff = Math.abs(offset) - rangeLength;
+
+ if (Math.abs(diff) < Numerical.EPSILON) {
+ return forward ? b : a;
+ } else if (diff > Numerical.EPSILON) {
+ return null;
+ }
+
+ let length = 0;
+ function f(t) {
+ length += Numerical.integrate(ds, start, t, Curve.getIterations(start, t));
+ start = t;
+ return length - offset;
+ }
+
+ const guess = offset / rangeLength;
+ return Numerical.findRoot(f, ds, start + guess, a, b, 32, Numerical.EPSILON);
+ };
+ Curve.getPoint = function (v, t) {
+ return Curve.evaluate(v, t, 0, false);
+ };
+ Curve.getTangent = function (v, t) {
+ return Curve.evaluate(v, t, 1, true);
+ };
+ Curve.getNormal = function (v, t) {
+ return Curve.evaluate(v, t, 2, true);
+ };
+ Curve.getWeightedNormal = function (v, t) {
+ return Curve.evaluate(v, t, 2, false);
+ };
+ Curve.getCurvature = function (v, t) {
+ return Curve.evaluate(v, t, 3, false).x;
+ };
+ Curve.getPeaks = function (v) {
+ const x0 = v[0], y0 = v[1], x1 = v[2], y1 = v[3], x2 = v[4], y2 = v[5], x3 = v[6], y3 = v[7];
+ const ax = -x0 + 3 * x1 - 3 * x2 + x3;
+ const bx = 3 * x0 - 6 * x1 + 3 * x2;
+ const cx = -3 * x0 + 3 * x1;
+ const ay = -y0 + 3 * y1 - 3 * y2 + y3;
+ const by = 3 * y0 - 6 * y1 + 3 * y2;
+ const cy = -3 * y0 + 3 * y1;
+
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+
+ const roots = [];
+ Numerical.solveCubic(
+ 9 * (ax * ax + ay * ay),
+ 9 * (ax * bx + by * ay),
+ 2 * (bx * bx + by * by) + 3 * (cx * ax + cy * ay),
+ (cx * bx + by * cy),
+ roots, tMin, tMax
+ );
+ return roots.sort();
+ };
+ Curve.addLocation = function (locations, include, c1, t1, c2, t2, overlap) {
+ const excludeStart = !overlap && c1.getPrevious() === c2;
+ const excludeEnd = !overlap && c1 !== c2 && c1.getNext() === c2;
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+ if (t1 !== null && t1 >= (excludeStart ? tMin : 0) && t1 <= (excludeEnd ? tMax : 1)) {
+ if (t2 !== null && t2 >= (excludeEnd ? tMin : 0) && t2 <= (excludeStart ? tMax : 1)) {
+ const loc1 = new CurveLocation(c1, t1, null, overlap);
+ const loc2 = new CurveLocation(c2, t2, null, overlap);
+ loc1._intersection = loc2;
+ loc2._intersection = loc1;
+ if (!include || include(loc1)) {
+ CurveLocation.insert(locations, loc1, true);
+ }
+ }
+ }
+ };
+ Curve.addCurveIntersections = function (v1, v2, c1, c2, locations, include, flip, recursion, calls, tMin, tMax, uMin, uMax) {
+ if (++calls >= 4096 || ++recursion >= 40)
+ return calls;
+
+ const fatLineEpsilon = 1e-9;
+ const q0x = v2[0], q0y = v2[1], q3x = v2[6], q3y = v2[7];
+
+ const d1 = Line.getSignedDistance(q0x, q0y, q3x, q3y, v2[2], v2[3]);
+ const d2 = Line.getSignedDistance(q0x, q0y, q3x, q3y, v2[4], v2[5]);
+
+ const factor = d1 * d2 > 0 ? 3 / 4 : 4 / 9;
+ const dMin = factor * Math.min(0, d1, d2);
+ const dMax = factor * Math.max(0, d1, d2);
+
+ const dp0 = Line.getSignedDistance(q0x, q0y, q3x, q3y, v1[0], v1[1]);
+ const dp1 = Line.getSignedDistance(q0x, q0y, q3x, q3y, v1[2], v1[3]);
+ const dp2 = Line.getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]);
+ const dp3 = Line.getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]);
+
+ const hull = Curve.getConvexHull(dp0, dp1, dp2, dp3);
+ const top = hull[0];
+ const bottom = hull[1];
+
+ let tMinClip;
+ let tMaxClip;
+ if (d1 === 0 && d2 === 0 && dp0 === 0 && dp1 === 0 && dp2 === 0 && dp3 === 0
+ || (tMinClip = Curve.clipConvexHull(top, bottom, dMin, dMax)) == null
+ || (tMaxClip = Curve.clipConvexHull(top.reverse(), bottom.reverse(), dMin, dMax)) == null) {
+ return calls;
+ }
+
+ const tMinNew = tMin + (tMax - tMin) * tMinClip;
+ const tMaxNew = tMin + (tMax - tMin) * tMaxClip;
+ if (Math.max(uMax - uMin, tMaxNew - tMinNew) < fatLineEpsilon) {
+ const t = (tMinNew + tMaxNew) / 2;
+ const u = (uMin + uMax) / 2;
+ Curve.addLocation(locations, include, flip ? c2 : c1, flip ? u : t, flip ? c1 : c2, flip ? t : u);
+ } else {
+ v1 = Curve.getPart(v1, tMinClip, tMaxClip);
+ const uDiff = uMax - uMin;
+ if (tMaxClip - tMinClip > 0.8) {
+ if (tMaxNew - tMinNew > uDiff) {
+ const parts = Curve.subdivide(v1, 0.5);
+ const t = (tMinNew + tMaxNew) / 2;
+ calls = Curve.addCurveIntersections(
+ v2, parts[0], c2, c1, locations, include, !flip,
+ recursion, calls, uMin, uMax, tMinNew, t);
+ calls = Curve.addCurveIntersections(
+ v2, parts[1], c2, c1, locations, include, !flip,
+ recursion, calls, uMin, uMax, t, tMaxNew);
+ } else {
+ const parts = Curve.subdivide(v2, 0.5);
+ const u = (uMin + uMax) / 2;
+ calls = Curve.addCurveIntersections(
+ parts[0], v1, c2, c1, locations, include, !flip,
+ recursion, calls, uMin, u, tMinNew, tMaxNew);
+ calls = Curve.addCurveIntersections(
+ parts[1], v1, c2, c1, locations, include, !flip,
+ recursion, calls, u, uMax, tMinNew, tMaxNew);
+ }
+ } else {
+ if (uDiff === 0 || uDiff >= fatLineEpsilon) {
+ calls = Curve.addCurveIntersections(
+ v2, v1, c2, c1, locations, include, !flip,
+ recursion, calls, uMin, uMax, tMinNew, tMaxNew);
+ } else {
+ calls = Curve.addCurveIntersections(
+ v1, v2, c1, c2, locations, include, flip,
+ recursion, calls, tMinNew, tMaxNew, uMin, uMax);
+ }
+ }
+ }
+ return calls;
+ };
+ Curve.getConvexHull = function (dq0, dq1, dq2, dq3) {
+ const p0 = [0, dq0];
+ const p1 = [1 / 3, dq1];
+ const p2 = [2 / 3, dq2];
+ const p3 = [1, dq3];
+ const dist1 = dq1 - (2 * dq0 + dq3) / 3;
+ const dist2 = dq2 - (dq0 + 2 * dq3) / 3;
+
+ let hull;
+ if (dist1 * dist2 < 0) {
+ hull = [[p0, p1, p3], [p0, p2, p3]];
+ } else {
+ const distRatio = dist1 / dist2;
+ hull = [
+ distRatio >= 2
+ ? [p0, p1, p3]
+ : distRatio <= 0.5
+ ? [p0, p2, p3]
+ : [p0, p1, p2, p3],
+ [p0, p3]
+ ];
+ }
+ return (dist1 || dist2) < 0 ? hull.reverse() : hull;
+ };
+ Curve.clipConvexHull = function (hullTop, hullBottom, dMin, dMax) {
+ if (hullTop[0][1] < dMin) {
+ return Curve.clipConvexHullPart(hullTop, true, dMin);
+ } else if (hullBottom[0][1] > dMax) {
+ return Curve.clipConvexHullPart(hullBottom, false, dMax);
+ } else {
+ return hullTop[0][0];
+ }
+ };
+ Curve.clipConvexHullPart = function (part, top, threshold) {
+ let px = part[0][0];
+ let py = part[0][1];
+ for (let i = 1, l = part.length; i < l; i++) {
+ const qx = part[i][0];
+ const qy = part[i][1];
+ if (top ? qy >= threshold : qy <= threshold) {
+ return qy === threshold ? qx : px + (threshold - py) * (qx - px) / (qy - py);
+ }
+ px = qx;
+ py = qy;
+ }
+ return null;
+ };
+ Curve.getCurveLineIntersections = function (v, px, py, vx, vy) {
+ if (Numerical.isZero(vx) && Numerical.isZero(vy)) {
+ const t = Curve.getTimeOf(v, new Point(px, py));
+ return t === null ? [] : [t];
+ }
+
+ const angle = Math.atan2(-vy, vx);
+ const sin = Math.sin(angle);
+ const cos = Math.cos(angle);
+ const rv = [];
+ const roots = [];
+ for (let i = 0; i < 8; i += 2) {
+ const x = v[i] - px;
+ const y = v[i + 1] - py;
+ rv.push(x * cos - y * sin, x * sin + y * cos);
+ }
+
+ Curve.solveCubic(rv, 1, 0, roots, 0, 1);
+ return roots;
+ };
+ Curve.addCurveLineIntersections = function (v1, v2, c1, c2, locations, include, flip) {
+ const x1 = v2[0];
+ const y1 = v2[1];
+ const x2 = v2[6];
+ const y2 = v2[7];
+ const roots = Curve.getCurveLineIntersections(v1, x1, y1, x2 - x1, y2 - y1);
+ for (let i = 0, l = roots.length; i < l; i++) {
+ const t1 = roots[i];
+ const p1 = Curve.getPoint(v1, t1);
+ const t2 = Curve.getTimeOf(v2, p1);
+ if (t2 !== null) {
+ flip
+ ? Curve.addLocation(locations, include, c2, t2, c1, t1)
+ : Curve.addLocation(locations, include, c1, t1, c2, t2);
+ }
+ }
+ };
+ Curve.addLineIntersection = function (v1, v2, c1, c2, locations, include) {
+ const pt = Line.intersect(v1[0], v1[1], v1[6], v1[7], v2[0], v2[1], v2[6], v2[7]);
+ if (pt) {
+ Curve.addLocation(locations, include,
+ c1, Curve.getTimeOf(v1, pt),
+ c2, Curve.getTimeOf(v2, pt)
+ );
+ }
+ };
+ Curve.getCurveIntersections = function (v1, v2, c1, c2, locations, include) {
+ if (Math.max(v1[0], v1[2], v1[4], v1[6]) + Numerical.EPSILON > Math.min(v2[0], v2[2], v2[4], v2[6])
+ && Math.min(v1[0], v1[2], v1[4], v1[6]) - Numerical.EPSILON < Math.max(v2[0], v2[2], v2[4], v2[6])
+ && Math.max(v1[1], v1[3], v1[5], v1[7]) + Numerical.EPSILON > Math.min(v2[1], v2[3], v2[5], v2[7])
+ && Math.min(v1[1], v1[3], v1[5], v1[7]) - Numerical.EPSILON < Math.max(v2[1], v2[3], v2[5], v2[7])) {
+ const overlaps = Curve.getOverlaps(v1, v2);
+ if (overlaps) {
+ for (let i = 0; i < 2; i++) {
+ const overlap = overlaps[i];
+ Curve.addLocation(locations, include, c1, overlap[0], c2, overlap[1], true);
+ }
+ } else {
+ const straight1 = Curve.isStraight(v1);
+ const straight2 = Curve.isStraight(v2);
+ const straight = straight1 && straight2;
+ const flip = straight1 && !straight2;
+ const before = locations.length;
+
+ const addIntersectionsFunction = straight
+ ? Curve.addLineIntersection
+ : straight1 || straight2
+ ? Curve.addCurveLineIntersections
+ : Curve.addCurveIntersections
+
+ flip
+ ? addIntersectionsFunction(v2, v1, c2, c1, locations, include, flip, 0, 0, 0, 1, 0, 1)
+ : addIntersectionsFunction(v1, v2, c1, c2, locations, include, flip, 0, 0, 0, 1, 0, 1);
+
+ if (!straight || locations.length === before) {
+ for (let i = 0; i < 4; i++) {
+ const t1 = i >> 1;
+ const t2 = i & 1;
+ const i1 = t1 * 6;
+ const i2 = t2 * 6;
+ const p1 = new Point(v1[i1], v1[i1 + 1]);
+ const p2 = new Point(v2[i2], v2[i2 + 1]);
+ if (p1.isClose(p2, Numerical.EPSILON)) {
+ Curve.addLocation(locations, include, c1, t1, c2, t2);
+ }
+ }
+ }
+ }
+ }
+ return locations;
+ };
+ Curve.getSelfIntersection = function (v1, c1, locations, include) {
+ const info = Curve.classify(v1);
+ if (info.type === CURVE_TYPES.loop) {
+ const roots = info.roots;
+ Curve.addLocation(locations, include, c1, roots[0], c1, roots[1]);
+ }
+ return locations;
+ };
+ Curve.getIntersections = function (curves1, curves2, include, matrix1, matrix2, _returnFirst) {
+ const epsilon = 1e-7;
+ const self = !curves2;
+ if (self)
+ curves2 = curves1;
+
+ const values1 = new Array(curves1.length);
+ const values2 = self ? values1 : new Array(curves2.length);
+ const locations = [];
+ for (let i = 0; i < curves1.length; i++) {
+ values1[i] = curves1[i].getValues(matrix1);
+ }
+ if (!self) {
+ for (let i = 0; i < curves2.length; i++) {
+ values2[i] = curves2[i].getValues(matrix2);
+ }
+ }
+
+ const boundsCollisions = CollisionDetection.findCurveBoundsCollisions(values1, values2, epsilon);
+ for (let index1 = 0; index1 < curves1.length; index1++) {
+ const curve1 = curves1[index1];
+ const v1 = values1[index1];
+ if (self) { Curve.getSelfIntersection(v1, curve1, locations, include); }
+
+ const collisions1 = boundsCollisions[index1];
+ if (collisions1) {
+ for (let j = 0; j < collisions1.length; j++) {
+ if (_returnFirst && locations.length)
+ return locations;
+
+ const index2 = collisions1[j];
+ if (!self || index2 > index1) {
+ const curve2 = curves2[index2];
+ const v2 = values2[index2];
+ Curve.getCurveIntersections(v1, v2, curve1, curve2, locations, include);
+ }
+ }
+ }
+ }
+ return locations;
+ };
+ Curve.getOverlaps = function (v1, v2) {
+
+ function getSquaredLineLength(v) {
+ const x = v[6] - v[0];
+ const y = v[7] - v[1];
+ return x * x + y * y;
+ }
+
+ const timeEpsilon = 1e-8;
+ const geomEpsilon = 1e-7;
+ let straight1 = Curve.isStraight(v1);
+ let straight2 = Curve.isStraight(v2);
+ let straightBoth = straight1 && straight2;
+ const flip = getSquaredLineLength(v1) < getSquaredLineLength(v2);
+ const l1 = flip ? v2 : v1;
+ const l2 = flip ? v1 : v2;
+ const px = l1[0], py = l1[1];
+ const vx = l1[6] - px, vy = l1[7] - py;
+ if (Line.getDistance(px, py, vx, vy, l2[0], l2[1], true) < geomEpsilon
+ && Line.getDistance(px, py, vx, vy, l2[6], l2[7], true) < geomEpsilon) {
+ if (!straightBoth
+ && Line.getDistance(px, py, vx, vy, l1[2], l1[3], true) < geomEpsilon
+ && Line.getDistance(px, py, vx, vy, l1[4], l1[5], true) < geomEpsilon
+ && Line.getDistance(px, py, vx, vy, l2[2], l2[3], true) < geomEpsilon
+ && Line.getDistance(px, py, vx, vy, l2[4], l2[5], true) < geomEpsilon) {
+ straight1 = straight2 = straightBoth = true;
+ }
+ } else if (straightBoth) {
+ return null;
+ }
+ if (straight1 ^ straight2) {
+ return null;
+ }
+
+ const v = [v1, v2];
+ let pairs = [];
+ for (let i = 0; i < 4 && pairs.length < 2; i++) {
+ const i1 = i & 1;
+ const i2 = i1 ^ 1;
+ const t1 = i >> 1;
+ const t2 = Curve.getTimeOf(v[i1], new Point(v[i2][t1 ? 6 : 0], v[i2][t1 ? 7 : 1]));
+
+ if (t2 != null) {
+ const pair = i1 ? [t1, t2] : [t2, t1];
+ if (!pairs.length || Math.abs(pair[0] - pairs[0][0]) > timeEpsilon && Math.abs(pair[1] - pairs[0][1]) > timeEpsilon) {
+ pairs.push(pair);
+ }
+ }
+ if (i > 2 && !pairs.length)
+ break;
+ }
+ if (pairs.length !== 2) {
+ pairs = null;
+ } else if (!straightBoth) {
+ const o1 = Curve.getPart(v1, pairs[0][0], pairs[1][0]);
+ const o2 = Curve.getPart(v2, pairs[0][1], pairs[1][1]);
+ if (Math.abs(o2[2] - o1[2]) > geomEpsilon
+ || Math.abs(o2[3] - o1[3]) > geomEpsilon
+ || Math.abs(o2[4] - o1[4]) > geomEpsilon
+ || Math.abs(o2[5] - o1[5]) > geomEpsilon)
+ pairs = null;
+ }
+ return pairs;
+ };
+ Curve.getTimesWithTangent = function (v, tangent) {
+ const x0 = v[0], y0 = v[1], x1 = v[2], y1 = v[3], x2 = v[4], y2 = v[5], x3 = v[6], y3 = v[7];
+
+ const normalized = tangent.normalize();
+ const tx = normalized.x;
+ const ty = normalized.y;
+
+ const ax = 3 * x3 - 9 * x2 + 9 * x1 - 3 * x0;
+ const ay = 3 * y3 - 9 * y2 + 9 * y1 - 3 * y0;
+ const bx = 6 * x2 - 12 * x1 + 6 * x0;
+ const by = 6 * y2 - 12 * y1 + 6 * y0;
+ const cx = 3 * x1 - 3 * x0;
+ const cy = 3 * y1 - 3 * y0;
+
+ let den = 2 * ax * ty - 2 * ay * tx;
+ const times = [];
+ if (Math.abs(den) < Numerical.CURVETIME_EPSILON) {
+ const num = ax * cy - ay * cx;
+ den = ax * by - ay * bx;
+ if (den != 0) {
+ const t = -num / den;
+ if (t >= 0 && t <= 1) times.push(t);
+ }
+ } else {
+ const delta = (bx * bx - 4 * ax * cx) * ty * ty +
+ (-2 * bx * by + 4 * ay * cx + 4 * ax * cy) * tx * ty +
+ (by * by - 4 * ay * cy) * tx * tx;
+ const k = bx * ty - by * tx;
+
+ if (delta >= 0 && den != 0) {
+ const d = Math.sqrt(delta);
+ const t0 = -(k + d) / den;
+ const t1 = (-k + d) / den;
+ if (t0 >= 0 && t0 <= 1) times.push(t0);
+ if (t1 >= 0 && t1 <= 1) times.push(t1);
+ }
+ }
+ return times;
+ };
+
+ const CurveLocation = function (curve, time, point, _overlap, _distance) {
+ if (time >= 0.99999999) {
+ const next = curve.getNext();
+ if (next) {
+ time = 0;
+ curve = next;
+ }
+ }
+ this._setCurve(curve);
+ this._time = time;
+ this._point = point || curve.getPointAtTime(time);
+ this._overlap = _overlap;
+ this._distance = _distance;
+ this._intersection = this._next = this._previous = null;
+ };
+ InitClassWithStatics(CurveLocation, Base);
+
+ CurveLocation.prototype._setPath = function (path) {
+ this._path = path;
+ this._version = path ? path._version : 0;
+ };
+ CurveLocation.prototype._setCurve = function (curve) {
+ this._setPath(curve._path);
+ this._curve = curve;
+ this._segment = null;
+ this._segment1 = curve._segment1;
+ this._segment2 = curve._segment2;
+ };
+ CurveLocation.prototype._setSegment = function (segment) {
+ const curve = segment.getCurve();
+ if (curve) {
+ this._setCurve(curve);
+ } else {
+ this._setPath(segment._path);
+ this._segment1 = segment;
+ this._segment2 = null;
+ }
+ this._segment = segment;
+ this._time = segment === this._segment1 ? 0 : 1;
+ this._point = segment._point.clone();
+ };
+ CurveLocation.prototype.getSegment = function () {
+ let segment = this._segment;
+ if (!segment) {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ if (time === 0) {
+ segment = curve._segment1;
+ } else if (time === 1) {
+ segment = curve._segment2;
+ } else if (time != null) {
+ segment = curve.getPartLength(0, time) < curve.getPartLength(time, 1)
+ ? curve._segment1
+ : curve._segment2;
+ }
+ this._segment = segment;
+ }
+ return segment;
+ };
+ CurveLocation.prototype.getCurve = function () {
+ if (this._path && this._path._version !== this._version) {
+ this._time = this._offset = this._curveOffset = this._curve = null;
+ }
+
+ const that = this;
+ function trySegment(segment) {
+ const curve = segment && segment.getCurve();
+ if (curve && (that._time = curve.getTimeOf(that._point)) != null) {
+ that._setCurve(curve);
+ return curve;
+ }
+ }
+
+ return this._curve
+ || trySegment(this._segment)
+ || trySegment(this._segment1)
+ || trySegment(this._segment2.getPrevious());
+ };
+ CurveLocation.prototype.getPath = function () {
+ const curve = this.getCurve();
+ return curve && curve._path;
+ };
+ CurveLocation.prototype.getIndex = function () {
+ const curve = this.getCurve();
+ return curve && curve.getIndex();
+ };
+ CurveLocation.prototype.getTime = function () {
+ const curve = this.getCurve();
+ return curve && this._time == null
+ ? this._time = curve.getTimeOf(this._point)
+ : this._time;
+ };
+ CurveLocation.prototype.getPoint = function () {
+ return this._point;
+ };
+ CurveLocation.prototype.getOffset = function () {
+ let offset = this._offset;
+ if (offset == null) {
+ offset = 0;
+ const path = this.getPath();
+ const index = this.getIndex();
+ if (path && index != null) {
+ const curves = path.getCurves();
+ for (let i = 0; i < index; i++)
+ offset += curves[i].getLength();
+ }
+ this._offset = offset += this.getCurveOffset();
+ }
+ return offset;
+ };
+ CurveLocation.prototype.getCurveOffset = function () {
+ let offset = this._curveOffset;
+ if (offset == null) {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ this._curveOffset = offset = time != null && curve && curve.getPartLength(0, time);
+ }
+ return offset;
+ };
+ CurveLocation.prototype.getIntersection = function () {
+ return this._intersection;
+ };
+ CurveLocation.prototype.getDistance = function () {
+ return this._distance;
+ };
+ CurveLocation.prototype.divide = function () {
+ const curve = this.getCurve();
+ const res = curve && curve.divideAtTime(this.getTime());
+ if (res) { this._setSegment(res._segment1); }
+ return res;
+ };
+ CurveLocation.prototype.equals = function (loc, _ignoreOther) {
+ if (this === loc) return true;
+ if (!(loc instanceof CurveLocation)) return false;
+
+ const curve1 = this.getCurve();
+ const curve2 = loc.getCurve();
+ const samePath = curve1._path === curve2._path;
+ if (!samePath) return false;
+
+ const offsetDifference = Math.abs(this.getOffset() - loc.getOffset());
+ const closeOffsets = (
+ offsetDifference < Numerical.GEOMETRIC_EPSILON ||
+ (curve1._path && Math.abs(curve1._path.getLength() - offsetDifference) < Numerical.GEOMETRIC_EPSILON)
+ );
+
+ const intersection1 = !_ignoreOther && this._intersection;
+ const intersection2 = !_ignoreOther && loc._intersection;
+
+ const matchingIntersections = !intersection1 && !intersection2 || (intersection1 && intersection2 && intersection1.equals(intersection2, true));
+ return closeOffsets && matchingIntersections;
+ };
+ CurveLocation.prototype.isTouching = function () {
+ if (this._intersection && this.getTangent().isCollinear(this._intersection.getTangent())) {
+ const curve1 = this.getCurve();
+ const curve2 = this._intersection.getCurve();
+ return !(curve1.isStraight() && curve2.isStraight() && curve1.getLine().intersect(curve2.getLine()));
+ }
+ return false;
+ };
+ CurveLocation.prototype.isCrossing = function () {
+ if (!this._intersection) { return false; }
+
+ const t1 = this.getTime();
+ const t2 = this._intersection.getTime();
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+ const t1Inside = t1 >= tMin && t1 <= tMax;
+ const t2Inside = t2 >= tMin && t2 <= tMax;
+ if (t1Inside && t2Inside)
+ return !this.isTouching();
+
+ let c2 = this.getCurve();
+ let c1 = c2 && t1 < tMin ? c2.getPrevious() : c2;
+ let c4 = this._intersection.getCurve();
+ let c3 = c4 && t2 < tMin ? c4.getPrevious() : c4;
+ if (t1 > tMax)
+ c2 = c2.getNext();
+ if (t2 > tMax)
+ c4 = c4.getNext();
+ if (!c1 || !c2 || !c3 || !c4)
+ return false;
+
+ const offsets = [];
+
+ function addOffsets(curve, end) {
+ const v = curve.getValues();
+ const roots = Curve.classify(v).roots || Curve.getPeaks(v);
+ const count = roots.length;
+ const offset = Curve.getLength(v, end && count ? roots[count - 1] : 0, !end && count ? roots[0] : 1);
+ offsets.push(count ? offset : offset / 32);
+ }
+
+ function isInRange(angle, min, max) {
+ return min < max
+ ? angle > min && angle < max
+ : angle > min || angle < max;
+ }
+
+ if (!t1Inside) {
+ addOffsets(c1, true);
+ addOffsets(c2, false);
+ }
+ if (!t2Inside) {
+ addOffsets(c3, true);
+ addOffsets(c4, false);
+ }
+ const pt = this.getPoint();
+ const offset = Math.min.apply(Math, offsets);
+
+ const v2 = t1Inside ? c2.getTangentAtTime(t1) : c2.getPointAt(offset).subtract(pt);
+ const v1 = t1Inside ? v2.negate() : c1.getPointAt(-offset).subtract(pt);
+ const v4 = t2Inside ? c4.getTangentAtTime(t2) : c4.getPointAt(offset).subtract(pt);
+ const v3 = t2Inside ? v4.negate() : c3.getPointAt(-offset).subtract(pt);
+
+ const a1 = v1.getAngle();
+ const a2 = v2.getAngle();
+ const a3 = v3.getAngle();
+ const a4 = v4.getAngle();
+
+ return !!(t1Inside
+ ? (isInRange(a1, a3, a4) ^ isInRange(a2, a3, a4)) && (isInRange(a1, a4, a3) ^ isInRange(a2, a4, a3))
+ : (isInRange(a3, a1, a2) ^ isInRange(a4, a1, a2)) && (isInRange(a3, a2, a1) ^ isInRange(a4, a2, a1)));
+ };
+ CurveLocation.prototype.hasOverlap = function () {
+ return !!this._overlap;
+ };
+ CurveLocation.prototype.getTangent = function () {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ return time != null && curve && curve.getTangentAt(time, true);
+ };
+ CurveLocation.prototype.getNormal = function () {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ return time != null && curve && curve.getNormalAt(time, true);
+ };
+ CurveLocation.prototype.getWeightedTangent = function () {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ return time != null && curve && curve.getWeightedTangentAt(time);
+ };
+ CurveLocation.prototype.getWeightedNormal = function () {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ return time != null && curve && curve.getWeightedNormalAt(time);
+ };
+ CurveLocation.prototype.getCurvature = function () {
+ const curve = this.getCurve();
+ const time = this.getTime();
+ return time != null && curve && curve.getCurvatureAt(time);
+ };
+
+ CurveLocation.insert = function (locations, loc, merge) {
+ const length = locations.length;
+
+ function search(index, dir) {
+ for (let i = index + dir; i >= -1 && i <= length; i += dir) {
+ const loc2 = locations[((i % length) + length) % length];
+ if (!loc.getPoint().isClose(loc2.getPoint(), 1e-7))
+ break;
+ if (loc.equals(loc2))
+ return loc2;
+ }
+ return null;
+ }
+
+ let l = 0;
+ let r = length - 1;
+
+ while (l <= r) {
+ const m = (l + r) >>> 1;
+ const loc2 = locations[m];
+ let found;
+ if (merge && (found = loc.equals(loc2) ? loc2 : (search(m, -1) || search(m, 1)))) {
+ if (loc._overlap) {
+ found._overlap = found._intersection._overlap = true;
+ }
+ return found;
+ }
+ const path1 = loc.getPath();
+ const path2 = loc2.getPath();
+ const diff = path1 !== path2
+ ? path1._id - path2._id
+ : (loc.getIndex() + loc.getTime()) - (loc2.getIndex() + loc2.getTime());
+ diff < 0 ? (r = m - 1) : (l = m + 1);
+ }
+ locations.splice(l, 0, loc);
+ return loc;
+ };
+ CurveLocation.expand = function (locations) {
+ const expanded = locations.slice();
+ for (let i = locations.length - 1; i >= 0; i--) {
+ CurveLocation.insert(expanded, locations[i]._intersection, false);
+ }
+ return expanded;
+ };
+
+ const PathItem = function PathItem() { };
+ InitClassWithStatics(PathItem, Item);
+
+ PathItem.prototype.isClockwise = function () {
+ return this.getArea() >= 0;
+ };
+ PathItem.prototype.setClockwise = function (clockwise) {
+ if (this.isClockwise() != (clockwise = !!clockwise))
+ this.reverse();
+ };
+ PathItem.prototype._contains = function (point) {
+ const winding = point.isInside(this.getBounds({ internal: true, handle: true }))
+ ? this._getWinding(point)
+ : {};
+ return winding.onPath || !!(winding.winding);
+ };
+ PathItem.prototype.getIntersections = function (path, include, _matrix, _returnFirst) {
+ const self = this === path || !path;
+ const matrix1 = this._matrix._orNullIfIdentity();
+ const matrix2 = self ? matrix1 : (_matrix || path._matrix)._orNullIfIdentity();
+ return self || this.getBounds(matrix1).intersects(path.getBounds(matrix2), 1e-12)
+ ? Curve.getIntersections(this.getCurves(), !self && path.getCurves(), include, matrix1, matrix2, _returnFirst)
+ : [];
+ };
+ PathItem.prototype.getNearestLocation = function () {
+ const point = Point.read(arguments);
+ const curves = this.getCurves();
+ let minDist = Infinity;
+ let minLoc = null;
+ for (let i = 0, l = curves.length; i < l; i++) {
+ const loc = curves[i].getNearestLocation(point);
+ if (loc._distance < minDist) {
+ minDist = loc._distance;
+ minLoc = loc;
+ }
+ }
+ return minLoc;
+ };
+ PathItem.prototype.getNearestPoint = function () {
+ const loc = this.getNearestLocation.apply(this, arguments);
+ return loc ? loc.getPoint() : loc;
+ };
+ PathItem.prototype.compare = function (path) {
+ if (!path) return false;
+
+ const paths1 = this._children || [this];
+ const paths2 = path._children ? path._children.slice() : [path];
+ const length1 = paths1.length;
+ const length2 = paths2.length;
+
+ const boundsOverlaps = CollisionDetection.findItemBoundsCollisions(paths1, paths2, Numerical.GEOMETRIC_EPSILON);
+
+ let matched = Array(length2).fill(false);
+ let matchCount = 0;
+ let allMatched = true;
+
+ for (let i1 = length1 - 1; i1 >= 0 && allMatched; i1--) {
+ const path1 = paths1[i1];
+ const pathBoundsOverlaps = boundsOverlaps[i1];
+ let pathMatched = false;
+
+ if (pathBoundsOverlaps) {
+ for (let i2 = pathBoundsOverlaps.length - 1; i2 >= 0 && !pathMatched; i2--) {
+ const pathIndex = pathBoundsOverlaps[i2];
+ if (path1.compare(paths2[pathIndex])) {
+ if (!matched[pathIndex]) {
+ matched[pathIndex] = true;
+ matchCount++;
+ }
+ pathMatched = true;
+ }
+ }
+ }
+ if (!pathMatched) allMatched = false;
+ }
+ return allMatched && matchCount === length2;
+ };
+
+
+ PathItem.prototype._getWinding = function (point, dir, closed) {
+ return PathItem.getWinding(point, this.getCurves(), dir, closed);
+ };
+ PathItem.prototype.unite = function (path) {
+ return PathItem.traceBoolean(this, path, OPERATIONS.unite);
+ };
+ PathItem.prototype.intersect = function (path) {
+ return PathItem.traceBoolean(this, path, OPERATIONS.intersect);
+ };
+ PathItem.prototype.subtract = function (path) {
+ return PathItem.traceBoolean(this, path, OPERATIONS.subtract);
+ };
+ PathItem.prototype.exclude = function (path) {
+ return PathItem.traceBoolean(this, path, OPERATIONS.exclude);
+ };
+ PathItem.prototype.divide = function (argument) {
+ // Original version with only two paths
+ if (!Array.isArray(argument)) {
+ const path = argument;
+ return PathItem.createResult([
+ this.exclude(path),
+ this.intersect(path)
+ ], true, this, path);
+ }
+
+ // Version for multiple paths
+ const paths = argument;
+
+ function calculateUniversumBounds(paths) {
+ const pathBounds = paths.map(function (path) { return path.getBounds(); });
+ const left = Math.min.apply(null, pathBounds.map(function (bounds) { return bounds.getLeft(); }));
+ const top = Math.min.apply(null, pathBounds.map(function (bounds) { return bounds.getTop(); }));
+ const right = Math.max.apply(null, pathBounds.map(function (bounds) { return bounds.getLeft() + bounds.getWidth(); }));
+ const bottom = Math.max.apply(null, pathBounds.map(function (bounds) { return bounds.getTop() + bounds.getHeight(); }));
+ return [left, top, right, bottom];
+ }
+ const bounds = calculateUniversumBounds(paths);
+ const delta = 1; // Expand universum so that it accurately includes all paths
+ const universum = new Path.Rectangle(bounds[0] - delta, bounds[1] - delta, bounds[2] + delta, bounds[3] + delta);
+
+ const areas = [];
+ for (let option = 1, totalCombinations = Math.pow(2, paths.length); option < totalCombinations; option++) {
+ let result = universum;
+ for (let i = 0; i < paths.length; i++) {
+ const path = paths[i];
+ const isBitSet = (option & (1 << i)) !== 0;
+ if (isBitSet) {
+ result = result.intersect(path);
+ } else {
+ result = result.intersect(universum.subtract(path));
+ }
+ }
+ if (!result.isEmpty()) {
+ result._option = option;
+ areas.push(result);
+ }
+ }
+
+ function splitCompoundPath(compoundPath) {
+ const split = [];
+ const paths = compoundPath.getChildren().slice();
+ const hasIntersection = function (p1, p2) { return !p1.intersect(p2).isEmpty(); };
+ paths.forEach(function (path) {
+ const intersects = paths.some(function (p1) {
+ return p1 !== path && hasIntersection(p1, path);
+ });
+ if (!intersects) {
+ split.push(path);
+ path.remove();
+ }
+ });
+
+ if (compoundPath.getChildren().length) {
+ split.push(compoundPath);
+ }
+ return split;
+ }
+
+ const fragments = areas.flatMap(function (area) {
+ if (area instanceof Path) { return [area]; }
+ if (area instanceof CompoundPath) { return splitCompoundPath(area); }
+ });
+
+ return fragments;
+ };
+ PathItem.prototype.resolveCrossings = function () {
+ let paths = this._children || [this];
+ let hasOverlaps = false;
+ let hasCrossings = false;
+
+ function hasOverlap(seg, path) {
+ const inter = seg && seg._intersection;
+ return inter && inter._overlap && inter._path === path;
+ }
+
+ let intersections = this.getIntersections(null, function (inter) {
+ return (inter.hasOverlap() && (hasOverlaps = true)) ||
+ (inter.isCrossing() && (hasCrossings = true));
+ });
+
+ const clearCurves = hasOverlaps && hasCrossings ? [] : null;
+ intersections = CurveLocation.expand(intersections);
+
+ if (hasOverlaps) {
+ const overlaps = PathItem.divideLocations(intersections, function (inter) {
+ return inter.hasOverlap();
+ }, clearCurves);
+
+ for (let i = overlaps.length - 1; i >= 0; i--) {
+ const overlap = overlaps[i];
+ const path = overlap._path;
+ const seg = overlap._segment;
+ const prev = seg.getPrevious();
+ const next = seg.getNext();
+
+ if (hasOverlap(prev, path) && hasOverlap(next, path)) {
+ seg.remove();
+ prev._handleOut._set(0, 0);
+ next._handleIn._set(0, 0);
+ if (prev !== seg && !prev.getCurve().hasLength()) {
+ next._handleIn.set(prev._handleIn);
+ prev.remove();
+ }
+ }
+ }
+ }
+ if (hasCrossings) {
+ PathItem.divideLocations(intersections, hasOverlaps && function (inter) {
+ const curve1 = inter.getCurve();
+ const seg1 = inter.getSegment();
+ const other = inter._intersection;
+ const curve2 = other._curve;
+ const seg2 = other._segment;
+ if (curve1 && curve2 && curve1._path && curve2._path) { return true; }
+ if (seg1) { seg1._intersection = null; }
+ if (seg2) { seg2._intersection = null; }
+ }, clearCurves);
+
+ if (clearCurves) PathItem.clearCurveHandles(clearCurves);
+
+ paths = PathItem.tracePaths(Base.each(paths, function (path) {
+ this.push.apply(this, path._segments);
+ }, []));
+ }
+
+ let item;
+ const length = paths.length;
+ if (length > 1 && this._children) {
+ if (paths !== this._children) { this.setChildren(paths); }
+ item = this;
+ } else if (length === 1 && !this._children) {
+ if (paths[0] !== this) { this.setSegments(paths[0].removeSegments()); }
+ item = this;
+ }
+
+ if (!item) {
+ item = new CompoundPath({ insert: false });
+ item.addChildren(paths);
+ item = item.reduce();
+ item.copyAttributes(this);
+ this.replaceWith(item);
+ }
+ return item;
+ };
+ PathItem.prototype.reorient = function (nonZero, clockwise) {
+ if (this._children && this._children.length) {
+ const reorientedChildren = PathItem.reorientPaths(
+ this.removeChildren(),
+ function (w) {
+ return !!(nonZero ? w : w & 1);
+ },
+ clockwise
+ );
+ this.setChildren(reorientedChildren);
+ } else if (clockwise !== undefined) {
+ this.setClockwise(clockwise);
+ }
+ return this;
+ };
+ PathItem.prototype.getInteriorPoint = function () {
+ const bounds = this.getBounds();
+ const point = bounds.getCenter(true);
+ if (this.contains(point)) return point;
+
+ const curves = this.getCurves();
+ const y = point.y;
+ const intercepts = [];
+ const roots = [];
+
+ curves.forEach(function (curve) {
+ const v = curve.getValues();
+ const [o0, o1, o2, o3] = [v[1], v[3], v[5], v[7]];
+
+ if (y >= Math.min(o0, o1, o2, o3) && y <= Math.max(o0, o1, o2, o3)) {
+ const monoCurves = Curve.getMonoCurves(v);
+
+ monoCurves.forEach(function (mv) {
+ const mo0 = mv[1];
+ const mo3 = mv[7];
+
+ if (mo0 !== mo3 && (y >= Math.min(mo0, mo3) && y <= Math.max(mo0, mo3))) {
+ const x = y === mo0
+ ? mv[0]
+ : y === mo3
+ ? mv[6]
+ : Curve.solveCubic(mv, 1, y, roots, 0, 1) === 1
+ ? Curve.getPoint(mv, roots[0]).x
+ : (mv[0] + mv[6]) / 2;
+
+ intercepts.push(x);
+ }
+ });
+ }
+ });
+
+ if (intercepts.length > 1) {
+ intercepts.sort(function (a, b) { return a - b; });
+ point.x = (intercepts[0] + intercepts[1]) / 2;
+ }
+ return point;
+ };
+
+ PathItem.getPaths = function (path) {
+ return path._children || [path];
+ };
+ PathItem.preparePath = function (path) {
+ let res = path
+ .clone(false)
+ .reduce({ simplify: true })
+ .transform(null, true, true);
+
+ const paths = PathItem.getPaths(res);
+ for (let i = 0, l = paths.length; i < l; i++) {
+ const path = paths[i];
+ if (!path._closed && !path.isEmpty()) {
+ path.closePath(Numerical.EPSILON);
+ path.getFirstSegment().setHandleIn(0, 0);
+ path.getLastSegment().setHandleOut(0, 0);
+ }
+ }
+ return res.resolveCrossings().reorient(true, true);
+ };
+ PathItem.createResult = function (paths, simplify, path1, path2) {
+ let result = new CompoundPath({ insert: false });
+ result.addChildren(paths, true);
+ result = result.reduce({ simplify: simplify });
+ result.copyAttributes(path1, true);
+ return result;
+ };
+ PathItem.filterIntersection = function (inter) {
+ return inter.hasOverlap() || inter.isCrossing();
+ };
+ PathItem.traceBoolean = function (path1, path2, operation) {
+ const operators = {
+ '1': { '1': true, '2': true, 'unite': true },
+ '2': { '2': true, 'intersect': true },
+ '3': { '1': true, 'subtract': true },
+ '4': { '1': true, '-1': true, 'exclude': true },
+ };
+ const operator = operators[operation];
+
+ const _path1 = PathItem.preparePath(path1);
+ const _path2 = path2 && path1 !== path2
+ ? PathItem.preparePath(path2)
+ : null;
+
+ if (_path2 && (operator['subtract'] || operator['exclude']) ^ (_path2.isClockwise() ^ _path1.isClockwise())) {
+ _path2.reverse();
+ }
+
+ const crossings = PathItem.divideLocations(
+ CurveLocation.expand(_path1.getIntersections(_path2, PathItem.filterIntersection))
+ );
+ const paths1 = PathItem.getPaths(_path1);
+ const paths2 = _path2 ? PathItem.getPaths(_path2) : null;
+ const segments = [];
+ const curves = [];
+
+ function collectPaths(paths) {
+ for (let i = 0, l = paths.length; i < l; i++) {
+ const path = paths[i];
+ segments.push.apply(segments, path._segments);
+ curves.push.apply(curves, path.getCurves());
+ path._overlapsOnly = true;
+ }
+ }
+
+ function getCurves(indices) {
+ const list = [];
+ for (let i = 0, l = indices && indices.length; i < l; i++) {
+ list.push(curves[indices[i]]);
+ }
+ return list;
+ }
+
+ let paths;
+ if (crossings.length) {
+ collectPaths(paths1);
+ if (paths2) collectPaths(paths2);
+
+ const curvesValues = new Array(curves.length);
+ for (let i = 0, l = curves.length; i < l; i++) {
+ curvesValues[i] = curves[i].getValues();
+ }
+
+ const curveCollisions = CollisionDetection.findCurveBoundsCollisions(curvesValues, curvesValues, 0, true);
+ const curveCollisionsMap = {};
+
+ for (let i = 0; i < curves.length; i++) {
+ const curve = curves[i];
+ const id = curve._path._id;
+ const map = curveCollisionsMap[id] = curveCollisionsMap[id] || {};
+ map[curve.getIndex()] = {
+ hor: getCurves(curveCollisions[i].hor),
+ ver: getCurves(curveCollisions[i].ver)
+ };
+ }
+ for (let i = 0, l = crossings.length; i < l; i++) {
+ PathItem.propagateWinding(crossings[i]._segment, _path1, _path2, curveCollisionsMap, operator);
+ }
+ for (let i = 0, l = segments.length; i < l; i++) {
+ const segment = segments[i];
+ const inter = segment._intersection;
+
+ if (!segment._winding) {
+ PathItem.propagateWinding(segment, _path1, _path2, curveCollisionsMap, operator);
+ }
+ if (!(inter && inter._overlap)) {
+ segment._path._overlapsOnly = false;
+ }
+ }
+
+ paths = PathItem.tracePaths(segments, operator);
+ } else {
+ paths = PathItem.reorientPaths(
+ paths2 ? paths1.concat(paths2) : paths1.slice(),
+ function (w) {
+ return !!operator[w];
+ }
+ );
+ }
+
+ return PathItem.createResult(paths, true, path1, path2);
+ };
+ PathItem.linkIntersections = function (from, to) {
+ let prev = from;
+ while (prev) {
+ if (prev === to)
+ return;
+ prev = prev._previous;
+ }
+ while (from._next && from._next !== to)
+ from = from._next;
+ if (!from._next) {
+ while (to._previous)
+ to = to._previous;
+ from._next = to;
+ to._previous = from;
+ }
+ };
+ PathItem.clearCurveHandles = function (curves) {
+ for (let i = curves.length - 1; i >= 0; i--)
+ curves[i].clearHandles();
+ };
+ PathItem.reorientPaths = function (paths, isInside, clockwise) {
+ const length = paths ? paths.length : 0;
+ if (!length) { return paths; }
+
+ const lookup = Base.each(paths, function (path, i) {
+ this[path._id] = {
+ container: null,
+ winding: path.isClockwise() ? 1 : -1,
+ index: i
+ };
+ }, {});
+
+ // Сортировка путей по площади
+ const sorted = paths.slice().sort(function (a, b) {
+ return Math.abs(b.getArea()) - Math.abs(a.getArea());
+ });
+
+ const first = sorted[0];
+ if (clockwise == null) { clockwise = first.isClockwise(); }
+
+ const collisions = CollisionDetection.findItemBoundsCollisions(sorted, null, Numerical.GEOMETRIC_EPSILON);
+ for (let i = 0; i < length; i++) {
+ const path1 = sorted[i];
+ const entry1 = lookup[path1._id];
+ let containerWinding = 0;
+ const indices = collisions[i];
+
+ if (indices) {
+ let point = null;
+ for (let j = indices.length - 1; j >= 0; j--) {
+ if (indices[j] < i) {
+ point = point || path1.getInteriorPoint();
+ const path2 = sorted[indices[j]];
+ if (path2.contains(point)) {
+ const entry2 = lookup[path2._id];
+ containerWinding = entry2.winding;
+ entry1.winding += containerWinding;
+ entry1.container = entry2['exclude'] ? entry2.container : path2;
+ break;
+ }
+ }
+ }
+ }
+ if (isInside(entry1.winding) === isInside(containerWinding)) {
+ entry1['exclude'] = true;
+ paths[entry1.index] = null;
+ } else {
+ path1.setClockwise(entry1.container ? !entry1.container.isClockwise() : clockwise);
+ }
+ }
+ return paths;
+ };
+ PathItem.divideLocations = function (locations, include, clearLater) {
+ const results = include && [];
+ const tMin = 1e-8;
+ const tMax = 1 - tMin;
+ const clearCurves = clearLater || [];
+ const clearLookup = clearLater && {};
+
+ let clearHandles = false;
+ let renormalizeLocs;
+ let prevCurve;
+ let prevTime;
+
+ function getId(curve) {
+ return curve._path._id + '.' + curve._segment1._index;
+ }
+
+ for (let i = (clearLater && clearLater.length) - 1; i >= 0; i--) {
+ const curve = clearLater[i];
+ if (curve._path) { clearLookup[getId(curve)] = true; }
+ }
+
+ for (let i = locations.length - 1; i >= 0; i--) {
+ const loc = locations[i];
+ const origTime = loc._time;
+ let time = loc._time;
+ if (loc._curve) {
+ if (loc._curve !== prevCurve) {
+ clearHandles = !loc._curve.hasHandles() || clearLookup && clearLookup[getId(loc._curve)];
+ renormalizeLocs = [];
+ prevTime = null;
+ prevCurve = loc._curve;
+ } else if (prevTime >= tMin) {
+ time /= prevTime;
+ }
+ }
+ const exclude = include && !include(loc);
+ if (exclude) {
+ if (renormalizeLocs) { renormalizeLocs.push(loc); }
+ continue;
+ } else if (include) {
+ results.unshift(loc);
+ }
+ prevTime = origTime;
+
+ let segment;
+ if (time < tMin) {
+ segment = loc._curve._segment1;
+ } else if (time > tMax) {
+ segment = loc._curve._segment2;
+ } else {
+ const newCurve = loc._curve.divideAtTime(time, true);
+ if (clearHandles)
+ clearCurves.push(loc._curve, newCurve);
+ segment = newCurve._segment1;
+ for (let j = renormalizeLocs.length - 1; j >= 0; j--) {
+ const l = renormalizeLocs[j];
+ l._time = (l._time - time) / (1 - time);
+ }
+ }
+ loc._setSegment(segment);
+
+ const inter = segment._intersection;
+ const dest = loc._intersection;
+ if (inter) {
+ PathItem.linkIntersections(inter, dest);
+ let other = inter;
+ while (other) {
+ PathItem.linkIntersections(other._intersection, inter);
+ other = other._next;
+ }
+ } else {
+ segment._intersection = dest;
+ }
+ }
+ if (!clearLater) { PathItem.clearCurveHandles(clearCurves); }
+
+ return results || locations;
+ };
+ PathItem.getWinding = function (point, curves, dir, closed, dontFlip) {
+ const curvesList = Array.isArray(curves) ? curves : (dir ? curves.hor : curves.ver);
+ const ia = dir ? 1 : 0;
+ const io = ia ^ 1;
+ const pv = [point.x, point.y];
+ const pa = pv[ia];
+ const po = pv[io];
+ const windingEpsilon = 1e-9;
+ const qualityEpsilon = 1e-6;
+ const paL = pa - windingEpsilon;
+ const paR = pa + windingEpsilon;
+
+ let windingL = 0, windingR = 0, pathWindingL = 0, pathWindingR = 0;
+ let onPath = false, onAnyPath = false, quality = 1;
+ let roots = [], vPrev, vClose;
+
+ function addWinding(v) {
+ const o0 = v[io + 0];
+ const o3 = v[io + 6];
+ if (po < Math.min(o0, o3) || po > Math.max(o0, o3)) { return; }
+
+ const a0 = v[ia + 0];
+ const a1 = v[ia + 2];
+ const a2 = v[ia + 4];
+ const a3 = v[ia + 6];
+
+ if (o0 === o3) {
+ if ((a0 < paR && a3 > paL) || (a3 < paR && a0 > paL)) { onPath = true; }
+ return;
+ }
+
+ const t = po === o0 ? 0 : (po === o3 ? 1 :
+ (paL > Math.max(a0, a1, a2, a3) || paR < Math.min(a0, a1, a2, a3) ? 1 :
+ Curve.solveCubic(v, io, po, roots, 0, 1) > 0 ? roots[0] : 1));
+
+ const a = t === 0 ? a0 : (t === 1 ? a3 : (dir ? Curve.getPoint(v, t).y : Curve.getPoint(v, t).x));
+ const winding = o0 > o3 ? 1 : -1;
+ const windingPrev = vPrev[io] > vPrev[io + 6] ? 1 : -1;
+ const a3Prev = vPrev[ia + 6];
+
+ if (po !== o0) {
+ if (a < paL) {
+ pathWindingL += winding;
+ } else if (a > paR) {
+ pathWindingR += winding;
+ } else {
+ onPath = true;
+ }
+ if (a > pa - qualityEpsilon && a < pa + qualityEpsilon) {
+ quality /= 2;
+ }
+ } else {
+ if (winding !== windingPrev) {
+ if (a0 < paL) {
+ pathWindingL += winding;
+ } else if (a0 > paR) {
+ pathWindingR += winding;
+ }
+ } else if (a0 != a3Prev) {
+ if (a3Prev < paR && a > paR) {
+ pathWindingR += winding;
+ onPath = true;
+ } else if (a3Prev > paL && a < paL) {
+ pathWindingL += winding;
+ onPath = true;
+ }
+ }
+ quality /= 4;
+ }
+
+ vPrev = v;
+ return !dontFlip && a > paL && a < paR
+ && (dir ? (Curve.getTangent(v, t).x === 0) : (Curve.getTangent(v, t).y === 0))
+ && PathItem.getWinding(point, curves, !dir, closed, true);
+ }
+
+ function handleCurve(v) {
+ const o0 = v[io + 0];
+ const o1 = v[io + 2];
+ const o2 = v[io + 4];
+ const o3 = v[io + 6];
+
+ if (po <= Math.max(o0, o1, o2, o3) && po >= Math.min(o0, o1, o2, o3)) {
+ const a0 = v[ia + 0];
+ const a1 = v[ia + 2];
+ const a2 = v[ia + 4];
+ const a3 = v[ia + 6];
+ const monoCurves = (paL > Math.max(a0, a1, a2, a3) || paR < Math.min(a0, a1, a2, a3))
+ ? [v]
+ : Curve.getMonoCurves(v, dir);
+
+ let res;
+ for (let i = 0, l = monoCurves.length; i < l; i++) {
+ if (res = addWinding(monoCurves[i])) {
+ return res;
+ }
+ }
+ }
+ }
+
+ for (let i = 0, l = curvesList.length; i < l; i++) {
+ const curve = curvesList[i];
+ const path = curve._path;
+ const v = curve.getValues();
+ if (!i || curvesList[i - 1]._path !== path) {
+ vPrev = null;
+ if (!path._closed) {
+ vClose = Curve.getValues(
+ path.getLastCurve().getSegment2(),
+ curve.getSegment1(),
+ null, !closed
+ );
+ if (vClose[io] !== vClose[io + 6]) {
+ vPrev = vClose;
+ }
+ }
+ if (!vPrev) {
+ vPrev = v;
+ let prev = path.getLastCurve();
+ while (prev && prev !== curve) {
+ const v2 = prev.getValues();
+ if (v2[io] !== v2[io + 6]) {
+ vPrev = v2;
+ break;
+ }
+ prev = prev.getPrevious();
+ }
+ }
+ }
+
+ let res;
+ if (res = handleCurve(v)) { return res; }
+ if (i + 1 === l || curvesList[i + 1]._path !== path) {
+ if (vClose && (res = handleCurve(vClose))) {
+ return res;
+ }
+ if (onPath && !pathWindingL && !pathWindingR) {
+ pathWindingL = pathWindingR = path.isClockwise(closed) ^ dir ? 1 : -1;
+ }
+ windingL += pathWindingL;
+ windingR += pathWindingR;
+ pathWindingL = pathWindingR = 0;
+ if (onPath) {
+ onAnyPath = true;
+ onPath = false;
+ }
+ vClose = null;
+ }
+ }
+ windingL = Math.abs(windingL);
+ windingR = Math.abs(windingR);
+
+ return {
+ winding: Math.max(windingL, windingR),
+ windingL: windingL,
+ windingR: windingR,
+ quality: quality,
+ onPath: onAnyPath
+ };
+ };
+ PathItem.propagateWinding = function (segment, path1, path2, curveCollisionsMap, operator) {
+ const chain = [];
+ const start = segment;
+ let totalLength = 0;
+ let winding = { winding: 0, quality: -1 };
+
+ do {
+ const curve = segment.getCurve();
+ if (curve) {
+ const length = curve.getLength();
+ chain.push({ segment, curve, length });
+ totalLength += length
+ }
+ segment = segment.getNext();
+ } while (segment && !segment._intersection && segment !== start);
+
+ const offsets = [0.5, 0.25, 0.75];
+ const tMin = 1e-3;
+ const tMax = 1 - tMin;
+
+ for (let i = 0; i < offsets.length && winding.quality < 0.5; i++) {
+ let lengthAtOffset = totalLength * offsets[i];
+
+ for (let j = 0, l = chain.length; j < l; j++) {
+ const entry = chain[j];
+ const curveLength = entry.length;
+ if (lengthAtOffset <= curveLength) {
+ const curve = entry.curve;
+ const path = curve._path;
+ const parent = path._parent;
+ const operand = parent instanceof CompoundPath ? parent : path;
+ const t = Numerical.clamp(curve.getTimeAt(lengthAtOffset), tMin, tMax);
+ const pt = curve.getPointAtTime(t);
+ const dir = Math.abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
+
+ let wind = null;
+ if (operator['subtract'] && path2) {
+ const otherPath = operand === path1 ? path2 : path1;
+ const pathWinding = otherPath._getWinding(pt, dir, true);
+ if (operand === path1 && pathWinding.winding ||
+ operand === path2 && !pathWinding.winding) {
+ if (pathWinding.quality < 1) {
+ continue;
+ } else {
+ wind = { winding: 0, quality: 1 };
+ }
+ }
+ }
+ wind = wind || PathItem.getWinding(pt, curveCollisionsMap[path._id][curve.getIndex()], dir, true);
+ if (wind.quality > winding.quality) {
+ winding = wind;
+ }
+ break;
+ }
+ lengthAtOffset -= curveLength;
+ }
+ }
+ for (let j = chain.length - 1; j >= 0; j--) {
+ chain[j].segment._winding = winding;
+ }
+ };
+ PathItem.tracePaths = function (segments, operator) {
+ const paths = [];
+ let starts;
+
+ function isValid(seg) {
+ let winding;
+ return !!(seg && !seg._visited && (!operator
+ || operator[(winding = seg._winding || {}).winding]
+ && !(operator['unite'] && winding.winding === 2
+ && winding.windingL && winding.windingR)));
+ }
+
+ function isStart(seg) {
+ if (seg) {
+ for (let i = 0, l = starts.length; i < l; i++) {
+ if (seg === starts[i]) { return true; }
+ }
+ }
+ return false;
+ }
+
+ function visitPath(path) {
+ for (let i = 0, l = path._segments.length; i < l; i++) {
+ path._segments[i]._visited = true;
+ }
+ }
+
+ function getCrossingSegments(segment, collectStarts) {
+ let inter = segment._intersection;
+ const start = inter;
+ const crossings = [];
+ if (collectStarts)
+ starts = [segment];
+
+ function collect(inter, end) {
+ while (inter && inter !== end) {
+ const other = inter._segment;
+ const path = other && other._path;
+ if (path) {
+ const next = other.getNext() || path.getFirstSegment();
+ const nextInter = next._intersection;
+ const isCrossingValid = isStart(other) || isStart(next) || next && (isValid(other) && (isValid(next) || nextInter && isValid(nextInter._segment)));
+ if (other !== segment && isCrossingValid) { crossings.push(other); }
+ if (collectStarts) { starts.push(other); }
+ }
+ inter = inter._next;
+ }
+ }
+
+ if (inter) {
+ collect(inter);
+ while (inter && inter._previous)
+ inter = inter._previous;
+ collect(inter, start);
+ }
+ return crossings;
+ }
+
+ segments.sort(function (seg1, seg2) {
+ const inter1 = seg1._intersection, inter2 = seg2._intersection;
+ const over1 = inter1 ? inter1._overlap : false;
+ const over2 = inter2 ? inter2._overlap : false;
+
+ if (over1 ^ over2) { return over1 ? 1 : -1; }
+ if (!inter1 ^ !inter2) { return inter1 ? 1 : -1; }
+ if (seg1._path !== seg2._path) { return seg1._path._id - seg2._path._id; }
+ return seg1._index - seg2._index;
+ });
+
+ for (let i = 0; i < segments.length; i++) {
+ let segment = segments[i];
+ let isValidSegment = isValid(segment);
+ if (isValidSegment && segment._path._overlapsOnly) {
+ const path1 = segment._path;
+ const path2 = segment._intersection._segment._path;
+
+ if (path1.compare(path2)) {
+ if (path1.getArea()) {
+ paths.push(path1.clone(false));
+ }
+ visitPath(path1);
+ visitPath(path2);
+ isValidSegment = false;
+ }
+ }
+
+ let visitedSegments;
+ let branches = [];
+ let currentPath = null;
+ let isFinished = false;
+ let isClosed = true;
+ let branch, handleIn;
+ while (isValidSegment) {
+ const isFirstSegment = !currentPath;
+ const crossings = getCrossingSegments(segment, isFirstSegment);
+ const otherSegment = crossings.shift();
+ isFinished = !isFirstSegment && (isStart(segment) || isStart(otherSegment));
+ const isCrossing = !isFinished && otherSegment;
+ if (isFirstSegment) {
+ currentPath = new Path({ insert: false });
+ branch = null;
+ }
+ if (isFinished) {
+ if (segment.isFirst() || segment.isLast()) { isClosed = segment._path._closed; }
+ segment._visited = true;
+ break;
+ }
+ if (isCrossing && branch) {
+ branches.push(branch);
+ branch = null;
+ }
+ if (!branch) {
+ if (isCrossing) { crossings.push(segment); }
+ branch = {
+ start: currentPath._segments.length,
+ crossings: crossings,
+ visited: visitedSegments = [],
+ handleIn: handleIn
+ };
+ }
+ if (isCrossing) { segment = otherSegment; }
+ if (!isValid(segment)) {
+ currentPath.removeSegments(branch.start);
+ visitedSegments.forEach(function (segment) { segment._visited = false; })
+ visitedSegments.length = 0;
+ do {
+ segment = branch && branch.crossings.shift();
+ if (!segment || !segment._path) {
+ segment = null;
+ branch = branches.pop();
+ if (branch) {
+ visitedSegments = branch.visited;
+ handleIn = branch.handleIn;
+ }
+ }
+ } while (branch && !isValid(segment));
+ if (!segment) {
+ break;
+ }
+ }
+ const nextSegment = segment.getNext();
+ currentPath.add(new Segment(segment._point, handleIn, nextSegment && segment._handleOut));
+ segment._visited = true;
+ visitedSegments.push(segment);
+ segment = nextSegment || segment._path.getFirstSegment();
+ handleIn = nextSegment && nextSegment._handleIn;
+ }
+
+ if (isFinished && isClosed) {
+ currentPath.getFirstSegment().setHandleIn(handleIn);
+ currentPath.setClosed(isClosed);
+ }
+ if (isFinished && currentPath.getArea() !== 0) {
+ paths.push(currentPath);
+ }
+ }
+ return paths;
+ };
+
+ const Path = function (arg) {
+ this._closed = false;
+ this._segments = [];
+ this._version = 0;
+
+ const isArrayArg = Array.isArray(arg);
+ const isObjectElement = isArrayArg && typeof arg[0] === 'object';
+ const isValidObject = arg && (arg.size === undefined && (arg.x !== undefined || arg.point !== undefined));
+ const segments = isArrayArg
+ ? isObjectElement ? arg : arguments
+ : isValidObject ? arguments : null;
+ segments && segments.length > 0
+ ? this.setSegments(segments)
+ : this._curves = undefined;
+ this._initialize(!segments && arg);
+ };
+ InitClassWithStatics(Path, PathItem);
+
+ Path.prototype._equals = function (item) {
+ return this._closed === item._closed
+ && Base.equals(this._segments, item._segments);
+ };
+ Path.prototype.copyContent = function (source) {
+ this.setSegments(source._segments);
+ this._closed = source._closed;
+ };
+ Path.prototype._changed = function _changed(flags) {
+ Item.prototype._changed.call(this, flags);
+ if (flags & 8) {
+ this._length = this._area = undefined;
+ if (flags & 32) {
+ this._version++;
+ } else if (this._curves) {
+ for (let i = 0, l = this._curves.length; i < l; i++)
+ this._curves[i]._changed();
+ }
+ } else if (flags & 64) {
+ this._bounds = undefined;
+ }
+ };
+ Path.prototype.getSegments = function () {
+ return this._segments;
+ };
+ Path.prototype.setSegments = function (segments) {
+ this._segments.length = 0;
+ this._curves = undefined;
+ let length = segments && segments.length;
+ if (!length) { return; }
+
+ const last = segments[length - 1];
+ if (typeof last === 'boolean') {
+ this.setClosed(last);
+ length--;
+ }
+ this._add(Segment.readList(segments, 0, {}, length));
+
+ };
+ Path.prototype.getFirstSegment = function () {
+ return this._segments[0];
+ };
+ Path.prototype.getLastSegment = function () {
+ return this._segments[this._segments.length - 1];
+ };
+ Path.prototype.getCurves = function () {
+ let curves = this._curves;
+ let segments = this._segments;
+ if (!curves) {
+ const length = this._countCurves();
+ curves = this._curves = new Array(length);
+ for (let i = 0; i < length; i++)
+ curves[i] = new Curve(this, segments[i],
+ segments[i + 1] || segments[0]);
+ }
+ return curves;
+ };
+ Path.prototype.getFirstCurve = function () {
+ return this.getCurves()[0];
+ };
+ Path.prototype.getLastCurve = function () {
+ const curves = this.getCurves();
+ return curves[curves.length - 1];
+ };
+ Path.prototype.isClosed = function () {
+ return this._closed;
+ };
+ Path.prototype.setClosed = function (closed) {
+ if (this._closed != (closed = !!closed)) {
+ this._closed = closed;
+ if (this._curves) {
+ const length = this._curves.length = this._countCurves();
+ if (closed)
+ this._curves[length - 1] = new Curve(this,
+ this._segments[length - 1], this._segments[0]);
+ }
+ this._changed(41);
+ }
+ };
+ Path.prototype.isEmpty = function () {
+ return !this._segments.length;
+ };
+ Path.prototype._transformContent = function (matrix) {
+ const segments = this._segments;
+ const coords = new Array(6);
+ for (let i = 0, l = segments.length; i < l; i++)
+ segments[i]._transformCoordinates(matrix, coords, true);
+ return true;
+ };
+ Path.prototype._add = function (segs, index) {
+ const segments = this._segments;
+ const curves = this._curves;
+ const amount = segs.length;
+ const append = index == null;
+ index = append ? segments.length : index;
+
+ for (let i = 0; i < amount; i++) {
+ let segment = segs[i];
+ if (segment._path) {
+ segment = segs[i] = segment.clone();
+ }
+ segment._path = this;
+ segment._index = index + i;
+ }
+ if (append) {
+ segments.push.apply(segments, segs);
+ } else {
+ segments.splice.apply(segments, [index, 0].concat(segs));
+ for (let i = index + amount, l = segments.length; i < l; i++) {
+ segments[i]._index = i;
+ }
+ }
+ if (curves) {
+ const total = this._countCurves();
+ const start = index > 0 && index + amount - 1 === total ? index - 1 : index;
+ let insert = start;
+ const end = Math.min(start + amount, total);
+ if (segs._curves) {
+ curves.splice.apply(curves, [start, 0].concat(segs._curves));
+ insert += segs._curves.length;
+ }
+ for (let i = insert; i < end; i++) {
+ curves.splice(i, 0, new Curve(this, null, null));
+ }
+ this._adjustCurves(start, end);
+ }
+ this._changed(41);
+ return segs;
+ };
+ Path.prototype._adjustCurves = function (start, end) {
+ const segments = this._segments;
+ const curves = this._curves;
+ let curve;
+ for (let i = start; i < end; i++) {
+ curve = curves[i];
+ curve._path = this;
+ curve._segment1 = segments[i];
+ curve._segment2 = segments[i + 1] || segments[0];
+ curve._changed();
+ }
+ if (curve = curves[this._closed && !start ? segments.length - 1 : start - 1]) {
+ curve._segment2 = segments[start] || segments[0];
+ curve._changed();
+ }
+ if (curve = curves[end]) {
+ curve._segment1 = segments[end];
+ curve._changed();
+ }
+ };
+ Path.prototype._countCurves = function () {
+ const length = this._segments.length;
+ return !this._closed && length > 0 ? length - 1 : length;
+ };
+ Path.prototype.add = function (segment1) {
+ return arguments.length > 1 && typeof segment1 !== 'number'
+ ? this._add(Segment.readList(arguments))
+ : this._add([Segment.read(arguments)])[0];
+ };
+ Path.prototype.insert = function (index, segment1) {
+ return arguments.length > 2 && typeof segment1 !== 'number'
+ ? this._add(Segment.readList(arguments, 1), index)
+ : this._add([Segment.read(arguments, 1)], index)[0];
+ };
+ Path.prototype.addSegment = function () {
+ return this._add([Segment.read(arguments)])[0];
+ };
+ Path.prototype.removeSegment = function (index) {
+ return this.removeSegments(index, index + 1)[0] || null;
+ };
+ Path.prototype.removeSegments = function (start, end, _includeCurves) {
+ if (start == null) start = 0;
+ if (end == null) end = this._segments.length;
+ const segments = this._segments;
+ const curves = this._curves;
+ const count = segments.length;
+ const removed = segments.splice(start, end - start);
+ const amount = removed.length;
+ if (!amount) return removed;
+
+ for (let i = 0; i < amount; i++) {
+ removed[i]._index = removed[i]._path = null;
+ }
+ for (let i = start, l = segments.length; i < l; i++) {
+ segments[i]._index = i;
+ }
+ if (curves) {
+ const index = (start > 0 && end === count + (this._closed ? 1 : 0)) ? start - 1 : start;
+ const removedCurves = curves.splice(index, amount);
+ for (let i = removedCurves.length - 1; i >= 0; i--) {
+ // Есть баг с файлом "shapesMerge - remove curves _path bug" (загрузил к себе в личные документы на nct)
+ // removedCurves[i]._path = null;
+ }
+ if (_includeCurves) {
+ removed._curves = removedCurves.slice(1);
+ }
+ this._adjustCurves(index, index);
+ }
+ this._changed(41);
+ return removed;
+ };
+ Path.prototype.hasHandles = function () {
+ for (let i = 0, l = this._segments.length; i < l; i++) {
+ if (this._segments[i].hasHandles()) { return true; }
+ }
+ return false;
+ };
+ Path.prototype.clearHandles = function () {
+ for (let i = 0, l = this._segments.length; i < l; i++)
+ this._segments[i].clearHandles();
+ };
+ Path.prototype.getLength = function () {
+ if (this._length == null) {
+ const curves = this.getCurves();
+ let length = 0;
+ for (let i = 0, l = curves.length; i < l; i++)
+ length += curves[i].getLength();
+ this._length = length;
+ }
+ return this._length;
+ };
+ Path.prototype.getArea = function () {
+ if (this._area != null) { return this._area; }
+
+ let area = 0;
+ const length = this._segments.length;
+ for (let i = 0; i < length; i++) {
+ const nextIndex = (i + 1) % length;
+ const isLastSegment = (i === length - 1);
+ area += Curve.getArea(Curve.getValues(
+ this._segments[i],
+ this._segments[isLastSegment ? 0 : nextIndex],
+ null, isLastSegment && !this._closed
+ ));
+ }
+ this._area = area;
+ return area;
+ };
+ Path.prototype.join = function (path, tolerance) {
+ const epsilon = tolerance || 0;
+ if (path && path !== this) {
+ let last1 = this.getLastSegment();
+ let last2 = path.getLastSegment();
+ if (!last2) { return this; }
+
+ if (last1 && last1._point.isClose(last2._point, epsilon)) { path.reverse(); }
+ const first2 = path.getFirstSegment();
+ if (last1 && last1._point.isClose(first2._point, epsilon)) {
+ last1.setHandleOut(first2._handleOut);
+ this._add(path._segments.slice(1));
+ } else {
+ const first1 = this.getFirstSegment();
+ if (first1 && first1._point.isClose(first2._point, epsilon)) { path.reverse(); }
+ last2 = path.getLastSegment();
+ if (first1 && first1._point.isClose(last2._point, epsilon)) {
+ first1.setHandleIn(last2._handleIn);
+ this._add(path._segments.slice(0, path._segments.length - 1), 0);
+ } else {
+ this._add(path._segments.slice());
+ }
+ }
+ if (path._closed) { this._add([path._segments[0]]); }
+ path.remove();
+ }
+ const first = this.getFirstSegment();
+ const last = this.getLastSegment();
+ if (first !== last && first._point.isClose(last._point, epsilon)) {
+ first.setHandleIn(last._handleIn);
+ last.remove();
+ this.setClosed(true);
+ }
+ return this;
+ };
+ Path.prototype.reduce = function (options) {
+ const curves = this.getCurves();
+ const simplify = options && options.simplify;
+ const tolerance = simplify ? 1e-7 : 0;
+ for (let i = curves.length - 1; i >= 0; i--) {
+ const curve = curves[i];
+ if (!curve.hasHandles() && (!curve.hasLength(tolerance) || simplify && curve.isCollinear(curve.getNext())))
+ curve.remove();
+ }
+ return this;
+ };
+ Path.prototype.reverse = function () {
+ this._segments.reverse();
+ for (let i = 0, l = this._segments.length; i < l; i++) {
+ const segment = this._segments[i];
+ const handleIn = segment._handleIn;
+ segment._handleIn = segment._handleOut;
+ segment._handleOut = handleIn;
+ segment._index = i;
+ }
+ this._curves = null;
+ this._changed(9);
+ };
+ Path.prototype.compare = function (path) {
+ if (!path || path instanceof CompoundPath)
+ return PathItem.prototype.compare.call(this, path);
+ const curves1 = this.getCurves();
+ const curves2 = path.getCurves();
+ if (!curves1.length || !curves2.length) {
+ return curves1.length == curves2.length;
+ }
+ let v1 = curves1[0].getValues();
+ const values2 = [];
+ let pos1 = 0, pos2;
+ let end1 = 0, end2;
+ for (let i = 0; i < curves2.length; i++) {
+ const v2 = curves2[i].getValues();
+ values2.push(v2);
+ const overlaps = Curve.getOverlaps(v1, v2);
+ if (overlaps) {
+ pos2 = !i && overlaps[0][0] > 0 ? curves2.length - 1 : i;
+ end2 = overlaps[0][1];
+ break;
+ }
+ }
+ let v2 = values2[pos2];
+ let start2;
+ while (v1 && v2) {
+ const overlaps = Curve.getOverlaps(v1, v2);
+ if (overlaps) {
+ const t1 = overlaps[0][0];
+ if (Math.abs(t1 - end1) < 1e-8) {
+ end1 = overlaps[1][0];
+ if (end1 === 1) {
+ v1 = ++pos1 < curves1.length ? curves1[pos1].getValues() : null;
+ end1 = 0;
+ }
+ const t2 = overlaps[0][1];
+ if (Math.abs(t2 - end2) < 1e-8) {
+ if (!start2)
+ start2 = [pos2, t2];
+ end2 = overlaps[1][1];
+ if (end2 === 1) {
+ if (++pos2 >= curves2.length)
+ pos2 = 0;
+ v2 = values2[pos2] || curves2[pos2].getValues();
+ end2 = 0;
+ }
+ if (!v1) {
+ return start2[0] === pos2 && start2[1] === end2;
+ }
+ continue;
+ }
+ }
+ }
+ break;
+ }
+ return false;
+ };
+ Path.prototype.getLocationAt = function (offset) {
+ if (typeof offset === 'number') {
+ const curves = this.getCurves();
+ let length = 0;
+ for (let i = 0, l = curves.length; i < l; i++) {
+ const start = length;
+ const curve = curves[i];
+ length += curve.getLength();
+ if (length > offset) {
+ return curve.getLocationAt(offset - start);
+ }
+ }
+ if (curves.length > 0 && offset <= this.getLength()) {
+ return new CurveLocation(curves[curves.length - 1], 1);
+ }
+ } else if (offset && offset.getPath && offset.getPath() === this) {
+ return offset;
+ }
+ return null;
+ };
+ Path.prototype.getPointAt = function (offset) {
+ const loc = this.getLocationAt(offset);
+ return loc && loc.getPoint();
+ };
+ Path.prototype.getTangentAt = function (offset) {
+ const loc = this.getLocationAt(offset);
+ return loc && loc.getTangent();
+ };
+ Path.prototype.getNormalAt = function (offset) {
+ const loc = this.getLocationAt(offset);
+ return loc && loc.getNormal();
+ };
+ Path.prototype.getCurvatureAt = function (offset) {
+ const loc = this.getLocationAt(offset);
+ return loc && loc.getCurvature();
+ };
+ Path.prototype.moveTo = function () {
+ if (this._segments.length === 1)
+ this.removeSegment(0);
+ if (!this._segments.length)
+ this._add([new Segment(Point.read(arguments))]);
+ };
+ Path.prototype.lineTo = function () {
+ this._add([new Segment(Point.read(arguments))]);
+ };
+ Path.prototype.cubicCurveTo = function () {
+ const handle1 = Point.read(arguments);
+ const handle2 = Point.read(arguments);
+ const to = Point.read(arguments);
+ const current = Path.getCurrentSegment(this);
+ current.setHandleOut(handle1.subtract(current._point));
+ this._add([new Segment(to, handle2.subtract(to))]);
+ };
+ Path.prototype.quadraticCurveTo = function () {
+ const handle = Point.read(arguments);
+ const to = Point.read(arguments);
+ const current = Path.getCurrentSegment(this)._point;
+ this.cubicCurveTo(
+ handle.add(current.subtract(handle).multiply(1 / 3)),
+ handle.add(to.subtract(handle).multiply(1 / 3)),
+ to
+ );
+ };
+ Path.prototype.closePath = function (tolerance) {
+ this.setClosed(true);
+ this.join(this, tolerance);
+ };
+ Path.prototype._getBounds = function (matrix, options) {
+ return options.handle
+ ? Path.getHandleBounds(this._segments, this._closed, this, matrix, options)
+ : Path.getBounds(this._segments, this._closed, this, matrix, options);
+ };
+
+ Path.getCurrentSegment = function (that) {
+ const segments = that._segments;
+ if (!segments.length) { throw new Error('Use a moveTo() command first'); }
+ return segments[segments.length - 1];
+ };
+ Path.getBounds = function (segments, closed, _path, matrix) {
+ const first = segments[0];
+ if (!first) { return new Rectangle(); }
+
+ let coords = new Array(6);
+ let prevCoords = first._transformCoordinates(matrix, new Array(6));
+ const min = prevCoords.slice(0, 2);
+ const max = min.slice();
+ const roots = new Array(2);
+
+ function processSegment(segment) {
+ segment._transformCoordinates(matrix, coords);
+ for (let i = 0; i < 2; i++) {
+ Curve._addBounds(
+ prevCoords[i],
+ prevCoords[i + 4],
+ coords[i + 2],
+ coords[i],
+ i, 0, min, max, roots);
+ }
+ const tmp = prevCoords;
+ prevCoords = coords;
+ coords = tmp;
+ }
+
+ for (let i = 1, l = segments.length; i < l; i++)
+ processSegment(segments[i]);
+ if (closed)
+ processSegment(first);
+ return new Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
+ };
+ Path.getHandleBounds = function (segments, _closed, _path, matrix) {
+ const coords = new Array(6);
+ let x1 = Infinity;
+ let x2 = -x1;
+ let y1 = x1;
+ let y2 = x2;
+ for (let i = 0, l = segments.length; i < l; i++) {
+ segments[i]._transformCoordinates(matrix, coords);
+ for (let j = 0; j < 6; j += 2) {
+ const x = coords[j];
+ const y = coords[j + 1];
+ if (x < x1) x1 = x;
+ if (x > x2) x2 = x;
+ if (y < y1) y1 = y;
+ if (y > y2) y2 = y;
+ }
+ }
+ return new Rectangle(x1, y1, x2 - x1, y2 - y1);
+ };
+ Path.Rectangle = function (left, top, right, bottom) {
+ const path = new Path();
+ path.moveTo(left, top);
+ path.lineTo(right, top);
+ path.lineTo(right, bottom);
+ path.lineTo(left, bottom);
+ path.closePath();
+ return path;
+ };
+
+ const CompoundPath = function (arg) {
+ this._children = [];
+ this._namedChildren = {};
+ if (!this._initialize(arg)) {
+ this.addChildren(Array.isArray(arg) ? arg : arguments);
+ }
+ };
+ InitClassWithStatics(CompoundPath, PathItem);
+
+ CompoundPath.prototype.insertChildren = function insertChildren(index, items) {
+ let list = items;
+ const first = list[0];
+ if (first && typeof first[0] === 'number')
+ list = [list];
+ for (let i = items.length - 1; i >= 0; i--) {
+ const item = list[i];
+ if (list === items && !(item instanceof Path))
+ list = Base.slice(list);
+ if (Array.isArray(item)) {
+ list[i] = new Path({ segments: item, insert: false });
+ } else if (item instanceof CompoundPath) {
+ list.splice.apply(list, [i, 1].concat(item.removeChildren()));
+ item.remove();
+ }
+ }
+ return Item.prototype.insertChildren.call(this, index, list);
+ };
+ CompoundPath.prototype.reduce = function reduce(options) {
+ for (let i = this._children.length - 1; i >= 0; i--) {
+ const path = this._children[i].reduce(options);
+ if (path.isEmpty())
+ path.remove();
+ }
+ if (!this._children.length) {
+ const path = new Path({ insert: false });
+ path.copyAttributes(this);
+ path.insertAbove(this);
+ this.remove();
+ return path;
+ }
+ return Item.prototype.reduce.call(this);
+ };
+ CompoundPath.prototype.isClosed = function () {
+ for (let i = 0, l = this._children.length; i < l; i++) {
+ if (!this._children[i]._closed)
+ return false;
+ }
+ return true;
+ };
+ CompoundPath.prototype.setClosed = function (closed) {
+ for (let i = 0, l = this._children.length; i < l; i++) {
+ this._children[i].setClosed(closed);
+ }
+ };
+ CompoundPath.prototype.getFirstSegment = function () {
+ const first = this.getFirstChild();
+ return first && first.getFirstSegment();
+ };
+ CompoundPath.prototype.getLastSegment = function () {
+ const last = this.getLastChild();
+ return last && last.getLastSegment();
+ };
+ CompoundPath.prototype.getCurves = function () {
+ const curves = [];
+ for (let i = 0, l = this._children.length; i < l; i++) {
+ curves.push.apply(curves, this._children[i].getCurves());
+ }
+ return curves;
+ };
+ CompoundPath.prototype.getFirstCurve = function () {
+ const first = this.getFirstChild();
+ return first && first.getFirstCurve();
+ };
+ CompoundPath.prototype.getLastCurve = function () {
+ const last = this.getLastChild();
+ return last && last.getLastCurve();
+ };
+ CompoundPath.prototype.getArea = function () {
+ let area = 0;
+ for (let i = 0, l = this._children.length; i < l; i++)
+ area += this._children[i].getArea();
+ return area;
+ };
+ CompoundPath.prototype.isEmpty = function () {
+ let empty = true;
+ for (let i = 0, l = this._children.length; i < l; i++)
+ empty *= this._children[i].isEmpty();
+ return empty;
+ };
+ CompoundPath.prototype.getLength = function () {
+ let length = 0;
+ for (let i = 0, l = this._children.length; i < l; i++)
+ length += this._children[i].getLength();
+ return length;
+ };
+ CompoundPath.prototype.moveTo = function () {
+ const current = CompoundPath.getCurrentPath(this);
+ const path = current && current.isEmpty() ? current : new Path({ insert: false });
+ if (path !== current) { this.addChild(path); }
+ path.moveTo.apply(path, arguments);
+ };
+ CompoundPath.prototype.closePath = function (tolerance) {
+ CompoundPath.getCurrentPath(this, true).closePath(tolerance);
+ };
+ CompoundPath.prototype.lineTo = function () {
+ const path = CompoundPath.getCurrentPath(this, true);
+ path.lineTo.apply(path, arguments);
+ };
+ CompoundPath.prototype.cubicCurveTo = function () {
+ const path = CompoundPath.getCurrentPath(this, true);
+ path.cubicCurveTo.apply(path, arguments);
+ };
+ CompoundPath.prototype.quadraticCurveTo = function () {
+ const path = CompoundPath.getCurrentPath(this, true);
+ path.quadraticCurveTo.apply(path, arguments);
+ };
+ CompoundPath.prototype.reverse = function (param) {
+ let res;
+ for (let i = 0, l = this._children.length; i < l; i++) {
+ res = this._children[i].reverse(param) || res;
+ }
+ return res;
+ };
+
+ CompoundPath.getCurrentPath = function (that, check) {
+ if (check && !that._children.length)
+ throw new Error('Use a moveTo() command first');
+ return that._children[that._children.length - 1];
+ };
+
+ // EXPORTS
+
+ window['AscCommon'] = window['AscCommon'] || {};
+ window['AscCommon']['PathBoolean'] = {}
+ window['AscCommon']['PathBoolean']['CompoundPath'] = CompoundPath;
+
+ CompoundPath.prototype['divide'] = PathItem.prototype.divide;
+ CompoundPath.prototype['unite'] = PathItem.prototype.unite;
+ CompoundPath.prototype['intersect'] = PathItem.prototype.intersect;
+ CompoundPath.prototype['subtract'] = PathItem.prototype.subtract;
+ CompoundPath.prototype['exclude'] = PathItem.prototype.exclude;
+
+ Path.prototype['divide'] = PathItem.prototype.divide;
+ Path.prototype['unite'] = PathItem.prototype.unite;
+ Path.prototype['intersect'] = PathItem.prototype.intersect;
+ Path.prototype['subtract'] = PathItem.prototype.subtract;
+ Path.prototype['exclude'] = PathItem.prototype.exclude;
+
+ CompoundPath.prototype['moveTo'] = CompoundPath.prototype.moveTo;
+ CompoundPath.prototype['lineTo'] = CompoundPath.prototype.lineTo;
+ CompoundPath.prototype['cubicCurveTo'] = CompoundPath.prototype.cubicCurveTo;
+ CompoundPath.prototype['closePath'] = CompoundPath.prototype.closePath;
+ CompoundPath.prototype['getChildren'] = Item.prototype.getChildren;
+ CompoundPath.prototype['getBounds'] = Item.prototype.getBounds;
+ CompoundPath.prototype['getPosition'] = Item.prototype.getPosition;
+ CompoundPath.prototype['setPosition'] = Item.prototype.setPosition;
+
+ Path.prototype['getSegments'] = Path.prototype.getSegments;
+ Path.prototype['isClosed'] = Path.prototype.isClosed;
+ Path.prototype['getBounds'] = Item.prototype.getBounds;
+ Path.prototype['getPosition'] = Item.prototype.getPosition;
+ Path.prototype['setPosition'] = Item.prototype.setPosition;
+
+ Segment.prototype['isFirst'] = Segment.prototype.isFirst;
+ Segment.prototype['isLast'] = Segment.prototype.isLast;
+ Segment.prototype['getPrevious'] = Segment.prototype.getPrevious;
+ Segment.prototype['getNext'] = Segment.prototype.getNext;
+ Segment.prototype['getPoint'] = Segment.prototype.getPoint;
+ Segment.prototype['getHandleOut'] = Segment.prototype.getHandleOut;
+ Segment.prototype['getHandleIn'] = Segment.prototype.getHandleIn;
+
+ Rectangle.prototype['getTopLeft'] = Rectangle.prototype.getTopLeft;
+ Rectangle.prototype['getWidth'] = Rectangle.prototype.getWidth;
+ Rectangle.prototype['getHeight'] = Rectangle.prototype.getHeight;
+ Rectangle.prototype['getLeft'] = Rectangle.prototype.getLeft;
+ Rectangle.prototype['getTop'] = Rectangle.prototype.getTop;
+
+ Point.prototype['subtract'] = Point.prototype.subtract;
+ Point.prototype['getX'] = Point.prototype.getX;
+ Point.prototype['getY'] = Point.prototype.getY;
+
+})(window);
diff --git a/common/Drawings/Metafile.js b/common/Drawings/Metafile.js
index d59200e7aa..23d401b1b3 100644
--- a/common/Drawings/Metafile.js
+++ b/common/Drawings/Metafile.js
@@ -1746,13 +1746,14 @@
// vsdxHalfDashDashDot : 24,
// vsdxHalfLongDashShortDash : 25,
// vsdxHalfLongDashShortDashShortDash : 26,
- // vsdxDoubleDot : 27,
- // vsdxDoubleDashDot : 28,
- // vsdxDoubleDashDotDot : 29,
- // vsdxDoubleDashDashDot : 30,
- // vsdxDoubleLongDashShortDash : 31,
- // vsdxDoubleLongDashShortDashShortDash : 32,
- // vsdxHalfHalfDash : 33,
+ // vsdxDoubleDash: : 27
+ // vsdxDoubleDot : 28,
+ // vsdxDoubleDashDot : 29,
+ // vsdxDoubleDashDotDot : 30,
+ // vsdxDoubleDashDashDot : 31,
+ // vsdxDoubleLongDashShortDash : 32,
+ // vsdxDoubleLongDashShortDashShortDash : 33,
+ // vsdxHalfHalfDash : 34,
var DashPatternPresets = [
[4, 3],
@@ -1767,6 +1768,8 @@
[3, 1, 1, 1, 1, 1],
[1, 1],
// visio types
+ // !!! line patterns were made to look correct for visio line cap type square.
+ // But now only flat cap type is supported in sdkjs.
[0, 1], // vsdxTransparent
[1, 0], // vsdxSolid
[9, 3], // vsdxDash
@@ -1790,8 +1793,7 @@
[16, 7, 16, 7, 2, 7], // vsdxDoubleDashDashDot
[41, 7, 17, 7], // vsdxDoubleLongDashShortDash
[41, 7, 17, 7, 17, 7], // vsdxDoubleLongDashShortDashShortDash
- [1, 0], // vsdxHalfHalfDash (in visio is solid)
-
+ [1, 0], // vsdxHalfHalfDash (in visio is solid for cap type square)
];
function CMetafileFontPicker(manager)
@@ -2081,7 +2083,11 @@
this.Memory.WriteByte(CommandType.ctBrushTexturePath);
var _src = src;
- if (isCloudPrinting)
+ if (src.startsWith("blob:"))
+ {
+ _src = AscCommon.g_oDocumentBlobUrls.getImageBase64(src);
+ }
+ else if (isCloudPrinting)
{
_src = getCloudPrintingUrl(src)
}
@@ -2378,6 +2384,16 @@
// images
drawImage : function(img, x, y, w, h, isUseOriginUrl)
{
+ if (img.startsWith("blob:"))
+ {
+ this.Memory.WriteString2(AscCommon.g_oDocumentBlobUrls.getImageBase64(img));
+ this.Memory.WriteDouble(x);
+ this.Memory.WriteDouble(y);
+ this.Memory.WriteDouble(w);
+ this.Memory.WriteDouble(h);
+ return;
+ }
+
var isCloudPrinting = isCloudPrintingUrl();
if (!window.editor)
diff --git a/common/Drawings/States.js b/common/Drawings/States.js
index c4546d5945..765c936d77 100644
--- a/common/Drawings/States.js
+++ b/common/Drawings/States.js
@@ -148,7 +148,7 @@ StartAddNewShape.prototype =
onMouseUp: function(e, x, y)
{
var bRet = false;
- if(this.bStart && this.drawingObjects.canEdit() && this.drawingObjects.arrTrackObjects.length > 0)
+ if(this.bStart && (this.drawingObjects.canEdit() || Asc.editor.isDrawSlideshowAnnotations()) && this.drawingObjects.arrTrackObjects.length > 0)
{
bRet = true;
var oThis = this;
@@ -286,8 +286,8 @@ StartAddNewShape.prototype =
return;
}
- var callback = function(bLock, isClickMouseEvent){
-
+ let callback = function(bLock, isClickMouseEvent)
+ {
if(bLock)
{
History.Create_NewPoint(AscDFH.historydescription_CommonStatesAddNewShape);
@@ -374,7 +374,13 @@ StartAddNewShape.prototype =
}
oThis.drawingObjects.updateOverlay();
};
- if(Asc.editor && Asc.editor.checkObjectsLock)
+ if(Asc.editor.isDrawSlideshowAnnotations())
+ {
+ AscFormat.ExecuteNoHistory(function () {
+ callback(true, e.ClickCount);
+ }, this, []);
+ }
+ else if(Asc.editor.checkObjectsLock)
{
Asc.editor.checkObjectsLock([AscCommon.g_oIdCounter.Get_NewId()], callback);
}
diff --git a/common/Drawings/TextDrawer.js b/common/Drawings/TextDrawer.js
index 7189ab3850..ca7b216b8e 100644
--- a/common/Drawings/TextDrawer.js
+++ b/common/Drawings/TextDrawer.js
@@ -651,6 +651,45 @@ CParagraphStructure.prototype.checkWord = function() {
}
};
+function CShapeStructure()
+{
+ this.m_aContent = [];
+ this.m_aBorders = [];
+ this.m_nType = DRAW_COMMAND_SHAPE;
+}
+
+CShapeStructure.prototype.Recalculate = function(oTheme, oColorMap, dWidth, dHeight, oShape)
+{
+ for (let i = 0; i < this.m_aContent.length; ++i)
+ this.m_aContent[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, true);
+
+ for (let i = 0; i < this.m_aBorders.length; ++i)
+ this.m_aBorders[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, true);
+};
+CShapeStructure.prototype.CheckContentStructs = function(aContentStructs)
+{
+ for (let i = 0; i < this.m_aContent.length; ++i)
+ this.m_aContent[i].CheckContentStructs(aContentStructs);
+};
+
+CShapeStructure.prototype.getAllBackgroundsBorders = function(aParaBackgrounds, aBackgrounds, aBorders, aComments)
+{
+ for (let i = 0; i < this.m_aBorders.length; ++i)
+ aBorders.push(this.m_aBorders[i]);
+
+ for (let i = 0; i < this.m_aContent.length; ++i)
+ this.m_aContent[i].getAllBackgroundsBorders(aParaBackgrounds, aBackgrounds, aBorders, aComments);
+};
+
+CShapeStructure.prototype.draw = function(graphics, transform, oTheme, oColorMap)
+{
+ for(let i = 0; i < this.m_aBorders.length; ++i)
+ this.m_aBorders[i].draw(graphics, undefined, transform, oTheme, oColorMap);
+
+ for(let i = 0; i < this.m_aContent.length; ++i)
+ this.m_aContent[i].draw(graphics, transform, oTheme, oColorMap);
+}
+
function CTableStructure()
{
this.m_nType = DRAW_COMMAND_TABLE;
@@ -844,6 +883,7 @@ var DRAW_COMMAND_DRAWING = 0x05;
var DRAW_COMMAND_HIDDEN_ELEM = 0x06;
var DRAW_COMMAND_NO_CREATE_GEOM = 0x07;
var DRAW_COMMAND_TABLE_ROW = 0x08;
+var DRAW_COMMAND_SHAPE = 0x09;
function GetConstDescription(nConst)
{
@@ -1014,7 +1054,7 @@ CTextDrawer.prototype.p_color = function(r,g,b,a)
{
oTextPr.TextOutline = new AscFormat.CLn();
}
- oTextPr.TextOutline.Fill = AscFormat.CreateUnfilFromRGB(r, g, b);
+ oTextPr.TextOutline.Fill = this.CreateUnfilFromRGB(r, g, b);
this.SetTextPr(oTextPr, this.m_oTheme);
return;
}
@@ -1112,7 +1152,7 @@ CTextDrawer.prototype.SetShd = function(oShd)
{
if(oShd.Color)
{
- this.m_oFill = AscFormat.CreateUnfilFromRGB(oShd.Color.r, oShd.Color.g, oShd.Color.b);
+ this.m_oFill = this.CreateUnfilFromRGB(oShd.Color.r, oShd.Color.g, oShd.Color.b);
}
else
{
@@ -1136,7 +1176,7 @@ CTextDrawer.prototype.SetBorder = function(oBorder)
{
if(oBorder && oBorder.Value !== border_None)
{
- this.m_oLine = CreatePenFromParams(oBorder.Unifill ? oBorder.Unifill : AscFormat.CreateUnfilFromRGB(oBorder.Color.r, oBorder.Color.g, oBorder.Color.b), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size);
+ this.m_oLine = CreatePenFromParams(oBorder.Unifill ? oBorder.Unifill : this.CreateUnfilFromRGB(oBorder.Color.r, oBorder.Color.g, oBorder.Color.b), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size);
}
else
{
@@ -1261,6 +1301,11 @@ CTextDrawer.prototype.Start_Command = function(commandId, param, index, nType)
this.m_aStackCurRowMaxIndex[this.m_aStackCurRowMaxIndex.length] = -1;
break;
}
+ case DRAW_COMMAND_SHAPE:
+ {
+ oNewStructure = new CShapeStructure();
+ break;
+ }
}
if(oNewStructure)
{
@@ -1329,6 +1374,11 @@ CTextDrawer.prototype.End_Command = function()
this.m_nCurLineIndex = this.m_aStackCurRowMaxIndex.pop();
break;
}
+ case DRAW_COMMAND_SHAPE:
+ {
+ this.m_aStack.pop();
+ break;
+ }
}
};
@@ -1485,6 +1535,30 @@ CTextDrawer.prototype.Get_PathToDraw = function(bStart, bStart2, x, y, Code)
oLastObjectToDraw.geometry.bDrawSmart = true;
break;
}
+ case DRAW_COMMAND_SHAPE:
+ {
+ if(oLastCommand.m_aBorders.length === 0 || bStart2)
+ {
+ oBrushColor = this.m_oBrush.Color1;
+ oPenColor = this.m_oPen.Color;
+ oLastCommand.m_aBorders.push(new ObjectToDraw(this.m_oFill, this.m_oLine, this.Width, this.Height, new Geometry(), this.m_oTransform, x, y));
+ }
+ oLastObjectToDraw = oLastCommand.m_aBorders[oLastCommand.m_aBorders.length - 1];
+
+ if(bStart2)
+ {
+ if(oLastObjectToDraw.geometry.isEmpty())
+ {
+ oLastObjectToDraw.resetBrushPen(this.m_oFill, this.m_oLine, x, y);
+ }
+ else
+ {
+ oLastCommand.m_aBorders.push(new ObjectToDraw(this.m_oFill, this.m_oLine, this.Width, this.Height, new Geometry(), this.m_oTransform, x, y));
+ oLastObjectToDraw = oLastCommand.m_aBorders[oLastCommand.m_aBorders.length - 1];
+ }
+ }
+ break;
+ }
case DRAW_COMMAND_PARAGRAPH:
{
break;
@@ -1556,9 +1630,16 @@ CTextDrawer.prototype._m = function(x,y)
if(this.m_bTurnOff)
return;
var oPathToDraw = this.Get_PathToDraw();
+
+ let tr = this.GetTransform();
+ let bUseTr = this.isStampAnnot;
+
+ let _x = bUseTr ? tr.TransformPointX(x, y) : x;
+ let _y = bUseTr ? tr.TransformPointY(x, y) : y;
+
if(oPathToDraw)
{
- oPathToDraw.moveTo(this.xKoeff*x, this.yKoeff*y);
+ oPathToDraw.moveTo(this.xKoeff*_x, this.yKoeff*_y);
}
this.lastX = x;
this.lastY = y;
@@ -1567,6 +1648,13 @@ CTextDrawer.prototype._l = function(x,y)
{
if(this.m_bTurnOff)
return;
+
+ let tr = this.GetTransform();
+ let bUseTr = this.isStampAnnot;
+
+ let _x = bUseTr ? tr.TransformPointX(x, y) : x;
+ let _y = bUseTr ? tr.TransformPointY(x, y) : y;
+
if(this.bCheckLines)
{
if(Math.abs(x - this.lastX) < EPSILON_TEXT_AUTOFIT && Math.abs(x - this.lastX) < Math.abs(y - this.lastY))
@@ -1587,27 +1675,45 @@ CTextDrawer.prototype._l = function(x,y)
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
- oPathToDraw.lnTo(this.xKoeff*x, this.yKoeff*y);
+ oPathToDraw.lnTo(this.xKoeff*_x, this.yKoeff*_y);
}
this.lastX = x;
this.lastY = y;
};
CTextDrawer.prototype._c = function(x1,y1,x2,y2,x3,y3)
{
+ let tr = this.GetTransform();
+ let bUseTr = this.isStampAnnot;
+
+ let _x1 = bUseTr ? tr.TransformPointX(x1, y1) : x1;
+ let _y1 = bUseTr ? tr.TransformPointY(x1, y1) : y1;
+ let _x2 = bUseTr ? tr.TransformPointX(x2, y2) : x2;
+ let _y2 = bUseTr ? tr.TransformPointY(x2, y2) : y2;
+ let _x3 = bUseTr ? tr.TransformPointX(x3, y3) : x3;
+ let _y3 = bUseTr ? tr.TransformPointY(x3, y3) : y3;
+
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
- oPathToDraw.cubicBezTo(this.xKoeff*x1, this.yKoeff*y1, this.xKoeff*x2, this.yKoeff*y2, this.xKoeff*x3, this.yKoeff*y3);
+ oPathToDraw.cubicBezTo(this.xKoeff*_x1, this.yKoeff*_y1, this.xKoeff*_x2, this.yKoeff*_y2, this.xKoeff*_x3, this.yKoeff*_y3);
}
this.lastX = x3;
this.lastY = y3;
};
CTextDrawer.prototype._c2 = function(x1,y1,x2,y2)
{
+ let tr = this.GetTransform();
+ let bUseTr = this.isStampAnnot;
+
+ let _x1 = bUseTr ? tr.TransformPointX(x1, y1) : x1;
+ let _y1 = bUseTr ? tr.TransformPointY(x1, y1) : y1;
+ let _x2 = bUseTr ? tr.TransformPointX(x2, y2) : x2;
+ let _y2 = bUseTr ? tr.TransformPointY(x2, y2) : y2;
+
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
- oPathToDraw.quadBezTo(this.xKoeff*x1, this.yKoeff*y1, this.xKoeff*x2, this.yKoeff*y2);
+ oPathToDraw.quadBezTo(this.xKoeff*_x1, this.yKoeff*_y1, this.xKoeff*_x2, this.yKoeff*_y2);
}
this.lastX = x2;
this.lastY = y2;
@@ -2178,7 +2284,7 @@ CTextDrawer.prototype.GetFillFromTextPr = function(oTextPr)
var RGBA = oTextPr.FontRef.Color.RGBA;
oColor = new CDocumentColor( RGBA.R, RGBA.G, RGBA.B, RGBA.A );
}
- return AscFormat.CreateUnfilFromRGB(oColor.r, oColor.g, oColor.b);
+ return this.CreateUnfilFromRGB(oColor.r, oColor.g, oColor.b);
}
return null;
}
@@ -2187,15 +2293,21 @@ CTextDrawer.prototype.GetFillFromTextPr = function(oTextPr)
if(this.m_oBrush.Color1.R !== -1)
{
var Color = this.m_oBrush.Color1;
- return AscFormat.CreateUnfilFromRGB(Color.R, Color.G, Color.B);
+ return this.CreateUnfilFromRGB(Color.R, Color.G, Color.B);
}
else
{
- return AscFormat.CreateUnfilFromRGB(0, 0, 0);
+ return this.CreateUnfilFromRGB(0, 0, 0);
}
}
};
+ CTextDrawer.prototype.CreateUnfilFromRGB = function (r, g, b) {
+ let oFill = AscFormat.CreateUnfilFromRGB(r, g, b);
+ oFill.check(this.m_oTheme, AscFormat.GetDefaultColorMap());
+ return oFill;
+ };
+
CTextDrawer.prototype.GetPenFromTextPr = function(oTextPr)
{
if(oTextPr)
@@ -2362,6 +2474,7 @@ function GetRectContentWidth(oContent, dMaxWidth)
window['AscFormat'].DRAW_COMMAND_HIDDEN_ELEM = DRAW_COMMAND_HIDDEN_ELEM;
window['AscFormat'].DRAW_COMMAND_NO_CREATE_GEOM = DRAW_COMMAND_NO_CREATE_GEOM;
window['AscFormat'].DRAW_COMMAND_TABLE_ROW = DRAW_COMMAND_TABLE_ROW;
+ window['AscFormat'].DRAW_COMMAND_SHAPE = DRAW_COMMAND_SHAPE;
window['AscFormat'].CreatePenFromParams = CreatePenFromParams;
window['AscFormat'].CTextDrawer = CTextDrawer;
window['AscFormat'].PolygonWrapper = PolygonWrapper;
diff --git a/common/Drawings/TrackObjects/NewShapeTracks.js b/common/Drawings/TrackObjects/NewShapeTracks.js
index 5ae42a02aa..ff5937336d 100644
--- a/common/Drawings/TrackObjects/NewShapeTracks.js
+++ b/common/Drawings/TrackObjects/NewShapeTracks.js
@@ -277,8 +277,24 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
}, this, []);
- this.track = function(e, x, y)
+ /**
+ *
+ * @param e
+ * @param x
+ * @param y
+ * @param {boolean?} isNoMinSize
+ */
+ this.track = function(e, x, y, isNoMinSize)
{
+ let minShapeSize = MIN_SHAPE_SIZE;
+ let minShapeSizeDiv2 = MIN_SHAPE_SIZE_DIV2;
+
+ // ignore minSize
+ if (isNoMinSize === true) {
+ minShapeSize = 0;
+ minShapeSizeDiv2 = 0;
+ }
+
var bConnectorHandled = false;
this.oShapeDrawConnectors = null;
this.lastSpPr = null;
@@ -360,15 +376,15 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
}
if(!(e.CtrlKey || e.ShiftKey) || (e.CtrlKey && !e.ShiftKey && this.isLine))
{
- this.extX = abs_dist_x >= MIN_SHAPE_SIZE ? abs_dist_x : (this.isLine ? 0 : MIN_SHAPE_SIZE);
- this.extY = abs_dist_y >= MIN_SHAPE_SIZE ? abs_dist_y : (this.isLine ? 0 : MIN_SHAPE_SIZE);
+ this.extX = abs_dist_x >= minShapeSize ? abs_dist_x : (this.isLine ? 0 : minShapeSize);
+ this.extY = abs_dist_y >= minShapeSize ? abs_dist_y : (this.isLine ? 0 : minShapeSize);
if(real_dist_x >= 0)
{
this.x = this.startX;
}
else
{
- this.x = abs_dist_x >= MIN_SHAPE_SIZE ? x : this.startX - this.extX;
+ this.x = abs_dist_x >= minShapeSize ? x : this.startX - this.extX;
}
if(real_dist_y >= 0)
@@ -377,31 +393,31 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
}
else
{
- this.y = abs_dist_y >= MIN_SHAPE_SIZE ? y : this.startY - this.extY;
+ this.y = abs_dist_y >= minShapeSize ? y : this.startY - this.extY;
}
}
else if(e.CtrlKey && !e.ShiftKey)
{
- if(abs_dist_x >= MIN_SHAPE_SIZE_DIV2 )
+ if(abs_dist_x >= minShapeSizeDiv2 )
{
this.x = this.startX - abs_dist_x;
this.extX = 2*abs_dist_x;
}
else
{
- this.x = this.startX - MIN_SHAPE_SIZE_DIV2;
- this.extX = MIN_SHAPE_SIZE;
+ this.x = this.startX - minShapeSizeDiv2;
+ this.extX = minShapeSize;
}
- if(abs_dist_y >= MIN_SHAPE_SIZE_DIV2 )
+ if(abs_dist_y >= minShapeSizeDiv2 )
{
this.y = this.startY - abs_dist_y;
this.extY = 2*abs_dist_y;
}
else
{
- this.y = this.startY - MIN_SHAPE_SIZE_DIV2;
- this.extY = MIN_SHAPE_SIZE;
+ this.y = this.startY - minShapeSizeDiv2;
+ this.extY = minShapeSize;
}
}
else if(!e.CtrlKey && e.ShiftKey)
@@ -411,7 +427,7 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
var prop_coefficient = (typeof AscFormat.SHAPE_ASPECTS[this.presetGeom] === "number" ? AscFormat.SHAPE_ASPECTS[this.presetGeom] : 1);
if(abs_dist_y === 0)
{
- new_width = abs_dist_x > MIN_SHAPE_SIZE ? abs_dist_x : MIN_SHAPE_SIZE;
+ new_width = abs_dist_x > minShapeSize ? abs_dist_x : minShapeSize;
new_height = abs_dist_x/prop_coefficient;
}
else
@@ -429,30 +445,30 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
}
}
- if(new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE)
+ if(new_width < minShapeSize || new_height < minShapeSize)
{
var k_wh = new_width/new_height;
- if(new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE)
+ if(new_height < minShapeSize && new_width < minShapeSize)
{
if(new_height < new_width)
{
- new_height = MIN_SHAPE_SIZE;
+ new_height = minShapeSize;
new_width = new_height*k_wh;
}
else
{
- new_width = MIN_SHAPE_SIZE;
+ new_width = minShapeSize;
new_height = new_width/k_wh;
}
}
- else if(new_height < MIN_SHAPE_SIZE)
+ else if(new_height < minShapeSize)
{
- new_height = MIN_SHAPE_SIZE;
+ new_height = minShapeSize;
new_width = new_height*k_wh;
}
else
{
- new_width = MIN_SHAPE_SIZE;
+ new_width = minShapeSize;
new_height = new_width/k_wh;
}
}
@@ -492,7 +508,7 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
var prop_coefficient = (typeof AscFormat.SHAPE_ASPECTS[this.presetGeom] === "number" ? AscFormat.SHAPE_ASPECTS[this.presetGeom] : 1);
if(abs_dist_y === 0)
{
- new_width = abs_dist_x > MIN_SHAPE_SIZE_DIV2 ? abs_dist_x*2 : MIN_SHAPE_SIZE;
+ new_width = abs_dist_x > minShapeSizeDiv2 ? abs_dist_x*2 : minShapeSize;
new_height = new_width/prop_coefficient;
}
else
@@ -510,30 +526,30 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
}
}
- if(new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE)
+ if(new_width < minShapeSize || new_height < minShapeSize)
{
var k_wh = new_width/new_height;
- if(new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE)
+ if(new_height < minShapeSize && new_width < minShapeSize)
{
if(new_height < new_width)
{
- new_height = MIN_SHAPE_SIZE;
+ new_height = minShapeSize;
new_width = new_height*k_wh;
}
else
{
- new_width = MIN_SHAPE_SIZE;
+ new_width = minShapeSize;
new_height = new_width/k_wh;
}
}
- else if(new_height < MIN_SHAPE_SIZE)
+ else if(new_height < minShapeSize)
{
- new_height = MIN_SHAPE_SIZE;
+ new_height = minShapeSize;
new_width = new_height*k_wh;
}
else
{
- new_width = MIN_SHAPE_SIZE;
+ new_width = minShapeSize;
new_height = new_width/k_wh;
}
}
diff --git a/common/Drawings/TrackObjects/PolyLine.js b/common/Drawings/TrackObjects/PolyLine.js
index f5f3017762..b3b994298a 100644
--- a/common/Drawings/TrackObjects/PolyLine.js
+++ b/common/Drawings/TrackObjects/PolyLine.js
@@ -32,71 +32,82 @@
"use strict";
-(function(window, undefined){
+(function (window, undefined) {
- function CPoint(x, y, bTemporary) {
- this.x = x;
- this.y = y;
- this.bTemporary = bTemporary === true;
- }
- CPoint.prototype.reset = function(x, y, bTemporary) {
- this.x = x;
- this.y = y;
- this.bTemporary = bTemporary === true;
- };
- CPoint.prototype.distance = function(x, y) {
- var dx = this.x - x;
- var dy = this.y - y;
- return Math.sqrt(dx*dx + dy*dy);
- };
- CPoint.prototype.distanceFromOther = function(oPoint) {
- return this.distance(oPoint.x, oPoint.y);
- };
- CPoint.prototype.isNear = function(x, y) {
- return this.distance(x, y) < 1;
- };
-function PolyLine (drawingObjects, theme, master, layout, slide, pageIndex)
-{
+ function CPoint(x, y, bTemporary) {
+ this.x = x;
+ this.y = y;
+ this.bTemporary = bTemporary === true;
+ }
- AscFormat.ExecuteNoHistory(function(){
+ CPoint.prototype.reset = function (x, y, bTemporary) {
+ this.x = x;
+ this.y = y;
+ this.bTemporary = bTemporary === true;
+ };
+ CPoint.prototype.distance = function (x, y) {
+ var dx = this.x - x;
+ var dy = this.y - y;
+ return Math.sqrt(dx * dx + dy * dy);
+ };
+ CPoint.prototype.distanceFromOther = function (oPoint) {
+ return this.distance(oPoint.x, oPoint.y);
+ };
+ CPoint.prototype.isNear = function (x, y) {
+ return this.distance(x, y) < 1;
+ };
+ CPoint.prototype.serialize = function (w) {
+ w.WriteDouble(this.x);
+ w.WriteDouble(this.y);
+ w.WriteBool(this.bTemporary);
+ };
+ CPoint.prototype.deserialize = function (r) {
+ this.x = r.GetDouble();
+ this.y = r.GetDouble();
+ this.bTemporary = r.GetBool();
+ };
- this.drawingObjects = drawingObjects;
- this.arrPoint = [];
- this.Matrix = new AscCommon.CMatrix();
- this.TransformMatrix = new AscCommon.CMatrix();
+ function PolyLine(drawingObjects, theme, master, layout, slide, pageIndex) {
- this.pageIndex = pageIndex;
- this.style = AscFormat.CreateDefaultShapeStyle();
- var style = this.style;
- style.fillRef.Color.Calculate(theme, slide, layout, master, {R:0, G: 0, B:0, A:255});
- var RGBA = style.fillRef.Color.RGBA;
- var pen = theme.getLnStyle(style.lnRef.idx, style.lnRef.Color);
- style.lnRef.Color.Calculate(theme, slide, layout, master);
- RGBA = style.lnRef.Color.RGBA;
+ AscFormat.ExecuteNoHistory(function () {
- const API = Asc.editor || editor;
- const bInkDraw = API.isInkDrawerOn();
- this.bInk = bInkDraw;
- if(bInkDraw)
- {
- pen = API.getInkPen();
- }
- if(pen.Fill)
- {
- pen.Fill.calculate(theme, slide, layout, master, RGBA);
- }
+ this.drawingObjects = drawingObjects;
+ this.arrPoint = [];
+ this.Matrix = new AscCommon.CMatrix();
+ this.TransformMatrix = new AscCommon.CMatrix();
+ this.pageIndex = pageIndex;
+ this.style = AscFormat.CreateDefaultShapeStyle();
+ var style = this.style;
+ style.fillRef.Color.Calculate(theme, slide, layout, master, {R: 0, G: 0, B: 0, A: 255});
+ var RGBA = style.fillRef.Color.RGBA;
+ var pen = theme.getLnStyle(style.lnRef.idx, style.lnRef.Color);
+ style.lnRef.Color.Calculate(theme, slide, layout, master);
+ RGBA = style.lnRef.Color.RGBA;
+
+ const API = Asc.editor || editor;
+ const bInkDraw = API.isInkDrawerOn();
+ this.bInk = bInkDraw;
+ if (bInkDraw) {
+ pen = API.getInkPen();
+ }
+ if (pen.Fill) {
+ pen.Fill.calculate(theme, slide, layout, master, RGBA);
+ }
- this.pen = pen;
- this.polylineForDrawer = new PolylineForDrawer(this);
- this.continuousRanges = [];
+ this.pen = pen;
- }, this, []);
-}
+ this.polylineForDrawer = new PolylineForDrawer(this);
+ this.continuousRanges = [];
+ let oAnnot = Asc.editor.getAnnotations();
+ if(oAnnot) {
+ oAnnot.onCreatePolylineTrack(this, drawingObjects.drawingObjects);
+ }
+ }, this, []);
+ }
- PolyLine.prototype.Draw = function(graphics)
- {
+ PolyLine.prototype.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
@@ -105,311 +116,302 @@ function PolyLine (drawingObjects, theme, master, layout, slide, pageIndex)
oShapeDrawer.fromShape(this, graphics);
oShapeDrawer.draw(this);
};
- PolyLine.prototype.draw = function(oDrawer)
- {
- if(AscFormat.isRealNumber(this.pageIndex) && oDrawer.SetCurrentPage)
- {
+ PolyLine.prototype.draw = function (oDrawer) {
+ if (AscFormat.isRealNumber(this.pageIndex) && oDrawer.SetCurrentPage) {
oDrawer.SetCurrentPage(this.pageIndex);
}
const oGraphics = oDrawer.Graphics || oDrawer;
const API = Asc.editor || editor;
const bInkDraw = API.isInkDrawerOn();
const dOldAlpha = oGraphics.globalAlpha;
- if(bInkDraw)
- {
- if(AscFormat.isRealNumber(oGraphics.globalAlpha) && oGraphics.put_GlobalAlpha)
- {
+ if (bInkDraw) {
+ if (AscFormat.isRealNumber(oGraphics.globalAlpha) && oGraphics.put_GlobalAlpha) {
oGraphics.put_GlobalAlpha(false, 1);
}
}
this.polylineForDrawer.Draw(oDrawer);
- if(AscFormat.isRealNumber(dOldAlpha) && oGraphics.put_GlobalAlpha)
- {
+ if (AscFormat.isRealNumber(dOldAlpha) && oGraphics.put_GlobalAlpha) {
oGraphics.put_GlobalAlpha(true, dOldAlpha);
}
};
- PolyLine.prototype.getBounds = function()
- {
- var boundsChecker = new AscFormat.CSlideBoundsChecker();
- this.draw(boundsChecker);
- boundsChecker.Bounds.posX = boundsChecker.Bounds.min_x;
- boundsChecker.Bounds.posY = boundsChecker.Bounds.min_y;
- boundsChecker.Bounds.extX = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
- boundsChecker.Bounds.extY = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
- return boundsChecker.Bounds;
- };
- PolyLine.prototype.getShape = function(bWord, drawingDocument, drawingObjects)
- {
- var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
- var i;
+ PolyLine.prototype.getBounds = function () {
+ var boundsChecker = new AscFormat.CSlideBoundsChecker();
+ this.draw(boundsChecker);
+ boundsChecker.Bounds.posX = boundsChecker.Bounds.min_x;
+ boundsChecker.Bounds.posY = boundsChecker.Bounds.min_y;
+ boundsChecker.Bounds.extX = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
+ boundsChecker.Bounds.extY = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
+ return boundsChecker.Bounds;
+ };
+ PolyLine.prototype.getShape = function (bWord, drawingDocument, drawingObjects) {
+ var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
+ var i;
- var bClosed = false;
- var min_dist;
- if(drawingObjects)
- {
- min_dist = drawingObjects.convertPixToMM(3);
- }
- else
- {
- min_dist = editor.WordControl.m_oDrawingDocument.GetMMPerDot(3)
- }
- var oLastPoint = this.arrPoint[this.arrPoint.length-1];
- var nLastIndex = this.arrPoint.length-1;
- if(oLastPoint.bTemporary) {
- nLastIndex--;
- }
- if(nLastIndex > 1)
- {
- var dx = this.arrPoint[0].x - this.arrPoint[nLastIndex].x;
- var dy = this.arrPoint[0].y - this.arrPoint[nLastIndex].y;
- if(Math.sqrt(dx*dx +dy*dy) < min_dist)
- {
- bClosed = true;
- }
- }
- if(this.bInk)
- {
- bClosed = false;
- }
- var nMaxPtIdx = bClosed ? (nLastIndex - 1) : nLastIndex;
- for( i = 1; i <= nMaxPtIdx; ++i)
- {
- if(this.arrPoint[i].x > xMax)
- {
- xMax = this.arrPoint[i].x;
- }
- if(this.arrPoint[i].y > yMax)
- {
- yMax = this.arrPoint[i].y;
- }
+ var bClosed = false;
+ var min_dist;
+ if (drawingObjects) {
+ min_dist = drawingObjects.convertPixToMM(3);
+ }
+ else {
+ min_dist = editor.WordControl.m_oDrawingDocument.GetMMPerDot(3)
+ }
+ var oLastPoint = this.arrPoint[this.arrPoint.length - 1];
+ var nLastIndex = this.arrPoint.length - 1;
+ if (oLastPoint.bTemporary) {
+ nLastIndex--;
+ }
+ if (nLastIndex > 1) {
+ var dx = this.arrPoint[0].x - this.arrPoint[nLastIndex].x;
+ var dy = this.arrPoint[0].y - this.arrPoint[nLastIndex].y;
+ if (Math.sqrt(dx * dx + dy * dy) < min_dist) {
+ bClosed = true;
+ }
+ }
+ if (this.bInk) {
+ bClosed = false;
+ }
+ var nMaxPtIdx = bClosed ? (nLastIndex - 1) : nLastIndex;
+ for (i = 1; i <= nMaxPtIdx; ++i) {
+ if (this.arrPoint[i].x > xMax) {
+ xMax = this.arrPoint[i].x;
+ }
+ if (this.arrPoint[i].y > yMax) {
+ yMax = this.arrPoint[i].y;
+ }
- if(this.arrPoint[i].x < xMin)
- {
- xMin = this.arrPoint[i].x;
- }
+ if (this.arrPoint[i].x < xMin) {
+ xMin = this.arrPoint[i].x;
+ }
- if(this.arrPoint[i].y < yMin)
- {
- yMin = this.arrPoint[i].y;
- }
- }
+ if (this.arrPoint[i].y < yMin) {
+ yMin = this.arrPoint[i].y;
+ }
+ }
let shape = this.drawingObjects.createShape();
- // if(drawingObjects)
- // {
- // shape.setWorksheet(drawingObjects.getWorksheetModel());
- // shape.addToDrawingObjects();
- // }
- shape.setSpPr(new AscFormat.CSpPr());
- shape.spPr.setParent(shape);
- shape.spPr.setXfrm(new AscFormat.CXfrm());
- shape.spPr.xfrm.setParent(shape.spPr);
- if(!bWord)
- {
- shape.spPr.xfrm.setOffX(xMin);
- shape.spPr.xfrm.setOffY(yMin);
- }
- else
- {
- shape.setWordShape(true);
- shape.spPr.xfrm.setOffX(0);
- shape.spPr.xfrm.setOffY(0);
- }
- shape.spPr.xfrm.setExtX(xMax-xMin);
- shape.spPr.xfrm.setExtY(yMax - yMin);
- shape.setStyle(AscFormat.CreateDefaultShapeStyle());
- if(this.bInk)
- {
- shape.spPr.setLn(this.pen);
- shape.spPr.setFill(AscFormat.CreateNoFillUniFill());
- }
- var geometry = new AscFormat.Geometry();
+ // if(drawingObjects)
+ // {
+ // shape.setWorksheet(drawingObjects.getWorksheetModel());
+ // shape.addToDrawingObjects();
+ // }
+ shape.setSpPr(new AscFormat.CSpPr());
+ shape.spPr.setParent(shape);
+ shape.spPr.setXfrm(new AscFormat.CXfrm());
+ shape.spPr.xfrm.setParent(shape.spPr);
+ if (!bWord) {
+ shape.spPr.xfrm.setOffX(xMin);
+ shape.spPr.xfrm.setOffY(yMin);
+ }
+ else {
+ shape.setWordShape(true);
+ shape.spPr.xfrm.setOffX(0);
+ shape.spPr.xfrm.setOffY(0);
+ }
+ shape.spPr.xfrm.setExtX(xMax - xMin);
+ shape.spPr.xfrm.setExtY(yMax - yMin);
+ shape.setStyle(AscFormat.CreateDefaultShapeStyle());
+ if (this.bInk) {
+ shape.spPr.setLn(this.pen);
+ shape.spPr.setFill(AscFormat.CreateNoFillUniFill());
+ }
+ var geometry = new AscFormat.Geometry();
- var w = xMax - xMin, h = yMax-yMin;
- var kw, kh, pathW, pathH;
- if(w > 0)
- {
- pathW = 43200;
- kw = 43200/ w;
- }
- else
- {
- pathW = 0;
- kw = 0;
- }
- if(h > 0)
- {
- pathH = 43200;
- kh = 43200 / h;
- }
- else
- {
- pathH = 0;
- kh = 0;
- }
- geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, pathW, pathH);
- geometry.AddRect("l", "t", "r", "b");
- geometry.AddPathCommand(1, (((this.arrPoint[0].x - xMin) * kw) >> 0) + "", (((this.arrPoint[0].y - yMin) * kh) >> 0) + "");
- i = 1;
- var aRanges = this.continuousRanges;
- var aRange, nRange;
- var nEnd;
- var nPtsCount = this.arrPoint.length;
- var oPt1, oPt2, oPt3, nPt;
- for(nRange = 0; nRange < aRanges.length; ++nRange)
- {
- aRange = aRanges[nRange];
- if(aRange[0] + 1 > nMaxPtIdx) {
- break;
- }
- nPt = aRange[0] + 1;
- nEnd = Math.min(aRange[1], nMaxPtIdx);
- while(nPt <= nEnd)
- {
- if(nPt + 2 <= nEnd)
- {
- //cubic bezier curve
- oPt1 = this.arrPoint[nPt++];
- oPt2 = this.arrPoint[nPt++];
- oPt3 = this.arrPoint[nPt++];
- geometry.AddPathCommand(5,
- (((oPt1.x - xMin) * kw) >> 0) + "", (((oPt1.y - yMin) * kh) >> 0) + "",
- (((oPt2.x - xMin) * kw) >> 0) + "", (((oPt2.y - yMin) * kh) >> 0) + "",
- (((oPt3.x - xMin) * kw) >> 0) + "", (((oPt3.y - yMin) * kh) >> 0) + ""
- );
- }
- else if(nPt + 1 <= nEnd)
- {
- //quad bezier curve
- oPt1 = this.arrPoint[nPt++];
- oPt2 = this.arrPoint[nPt++];
- geometry.AddPathCommand(4,
- (((oPt1.x - xMin) * kw) >> 0) + "", (((oPt1.y - yMin) * kh) >> 0) + "",
- (((oPt2.x - xMin) * kw) >> 0) + "", (((oPt2.y - yMin) * kh) >> 0) + ""
- );
- }
- else
- {
- //lineTo
- oPt1 = this.arrPoint[nPt++];
- geometry.AddPathCommand(2,
- (((oPt1.x - xMin) * kw) >> 0) + "", (((oPt1.y - yMin) * kh) >> 0) + ""
- );
- }
- }
- }
- if(bClosed)
- {
- geometry.AddPathCommand(6);
- }
+ var w = xMax - xMin, h = yMax - yMin;
+ var kw, kh, pathW, pathH;
+ if (w > 0) {
+ pathW = 43200;
+ kw = 43200 / w;
+ }
+ else {
+ pathW = 0;
+ kw = 0;
+ }
+ if (h > 0) {
+ pathH = 43200;
+ kh = 43200 / h;
+ }
+ else {
+ pathH = 0;
+ kh = 0;
+ }
+ geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, pathW, pathH);
+ geometry.AddRect("l", "t", "r", "b");
+ geometry.AddPathCommand(1, (((this.arrPoint[0].x - xMin) * kw) >> 0) + "", (((this.arrPoint[0].y - yMin) * kh) >> 0) + "");
+ i = 1;
+ var aRanges = this.continuousRanges;
+ var aRange, nRange;
+ var nEnd;
+ var nPtsCount = this.arrPoint.length;
+ var oPt1, oPt2, oPt3, nPt;
+ for (nRange = 0; nRange < aRanges.length; ++nRange) {
+ aRange = aRanges[nRange];
+ if (aRange[0] + 1 > nMaxPtIdx) {
+ break;
+ }
+ nPt = aRange[0] + 1;
+ nEnd = Math.min(aRange[1], nMaxPtIdx);
+ while (nPt <= nEnd) {
+ if (nPt + 2 <= nEnd) {
+ //cubic bezier curve
+ oPt1 = this.arrPoint[nPt++];
+ oPt2 = this.arrPoint[nPt++];
+ oPt3 = this.arrPoint[nPt++];
+ geometry.AddPathCommand(5, (((oPt1.x - xMin) * kw) >> 0) + "", (((oPt1.y - yMin) * kh) >> 0) + "", (((oPt2.x - xMin) * kw) >> 0) + "", (((oPt2.y - yMin) * kh) >> 0) + "", (((oPt3.x - xMin) * kw) >> 0) + "", (((oPt3.y - yMin) * kh) >> 0) + "");
+ }
+ else if (nPt + 1 <= nEnd) {
+ //quad bezier curve
+ oPt1 = this.arrPoint[nPt++];
+ oPt2 = this.arrPoint[nPt++];
+ geometry.AddPathCommand(4, (((oPt1.x - xMin) * kw) >> 0) + "", (((oPt1.y - yMin) * kh) >> 0) + "", (((oPt2.x - xMin) * kw) >> 0) + "", (((oPt2.y - yMin) * kh) >> 0) + "");
+ }
+ else {
+ //lineTo
+ oPt1 = this.arrPoint[nPt++];
+ geometry.AddPathCommand(2, (((oPt1.x - xMin) * kw) >> 0) + "", (((oPt1.y - yMin) * kh) >> 0) + "");
+ }
+ }
+ }
+ if (bClosed) {
+ geometry.AddPathCommand(6);
+ }
- shape.spPr.setGeometry(geometry);
- shape.setBDeleted(false);
- shape.recalculate();
- shape.x = xMin;
- shape.y = yMin;
- return shape;
- };
- PolyLine.prototype.tryAddPoint = function(x, y)
- {
- var oLastPoint = this.arrPoint[this.arrPoint.length - 1];
- if(!oLastPoint) {
- this.addPoint(x, y);
- return;
- }
- if(oLastPoint.isNear(x, y)) {
- //oLastPoint.reset(x, y);
- return;
- }
- this.addPoint(x, y);
- };
+ shape.spPr.setGeometry(geometry);
+ shape.setBDeleted(false);
+ shape.recalculate();
+ shape.x = xMin;
+ shape.y = yMin;
+ return shape;
+ };
+ PolyLine.prototype.checkAnnotationChanges = function () {
+ let oAnnot = Asc.editor.getAnnotations();
+ if(oAnnot) {
+ oAnnot.onPolylineTrackChanged(this);
+ }
+ };
+ PolyLine.prototype.tryAddPoint = function (x, y) {
+ var oLastPoint = this.arrPoint[this.arrPoint.length - 1];
+ if (!oLastPoint) {
+ this.addPoint(x, y);
+ this.checkAnnotationChanges();
+ return;
+ }
+ if (oLastPoint.isNear(x, y)) {
+ //oLastPoint.reset(x, y);
+ return;
+ }
+ this.addPoint(x, y);
+ this.checkAnnotationChanges();
+ };
- PolyLine.prototype.createContinuousRange = function()
- {
- var nIdx = this.arrPoint.length - 1;
- this.continuousRanges.push([nIdx, nIdx]);
- };
- PolyLine.prototype.getLastContinuousRange = function()
- {
- if(this.continuousRanges.length === 0) {
- this.createContinuousRange();
- }
- return this.continuousRanges[this.continuousRanges.length - 1];
- };
- PolyLine.prototype.addPoint = function(x, y, bTemporary)
- {
- this.arrPoint.push(new CPoint(x, y, bTemporary));
- var oLastRange = this.getLastContinuousRange();
- oLastRange[1] = this.arrPoint.length - 1;
- };
- PolyLine.prototype.replaceLastPoint = function(x, y, bTemporary)
- {
- var oLastPoint = this.arrPoint[this.arrPoint.length - 1];
- if(!oLastPoint) {
- this.addPoint(x, y, bTemporary);
- return;
- }
- oLastPoint.reset(x, y, bTemporary);
- var oLastRange = this.getLastContinuousRange();
- if(oLastRange[0] !== this.arrPoint.length - 1) {
- this.createContinuousRange();
- }
- };
- PolyLine.prototype.canCreateShape = function()
- {
- var nCount = this.arrPoint.length;
- if(nCount < 2) {
- return false;
+ PolyLine.prototype.createContinuousRange = function () {
+ var nIdx = this.arrPoint.length - 1;
+ this.continuousRanges.push([nIdx, nIdx]);
+ };
+ PolyLine.prototype.getLastContinuousRange = function () {
+ if (this.continuousRanges.length === 0) {
+ this.createContinuousRange();
+ }
+ return this.continuousRanges[this.continuousRanges.length - 1];
+ };
+ PolyLine.prototype.addPoint = function (x, y, bTemporary) {
+ this.arrPoint.push(new CPoint(x, y, bTemporary));
+ let oLastRange = this.getLastContinuousRange();
+ oLastRange[1] = this.arrPoint.length - 1;
+
+ };
+ PolyLine.prototype.replaceLastPoint = function (x, y, bTemporary) {
+ let oLastPoint = this.arrPoint[this.arrPoint.length - 1];
+ if (!oLastPoint) {
+ this.addPoint(x, y, bTemporary);
+ this.checkAnnotationChanges();
+ return;
+ }
+ oLastPoint.reset(x, y, bTemporary);
+ let oLastRange = this.getLastContinuousRange();
+ if (oLastRange[0] !== this.arrPoint.length - 1) {
+ this.createContinuousRange();
+ }
+ this.checkAnnotationChanges();
+ };
+ PolyLine.prototype.canCreateShape = function () {
+ var nCount = this.arrPoint.length;
+ if (nCount < 2) {
+ return false;
+ }
+ var oLast = this.arrPoint[this.arrPoint.length - 1];
+ if (oLast.bTemporary) {
+ --nCount;
+ }
+ return nCount > 1;
+ };
+ PolyLine.prototype.getPointsCount = function () {
+ return this.arrPoint.length;
+ };
+ PolyLine.prototype.serialize = function (w) {
+ let nCount = this.arrPoint.length;
+ w.WriteLong(nCount);
+ for(let nPt = 0; nPt < nCount; ++nPt) {
+ this.arrPoint[nPt].serialize(w);
}
- var oLast = this.arrPoint[this.arrPoint.length - 1];
- if(oLast.bTemporary) {
- --nCount;
+ let nRangesCount = this.continuousRanges.length;
+ w.WriteLong(nRangesCount);
+ for(let nRange = 0; nRange < nRangesCount; ++nRange) {
+ let oRange = this.continuousRanges[nRange];
+ w.WriteLong(oRange[0]);
+ w.WriteLong(oRange[1]);
+ }
+ };
+ PolyLine.prototype.deserialize = function (r) {
+ this.arrPoint.length = 0;
+ this.continuousRanges.length = 0;
+ let nCount = r.GetLong();
+ for(let nPt = 0; nPt < nCount; ++nPt) {
+ let oPt = new CPoint();
+ oPt.deserialize(r);
+ this.arrPoint.push(oPt);
}
- return nCount > 1;
- };
- PolyLine.prototype.getPointsCount = function()
- {
- return this.arrPoint.length;
- };
+ let nRangesCount = r.GetLong();
+ for(let nRange = 0; nRange < nRangesCount; ++nRange) {
+ let oRange = [];
+ oRange[0] = r.GetLong();
+ oRange[1] = r.GetLong();
+ this.continuousRanges.push(oRange);
+ }
+ };
-function PolylineForDrawer(polyline)
-{
- this.polyline = polyline;
- this.pen = polyline.pen;
- this.brush = polyline.brush;
- this.TransformMatrix = polyline.TransformMatrix;
- this.Matrix = polyline.Matrix;
+ function PolylineForDrawer(polyline) {
+ this.polyline = polyline;
+ this.pen = polyline.pen;
+ this.brush = polyline.brush;
+ this.TransformMatrix = polyline.TransformMatrix;
+ this.Matrix = polyline.Matrix;
- this.Draw = function(graphics)
- {
- graphics.SetIntegerGrid(false);
- graphics.transform3(this.Matrix);
+ this.Draw = function (graphics) {
+ graphics.SetIntegerGrid(false);
+ graphics.transform3(this.Matrix);
- const shape_drawer = new AscCommon.CShapeDrawer();
- shape_drawer.fromShape(this, graphics);
- shape_drawer.draw(this);
- };
- this.draw = function(g)
- {
- g._e();
- if(this.polyline.arrPoint.length < 2)
- {
- return;
- }
- g._m(this.polyline.arrPoint[0].x, this.polyline.arrPoint[0].y);
- for(var i = 1; i < this.polyline.arrPoint.length; ++i)
- {
- g._l(this.polyline.arrPoint[i].x, this.polyline.arrPoint[i].y);
- }
- g.ds();
- };
-}
+ const shape_drawer = new AscCommon.CShapeDrawer();
+ shape_drawer.fromShape(this, graphics);
+ shape_drawer.draw(this);
+ };
+ this.draw = function (g) {
+ g._e();
+ if (this.polyline.arrPoint.length < 2) {
+ return;
+ }
+ g._m(this.polyline.arrPoint[0].x, this.polyline.arrPoint[0].y);
+ for (var i = 1; i < this.polyline.arrPoint.length; ++i) {
+ g._l(this.polyline.arrPoint[i].x, this.polyline.arrPoint[i].y);
+ }
+ g.ds();
+ };
+ }
- //--------------------------------------------------------export----------------------------------------------------
- window['AscFormat'] = window['AscFormat'] || {};
- window['AscFormat'].PolyLine = PolyLine;
+ //--------------------------------------------------------export----------------------------------------------------
+ window['AscFormat'] = window['AscFormat'] || {};
+ window['AscFormat'].PolyLine = PolyLine;
})(window);
diff --git a/common/Drawings/TrackObjects/ResizeTracks.js b/common/Drawings/TrackObjects/ResizeTracks.js
index cb837c1d76..6f8c9a09c1 100644
--- a/common/Drawings/TrackObjects/ResizeTracks.js
+++ b/common/Drawings/TrackObjects/ResizeTracks.js
@@ -1096,13 +1096,18 @@ function ResizeTrackShapeImage(originalObject, cardDirection, drawingsController
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
- if(this.resizedflipH)
- {
- global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
- }
- if(this.resizedflipV)
+ // no flip inside FreeText annot
+ let isInFreeTextAnnot = this.originalObject.group && this.originalObject.group.IsFreeText && this.originalObject.group.IsFreeText();
+ if (!isInFreeTextAnnot)
{
- global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
+ if(this.resizedflipH)
+ {
+ global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
+ }
+ if(this.resizedflipV)
+ {
+ global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
+ }
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
diff --git a/common/Drawings/WorkEvents.js b/common/Drawings/WorkEvents.js
index eaa6d9cbe4..52bca66963 100644
--- a/common/Drawings/WorkEvents.js
+++ b/common/Drawings/WorkEvents.js
@@ -810,7 +810,7 @@
if (this.isUseRequestAnimationFrame)
{
- this.cancelAnimationFrame(this.id);
+ this.cancelAnimationFrame.call(window, this.id);
}
else
{
@@ -881,6 +881,83 @@
return isSupport;
}
+ function checkMouseWhell(e, options)
+ {
+ let isSupportBidirectional = false;
+ let isAllowHorizontal = false;
+ let isUseMaximumDelta = false;
+
+ if (options)
+ {
+ isSupportBidirectional = (true === options.isSupportBidirectional);
+ isAllowHorizontal = (true === options.isAllowHorizontal);
+ isUseMaximumDelta = (true === options.isUseMaximumDelta);
+ }
+
+ let delta = 0;
+ let deltaX = 0;
+ let deltaY = 0;
+
+ // delta
+ if (undefined !== e.wheelDelta && 0 !== e.wheelDelta)
+ {
+ delta = -45 * e.wheelDelta / 120;
+ }
+ else if (undefined !== e.detail && 0 !== e.detail)
+ {
+ delta = 45 * e.detail / 3;
+ }
+
+ // y
+ if (undefined !== e.wheelDeltaY)
+ {
+ deltaY = -45 * e.wheelDeltaY / 120;
+ }
+ else
+ deltaY = delta;
+
+ // x
+ if (isAllowHorizontal)
+ {
+ if (undefined !== e.wheelDeltaX)
+ {
+ deltaX = -45 * e.wheelDeltaX / 120;
+ }
+
+ if (e.axis !== undefined && e.axis === e.HORIZONTAL_AXIS)
+ {
+ deltaY = 0;
+
+ if (0 === deltaX)
+ deltaX = delta;
+ }
+ }
+
+ deltaX >>= 0;
+ deltaY >>= 0;
+
+ if (!isSupportBidirectional)
+ {
+ if (isUseMaximumDelta)
+ {
+ if (Math.abs(deltaY) >= Math.abs(deltaX))
+ deltaX = 0;
+ else
+ deltaY = 0;
+ }
+ else
+ {
+ if (0 !== deltaX)
+ deltaY = 0;
+ }
+ }
+
+ return {
+ x : deltaX,
+ y : deltaY
+ };
+ }
+
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].g_mouse_event_type_down = g_mouse_event_type_down;
@@ -909,4 +986,6 @@
window['AscCommon'].PaintMessageLoop = PaintMessageLoop;
window['AscCommon'].isSupportDoublePx = isSupportDoublePx;
+ window['AscCommon'].checkMouseWhell = checkMouseWhell;
+
})(window);
diff --git a/common/ExternalDataLoader.js b/common/ExternalDataLoader.js
index dfc2749944..27268df087 100644
--- a/common/ExternalDataLoader.js
+++ b/common/ExternalDataLoader.js
@@ -60,6 +60,14 @@
const sToken = oData['token'];
const sKey = oData['key'];
+ //check updated file on server. compare keys. if file not updated - check only collaborative editing
+ let curEr = oThis.externalReferences[i].externalReference;
+ let curErKey = curEr.getKey();
+ oData.notChangedFile = sKey === curEr.getKey();
+ if (curErKey == null) {
+ curEr.setKey(sKey);
+ }
+
if (!sKey) {
//if don't have key, then don't have force save
isForceSavePossible = false;
@@ -84,6 +92,7 @@
arrData[i]["url"] = oResult["url"];
arrData[i]["fileType"] = "xlsx";
arrData[i]["token"] = null;
+ arrData[i].notChangedFile = false;
}
fResolve();
});
@@ -103,7 +112,7 @@
const nLength = Math.max(arrData.length, this.externalReferences.length);
const arrFPromiseGetters = [];
for (let i = 0; i < nLength; i += 1) {
- if (this.isLocalDesktop || (arrData[i] && !arrData[i]["error"])) {
+ if (this.isLocalDesktop || (arrData[i] && !arrData[i]["error"] && !arrData[i].notChangedFile)) {
const oPromiseGetter = new CExternalDataPromiseGetter(this.api, this.getExternalReference(i), arrData[i]);
arrFPromiseGetters.push(oPromiseGetter.getPromise.bind(oPromiseGetter));
}
diff --git a/common/HistoryCommon.js b/common/HistoryCommon.js
index 0049c537e5..afdf6d1792 100644
--- a/common/HistoryCommon.js
+++ b/common/HistoryCommon.js
@@ -1325,6 +1325,9 @@
case AscDFH.historydescription_Collaborative_DeletedTextRecovery:
sString = "Collaborative_DeletedTextRecovery";
break;
+ case AscDFH.historydescription_Presentation_MergeSelectedShapes:
+ sString = "Presentation_MergeSelectedShapes";
+ break;
}
return sString;
}
@@ -1805,7 +1808,7 @@
window['AscDFH'].historyitem_type_Pdf_List_Form = 2228 << 16;
window['AscDFH'].historyitem_type_Pdf_Drawing = 2229 << 16;
window['AscDFH'].historyitem_type_Pdf_Page = 2230 << 16;
- window['AscDFH'].historyitem_type_Pdf_Annot_Stamp = 2230 << 16;
+ window['AscDFH'].historyitem_type_Pdf_Annot_Stamp = 2231 << 16;
window['AscDFH'].historyitem_type_CustomProperties = 2301 << 16;
@@ -1889,6 +1892,7 @@
window['AscDFH'].historyitem_Paragraph_SuppressLineNumbers = window['AscDFH'].historyitem_type_Paragraph | 39;
window['AscDFH'].historyitem_Paragraph_Shd_Fill = window['AscDFH'].historyitem_type_Paragraph | 40;
window['AscDFH'].historyitem_Paragraph_Shd_ThemeFill = window['AscDFH'].historyitem_type_Paragraph | 41;
+ window['AscDFH'].historyitem_Paragraph_Bidi = window['AscDFH'].historyitem_type_Paragraph | 42;
//------------------------------------------------------------------------------------------------------------------
// Типы изменений в классе ParaTextPr
//------------------------------------------------------------------------------------------------------------------
@@ -2322,7 +2326,8 @@
window['AscDFH'].historyitem_SdtPr_FormPr = window['AscDFH'].historyitem_type_SdtPr | 22;
window['AscDFH'].historyitem_SdtPr_PictureFormPr = window['AscDFH'].historyitem_type_SdtPr | 23;
window['AscDFH'].historyitem_SdtPr_ComplexFormPr = window['AscDFH'].historyitem_type_SdtPr | 24;
- window['AscDFH'].historyitem_SdtPr_OForm = window['AscDFH'].historyitem_type_SdtPr | 24;
+ window['AscDFH'].historyitem_SdtPr_OForm = window['AscDFH'].historyitem_type_SdtPr | 25;
+ window['AscDFH'].historyitem_SdtPr_DataBinding = window['AscDFH'].historyitem_type_SdtPr | 26;
//------------------------------------------------------------------------------------------------------------------
// Типы изменений в классе CSdtPr
//------------------------------------------------------------------------------------------------------------------
@@ -3265,6 +3270,7 @@
window['AscDFH'].historyitem_Sparkline_ChangeData = window['AscDFH'].historyitem_type_Sparkline | 27;
window['AscDFH'].historyitem_Sparkline_RemoveData = window['AscDFH'].historyitem_type_Sparkline | 28;
window['AscDFH'].historyitem_Sparkline_RemoveSparkline = window['AscDFH'].historyitem_type_Sparkline | 29;
+ window['AscDFH'].historyitem_Sparkline_Worksheet = window['AscDFH'].historyitem_type_Sparkline | 30;
window['AscDFH'].historyitem_NotesMasterSetHF = window['AscDFH'].historyitem_type_NotesMaster | 1;
@@ -4005,9 +4011,13 @@
AscDFH.historyitem_Pdf_Form_Add_Kid = AscDFH.historyitem_type_Pdf_Form | 2;
AscDFH.historyitem_Pdf_Form_Remove_Kid = AscDFH.historyitem_type_Pdf_Form | 3;
AscDFH.historyitem_Pdf_Form_Change_Display = AscDFH.historyitem_type_Pdf_Form | 4;
+ AscDFH.historyitem_Pdf_Form_Changed = AscDFH.historyitem_type_Pdf_Form | 5;
+ AscDFH.historyitem_Pdf_Form_Parent_Value = AscDFH.historyitem_type_Pdf_Form | 6;
+ AscDFH.historyitem_Pdf_Form_Format_Value = AscDFH.historyitem_type_Pdf_Form | 7;
- AscDFH.historyitem_Pdf_List_Form_Cur_Idxs = AscDFH.historyitem_type_Pdf_List_Form | 1;
- AscDFH.historyitem_Pdf_List_Form_Top_Idx = AscDFH.historyitem_type_Pdf_List_Form | 2;
+ AscDFH.historyitem_Pdf_List_Form_Cur_Idxs = AscDFH.historyitem_type_Pdf_List_Form | 1;
+ AscDFH.historyitem_Pdf_List_Form_Top_Idx = AscDFH.historyitem_type_Pdf_List_Form | 2;
+ AscDFH.historyitem_Pdf_List_Form_Parent_Cur_Idxs = AscDFH.historyitem_type_Pdf_List_Form | 3;
AscDFH.historyitem_Pdf_Pushbutton_Image = AscDFH.historyitem_type_Pdf_Pushbutton | 1;
@@ -4037,6 +4047,8 @@
AscDFH.historyitem_Pdf_Annot_Intent = AscDFH.historyitem_type_Pdf_Annot | 18;
AscDFH.historyitem_Pdf_Annot_Rotate = AscDFH.historyitem_type_Pdf_Annot | 19;
AscDFH.historyitem_Pdf_Annot_User_Id = AscDFH.historyitem_type_Pdf_Annot | 20;
+ AscDFH.historyitem_Pdf_Annot_Changed = AscDFH.historyitem_type_Pdf_Annot | 21;
+ AscDFH.historyitem_Pdf_Annot_Changed_View = AscDFH.historyitem_type_Pdf_Annot | 22;
// Comment
AscDFH.historyitem_Pdf_Comment_Data = AscDFH.historyitem_type_Pdf_Comment | 1;
@@ -4057,6 +4069,7 @@
// annot stamp
AscDFH.historyitem_Pdf_Stamp_Type = AscDFH.historyitem_type_Pdf_Annot_Stamp | 1;
+ AscDFH.historyitem_Pdf_Stamp_InRect = AscDFH.historyitem_type_Pdf_Annot_Stamp | 2;
//------------------------------------------------------------------------------------------------------------------
// Типы изменений в PDF drawing prototype
@@ -4535,6 +4548,10 @@
window['AscDFH'].historydescription_CustomProperties_Add = 0x01b8;
window['AscDFH'].historydescription_CustomProperties_Remove = 0x01b9;
window['AscDFH'].historydescription_CustomProperties_Modify = 0x01c0;
+
+ window['AscDFH'].historydescription_Presentation_MergeSelectedShapes = 0x01c1;
+ window['AscDFH'].historydescription_Presentation_SaveAnnotations = 0x01c2;
+ window['AscDFH'].historydescription_Document_SetParagraphBidi = 0x01c3;
// pdf
window['AscDFH'].historydescription_Pdf_AddAnnot = 0x29a;
window['AscDFH'].historydescription_Pdf_FreeTextGeom = 0x29b;
@@ -4554,6 +4571,9 @@
window['AscDFH'].historydescription_Pdf_ExecActions = 0x2a8;
window['AscDFH'].historydescription_Pdf_FreeTextFitTextBox = 0x2a9;
window['AscDFH'].historydescription_Pdf_AddComment = 0x2b0;
+ window['AscDFH'].historydescription_Pdf_ChangeStrokeColor = 0x2b1;
+ window['AscDFH'].historydescription_Pdf_ChangeFillColor = 0x2b2;
+ window['AscDFH'].historydescription_Pdf_ChangeOpacity = 0x2b3;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4634,6 +4654,10 @@
{
return false;
};
+ CChangesBase.prototype.IsSpreadsheetChange = function()
+ {
+ return false;
+ };
CChangesBase.prototype.CreateReverseChange = function()
{
return null;
diff --git a/common/Images/reporter/buttons.png b/common/Images/reporter/buttons.png
index 4b66346b27..1ca4614ca2 100644
Binary files a/common/Images/reporter/buttons.png and b/common/Images/reporter/buttons.png differ
diff --git a/common/Images/reporter/buttons@1.25x.png b/common/Images/reporter/buttons@1.25x.png
index 0702c96e09..2a0ced31dd 100644
Binary files a/common/Images/reporter/buttons@1.25x.png and b/common/Images/reporter/buttons@1.25x.png differ
diff --git a/common/Images/reporter/buttons@1.5x.png b/common/Images/reporter/buttons@1.5x.png
index 3703ff55f6..4e8057f180 100644
Binary files a/common/Images/reporter/buttons@1.5x.png and b/common/Images/reporter/buttons@1.5x.png differ
diff --git a/common/Images/reporter/buttons@1.75x.png b/common/Images/reporter/buttons@1.75x.png
index 95772328ef..0963f5645f 100644
Binary files a/common/Images/reporter/buttons@1.75x.png and b/common/Images/reporter/buttons@1.75x.png differ
diff --git a/common/Images/reporter/buttons@2x.png b/common/Images/reporter/buttons@2x.png
index 31e36dc9a3..40efa9c875 100644
Binary files a/common/Images/reporter/buttons@2x.png and b/common/Images/reporter/buttons@2x.png differ
diff --git a/common/Local/common.js b/common/Local/common.js
index 92d4720fe7..61e012926b 100644
--- a/common/Local/common.js
+++ b/common/Local/common.js
@@ -212,67 +212,83 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data, _len)
/////////////////////////////////////////////////////////
////////////// IMAGES ////////////////////////
/////////////////////////////////////////////////////////
-var prot = AscCommon.DocumentUrls.prototype;
-prot.mediaPrefix = 'media/';
-prot.init = function(urls) {
-};
-prot.getUrls = function() {
- return this.urls;
-};
-prot.addUrls = function(urls){
-};
-prot.addImageUrl = function(strPath, url){
-};
-prot.getImageUrl = function(strPath){
- if (0 === strPath.indexOf('theme'))
- return null;
-
- if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
- return null;
- return this.documentUrl + "/media/" + strPath;
-};
-prot.getImageLocal = function(_url){
- let url = _url.replaceAll("%20", " ");
- var _first = this.documentUrl + "/media/";
- if (0 === url.indexOf(_first))
- return url.substring(_first.length);
-
- if (window.editor && window.editor.ThemeLoader && 0 === url.indexOf(editor.ThemeLoader.ThemesUrlAbs)) {
- return url.substring(editor.ThemeLoader.ThemesUrlAbs.length);
- }
+let isOverrideDocumentUrls = window['Asc']['VisioEditorApi'] ? false : true;
- return null;
-};
-prot.imagePath2Local = function(imageLocal)
+if (isOverrideDocumentUrls)
{
- if (imageLocal && this.mediaPrefix === imageLocal.substring(0, this.mediaPrefix.length))
- imageLocal = imageLocal.substring(this.mediaPrefix.length);
- return imageLocal;
-};
-prot.getUrl = function(strPath){
- if (0 === strPath.indexOf('theme'))
- return null;
+ var prot = AscCommon.DocumentUrls.prototype;
+ prot.mediaPrefix = 'media/';
+ prot.init = function(urls)
+ {
+ };
+ prot.getUrls = function()
+ {
+ return this.urls;
+ };
+ prot.addUrls = function(urls)
+ {
+ };
+ prot.addImageUrl = function(strPath, url)
+ {
+ };
+ prot.getImageUrl = function(strPath)
+ {
+ if (0 === strPath.indexOf('theme'))
+ return null;
- if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
- return null;
+ if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
+ return null;
- if (strPath == "Editor.xlsx")
+ return this.documentUrl + "/media/" + strPath;
+ };
+ prot.getImageLocal = function(_url)
{
- var test = this.documentUrl + "/" + strPath;
- if (window["AscDesktopEditor"]["IsLocalFileExist"](test))
- return test;
- return undefined;
- }
+ let url = _url.replaceAll("%20", " ");
+ var _first = this.documentUrl + "/media/";
+ if (0 === url.indexOf(_first))
+ return url.substring(_first.length);
- return this.documentUrl + "/media/" + strPath;
-};
-prot.getLocal = function(url){
- return this.getImageLocal(url);
-};
-prot.isThemeUrl = function(sUrl){
- return sUrl && (0 === sUrl.indexOf('theme'));
-};
+ if (window.editor && window.editor.ThemeLoader && 0 === url.indexOf(editor.ThemeLoader.ThemesUrlAbs))
+ {
+ return url.substring(editor.ThemeLoader.ThemesUrlAbs.length);
+ }
+
+ return null;
+ };
+ prot.imagePath2Local = function(imageLocal)
+ {
+ if (imageLocal && this.mediaPrefix === imageLocal.substring(0, this.mediaPrefix.length))
+ imageLocal = imageLocal.substring(this.mediaPrefix.length);
+ return imageLocal;
+ };
+ prot.getUrl = function(strPath)
+ {
+ if (0 === strPath.indexOf('theme'))
+ return null;
+
+ if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
+ return null;
+
+ if (strPath == "Editor.xlsx")
+ {
+ var test = this.documentUrl + "/" + strPath;
+ if (window["AscDesktopEditor"]["IsLocalFileExist"](test))
+ return test;
+ return undefined;
+ }
+
+ return this.documentUrl + "/media/" + strPath;
+ };
+ prot.getLocal = function(url)
+ {
+ return this.getImageLocal(url);
+ };
+ prot.isThemeUrl = function(sUrl)
+ {
+ return sUrl && (0 === sUrl.indexOf('theme'));
+ };
+}
AscCommon.sendImgUrls = function(api, images, callback)
{
@@ -695,7 +711,7 @@ function getBinaryArray(_data, _len)
}
// encryption ----------------------------------
-var _proto = Asc['asc_docs_api'] ? Asc['asc_docs_api'] : Asc['spreadsheet_api'];
+var _proto = Asc['asc_docs_api'] || Asc['spreadsheet_api'] || Asc['VisioEditorApi'];
_proto.prototype["pluginMethod_OnEncryption"] = function(obj)
{
var _editor = window["Asc"]["editor"] ? window["Asc"]["editor"] : window.editor;
diff --git a/common/Native/native.js b/common/Native/native.js
index dafd787a33..b0b79f1971 100644
--- a/common/Native/native.js
+++ b/common/Native/native.js
@@ -269,13 +269,18 @@ function NativeCreateApi(options)
switch (window.NATIVE_DOCUMENT_TYPE)
{
- case "draw":
case "document":
case "presentation":
{
Api = new window["Asc"]["asc_docs_api"](configApi);
if (options && options["documentLayout"] && undefined !== options["documentLayout"]["openedAt"])
Api.setOpenedAt(options["documentLayout"]["openedAt"]);
+ if (options && options["documentLayout"] && undefined !== options["documentLayout"]["headingsColor"])
+ {
+ let rgba = window["AscCommon"]["RgbaTextToRGBA"](options["documentLayout"]["headingsColor"]);
+ if (window["AscWord"] && window["AscWord"]["setDefaultHeadingColor"])
+ window["AscWord"]["setDefaultHeadingColor"](rgba.R, rgba.G, rgba.B);
+ }
break;
}
case "spreadsheet":
@@ -288,6 +293,11 @@ function NativeCreateApi(options)
Api = new window["Asc"]["PDFEditorApi"](configApi);
break;
}
+ case "visio":
+ {
+ Api = new window["Asc"]["VisioEditorApi"](configApi);
+ break;
+ }
default:
break;
}
@@ -302,7 +312,7 @@ function NativeOpenFileData(data, version, xlsx_file_path, options)
switch (window.NATIVE_DOCUMENT_TYPE)
{
- case "draw":
+ case "visio":
case "document":
case "presentation":
{
diff --git a/common/Scrolls/mobileTouchManagerBase.js b/common/Scrolls/mobileTouchManagerBase.js
index dced457e37..cc9c77a61a 100644
--- a/common/Scrolls/mobileTouchManagerBase.js
+++ b/common/Scrolls/mobileTouchManagerBase.js
@@ -805,7 +805,8 @@
}
case AscCommon.c_oEditorId.Spreadsheet:
{
- if (this.Api.isStartAddShape === true)
+ if (this.Api.isStartAddShape === true ||
+ this.Api.isInkDrawerOn())
{
this.desktopTouchState = false;
}
@@ -813,7 +814,17 @@
}
case AscCommon.c_oEditorId.Presentation:
{
- if (this.Api.isStartAddShape === true)
+ if (this.Api.isStartAddShape === true ||
+ this.Api.isInkDrawerOn())
+ {
+ this.desktopTouchState = false;
+ }
+ break;
+ }
+ case AscCommon.c_oEditorId.Visio:
+ {
+ if (this.Api.isStartAddShape === true ||
+ this.Api.isInkDrawerOn())
{
this.desktopTouchState = false;
}
@@ -1337,7 +1348,9 @@
CMobileTouchManagerBase.prototype.Destroy = function()
{
var _scroller = document.getElementById(this.iScrollElement);
- this.delegate.GetScrollerParent().removeChild(_scroller);
+ if (_scroller) {
+ this.delegate.GetScrollerParent().removeChild(_scroller);
+ }
if (this.iScroll != null)
this.iScroll.destroy();
@@ -2698,10 +2711,12 @@
}
}
if (isShow)
- AscCommon.g_inputContext.HtmlArea.focus();
+ {
+ AscCommon.g_inputContext.showKeyboard();
- if (this.isCheckFocusOnClick)
- this.isCheckFocusOnClickValue = true;
+ if (this.isCheckFocusOnClick)
+ this.isCheckFocusOnClickValue = true;
+ }
}
};
@@ -2716,7 +2731,7 @@
if (this.isCheckFocusOnClickValue === true)
{
if (AscCommon.g_inputContext)
- AscCommon.g_inputContext.HtmlArea.focus();
+ AscCommon.g_inputContext.showKeyboard();
this.isCheckFocusOnClickValue = false;
}
diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js
index 6e27d8290d..7e1c530532 100644
--- a/common/Shapes/Serialize.js
+++ b/common/Shapes/Serialize.js
@@ -7318,6 +7318,7 @@ function BinaryPPTYLoader()
_smartArt.generateDefaultStructures();
_smartArt.checkDataModel();
_smartArt.checkNodePointsAfterRead();
+ _smartArt.correctUngeneratedSmartArtContent();
}
else
{
diff --git a/common/SmartArts/SmartArtTree.js b/common/SmartArts/SmartArtTree.js
index beb2e34d5c..5aa645a0ae 100644
--- a/common/SmartArts/SmartArtTree.js
+++ b/common/SmartArts/SmartArtTree.js
@@ -8433,5 +8433,6 @@ function CConnectionDistanceResolver() {
// });
AscFormat.SmartArtAlgorithm = SmartArtAlgorithm;
+ AscFormat.TextAlgorithm = TextAlgorithm;
})(window);
diff --git a/common/TableId.js b/common/TableId.js
index 3b566dddc0..c7ccf84588 100644
--- a/common/TableId.js
+++ b/common/TableId.js
@@ -458,6 +458,7 @@
this.m_oFactoryClass[AscDFH.historyitem_type_Pdf_Annot_Underline] = AscPDF.CAnnotationUnderline;
this.m_oFactoryClass[AscDFH.historyitem_type_Pdf_Annot_Strikeout] = AscPDF.CAnnotationStrikeout;
this.m_oFactoryClass[AscDFH.historyitem_type_Pdf_Annot_FreeText] = AscPDF.CAnnotationFreeText;
+ this.m_oFactoryClass[AscDFH.historyitem_type_Pdf_Annot_Stamp] = AscPDF.CAnnotationStamp;
this.m_oFactoryClass[AscDFH.historyitem_type_Pdf_Page] = AscPDF.CPageInfo;
}
diff --git a/common/api/firstLetterExceptions.js b/common/api/firstLetterExceptions.js
index dd43972127..f9b6433515 100644
--- a/common/api/firstLetterExceptions.js
+++ b/common/api/firstLetterExceptions.js
@@ -98,8 +98,41 @@
"э", "экз",
"ю"
];
-
-
+
+ DEFAULT_EXCEPTIONS[lcid_deDE] = [
+ "zb", "bzw", "dh", "evtl", "idr", "usw", "ua", "uu", "ca", "nr", "abs", "s", "univ", "str", "zt", "so", "su", "vgl", "dj", "dm", "uvm", "mwst", "ag", "gmbh", "zhd", "pa", "zzt", "ia", "iv", "uam", "zzgl", "inkl", "exkl", "baw", "nchr", "vchr", "zh", "st", "geb", "gest", "jh", "bd", "ff", "uae", "sa", "dhi", "dhs", "dhes", "dher", "dhdu", "dhich", "dhwir", "dh ihr", "dhsie", "dhes", "dhman", "dhjemand", "dhniemand", "dhalle", "dhkeiner", "dhjeder", "dhjemand", "dhniemand", "dhalle", "dhkeiner", "dhjeder", "dhjemand"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_esES] = [
+ "ac", "dc", "pej", "etc", "pag", "num", "av", "c", "dpto", "tel", "aprox", "max", "min", "art", "cap", "ed", "vol", "fig", "sf", "sl", "sn", "qepd", "pd", "nb", "sa", "sl", "eeuu", "ffcc", "rrhh", "aavv", "dl"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_frFR] = [
+ "av", "apr", "env", "etc", "pex", "cad", "n", "v", "cf", "ed", "vol", "fig", "chap", "art", "al", "obs", "nb", "ps", "sas", "sarl", "sa", "ong", "otan", "onu", "ue", "omc", "fmi", "oms", "oit", "unicef", "ovni", "adn", "sida", "tic", "ttc", "ht", "tva", "cdi", "cdd", "rh", "btp", "rer", "tgv", "ter", "hlm", "zup", "zac"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_ptPT] = [
+ "pex", "etc", "ac", "dc", "n", "vol", "cap", "pag", "ed", "trad", "rev", "org", "coord", "dir", "ed", "comp", "col", "fig", "il", "obs", "ref", "apend", "anexo", "max", "min", "aprox", "adm", "dep", "func", "ger", "rechum", "ti", "rh", "cont", "fin", "mkt", "com", "vendas", "log", "prod", "qual", "seg", "manut", "ti", "adm", "aux", "est", "temp", "efet", "clt", "pj", "pf", "cpf", "cnpj", "rg", "ie", "im", "cep", "tel", "cel"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_plPL] = [
+ "np", "itd", "itp", "tj", "tzw", "min", "godz", "min", "ul", "al", "pl", "sek", "r", "w", "zl", "gr", "cm", "m", "km", "kg", "g", "l", "ml", "s", "t", "wyd", "red", "oprac", "przyp", "zal", "cdn"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_itIT] = [
+ "ps", "ecc", "pes", "ca", "cfr", "v", "n", "p", "vol", "cap", "art", "ed", "trad", "fig", "tab", "ecc", "etc", "ac", "dc", "km", "cm", "mm", "kg", "g", "l", "ml", "h", "min", "sec"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_svSE] = [
+ "bla", "osv", "tex", "mm", "ca", "dvs", "ed", "jfr", "sk", "mfl", "mao", "od", "obs", "pga", "tom", "from", "kl", "nr", "s", "bil", "ang", "forts", "resp", "tidskr", "utg", "overs", "red", "forf", "anm", "fig", "tab", "jfr", "ibid", "opcit", "etal", "etc", "ie", "eg", "pm", "am", "ps"
+ ];
+
+ DEFAULT_EXCEPTIONS[lcid_daDK]= [
+ "feks", "mfl", "osv", "dvs", "ca", "bla", "jfr", "pga", "tom", "from", "kl", "nr", "s", "bil", "ang", "forts", "resp", "tidskr", "utg", "overs", "red", "forf", "anm", "fig", "tab", "jfr", "ibid", "opcit", "etal", "etc", "ie", "eg", "pm", "am", "ps"
+ ];
+
+
+
/**
* Класс для работы с исключениями автозамены первого символа в предложении
* @constructor
@@ -113,6 +146,10 @@
{
return DEFAULT_EXCEPTIONS[lang] ? DEFAULT_EXCEPTIONS[lang] : [];
};
+ CFirstLetterExceptions.GetDefaultLangs = function()
+ {
+ return Object.keys(DEFAULT_EXCEPTIONS);
+ };
CFirstLetterExceptions.prototype.Check = function(word, lang)
{
if (!word)
@@ -206,9 +243,10 @@
};
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'].CFirstLetterExceptions = CFirstLetterExceptions;
-
+
CFirstLetterExceptions.prototype["get_Exceptions"] = CFirstLetterExceptions.prototype.get_Exceptions = CFirstLetterExceptions.prototype.GetExceptions;
CFirstLetterExceptions.prototype["put_Exceptions"] = CFirstLetterExceptions.prototype.put_Exceptions = CFirstLetterExceptions.prototype.SetExceptions;
+ CFirstLetterExceptions.prototype["get_DefaultLangs"] = CFirstLetterExceptions.prototype.get_DefaultLangs = CFirstLetterExceptions.GetDefaultLangs;
CFirstLetterExceptions.prototype["get_DefaultExceptions"] = CFirstLetterExceptions.prototype.get_DefaultExceptions = CFirstLetterExceptions.GetDefaultExceptions;
CFirstLetterExceptions.prototype["add_Exception"] = CFirstLetterExceptions.prototype.add_Exception = CFirstLetterExceptions.prototype.AddException;
CFirstLetterExceptions.prototype["remove_Exception"] = CFirstLetterExceptions.prototype.remove_Exception = CFirstLetterExceptions.prototype.RemoveException;
diff --git a/common/apiBase.js b/common/apiBase.js
index 75c256176d..df1d38252a 100644
--- a/common/apiBase.js
+++ b/common/apiBase.js
@@ -103,6 +103,8 @@
this.IsLongActionCurrent = 0;
this.LongActionCallbacks = [];
this.LongActionCallbacksParams = [];
+ this.IsActionRestrictionCurrent = 0;
+ this.IsActionRestrictionPrev = null;
// AutoSave
this.autoSaveGap = 0; // Интервал автосохранения (0 - означает, что автосохранения нет) в милесекундах
@@ -167,8 +169,8 @@
this.forceSaveButtonContinue = false;
this.forceSaveTimeoutTimeout = null;
this.forceSaveForm = null;
- this.disconnectRestrictions = null;//to restore restrictions after disconnect
this.forceSaveUndoRequest = false; // Флаг нужен, чтобы мы знали, что данное сохранение пришло по запросу Undo в совместке
+ this.saveRelativePrev = {};
// Version History
this.VersionHistory = null; // Объект, который отвечает за точку в списке версий
@@ -282,25 +284,24 @@
this._loadModules();
+ const noop = function () { };
if (!this.isPdfEditor())
{
- AscCommon.loadChartStyles(function() {}, function(err) {
+ AscCommon.loadChartStyles(noop, function (err) {
t.sendEvent("asc_onError", Asc.c_oAscError.ID.LoadingScriptError, c_oAscError.Level.NoCritical);
});
}
-
- var oldOnError = window.onerror;
- window.onerror = function(errorMsg, url, lineNumber, column, errorObj) {
- //send only first error to reduce number of requests. also following error may be consequences of first
- window.onerror = oldOnError;
+ const sendUnhandledError = function(errorMsg, url, lineNumber, column, stack) {
let editorInfo = t.getEditorErrorInfo();
let memoryInfo = AscCommon.getMemoryInfo();
- var msg = 'Error: ' + errorMsg + '\n Script: ' + url + '\n Line: ' + lineNumber + ':' + column +
+ lineNumber = undefined !== lineNumber ? lineNumber : "";
+ column = undefined !== column ? column : "";
+ var msg = 'Error: ' + errorMsg + '\n Script: ' + (url || "") + '\n Line: ' + lineNumber + ':' + column +
'\n userAgent: ' + (navigator.userAgent || navigator.vendor || window.opera) + '\n platform: ' +
navigator.platform + '\n isLoadFullApi: ' + t.isLoadFullApi + '\n isDocumentLoadComplete: ' +
t.isDocumentLoadComplete + (editorInfo ? '\n ' + editorInfo : "") +
(memoryInfo ? '\n performance.memory: ' + memoryInfo : "") +
- '\n StackTrace: ' + (errorObj ? errorObj.stack : "");
+ '\n StackTrace: ' + (stack || "");
AscCommon.sendClientLog("error", "changesError: " + msg, t);
if (t.isLoadFullApi ) {
if(t.isDocumentLoadComplete) {
@@ -316,6 +317,26 @@
t.sendEvent("asc_onError", Asc.c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
}
}
+ }
+ var oldOnunhandledrejection = window.onunhandledrejection;
+ window.onunhandledrejection = function(errorEvent) {
+ //send only first error to reduce number of requests. also following error may be consequences of first
+ window.onunhandledrejection = oldOnunhandledrejection;
+ const errorMsg = errorEvent.reason.message || errorEvent.reason;
+ const stack = errorEvent.reason.stack || "";
+ console.error(errorEvent.reason);
+ sendUnhandledError(errorMsg, undefined, undefined, undefined, stack);
+ if (oldOnunhandledrejection) {
+ return oldOnunhandledrejection.apply(this, arguments);
+ } else {
+ return false;
+ }
+ }
+ var oldOnError = window.onerror;
+ window.onerror = function(errorMsg, url, lineNumber, column, errorObj) {
+ //send only first error to reduce number of requests. also following error may be consequences of first
+ window.onerror = oldOnError;
+ sendUnhandledError(errorMsg, url, lineNumber, column, (errorObj ? errorObj.stack : ""));
if (oldOnError) {
return oldOnError.apply(this, arguments);
} else {
@@ -375,6 +396,9 @@
case c_oEditorId.Presentation:
res = 'slide';
break;
+ case c_oEditorId.Visio:
+ res = 'visio';
+ break;
}
return res;
};
@@ -384,7 +408,15 @@
switch (this.editorId)
{
case c_oEditorId.Word:
- res = isOpenOoxml ? Asc.c_oAscFileType.DOCX : Asc.c_oAscFileType.CANVAS_WORD;
+ if (this.isPdfEditor())
+ {
+ //todo выставить формат
+ res = undefined;
+ }
+ else
+ {
+ res = isOpenOoxml ? Asc.c_oAscFileType.DOCX : Asc.c_oAscFileType.CANVAS_WORD;
+ }
break;
case c_oEditorId.Spreadsheet:
res = isOpenOoxml ? Asc.c_oAscFileType.XLSX: Asc.c_oAscFileType.CANVAS_SPREADSHEET;
@@ -671,7 +703,12 @@
this.sendEvent("asc_onInitEditorFonts", gui_fonts);
}
};
- baseEditorsApi.prototype.sync_StartAction = function(type, id)
+ /**
+ * @param {Asc.c_oAscAsyncAction} type
+ * @param {Asc.c_oAscAsyncActionType} id
+ * @param {Asc.c_oAscRestrictionType} [actionRestriction]
+ */
+ baseEditorsApi.prototype.sync_StartAction = function(type, id, actionRestriction)
{
if (type !== c_oAscAsyncActionType.Empty)
this.sendEvent('asc_onStartAction', type, id);
@@ -681,8 +718,20 @@
{
this.incrementCounterLongAction();
}
+ if (undefined !== actionRestriction)
+ {
+ //для некоторых действий не хочется показывать модальный loader, который закрывает всю страницу
+ //если для них делать incrementCounterLongAction, то будут проблемы, что не заблокированы линейки, resize окна не работает
+ //И скорее всего другие проблемы, поэтому делается через asc_setRestriction
+ this.incrementCounterActionRestriction(actionRestriction);
+ }
};
- baseEditorsApi.prototype.sync_EndAction = function(type, id)
+ /**
+ * @param type {Asc.c_oAscAsyncAction}
+ * @param id {Asc.c_oAscAsyncActionType}
+ * @param {Asc.c_oAscRestrictionType} [actionRestriction]
+ */
+ baseEditorsApi.prototype.sync_EndAction = function(type, id, actionRestriction)
{
if (type !== c_oAscAsyncActionType.Empty)
this.sendEvent('asc_onEndAction', type, id);
@@ -692,10 +741,10 @@
{
this.decrementCounterLongAction();
}
- };
- baseEditorsApi.prototype.sync_TryUndoInFastCollaborative = function()
- {
- this.sendEvent("asc_OnTryUndoInFastCollaborative");
+ if (undefined !== actionRestriction)
+ {
+ this.decrementCounterActionRestriction();
+ }
};
baseEditorsApi.prototype.asc_setViewMode = function()
{
@@ -1009,6 +1058,34 @@
this.LongActionCallbacksParams.splice(0, _length);
}
};
+
+ baseEditorsApi.prototype.isActionWithRestriction = function()
+ {
+ return 0 !== this.IsActionRestrictionCurrent;
+ };
+ baseEditorsApi.prototype.incrementCounterActionRestriction = function(restrictions)
+ {
+ if (0 === this.IsActionRestrictionCurrent)
+ {
+ this.IsActionRestrictionPrev = this.restrictions;
+ this.asc_setRestriction(restrictions);
+ }
+ ++this.IsActionRestrictionCurrent;
+ };
+ baseEditorsApi.prototype.decrementCounterActionRestriction = function()
+ {
+ this.IsActionRestrictionCurrent--;
+ if (this.IsActionRestrictionCurrent < 0)
+ {
+ this.IsActionRestrictionCurrent = 0;
+ }
+
+ if (0 === this.IsActionRestrictionCurrent && null !== this.IsActionRestrictionPrev)
+ {
+ this.asc_setRestriction(this.IsActionRestrictionPrev);
+ this.IsActionRestrictionPrev = null;
+ }
+ };
baseEditorsApi.prototype.checkLongActionCallback = function(_callback, _param)
{
if (this.isLongActionBase())
@@ -1041,6 +1118,10 @@
case c_oEditorId.Presentation:
res = true;
break;
+ case c_oEditorId.Visio:
+ //todo сделать как в презентациях когда будет редактор
+ res = false;
+ break;
}
return res;
};
@@ -1314,7 +1395,15 @@
* @param callback {saveRelativeFromChangesCallback}
*/
baseEditorsApi.prototype.saveRelativeFromChanges = function(docId, token, timeout, callback) {
- if (!this.CoAuthoringApi.callPRC({'type': 'saveRelativeFromChanges', 'docId': docId, 'token': token}, timeout, callback)) {
+ let t = this;
+ let time = this.saveRelativePrev[docId];
+ let callbackWrapper = function (timeout, data) {
+ if (data && data.time) {
+ t.saveRelativePrev[docId] = data.time;
+ }
+ callback(timeout, data);
+ }
+ if (!this.CoAuthoringApi.callPRC({'type': 'saveRelativeFromChanges', 'docId': docId, 'token': token, 'time': time}, timeout, callbackWrapper)) {
callback(true, undefined);
}
};
@@ -1619,11 +1708,7 @@
t.sendEvent('asc_onCoAuthoringChatReceiveMessage', e, clear);
};
this.CoAuthoringApi.onServerVersion = function (buildVersion, buildNumber) {
- if (null !== t.disconnectRestrictions) {
- t.sync_EndAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.Disconnect);
- t.asc_setRestriction(t.disconnectRestrictions);
- t.disconnectRestrictions = null;
- }
+ t.sync_EndAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.Disconnect, Asc.c_oAscRestrictionType.View);
t.sendEvent('asc_onServerVersion', buildVersion, buildNumber);
};
@@ -1835,11 +1920,7 @@
}
let isSessionIdleDisconnect = AscCommon.c_oCloseCode.sessionIdle === opt_closeCode;
if (null != opt_closeCode && !isSessionIdleDisconnect) {
- if (null !== t.disconnectRestrictions) {
- t.sync_EndAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.Disconnect);
- t.asc_setRestriction(t.disconnectRestrictions);
- t.disconnectRestrictions = null;
- }
+ t.sync_EndAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.Disconnect, Asc.c_oAscRestrictionType.View);
let allowRefresh = [c_oCloseCode.updateVersion, c_oCloseCode.noCache, c_oCloseCode.restore, c_oCloseCode.quiet];
if (-1 !== allowRefresh.indexOf(opt_closeCode) && !t.isDocumentModified() && t.canRefreshFile()) {
t.onRefreshFile();
@@ -1853,10 +1934,8 @@
t.sendEvent('asc_onError', error, level);
}
}
- } else if (null === t.disconnectRestrictions){
- t.disconnectRestrictions = t.restrictions;
- t.sync_StartAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.Disconnect);
- t.asc_setRestriction(Asc.c_oAscRestrictionType.View);
+ } else if (!t.isActionWithRestriction()){
+ t.sync_StartAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.Disconnect, Asc.c_oAscRestrictionType.View);
if (isSessionIdleDisconnect) {
t.waitNotIdle(undefined, function () {
t.CoAuthoringApi.connect();
@@ -1965,7 +2044,7 @@
this._coAuthoringInitEnd();
let openCmd = this._getOpenCmd();
- this.CoAuthoringApi.init(this.User, this.documentId, this.documentCallbackUrl, 'fghhfgsjdgfjs', this.editorId, this.documentFormatSave, this.DocInfo, this.documentShardKey, this.documentWopiSrc, this.documentUserSessionId, openCmd);
+ this.CoAuthoringApi.init(this.User, this.documentId, this.documentCallbackUrl, 'fghhfgsjdgfjs', this.editorId, this.documentFormatSave, this.DocInfo, this.documentShardKey, this.documentWopiSrc, this.documentUserSessionId, this.headingsColor, openCmd);
};
baseEditorsApi.prototype._coAuthoringInitEnd = function()
{
@@ -2251,7 +2330,7 @@
jsonparams["locale"] = this.asc_getLocale();
//todo move cmd from header to body and uncomment
// jsonparams["translate"] = AscCommon.translateManager.mapTranslate;
- jsonparams["documentLayout"] = { "openedAt" : this.openedAt};
+ jsonparams["documentLayout"] = { "openedAt" : this.openedAt, "headingsColor" : this.headingsColor};
if (this.watermarkDraw && this.watermarkDraw.inputContentSrc) {
jsonparams["watermark"] = JSON.parse(this.watermarkDraw.inputContentSrc);
}
@@ -2259,7 +2338,7 @@
} else if ((Asc.c_oAscFileType.PDF === options.fileType || Asc.c_oAscFileType.PDFA === options.fileType) &&
this.watermarkDraw && this.watermarkDraw.inputContentSrc) {
let jsonparams = {};
- jsonparams["watermark"] = JSON.parse(this.watermarkDraw.inputContentSrc);
+ jsonparams["watermark"] = JSON.parse(this.watermarkDraw.getCorrectedInputContentSrc());
oAdditionalData["jsonparams"] = jsonparams;
}
if (options.textParams && undefined !== options.textParams.asc_getAssociation()) {
@@ -2693,7 +2772,7 @@
return this.VersionHistory;
};
baseEditorsApi.prototype.asc_refreshFile = function(docInfo) {
- this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.RefreshFile);
+ this.sync_EndAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.RefreshFile, Asc.c_oAscRestrictionType.View);
//todo always call asc_CloseFile ?
let isInfinityLoop = this.documentIsWopi
? docInfo.get_Wopi()["Version"] === this.DocInfo.get_Wopi()["Version"]
@@ -2715,7 +2794,7 @@
}
baseEditorsApi.prototype.onRefreshFile = function () {
let t = this;
- this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.RefreshFile);
+ this.sync_StartAction(Asc.c_oAscAsyncActionType.Information, Asc.c_oAscAsyncAction.RefreshFile, Asc.c_oAscRestrictionType.View);
if (this.documentIsWopi) {
let callback = function (isTimeout, response) {
if (response) {
@@ -3273,6 +3352,11 @@
}
};
+ baseEditorsApi.prototype.isDrawSlideshowAnnotations = function()
+ {
+ return false;
+ };
+
// plugins
baseEditorsApi.prototype._checkLicenseApiFunctions = function()
{
@@ -3283,8 +3367,15 @@
{
if (null != this.pluginsManager)
{
- this.pluginsManager.register(basePath, plugins);
+ let runnedArray = [];
+ this.pluginsManager.register(basePath, plugins, undefined, runnedArray);
this.checkInstalledPlugins();
+
+ for (let i = 0, len = runnedArray.length; i < len; i++)
+ {
+ if (!this.pluginsManager.isRunned(runnedArray[i]))
+ this.pluginsManager.run(runnedArray[i], 0, "");
+ }
}
else
{
@@ -4332,24 +4423,18 @@
return 0;
};
- baseEditorsApi.prototype.asc_decodeBuffer = function(buffer, options, callback) {
+ baseEditorsApi.prototype.asc_decodeBuffer = function(buffer, codePage, callback) {
+ //todo TextDecoder (ie11)
var reader = new FileReader();
//todo onerror
reader.onload = reader.onerror = function(e) {
- var text = e.target.result ? e.target.result : "";
- if (options instanceof Asc.asc_CTextOptions) {
- callback(AscCommon.parseText(text, options));
- } else {
- callback(text.match(/[^\r\n]+/g));
- }
+ callback(e.target.result ? e.target.result : "");
};
-
var encoding = "UTF-8";
- var codePage = options.asc_getCodePage();
var encodingsLen = AscCommon.c_oAscEncodings.length;
for (var i = 0; i < encodingsLen; ++i)
{
- if (AscCommon.c_oAscEncodings[i][0] == codePage)
+ if (AscCommon.c_oAscEncodings[i][0] === codePage)
{
encoding = AscCommon.c_oAscEncodings[i][2];
break;
@@ -4358,6 +4443,9 @@
reader.readAsText(new Blob([buffer]), encoding);
};
+ baseEditorsApi.prototype.asc_parseText = function(text, options) {
+ return AscCommon.parseText(text, options, true);
+ }
baseEditorsApi.prototype.asc_setVisiblePasteButton = function(val)
{
@@ -4572,6 +4660,10 @@
return this.Shortcuts.Get(e.GetKeyCode(), e.IsCtrl(), e.IsShift(), e.IsAlt());
else
return this.Shortcuts.Get(e.KeyCode, e.CtrlKey, e.ShiftKey, e.AltKey);
+ };
+ baseEditorsApi.prototype.executeShortcut = function(type)
+ {
+
};
baseEditorsApi.prototype.getCustomShortcutAction = function(nActionType)
{
@@ -4767,17 +4859,21 @@
if (!this.internalEvents.hasOwnProperty(name))
this.internalEvents[name] = {};
this.internalEvents[name]["" + ((undefined === listenerId) ? 0 : listenerId)] = callback;
+
+ return true;
};
baseEditorsApi.prototype.detachEvent = function(name, listenerId)
{
if (!this.internalEvents.hasOwnProperty(name))
- return;
+ return false;
var obj = this.internalEvents[name];
var prop = "" + ((undefined === listenerId) ? 0 : listenerId);
if (obj[prop])
delete obj[prop];
if (0 === Object.getOwnPropertyNames(obj).length)
delete this.internalEvents[name];
+
+ return true;
};
baseEditorsApi.prototype.sendInternalEvent = function()
{
@@ -5088,6 +5184,23 @@
baseEditorsApi.prototype.asc_StopInkDrawer = function() {
this.stopInkDrawer();
};
+ baseEditorsApi.prototype.asc_RemoveAllInks = function() {
+ this.removeAllInks();
+ };
+ baseEditorsApi.prototype.removeAllInks = function() {
+ };
+ baseEditorsApi.prototype.asc_HaveInks = function() {
+ return this.haveInks();
+ };
+ baseEditorsApi.prototype.haveInks = function() {
+ return true;
+ };
+ baseEditorsApi.prototype.asc_CanRemoveAllInks = function() {
+ return this.canRemoveAllInks();
+ };
+ baseEditorsApi.prototype.canRemoveAllInks = function() {
+ return true;
+ };
baseEditorsApi.prototype.stopInkDrawer = function() {
this.inkDrawer.turnOff();
};
@@ -5108,6 +5221,9 @@
baseEditorsApi.prototype.getInkCursorType = function() {
return this.inkDrawer.getCursorType();
};
+ baseEditorsApi.prototype.getAnnotations = function() {
+ return null;
+ };
baseEditorsApi.prototype.isMasterMode = function(){
return false;
};
@@ -5252,6 +5368,14 @@
});
};
+ baseEditorsApi.prototype.wrapShortcut = function(methodName, shortcutType)
+ {
+ this[methodName] = function() {
+ this.executeShortcut.call(this, shortcutType);
+ };
+ this.wrapFunction(methodName);
+ };
+
baseEditorsApi.prototype.setPluginsOptions = function(options)
{
this.externalPluginsOptions = options;
@@ -5327,6 +5451,24 @@
plugins.callMethod(plugins.internalGuid, name, params);
};
+
+ baseEditorsApi.prototype.asc_mergeSelectedShapes = function(operation) {
+ if(AscCommon['PathBoolean']) {
+ this.asc_mergeSelectedShapesAction(operation);
+ return;
+ }
+ let oThis = this;
+ AscCommon.loadPathBoolean(function () {
+ oThis.asc_mergeSelectedShapesAction(operation);
+ }, function () {
+ oThis.sendEvent("asc_onError", Asc.c_oAscError.ID.LoadingScriptError, c_oAscError.Level.NoCritical)
+ })
+ };
+
+ baseEditorsApi.prototype.asc_mergeSelectedShapesAction = function(operation) {
+
+ };
+
//----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].baseEditorsApi = baseEditorsApi;
@@ -5348,6 +5490,7 @@
prot['asc_runAutostartMacroses'] = prot.asc_runAutostartMacroses;
prot['asc_runMacros'] = prot.asc_runMacros;
prot['asc_getAllMacrosNames'] = prot.asc_getAllMacrosNames;
+ prot['asc_parseText'] = prot.asc_parseText;
prot['asc_setVisiblePasteButton'] = prot.asc_setVisiblePasteButton;
prot['asc_getAutoCorrectMathSymbols'] = prot.asc_getAutoCorrectMathSymbols;
prot['asc_getAutoCorrectMathFunctions'] = prot.asc_getAutoCorrectMathFunctions;
@@ -5390,6 +5533,9 @@
prot['asc_StartDrawInk'] = prot.asc_StartDrawInk;
prot['asc_StartInkEraser'] = prot.asc_StartInkEraser;
prot['asc_StopInkDrawer'] = prot.asc_StopInkDrawer;
+ prot['asc_RemoveAllInks'] = prot.asc_RemoveAllInks;
+ prot['asc_HaveInks'] = prot.asc_HaveInks;
+ prot['asc_CanRemoveAllInks'] = prot.asc_CanRemoveAllInks;
prot['startGetDocInfo'] = prot.startGetDocInfo;
prot['stopGetDocInfo'] = prot.stopGetDocInfo;
prot["can_CopyCut"] = prot.can_CopyCut;
@@ -5432,6 +5578,7 @@
prot["asc_removeCustomProperty"] = prot.asc_removeCustomProperty;
prot["asc_setPdfViewer"] = prot.asc_setPdfViewer;
+ prot["asc_mergeSelectedShapes"] = prot.asc_mergeSelectedShapes;
prot["callCommand"] = prot.callCommand;
prot["callMethod"] = prot.callMethod;
diff --git a/common/apiBase_plugins.js b/common/apiBase_plugins.js
index d286c21fd3..858ef3175e 100644
--- a/common/apiBase_plugins.js
+++ b/common/apiBase_plugins.js
@@ -1353,6 +1353,11 @@
// UPD: done. Ничего не изменять в менеджере плагинов, если guid пуст
let result = window["AscDesktopEditor"]["PluginInstall"](JSON.stringify(config));
+
+ if (result && window.g_asc_plugins.isRunned(config["guid"]))
+ {
+ window.g_asc_plugins.close(config["guid"]);
+ }
return {
"type" : loadFuncName,
@@ -1639,10 +1644,10 @@
};
};
/**
- * Installs a plugin by the URL to the plugin config.
+ * Installs a plugin using the specified plugin config.
* @memberof Api
* @typeofeditors ["CDE", "CSE", "CPE"]
- * @param {object} [config] - The plugin config for installing.
+ * @param {object} [config] - The plugin {@link https://api.onlyoffice.com/docs/plugin-and-macros/structure/manifest/ config}.
* @alias InstallPlugin
* @returns {object} - An object with the result information.
* @since 7.2.0
@@ -1653,10 +1658,10 @@
return installPlugin(config, "Installed");
};
/**
- * Updates a plugin by the URL to the plugin config.
+ * Updates a plugin using the specified plugin config.
* @memberof Api
* @typeofeditors ["CDE", "CSE", "CPE"]
- * @param {object} [config] - The plugin config for updating.
+ * @param {object} [config] - The plugin {@link https://api.onlyoffice.com/docs/plugin-and-macros/structure/manifest/ config}.
* @alias UpdatePlugin
* @returns {object} - An object with the result information.
* @since 7.3.0
@@ -1667,16 +1672,6 @@
return installPlugin(config, "Updated");
};
- /**
- * Installs a plugin by the URL to the plugin config.
- * @memberof Api
- * @typeofeditors ["CDE", "CSE", "CPE"]
- * @param {string} configUrl - The URL to the plugin *config.json* for installing.
- * @alias InstallDeveloperPlugin
- * @returns {boolean} - Returns true if the plugin is installed.
- * @since 7.4.0
- * @see office-js-api/Examples/Plugins/{Editor}/Api/Methods/InstallDeveloperPlugin.js
- */
Api.prototype["installDeveloperPlugin"] = function(configUrl)
{
try
@@ -2071,6 +2066,21 @@
{
this.sendEvent("asc_onPluginWindowMouseMove", frameId, x, y);
};
+
+ /**
+ * Shows an error/warning message.
+ * @memberof Api
+ * @typeofeditors ["CDE", "CSE", "CPE", "PDF"]
+ * @param {string} error - The error text.
+ * @param {number} level - -1 or 0 for error or warning.
+ * @alias ShowError
+ * @since 8.3.0
+ * @see office-js-api/Examples/Plugins/{Editor}/Api/Methods/ShowError.js
+ */
+ Api.prototype["pluginMethod_ShowError"] = function(error, level)
+ {
+ this.sendEvent("asc_onError", error, level);
+ };
})(window);
diff --git a/common/apiCommon.js b/common/apiCommon.js
index ed5b0a9347..41ec4b6e48 100644
--- a/common/apiCommon.js
+++ b/common/apiCommon.js
@@ -2680,6 +2680,7 @@ function (window, undefined) {
function asc_CParagraphProperty(obj) {
if (obj) {
+ this.Bidi = undefined !== obj.Bidi ? obj.Bidi : undefined;
this.ContextualSpacing = (undefined != obj.ContextualSpacing) ? obj.ContextualSpacing : null;
this.Ind = (undefined != obj.Ind && null != obj.Ind) ? new asc_CParagraphInd(obj.Ind) : null;
this.KeepLines = (undefined != obj.KeepLines) ? obj.KeepLines : null;
@@ -2722,7 +2723,6 @@ function (window, undefined) {
this.CanEditBlockCC = undefined !== obj.CanEditBlockCC ? obj.CanEditBlockCC : true;
this.CanDeleteInlineCC = undefined !== obj.CanDeleteInlineCC ? obj.CanDeleteInlineCC : true;
this.CanEditInlineCC = undefined !== obj.CanEditInlineCC ? obj.CanEditInlineCC : true;
-
}
else {
//ContextualSpacing : false, // Удалять ли интервал между параграфами одинакового стиля
@@ -2742,6 +2742,7 @@ function (window, undefined) {
//
// PageBreakBefore : false, // начинать параграф с новой страницы
+ this.Bidi = undefined;
this.ContextualSpacing = undefined;
this.Ind = new asc_CParagraphInd();
this.KeepLines = undefined;
@@ -2777,7 +2778,13 @@ function (window, undefined) {
this.CanEditInlineCC = true;
}
}
-
+
+ asc_CParagraphProperty.prototype.asc_getRtlDirection = function() {
+ return this.Bidi;
+ };
+ asc_CParagraphProperty.prototype.asc_putRtlDirection = function(v) {
+ this.Bidi = v;
+ };
asc_CParagraphProperty.prototype.asc_getContextualSpacing = function () {
return this.ContextualSpacing;
};
@@ -4722,6 +4729,9 @@ function (window, undefined) {
//for external reference
this.ReferenceData = null;
+
+ this.showVerticalScroll = null;
+ this.showHorizontalScroll = null;
}
prot = asc_CDocInfo.prototype;
@@ -4769,7 +4779,7 @@ function (window, undefined) {
docInfo.put_Url(userAuth["wopiSrc"] + "/contents?access_token=" + userAuth["access_token"]);
}
docInfo.put_Title(fileInfo["BreadcrumbDocName"] || fileInfo["BaseFileName"]);
- docInfo.put_CallbackUrl(JSON.stringify(userAuth),);
+ docInfo.put_CallbackUrl(JSON.stringify(userAuth));
docInfo.put_Token(token);
//todo does userInfo can change? (IsAnonymousUser)
@@ -4955,6 +4965,18 @@ function (window, undefined) {
prot.get_Shardkey = prot.asc_getShardkey = function () {
return this.shardkey;
};
+ prot.put_ShowVerticalScroll = prot.asc_putShowVerticalScroll = function (v) {
+ this.showVerticalScroll = v;
+ };
+ prot.get_ShowVerticalScroll = prot.asc_getShowVerticalScroll = function () {
+ return this.showVerticalScroll;
+ };
+ prot.put_ShowHorizontalScroll = prot.asc_putShowHorizontalScroll = function (v) {
+ this.showHorizontalScroll = v;
+ };
+ prot.get_ShowHorizontalScroll = prot.asc_getShowHorizontalScroll = function () {
+ return this.showHorizontalScroll;
+ };
function COpenProgress() {
this.Type = Asc.c_oAscAsyncAction.Open;
@@ -5169,6 +5191,15 @@ function (window, undefined) {
//console.log( this.image.toDataURL("image/png"));
};
+ this.getCorrectedInputContentSrc = function() {
+ let content = this.inputContentSrc;
+ for (let key in this.replaceMap) {
+ if (!this.replaceMap.hasOwnProperty(key)) continue;
+ content = content.replace(new RegExp(key, 'g'), this.replaceMap[key]);
+ }
+ return content;
+ };
+
this.Draw = function (context, dw_or_dx, dh_or_dy, dw, dh) {
if (!this.image || !this.isFontsLoaded) return;
@@ -5263,6 +5294,11 @@ function (window, undefined) {
oShape.setWorksheet(oApi.wb.getWorksheet().model);
break;
}
+ case AscCommon.c_oEditorId.Visio: {
+ oShape.setWordShape(false);
+ oShape.setParent(oApi.WordControl.m_oLogicDocument);
+ break;
+ }
}
let _oldTrackRevision = false;
@@ -5509,7 +5545,8 @@ function (window, undefined) {
break;
}
- case AscCommon.c_oEditorId.Presentation: {
+ case AscCommon.c_oEditorId.Presentation:
+ case AscCommon.c_oEditorId.Visio: {
if (oApi.WordControl) {
if (oApi.watermarkDraw) {
oApi.watermarkDraw.zoom = oApi.WordControl.m_nZoomValue / 100;
@@ -6001,6 +6038,30 @@ function (window, undefined) {
CDocInfoProp.prototype.put_SymbolsWSCount = function (v) {
this.SymbolsWSCount = v;
};
+
+ /**
+ * @constructor
+ */
+ function RangePermProp(obj) {
+ if (obj) {
+ this.editText = undefined !== obj.editText ? obj.editText : true;
+ this.editParagraph = undefined !== obj.editParagraph ? obj.editParagraph : true;
+ this.insertObject = undefined !== obj.insertObject ? obj.insertObject : true;
+ } else {
+ this.editText = true;
+ this.editParagraph = true;
+ this.insertObject = true;
+ }
+ }
+ RangePermProp.prototype.get_canEditText = function() {
+ return this.editText;
+ };
+ RangePermProp.prototype.get_canEditPara = function() {
+ return this.editParagraph;
+ };
+ RangePermProp.prototype.get_canInsObject = function() {
+ return this.insertObject;
+ };
/*
* Export
@@ -6462,6 +6523,8 @@ function (window, undefined) {
window["Asc"]["asc_CParagraphProperty"] = window["Asc"].asc_CParagraphProperty = asc_CParagraphProperty;
prot = asc_CParagraphProperty.prototype;
+ prot["get_RtlDirection"] = prot["asc_getRtlDirection"] = prot.asc_getRtlDirection;
+ prot["put_RtlDirection"] = prot["asc_putRtlDirection"] = prot.asc_putRtlDirection;
prot["get_ContextualSpacing"] = prot["asc_getContextualSpacing"] = prot.asc_getContextualSpacing;
prot["put_ContextualSpacing"] = prot["asc_putContextualSpacing"] = prot.asc_putContextualSpacing;
prot["get_Ind"] = prot["asc_getInd"] = prot.asc_getInd;
@@ -6968,6 +7031,10 @@ function (window, undefined) {
prot["get_Wopi"] = prot["asc_getWopi"] = prot.asc_getWopi;
prot["put_Shardkey"] = prot["asc_putShardkey"] = prot.asc_putShardkey;
prot["get_Shardkey"] = prot["asc_getShardkey"] = prot.asc_getShardkey;
+ prot["put_ShowVerticalScroll"] = prot["asc_putShowVerticalScroll"] = prot.asc_putShowVerticalScroll;
+ prot["get_ShowVerticalScroll"] = prot["get_getShowVerticalScroll"] = prot.get_getShowVerticalScroll;
+ prot["put_ShowHorizontalScroll"] = prot["asc_putShowHorizontalScroll"] = prot.asc_putShowHorizontalScroll;
+ prot["get_ShowHorizontalScroll"] = prot["get_getShowHorizontalScroll"] = prot.get_getShowHorizontalScroll;
window["AscCommon"].COpenProgress = COpenProgress;
prot = COpenProgress.prototype;
@@ -7030,6 +7097,12 @@ function (window, undefined) {
CDocInfoProp.prototype['get_SymbolsWSCount'] = CDocInfoProp.prototype.get_SymbolsWSCount;
CDocInfoProp.prototype['put_SymbolsWSCount'] = CDocInfoProp.prototype.put_SymbolsWSCount;
+ window["Asc"]["RangePermProp"] = window["Asc"].RangePermProp = RangePermProp;
+ prot = RangePermProp.prototype;
+ prot["get_canEditText"] = prot.get_canEditText;
+ prot["get_canEditPara"] = prot.get_canEditPara;
+ prot["get_canInsObject"] = prot.get_canInsObject;
+
window["AscCommon"]["pix2mm"] = window["AscCommon"].pix2mm = function(pix)
{
return pix * AscCommon.g_dKoef_pix_to_mm;
diff --git a/common/bidi/bidi-types.js b/common/bidi/bidi-types.js
index fa8edc1e8c..ec1ee1f208 100644
--- a/common/bidi/bidi-types.js
+++ b/common/bidi/bidi-types.js
@@ -89,7 +89,8 @@
LRI : FLAG.NEUTRAL | FLAG.ISOLATE,
RLI : FLAG.NEUTRAL | FLAG.ISOLATE | FLAG.RTL,
FSI : FLAG.NEUTRAL | FLAG.ISOLATE | FLAG.FS,
- PDI : FLAG.NEUTRAL | FLAG.WEAK | FLAG.ISOLATE
+ PDI : FLAG.NEUTRAL | FLAG.WEAK | FLAG.ISOLATE,
+ PM : FLAG.STRONG // Paragraph end mark
};
const DIRECTION = {
diff --git a/common/collaborativeHistory.js b/common/collaborativeHistory.js
index 2dbd5544ad..6266af7601 100644
--- a/common/collaborativeHistory.js
+++ b/common/collaborativeHistory.js
@@ -346,7 +346,11 @@
// Формируем новую пачку действий, которые будут откатывать нужные нам действия
let reverseChanges = this.GetReverseOwnChanges();
if (reverseChanges.length <= 0)
+ {
+ //чтобы не было бесконечного saving(пересмотреть чтобы работало без saveChanges)
+ this.saveChanges([]);
return [];
+ }
for (let index = 0, count = reverseChanges.length; index < count; ++index)
{
@@ -370,21 +374,29 @@
let historyChange = historyItem.Data;
let historyClass = historyItem.Class;
- if (!historyClass || !historyClass.Get_Id)
+ //todo заполнить Class и Data в изменениях автофигур spreadsheet
+ if (!historyClass || !(historyClass.Get_Id || historyClass.Class && historyClass.Class.Get_Id))
continue;
- let data = AscCommon.CCollaborativeChanges.ToBase64(historyItem.Binary.Pos, historyItem.Binary.Len);
- changesToSend.push(data);
+ if (historyItem.Binary.Len) //spreadsheet local changes
+ {
+ let data = AscCommon.CCollaborativeChanges.ToBase64(historyItem.Binary.Pos, historyItem.Binary.Len);
+ changesToSend.push(data);
+ }
changesToRecalc.push(historyChange);
}
AscCommon.History.Remove_LastPoint();
this.CoEditing.Clear_DCChanges();
- editor.CoAuthoringApi.saveChanges(changesToSend, null, null, false, this.CoEditing.getCollaborativeEditing());
-
+ this.saveChanges(changesToSend);
return changesToRecalc;
};
+ CCollaborativeHistory.prototype.saveChanges = function(changesToSend)
+ {
+ //separate function to override in excel
+ (Asc.editor || editor).CoAuthoringApi.saveChanges(changesToSend, null, null, false, this.CoEditing.getCollaborativeEditing());
+ };
CCollaborativeHistory.prototype.GetEmptyContentChanges = function()
{
let changes = [];
@@ -438,7 +450,7 @@
let nPosition = range.Position;
let nCount = range.Length;
- let arrChanges = [];
+ let arrReverseChanges = [];
for (let nIndex = nCount - 1; nIndex >= 0; --nIndex)
{
let oChange = this.Changes[nPosition + nIndex];
@@ -451,32 +463,71 @@
let _oChange = oChange.Copy();
if (this.CommuteContentChange(_oChange, nPosition + nCount))
- arrChanges.push(_oChange);
+ {
+ let oReverseChange = _oChange.CreateReverseChange();
+ if (oReverseChange)
+ {
+ arrReverseChanges.push(oReverseChange);
+ oReverseChange.SetReverted(true);
+ }
+ }
oChange.SetReverted(true);
}
+ else if (oChange.IsSpreadsheetChange())
+ {
+ let _oChange = oChange.Copy();
+ //удобнее сначала создавать обратное изменение
+ let oReverseChange = _oChange.CreateReverseChange();
+ if (oReverseChange) {
+ if (this.CommuteRelated(oClass, oReverseChange, nPosition + nCount))
+ {
+ oReverseChange.SetReverted(true);
+ arrReverseChanges.push(oReverseChange);
+ }
+ else
+ {
+ //todo для автофигур не надо скрывать всю точку
+ //в таблицах не принимается вся точка
+ //например при вставка столбца копируется заливка соседнего столбца
+ arrReverseChanges = [];
+ for (let i = nCount - 1; i > nIndex; --i)
+ {
+ this.Changes[nPosition + i].SetReverted(false);
+ }
+ break;
+ }
+ }
+ else if(null !== oReverseChange)
+ {
+ //ничего не делаем если есть изменения которые не готовы
+ arrReverseChanges = [];
+ for (let i = nCount - 1; i > nIndex; --i)
+ {
+ this.Changes[nPosition + i].SetReverted(false);
+ }
+ break;
+ }
+ oChange.SetReverted(true);
+ }
else
{
let _oChange = oChange; // TODO: Тут надо бы сделать копирование
if (this.CommutePropertyChange(oClass, _oChange, nPosition + nCount))
- arrChanges.push(_oChange);
+ {
+ let oReverseChange = _oChange.CreateReverseChange();
+ if (oReverseChange)
+ {
+ arrReverseChanges.push(oReverseChange);
+ oReverseChange.SetReverted(true);
+ }
+ }
}
}
this.OwnRanges.length = this.OwnRanges.length - 1;
- let arrReverseChanges = [];
- for (let nIndex = 0, nCount = arrChanges.length; nIndex < nCount; ++nIndex)
- {
- let oReverseChange = arrChanges[nIndex].CreateReverseChange();
- if (oReverseChange)
- {
- arrReverseChanges.push(oReverseChange);
- oReverseChange.SetReverted(true);
- }
- }
-
return arrReverseChanges;
};
CCollaborativeHistory.prototype.CommuteContentChange = function(oChange, nStartPosition, arrChanges)
@@ -601,6 +652,11 @@
return true;
};
+
+ CCollaborativeHistory.prototype.CommuteRelated = function(oClass, oChange, nStartPosition)
+ {
+ return true;
+ }
CCollaborativeHistory.prototype.CreateLocalHistoryPointByReverseChanges = function(reverseChanges)
{
let localHistory = AscCommon.History;
diff --git a/common/commonDefines.js b/common/commonDefines.js
index f9f17410a0..f249736d12 100644
--- a/common/commonDefines.js
+++ b/common/commonDefines.js
@@ -694,21 +694,22 @@ window.AscCommon.g_cIsBeta = "false";
};
var c_oAscTypeSelectElement = {
- Paragraph : 0,
- Table : 1,
- Image : 2,
- Header : 3,
- Hyperlink : 4,
- SpellCheck : 5,
- Shape : 6,
- Slide : 7,
- Chart : 8,
- Math : 9,
- MailMerge : 10,
- ContentControl : 11,
- Animation : 12,
- Text : 13, // viewer
- Annot : 14
+ Paragraph : 0,
+ Table : 1,
+ Image : 2,
+ Header : 3,
+ Hyperlink : 4,
+ SpellCheck : 5,
+ Shape : 6,
+ Slide : 7,
+ Chart : 8,
+ Math : 9,
+ MailMerge : 10,
+ ContentControl : 11,
+ Animation : 12,
+ Text : 13, // viewer
+ Annot : 14,
+ UnProtectedRegion : 15
};
var c_oAscLineDrawingRule = {
@@ -4460,6 +4461,25 @@ window.AscCommon.g_cIsBeta = "false";
"HH:mm",
"HH:mm:ss"
];
+ c_oAscDateTimeFormat[lcid_sqAL] = [
+ "d.M.yyyy",
+ "dddd, d MMMM yyyy",
+ "d MMMM yyyy",
+ "d.M.yy",
+ "yyyy-MM-dd",
+ "d-MMM-yy",
+ "d/M/yyyy",
+ "d MMM. yy",
+ "d/M/yy",
+ "MMMM yy",
+ "MMM-yy",
+ "d.M.yyyy h:mm am/pm",
+ "d.M.yyyy h:mm:ss am/pm",
+ "h:mm am/pm",
+ "h:mm:ss am/pm",
+ "HH:mm",
+ "HH:mm:ss"
+ ];
c_oAscDateTimeFormat[lcid_trTR] = [
"d.MM.yyyy",
"d MMMM yyyy dddd",
@@ -4713,22 +4733,25 @@ window.AscCommon.g_cIsBeta = "false";
prot['BringForward'] = prot.BringForward;
prot['SendBackward'] = prot.SendBackward;
window['Asc']['c_oAscTypeSelectElement'] = window['Asc'].c_oAscTypeSelectElement = c_oAscTypeSelectElement;
- prot = c_oAscTypeSelectElement;
- prot['Paragraph'] = prot.Paragraph;
- prot['Table'] = prot.Table;
- prot['Image'] = prot.Image;
- prot['Header'] = prot.Header;
- prot['Hyperlink'] = prot.Hyperlink;
- prot['SpellCheck'] = prot.SpellCheck;
- prot['Shape'] = prot.Shape;
- prot['Slide'] = prot.Slide;
- prot['Chart'] = prot.Chart;
- prot['Math'] = prot.Math;
- prot['MailMerge'] = prot.MailMerge;
- prot['ContentControl'] = prot.ContentControl;
- prot['Animation'] = prot.Animation;
- prot['Text'] = prot.Text;
- prot['Annot'] = prot.Annot;
+
+ prot = c_oAscTypeSelectElement;
+ prot['Paragraph'] = prot.Paragraph;
+ prot['Table'] = prot.Table;
+ prot['Image'] = prot.Image;
+ prot['Header'] = prot.Header;
+ prot['Hyperlink'] = prot.Hyperlink;
+ prot['SpellCheck'] = prot.SpellCheck;
+ prot['Shape'] = prot.Shape;
+ prot['Slide'] = prot.Slide;
+ prot['Chart'] = prot.Chart;
+ prot['Math'] = prot.Math;
+ prot['MailMerge'] = prot.MailMerge;
+ prot['ContentControl'] = prot.ContentControl;
+ prot['Animation'] = prot.Animation;
+ prot['Text'] = prot.Text;
+ prot['Annot'] = prot.Annot;
+ prot['UnProtectedRegion'] = prot.UnProtectedRegion;
+
window['Asc']['linerule_AtLeast'] = window['Asc'].linerule_AtLeast = linerule_AtLeast;
window['Asc']['linerule_Auto'] = window['Asc'].linerule_Auto = linerule_Auto;
window['Asc']['linerule_Exact'] = window['Asc'].linerule_Exact = linerule_Exact;
diff --git a/common/docscoapi.js b/common/docscoapi.js
index e08012da98..7810c6c640 100644
--- a/common/docscoapi.js
+++ b/common/docscoapi.js
@@ -50,7 +50,7 @@
this._onlineWork = false;
}
- CDocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, docInfo, shardKey, wopiSrc, userSessionId, openCmd) {
+ CDocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, docInfo, shardKey, wopiSrc, userSessionId, headingsColor, openCmd) {
if (this._CoAuthoringApi && this._CoAuthoringApi.isRightURL()) {
var t = this;
this._CoAuthoringApi.onAuthParticipantsChanged = function(e, id) {
@@ -59,9 +59,6 @@
this._CoAuthoringApi.onParticipantsChanged = function(e) {
t.callback_OnParticipantsChanged(e);
};
- this._CoAuthoringApi.onParticipantsChangedOrigin = function(e) {
- t.callback_OnParticipantsChangedOrigin(e);
- };
this._CoAuthoringApi.onMessage = function(e, clear) {
t.callback_OnMessage(e, clear);
};
@@ -145,7 +142,7 @@
t.callback_OnLicenseChanged(res);
};
- this._CoAuthoringApi.init(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, docInfo, shardKey, wopiSrc, userSessionId, openCmd);
+ this._CoAuthoringApi.init(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, docInfo, shardKey, wopiSrc, userSessionId, headingsColor, openCmd);
this._onlineWork = true;
} else {
// Фиктивные вызовы
@@ -394,12 +391,6 @@
}
};
- CDocsCoApi.prototype.callback_OnParticipantsChangedOrigin = function(e) {
- if (this.onParticipantsChangedOrigin) {
- this.onParticipantsChangedOrigin(e);
- }
- };
-
CDocsCoApi.prototype.callback_OnMessage = function(e, clear) {
if (this.onMessage) {
this.onMessage(e, clear);
@@ -651,6 +642,7 @@
this.encrypted = undefined;
this.IsAnonymousUser = undefined;
this.coEditingMode = undefined;
+ this.headingsColor = undefined;
this._isReSaveAfterAuth = false; // Флаг для сохранения после повторной авторизации (для разрыва соединения во время сохранения)
this._lockBuffer = [];
this._saveChangesChunks = [];
@@ -1433,7 +1425,6 @@
if (this.onAuthParticipantsChanged) {
this.onAuthParticipantsChanged(this._participants, this._userId);
}
- this.onParticipantsChangedOrigin(participants);
// Посылаем эвент о совместном редактировании
if (1 < this._countEditUsers) {
@@ -1465,8 +1456,6 @@
this._participantsTimestamp = data['participantsTimestamp'];
usersStateChanged = this._onParticipantsChanged(data['participants'], true);
- this.onParticipantsChangedOrigin(data['participants']);
-
if (isWaitAuth && !(usersStateChanged.length > 0 && 1 < this._countEditUsers)) {
var errorMsg = 'Error: connection state changed waitAuth' +
';usersStateChanged:' + JSON.stringify(usersStateChanged) +
@@ -1642,7 +1631,7 @@
this._authOtherChanges = [];
};
- DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, docInfo, shardKey, wopiSrc, userSessionId, openCmd) {
+ DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave, docInfo, shardKey, wopiSrc, userSessionId, headingsColor, openCmd) {
this._user = user;
this._docid = null;
this._documentCallbackUrl = documentCallbackUrl;
@@ -1666,6 +1655,7 @@
this.shardKey = shardKey;
this.wopiSrc = wopiSrc;
this.userSessionId = userSessionId;
+ this.headingsColor = headingsColor;
this.setDocId(docid);
this._initSocksJs();
@@ -1718,6 +1708,7 @@
'encrypted': this.encrypted,
'IsAnonymousUser': this.IsAnonymousUser,
'timezoneOffset': (new Date()).getTimezoneOffset(),
+ 'headingsColor': this.headingsColor,
'coEditingMode': this.coEditingMode,
'jwtOpen': this.jwtOpen,
'jwtSession': this.jwtSession,
diff --git a/common/docscoapicommon.js b/common/docscoapicommon.js
index a755914804..1bd04b18f0 100644
--- a/common/docscoapicommon.js
+++ b/common/docscoapicommon.js
@@ -134,7 +134,7 @@
Word:0,
Spreadsheet:1,
Presentation:2,
- Draw:3
+ Visio:3
};
var c_oCloseCode = {
diff --git a/common/editorscommon.js b/common/editorscommon.js
index d79998c51a..40d1c461ac 100644
--- a/common/editorscommon.js
+++ b/common/editorscommon.js
@@ -194,7 +194,6 @@
var oZipImages = null;
var sDownloadServiceLocalUrl = "../../../../downloadas";
var sUploadServiceLocalUrl = "../../../../upload";
- var sUploadServiceLocalUrlOld = "../../../../uploadold";
var sSaveFileLocalUrl = "../../../../savefile";
var sDownloadFileLocalUrl = "../../../../downloadfile";
var nMaxRequestLength = 5242880;//5mb default 30mb
@@ -1160,7 +1159,12 @@
function getFullImageSrc2(src)
{
if (window["NATIVE_EDITOR_ENJINE"])
+ {
+ let localUrl = g_oDocumentUrls.getImageUrl(src);
+ if (localUrl && localUrl.startsWith("blob:"))
+ return localUrl;
return src;
+ }
var start = src.slice(0, 6);
if (0 === start.indexOf('theme') && editor.ThemeLoader)
@@ -1492,14 +1496,14 @@
function build_rx_table_cur()
{
- var loc_all = cStrucTableLocalColumns['a'],
+ let loc_all = cStrucTableLocalColumns['a'],
loc_headers = cStrucTableLocalColumns['h'],
loc_data = cStrucTableLocalColumns['d'],
loc_totals = cStrucTableLocalColumns['t'],
loc_this_row = cStrucTableLocalColumns['tr'],
structured_tables_headata = new XRegExp('(?:\\[\\#' + loc_headers + '\\]\\' + FormulaSeparators.functionArgumentSeparator + '\\[\\#' + loc_data + '\\])'),
structured_tables_datals = new XRegExp('(?:\\[\\#' + loc_data + '\\]\\' + FormulaSeparators.functionArgumentSeparator + '\\[\\#' + loc_totals + '\\])'),
- structured_tables_userColumn = new XRegExp('(?:\'\\[|\'\\]|[^[\\]])+'),
+ structured_tables_userColumn = new XRegExp('\\s*\\[{0,1}(?:\'\\[|\'\\]|[^[\\]])+\\]{0,1}\\s*'),
structured_tables_reservedColumn = new XRegExp('\\#(?:' + loc_all + '|' + loc_headers + '|' + loc_totals + '|' + loc_data + /*'|' + loc_this_row + */')'),
structured_tables_thisRow = new XRegExp('(?:\\#(?:' + loc_this_row +')|(?:\\@))');
@@ -1525,7 +1529,7 @@
let argsSeparator = FormulaSeparators.functionArgumentSeparator;
return XRegExp.build('^(?{{tableName}})\\[(?{{columnName}})?\\]', {
"tableName": new XRegExp("^(:?[" + str_namedRanges + "][" + str_namedRanges + "\\d.]*)"),
- "columnName": XRegExp.build('(?{{reservedColumn}}|{{thisRow}})|(?{{userColumn}})|(?{{userColumnRange}})|(?{{hdtcc}})', {
+ "columnName": XRegExp.build('(?{{hdtcc}})|(?{{reservedColumn}}|{{thisRow}})|(?{{userColumn}})|(?{{userColumnRange}})', {
"userColumn": structured_tables_userColumn,
"reservedColumn": structured_tables_reservedColumn,
"thisRow": structured_tables_thisRow,
@@ -2278,48 +2282,7 @@
function ShowImageFileDialog(documentId, documentUserId, jwt, shardKey, wopiSrc, userSessionId, callback, callbackOld)
{
if (false === _ShowFileDialog(getAcceptByArray(c_oAscImageUploadProp.SupportedFormats), true, true, ValidateUploadImage, callback)) {
- //todo remove this compatibility
- var frameWindow = GetUploadIFrame();
- let url = sUploadServiceLocalUrlOld + '/' + documentId;
- let queryParams = [];
- if (shardKey) {
- queryParams.push(Asc.c_sShardKeyName + '=' + encodeURIComponent(shardKey));
- }
- if (wopiSrc) {
- queryParams.push(Asc.c_sWopiSrcName + '=' + encodeURIComponent(wopiSrc));
- }
- if (userSessionId) {
- queryParams.push(Asc.c_sUserSessionIdName + '=' + encodeURIComponent(userSessionId));
- }
- if (jwt) {
- queryParams.push('token=' + encodeURIComponent(jwt));
- }
- if (queryParams.length > 0) {
- url += '?' + queryParams.join('&');
- }
- var content = '';
- frameWindow.document.open();
- frameWindow.document.write(content);
- frameWindow.document.close();
-
- var fileName = frameWindow.document.getElementById("apiiuFile");
- var fileSubmit = frameWindow.document.getElementById("apiiuSubmit");
-
- fileName.onchange = function (e)
- {
- if (e && e.target && e.target.files)
- {
- var nError = ValidateUploadImage(e.target.files);
- if (c_oAscServerError.NoError != nError)
- {
- callbackOld(mapAscServerErrorToAscError(nError));
- return;
- }
- }
- callbackOld(Asc.c_oAscError.ID.No);
- fileSubmit.click();
- };
- fileName.click();
+ callback(Asc.c_oAscError.ID.Unknown);
}
}
function ShowDocumentFileDialog(callback, isAllowMultiple) {
@@ -2946,7 +2909,7 @@
hostnameRe = /^(((https?)|(ftps?)):\/\/)?([\-\wа-яё]*:?[\-\wа-яё]*@)?(([\-\wа-яё]+\.)+[\wа-яё\-]{2,}(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@:`'~=%!,\(\)]*)(\.[\wа-яё]{2,})?)*)*\/?)/i,
localRe = /^(((https?)|(ftps?)):\/\/)([\-\wа-яё]*:?[\-\wа-яё]*@)?(([\-\wа-яё]+)(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@:`'~=%!,\(\)]*)(\.[\wа-яё]{2,})?)*)*\/?)/i,
fileRe = /^((file):\/\/)[^'`"%^{}<>].*/i,//reserved symbols from word 2010
- rx_allowedProtocols = /(^((https?|ftps?|file|tessa|smb):\/\/)|(mailto:)).*/i,
+ rx_allowedProtocols = /(^((https?|ftps?|file|tessa|joplin|smb):\/\/)|(mailto:)).*/i,
rx_table = build_rx_table(null),
rx_table_local = build_rx_table(null);
@@ -3012,6 +2975,71 @@
return null;
}
+ function isExternalShortLink (string) {
+ // short links that ms writes as [externalLink] + "!" + "Defname"
+ // strings come in "!"+"Defname" format only after external
+ if (string[0] !== "!") {
+ return null;
+ }
+
+ let secondPartOfString = string.slice(1);
+ let defname = XRegExp.exec(secondPartOfString, rx_name);
+
+ if (defname && defname["name"]) {
+ defname = defname["name"];
+ }
+
+ if (!defname || !AscCommon.rx_defName.test(defname)) {
+ return null;
+ }
+
+ return {
+ externalLink: "",
+ defname: defname,
+ fullString: "!" + defname,
+ }
+ }
+
+ function isExternalShortLinkLocal (string) {
+ // short links that user writes as "'externalLinkWithoutBrackets'" + "!" + "Defname" - "'DefTest.xlsx'!_s1"
+ // we split the string into two parts, where the separator is an exclamation point
+ if (!string) {
+ return null;
+ }
+
+ let shortLinkReg = /[\<\>\?\[\]\\\/\|\*\+\"\:\']/; // reg contains special characters that are not allowed in the shortLink
+
+ let linkInQuotes;
+ let exclamationMarkIndex = string.indexOf("!");
+ let externalLink = exclamationMarkIndex !== -1 ? string.substring(0, exclamationMarkIndex) : null;
+ let secondPartOfString = exclamationMarkIndex !== -1 ? string.substring(exclamationMarkIndex + 1) : null;
+
+ let defname = XRegExp.exec(secondPartOfString, rx_name);
+ if (defname && defname["name"]) {
+ defname = defname["name"];
+ }
+
+ if (externalLink && externalLink[0] === "'" && externalLink[externalLink.length - 1] === "'") {
+ externalLink = externalLink.substring(1, externalLink.length - 1);
+ linkInQuotes = true;
+ }
+
+ if (!externalLink || !defname || shortLinkReg.test(externalLink) || !AscCommon.rx_defName.test(defname)) {
+ return null;
+ }
+
+ // external link without quotes is parsed using a regular parser for the name
+ if (!linkInQuotes && !rx_test_ws_name.test(externalLink)) {
+ return null;
+ }
+
+ return {
+ externalLink: externalLink,
+ defname: defname,
+ fullString: linkInQuotes ? ("'" + externalLink + "'" + "!" + defname) : (externalLink + "!" + defname)
+ }
+ }
+
function isValidFileUrl(url) {
if(!url.startsWith("file:")) {
return false;
@@ -3411,7 +3439,32 @@
return false;
};
- parserHelper.prototype.is3DRef = function (formula, start_pos, support_digital_start)
+ /**
+ * Checks if the provided formula is a 3D reference.
+ *
+ * A 3D reference in the context of formulas typically indicates a range of cells
+ * that can span multiple sheets in an Excel workbook. This function analyzes
+ * the formula to determine if it conforms to the format of a 3D reference.
+ *
+ * The function processes the formula starting from the specified position,
+ * handling external links, short links, and various formats of references.
+ *
+ * @param {string} formula - The formula to be checked for 3D reference.
+ * @param {number} start_pos - The starting position in the formula for analysis.
+ * @param {boolean} support_digital_start - Indicates whether the function
+ * supports digital start references (e.g., "1Sheet").
+ * @param {boolean} local - the flag that indicate is local context used or not, that may be used during
+ * the analysis of the formula.
+ * @returns {[boolean, (string|null), (string|null), (string|null), (number|Object|null), (string|null)]}
+ * Returns an array containing:
+ * - A boolean indicating if the formula is a 3D reference.
+ * - The name of the starting sheet or null if not applicable.
+ * - The name of the ending sheet or null if not applicable.
+ * - The external link if applicable, or null.
+ * - The length of the external link if not applicable, or shortLink info object if it exists.
+ * - The supposed defname or null.
+ */
+ parserHelper.prototype.is3DRef = function (formula, start_pos, support_digital_start, local)
{
if (this instanceof parserHelper)
{
@@ -3432,6 +3485,7 @@
//необходимо вычленить имя файла и путь к нему, затем проверить путь
//если путь указан, то ссылка должна быть в одинарных кавычках, если указан просто название файла в [] - в мс это означает, что данный файл открыт, при его закрытии путь проставляется
//пока не реализовываем с открытыми файлами, работаем только с путями
+ //также ссылки типа [] + ! + Defname должны обрабатываться аналогично как [] + SheetName + ! + Defname
external = parseExternalLink(subSTR);
if (external) {
if (external.name && (external.name.indexOf("[") !== -1 || external.name.indexOf(":") !== -1)) {
@@ -3451,7 +3505,25 @@
}
}
- var match = XRegExp.exec(subSTR, rx_ref3D_quoted) || XRegExp.exec(subSTR, rx_ref3D_non_quoted);
+ /* current file check */
+ let currentFileName = window["Asc"]["editor"].DocInfo && window["Asc"]["editor"].DocInfo.get_Title();
+
+ /* shortlink return obj {fullstring, externalLink, defname} */
+ let shortLink = isExternalShortLink(subSTR) || (local && !external && isExternalShortLinkLocal(subSTR));
+
+ if (shortLink) {
+ if ((shortLink.externalLink && shortLink.externalLink === currentFileName) || external === "0") {
+ external = null;
+ shortLink.currentFile = true;
+ }
+
+ this.pCurrPos += shortLink.fullString.length + externalLength;
+ this.operand_str = shortLink.defname;
+ return [true, null, null, external, shortLink];
+ }
+
+ let match = XRegExp.exec(subSTR, rx_ref3D_quoted) || XRegExp.exec(subSTR, rx_ref3D_non_quoted);
+
if(!match && support_digital_start) {
match = XRegExp.exec(subSTR, rx_ref3D_non_quoted_2);
}
@@ -3460,7 +3532,15 @@
{
this.pCurrPos += match[0].length + externalLength;
this.operand_str = match[1];
- return [true, match["name_from"] ? match["name_from"].replace(/''/g, "'") : null, match["name_to"] ? match["name_to"].replace(/''/g, "'") : null, external];
+
+ let currentFileDefname;
+ if (external && external === currentFileName) {
+ let exclamationMarkIndex = subSTR.lastIndexOf("!");
+ let defname = exclamationMarkIndex !== -1 ? subSTR.slice(exclamationMarkIndex + 1) : null;
+ currentFileDefname = defname ? defname : null;
+ }
+
+ return [true, match["name_from"] ? match["name_from"].replace(/''/g, "'") : null, match["name_to"] ? match["name_to"].replace(/''/g, "'") : null, external, null, currentFileDefname];
}
return [false, null, null, external, externalLength];
};
@@ -3794,19 +3874,44 @@
return true;
}
};
- parserHelper.prototype.isTable = function (formula, start_pos, local)
+ parserHelper.prototype.isTable = function (formula, start_pos, local, parserFormula)
{
if (this instanceof parserHelper)
{
this._reset();
}
- let subSTR = formula.substring(start_pos),
- match = XRegExp.exec(subSTR, local ? rx_table_local : rx_table);
+ let subSTR = formula.substring(start_pos);
+ /*
+ short notation can be used inside table cells
+ short entry - an entry without table name, but with the same syntax
+ */
+ let tableIntersection;
+ if (local && subSTR[0] === "[" && parserFormula.parent && parserFormula.ws && parserFormula.ws.TableParts) {
+ let col = parserFormula.parent.nCol;
+ let row = parserFormula.parent.nRow;
+ // go through each existing table and check intersection by col row
+ for (let i = 0; i < parserFormula.ws.TableParts.length; i++) {
+ let table = parserFormula.ws.TableParts[i];
+ let tableRef = table.Ref;
+ if (!tableRef.contains(col, row)) {
+ continue;
+ }
+ tableIntersection = table;
+ break;
+ }
+
+ if (tableIntersection) {
+ // add the table name to the beginning of the line for correct checking further
+ subSTR = tableIntersection.DisplayName + subSTR;
+ }
+ }
+
+ const match = XRegExp.exec(subSTR, local ? rx_table_local : rx_table);
if (match != null && match["tableName"])
{
- this.operand_str = match[0];
- this.pCurrPos += match[0].length;
+ this.operand_str = tableIntersection ? "[" + match.columnName1 + "]" : match[0];
+ this.pCurrPos += tableIntersection ? match.columnName1.length + 2 : match[0].length;
return match;
}
@@ -3818,13 +3923,13 @@
{
this._reset();
}
- // todo если строка подстрока другой
const subSTR = formula.substring(start_pos);
- const fieldName = opt_namesList[0][0];
- const itemNames = opt_namesList[1];
- const fullPatterns = itemNames.map(function(name) {
- return '^' + fieldName + '\\s*\\[\\s*(' + name + ')\\s*\\]'
- });
+ const fullPatterns = [];
+ for (let i = 0; i < opt_namesList[0].length; i += 1) {
+ for (let j = 0; j < opt_namesList[1].length; j += 1) {
+ fullPatterns.push('^(' + opt_namesList[0][i] + ')\\s*\\[\\s*(' + opt_namesList[1][j] + ')\\s*\\]');
+ }
+ }
const fullRegs = fullPatterns.map(function(pattern) {
return new RegExp(pattern, 'i');
});
@@ -3833,10 +3938,10 @@
if (match !== null) {
this.operand_str = match[0];
this.pCurrPos += match[0].length;
- return [fieldName, match[1]];
+ return [match[1], match[2]];
}
}
- const shortPatterns = itemNames.map(function(name) {
+ const shortPatterns = opt_namesList[1].map(function(name) {
return '^(' + name + ')(?:\\W|$)'
});
const shortRegs = shortPatterns.map(function(pattern) {
@@ -3847,7 +3952,7 @@
if (match !== null) {
this.operand_str = match[1];
this.pCurrPos += match[1].length;
- return [null, match[1]];
+ return [null, match[2] ? match[2] : match[1]];
}
}
return false;
@@ -3859,7 +3964,16 @@
this._reset();
}
const subSTR = formula.substring(start_pos);
- const reg = /^(\w+|(?:\'.+?\'(?!\')))\[(\w+|(?:\'.+?\'(?!\')))\]/;
+ const reg = XRegExp.build('(?x) ^({{fieldName}})\\[({{itemName}})\\]', {
+ 'fieldName': XRegExp.build('{{simple}}|{{quotes}}', {
+ 'simple': '[\\p{L}_][\\p{L}\\p{N}_]*',
+ 'quotes': "\\'.+?\\'(?!\\')",
+ }),
+ 'itemName': XRegExp.build('{{simple}}|{{quotes}}', {
+ 'simple': '[\\p{L}\\p{N}_]+',
+ 'quotes': "\\'.+?\\'(?!\\')",
+ })
+ });
const match = reg.exec(subSTR);
if (match !== null && match[1] && match[2]) {
this.operand_str = match[0];
@@ -3908,8 +4022,11 @@
}
};
// Возвращает экранируемое название листа
- parserHelper.prototype.getEscapeSheetName = function (sheet)
+ parserHelper.prototype.getEscapeSheetName = function (sheet, shortLink)
{
+ if (shortLink) {
+ return rx_test_ws_name.test(sheet) ? sheet : sheet.replace(/'/g, "''");
+ }
return rx_test_ws_name.test(sheet) ? sheet : "'" + sheet.replace(/'/g, "''") + "'";
};
/**
@@ -11386,6 +11503,10 @@
loadScript('../../../../sdkjs/common/Charts/ChartStyles.js', onSuccess, onError);
}
+ function loadPathBoolean(onSuccess, onError) {
+ loadScript('../../../../sdkjs/common/Drawings/Format/path-boolean-min.js', onSuccess, onError);
+ }
+
function getAltGr(e)
{
if (true === e["altGraphKey"])
@@ -13865,7 +13986,12 @@
var textQualifier = options.asc_getTextQualifier();
var matrix = [];
//var rows = text.match(/[^\r\n]+/g);
- var rows = text.split(/\r?\n/);
+ var rows;
+ if (delimiterChar === '\n') {
+ rows = [text];
+ } else {
+ rows = text.split(/\r?\n/);
+ }
for (var i = 0; i < rows.length; ++i) {
var row = rows[i];
if(" " === delimiterChar && bTrimSpaces) {
@@ -14772,31 +14898,6 @@
return aArray[Math.random() * aArray.length | 0];
}
- function registerServiceWorker() {
- if ('serviceWorker' in navigator) {
- const serviceWorkerName = 'document_editor_service_worker.js';
- const serviceWorkerPath = '../../../../' + serviceWorkerName;
- let reg;
- navigator.serviceWorker.register(serviceWorkerPath)
- .then(function (registration) {
- reg = registration;
- return navigator.serviceWorker.getRegistrations();
- })
- .then(function (registrations) {
- //delete stale service workers
- for (const registration of registrations) {
- if (registration !== reg && registration.active && registration.active.scriptURL.endsWith(serviceWorkerName)) {
- registration.unregister();
- }
- }
- })
- .catch(function (err) {
- console.error('Registration failed with ' + err);
- });
- }
- }
- registerServiceWorker();
-
function consoleLog(val) {
// console.log(val);
const showMessages = false;
@@ -14913,6 +15014,7 @@
window["AscCommon"].loadSdk = loadSdk;
window["AscCommon"].loadScript = loadScript;
window["AscCommon"].loadChartStyles = loadChartStyles;
+ window["AscCommon"].loadPathBoolean = loadPathBoolean;
window["AscCommon"].getAltGr = getAltGr;
window["AscCommon"].getColorSchemeByName = getColorSchemeByName;
window["AscCommon"].getColorSchemeByIdx = getColorSchemeByIdx;
@@ -15254,6 +15356,9 @@ window["buildCryptoFile_End"] = function(url, error, hash, password)
case AscCommon.c_oEditorId.Spreadsheet:
ext = ".xlsx";
break;
+ case AscCommon.c_oEditorId.Visio:
+ ext = ".vsdx";
+ break;
default:
break;
}
diff --git a/common/errorCodes.js b/common/errorCodes.js
index 07a3cd2b9e..b3f22b3c46 100644
--- a/common/errorCodes.js
+++ b/common/errorCodes.js
@@ -260,7 +260,12 @@
MustIntegerOrDecimalNumber: 1070,
- DocumentAndChangeMismatch: 1080
+ DocumentAndChangeMismatch: 1080,
+ EditProtectedRange : 1081,
+
+
+ // pdf forms
+ PDFFormsLocked: -1200
}
};
@@ -438,6 +443,8 @@
prot['TracePrecedentsNoValidReference'] = prot.TracePrecedentsNoValidReference;
prot['MustIntegerOrDecimalNumber'] = prot.MustIntegerOrDecimalNumber;
prot['DocumentAndChangeMismatch'] = prot.DocumentAndChangeMismatch;
+ prot['EditProtectedRange'] = prot.EditProtectedRange;
+ prot['PDFFormsLocked'] = prot.PDFFormsLocked;
diff --git a/common/libfont/engine.js b/common/libfont/engine.js
index b4e3a92977..8b2b5ac1ec 100644
--- a/common/libfont/engine.js
+++ b/common/libfont/engine.js
@@ -761,6 +761,14 @@ function onLoadFontsModule(window, undefined)
{
return this.engine["getImageBlob"](path);
};
+ /**
+ * Get image file raw data. this memory was copied and detach from archive.
+ * @returns {Uint8Array}
+ */
+ ZLib.prototype.getImageBuffer = function(path)
+ {
+ return this.engine["getImageBuffer"](path);
+ };
/**
* Get all file paths in archive
* @returns {Array}
@@ -772,6 +780,77 @@ function onLoadFontsModule(window, undefined)
AscCommon.ZLib = ZLib;
+ function ZlibImageBlobs()
+ {
+ this.url2BlobUrl = {};
+ this.blobUrl2Data = {};
+ this.url2Base64 = {};
+
+ this.nativeBlobCounter = 1;
+ }
+ ZlibImageBlobs.prototype.getBlobUrl = function(path, zip)
+ {
+ if (this.url2BlobUrl[path])
+ return this.url2BlobUrl[path];
+
+ let result = zip.getImageBuffer(path);
+ if (result == null)
+ return "";
+
+ let blobUrl = "";
+ let blobType = AscCommon.openXml.GetMimeType((24 !== result["type"]) ? AscCommon.GetFileExtension(path) : "svg");
+
+ if (window["NATIVE_EDITOR_ENJINE"])
+ {
+ blobUrl = "blob:internal-image" + this.nativeBlobCounter++;
+ }
+ else
+ {
+ try
+ {
+ let blob = new Blob([result["dataBlob"] ? result["dataBlob"] : result["data"]], {type: blobType});
+ blobUrl = window.URL.createObjectURL(blob);
+ }
+ catch (e)
+ {
+ blobUrl = "error";
+ AscCommon.consoleLog("ERROR: Image blob was not loaded");
+ }
+ }
+
+ this.blobUrl2Data[blobUrl] = result;
+ this.url2BlobUrl[path] = blobUrl;
+ return blobUrl;
+ };
+ ZlibImageBlobs.prototype.getImageBase64 = function(url)
+ {
+ if (this.url2Base64[url])
+ return this.url2Base64[url];
+
+ let obj = this.blobUrl2Data[url];
+ if (!obj)
+ return url;
+
+ let header = "";
+ switch (obj.type)
+ {
+ case 3:
+ header = "data:image/jpeg;base64,";
+ break;
+ case 24:
+ header = "data:image/svg+xml;base64,";
+ break;
+ case 4:
+ default:
+ header = "data:image/png;base64,";
+ }
+
+ this.url2Base64[url] = header + AscCommon.Base64.encode(obj.data);
+ return this.url2Base64[url];
+ };
+
+ window["AscCommon"].g_oDocumentBlobUrls = new ZlibImageBlobs();
+
if (AscCommon["CZLibEngineJS"])
AscCommon["CZLibEngineJS"].prototype["isModuleInit"] = true;
diff --git a/common/libfont/engine/fonts.js b/common/libfont/engine/fonts.js
index d26f609e42..827dfa01ce 100644
--- a/common/libfont/engine/fonts.js
+++ b/common/libfont/engine/fonts.js
@@ -1,5 +1,5 @@
/*
- * (c) Copyright Ascensio System SIA 2010-2024
+ * (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
@@ -48,7 +48,7 @@ if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependen
function(filename){return filename.startsWith(dataURIPrefix)};var wasmBinaryFile;wasmBinaryFile="fonts.wasm";if(!isDataURI(wasmBinaryFile))wasmBinaryFile=locateFile(wasmBinaryFile);function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(file);throw"both async and sync fetching of the wasm failed";}function getBinaryPromise2(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER))if(typeof fetch=="function")return fetch(binaryFile,
{credentials:"same-origin"}).then(function(response){if(!response["ok"])throw"failed to load wasm binary file at '"+binaryFile+"'";return response["arrayBuffer"]()}).catch(function(){return getBinarySync(binaryFile)});return Promise.resolve().then(function(){return getBinarySync(binaryFile)})}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(function(binary){return WebAssembly.instantiate(binary,imports)}).then(function(instance){return instance}).then(receiver,
function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&typeof fetch=="function")return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");
-return instantiateArrayBuffer(binaryFile,imports,callback)})});return instantiateArrayBuffer(binaryFile,imports,callback)}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["Aa"];updateMemoryViews();wasmTable=wasmExports["Ca"];addOnInit(wasmExports["Ba"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}
+return instantiateArrayBuffer(binaryFile,imports,callback)})});return instantiateArrayBuffer(binaryFile,imports,callback)}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["Ca"];updateMemoryViews();wasmTable=wasmExports["Ea"];addOnInit(wasmExports["Da"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}
if(Module["instantiateWasm"])try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult);return{}}function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}var callRuntimeCallbacks=function(callbacks){while(callbacks.length>0)callbacks.shift()(Module)};var noExitRuntime=Module["noExitRuntime"]||
true;var exceptionCaught=[];var uncaughtExceptionCount=0;var ___cxa_begin_catch=function(ptr){var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);___cxa_increment_exception_refcount(info.excPtr);return info.get_exception_ptr()};var exceptionLast=0;var ___cxa_end_catch=function(){_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=0};function ExceptionInfo(excPtr){this.excPtr=
excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};
@@ -80,27 +80,27 @@ addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new
2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12)return"AM";return"PM"},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var days=date.tm_yday+7-date.tm_wday;return leadingNulls(Math.floor(days/7),2)},"%V":function(date){var val=Math.floor((date.tm_yday+7-(date.tm_wday+6)%7)/7);if((date.tm_wday+371-date.tm_yday-2)%7<=2)val++;if(!val){val=52;var dec31=(date.tm_wday+
7-date.tm_yday-1)%7;if(dec31==4||dec31==5&&isLeapYear(date.tm_year%400-1))val++}else if(val==53){var jan1=(date.tm_wday+371-date.tm_yday)%7;if(jan1!=4&&(jan1!=3||!isLeapYear(date.tm_year)))val=1}return leadingNulls(val,2)},"%w":function(date){return date.tm_wday},"%W":function(date){var days=date.tm_yday+7-(date.tm_wday+6)%7;return leadingNulls(Math.floor(days/7),2)},"%y":function(date){return(date.tm_year+1900).toString().substring(2)},"%Y":function(date){return date.tm_year+1900},"%z":function(date){var off=
date.tm_gmtoff;var ahead=off>=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};pattern=pattern.replace(/%%/g,"\x00\x00");for(var rule in EXPANSION_RULES_2)if(pattern.includes(rule))pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date));pattern=pattern.replace(/\0\0/g,"%");var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize)return 0;writeArrayToMemory(bytes,
-s);return bytes.length-1};var _strftime_l=function(s,maxsize,format,tm,loc){return _strftime(s,maxsize,format,tm)};var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=function(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var wasmImports={v:___cxa_begin_catch,x:___cxa_end_catch,a:___cxa_find_matching_catch_2,j:___cxa_find_matching_catch_3,U:___cxa_rethrow,
-A:___cxa_throw,ea:___cxa_uncaught_exceptions,e:___resumeException,S:___syscall_fcntl64,oa:___syscall_fstat64,qa:___syscall_ioctl,la:___syscall_lstat64,ma:___syscall_newfstatat,T:___syscall_openat,ha:___syscall_rmdir,na:___syscall_stat64,ia:___syscall_unlinkat,ra:__emscripten_get_now_is_monotonic,fa:__emscripten_throw_longjmp,K:_abort,sa:_emscripten_date_now,ta:_emscripten_memcpy_js,ga:_emscripten_resize_heap,ja:_environ_get,ka:_environ_sizes_get,C:_exit,M:_fd_close,pa:_fd_read,ba:_fd_seek,R:_fd_write,
-y:invoke_di,P:invoke_diii,Q:invoke_fiii,q:invoke_i,b:invoke_ii,va:invoke_iid,u:invoke_iidd,J:invoke_iidddddd,f:invoke_iii,ua:invoke_iiidd,wa:invoke_iiidddd,d:invoke_iiii,xa:invoke_iiiidddd,k:invoke_iiiii,da:invoke_iiiiid,n:invoke_iiiiii,Z:invoke_iiiiiidd,s:invoke_iiiiiii,B:invoke_iiiiiiii,E:invoke_iiiiiiiii,I:invoke_iiiiiiiiiiii,O:invoke_iiiiiiiiiiiiiii,aa:invoke_jiiii,m:invoke_v,h:invoke_vi,t:invoke_vidd,Y:invoke_viddddiii,g:invoke_vidi,c:invoke_vii,o:invoke_viidd,X:invoke_viidi,W:invoke_viidiii,
-za:invoke_viiffffffi,$:invoke_viiffffi,i:invoke_viii,N:invoke_viiiddiidd,D:invoke_viiiffffffi,z:invoke_viiiffffi,w:invoke_viiiffi,l:invoke_viiii,p:invoke_viiiii,V:invoke_viiiiidd,G:invoke_viiiiii,r:invoke_viiiiiii,L:invoke_viiiiiiii,ya:invoke_viiiiiiiii,F:invoke_viiiiiiiiii,H:invoke_viiiiiiiiiiiiiii,_:_llvm_eh_typeid_for,ca:_strftime_l};var wasmExports=createWasm();var ___wasm_call_ctors=function(){return(___wasm_call_ctors=wasmExports["Ba"])()};var _malloc=Module["_malloc"]=function(a0){return(_malloc=
-Module["_malloc"]=wasmExports["Da"])(a0)};var _free=Module["_free"]=function(a0){return(_free=Module["_free"]=wasmExports["Ea"])(a0)};var ___errno_location=function(){return(___errno_location=wasmExports["__errno_location"])()};var _ASC_FT_Malloc=Module["_ASC_FT_Malloc"]=function(a0){return(_ASC_FT_Malloc=Module["_ASC_FT_Malloc"]=wasmExports["Fa"])(a0)};var _ASC_FT_Free=Module["_ASC_FT_Free"]=function(a0){return(_ASC_FT_Free=Module["_ASC_FT_Free"]=wasmExports["Ga"])(a0)};var _ASC_FT_Init=Module["_ASC_FT_Init"]=
-function(){return(_ASC_FT_Init=Module["_ASC_FT_Init"]=wasmExports["Ha"])()};var _ASC_FT_Done_FreeType=Module["_ASC_FT_Done_FreeType"]=function(a0){return(_ASC_FT_Done_FreeType=Module["_ASC_FT_Done_FreeType"]=wasmExports["Ia"])(a0)};var _ASC_FT_Set_TrueType_HintProp=Module["_ASC_FT_Set_TrueType_HintProp"]=function(a0,a1){return(_ASC_FT_Set_TrueType_HintProp=Module["_ASC_FT_Set_TrueType_HintProp"]=wasmExports["Ja"])(a0,a1)};var _ASC_FT_Open_Face=Module["_ASC_FT_Open_Face"]=function(a0,a1,a2,a3){return(_ASC_FT_Open_Face=
-Module["_ASC_FT_Open_Face"]=wasmExports["Ka"])(a0,a1,a2,a3)};var _ASC_FT_Done_Face=Module["_ASC_FT_Done_Face"]=function(a0){return(_ASC_FT_Done_Face=Module["_ASC_FT_Done_Face"]=wasmExports["La"])(a0)};var _ASC_FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"]=function(a0,a1){return(_ASC_FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"]=wasmExports["Ma"])(a0,a1)};var _ASC_FT_GetFaceInfo=Module["_ASC_FT_GetFaceInfo"]=function(a0){return(_ASC_FT_GetFaceInfo=Module["_ASC_FT_GetFaceInfo"]=
-wasmExports["Na"])(a0)};var _ASC_FT_GetFaceMaxAdvanceX=Module["_ASC_FT_GetFaceMaxAdvanceX"]=function(a0){return(_ASC_FT_GetFaceMaxAdvanceX=Module["_ASC_FT_GetFaceMaxAdvanceX"]=wasmExports["Oa"])(a0)};var _ASC_FT_GetKerningX=Module["_ASC_FT_GetKerningX"]=function(a0,a1,a2){return(_ASC_FT_GetKerningX=Module["_ASC_FT_GetKerningX"]=wasmExports["Pa"])(a0,a1,a2)};var _ASC_FT_Set_Transform=Module["_ASC_FT_Set_Transform"]=function(a0,a1,a2,a3,a4){return(_ASC_FT_Set_Transform=Module["_ASC_FT_Set_Transform"]=
-wasmExports["Qa"])(a0,a1,a2,a3,a4)};var _ASC_FT_Set_Char_Size=Module["_ASC_FT_Set_Char_Size"]=function(a0,a1,a2,a3,a4){return(_ASC_FT_Set_Char_Size=Module["_ASC_FT_Set_Char_Size"]=wasmExports["Ra"])(a0,a1,a2,a3,a4)};var _ASC_FT_Load_Glyph=Module["_ASC_FT_Load_Glyph"]=function(a0,a1,a2){return(_ASC_FT_Load_Glyph=Module["_ASC_FT_Load_Glyph"]=wasmExports["Sa"])(a0,a1,a2)};var _ASC_FT_Glyph_Get_CBox=Module["_ASC_FT_Glyph_Get_CBox"]=function(a0,a1){return(_ASC_FT_Glyph_Get_CBox=Module["_ASC_FT_Glyph_Get_CBox"]=
-wasmExports["Ta"])(a0,a1)};var _ASC_FT_Get_Glyph_Measure_Params=Module["_ASC_FT_Get_Glyph_Measure_Params"]=function(a0,a1){return(_ASC_FT_Get_Glyph_Measure_Params=Module["_ASC_FT_Get_Glyph_Measure_Params"]=wasmExports["Ua"])(a0,a1)};var _ASC_FT_Get_Glyph_Render_Params=Module["_ASC_FT_Get_Glyph_Render_Params"]=function(a0,a1){return(_ASC_FT_Get_Glyph_Render_Params=Module["_ASC_FT_Get_Glyph_Render_Params"]=wasmExports["Va"])(a0,a1)};var _ASC_FT_Get_Glyph_Render_Buffer=Module["_ASC_FT_Get_Glyph_Render_Buffer"]=
-function(a0){return(_ASC_FT_Get_Glyph_Render_Buffer=Module["_ASC_FT_Get_Glyph_Render_Buffer"]=wasmExports["Wa"])(a0)};var _ASC_HB_LanguageFromString=Module["_ASC_HB_LanguageFromString"]=function(a0){return(_ASC_HB_LanguageFromString=Module["_ASC_HB_LanguageFromString"]=wasmExports["Xa"])(a0)};var _ASC_HB_ShapeText=Module["_ASC_HB_ShapeText"]=function(a0,a1,a2,a3,a4,a5,a6){return(_ASC_HB_ShapeText=Module["_ASC_HB_ShapeText"]=wasmExports["Ya"])(a0,a1,a2,a3,a4,a5,a6)};var _ASC_HB_FontFree=Module["_ASC_HB_FontFree"]=
-function(a0){return(_ASC_HB_FontFree=Module["_ASC_HB_FontFree"]=wasmExports["Za"])(a0)};var ___cxa_free_exception=function(a0){return(___cxa_free_exception=wasmExports["__cxa_free_exception"])(a0)};var _Zlib_Malloc=Module["_Zlib_Malloc"]=function(a0){return(_Zlib_Malloc=Module["_Zlib_Malloc"]=wasmExports["_a"])(a0)};var _Zlib_Free=Module["_Zlib_Free"]=function(a0){return(_Zlib_Free=Module["_Zlib_Free"]=wasmExports["$a"])(a0)};var _Zlib_Create=Module["_Zlib_Create"]=function(){return(_Zlib_Create=
-Module["_Zlib_Create"]=wasmExports["ab"])()};var _Zlib_Open=Module["_Zlib_Open"]=function(a0,a1){return(_Zlib_Open=Module["_Zlib_Open"]=wasmExports["bb"])(a0,a1)};var _Zlib_Close=Module["_Zlib_Close"]=function(a0){return(_Zlib_Close=Module["_Zlib_Close"]=wasmExports["cb"])(a0)};var _Zlib_AddFile=Module["_Zlib_AddFile"]=function(a0,a1,a2,a3){return(_Zlib_AddFile=Module["_Zlib_AddFile"]=wasmExports["db"])(a0,a1,a2,a3)};var _Zlib_RemoveFile=Module["_Zlib_RemoveFile"]=function(a0,a1){return(_Zlib_RemoveFile=
-Module["_Zlib_RemoveFile"]=wasmExports["eb"])(a0,a1)};var _Zlib_GetPaths=Module["_Zlib_GetPaths"]=function(a0){return(_Zlib_GetPaths=Module["_Zlib_GetPaths"]=wasmExports["fb"])(a0)};var _Zlib_GetFile=Module["_Zlib_GetFile"]=function(a0,a1){return(_Zlib_GetFile=Module["_Zlib_GetFile"]=wasmExports["gb"])(a0,a1)};var _Zlib_Save=Module["_Zlib_Save"]=function(a0){return(_Zlib_Save=Module["_Zlib_Save"]=wasmExports["hb"])(a0)};var _Raster_DecodeFile=Module["_Raster_DecodeFile"]=function(a0,a1,a2){return(_Raster_DecodeFile=
-Module["_Raster_DecodeFile"]=wasmExports["ib"])(a0,a1,a2)};var _Raster_GetDecodedBuffer=Module["_Raster_GetDecodedBuffer"]=function(a0){return(_Raster_GetDecodedBuffer=Module["_Raster_GetDecodedBuffer"]=wasmExports["jb"])(a0)};var _Raster_GetWidth=Module["_Raster_GetWidth"]=function(a0){return(_Raster_GetWidth=Module["_Raster_GetWidth"]=wasmExports["kb"])(a0)};var _Raster_GetHeight=Module["_Raster_GetHeight"]=function(a0){return(_Raster_GetHeight=Module["_Raster_GetHeight"]=wasmExports["lb"])(a0)};
-var _Raster_GetStride=Module["_Raster_GetStride"]=function(a0){return(_Raster_GetStride=Module["_Raster_GetStride"]=wasmExports["mb"])(a0)};var _Raster_Destroy=Module["_Raster_Destroy"]=function(a0){return(_Raster_Destroy=Module["_Raster_Destroy"]=wasmExports["nb"])(a0)};var _Raster_EncodeImageData=Module["_Raster_EncodeImageData"]=function(a0,a1,a2,a3,a4,a5){return(_Raster_EncodeImageData=Module["_Raster_EncodeImageData"]=wasmExports["ob"])(a0,a1,a2,a3,a4,a5)};var _Raster_Encode=Module["_Raster_Encode"]=
-function(a0,a1,a2){return(_Raster_Encode=Module["_Raster_Encode"]=wasmExports["pb"])(a0,a1,a2)};var _Raster_GetEncodedSize=Module["_Raster_GetEncodedSize"]=function(a0){return(_Raster_GetEncodedSize=Module["_Raster_GetEncodedSize"]=wasmExports["qb"])(a0)};var _Raster_GetEncodedBuffer=Module["_Raster_GetEncodedBuffer"]=function(a0){return(_Raster_GetEncodedBuffer=Module["_Raster_GetEncodedBuffer"]=wasmExports["rb"])(a0)};var _Raster_DestroyEncodedData=Module["_Raster_DestroyEncodedData"]=function(a0){return(_Raster_DestroyEncodedData=
-Module["_Raster_DestroyEncodedData"]=wasmExports["sb"])(a0)};var _Image_GetFormat=Module["_Image_GetFormat"]=function(a0,a1){return(_Image_GetFormat=Module["_Image_GetFormat"]=wasmExports["tb"])(a0,a1)};var setTempRet0=function(a0){return(setTempRet0=wasmExports["ub"])(a0)};var _hyphenCreateApplication=Module["_hyphenCreateApplication"]=function(){return(_hyphenCreateApplication=Module["_hyphenCreateApplication"]=wasmExports["vb"])()};var _hyphenDestroyApplication=Module["_hyphenDestroyApplication"]=
-function(a0){return(_hyphenDestroyApplication=Module["_hyphenDestroyApplication"]=wasmExports["wb"])(a0)};var _hyphenLoadDictionary=Module["_hyphenLoadDictionary"]=function(a0,a1,a2,a3){return(_hyphenLoadDictionary=Module["_hyphenLoadDictionary"]=wasmExports["xb"])(a0,a1,a2,a3)};var _hyphenCheckDictionary=Module["_hyphenCheckDictionary"]=function(a0,a1){return(_hyphenCheckDictionary=Module["_hyphenCheckDictionary"]=wasmExports["yb"])(a0,a1)};var _hyphenWord=Module["_hyphenWord"]=function(a0,a1,a2,
-a3){return(_hyphenWord=Module["_hyphenWord"]=wasmExports["zb"])(a0,a1,a2,a3)};var _setThrew=function(a0,a1){return(_setThrew=wasmExports["Ab"])(a0,a1)};var stackSave=function(){return(stackSave=wasmExports["Bb"])()};var stackRestore=function(a0){return(stackRestore=wasmExports["Cb"])(a0)};var ___cxa_decrement_exception_refcount=function(a0){return(___cxa_decrement_exception_refcount=wasmExports["Db"])(a0)};var ___cxa_increment_exception_refcount=function(a0){return(___cxa_increment_exception_refcount=
-wasmExports["Eb"])(a0)};var ___cxa_can_catch=function(a0,a1,a2){return(___cxa_can_catch=wasmExports["Fb"])(a0,a1,a2)};var ___cxa_is_pointer_type=function(a0){return(___cxa_is_pointer_type=wasmExports["Gb"])(a0)};var dynCall_jiiii=Module["dynCall_jiiii"]=function(a0,a1,a2,a3,a4){return(dynCall_jiiii=Module["dynCall_jiiii"]=wasmExports["Hb"])(a0,a1,a2,a3,a4)};function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,
+s);return bytes.length-1};var _strftime_l=function(s,maxsize,format,tm,loc){return _strftime(s,maxsize,format,tm)};var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=function(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var wasmImports={v:___cxa_begin_catch,x:___cxa_end_catch,a:___cxa_find_matching_catch_2,k:___cxa_find_matching_catch_3,V:___cxa_rethrow,
+B:___cxa_throw,ga:___cxa_uncaught_exceptions,d:___resumeException,T:___syscall_fcntl64,qa:___syscall_fstat64,sa:___syscall_ioctl,na:___syscall_lstat64,oa:___syscall_newfstatat,U:___syscall_openat,ja:___syscall_rmdir,pa:___syscall_stat64,ka:___syscall_unlinkat,ta:__emscripten_get_now_is_monotonic,ha:__emscripten_throw_longjmp,K:_abort,ua:_emscripten_date_now,va:_emscripten_memcpy_js,ia:_emscripten_resize_heap,la:_environ_get,ma:_environ_sizes_get,C:_exit,M:_fd_close,ra:_fd_read,ca:_fd_seek,S:_fd_write,
+y:invoke_di,Q:invoke_diii,R:invoke_fiii,r:invoke_i,b:invoke_ii,ya:invoke_iid,o:invoke_iidd,J:invoke_iidddddd,f:invoke_iii,xa:invoke_iiidd,za:invoke_iiidddd,e:invoke_iiii,O:invoke_iiiidddd,j:invoke_iiiii,fa:invoke_iiiiid,n:invoke_iiiiii,_:invoke_iiiiiidd,s:invoke_iiiiiii,z:invoke_iiiiiiii,E:invoke_iiiiiiiii,I:invoke_iiiiiiiiiiii,P:invoke_iiiiiiiiiiiiiii,ba:invoke_jiiii,m:invoke_v,i:invoke_vi,wa:invoke_vid,u:invoke_vidd,Z:invoke_viddddiii,h:invoke_vidi,c:invoke_vii,da:invoke_viid,p:invoke_viidd,Y:invoke_viidi,
+X:invoke_viidiii,Ba:invoke_viiffffffi,aa:invoke_viiffffi,g:invoke_viii,N:invoke_viiiddiidd,D:invoke_viiiffffffi,A:invoke_viiiffffi,w:invoke_viiiffi,l:invoke_viiii,q:invoke_viiiii,W:invoke_viiiiidd,G:invoke_viiiiii,t:invoke_viiiiiii,L:invoke_viiiiiiii,Aa:invoke_viiiiiiiii,F:invoke_viiiiiiiiii,H:invoke_viiiiiiiiiiiiiii,$:_llvm_eh_typeid_for,ea:_strftime_l};var wasmExports=createWasm();var ___wasm_call_ctors=function(){return(___wasm_call_ctors=wasmExports["Da"])()};var _malloc=Module["_malloc"]=function(a0){return(_malloc=
+Module["_malloc"]=wasmExports["Fa"])(a0)};var _free=Module["_free"]=function(a0){return(_free=Module["_free"]=wasmExports["Ga"])(a0)};var ___errno_location=function(){return(___errno_location=wasmExports["__errno_location"])()};var _ASC_FT_Malloc=Module["_ASC_FT_Malloc"]=function(a0){return(_ASC_FT_Malloc=Module["_ASC_FT_Malloc"]=wasmExports["Ha"])(a0)};var _ASC_FT_Free=Module["_ASC_FT_Free"]=function(a0){return(_ASC_FT_Free=Module["_ASC_FT_Free"]=wasmExports["Ia"])(a0)};var _ASC_FT_Init=Module["_ASC_FT_Init"]=
+function(){return(_ASC_FT_Init=Module["_ASC_FT_Init"]=wasmExports["Ja"])()};var _ASC_FT_Done_FreeType=Module["_ASC_FT_Done_FreeType"]=function(a0){return(_ASC_FT_Done_FreeType=Module["_ASC_FT_Done_FreeType"]=wasmExports["Ka"])(a0)};var _ASC_FT_Set_TrueType_HintProp=Module["_ASC_FT_Set_TrueType_HintProp"]=function(a0,a1){return(_ASC_FT_Set_TrueType_HintProp=Module["_ASC_FT_Set_TrueType_HintProp"]=wasmExports["La"])(a0,a1)};var _ASC_FT_Open_Face=Module["_ASC_FT_Open_Face"]=function(a0,a1,a2,a3){return(_ASC_FT_Open_Face=
+Module["_ASC_FT_Open_Face"]=wasmExports["Ma"])(a0,a1,a2,a3)};var _ASC_FT_Done_Face=Module["_ASC_FT_Done_Face"]=function(a0){return(_ASC_FT_Done_Face=Module["_ASC_FT_Done_Face"]=wasmExports["Na"])(a0)};var _ASC_FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"]=function(a0,a1){return(_ASC_FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"]=wasmExports["Oa"])(a0,a1)};var _ASC_FT_GetFaceInfo=Module["_ASC_FT_GetFaceInfo"]=function(a0){return(_ASC_FT_GetFaceInfo=Module["_ASC_FT_GetFaceInfo"]=
+wasmExports["Pa"])(a0)};var _ASC_FT_GetFaceMaxAdvanceX=Module["_ASC_FT_GetFaceMaxAdvanceX"]=function(a0){return(_ASC_FT_GetFaceMaxAdvanceX=Module["_ASC_FT_GetFaceMaxAdvanceX"]=wasmExports["Qa"])(a0)};var _ASC_FT_GetKerningX=Module["_ASC_FT_GetKerningX"]=function(a0,a1,a2){return(_ASC_FT_GetKerningX=Module["_ASC_FT_GetKerningX"]=wasmExports["Ra"])(a0,a1,a2)};var _ASC_FT_Set_Transform=Module["_ASC_FT_Set_Transform"]=function(a0,a1,a2,a3,a4){return(_ASC_FT_Set_Transform=Module["_ASC_FT_Set_Transform"]=
+wasmExports["Sa"])(a0,a1,a2,a3,a4)};var _ASC_FT_Set_Char_Size=Module["_ASC_FT_Set_Char_Size"]=function(a0,a1,a2,a3,a4){return(_ASC_FT_Set_Char_Size=Module["_ASC_FT_Set_Char_Size"]=wasmExports["Ta"])(a0,a1,a2,a3,a4)};var _ASC_FT_Load_Glyph=Module["_ASC_FT_Load_Glyph"]=function(a0,a1,a2){return(_ASC_FT_Load_Glyph=Module["_ASC_FT_Load_Glyph"]=wasmExports["Ua"])(a0,a1,a2)};var _ASC_FT_Glyph_Get_CBox=Module["_ASC_FT_Glyph_Get_CBox"]=function(a0,a1){return(_ASC_FT_Glyph_Get_CBox=Module["_ASC_FT_Glyph_Get_CBox"]=
+wasmExports["Va"])(a0,a1)};var _ASC_FT_Get_Glyph_Measure_Params=Module["_ASC_FT_Get_Glyph_Measure_Params"]=function(a0,a1){return(_ASC_FT_Get_Glyph_Measure_Params=Module["_ASC_FT_Get_Glyph_Measure_Params"]=wasmExports["Wa"])(a0,a1)};var _ASC_FT_Get_Glyph_Render_Params=Module["_ASC_FT_Get_Glyph_Render_Params"]=function(a0,a1){return(_ASC_FT_Get_Glyph_Render_Params=Module["_ASC_FT_Get_Glyph_Render_Params"]=wasmExports["Xa"])(a0,a1)};var _ASC_FT_Get_Glyph_Render_Buffer=Module["_ASC_FT_Get_Glyph_Render_Buffer"]=
+function(a0){return(_ASC_FT_Get_Glyph_Render_Buffer=Module["_ASC_FT_Get_Glyph_Render_Buffer"]=wasmExports["Ya"])(a0)};var _ASC_HB_LanguageFromString=Module["_ASC_HB_LanguageFromString"]=function(a0){return(_ASC_HB_LanguageFromString=Module["_ASC_HB_LanguageFromString"]=wasmExports["Za"])(a0)};var _ASC_HB_ShapeText=Module["_ASC_HB_ShapeText"]=function(a0,a1,a2,a3,a4,a5,a6){return(_ASC_HB_ShapeText=Module["_ASC_HB_ShapeText"]=wasmExports["_a"])(a0,a1,a2,a3,a4,a5,a6)};var _ASC_HB_FontFree=Module["_ASC_HB_FontFree"]=
+function(a0){return(_ASC_HB_FontFree=Module["_ASC_HB_FontFree"]=wasmExports["$a"])(a0)};var ___cxa_free_exception=function(a0){return(___cxa_free_exception=wasmExports["__cxa_free_exception"])(a0)};var _Zlib_Malloc=Module["_Zlib_Malloc"]=function(a0){return(_Zlib_Malloc=Module["_Zlib_Malloc"]=wasmExports["ab"])(a0)};var _Zlib_Free=Module["_Zlib_Free"]=function(a0){return(_Zlib_Free=Module["_Zlib_Free"]=wasmExports["bb"])(a0)};var _Zlib_Create=Module["_Zlib_Create"]=function(){return(_Zlib_Create=
+Module["_Zlib_Create"]=wasmExports["cb"])()};var _Zlib_Open=Module["_Zlib_Open"]=function(a0,a1){return(_Zlib_Open=Module["_Zlib_Open"]=wasmExports["db"])(a0,a1)};var _Zlib_Close=Module["_Zlib_Close"]=function(a0){return(_Zlib_Close=Module["_Zlib_Close"]=wasmExports["eb"])(a0)};var _Zlib_AddFile=Module["_Zlib_AddFile"]=function(a0,a1,a2,a3){return(_Zlib_AddFile=Module["_Zlib_AddFile"]=wasmExports["fb"])(a0,a1,a2,a3)};var _Zlib_RemoveFile=Module["_Zlib_RemoveFile"]=function(a0,a1){return(_Zlib_RemoveFile=
+Module["_Zlib_RemoveFile"]=wasmExports["gb"])(a0,a1)};var _Zlib_GetPaths=Module["_Zlib_GetPaths"]=function(a0){return(_Zlib_GetPaths=Module["_Zlib_GetPaths"]=wasmExports["hb"])(a0)};var _Zlib_GetFile=Module["_Zlib_GetFile"]=function(a0,a1){return(_Zlib_GetFile=Module["_Zlib_GetFile"]=wasmExports["ib"])(a0,a1)};var _Zlib_Save=Module["_Zlib_Save"]=function(a0){return(_Zlib_Save=Module["_Zlib_Save"]=wasmExports["jb"])(a0)};var _Raster_DecodeFile=Module["_Raster_DecodeFile"]=function(a0,a1,a2){return(_Raster_DecodeFile=
+Module["_Raster_DecodeFile"]=wasmExports["kb"])(a0,a1,a2)};var _Raster_GetDecodedBuffer=Module["_Raster_GetDecodedBuffer"]=function(a0){return(_Raster_GetDecodedBuffer=Module["_Raster_GetDecodedBuffer"]=wasmExports["lb"])(a0)};var _Raster_GetWidth=Module["_Raster_GetWidth"]=function(a0){return(_Raster_GetWidth=Module["_Raster_GetWidth"]=wasmExports["mb"])(a0)};var _Raster_GetHeight=Module["_Raster_GetHeight"]=function(a0){return(_Raster_GetHeight=Module["_Raster_GetHeight"]=wasmExports["nb"])(a0)};
+var _Raster_GetStride=Module["_Raster_GetStride"]=function(a0){return(_Raster_GetStride=Module["_Raster_GetStride"]=wasmExports["ob"])(a0)};var _Raster_Destroy=Module["_Raster_Destroy"]=function(a0){return(_Raster_Destroy=Module["_Raster_Destroy"]=wasmExports["pb"])(a0)};var _Raster_EncodeImageData=Module["_Raster_EncodeImageData"]=function(a0,a1,a2,a3,a4,a5){return(_Raster_EncodeImageData=Module["_Raster_EncodeImageData"]=wasmExports["qb"])(a0,a1,a2,a3,a4,a5)};var _Raster_Encode=Module["_Raster_Encode"]=
+function(a0,a1,a2){return(_Raster_Encode=Module["_Raster_Encode"]=wasmExports["rb"])(a0,a1,a2)};var _Raster_GetEncodedSize=Module["_Raster_GetEncodedSize"]=function(a0){return(_Raster_GetEncodedSize=Module["_Raster_GetEncodedSize"]=wasmExports["sb"])(a0)};var _Raster_GetEncodedBuffer=Module["_Raster_GetEncodedBuffer"]=function(a0){return(_Raster_GetEncodedBuffer=Module["_Raster_GetEncodedBuffer"]=wasmExports["tb"])(a0)};var _Raster_DestroyEncodedData=Module["_Raster_DestroyEncodedData"]=function(a0){return(_Raster_DestroyEncodedData=
+Module["_Raster_DestroyEncodedData"]=wasmExports["ub"])(a0)};var _Image_GetFormat=Module["_Image_GetFormat"]=function(a0,a1){return(_Image_GetFormat=Module["_Image_GetFormat"]=wasmExports["vb"])(a0,a1)};var setTempRet0=function(a0){return(setTempRet0=wasmExports["wb"])(a0)};var _hyphenCreateApplication=Module["_hyphenCreateApplication"]=function(){return(_hyphenCreateApplication=Module["_hyphenCreateApplication"]=wasmExports["xb"])()};var _hyphenDestroyApplication=Module["_hyphenDestroyApplication"]=
+function(a0){return(_hyphenDestroyApplication=Module["_hyphenDestroyApplication"]=wasmExports["yb"])(a0)};var _hyphenLoadDictionary=Module["_hyphenLoadDictionary"]=function(a0,a1,a2,a3){return(_hyphenLoadDictionary=Module["_hyphenLoadDictionary"]=wasmExports["zb"])(a0,a1,a2,a3)};var _hyphenCheckDictionary=Module["_hyphenCheckDictionary"]=function(a0,a1){return(_hyphenCheckDictionary=Module["_hyphenCheckDictionary"]=wasmExports["Ab"])(a0,a1)};var _hyphenWord=Module["_hyphenWord"]=function(a0,a1,a2,
+a3){return(_hyphenWord=Module["_hyphenWord"]=wasmExports["Bb"])(a0,a1,a2,a3)};var _setThrew=function(a0,a1){return(_setThrew=wasmExports["Cb"])(a0,a1)};var stackSave=function(){return(stackSave=wasmExports["Db"])()};var stackRestore=function(a0){return(stackRestore=wasmExports["Eb"])(a0)};var ___cxa_decrement_exception_refcount=function(a0){return(___cxa_decrement_exception_refcount=wasmExports["Fb"])(a0)};var ___cxa_increment_exception_refcount=function(a0){return(___cxa_increment_exception_refcount=
+wasmExports["Gb"])(a0)};var ___cxa_can_catch=function(a0,a1,a2){return(___cxa_can_catch=wasmExports["Hb"])(a0,a1,a2)};var ___cxa_is_pointer_type=function(a0){return(___cxa_is_pointer_type=wasmExports["Ib"])(a0)};var dynCall_jiiii=Module["dynCall_jiiii"]=function(a0,a1,a2,a3,a4){return(dynCall_jiiii=Module["dynCall_jiiii"]=wasmExports["Jb"])(a0,a1,a2,a3,a4)};function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,
a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);
if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,
a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiii(index,
@@ -115,29 +115,31 @@ try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)thro
a7){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidd(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiidd(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiddiidd(index,
a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viddddiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vidd(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,
0)}}function invoke_viidi(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiidd(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+
-0)throw e;_setThrew(1,0)}}function invoke_iiiiid(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_fiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==
-e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}
-function invoke_jiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_jiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0)return;preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();
-postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else doRun()}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0)Module["preInit"].pop()()}run();function CReturnObject(){this.error=0;this.freeObj=0}CReturnObject.prototype.free=function(){Module["_ASC_FT_Free"](this.freeObj)};var g_return_obj=new CReturnObject;var g_return_obj_count=
-new CReturnObject;g_return_obj_count.count=0;AscFonts.CopyStreamToMemory=function(data,size){var fontStreamPointer=Module["_ASC_FT_Malloc"](size);Module["HEAP8"].set(data,fontStreamPointer);return fontStreamPointer};AscFonts.GetUint8ArrayFromPointer=function(pointer,size){return new Uint8Array(Module["HEAP8"].buffer,pointer,size)};function CShapeString(size){this.size=size;this.pointer=Module["_malloc"](size)}CShapeString.prototype.getBuffer=function(){return new Uint8Array(Module["HEAPU8"].buffer,
-this.pointer,this.size)};CShapeString.prototype.free=function(){Module["_free"](this.pointer)};CShapeString.prototype.set=function(index,value){Module["HEAPU8"][this.pointer+index]=value};AscFonts.AllocString=function(size){return new CShapeString(size)};AscFonts.FT_CreateLibrary=Module["_ASC_FT_Init"];AscFonts.FT_Done_Library=Module["_ASC_FT_Done_FreeType"];AscFonts.FT_Set_TrueType_HintProp=Module["_ASC_FT_Set_TrueType_HintProp"];AscFonts.FT_Open_Face=Module["_ASC_FT_Open_Face"];AscFonts.FT_Done_Face=
-Module["_ASC_FT_Done_Face"];AscFonts.FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"];AscFonts.FT_GetKerningX=Module["_ASC_FT_GetKerningX"];AscFonts.FT_GetFaceMaxAdvanceX=Module["_ASC_FT_GetFaceMaxAdvanceX"];AscFonts.FT_Set_Transform=Module["_ASC_FT_Set_Transform"];AscFonts.FT_Set_Char_Size=Module["_ASC_FT_Set_Char_Size"];AscFonts.FT_GetFaceInfo=function(face,reader){var pointer=Module["_ASC_FT_GetFaceInfo"](face);if(!pointer){g_return_obj.error=1;return g_return_obj}var len_buffer=Math.min(Module["HEAP8"].length-
-pointer,1E3);reader.init(new Uint8Array(Module["HEAP8"].buffer,pointer,len_buffer));g_return_obj.freeObj=pointer;g_return_obj.error=0;return g_return_obj};AscFonts.FT_Load_Glyph=Module["_ASC_FT_Load_Glyph"];AscFonts.FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"];AscFonts.FT_Get_Glyph_Measure_Params=function(face,vector_worker,reader){var pointer=Module["_ASC_FT_Get_Glyph_Measure_Params"](face,vector_worker?1:0);if(!pointer){g_return_obj_count.error=1;return g_return_obj_count}var len=
-!vector_worker?15:Module["HEAP32"][pointer>>2];if(vector_worker)len=Module["HEAP32"][pointer>>2];reader.init(new Uint8Array(Module["HEAP8"].buffer,pointer+4,4*(len-1)));g_return_obj_count.freeObj=pointer;g_return_obj_count.count=len;g_return_obj_count.error=0;return g_return_obj_count};AscFonts.FT_Get_Glyph_Render_Params=function(face,render_mode,reader){var pointer=Module["_ASC_FT_Get_Glyph_Render_Params"](face,render_mode);if(!pointer){g_return_obj_count.error=1;return g_return_obj_count}reader.init(new Uint8Array(Module["HEAP8"].buffer,
-pointer,4*6));g_return_obj.freeObj=pointer;g_return_obj.error=0;return g_return_obj};AscFonts.FT_Get_Glyph_Render_Buffer=function(face,size){var pointer=Module["_ASC_FT_Get_Glyph_Render_Buffer"](face);return new Uint8Array(Module["HEAP8"].buffer,pointer,size)};var hb_cache_languages={};AscFonts.HB_FontFree=Module["ASC_HB_FontFree"];AscFonts.HB_ShapeText=function(fontFile,text,features,script,direction,language,reader){if(!hb_cache_languages[language]){var langBuffer=language.toUtf8();var langPointer=
-Module["_malloc"](langBuffer.length);Module["HEAP8"].set(langBuffer,langBuffer);hb_cache_languages[language]=Module["_ASC_HB_LanguageFromString"](langPointer);Module["_free"](langPointer)}var pointer=Module["_ASC_HB_ShapeText"](fontFile["GetFace"](),fontFile["GetHBFont"](),text.pointer,features,script,direction,hb_cache_languages[language]);if(!pointer){g_return_obj_count.error=1;return g_return_obj_count}var buffer=Module["HEAP8"];var len=(buffer[pointer+3]&255)<<24|(buffer[pointer+2]&255)<<16|(buffer[pointer+
-1]&255)<<8|buffer[pointer]&255;reader.init(buffer,pointer+4,len-4);fontFile["SetHBFont"](reader.readPointer64());g_return_obj_count.freeObj=pointer;g_return_obj_count.count=(len-12)/26;g_return_obj_count.error=0;return g_return_obj_count};function ZLib(){this.engine=0;this.files={}}ZLib.prototype.isModuleInit=false;ZLib.prototype.open=function(buf){if(!this.isModuleInit)return false;if(this.engine)this.close();if(!buf)return false;var arrayBuffer=undefined!==buf.byteLength?new Uint8Array(buf):buf;
-var FileRawDataSize=arrayBuffer.length;var FileRawData=Module["_Zlib_Malloc"](FileRawDataSize);if(0==FileRawData)return false;Module["HEAP8"].set(arrayBuffer,FileRawData);this.engine=Module["_Zlib_Open"](FileRawData,FileRawDataSize);if(0==this.engine){Module["_Zlib_Free"](FileRawData);return false}var pointer=Module["_Zlib_GetPaths"](this.engine);if(0==pointer){Module["_Zlib_Close"](this.engine);Module["_Zlib_Free"](FileRawData);return false}var lenArray=new Int32Array(Module["HEAP8"].buffer,pointer,
-4);var len=lenArray[0];len-=4;var buffer=new Uint8Array(Module["HEAP8"].buffer,pointer+4,len);var index=0;while(index0)return new Uint8Array(Module["HEAP8"].buffer,this.files[path].p,this.files[path].l);else{var _lenFile=new Int32Array(Module["HEAP8"].buffer,this.files[path].p,4);var len=_lenFile[0];return new Uint8Array(Module["HEAP8"].buffer,this.files[path].p+4,len)}var tmp=path.toUtf8();var pointer=Module["_Zlib_Malloc"](tmp.length);
-if(0==pointer)return null;Module["HEAP8"].set(tmp,pointer);var pointerFile=Module["_Zlib_GetFile"](this.engine,pointer);if(0==pointerFile){Module["_Zlib_Free"](pointer);return null}var _lenFile=new Int32Array(Module["HEAP8"].buffer,pointerFile,4);var len=_lenFile[0];Module["_Zlib_Free"](pointer);this.files[path]={p:pointerFile,l:0};return new Uint8Array(Module["HEAP8"].buffer,pointerFile+4,len)};ZLib.prototype.addFile=function(path,data){if(!this.isModuleInit||!this.engine)return false;if(!data)return false;
-if(undefined!==this.files[path])this.removeFile(path);var tmp=path.toUtf8();var pointer=Module["_Zlib_Malloc"](tmp.length);if(0==pointer)return false;Module["HEAP8"].set(tmp,pointer);var arrayBuffer=undefined!==data.byteLength?new Uint8Array(data):data;var FileRawDataSize=arrayBuffer.length;var FileRawData=Module["_Zlib_Malloc"](FileRawDataSize);if(0==FileRawData){Module["_Zlib_Free"](pointer);return false}Module["HEAP8"].set(arrayBuffer,FileRawData);Module["_Zlib_AddFile"](this.engine,pointer,FileRawData,
-FileRawDataSize);this.files[path]={p:FileRawData,l:FileRawDataSize};Module["_Zlib_Free"](pointer);return true};ZLib.prototype.removeFile=function(path){if(!this.isModuleInit||!this.engine)return false;if(undefined===this.files[path])return false;var tmp=path.toUtf8();var pointer=Module["_Zlib_Malloc"](tmp.length);if(0==pointer)return false;Module["HEAP8"].set(tmp,pointer);Module["_Zlib_RemoveFile"](this.engine,pointer);if(this.files[path]&&this.files[path].p){Module["_Zlib_Free"](this.files[path].p);
-delete this.files[path]}Module["_Zlib_Free"](pointer);return true};ZLib.prototype.close=function(){if(!this.isModuleInit||!this.engine)return;for(var i in this.files)if(this.files[i]&&this.files[i].p)Module["_Zlib_Free"](this.files[i].p);this.files={};if(this.engine)Module["_Zlib_Free"](this.engine);this.engine=0};ZLib.prototype.getImageType=function(path){var fileData=this.getFile(path);return Module["_Image_GetFormat"](this.files[path].p+4,fileData.length)};ZLib.prototype.getImageAsFormat=function(path,
-format){var fileData=this.getFile(path);var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,format);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);var copyData=new Uint8Array(encodedSize);copyData.set(new Uint8Array(Module["HEAP8"].buffer,encodedBuffer,encodedSize));Module["_Raster_DestroyEncodedData"](encodedData);return copyData};ZLib.prototype.getImageAsSvg=function(path){var fileData=this.getFile(path);
-var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,24);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);var string=String.prototype.fromUtf8(new Uint8Array(Module["HEAP8"].buffer,encodedBuffer,encodedSize));Module["_Raster_DestroyEncodedData"](encodedData);return string};ZLib.prototype.getImageBlob=function(path){var imageType=this.getImageType(path);if(imageType!=10&&imageType!=21)return new Blob([this.getFile(path)],
-{type:AscCommon.openXml.GetMimeType(AscCommon.GetFileExtension(path))});var fileData=this.getFile(path);var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,24);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);var blob=new Blob([new Uint8Array(Module["HEAP8"].buffer,encodedBuffer,encodedSize)],{type:AscCommon.openXml.GetMimeType("svg")});Module["_Raster_DestroyEncodedData"](encodedData);return blob};
-window.AscCommon=window.AscCommon||{};window.AscCommon.CZLibEngineJS=ZLib;var hyphenApplication=0;AscFonts.Hyphen_Init=function(){hyphenApplication=Module["_hyphenCreateApplication"]()};AscFonts.Hyphen_Destroy=function(){Module["_hyphenDestroyApplication"](hyphenApplication)};AscFonts.Hyphen_CheckDictionary=function(lang){return false};AscFonts.Hyphen_LoadDictionary=function(lang,data){var dictSize=data.byteLength;var dictPointer=Module["_malloc"](dictSize);Module["HEAP8"].set(new Uint8ClampedArray(data),
-dictPointer);var result=Module["_hyphenLoadDictionary"](hyphenApplication,lang,dictPointer,dictSize);Module["_free"](dictPointer);return result===0?true:false};AscFonts.Hyphen_Word=function(lang,word){var wordPointer=word.toUtf8Pointer(true);var wordLen=wordPointer.length;var hyphens=[];if(wordPointer){var ptr=Module._hyphenWord(hyphenApplication,lang,wordPointer.ptr,wordLen);var vector=new Uint8ClampedArray(Module["HEAP8"].buffer,ptr,wordLen+5);var pos=0;while(vector[pos]!=0){if(1===(vector[pos]&
-1))hyphens.push(pos+1);pos++}wordPointer.free()}return hyphens};if(window["NATIVE_EDITOR_ENJINE"])window.immediateRun();AscFonts.onLoadModule()})(window,undefined);
+0)throw e;_setThrew(1,0)}}function invoke_vid(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiid(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_fiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,
+0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15){var sp=stackSave();try{getWasmTableEntry(index)(a1,
+a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viid(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_jiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();
+if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0)return;preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else doRun()}if(Module["preInit"]){if(typeof Module["preInit"]==
+"function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0)Module["preInit"].pop()()}run();function CReturnObject(){this.error=0;this.freeObj=0}CReturnObject.prototype.free=function(){Module["_ASC_FT_Free"](this.freeObj)};var g_return_obj=new CReturnObject;var g_return_obj_count=new CReturnObject;g_return_obj_count.count=0;AscFonts.CopyStreamToMemory=function(data,size){var fontStreamPointer=Module["_ASC_FT_Malloc"](size);Module["HEAP8"].set(data,fontStreamPointer);return fontStreamPointer};
+AscFonts.GetUint8ArrayFromPointer=function(pointer,size){return new Uint8Array(Module["HEAP8"].buffer,pointer,size)};function CShapeString(size){this.size=size;this.pointer=Module["_malloc"](size)}CShapeString.prototype.getBuffer=function(){return new Uint8Array(Module["HEAPU8"].buffer,this.pointer,this.size)};CShapeString.prototype.free=function(){Module["_free"](this.pointer)};CShapeString.prototype.set=function(index,value){Module["HEAPU8"][this.pointer+index]=value};AscFonts.AllocString=function(size){return new CShapeString(size)};
+AscFonts.FT_CreateLibrary=Module["_ASC_FT_Init"];AscFonts.FT_Done_Library=Module["_ASC_FT_Done_FreeType"];AscFonts.FT_Set_TrueType_HintProp=Module["_ASC_FT_Set_TrueType_HintProp"];AscFonts.FT_Open_Face=Module["_ASC_FT_Open_Face"];AscFonts.FT_Done_Face=Module["_ASC_FT_Done_Face"];AscFonts.FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"];AscFonts.FT_GetKerningX=Module["_ASC_FT_GetKerningX"];AscFonts.FT_GetFaceMaxAdvanceX=Module["_ASC_FT_GetFaceMaxAdvanceX"];AscFonts.FT_Set_Transform=Module["_ASC_FT_Set_Transform"];
+AscFonts.FT_Set_Char_Size=Module["_ASC_FT_Set_Char_Size"];AscFonts.FT_GetFaceInfo=function(face,reader){var pointer=Module["_ASC_FT_GetFaceInfo"](face);if(!pointer){g_return_obj.error=1;return g_return_obj}var len_buffer=Math.min(Module["HEAP8"].length-pointer,1E3);reader.init(new Uint8Array(Module["HEAP8"].buffer,pointer,len_buffer));g_return_obj.freeObj=pointer;g_return_obj.error=0;return g_return_obj};AscFonts.FT_Load_Glyph=Module["_ASC_FT_Load_Glyph"];AscFonts.FT_SetCMapForCharCode=Module["_ASC_FT_SetCMapForCharCode"];
+AscFonts.FT_Get_Glyph_Measure_Params=function(face,vector_worker,reader){var pointer=Module["_ASC_FT_Get_Glyph_Measure_Params"](face,vector_worker?1:0);if(!pointer){g_return_obj_count.error=1;return g_return_obj_count}var len=!vector_worker?15:Module["HEAP32"][pointer>>2];if(vector_worker)len=Module["HEAP32"][pointer>>2];reader.init(new Uint8Array(Module["HEAP8"].buffer,pointer+4,4*(len-1)));g_return_obj_count.freeObj=pointer;g_return_obj_count.count=len;g_return_obj_count.error=0;return g_return_obj_count};
+AscFonts.FT_Get_Glyph_Render_Params=function(face,render_mode,reader){var pointer=Module["_ASC_FT_Get_Glyph_Render_Params"](face,render_mode);if(!pointer){g_return_obj_count.error=1;return g_return_obj_count}reader.init(new Uint8Array(Module["HEAP8"].buffer,pointer,4*6));g_return_obj.freeObj=pointer;g_return_obj.error=0;return g_return_obj};AscFonts.FT_Get_Glyph_Render_Buffer=function(face,size){var pointer=Module["_ASC_FT_Get_Glyph_Render_Buffer"](face);return new Uint8Array(Module["HEAP8"].buffer,
+pointer,size)};var hb_cache_languages={};AscFonts.HB_FontFree=Module["ASC_HB_FontFree"];AscFonts.HB_ShapeText=function(fontFile,text,features,script,direction,language,reader){if(!hb_cache_languages[language]){var langBuffer=language.toUtf8();var langPointer=Module["_malloc"](langBuffer.length);Module["HEAP8"].set(langBuffer,langBuffer);hb_cache_languages[language]=Module["_ASC_HB_LanguageFromString"](langPointer);Module["_free"](langPointer)}var pointer=Module["_ASC_HB_ShapeText"](fontFile["GetFace"](),
+fontFile["GetHBFont"](),text.pointer,features,script,direction,hb_cache_languages[language]);if(!pointer){g_return_obj_count.error=1;return g_return_obj_count}var buffer=Module["HEAP8"];var len=(buffer[pointer+3]&255)<<24|(buffer[pointer+2]&255)<<16|(buffer[pointer+1]&255)<<8|buffer[pointer]&255;reader.init(buffer,pointer+4,len-4);fontFile["SetHBFont"](reader.readPointer64());g_return_obj_count.freeObj=pointer;g_return_obj_count.count=(len-12)/26;g_return_obj_count.error=0;return g_return_obj_count};
+function ZLib(){this.engine=0;this.files={}}ZLib.prototype.isModuleInit=false;ZLib.prototype.open=function(buf){if(!this.isModuleInit)return false;if(this.engine)this.close();if(!buf)return false;var arrayBuffer=undefined!==buf.byteLength?new Uint8Array(buf):buf;var FileRawDataSize=arrayBuffer.length;var FileRawData=Module["_Zlib_Malloc"](FileRawDataSize);if(0==FileRawData)return false;Module["HEAP8"].set(arrayBuffer,FileRawData);this.engine=Module["_Zlib_Open"](FileRawData,FileRawDataSize);if(0==
+this.engine){Module["_Zlib_Free"](FileRawData);return false}var pointer=Module["_Zlib_GetPaths"](this.engine);if(0==pointer){Module["_Zlib_Close"](this.engine);Module["_Zlib_Free"](FileRawData);return false}var lenArray=new Int32Array(Module["HEAP8"].buffer,pointer,4);var len=lenArray[0];len-=4;var buffer=new Uint8Array(Module["HEAP8"].buffer,pointer+4,len);var index=0;while(index0)return new Uint8Array(Module["HEAP8"].buffer,
+this.files[path].p,this.files[path].l);else{var _lenFile=new Int32Array(Module["HEAP8"].buffer,this.files[path].p,4);var len=_lenFile[0];return new Uint8Array(Module["HEAP8"].buffer,this.files[path].p+4,len)}var tmp=path.toUtf8();var pointer=Module["_Zlib_Malloc"](tmp.length);if(0==pointer)return null;Module["HEAP8"].set(tmp,pointer);var pointerFile=Module["_Zlib_GetFile"](this.engine,pointer);if(0==pointerFile){Module["_Zlib_Free"](pointer);return null}var _lenFile=new Int32Array(Module["HEAP8"].buffer,
+pointerFile,4);var len=_lenFile[0];Module["_Zlib_Free"](pointer);this.files[path]={p:pointerFile,l:0};return new Uint8Array(Module["HEAP8"].buffer,pointerFile+4,len)};ZLib.prototype.addFile=function(path,data){if(!this.isModuleInit||!this.engine)return false;if(!data)return false;if(undefined!==this.files[path])this.removeFile(path);var tmp=path.toUtf8();var pointer=Module["_Zlib_Malloc"](tmp.length);if(0==pointer)return false;Module["HEAP8"].set(tmp,pointer);var arrayBuffer=undefined!==data.byteLength?
+new Uint8Array(data):data;var FileRawDataSize=arrayBuffer.length;var FileRawData=Module["_Zlib_Malloc"](FileRawDataSize);if(0==FileRawData){Module["_Zlib_Free"](pointer);return false}Module["HEAP8"].set(arrayBuffer,FileRawData);Module["_Zlib_AddFile"](this.engine,pointer,FileRawData,FileRawDataSize);this.files[path]={p:FileRawData,l:FileRawDataSize};Module["_Zlib_Free"](pointer);return true};ZLib.prototype.removeFile=function(path){if(!this.isModuleInit||!this.engine)return false;if(undefined===this.files[path])return false;
+var tmp=path.toUtf8();var pointer=Module["_Zlib_Malloc"](tmp.length);if(0==pointer)return false;Module["HEAP8"].set(tmp,pointer);Module["_Zlib_RemoveFile"](this.engine,pointer);if(this.files[path]&&this.files[path].p){Module["_Zlib_Free"](this.files[path].p);delete this.files[path]}Module["_Zlib_Free"](pointer);return true};ZLib.prototype.close=function(){if(!this.isModuleInit||!this.engine)return;for(var i in this.files)if(this.files[i]&&this.files[i].p)Module["_Zlib_Free"](this.files[i].p);this.files=
+{};if(this.engine)Module["_Zlib_Free"](this.engine);this.engine=0};ZLib.prototype.getImageType=function(path){var fileData=this.getFile(path);return Module["_Image_GetFormat"](this.files[path].p+4,fileData.length)};ZLib.prototype.getImageAsFormat=function(path,format){var fileData=this.getFile(path);var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,format);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);
+var copyData=new Uint8Array(encodedSize);copyData.set(new Uint8Array(Module["HEAP8"].buffer,encodedBuffer,encodedSize));Module["_Raster_DestroyEncodedData"](encodedData);return copyData};ZLib.prototype.getImageAsSvg=function(path){var fileData=this.getFile(path);var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,24);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);var string=String.prototype.fromUtf8(new Uint8Array(Module["HEAP8"].buffer,
+encodedBuffer,encodedSize));Module["_Raster_DestroyEncodedData"](encodedData);return string};ZLib.prototype.getImageBuffer=function(path){var result={type:0,data:null};result.type=this.getImageType(path);if(result.type===0)return null;var fileData=this.getFile(path);result.data=new Uint8Array(fileData.length);result.data.set(fileData);if(result.type!=10&&result.type!=21)return result;result.type=24;var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,24);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);
+var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);var fileDataEnc=new Uint8Array(Module["HEAP8"].buffer,encodedBuffer,encodedSize);result.dataBlob=new Uint8Array(fileDataEnc.length);result.dataBlob.set(fileDataEnc);Module["_Raster_DestroyEncodedData"](encodedData);return result};ZLib.prototype.getImageBlob=function(path){var imageType=this.getImageType(path);if(imageType!=10&&imageType!=21)return new Blob([this.getFile(path)],{type:AscCommon.openXml.GetMimeType(AscCommon.GetFileExtension(path))});
+var fileData=this.getFile(path);var encodedData=Module["_Raster_Encode"](this.files[path].p+4,fileData.length,24);var encodedSize=Module["_Raster_GetEncodedSize"](encodedData);var encodedBuffer=Module["_Raster_GetEncodedBuffer"](encodedData);var blob=new Blob([new Uint8Array(Module["HEAP8"].buffer,encodedBuffer,encodedSize)],{type:AscCommon.openXml.GetMimeType("svg")});Module["_Raster_DestroyEncodedData"](encodedData);return blob};window.AscCommon=window.AscCommon||{};window.AscCommon.CZLibEngineJS=
+ZLib;var hyphenApplication=0;AscFonts.Hyphen_Init=function(){hyphenApplication=Module["_hyphenCreateApplication"]()};AscFonts.Hyphen_Destroy=function(){Module["_hyphenDestroyApplication"](hyphenApplication)};AscFonts.Hyphen_CheckDictionary=function(lang){return false};AscFonts.Hyphen_LoadDictionary=function(lang,data){var dictSize=data.byteLength;var dictPointer=Module["_malloc"](dictSize);Module["HEAP8"].set(new Uint8ClampedArray(data),dictPointer);var result=Module["_hyphenLoadDictionary"](hyphenApplication,
+lang,dictPointer,dictSize);Module["_free"](dictPointer);return result===0?true:false};AscFonts.Hyphen_Word=function(lang,word){var wordPointer=word.toUtf8Pointer(true);var wordLen=wordPointer.length;var hyphens=[];if(wordPointer){var ptr=Module._hyphenWord(hyphenApplication,lang,wordPointer.ptr,wordLen);var vector=new Uint8ClampedArray(Module["HEAP8"].buffer,ptr,wordLen+5);var pos=0;while(vector[pos]!=0){if(1===(vector[pos]&1))hyphens.push(pos+1);pos++}wordPointer.free()}return hyphens};if(window["NATIVE_EDITOR_ENJINE"])window.immediateRun();
+AscFonts.onLoadModule()})(window,undefined);
diff --git a/common/libfont/engine/fonts.wasm b/common/libfont/engine/fonts.wasm
index 252e86dee0..f6c3e42a4e 100644
Binary files a/common/libfont/engine/fonts.wasm and b/common/libfont/engine/fonts.wasm differ
diff --git a/common/libfont/engine/fonts_ie.js b/common/libfont/engine/fonts_ie.js
index d29d839e9f..f8ed788f9a 100644
--- a/common/libfont/engine/fonts_ie.js
+++ b/common/libfont/engine/fonts_ie.js
@@ -29,1019 +29,11265 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
-
-(function(window, undefined) {
-
-var AscFonts = window['AscFonts'];
-
-if (window["NATIVE_EDITOR_ENJINE"])
- window.setImmediate = function(fn) { fn(); };
-
-var setImmediate = window.setImmediate;
-
-// correct fetch for desktop application
-
-var printErr = undefined;
-var print = undefined;
-
-var fetch = ("undefined" !== typeof window) ? window.fetch : (("undefined" !== typeof self) ? self.fetch : null);
-var getBinaryPromise = null;
-
-function internal_isLocal()
-{
- if (window.navigator && window.navigator.userAgent.toLowerCase().indexOf("ascdesktopeditor") < 0)
- return false;
- if (window.location && window.location.protocol == "file:")
- return true;
- if (window.document && window.document.currentScript && 0 == window.document.currentScript.src.indexOf("file:///"))
- return true;
- return false;
-}
-
-if (internal_isLocal())
-{
- fetch = undefined; // fetch not support file:/// scheme
- getBinaryPromise = function()
- {
- var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8);
- return new Promise(function (resolve, reject)
- {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', wasmPath, true);
- xhr.responseType = 'arraybuffer';
-
- if (xhr.overrideMimeType)
- xhr.overrideMimeType('text/plain; charset=x-user-defined');
- else
- xhr.setRequestHeader('Accept-Charset', 'x-user-defined');
-
- xhr.onload = function ()
- {
- if (this.status == 200)
- resolve(new Uint8Array(this.response));
- };
- xhr.send(null);
- });
- }
-}
-else
-{
- getBinaryPromise = function() { return getBinaryPromise2(); }
-}
-
-
-var ob;function pb(h){var f=0;return function(){return fh&&(h=Math.max(0,Ka+h));if(null==Za||Za>Ka)Za=Ka;Za=Number(Za);0>Za&&(Za=Math.max(0,Ka+Za));for(h=Number(h||0);hf||1342177279>>=1)h+=h;return Za}});
-Gd("Number.isFinite",function(h){return h?h:function(f){return"number"!==typeof f?!1:!isNaN(f)&&Infinity!==f&&-Infinity!==f}});Gd("Number.isInteger",function(h){return h?h:function(f){return Number.isFinite(f)?f===Math.floor(f):!1}});Gd("String.prototype.endsWith",function(h){return h?h:function(f,h){var Ka=Hd(this,f,"endsWith");f+="";void 0===h&&(h=Ka.length);h=Math.max(0,Math.min(h|0,Ka.length));for(var bb=f.length;0=bb}});
-Gd("String.prototype.padStart",function(h){return h?h:function(f,h){var Ka=Hd(this,null,"padStart");f-=Ka.length;h=void 0!==h?String(h):" ";return(0=gb}});Gd("Object.is",function(h){return h?h:function(f,h){return f===h?0!==f||1/f===1/h:f!==f&&h!==h}});
-Gd("Array.prototype.includes",function(h){return h?h:function(f,h){var Ka=this;Ka instanceof String&&(Ka=String(Ka));var bb=Ka.length;h=h||0;for(0>h&&(h=Math.max(h+bb,0));hf?-h:h}});Gd("Math.log1p",function(h){return h?h:function(f){f=Number(f);if(.25>f&&-.25f&&-.25f?-h:h}});Gd("Math.log10",function(h){return h?h:function(f){return Math.log(f)/Math.LN10}});Gd("Math.cosh",function(h){if(h)return h;var f=Math.exp;return function(h){h=Number(h);return(f(h)+f(-h))/2}});Gd("Math.sinh",function(h){if(h)return h;var f=Math.exp;return function(h){h=Number(h);return 0===h?h:(f(h)-f(-h))/2}});
-Gd("Math.acosh",function(h){return h?h:function(f){f=Number(f);return Math.log(f+Math.sqrt(f*f-1))}});Gd("Math.atanh",function(h){if(h)return h;var f=Math.log1p;return function(h){h=Number(h);return(f(h)-f(-h))/2}});Gd("Math.asinh",function(h){return h?h:function(f){f=Number(f);if(0===f)return f;var h=Math.log(Math.abs(f)+Math.sqrt(f*f+1));return 0>f?-h:h}});Gd("Array.prototype.findIndex",function(h){return h?h:function(f,h){return Fw(this,f,h).dn}});
-
-Math.imul = Math.imul || function(a, b) {
- var ah = (a >>> 16) & 0xffff;
- var al = a & 0xffff;
- var bh = (b >>> 16) & 0xffff;
- var bl = b & 0xffff;
- // сдвиг на 0 бит закрепляет знак в старшей части числа
- // окончательный |0 преобразует беззнаковое значение обратно в знаковое значение
- return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
-};
-
-Math.fround = Math.fround || function(x) {
- return new Float32Array([x])[0];
-};
-
-Math.clz32 = Math.clz32 || function(value) {
- value = Number(value) >>> 0;
- return value !== 0 ? 31 - Math.floor(Math.log(value + 0.5) / Math.log(2)) : 32;
-};
-
-Uint8Array.prototype.copyWithin = Uint8Array.prototype.copyWithin || function(target, start, end) {
- var tmpArray = this.subarray(start, end);
- this.set(tmpArray, target);
- return this;
-};
-
-
-(function(){
-
- if (undefined !== String.prototype.fromUtf8 &&
- undefined !== String.prototype.toUtf8)
- return;
-
- var STRING_UTF8_BUFFER_LENGTH = 1024;
- var STRING_UTF8_BUFFER = new ArrayBuffer(STRING_UTF8_BUFFER_LENGTH);
-
- /**
- * Read string from utf8
- * @param {Uint8Array} buffer
- * @param {number} [start=0]
- * @param {number} [len]
- * @returns {string}
- */
- String.prototype.fromUtf8 = function(buffer, start, len) {
- if (undefined === start)
- start = 0;
- if (undefined === len)
- len = buffer.length - start;
-
- var result = "";
- var index = start;
- var end = start + len;
- while (index < end)
- {
- var u0 = buffer[index++];
- if (!(u0 & 128))
- {
- result += String.fromCharCode(u0);
- continue;
- }
- var u1 = buffer[index++] & 63;
- if ((u0 & 224) == 192)
- {
- result += String.fromCharCode((u0 & 31) << 6 | u1);
- continue;
- }
- var u2 = buffer[index++] & 63;
- if ((u0 & 240) == 224)
- u0 = (u0 & 15) << 12 | u1 << 6 | u2;
- else
- u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | buffer[index++] & 63;
- if (u0 < 65536)
- result += String.fromCharCode(u0);
- else
- {
- var ch = u0 - 65536;
- result += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
- }
- }
- return result;
- };
-
- /**
- * Convert string to utf8 array
- * @returns {Uint8Array}
- */
- String.prototype.toUtf8 = function(isNoEndNull, isUseBuffer) {
- var inputLen = this.length;
- var testLen = 6 * inputLen + 1;
- var tmpStrings = (isUseBuffer && testLen < STRING_UTF8_BUFFER_LENGTH) ? STRING_UTF8_BUFFER : new ArrayBuffer(testLen);
-
- var code = 0;
- var index = 0;
-
- var outputIndex = 0;
- var outputDataTmp = new Uint8Array(tmpStrings);
- var outputData = outputDataTmp;
-
- while (index < inputLen)
- {
- code = this.charCodeAt(index++);
- if (code >= 0xD800 && code <= 0xDFFF && index < inputLen)
- code = 0x10000 + (((code & 0x3FF) << 10) | (0x03FF & this.charCodeAt(index++)));
-
- if (code < 0x80)
- outputData[outputIndex++] = code;
- else if (code < 0x0800)
- {
- outputData[outputIndex++] = 0xC0 | (code >> 6);
- outputData[outputIndex++] = 0x80 | (code & 0x3F);
- }
- else if (code < 0x10000)
- {
- outputData[outputIndex++] = 0xE0 | (code >> 12);
- outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F);
- outputData[outputIndex++] = 0x80 | (code & 0x3F);
- }
- else if (code < 0x1FFFFF)
- {
- outputData[outputIndex++] = 0xF0 | (code >> 18);
- outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F);
- outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F);
- outputData[outputIndex++] = 0x80 | (code & 0x3F);
- }
- else if (code < 0x3FFFFFF)
- {
- outputData[outputIndex++] = 0xF8 | (code >> 24);
- outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F);
- outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F);
- outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F);
- outputData[outputIndex++] = 0x80 | (code & 0x3F);
- }
- else if (code < 0x7FFFFFFF)
- {
- outputData[outputIndex++] = 0xFC | (code >> 30);
- outputData[outputIndex++] = 0x80 | ((code >> 24) & 0x3F);
- outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F);
- outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F);
- outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F);
- outputData[outputIndex++] = 0x80 | (code & 0x3F);
- }
- }
-
- if (isNoEndNull !== true)
- outputData[outputIndex++] = 0;
-
- return new Uint8Array(tmpStrings, 0, outputIndex);
- };
-
- function StringPointer(pointer, len)
- {
- this.ptr = pointer;
- this.length = len;
- }
- StringPointer.prototype.free = function()
- {
- if (0 !== this.ptr)
- Module["_free"](this.ptr);
- };
-
- String.prototype.toUtf8Pointer = function(isNoEndNull) {
- var tmp = this.toUtf8(isNoEndNull, true);
- var pointer = Module["_malloc"](tmp.length);
- if (0 == pointer)
- return null;
-
- Module["HEAP8"].set(tmp, pointer);
- return new StringPointer(pointer, tmp.length);
- };
-
-})();
-
-
-var Module=typeof Module!="undefined"?Module:{};
-var Promise=function(){function noop(){}function bind(fn,thisArg){return function(){fn.apply(thisArg,arguments)}}function Promise(fn){if(!(this instanceof Promise))throw new TypeError("Promises must be constructed via new");if(typeof fn!="function")throw new TypeError("not a function");this._state=0;this._handled=false;this._value=undefined;this._deferreds=[];doResolve(fn,this)}function handle(self,deferred){while(self._state===3)self=self._value;if(self._state===0){self._deferreds.push(deferred);
-return}self._handled=true;Promise._immediateFn(function(){var cb=self._state===1?deferred.onFulfilled:deferred.onRejected;if(cb===null){(self._state===1?resolve:reject)(deferred.promise,self._value);return}var ret;try{ret=cb(self._value)}catch(e){reject(deferred.promise,e);return}resolve(deferred.promise,ret)})}function resolve(self,newValue){try{if(newValue===self)throw new TypeError("A promise cannot be resolved with itself.");if(newValue&&(typeof newValue=="object"||typeof newValue=="function")){var then=
-newValue.then;if(newValue instanceof Promise){self._state=3;self._value=newValue;finale(self);return}else if(typeof then=="function"){doResolve(bind(then,newValue),self);return}}self._state=1;self._value=newValue;finale(self)}catch(e){reject(self,e)}}function reject(self,newValue){self._state=2;self._value=newValue;finale(self)}function finale(self){if(self._state===2&&self._deferreds.length===0)Promise._immediateFn(function(){if(!self._handled)Promise._unhandledRejectionFn(self._value)});for(var i=
-0,len=self._deferreds.length;i=0;--a){f[48+a]=52+a;f[65+a]=a;f[97+a]=26+a}f[43]=62;f[47]=63;function l(m,n,o){var g,h,a=0,i=n,j=o.length,k=n+(j*3>>2)-(o[j-2]=="=")-(o[j-1]=="=");for(;a>4;if(i>2;if(i>2];a:{b:{c:{d:{e:{f:{g:{h:{i:{if(I[a+212|0]){break i}S=a+236|0;T=a+124|0;R=C- -64|0;N=a+4|0;ba=a+8|0;b=H[e-12>>2];d=b+a|0;c=H[d+12>>2];k=H[d+8>>2];while(1){if(c>>>0<=k>>>0){break i}b=b+ba|0;l=e-12|0;j=0;j:{if(k+1>>>0>=c>>>0){h=0;break j}h=I[k|0]|I[k+1|0]<<8;H[b>>2]=k+2;d=H[l>>2]+N|0;b=d+4|0;c=H[d+8>>2];k=H[d+4>>2]}e=0;if(k+1>>>0>>0){j=I[k|0]|I[k+1|0]<<8;H[b>>2]=k+2;c=H[l>>2]+N|0;b=c+4|0;k=H[c+4>>2];c=H[c+8>>2]}if(k+3>>>0>>0){H[b>>2]=k+4;c=H[l>>2]+N|0;b=c+4|0;k=H[c+4>>2];c=H[c+8>>2]}if(c>>>0>k+3>>>0){e=I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24);H[b>>2]=k+4}H[a+116>>2]=e;c=H[l>>2]+N|0;b=c+4|0;ca=H[c>>2];L=H[c+4>>2];k:{l:{switch(h-16385|0){case 52:F[a+213|0]=1;b=H[l>>2]+N|0;j=b+4|0;z=0;e=H[b+8>>2];k=H[b+4>>2];if(e>>>0<=k+3>>>0){r=0}else{y=(x(2,I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24)),B());H[b+4>>2]=k+4;b=H[l>>2]+N|0;j=b+4|0;e=H[b+8>>2];k=H[b+4>>2];r=+y}if(k+3>>>0>>0){y=(x(2,I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24)),B());H[j>>2]=k+4;z=+y}b=H[a+208>>2];if(!b){break k}zb[H[H[b>>2]+468>>2]](b,r,z);break k;case 48:F[a+213|0]=1;b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}b=H[a+208>>2];if(!b){break k}zb[H[H[b>>2]+472>>2]](b);b=H[a+208>>2];zb[H[H[b>>2]+60>>2]](b);break k;case 50:l=j&65535;F[a+213|0]=1;m:{if(!H[a+208>>2]){break m}c=a+236|0;k=H[c>>2];if(!k){break m}e=l&255;b=c;while(1){d=e>>>0>K[k+16>>2];b=d?b:k;k=H[(d<<2)+k>>2];if(k){continue}break}if((b|0)==(c|0)|e>>>0>2]){break m}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=3){break m}c=H[b+20>>2];if(!c){break m}b=H[a+208>>2];zb[H[H[b>>2]+60>>2]](b);b=H[a+208>>2];ha=b,ja=c+4|0,la=l>>>8&15,ma=zb[H[H[a>>2]+88>>2]](a,2)|0,fa=H[H[b>>2]+72>>2],zb[fa](ha|0,ja|0,la|0,ma|0);b=H[a+208>>2];zb[H[H[b>>2]+476>>2]](b,l<<16>>16,c)}break k;case 49:f=xb-96|0;xb=f;F[a+213|0]=1;b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}c=j&65535;H[f+88>>2]=0;H[f+92>>2]=0;H[f+80>>2]=0;H[f+84>>2]=0;H[f+72>>2]=0;H[f+76>>2]=0;H[f+64>>2]=0;H[f+68>>2]=0;Ae((H[H[a>>2]-12>>2]+a|0)+4|0,f- -64|0);b=H[a+208>>2];if(b){zb[H[H[b>>2]+60>>2]](b);w=M[f+72>>3];M[f+40>>3]=w;r=M[f+64>>3];M[f+48>>3]=r+M[f+80>>3];M[f+56>>3]=w+M[f+88>>3];b=H[f+44>>2];H[f+8>>2]=H[f+40>>2];H[f+12>>2]=b;b=H[f+52>>2];H[f+16>>2]=H[f+48>>2];H[f+20>>2]=b;b=H[f+60>>2];H[f+24>>2]=H[f+56>>2];H[f+28>>2]=b;M[f+32>>3]=r;b=H[f+36>>2];H[f>>2]=H[f+32>>2];H[f+4>>2]=b;e=c>>>8&15;l=xb-32|0;xb=l;H[l+8>>2]=419120;g=l+8|4;H[g+4>>2]=0;H[g+8>>2]=0;H[g+12>>2]=0;H[g>>2]=424816;H[l+8>>2]=419680;H[g>>2]=419704;r=M[f+8>>3];A=M[f>>3];H[197455]=0;xa(1780,g|0,+A,+r)|0;b=H[197455];H[197455]=0;n:{o:{if((b|0)==1){break o}w=M[f+16>>3];H[197455]=0;xa(1781,g|0,+w,+r)|0;b=H[197455];H[197455]=0;if((b|0)==1){break o}r=M[f+24>>3];H[197455]=0;xa(1781,g|0,+w,+r)|0;b=H[197455];H[197455]=0;if((b|0)==1){break o}H[197455]=0;xa(1781,g|0,+A,+r)|0;b=H[197455];H[197455]=0;if((b|0)==1){break o}H[197455]=0;aa(1782,g|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break o}d=H[a+208>>2];if(d){b=H[H[a>>2]+88>>2];H[197455]=0;c=da(b|0,a|0,2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break o}b=H[H[d>>2]+72>>2];H[197455]=0;ka(b|0,d|0,g|0,e|0,c|0);b=H[197455];H[197455]=0;if((b|0)==1){break o}}H[197455]=0;ia(1892,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break o}oe(g);xb=l+32|0;break n}a=$()|0;_()|0;oe(g);ea(a|0);X()}b=H[a+208>>2];zb[H[H[b>>2]+480>>2]](b,e,f- -64|0)}xb=f+96|0;break k;case 51:F[a+213|0]=1;if(!H[a+208>>2]){break k}k=H[S>>2];if(!k){break k}d=j&255;e=S;while(1){b=d>>>0>K[k+16>>2];e=b?e:k;k=H[(b<<2)+k>>2];if(k){continue}break};if((e|0)==(S|0)|d>>>0>2]){break k}b=H[e+20>>2];if((zb[H[H[b>>2]+12>>2]](b)|0)!=4){break k}c=H[e+20>>2];if(!c){break k}b=H[a+208>>2];zb[H[H[b>>2]+60>>2]](b);b=H[a+208>>2];zb[H[H[b>>2]+484>>2]](b,d,j>>>8&15,c);break k;case 2:H[c+4>>2]=e+L;b=H[a+208>>2];if(!b){break k}zb[H[H[b>>2]+488>>2]](b,H[l>>2]+N|0,e);break k;case 1:b=H[a+208>>2];if(!b){G[a+212>>1]=1;break k}zb[H[H[b>>2]+12>>2]](b);G[a+212>>1]=1;b=H[a+208>>2];if(!b){break k}zb[H[H[b>>2]+492>>2]](b);break k;case 3:F[a+213|0]=0;b=H[a+208>>2];if(!b){break k}zb[H[H[b>>2]+496>>2]](b);break k;case 0:f=0;h=0;e=H[a>>2]-12|0;b=H[e>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;d=H[e>>2]+a|0;c=d+8|0;j=H[c>>2];b=H[d+12>>2];if(b>>>0>j+3>>>0){f=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[d+8>>2]=j+4;c=H[e>>2]+a|0;b=H[c+12>>2];c=c+8|0;j=H[c>>2]}if(j+3>>>0>>0){h=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[c>>2]=j+4}H[a+216>>2]=h;j=0;b=H[e>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){j=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}F[a+213|0]=1;H[a+220>>2]=j;b=H[a+208>>2];if(b){zb[H[H[b>>2]+8>>2]](b);b=H[a+208>>2];zb[H[H[b>>2]+500>>2]](b,f,H[a+216>>2],H[a+220>>2])}break k;case 8:j=0;H[C+32>>2]=0;c=H[l>>2]+N|0;e=H[c+4>>2];b=H[c+8>>2];p:{if(e>>>0>=b>>>0){h=0;break p}h=I[e|0];e=e+1|0;H[c+4>>2]=e}F[C+32|0]=h;if(b>>>0>e>>>0){j=I[e|0];e=e+1|0;H[c+4>>2]=e}F[C+33|0]=j;j=0;q:{if(b>>>0<=e>>>0){h=0;break q}h=I[e|0];e=e+1|0;H[c+4>>2]=e}F[C+34|0]=h;if(b>>>0>e>>>0){j=I[e|0];H[c+4>>2]=e+1}F[C+35|0]=j;b=H[a+208>>2];if(b){zb[H[H[b>>2]+504>>2]](b,C+32|0)}F[a+213|0]=1;break k;case 17:r:{if(j&16384){J=0;z=0;D=0;i=xb-32|0;xb=i;d=H[a>>2]-12|0;c=H[d>>2]+a|0;h=c+8|0;f=H[h>>2];b=H[c+12>>2];if(b>>>0<=f+3>>>0){w=0}else{y=(x(2,I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24)),B());H[c+8>>2]=f+4;c=H[d>>2]+a|0;b=H[c+12>>2];h=c+8|0;f=H[h>>2];w=+y}if(f+3>>>0>>0){y=(x(2,I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24)),B());H[h>>2]=f+4;c=H[d>>2]+a|0;b=H[c+12>>2];D=+y;h=c+8|0;f=H[h>>2]}if(f+1>>>0>=b>>>0){A=0}else{c=(I[f|0]|I[f+1|0]<<8)<<16>>16;f=f+2|0;H[h>>2]=f;A=+(c|0)}if(f+1>>>0>>0){c=(I[f|0]|I[f+1|0]<<8)<<16>>16;f=f+2|0;H[h>>2]=f;J=+(c|0)}if(f+1>>>0>=b>>>0){r=0}else{c=(I[f|0]|I[f+1|0]<<8)<<16>>16;f=f+2|0;H[h>>2]=f;r=+(c|0)}if(f+1>>>0>>0){b=(I[f|0]|I[f+1|0]<<8)<<16>>16;H[h>>2]=f+2;z=+(b|0)}g=j&65535;c=a+236|0;f=H[c>>2];s:{if(!f){break s}e=g<<24>>24;b=c;while(1){d=e>>>0>K[f+16>>2];b=d?b:f;f=H[(d<<2)+f>>2];if(f){continue}break}if((b|0)==(c|0)|e>>>0>2]){break s}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break s}b=H[b+20>>2];if(!b){break s}l=b+4|0;H[H[a+120>>2]+12>>2]=l;b=H[H[a+120>>2]+680>>2];M[i+8>>3]=J;M[i>>3]=A;M[i+16>>3]=r;M[i+24>>3]=z;Yp(a,A,J);z=J+z;t:{if(P(z)<2147483648){d=~~z;break t}d=-2147483648}r=A+r;u:{if(P(r)<2147483648){c=~~r;break u}c=-2147483648}r=D+-360;e=(b|0)==1;if(P(J)<2147483648){b=~~J}else{b=-2147483648}r=e?D:r;if(P(A)<2147483648){e=~~A}else{e=-2147483648}Sf(a,e,b,c,d,w,r);Rf(a,1,0,1);b=H[a+208>>2];if(b){zb[H[H[b>>2]+508>>2]](b,g&255,w,r,i)}b=H[a+120>>2];if((l|0)==H[b+12>>2]){H[b+12>>2]=0}}xb=i+32|0;break r}g=j&65535;D=0;f=xb+-64|0;xb=f;H[f+56>>2]=0;H[f+60>>2]=0;H[f+48>>2]=0;H[f+52>>2]=0;H[f+40>>2]=0;H[f+44>>2]=0;H[f+32>>2]=0;H[f+36>>2]=0;e=H[a>>2]-12|0;b=H[e>>2];d=b+a|0;h=d+8|0;j=H[h>>2];c=H[d+12>>2];if(c>>>0<=j+3>>>0){r=0}else{y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[d+8>>2]=j+4;b=H[e>>2];d=b+a|0;c=H[d+12>>2];h=d+8|0;j=H[h>>2];r=+y}if(j+3>>>0>>0){y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[h>>2]=j+4;D=+y;b=H[e>>2]}Ae((a+b|0)+4|0,f+32|0);c=a+236|0;j=H[c>>2];v:{if(!j){break v}e=g<<24>>24;b=c;while(1){d=e>>>0>K[j+16>>2];b=d?b:j;j=H[(d<<2)+j>>2];if(j){continue}break}if((b|0)==(c|0)|e>>>0>2]){break v}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break v}b=H[b+20>>2];if(!b){break v}l=b+4|0;H[H[a+120>>2]+12>>2]=l;b=H[H[a+120>>2]+680>>2];w=M[f+56>>3];M[f+24>>3]=w;A=M[f+48>>3];M[f+16>>3]=A;J=M[f+40>>3];M[f+8>>3]=J;z=M[f+32>>3];M[f>>3]=z;Yp(a,z,J);w=J+w;w:{if(P(w)<2147483648){d=~~w;break w}d=-2147483648}w=z+A;x:{if(P(w)<2147483648){c=~~w;break x}c=-2147483648}w=D+-360;e=(b|0)==1;if(P(J)<2147483648){b=~~J}else{b=-2147483648}w=e?D:w;if(P(z)<2147483648){e=~~z}else{e=-2147483648}Sf(a,e,b,c,d,r,w);Rf(a,1,0,1);b=H[a+208>>2];if(b){zb[H[H[b>>2]+508>>2]](b,g&255,r,w,f)}b=H[a+120>>2];if((l|0)==H[b+12>>2]){H[b+12>>2]=0}}xb=f- -64|0}F[a+213|0]=1;break k;case 24:c=j&65535;y:{if(j&2048){d=xb+-64|0;xb=d;z:{A:{B:{C:{D:{E:{F:{b=H[H[a>>2]-12>>2]+a|0;e=H[b+8>>2];G:{if(e+3>>>0>=K[b+12>>2]){break G}t=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[b+8>>2]=e+4;if(t>>>0<3){break G}H[d+40>>2]=0;H[d+32>>2]=0;H[d+36>>2]=0;if((t|0)<0){H[197455]=0;ia(1867,d+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break h}break z}H[197455]=0;q=aa(899,t|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break h}b=a+236|0;h=H[b>>2];H:{if(!h){break H}s=c&255;e=b;while(1){c=s>>>0>K[h+16>>2];e=c?e:h;h=H[(c<<2)+h>>2];if(h){continue}break}if((b|0)==(e|0)|s>>>0>2]){break H}c=H[e+20>>2];b=H[H[c>>2]+12>>2];H[197455]=0;c=aa(b|0,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break E}if((c|0)!=2){break H}c=H[e+20>>2];if(!c){break H}b=H[a+120>>2];H[197455]=0;i=c+4|0;H[b+12>>2]=i;b=H[197455];H[197455]=0;if((b|0)==1){break E}H[d+8>>2]=0;H[d>>2]=0;H[d+4>>2]=0;I:{if((q|0)==(q+t|0)){o=0;H[d+24>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0;break I}J:{K:{if((t|0)<0){H[197455]=0;ia(1867,d|0);a=H[197455];H[197455]=0;if((a|0)!=1){break z}break K}H[197455]=0;c=aa(899,t|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break J}}h=$()|0;_()|0;a=H[d>>2];if(!a){break A}H[d+4>>2]=a;Kb(a);break A}H[d>>2]=c;H[d+8>>2]=c+t;p=Ob(c,q,t);H[d+56>>2]=0;H[d+48>>2]=0;H[d+52>>2]=0;if(t>>>0>=268435456){H[197455]=0;ia(1869,d+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break z}break B}H[197455]=0;c=t<<4;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break B}h=c+o|0;L:{if(t>>>0<2){break L}e=1;b=t-1|0;g=b&1;if((t|0)!=2){l=b&-2;f=0;while(1){b=(e<<4)+o|0;n=b-16|0;m=H[n+4>>2];c=H[n>>2];H[b+16>>2]=c;H[b+20>>2]=m;H[b>>2]=c;H[b+4>>2]=m;m=H[n+12>>2];c=H[n+8>>2];H[b+24>>2]=c;H[b+28>>2]=m;H[b+8>>2]=c;H[b+12>>2]=m;e=e+2|0;f=f+2|0;if((l|0)!=(f|0)){continue}break}}if(!g){break L}e=(e<<4)+o|0;c=e-16|0;b=H[c+4>>2];H[e>>2]=H[c>>2];H[e+4>>2]=b;b=H[c+12>>2];H[e+8>>2]=H[c+8>>2];H[e+12>>2]=b}H[d+24>>2]=h;H[d+20>>2]=h;H[d+16>>2]=o;H[d+4>>2]=p;Kb(p)}w=M[o+8>>3];r=M[o>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;e=1;if((b|0)==1){break F}if(t>>>0>1){while(1){b=(e<<4)+o|0;D=M[b+16>>3];J=M[b+24>>3];z=M[b+32>>3];A=M[b+40>>3];w=M[b>>3];r=M[b+8>>3];H[197455]=0;if(P(r)<2147483648){c=~~r}else{c=-2147483648}if(P(w)<2147483648){b=~~w}else{b=-2147483648}if(P(A)<2147483648){f=~~A}else{f=-2147483648}if(P(z)<2147483648){g=~~z}else{g=-2147483648}if(P(J)<2147483648){l=~~J}else{l=-2147483648}if(P(D)<2147483648){h=~~D}else{h=-2147483648}ua(1871,a|0,b|0,c|0,h|0,l|0,g|0,f|0);b=H[197455];H[197455]=0;if((b|0)==1){break D}e=e+3|0;if(t>>>0>e>>>0){continue}break}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break F}c=H[a+208>>2];if(c){b=H[H[c>>2]+512>>2];H[197455]=0;ga(b|0,c|0,s|0,d+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break F}}b=H[a+120>>2];H[197455]=0;if((i|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break F}b=H[d+16>>2];if(!b){break H}H[d+20>>2]=b;Kb(b)}Kb(q)}xb=d- -64|0;break y}h=$()|0;_()|0;o=H[d+16>>2];if(!o){break A}break C}h=$()|0;_()|0;break A}h=$()|0;_()|0}H[d+20>>2]=o;Kb(o);break A}h=$()|0;_()|0;a=H[d+48>>2];if(a){H[d+52>>2]=a;Kb(a)}H[d+4>>2]=p;Kb(p)}Kb(q);ea(h|0);X()}X()}if(c&16384){c=j&65535;q=xb+-64|0;xb=q;M:{N:{O:{P:{Q:{R:{l=H[a>>2]-12|0;b=H[l>>2]+a|0;d=H[b+8>>2];S:{if(d+3>>>0>=K[b+12>>2]){break S}m=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[b+8>>2]=d+4;if(m>>>0<3){break S}H[q+40>>2]=0;H[q+32>>2]=0;H[q+36>>2]=0;T:{U:{if(m>>>0>=1073741824){H[197455]=0;ia(1808,q+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break U}break M}H[197455]=0;e=m<<2;g=aa(899,e|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break T}}a=$()|0;_()|0;b=H[q+32>>2];if(b){H[q+36>>2]=b;Kb(b)}break d}n=c&255;H[q+32>>2]=g;i=e+g|0;H[q+40>>2]=i;d=0;p=Nb(g,0,e);H[q+36>>2]=i;c=a+4|0;while(1){g=p+(d<<2)|0;f=c+H[l>>2]|0;o=H[f+4>>2];b=H[f+8>>2];V:{if(o+1>>>0>=b>>>0){e=0;break V}e=I[o|0]|I[o+1|0]<<8;o=o+2|0;H[f+4>>2]=o}G[g>>1]=e;e=0;if(b>>>0>o+1>>>0){e=I[o|0]|I[o+1|0]<<8;H[f+4>>2]=o+2}G[g+2>>1]=e;d=d+1|0;if((m|0)!=(d|0)){continue}break}c=a+236|0;d=H[c>>2];W:{if(!d){break W}b=c;while(1){e=n>>>0>K[d+16>>2];b=e?b:d;d=H[(e<<2)+d>>2];if(d){continue}break}if((b|0)==(c|0)|n>>>0>2]){break W}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;X:{if((c|0)!=1){if((d|0)!=2){break W}c=H[b+20>>2];if(!c){break W}b=H[a+120>>2];H[197455]=0;f=c+4|0;H[b+12>>2]=f;b=H[197455];H[197455]=0;if((b|0)!=1){break X}}d=$()|0;_()|0;break N}H[q+8>>2]=0;H[q>>2]=0;H[q+4>>2]=0;s=i-p|0;m=s>>2;Y:{if((i|0)==(p|0)){h=0;H[q+24>>2]=0;H[q+16>>2]=0;H[q+20>>2]=0;break Y}Z:{_:{if((s|0)<0){H[197455]=0;ia(1808,q|0);a=H[197455];H[197455]=0;if((a|0)!=1){break M}break _}H[197455]=0;c=aa(899,s|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Z}}d=$()|0;_()|0;a=H[q>>2];if(!a){break N}H[q+4>>2]=a;Kb(a);break N}H[q>>2]=c;H[q+8>>2]=c+(m<<2);i=Ob(c,p,s);$:{if(s){H[q+56>>2]=0;H[q+48>>2]=0;H[q+52>>2]=0;c=(i+s|0)-i|0;if(c>>>0>=1073741821){H[197455]=0;ia(1869,q+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break M}break O}H[197455]=0;h=aa(899,c<<2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break O}g=c>>2;b=g>>>0>1?g:1;l=b&1;d=0;if(c>>>0>=8){e=b&-2;o=0;while(1){c=(d<<4)+h|0;b=i+(d<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];b=d|1;c=(b<<4)+h|0;b=i+(b<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];d=d+2|0;o=o+2|0;if((e|0)!=(o|0)){continue}break}}if(l){c=(d<<4)+h|0;b=i+(d<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1]}H[q+16>>2]=h;b=(g<<4)+h|0;H[q+24>>2]=b;H[q+20>>2]=b;break $}h=0;H[q+24>>2]=0;H[q+16>>2]=0;H[q+20>>2]=0}H[q+4>>2]=i;Kb(i)}w=M[h+8>>3];r=M[h>>3];H[197455]=0;ta(1870,a|0,+r,+w);c=H[197455];H[197455]=0;b=1;if((c|0)==1){break R}if(s>>>0>4){while(1){c=(b<<4)+h|0;D=M[c+16>>3];J=M[c+24>>3];z=M[c+32>>3];A=M[c+40>>3];w=M[c>>3];r=M[c+8>>3];H[197455]=0;if(P(r)<2147483648){d=~~r}else{d=-2147483648}if(P(w)<2147483648){c=~~w}else{c=-2147483648}if(P(A)<2147483648){g=~~A}else{g=-2147483648}if(P(z)<2147483648){l=~~z}else{l=-2147483648}if(P(J)<2147483648){e=~~J}else{e=-2147483648}if(P(D)<2147483648){i=~~D}else{i=-2147483648}ua(1871,a|0,c|0,d|0,i|0,e|0,l|0,g|0);c=H[197455];H[197455]=0;if((c|0)==1){break Q}b=b+3|0;if(m>>>0>b>>>0){continue}break}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break R}c=H[a+208>>2];if(c){b=H[H[c>>2]+512>>2];H[197455]=0;ga(b|0,c|0,n|0,q+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break R}}b=H[a+120>>2];H[197455]=0;if((f|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break R}b=H[q+16>>2];if(!b){break W}H[q+20>>2]=b;Kb(b)}Kb(p)}xb=q- -64|0;break y}d=$()|0;_()|0;h=H[q+16>>2];if(!h){break N}break P}d=$()|0;_()|0}H[q+20>>2]=h;Kb(h);break N}d=$()|0;_()|0;a=H[q+48>>2];if(a){H[q+52>>2]=a;Kb(a)}H[q+4>>2]=i;Kb(i)}Kb(p);ea(d|0);X()}X()}d=j&65535;u=xb+-64|0;xb=u;aa:{ba:{ca:{da:{ea:{fa:{ga:{g=H[a>>2]-12|0;b=H[g>>2]+a|0;c=H[b+8>>2];ha:{if(c+3>>>0>=K[b+12>>2]){break ha}i=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4;if(i>>>0<3){break ha}H[u+40>>2]=0;H[u+32>>2]=0;H[u+36>>2]=0;ia:{ja:{if(i>>>0>=268435456){H[197455]=0;ia(1869,u+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break ja}break ba}H[197455]=0;c=i<<4;t=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break ia}}a=$()|0;_()|0;b=H[u+32>>2];if(b){H[u+36>>2]=b;Kb(b)}break d}s=d&255;H[u+32>>2]=t;m=c+t|0;H[u+40>>2]=m;H[u+36>>2]=m;d=a+4|0;l=0;while(1){b=t+(l<<4)|0;f=d+H[g>>2]|0;e=H[f+4>>2];c=H[f+8>>2];if(e+3>>>0>=c>>>0){r=0}else{y=(x(2,I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24)),B());e=e+4|0;H[f+4>>2]=e;r=+y}M[b>>3]=r;if(c>>>0>e+3>>>0){y=(x(2,I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24)),B());H[f+4>>2]=e+4;r=+y}else{r=0}M[b+8>>3]=r;l=l+1|0;if((i|0)!=(l|0)){continue}break}c=a+236|0;l=H[c>>2];ka:{if(!l){break ka}b=c;while(1){d=s>>>0>K[l+16>>2];b=d?b:l;l=H[(d<<2)+l>>2];if(l){continue}break}if((b|0)==(c|0)|s>>>0>2]){break ka}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;la:{if((c|0)!=1){if((d|0)!=2){break ka}c=H[b+20>>2];if(!c){break ka}b=H[a+120>>2];H[197455]=0;i=c+4|0;H[b+12>>2]=i;b=H[197455];H[197455]=0;if((b|0)!=1){break la}}l=$()|0;_()|0;break ca}H[u+8>>2]=0;H[u>>2]=0;H[u+4>>2]=0;q=m-t|0;h=q>>4;ma:{if((m|0)==(t|0)){b=0;H[u+24>>2]=0;H[u+16>>2]=0;H[u+20>>2]=0;break ma}na:{oa:{if((q|0)<0){H[197455]=0;ia(1869,u|0);a=H[197455];H[197455]=0;if((a|0)!=1){break ba}break oa}H[197455]=0;c=aa(899,q|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break na}}l=$()|0;_()|0;a=H[u>>2];if(!a){break ca}H[u+4>>2]=a;Kb(a);break ca}H[u>>2]=c;H[u+8>>2]=c+(h<<4);v=Ob(c,t,q);pa:{if(q){H[u+56>>2]=0;H[u+48>>2]=0;H[u+52>>2]=0;d=(q+v|0)-v|0;if((d|0)<0){H[197455]=0;ia(1869,u+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break ba}break da}H[197455]=0;b=aa(899,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break da}m=d>>4;c=m>>>0>1?m:1;g=c&3;k=0;l=0;if(c-1>>>0>=3){e=c&-4;f=0;while(1){p=l<<4;d=p+b|0;n=p+v|0;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=p|16;d=c+b|0;n=c+v|0;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;c=p|32;d=c+b|0;n=c+v|0;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;c=p|48;d=c+b|0;n=c+v|0;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;l=l+4|0;f=f+4|0;if((e|0)!=(f|0)){continue}break}}if(g){while(1){c=l<<4;d=c+b|0;e=c+v|0;c=H[e+4>>2];H[d>>2]=H[e>>2];H[d+4>>2]=c;c=H[e+12>>2];H[d+8>>2]=H[e+8>>2];H[d+12>>2]=c;l=l+1|0;k=k+1|0;if((g|0)!=(k|0)){continue}break}}H[u+16>>2]=b;c=(m<<4)+b|0;H[u+24>>2]=c;H[u+20>>2]=c;break pa}b=0;H[u+24>>2]=0;H[u+16>>2]=0;H[u+20>>2]=0}H[u+4>>2]=v;Kb(v)}w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1870,a|0,+r,+w);c=H[197455];H[197455]=0;e=1;if((c|0)==1){break ga}if(q>>>0>16){while(1){c=(e<<4)+b|0;D=M[c+16>>3];J=M[c+24>>3];z=M[c+32>>3];A=M[c+40>>3];w=M[c>>3];r=M[c+8>>3];H[197455]=0;if(P(r)<2147483648){d=~~r}else{d=-2147483648}if(P(w)<2147483648){c=~~w}else{c=-2147483648}if(P(A)<2147483648){f=~~A}else{f=-2147483648}if(P(z)<2147483648){g=~~z}else{g=-2147483648}if(P(J)<2147483648){l=~~J}else{l=-2147483648}if(P(D)<2147483648){m=~~D}else{m=-2147483648}ua(1871,a|0,c|0,d|0,m|0,l|0,g|0,f|0);c=H[197455];H[197455]=0;if((c|0)==1){break fa}e=e+3|0;if(h>>>0>e>>>0){continue}break}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break ga}c=H[a+208>>2];if(c){b=H[H[c>>2]+512>>2];H[197455]=0;ga(b|0,c|0,s|0,u+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break ga}}b=H[a+120>>2];H[197455]=0;if((i|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break ga}b=H[u+16>>2];if(!b){break ka}H[u+20>>2]=b;Kb(b)}Kb(t)}xb=u- -64|0;break aa}l=$()|0;_()|0;b=H[u+16>>2];if(!b){break ca}break ea}l=$()|0;_()|0}H[u+20>>2]=b;Kb(b);break ca}l=$()|0;_()|0;a=H[u+48>>2];if(a){H[u+52>>2]=a;Kb(a)}H[u+4>>2]=v;Kb(v)}Kb(t);break c}X()}}F[a+213|0]=1;break k;case 22:l=j&65535;qa:{if(j&2048){d=xb+-64|0;xb=d;b=H[a>>2]-12|0;e=H[b>>2]+a|0;c=e+8|0;f=H[c>>2];u=H[e+12>>2];if(u>>>0<=f+3>>>0){r=0}else{y=(x(2,I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24)),B());H[e+8>>2]=f+4;b=H[b>>2]+a|0;u=H[b+12>>2];c=b+8|0;f=H[c>>2];r=+y}ra:{sa:{ta:{ua:{va:{wa:{xa:{ya:{if(f+3>>>0>=u>>>0){break ya}q=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[c>>2]=f+4;if(q>>>0<3){break ya}H[d+40>>2]=0;H[d+32>>2]=0;H[d+36>>2]=0;if((q|0)<0){H[197455]=0;ia(1867,d+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break h}break ra}H[197455]=0;p=aa(899,q|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break h}b=a+236|0;f=H[b>>2];za:{if(!f){break za}n=l&255;c=b;while(1){e=n>>>0>K[f+16>>2];c=e?c:f;f=H[(e<<2)+f>>2];if(f){continue}break}if((b|0)==(c|0)|n>>>0>2]){break za}e=H[c+20>>2];b=H[H[e>>2]+12>>2];H[197455]=0;e=aa(b|0,e|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break wa}if((e|0)!=2){break za}c=H[c+20>>2];if(!c){break za}b=H[a+120>>2];H[197455]=0;i=c+4|0;H[b+12>>2]=i;b=H[197455];H[197455]=0;if((b|0)==1){break wa}H[d+8>>2]=0;H[d>>2]=0;H[d+4>>2]=0;Aa:{if((p|0)==(q+p|0)){o=0;H[d+24>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0;break Aa}Ba:{Ca:{if((q|0)<0){H[197455]=0;ia(1867,d|0);a=H[197455];H[197455]=0;if((a|0)!=1){break ra}break Ca}H[197455]=0;c=aa(899,q|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Ba}}f=$()|0;_()|0;a=H[d>>2];if(!a){break sa}H[d+4>>2]=a;Kb(a);break sa}H[d>>2]=c;H[d+8>>2]=c+q;s=Ob(c,p,q);H[d+56>>2]=0;H[d+48>>2]=0;H[d+52>>2]=0;if(q>>>0>=268435456){H[197455]=0;ia(1869,d+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break ra}break ta}H[197455]=0;c=q<<4;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break ta}m=c+o|0;Da:{if(q>>>0<2){break Da}c=1;b=q-1|0;g=b&1;if((q|0)!=2){l=b&-2;u=0;while(1){b=(c<<4)+o|0;h=b-16|0;f=H[h+4>>2];e=H[h>>2];H[b+16>>2]=e;H[b+20>>2]=f;H[b>>2]=e;H[b+4>>2]=f;f=H[h+12>>2];e=H[h+8>>2];H[b+24>>2]=e;H[b+28>>2]=f;H[b+8>>2]=e;H[b+12>>2]=f;c=c+2|0;u=u+2|0;if((l|0)!=(u|0)){continue}break}}if(!g){break Da}e=(c<<4)+o|0;c=e-16|0;b=H[c+4>>2];H[e>>2]=H[c>>2];H[e+4>>2]=b;b=H[c+12>>2];H[e+8>>2]=H[c+8>>2];H[e+12>>2]=b}H[d+24>>2]=m;H[d+20>>2]=m;H[d+16>>2]=o;H[d+4>>2]=s;Kb(s)}A=M[o+8>>3];w=M[o>>3];H[197455]=0;ta(1870,a|0,+w,+A);b=H[197455];H[197455]=0;c=1;if((b|0)==1){break xa}if(q>>>0>1){while(1){b=(c<<4)+o|0;Q=M[b+16>>3];D=M[b+24>>3];J=M[b+32>>3];z=M[b+40>>3];A=M[b>>3];w=M[b+8>>3];H[197455]=0;if(P(w)<2147483648){e=~~w}else{e=-2147483648}if(P(A)<2147483648){b=~~A}else{b=-2147483648}if(P(z)<2147483648){f=~~z}else{f=-2147483648}if(P(J)<2147483648){g=~~J}else{g=-2147483648}if(P(D)<2147483648){l=~~D}else{l=-2147483648}if(P(Q)<2147483648){h=~~Q}else{h=-2147483648}ua(1871,a|0,b|0,e|0,h|0,l|0,g|0,f|0);b=H[197455];H[197455]=0;if((b|0)==1){break va}c=c+3|0;if(q>>>0>c>>>0){continue}break}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break xa}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break xa}c=H[a+208>>2];if(c){b=H[H[c>>2]+516>>2];H[197455]=0;Pa(b|0,c|0,n|0,+r,d+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break xa}}b=H[a+120>>2];H[197455]=0;if((i|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break xa}b=H[d+16>>2];if(!b){break za}H[d+20>>2]=b;Kb(b)}Kb(p)}xb=d- -64|0;break qa}f=$()|0;_()|0;o=H[d+16>>2];if(!o){break sa}break ua}f=$()|0;_()|0;break sa}f=$()|0;_()|0}H[d+20>>2]=o;Kb(o);break sa}f=$()|0;_()|0;a=H[d+48>>2];if(a){H[d+52>>2]=a;Kb(a)}H[d+4>>2]=s;Kb(s)}Kb(p);break a}X()}if(l&16384){c=j&65535;d=xb+-64|0;xb=d;l=H[a>>2]-12|0;e=H[l>>2]+a|0;b=e+8|0;h=H[b>>2];o=H[e+12>>2];if(o>>>0<=h+3>>>0){r=0}else{y=(x(2,I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24)),B());H[e+8>>2]=h+4;b=H[l>>2]+a|0;o=H[b+12>>2];b=b+8|0;h=H[b>>2];r=+y}Ea:{Fa:{Ga:{Ha:{Ia:{Ja:{Ka:{if(h+3>>>0>=o>>>0){break Ka}s=I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24);H[b>>2]=h+4;if(s>>>0<3){break Ka}H[d+40>>2]=0;H[d+32>>2]=0;H[d+36>>2]=0;if(s>>>0>=1073741824){H[197455]=0;ia(1808,d+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break h}break Ea}H[197455]=0;e=s<<2;g=aa(899,e|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break h}n=c&255;H[d+32>>2]=g;f=e+g|0;H[d+40>>2]=f;m=0;p=Nb(g,0,e);H[d+36>>2]=f;e=a+4|0;while(1){g=e+H[l>>2]|0;b=H[g+4>>2];c=H[g+8>>2];La:{if(b+1>>>0>=c>>>0){o=0;break La}o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[g+4>>2]=b}G[p>>1]=o;o=0;if(c>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;H[g+4>>2]=b+2}G[p+2>>1]=o;m=m+1|0;if((s|0)!=(m|0)){continue}break}c=a+236|0;h=H[c>>2];Ma:{if(!h){break Ma}b=c;while(1){e=n>>>0>K[h+16>>2];b=e?b:h;h=H[(e<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|n>>>0>2]){break Ma}e=H[b+20>>2];c=H[H[e>>2]+12>>2];H[197455]=0;e=aa(c|0,e|0)|0;c=H[197455];H[197455]=0;Na:{if((c|0)!=1){if((e|0)!=2){break Ma}c=H[b+20>>2];if(!c){break Ma}b=H[a+120>>2];H[197455]=0;i=c+4|0;H[b+12>>2]=i;b=H[197455];H[197455]=0;if((b|0)!=1){break Na}}h=$()|0;_()|0;break Fa}H[d+8>>2]=0;H[d>>2]=0;H[d+4>>2]=0;Oa:{if((f|0)==(p|0)){o=0;H[d+24>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0;break Oa}Pa:{e=f-p|0;Qa:{if((e|0)<0){H[197455]=0;ia(1808,d|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Ea}break Qa}H[197455]=0;c=aa(899,e|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Pa}}h=$()|0;_()|0;a=H[d>>2];if(!a){break Fa}H[d+4>>2]=a;Kb(a);break Fa}H[d>>2]=c;H[d+8>>2]=c+(e>>2<<2);f=Ob(c,p,e);Ra:{if(e){H[d+56>>2]=0;H[d+48>>2]=0;H[d+52>>2]=0;c=(e+f|0)-f|0;if(c>>>0>=1073741821){H[197455]=0;ia(1869,d+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Ea}break Ga}H[197455]=0;o=aa(899,c<<2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Ga}g=c>>2;b=g>>>0>1?g:1;l=b&1;h=0;if(c>>>0>=8){e=b&-2;m=0;while(1){c=(h<<4)+o|0;b=f+(h<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];b=h|1;c=(b<<4)+o|0;b=f+(b<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];h=h+2|0;m=m+2|0;if((e|0)!=(m|0)){continue}break}}if(l){c=(h<<4)+o|0;b=f+(h<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1]}H[d+16>>2]=o;b=(g<<4)+o|0;H[d+24>>2]=b;H[d+20>>2]=b;break Ra}o=0;H[d+24>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0}H[d+4>>2]=f;Kb(f)}A=M[o+8>>3];w=M[o>>3];H[197455]=0;ta(1870,a|0,+w,+A);c=H[197455];H[197455]=0;b=1;if((c|0)==1){break Ja}if(s>>>0>1){while(1){c=(b<<4)+o|0;Q=M[c+16>>3];D=M[c+24>>3];J=M[c+32>>3];z=M[c+40>>3];A=M[c>>3];w=M[c+8>>3];H[197455]=0;if(P(w)<2147483648){e=~~w}else{e=-2147483648}if(P(A)<2147483648){c=~~A}else{c=-2147483648}if(P(z)<2147483648){f=~~z}else{f=-2147483648}if(P(J)<2147483648){g=~~J}else{g=-2147483648}if(P(D)<2147483648){l=~~D}else{l=-2147483648}if(P(Q)<2147483648){h=~~Q}else{h=-2147483648}ua(1871,a|0,c|0,e|0,h|0,l|0,g|0,f|0);c=H[197455];H[197455]=0;if((c|0)==1){break Ia}b=b+3|0;if(s>>>0>b>>>0){continue}break}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ja}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break Ja}c=H[a+208>>2];if(c){b=H[H[c>>2]+516>>2];H[197455]=0;Pa(b|0,c|0,n|0,+r,d+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ja}}b=H[a+120>>2];H[197455]=0;if((i|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Ja}b=H[d+16>>2];if(!b){break Ma}H[d+20>>2]=b;Kb(b)}Kb(p)}xb=d- -64|0;break qa}h=$()|0;_()|0;o=H[d+16>>2];if(!o){break Fa}break Ha}h=$()|0;_()|0}H[d+20>>2]=o;Kb(o);break Fa}h=$()|0;_()|0;a=H[d+48>>2];if(a){H[d+52>>2]=a;Kb(a)}H[d+4>>2]=f;Kb(f)}Kb(p);ea(h|0);X()}X()}d=j&65535;v=xb+-64|0;xb=v;f=H[a>>2]-12|0;c=H[f>>2]+a|0;b=c+8|0;g=H[b>>2];h=H[c+12>>2];if(h>>>0<=g+3>>>0){r=0}else{y=(x(2,I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24)),B());H[c+8>>2]=g+4;b=H[f>>2]+a|0;h=H[b+12>>2];b=b+8|0;g=H[b>>2];r=+y}Sa:{Ta:{Ua:{Va:{Wa:{Xa:{Ya:{Za:{if(g+3>>>0>=h>>>0){break Za}q=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[b>>2]=g+4;if(q>>>0<3){break Za}H[v+40>>2]=0;H[v+32>>2]=0;H[v+36>>2]=0;_a:{$a:{if(q>>>0>=268435456){H[197455]=0;ia(1869,v+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break $a}break Ta}H[197455]=0;c=q<<4;l=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break _a}}a=$()|0;_()|0;b=H[v+32>>2];if(b){H[v+36>>2]=b;Kb(b)}break d}s=d&255;H[v+32>>2]=l;i=c+l|0;H[v+40>>2]=i;H[v+36>>2]=i;d=a+4|0;e=0;while(1){g=d+H[f>>2]|0;b=H[g+4>>2];c=H[g+8>>2];if(b+3>>>0>=c>>>0){w=0}else{y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());b=b+4|0;H[g+4>>2]=b;w=+y}M[l>>3]=w;if(c>>>0>b+3>>>0){y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());H[g+4>>2]=b+4;w=+y}else{w=0}M[l+8>>3]=w;e=e+1|0;if((q|0)!=(e|0)){continue}break}c=a+236|0;g=H[c>>2];ab:{if(!g){break ab}b=c;while(1){d=s>>>0>K[g+16>>2];b=d?b:g;g=H[(d<<2)+g>>2];if(g){continue}break}if((b|0)==(c|0)|s>>>0>2]){break ab}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;bb:{if((c|0)!=1){if((d|0)!=2){break ab}c=H[b+20>>2];if(!c){break ab}b=H[a+120>>2];H[197455]=0;m=c+4|0;H[b+12>>2]=m;b=H[197455];H[197455]=0;if((b|0)!=1){break bb}}g=$()|0;_()|0;break Ua}H[v+8>>2]=0;H[v>>2]=0;H[v+4>>2]=0;cb:{if((i|0)==(l|0)){b=0;H[v+24>>2]=0;H[v+16>>2]=0;H[v+20>>2]=0;break cb}db:{d=i-l|0;eb:{if((d|0)<0){H[197455]=0;ia(1869,v|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Ta}break eb}H[197455]=0;c=aa(899,d|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break db}}g=$()|0;_()|0;a=H[v>>2];if(!a){break Ua}H[v+4>>2]=a;Kb(a);break Ua}H[v>>2]=c;H[v+8>>2]=c+(d>>4<<4);t=Ob(c,l,d);fb:{if(d){H[v+56>>2]=0;H[v+48>>2]=0;H[v+52>>2]=0;d=(d+t|0)-t|0;if((d|0)<0){H[197455]=0;ia(1869,v+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Ta}break Va}H[197455]=0;b=aa(899,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Va}h=d>>4;c=h>>>0>1?h:1;i=c&3;k=0;g=0;if(c-1>>>0>=3){e=c&-4;f=0;while(1){p=g<<4;d=p+b|0;n=p+t|0;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=p|16;d=c+b|0;n=c+t|0;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;c=p|32;d=c+b|0;n=c+t|0;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;c=p|48;d=c+b|0;n=c+t|0;c=H[n+12>>2];H[d+8>>2]=H[n+8>>2];H[d+12>>2]=c;c=H[n+4>>2];H[d>>2]=H[n>>2];H[d+4>>2]=c;g=g+4|0;f=f+4|0;if((e|0)!=(f|0)){continue}break}}if(i){while(1){c=g<<4;d=c+b|0;e=c+t|0;c=H[e+4>>2];H[d>>2]=H[e>>2];H[d+4>>2]=c;c=H[e+12>>2];H[d+8>>2]=H[e+8>>2];H[d+12>>2]=c;g=g+1|0;k=k+1|0;if((i|0)!=(k|0)){continue}break}}H[v+16>>2]=b;c=(h<<4)+b|0;H[v+24>>2]=c;H[v+20>>2]=c;break fb}b=0;H[v+24>>2]=0;H[v+16>>2]=0;H[v+20>>2]=0}H[v+4>>2]=t;Kb(t)}A=M[b+8>>3];w=M[b>>3];H[197455]=0;ta(1870,a|0,+w,+A);c=H[197455];H[197455]=0;e=1;if((c|0)==1){break Ya}if(q>>>0>1){while(1){c=(e<<4)+b|0;Q=M[c+16>>3];D=M[c+24>>3];J=M[c+32>>3];z=M[c+40>>3];A=M[c>>3];w=M[c+8>>3];H[197455]=0;if(P(w)<2147483648){d=~~w}else{d=-2147483648}if(P(A)<2147483648){c=~~A}else{c=-2147483648}if(P(z)<2147483648){i=~~z}else{i=-2147483648}if(P(J)<2147483648){f=~~J}else{f=-2147483648}if(P(D)<2147483648){g=~~D}else{g=-2147483648}if(P(Q)<2147483648){h=~~Q}else{h=-2147483648}ua(1871,a|0,c|0,d|0,h|0,g|0,f|0,i|0);c=H[197455];H[197455]=0;if((c|0)==1){break Xa}e=e+3|0;if(q>>>0>e>>>0){continue}break}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ya}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break Ya}c=H[a+208>>2];if(c){b=H[H[c>>2]+516>>2];H[197455]=0;Pa(b|0,c|0,s|0,+r,v+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ya}}b=H[a+120>>2];H[197455]=0;if((m|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Ya}b=H[v+16>>2];if(!b){break ab}H[v+20>>2]=b;Kb(b)}Kb(l)}xb=v- -64|0;break Sa}g=$()|0;_()|0;b=H[v+16>>2];if(!b){break Ua}break Wa}g=$()|0;_()|0}H[v+20>>2]=b;Kb(b);break Ua}g=$()|0;_()|0;a=H[v+48>>2];if(a){H[v+52>>2]=a;Kb(a)}H[v+4>>2]=t;Kb(t)}Kb(l);break b}X()}}F[a+213|0]=1;break k;case 23:gb:{if(j&16384){h=0;b=0;v=0;m=0;q=xb+-64|0;xb=q;s=H[a>>2]-12|0;e=H[s>>2]+a|0;d=e+8|0;g=H[d>>2];c=H[e+12>>2];if(c>>>0<=g+3>>>0){r=0}else{y=(x(2,I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24)),B());H[e+8>>2]=g+4;d=H[s>>2]+a|0;c=H[d+12>>2];d=d+8|0;g=H[d>>2];r=+y}f=j&65535;if(g+3>>>0>>0){m=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[d>>2]=g+4;d=H[s>>2]+a|0;c=H[d+12>>2];d=d+8|0;g=H[d>>2]}if(g+3>>>0>>0){v=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[d>>2]=g+4;d=H[s>>2]+a|0;c=H[d+12>>2];d=d+8|0;g=H[d>>2]}hb:{ib:{if(g+3>>>0>=c>>>0){H[q+40>>2]=0;H[q+32>>2]=0;H[q+36>>2]=0;break ib}e=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[d>>2]=g+4;H[q+40>>2]=0;H[q+32>>2]=0;H[q+36>>2]=0;if(!e){break ib}jb:{kb:{if(e>>>0>=1073741824){H[197455]=0;ia(1808,q+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break kb}break hb}g=0;H[197455]=0;c=e<<2;h=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break jb}}g=$()|0;_()|0;a=H[q+32>>2];if(!a){break b}H[q+36>>2]=a;Kb(a);break b}H[q+32>>2]=h;b=c+h|0;H[q+40>>2]=b;i=Nb(h,0,c);H[q+36>>2]=b;l=a+4|0;while(1){d=0;n=l+H[s>>2]|0;c=H[n+4>>2];b=H[n+8>>2];lb:{if(c+1>>>0>=b>>>0){k=0;break lb}k=I[c|0]|I[c+1|0]<<8;c=c+2|0;H[n+4>>2]=c}G[i>>1]=k;if(b>>>0>c+1>>>0){d=I[c|0]|I[c+1|0]<<8;H[n+4>>2]=c+2}G[i+2>>1]=d;g=g+1|0;if((e|0)!=(g|0)){continue}break}b=e}mb:{nb:{ob:{pb:{qb:{d=a+236|0;g=H[d>>2];rb:{if(!g){break rb}p=f&255;c=d;while(1){e=p>>>0>K[g+16>>2];c=e?c:g;g=H[(e<<2)+g>>2];if(g){continue}break}if((c|0)==(d|0)|p>>>0>2]){break rb}e=H[c+20>>2];d=H[H[e>>2]+12>>2];H[197455]=0;e=aa(d|0,e|0)|0;d=H[197455];H[197455]=0;sb:{if((d|0)!=1){if((e|0)!=2){break rb}d=H[c+20>>2];if(!d){break rb}c=H[a+120>>2];H[197455]=0;n=d+4|0;H[c+12>>2]=n;c=H[197455];H[197455]=0;if((c|0)!=1){break sb}}g=$()|0;_()|0;break mb}H[q+8>>2]=0;H[q>>2]=0;H[q+4>>2]=0;c=H[q+36>>2];tb:{if((c|0)==(h|0)){d=0;H[q+24>>2]=0;H[q+16>>2]=0;H[q+20>>2]=0;break tb}ub:{e=c-h|0;vb:{if((e|0)<0){H[197455]=0;ia(1808,q|0);a=H[197455];H[197455]=0;if((a|0)!=1){break hb}break vb}H[197455]=0;d=aa(899,e|0)|0;c=H[197455];H[197455]=0;if((c|0)!=1){break ub}}g=$()|0;_()|0;a=H[q>>2];if(!a){break mb}H[q+4>>2]=a;Kb(a);break mb}H[q>>2]=d;H[q+8>>2]=d+(e>>2<<2);s=Ob(d,h,e);wb:{if(e){H[q+56>>2]=0;H[q+48>>2]=0;H[q+52>>2]=0;e=(e+s|0)-s|0;if(e>>>0>=1073741821){H[197455]=0;ia(1869,q+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break hb}break nb}H[197455]=0;d=aa(899,e<<2)|0;c=H[197455];H[197455]=0;if((c|0)==1){break nb}i=e>>2;c=i>>>0>1?i:1;f=c&1;g=0;if(e>>>0>=8){l=c&-2;k=0;while(1){e=(g<<4)+d|0;c=s+(g<<2)|0;M[e>>3]=G[c>>1];M[e+8>>3]=G[c+2>>1];c=g|1;e=(c<<4)+d|0;c=s+(c<<2)|0;M[e>>3]=G[c>>1];M[e+8>>3]=G[c+2>>1];g=g+2|0;k=k+2|0;if((l|0)!=(k|0)){continue}break}}if(f){e=(g<<4)+d|0;c=s+(g<<2)|0;M[e>>3]=G[c>>1];M[e+8>>3]=G[c+2>>1]}H[q+16>>2]=d;c=(i<<4)+d|0;H[q+24>>2]=c;H[q+20>>2]=c;break wb}d=0;H[q+24>>2]=0;H[q+16>>2]=0;H[q+20>>2]=0}H[q+4>>2]=s;Kb(s)}A=M[d+8>>3];w=M[d>>3];H[197455]=0;ta(1870,a|0,+w,+A);e=H[197455];H[197455]=0;c=1;if((e|0)==1){break qb}if(b>>>0>1){while(1){e=(c<<4)+d|0;Q=M[e+16>>3];D=M[e+24>>3];J=M[e+32>>3];z=M[e+40>>3];A=M[e>>3];w=M[e+8>>3];H[197455]=0;if(P(w)<2147483648){l=~~w}else{l=-2147483648}if(P(A)<2147483648){e=~~A}else{e=-2147483648}if(P(z)<2147483648){i=~~z}else{i=-2147483648}if(P(J)<2147483648){f=~~J}else{f=-2147483648}if(P(D)<2147483648){g=~~D}else{g=-2147483648}if(P(Q)<2147483648){j=~~Q}else{j=-2147483648}ua(1871,a|0,e|0,l|0,j|0,g|0,f|0,i|0);e=H[197455];H[197455]=0;if((e|0)==1){break pb}c=c+3|0;if(c>>>0>>0){continue}break}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break qb}c=H[a+208>>2];if(c){b=H[H[c>>2]+520>>2];H[197455]=0;Za(b|0,c|0,p|0,+r,m|0,v|0,q+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break qb}}b=H[a+120>>2];H[197455]=0;if((n|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break qb}b=H[q+16>>2];if(!b){break rb}H[q+20>>2]=b;Kb(b)}if(h){H[q+36>>2]=h;Kb(h)}xb=q- -64|0;break gb}g=$()|0;_()|0;d=H[q+16>>2];if(!d){break mb}break ob}g=$()|0;_()|0}H[q+20>>2]=d;Kb(d);break mb}g=$()|0;_()|0;a=H[q+48>>2];if(a){H[q+52>>2]=a;Kb(a)}H[q+4>>2]=s;Kb(s)}if(!h){break b}H[q+36>>2]=h;Kb(h);break b}X()}l=0;b=0;o=0;u=0;t=xb+-64|0;xb=t;i=H[a>>2]-12|0;d=H[i>>2]+a|0;m=d+8|0;f=H[m>>2];c=H[d+12>>2];if(c>>>0<=f+3>>>0){r=0}else{y=(x(2,I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24)),B());H[d+8>>2]=f+4;d=H[i>>2]+a|0;c=H[d+12>>2];m=d+8|0;f=H[m>>2];r=+y}g=j&65535;if(f+3>>>0>>0){u=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[m>>2]=f+4;d=H[i>>2]+a|0;c=H[d+12>>2];m=d+8|0;f=H[m>>2]}if(f+3>>>0>>0){o=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[m>>2]=f+4;d=H[i>>2]+a|0;c=H[d+12>>2];m=d+8|0;f=H[m>>2]}xb:{yb:{zb:{if(f+3>>>0>=c>>>0){H[t+40>>2]=0;H[t+32>>2]=0;H[t+36>>2]=0;break zb}d=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[m>>2]=f+4;H[t+40>>2]=0;H[t+32>>2]=0;H[t+36>>2]=0;if(!d){break zb}Ab:{Bb:{if(d>>>0>=268435456){H[197455]=0;ia(1869,t+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break Bb}break yb}m=0;H[197455]=0;c=d<<4;l=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Ab}}f=$()|0;_()|0;a=H[t+32>>2];if(!a){break a}H[t+36>>2]=a;Kb(a);break a}H[t+32>>2]=l;b=c+l|0;H[t+40>>2]=b;H[t+36>>2]=b;e=a+4|0;while(1){f=e+H[i>>2]|0;c=H[f+4>>2];b=H[f+8>>2];if(c+3>>>0>=b>>>0){w=0}else{y=(x(2,I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24)),B());c=c+4|0;H[f+4>>2]=c;w=+y}M[l>>3]=w;if(b>>>0>c+3>>>0){y=(x(2,I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24)),B());H[f+4>>2]=c+4;w=+y}else{w=0}M[l+8>>3]=w;m=m+1|0;if((d|0)!=(m|0)){continue}break}b=d}Cb:{Db:{Eb:{Fb:{Gb:{d=a+236|0;f=H[d>>2];Hb:{if(!f){break Hb}s=g&255;c=d;while(1){e=s>>>0>K[f+16>>2];c=e?c:f;f=H[(e<<2)+f>>2];if(f){continue}break}if((c|0)==(d|0)|s>>>0>2]){break Hb}e=H[c+20>>2];d=H[H[e>>2]+12>>2];H[197455]=0;e=aa(d|0,e|0)|0;d=H[197455];H[197455]=0;Ib:{if((d|0)!=1){if((e|0)!=2){break Hb}d=H[c+20>>2];if(!d){break Hb}c=H[a+120>>2];H[197455]=0;h=d+4|0;H[c+12>>2]=h;c=H[197455];H[197455]=0;if((c|0)!=1){break Ib}}f=$()|0;_()|0;break Cb}H[t+8>>2]=0;H[t>>2]=0;H[t+4>>2]=0;c=H[t+36>>2];Jb:{if((c|0)==(l|0)){c=0;H[t+24>>2]=0;H[t+16>>2]=0;H[t+20>>2]=0;break Jb}Kb:{e=c-l|0;Lb:{if((e|0)<0){H[197455]=0;ia(1869,t|0);a=H[197455];H[197455]=0;if((a|0)!=1){break yb}break Lb}H[197455]=0;d=aa(899,e|0)|0;c=H[197455];H[197455]=0;if((c|0)!=1){break Kb}}f=$()|0;_()|0;a=H[t>>2];if(!a){break Cb}H[t+4>>2]=a;Kb(a);break Cb}H[t>>2]=d;H[t+8>>2]=d+(e>>4<<4);q=Ob(d,l,e);Mb:{if(e){H[t+56>>2]=0;H[t+48>>2]=0;H[t+52>>2]=0;e=(e+q|0)-q|0;if((e|0)<0){H[197455]=0;ia(1869,t+48|0);a=H[197455];H[197455]=0;if((a|0)!=1){break yb}break Db}H[197455]=0;c=aa(899,e|0)|0;d=H[197455];H[197455]=0;if((d|0)==1){break Db}m=e>>4;d=m>>>0>1?m:1;i=d&3;j=0;f=0;if(d-1>>>0>=3){g=d&-4;k=0;while(1){p=f<<4;e=p+c|0;n=q+p|0;d=H[n+4>>2];H[e>>2]=H[n>>2];H[e+4>>2]=d;d=H[n+12>>2];H[e+8>>2]=H[n+8>>2];H[e+12>>2]=d;d=p|16;e=d+c|0;n=d+q|0;d=H[n+12>>2];H[e+8>>2]=H[n+8>>2];H[e+12>>2]=d;d=H[n+4>>2];H[e>>2]=H[n>>2];H[e+4>>2]=d;d=p|32;e=d+c|0;n=d+q|0;d=H[n+12>>2];H[e+8>>2]=H[n+8>>2];H[e+12>>2]=d;d=H[n+4>>2];H[e>>2]=H[n>>2];H[e+4>>2]=d;d=p|48;e=d+c|0;n=d+q|0;d=H[n+12>>2];H[e+8>>2]=H[n+8>>2];H[e+12>>2]=d;d=H[n+4>>2];H[e>>2]=H[n>>2];H[e+4>>2]=d;f=f+4|0;k=k+4|0;if((g|0)!=(k|0)){continue}break}}if(i){while(1){d=f<<4;e=d+c|0;g=d+q|0;d=H[g+4>>2];H[e>>2]=H[g>>2];H[e+4>>2]=d;d=H[g+12>>2];H[e+8>>2]=H[g+8>>2];H[e+12>>2]=d;f=f+1|0;j=j+1|0;if((i|0)!=(j|0)){continue}break}}H[t+16>>2]=c;d=(m<<4)+c|0;H[t+24>>2]=d;H[t+20>>2]=d;break Mb}c=0;H[t+24>>2]=0;H[t+16>>2]=0;H[t+20>>2]=0}H[t+4>>2]=q;Kb(q)}A=M[c+8>>3];w=M[c>>3];H[197455]=0;ta(1870,a|0,+w,+A);d=H[197455];H[197455]=0;m=1;if((d|0)==1){break Gb}if(b>>>0>1){while(1){d=(m<<4)+c|0;Q=M[d+16>>3];D=M[d+24>>3];J=M[d+32>>3];z=M[d+40>>3];A=M[d>>3];w=M[d+8>>3];H[197455]=0;if(P(w)<2147483648){e=~~w}else{e=-2147483648}if(P(A)<2147483648){d=~~A}else{d=-2147483648}if(P(z)<2147483648){i=~~z}else{i=-2147483648}if(P(J)<2147483648){f=~~J}else{f=-2147483648}if(P(D)<2147483648){g=~~D}else{g=-2147483648}if(P(Q)<2147483648){j=~~Q}else{j=-2147483648}ua(1871,a|0,d|0,e|0,j|0,g|0,f|0,i|0);d=H[197455];H[197455]=0;if((d|0)==1){break Fb}m=m+3|0;if(m>>>0>>0){continue}break}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break Gb}c=H[a+208>>2];if(c){b=H[H[c>>2]+520>>2];H[197455]=0;Za(b|0,c|0,s|0,+r,u|0,o|0,t+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Gb}}b=H[a+120>>2];H[197455]=0;if((h|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Gb}b=H[t+16>>2];if(!b){break Hb}H[t+20>>2]=b;Kb(b)}if(l){H[t+36>>2]=l;Kb(l)}xb=t- -64|0;break xb}f=$()|0;_()|0;c=H[t+16>>2];if(!c){break Cb}break Eb}f=$()|0;_()|0}H[t+20>>2]=c;Kb(c);break Cb}f=$()|0;_()|0;a=H[t+48>>2];if(a){H[t+52>>2]=a;Kb(a)}H[t+4>>2]=q;Kb(q)}if(!l){break a}H[t+36>>2]=l;Kb(l);break a}X()}}F[a+213|0]=1;break k;case 53:h=0;c=0;u=0;m=0;p=xb-96|0;xb=p;l=H[a>>2]-12|0;e=H[l>>2]+a|0;o=e+8|0;d=H[o>>2];b=H[e+12>>2];if(b>>>0>d+3>>>0){h=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[e+8>>2]=d+4;d=H[l>>2]+a|0;b=H[d+12>>2];o=d+8|0;d=H[o>>2]}if(d+3>>>0>>0){m=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[o>>2]=d+4;d=H[l>>2]+a|0;b=H[d+12>>2];o=d+8|0;d=H[o>>2]}if(d+3>>>0>>0){u=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[o>>2]=d+4;d=H[l>>2]+a|0;b=H[d+12>>2];o=d+8|0;d=H[o>>2]}i=j&65535;Nb:{Ob:{Pb:{Qb:{Rb:{if(d+3>>>0>=b>>>0){break Rb}s=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[o>>2]=d+4;if(!s){break Rb}d=s+1|0;b=d+d|0;n=Qb(b>>>0>>0?-1:b);G[n+(s<<1)>>1]=0;f=H[l>>2]+a|0;g=H[f+12>>2];b=H[f+8>>2];d=(g-b|0)/2|0;l=d>>>0>>0?d:s;Sb:{if(!l){break Sb}if(g>>>0>b+1>>>0){d=0;if((l|0)!=1){e=l&-2;while(1){Tb:{if(g>>>0<=b+1>>>0){o=0;break Tb}o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[f+8>>2]=b}G[n+(d<<1)>>1]=o;o=0;if(g>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[f+8>>2]=b}G[n+((d|1)<<1)>>1]=o;d=d+2|0;c=c+2|0;if((e|0)!=(c|0)){continue}break}}if(!(l&1)){break Sb}o=0;if(g>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;H[f+8>>2]=b+2}G[n+(d<<1)>>1]=o;break Sb}Nb(n,0,l<<1)}H[p+88>>2]=0;H[p+80>>2]=0;H[p+84>>2]=0;zk(p+16|0,n,s);H[p+88>>2]=H[p+24>>2];b=H[p+20>>2];H[p+80>>2]=H[p+16>>2];H[p+84>>2]=b;Kb(n);H[197455]=0;ga(1874,p- -64|0,a|0,s|0);b=H[197455];H[197455]=0;Ub:{Vb:{Wb:{Xb:{if((b|0)!=1){if((u|0)==1){H[p+32>>2]=0;H[p+36>>2]=0;H[p+56>>2]=0;H[p+60>>2]=0;H[p+24>>2]=0;H[p+28>>2]=0;H[p+16>>2]=0;H[p+20>>2]=1072693248;H[p+48>>2]=0;H[p+52>>2]=0;H[p+40>>2]=0;H[p+44>>2]=1072693248;b=H[H[a>>2]-12>>2];H[197455]=0;lg((a+b|0)+4|0,p+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Xb}F[a+213|0]=1}if(!H[a+208>>2]){break Ub}o=0;b=I[p+91|0];l=b<<24>>24<0?H[p+84>>2]:b;c=H[p+68>>2];s=H[p+64>>2];e=c-s|0;if((l|0)!=e>>4){break Ub}H[p+24>>2]=0;H[p+16>>2]=0;H[p+20>>2]=0;if((c|0)==(s|0)){break Vb}if((e|0)>=0){break Wb}H[197455]=0;ia(1652,p+16|0);a=H[197455];H[197455]=0;if((a|0)==1){break Qb}X()}d=$()|0;_()|0;break Ob}d=$()|0;_()|0;break Pb}d=0;H[197455]=0;o=aa(899,e|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Qb}H[p+16>>2]=o;c=l<<4;b=c+o|0;H[p+24>>2]=b;n=Nb(o,0,c);H[p+20>>2]=b;b=l>>>0>1?l:1;g=b&1;if(l>>>0>=2){l=b&-2;b=0;while(1){f=d<<4;e=f+n|0;c=f+s|0;M[e>>3]=M[c>>3];M[e+8>>3]=M[c+8>>3];c=f|16;e=c+n|0;c=c+s|0;M[e>>3]=M[c>>3];M[e+8>>3]=M[c+8>>3];d=d+2|0;b=b+2|0;if((l|0)!=(b|0)){continue}break}}if(!g){break Vb}b=d<<4;c=b+n|0;b=b+s|0;M[c>>3]=M[b>>3];M[c+8>>3]=M[b+8>>3]}c=a+236|0;d=H[c>>2];Yb:{if(!d){break Yb}g=i&255;b=c;while(1){e=g>>>0>K[d+16>>2];b=e?b:d;d=H[(e<<2)+d>>2];if(d){continue}break}if((b|0)==(c|0)|g>>>0>2]){break Yb}e=H[b+20>>2];d=H[H[e>>2]+12>>2];H[197455]=0;e=aa(d|0,e|0)|0;d=H[197455];H[197455]=0;if((d|0)==1){break Qb}if((e|0)!=6){break Yb}d=H[b+20>>2];if(!d){break Yb}b=H[a+120>>2];H[197455]=0;l=d+4|0;H[b+16>>2]=l;b=H[197455];H[197455]=0;if((b|0)==1){break Qb}Zb:{if(i<<16>>16<0){F[p+11|0]=h>>>24;F[p+8|0]=h>>>16;b=h<<8|(h&65280)>>>8;F[p+9|0]=b;F[p+10|0]=b>>>8;c=H[a+120>>2];H[197455]=0;b=H[197455];H[197455]=0;_b:{if((b|0)==1){break _b}H[p+4>>2]=I[c+592|0]|I[c+593|0]<<8|(I[c+594|0]<<16|I[c+595|0]<<24);b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[p+8|0];F[b+593|0]=I[p+9|0];F[b+594|0]=I[p+10|0];F[b+595|0]=I[p+11|0];b=H[197455];H[197455]=0;if((b|0)==1){break _b}c=H[a+208>>2];b=H[H[c>>2]+24>>2];H[197455]=0;ga(b|0,c|0,p+80|0,p+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break _b}c=H[a+208>>2];b=H[H[c>>2]+524>>2];H[197455]=0;La(b|0,c|0,g|0,h|0,m|0,u|0,0,p+80|0,p+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break _b}b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[p+4|0];F[b+593|0]=I[p+5|0];F[b+594|0]=I[p+6|0];F[b+595|0]=I[p+7|0];b=H[197455];H[197455]=0;if((b|0)!=1){break Zb}}break Qb}d=H[c>>2];if(!d){break Yb}b=c;while(1){e=K[d+16>>2]>>0;b=e?b:d;d=H[(e<<2)+d>>2];if(d){continue}break}if((b|0)==(c|0)|K[b+16>>2]>h>>>0){break Yb}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Qb}if((d|0)!=1){break Yb}b=H[b+20>>2];if(!b){break Yb}F[p+10|0]=I[b+8|0];F[p+9|0]=I[b+9|0];F[p+8|0]=I[b+10|0];F[p+11|0]=I[b+11|0];c=H[a+120>>2];H[197455]=0;b=H[197455];H[197455]=0;if((b|0)==1){break Qb}H[p+4>>2]=I[c+592|0]|I[c+593|0]<<8|(I[c+594|0]<<16|I[c+595|0]<<24);b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[p+8|0];F[b+593|0]=I[p+9|0];F[b+594|0]=I[p+10|0];F[b+595|0]=I[p+11|0];b=H[197455];H[197455]=0;if((b|0)==1){break Qb}c=H[a+208>>2];b=H[H[c>>2]+24>>2];H[197455]=0;ga(b|0,c|0,p+80|0,p+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Qb}c=H[a+208>>2];if(c){b=H[H[c>>2]+524>>2];H[197455]=0;La(b|0,c|0,g|0,h|0,m|0,u|0,0,p+80|0,p+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Qb}}b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[p+4|0];F[b+593|0]=I[p+5|0];F[b+594|0]=I[p+6|0];F[b+595|0]=I[p+7|0];b=H[197455];H[197455]=0;if((b|0)==1){break Qb}}b=H[a+120>>2];H[197455]=0;if((l|0)==H[b+16>>2]){H[b+16>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Qb}F[a+213|0]=1;o=H[p+16>>2]}if(!o){break Ub}H[p+20>>2]=o;Kb(o)}b=H[p+64>>2];if(b){H[p+68>>2]=b;Kb(b)}if(F[p+91|0]>=0){break Rb}Kb(H[p+80>>2])}xb=p+96|0;break Nb}d=$()|0;_()|0;a=H[p+16>>2];if(!a){break Pb}H[p+20>>2]=a;Kb(a)}a=H[p+64>>2];if(!a){break Ob}H[p+68>>2]=a;Kb(a)}if(F[p+91|0]<0){Kb(H[p+80>>2])}ea(d|0);X()}break k;case 14:$b:{if(j&16384){u=0;v=0;m=0;e=0;n=xb-32|0;xb=n;c=H[H[a>>2]-12>>2]+a|0;h=H[c+8>>2];b=H[c+12>>2];if(h+1>>>0>>0){v=(I[h|0]|I[h+1|0]<<8)<<16>>16;h=h+2|0;H[c+8>>2]=h}if(b>>>0>h+1>>>0){u=(I[h|0]|I[h+1|0]<<8)<<16>>16;h=h+2|0;H[c+8>>2]=h}if(b>>>0>h+1>>>0){e=(I[h|0]|I[h+1|0]<<8)<<16>>16;h=h+2|0;H[c+8>>2]=h}if(b>>>0>h+1>>>0){m=(I[h|0]|I[h+1|0]<<8)<<16>>16;H[c+8>>2]=h+2}b=j&65535;c=a+236|0;h=H[c>>2];ac:{if(!h){break ac}i=b&255;b=c;while(1){d=i>>>0>K[h+16>>2];b=d?b:h;h=H[(d<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|i>>>0>2]){break ac}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break ac}f=H[b+20>>2];if(!f){break ac}b=H[f+28>>2];if(b){H[H[a+120>>2]+8>>2]=b+4}d=f+4|0;H[H[a+120>>2]+12>>2]=d;g=u<<16>>16;l=g+(m<<16>>16)|0;c=v<<16>>16;b=c+(e<<16>>16)|0;bc:{if(H[H[a+120>>2]+680>>2]==1){Sf(a,c,g,b,l,0,360);break bc}Sf(a,c,l,b,g,0,360)}Rf(a,1,0,1);b=H[a+208>>2];if(b){M[n+24>>3]=m<<16>>16;M[n+16>>3]=e<<16>>16;M[n+8>>3]=u<<16>>16;M[n>>3]=v<<16>>16;zb[H[H[b>>2]+528>>2]](b,i,n)}c=H[f+28>>2];if(c){b=H[a+120>>2];if(H[b+8>>2]==(c+4|0)){H[b+8>>2]=0}}b=H[a+120>>2];if((d|0)==H[b+12>>2]){H[b+12>>2]=0}}xb=n+32|0;break $b}b=j&65535;m=xb+-64|0;xb=m;H[m+56>>2]=0;H[m+60>>2]=0;H[m+48>>2]=0;H[m+52>>2]=0;H[m+40>>2]=0;H[m+44>>2]=0;H[m+32>>2]=0;H[m+36>>2]=0;Ae((H[H[a>>2]-12>>2]+a|0)+4|0,m+32|0);c=a+236|0;h=H[c>>2];cc:{if(!h){break cc}i=b&255;b=c;while(1){d=i>>>0>K[h+16>>2];b=d?b:h;h=H[(d<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|i>>>0>2]){break cc}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break cc}f=H[b+20>>2];if(!f){break cc}b=H[f+28>>2];if(b){H[H[a+120>>2]+8>>2]=b+4}g=f+4|0;H[H[a+120>>2]+12>>2]=g;w=M[m+48>>3];z=M[m+32>>3];b=H[H[a+120>>2]+680>>2];A=M[m+40>>3];r=A+M[m+56>>3];dc:{if(P(r)<2147483648){e=~~r;break dc}e=-2147483648}r=z+w;ec:{if(P(r)<2147483648){d=~~r;break ec}d=-2147483648}if(P(A)<2147483648){c=~~A}else{c=-2147483648}l=(b|0)!=1;if(P(z)<2147483648){b=~~z}else{b=-2147483648}fc:{if(!l){Sf(a,b,c,d,e,0,360);break fc}Sf(a,b,e,d,c,0,360)}Rf(a,1,0,1);b=H[a+208>>2];if(b){M[m+24>>3]=M[m+56>>3];M[m+16>>3]=M[m+48>>3];M[m+8>>3]=M[m+40>>3];M[m>>3]=M[m+32>>3];zb[H[H[b>>2]+528>>2]](b,i,m)}c=H[f+28>>2];if(c){b=H[a+120>>2];if(H[b+8>>2]==(c+4|0)){H[b+8>>2]=0}}b=H[a+120>>2];if((g|0)==H[b+12>>2]){H[b+12>>2]=0}}xb=m- -64|0}F[a+213|0]=1;break k;case 25:gc:{if(j&16384){D=0;z=0;f=0;g=xb-48|0;xb=g;H[g+40>>2]=0;H[g+44>>2]=0;H[g+32>>2]=0;H[g+36>>2]=0;H[g+24>>2]=0;H[g+28>>2]=0;H[g+16>>2]=0;H[g+20>>2]=0;l=H[a>>2]-12|0;b=H[l>>2]+a|0;c=b+8|0;k=H[c>>2];e=H[b+12>>2];if(e>>>0>k+3>>>0){f=I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24);H[b+8>>2]=k+4;b=H[l>>2]+a|0;e=H[b+12>>2];c=b+8|0;k=H[c>>2]}d=j&65535;hc:{ic:{if(k+3>>>0>=e>>>0){break ic}b=I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24);H[c>>2]=k+4;if((b|0)!=2){break ic}Ae((H[l>>2]+a|0)+4|0,g+16|0);l=H[H[a>>2]-12>>2]+a|0;e=H[l+8>>2];c=H[l+12>>2];if(e+1>>>0>=c>>>0){w=0}else{b=(I[e|0]|I[e+1|0]<<8)<<16>>16;e=e+2|0;H[l+8>>2]=e;w=+(b|0)}if(c>>>0>e+1>>>0){b=(I[e|0]|I[e+1|0]<<8)<<16>>16;e=e+2|0;H[l+8>>2]=e;D=+(b|0)}if(c>>>0<=e+1>>>0){r=0}else{b=(I[e|0]|I[e+1|0]<<8)<<16>>16;e=e+2|0;H[l+8>>2]=e;r=+(b|0)}if(c>>>0>e+1>>>0){b=(I[e|0]|I[e+1|0]<<8)<<16>>16;H[l+8>>2]=e+2;z=+(b|0)}c=Qb(48);H[g>>2]=c;b=c+48|0;H[g+8>>2]=b;M[c+40>>3]=D+z;r=w+r;M[c+32>>3]=r;M[c+24>>3]=D;M[c+16>>3]=r;M[c+8>>3]=D;M[c>>3]=w;H[197455]=0;H[g+4>>2]=b;wa(1880,a|0,d&255,f|0,g+16|0,g|0);b=H[197455];H[197455]=0;if((b|0)==1){break hc}Kb(c)}xb=g+48|0;break gc}a=$()|0;_()|0;Kb(c);break d}d=j&65535;k=0;l=xb-80|0;xb=l;H[l+72>>2]=0;H[l+76>>2]=0;b=l- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[l+56>>2]=0;H[l+60>>2]=0;H[l+48>>2]=0;H[l+52>>2]=0;e=H[a>>2]-12|0;c=H[e>>2]+a|0;h=c+8|0;j=H[h>>2];b=H[c+12>>2];if(b>>>0>j+3>>>0){k=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[c+8>>2]=j+4;c=H[e>>2]+a|0;b=H[c+12>>2];h=c+8|0;j=H[h>>2]}jc:{kc:{lc:{if(j+3>>>0>=b>>>0){break lc}b=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[h>>2]=j+4;if((b|0)!=2){break lc}c=l+48|0;Ae((H[e>>2]+a|0)+4|0,c);H[l+40>>2]=0;H[l+44>>2]=0;H[l+32>>2]=0;H[l+36>>2]=0;H[l+24>>2]=0;H[l+28>>2]=0;H[l+16>>2]=0;H[l+20>>2]=0;Ae((H[H[a>>2]-12>>2]+a|0)+4|0,l+16|0);w=M[l+32>>3];r=M[l+40>>3];z=M[l+24>>3];A=M[l+16>>3];e=Qb(48);H[l>>2]=e;b=e+48|0;H[l+8>>2]=b;M[e+40>>3]=z+r;r=A+w;M[e+32>>3]=r;M[e+24>>3]=z;M[e+16>>3]=r;M[e+8>>3]=z;M[e>>3]=A;H[197455]=0;H[l+4>>2]=b;wa(1880,a|0,d&255,k|0,c|0,l|0);b=H[197455];H[197455]=0;if((b|0)==1){break kc}Kb(e)}xb=l+80|0;break jc}a=$()|0;_()|0;Kb(e);break d}}F[a+213|0]=1;break k;case 26:f=j&65535;mc:{if(j&2048){o=0;k=0;n=xb-96|0;xb=n;H[n+72>>2]=0;H[n+76>>2]=0;b=n- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[n+56>>2]=0;H[n+60>>2]=0;H[n+48>>2]=0;H[n+52>>2]=0;c=H[a>>2]-12|0;m=H[c>>2];b=m+a|0;e=b+8|0;j=H[e>>2];u=H[b+12>>2];if(u>>>0>j+3>>>0){k=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[b+8>>2]=j+4;m=H[c>>2];b=m+a|0;u=H[b+12>>2];e=b+8|0;j=H[e>>2]}if(j+3>>>0>>0){o=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[e>>2]=j+4;m=H[c>>2]}Ae((m+a|0)+4|0,n+48|0);j=0;b=H[H[a>>2]-12>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){j=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}nc:{oc:{pc:{qc:{rc:{sc:{if((o|0)!=2&(j|0)!=3){break sc}u=0;H[n+40>>2]=0;H[n+32>>2]=0;H[n+36>>2]=0;tc:{uc:{if(!j){H[n+8>>2]=0;H[n>>2]=0;H[n+4>>2]=0;break uc}vc:{wc:{xc:{if((j|0)<0){H[197455]=0;ia(1867,n+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break xc}break vc}H[197455]=0;u=aa(899,j|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break wc}}j=$()|0;_()|0;a=H[n+32>>2];if(!a){break nc}H[n+36>>2]=a;Kb(a);break nc}H[n+32>>2]=u;b=j+u|0;H[n+40>>2]=b;H[n+36>>2]=b;H[n+8>>2]=0;H[n>>2]=0;H[n+4>>2]=0;if(!j){break uc}yc:{zc:{if((j|0)<0){H[197455]=0;ia(1867,n|0);a=H[197455];H[197455]=0;if((a|0)!=1){break vc}break zc}H[197455]=0;v=aa(899,j|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break yc}}j=$()|0;_()|0;a=H[n>>2];if(!a){break oc}H[n+4>>2]=a;Kb(a);break oc}H[n>>2]=v;b=j+v|0;H[n+8>>2]=b;Ob(v,u,j);H[n+4>>2]=b;H[n+88>>2]=0;H[n+80>>2]=0;H[n+84>>2]=0;Ac:{if(j>>>0<=268435455){H[197455]=0;c=j<<4;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Ac}g=c+o|0;Bc:{if(j>>>0<2){break Bc}m=1;b=j-1|0;d=b&1;if((j|0)!=2){c=b&-2;e=0;while(1){h=(m<<4)+o|0;i=h-16|0;l=H[i+4>>2];b=H[i>>2];H[h+16>>2]=b;H[h+20>>2]=l;H[h>>2]=b;H[h+4>>2]=l;l=H[i+12>>2];b=H[i+8>>2];H[h+24>>2]=b;H[h+28>>2]=l;H[h+8>>2]=b;H[h+12>>2]=l;m=m+2|0;e=e+2|0;if((c|0)!=(e|0)){continue}break}}if(!d){break Bc}d=(m<<4)+o|0;c=d-16|0;b=H[c+4>>2];H[d>>2]=H[c>>2];H[d+4>>2]=b;b=H[c+12>>2];H[d+8>>2]=H[c+8>>2];H[d+12>>2]=b}H[n+24>>2]=g;H[n+20>>2]=g;H[n+16>>2]=o;break tc}H[197455]=0;ia(1869,n+80|0);a=H[197455];H[197455]=0;if((a|0)!=1){break vc}}j=$()|0;_()|0;a=H[n+80>>2];if(!a){break qc}H[n+84>>2]=a;Kb(a);break qc}X()}v=0;H[n+24>>2]=0;H[n+16>>2]=0;H[n+20>>2]=0;o=0}H[197455]=0;wa(1880,a|0,f&255,k|0,n+48|0,n+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break rc}if(o){H[n+20>>2]=o;Kb(o)}if(v){H[n+4>>2]=v;Kb(v)}if(!u){break sc}Kb(u)}xb=n+96|0;break mc}j=$()|0;_()|0;if(o){H[n+20>>2]=o;Kb(o)}if(!v){break pc}}H[n+4>>2]=v;Kb(v)}if(!u){break nc}}Kb(u);ea(j|0);X()}ea(j|0);X()}if(f&16384){d=0;e=0;p=xb-96|0;xb=p;H[p+72>>2]=0;H[p+76>>2]=0;b=p- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[p+56>>2]=0;H[p+60>>2]=0;H[p+48>>2]=0;H[p+52>>2]=0;c=H[a>>2]-12|0;g=H[c>>2];b=g+a|0;h=b+8|0;l=H[h>>2];u=H[b+12>>2];if(u>>>0>l+3>>>0){e=I[l|0]|I[l+1|0]<<8|(I[l+2|0]<<16|I[l+3|0]<<24);H[b+8>>2]=l+4;g=H[c>>2];b=g+a|0;u=H[b+12>>2];h=b+8|0;l=H[h>>2]}if(l+3>>>0>>0){d=I[l|0]|I[l+1|0]<<8|(I[l+2|0]<<16|I[l+3|0]<<24);H[h>>2]=l+4;g=H[c>>2]}Ae((g+a|0)+4|0,p+48|0);g=0;i=H[a>>2]-12|0;b=H[i>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){g=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}m=j&65535;Cc:{Dc:{Ec:{Fc:{Gc:{Hc:{if((d|0)!=2&(g|0)!=3){break Hc}d=0;H[p+40>>2]=0;H[p+32>>2]=0;H[p+36>>2]=0;v=0;o=0;if(g){Ic:{Jc:{if(g>>>0>=1073741824){H[197455]=0;ia(1808,p+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break Jc}break Cc}l=0;H[197455]=0;c=g<<2;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Ic}}l=$()|0;_()|0;a=H[p+32>>2];if(!a){break c}H[p+36>>2]=a;Kb(a);break c}H[p+32>>2]=o;v=c+o|0;H[p+40>>2]=v;f=Nb(o,0,c);H[p+36>>2]=v;c=a+4|0;while(1){n=f+(l<<2)|0;u=0;s=c+H[i>>2]|0;h=H[s+4>>2];b=H[s+8>>2];Kc:{if(h+1>>>0>=b>>>0){k=0;break Kc}k=I[h|0]|I[h+1|0]<<8;h=h+2|0;H[s+4>>2]=h}G[n>>1]=k;if(b>>>0>h+1>>>0){u=I[h|0]|I[h+1|0]<<8;H[s+4>>2]=h+2}G[n+2>>1]=u;l=l+1|0;if((l|0)!=(g|0)){continue}break}}H[p+8>>2]=0;H[p>>2]=0;H[p+4>>2]=0;Lc:{Mc:{if((o|0)!=(v|0)){Nc:{c=v-o|0;Oc:{if((c|0)<0){H[197455]=0;ia(1808,p|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Cc}break Oc}H[197455]=0;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Nc}}l=$()|0;_()|0;d=H[p>>2];if(d){break Ec}break Dc}H[p>>2]=d;H[p+8>>2]=(c>>2<<2)+d;s=Ob(d,o,c);b=s+c|0;H[p+4>>2]=b;if(c){break Mc}}g=0;H[p+24>>2]=0;H[p+16>>2]=0;H[p+20>>2]=0;break Lc}H[p+88>>2]=0;H[p+80>>2]=0;H[p+84>>2]=0;c=b-s|0;if(c>>>0>=1073741821){H[197455]=0;ia(1869,p+80|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Cc}break Fc}H[197455]=0;g=aa(899,c<<2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Fc}n=c>>2;b=n>>>0>1?n:1;i=b&1;l=0;if(c>>>0>=8){f=b&-2;h=0;while(1){c=(l<<4)+g|0;b=s+(l<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];b=l|1;c=(b<<4)+g|0;b=s+(b<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];l=l+2|0;h=h+2|0;if((f|0)!=(h|0)){continue}break}}if(i){c=(l<<4)+g|0;b=s+(l<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1]}H[p+16>>2]=g;b=(n<<4)+g|0;H[p+24>>2]=b;H[p+20>>2]=b}H[197455]=0;wa(1880,a|0,m&255,e|0,p+48|0,p+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Gc}if(g){Kb(g)}if(d){H[p+4>>2]=d;Kb(d)}if(!o){break Hc}Kb(o)}xb=p+96|0;break mc}l=$()|0;_()|0;if(g){H[p+20>>2]=g;Kb(g)}if(!d){break Dc}break Ec}l=$()|0;_()|0;a=H[p+80>>2];if(!a){break Ec}H[p+84>>2]=a;Kb(a)}H[p+4>>2]=d;Kb(d)}if(!o){break c}Kb(o);break c}X()}i=j&65535;h=0;j=0;q=xb-96|0;xb=q;H[q+72>>2]=0;H[q+76>>2]=0;b=q- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[q+56>>2]=0;H[q+60>>2]=0;H[q+48>>2]=0;H[q+52>>2]=0;c=H[a>>2]-12|0;d=H[c>>2];b=d+a|0;e=b+8|0;g=H[e>>2];m=H[b+12>>2];if(m>>>0>g+3>>>0){j=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[b+8>>2]=g+4;d=H[c>>2];b=d+a|0;m=H[b+12>>2];e=b+8|0;g=H[e>>2]}if(g+3>>>0>>0){h=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[e>>2]=g+4;d=H[c>>2]}Ae((a+d|0)+4|0,q+48|0);u=0;f=H[a>>2]-12|0;b=H[f>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){u=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}Pc:{Qc:{Rc:{Sc:{Tc:{Uc:{Vc:{if((h|0)!=2&(u|0)!=3){break Vc}h=0;H[q+40>>2]=0;H[q+32>>2]=0;H[q+36>>2]=0;d=0;o=0;if(u){Wc:{Xc:{if(u>>>0>=268435456){H[197455]=0;ia(1869,q+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break Xc}break Qc}g=0;H[197455]=0;c=u<<4;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Wc}}g=$()|0;_()|0;a=H[q+32>>2];if(!a){break b}H[q+36>>2]=a;Kb(a);break b}H[q+32>>2]=o;d=c+o|0;H[q+40>>2]=d;H[q+36>>2]=d;l=a+4|0;while(1){b=(g<<4)+o|0;m=l+H[f>>2]|0;e=H[m+4>>2];c=H[m+8>>2];if(e+3>>>0>=c>>>0){r=0}else{y=(x(2,I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24)),B());e=e+4|0;H[m+4>>2]=e;r=+y}M[b>>3]=r;if(c>>>0>e+3>>>0){y=(x(2,I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24)),B());H[m+4>>2]=e+4;r=+y}else{r=0}M[b+8>>3]=r;g=g+1|0;if((u|0)!=(g|0)){continue}break}}H[q+8>>2]=0;H[q>>2]=0;H[q+4>>2]=0;Yc:{Zc:{if((d|0)!=(o|0)){_c:{c=d-o|0;$c:{if((c|0)<0){H[197455]=0;ia(1869,q|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Qc}break $c}H[197455]=0;h=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break _c}}g=$()|0;_()|0;h=H[q>>2];if(h){break Sc}break Rc}H[q>>2]=h;H[q+8>>2]=(c>>4<<4)+h;p=Ob(h,o,c);b=p+c|0;H[q+4>>2]=b;if(c){break Zc}}d=0;H[q+24>>2]=0;H[q+16>>2]=0;H[q+20>>2]=0;break Yc}H[q+88>>2]=0;H[q+80>>2]=0;H[q+84>>2]=0;c=b-p|0;if((c|0)<0){H[197455]=0;ia(1869,q+80|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Qc}break Tc}H[197455]=0;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Tc}f=c>>4;b=f>>>0>1?f:1;l=b&3;m=0;g=0;if(b-1>>>0>=3){e=b&-4;u=0;while(1){s=g<<4;c=s+d|0;n=p+s|0;b=H[n+4>>2];H[c>>2]=H[n>>2];H[c+4>>2]=b;b=H[n+12>>2];H[c+8>>2]=H[n+8>>2];H[c+12>>2]=b;b=s|16;c=b+d|0;n=b+p|0;b=H[n+12>>2];H[c+8>>2]=H[n+8>>2];H[c+12>>2]=b;b=H[n+4>>2];H[c>>2]=H[n>>2];H[c+4>>2]=b;b=s|32;c=b+d|0;n=b+p|0;b=H[n+12>>2];H[c+8>>2]=H[n+8>>2];H[c+12>>2]=b;b=H[n+4>>2];H[c>>2]=H[n>>2];H[c+4>>2]=b;b=s|48;c=b+d|0;n=b+p|0;b=H[n+12>>2];H[c+8>>2]=H[n+8>>2];H[c+12>>2]=b;b=H[n+4>>2];H[c>>2]=H[n>>2];H[c+4>>2]=b;g=g+4|0;u=u+4|0;if((e|0)!=(u|0)){continue}break}}if(l){while(1){b=g<<4;c=b+d|0;e=b+p|0;b=H[e+4>>2];H[c>>2]=H[e>>2];H[c+4>>2]=b;b=H[e+12>>2];H[c+8>>2]=H[e+8>>2];H[c+12>>2]=b;g=g+1|0;m=m+1|0;if((l|0)!=(m|0)){continue}break}}H[q+16>>2]=d;b=(f<<4)+d|0;H[q+24>>2]=b;H[q+20>>2]=b}H[197455]=0;wa(1880,a|0,i&255,j|0,q+48|0,q+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Uc}if(d){Kb(d)}if(h){H[q+4>>2]=h;Kb(h)}if(!o){break Vc}Kb(o)}xb=q+96|0;break Pc}g=$()|0;_()|0;if(d){H[q+20>>2]=d;Kb(d)}if(!h){break Rc}break Sc}g=$()|0;_()|0;a=H[q+80>>2];if(!a){break Sc}H[q+84>>2]=a;Kb(a)}H[q+4>>2]=h;Kb(h)}if(!o){break b}Kb(o);break b}X()}}F[a+213|0]=1;break k;case 12:t=j&65535;ad:{if(j&2048){m=0;e=xb-80|0;xb=e;bd:{cd:{dd:{ed:{fd:{gd:{hd:{id:{jd:{kd:{b=H[H[a>>2]-12>>2]+a|0;c=H[b+8>>2];ld:{if(c+3>>>0>=K[b+12>>2]){break ld}j=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4;if(!j){break ld}H[e+56>>2]=0;H[e+48>>2]=0;H[e+52>>2]=0;if((j|0)<0){H[197455]=0;ia(1867,e+48|0);a=H[197455];H[197455]=0;if((a|0)==1){break g}break bd}H[197455]=0;u=aa(899,j|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break g}H[e+48>>2]=u;b=a+236|0;l=H[b>>2];md:{if(!l){break md}q=t&255;c=b;while(1){d=q>>>0>K[l+16>>2];c=d?c:l;l=H[(d<<2)+l>>2];if(l){continue}break}if((b|0)==(c|0)|q>>>0>2]){break md}d=H[c+20>>2];b=H[H[d>>2]+12>>2];H[197455]=0;d=aa(b|0,d|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break id}if((d|0)!=2){break md}p=H[c+20>>2];if(!p){break md}b=H[a+120>>2];H[197455]=0;i=p+4|0;H[b+12>>2]=i;b=H[197455];H[197455]=0;if((b|0)==1){break id}c=H[p+28>>2];if(c){b=H[a+120>>2];H[197455]=0;H[b+8>>2]=c+4;b=H[197455];H[197455]=0;if((b|0)==1){break id}}H[e+40>>2]=0;H[e+32>>2]=0;H[e+36>>2]=0;nd:{od:{pd:{qd:{rd:{f=(u|0)==(j+u|0);sd:{if(!f){td:{ud:{if((j|0)<0){H[197455]=0;ia(1867,e+32|0);a=H[197455];H[197455]=0;if((a|0)!=1){break bd}break ud}H[197455]=0;c=aa(899,j|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break td}}l=$()|0;_()|0;a=H[e+32>>2];if(!a){break cd}H[e+36>>2]=a;Kb(a);break cd}H[e+32>>2]=c;H[e+40>>2]=c+j;v=Ob(c,u,j);H[e+72>>2]=0;H[e+64>>2]=0;H[e+68>>2]=0;if(j>>>0>=268435456){H[197455]=0;ia(1869,e- -64|0);a=H[197455];H[197455]=0;if((a|0)!=1){break bd}break ed}H[197455]=0;c=j<<4;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break ed}n=c+o|0;vd:{if(j>>>0<2){break vd}c=1;b=j-1|0;g=b&1;if((j|0)!=2){l=b&-2;while(1){b=o+(c<<4)|0;s=b-16|0;h=H[s+4>>2];d=H[s>>2];H[b+16>>2]=d;H[b+20>>2]=h;H[b>>2]=d;H[b+4>>2]=h;h=H[s+12>>2];d=H[s+8>>2];H[b+24>>2]=d;H[b+28>>2]=h;H[b+8>>2]=d;H[b+12>>2]=h;c=c+2|0;m=m+2|0;if((l|0)!=(m|0)){continue}break}}if(!g){break vd}d=o+(c<<4)|0;c=d-16|0;b=H[c+4>>2];H[d>>2]=H[c>>2];H[d+4>>2]=b;b=H[c+12>>2];H[d+8>>2]=H[c+8>>2];H[d+12>>2]=b}if((n|0)!=(o|0)){H[197455]=0;ta(1870,a|0,0,0);b=H[197455];H[197455]=0;if((b|0)==1){break kd}b=n-o|0;if(b>>>0>=17){b=b>>4;c=b>>>0>2?b:2;l=1;while(1){b=o+(l<<4)|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break kd}l=l+1|0;if((c|0)!=(l|0)){continue}break}}if(t&8192){H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break kd}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break kd}}Kb(o);H[e+36>>2]=v;Kb(v);l=H[a+208>>2];if(!l){break nd}H[e+8>>2]=0;H[e>>2]=0;H[e+4>>2]=0;if(f){break sd}if((j|0)>=0){break rd}H[197455]=0;ia(1867,e|0);a=H[197455];H[197455]=0;if((a|0)!=1){break bd}break qd}l=H[a+208>>2];if(!l){break nd}H[e+8>>2]=0;H[e>>2]=0;H[e+4>>2]=0}o=0;H[e+24>>2]=0;H[e+16>>2]=0;H[e+20>>2]=0;break od}H[197455]=0;o=aa(899,j|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break pd}}l=$()|0;_()|0;o=H[e>>2];if(o){break fd}break cd}H[e>>2]=o;b=j+o|0;H[e+8>>2]=b;Ob(o,u,j);H[e+4>>2]=b;H[e+72>>2]=0;H[e+64>>2]=0;H[e+68>>2]=0;if(j>>>0>268435455){break hd}H[197455]=0;c=j<<4;s=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break gd}h=c+s|0;wd:{if(j>>>0<2){break wd}c=1;b=j-1|0;g=b&1;if((j|0)!=2){d=b&-2;f=0;while(1){t=s+(c<<4)|0;n=t-16|0;m=H[n+4>>2];b=H[n>>2];H[t+16>>2]=b;H[t+20>>2]=m;H[t>>2]=b;H[t+4>>2]=m;m=H[n+12>>2];b=H[n+8>>2];H[t+24>>2]=b;H[t+28>>2]=m;H[t+8>>2]=b;H[t+12>>2]=m;c=c+2|0;f=f+2|0;if((d|0)!=(f|0)){continue}break}}if(!g){break wd}d=s+(c<<4)|0;c=d-16|0;b=H[c+4>>2];H[d>>2]=H[c>>2];H[d+4>>2]=b;b=H[c+12>>2];H[d+8>>2]=H[c+8>>2];H[d+12>>2]=b}H[e+24>>2]=h;H[e+20>>2]=h;H[e+16>>2]=s}b=H[H[l>>2]+540>>2];H[197455]=0;ga(b|0,l|0,q|0,e+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break jd}b=H[e+16>>2];if(b){H[e+20>>2]=b;Kb(b)}if(!o){break nd}H[e+4>>2]=o;Kb(o)}b=H[p+28>>2];if(b){c=H[a+120>>2];H[197455]=0;if(H[c+8>>2]==(b+4|0)){H[c+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break id}}b=H[a+120>>2];H[197455]=0;if((i|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break id}F[a+213|0]=1}Kb(u)}xb=e+80|0;break ad}l=$()|0;_()|0;Kb(o);break dd}l=$()|0;_()|0;a=H[e+16>>2];if(a){H[e+20>>2]=a;Kb(a)}if(!o){break cd}break fd}l=$()|0;_()|0;break cd}H[197455]=0;ia(1869,e- -64|0);a=H[197455];H[197455]=0;if((a|0)!=1){break bd}}l=$()|0;_()|0;a=H[e+64>>2];if(!a){break fd}H[e+68>>2]=a;Kb(a)}H[e+4>>2]=o;Kb(o);break cd}l=$()|0;_()|0;a=H[e+64>>2];if(!a){break dd}H[e+68>>2]=a;Kb(a)}H[e+36>>2]=v;Kb(v)}Kb(u);break c}X()}if(t&16384){s=j&65535;e=xb-80|0;xb=e;xd:{yd:{zd:{Ad:{Bd:{Cd:{Dd:{Ed:{Fd:{g=H[a>>2]-12|0;b=H[g>>2]+a|0;c=H[b+8>>2];Gd:{if(c+3>>>0>=K[b+12>>2]){break Gd}h=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4;if(!h){break Gd}H[e+56>>2]=0;H[e+48>>2]=0;H[e+52>>2]=0;if(h>>>0>=1073741824){H[197455]=0;ia(1808,e+48|0);a=H[197455];H[197455]=0;if((a|0)==1){break g}break xd}H[197455]=0;c=h<<2;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break g}t=s&255;H[e+48>>2]=d;q=c+d|0;H[e+56>>2]=q;f=0;v=Nb(d,0,c);H[e+52>>2]=q;l=a+4|0;while(1){i=v+(f<<2)|0;m=l+H[g>>2]|0;b=H[m+4>>2];c=H[m+8>>2];Hd:{if(b+1>>>0>=c>>>0){d=0;break Hd}d=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[m+4>>2]=b}G[i>>1]=d;d=0;if(c>>>0>b+1>>>0){d=I[b|0]|I[b+1|0]<<8;H[m+4>>2]=b+2}G[i+2>>1]=d;f=f+1|0;if((h|0)!=(f|0)){continue}break}c=a+236|0;f=H[c>>2];Id:{if(!f){break Id}b=c;while(1){d=t>>>0>K[f+16>>2];b=d?b:f;f=H[(d<<2)+f>>2];if(f){continue}break}if((b|0)==(c|0)|t>>>0>2]){break Id}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Dd}if((d|0)!=2){break Id}p=H[b+20>>2];if(!p){break Id}b=H[a+120>>2];H[197455]=0;n=p+4|0;H[b+12>>2]=n;b=H[197455];H[197455]=0;if((b|0)==1){break Dd}c=H[p+28>>2];if(c){b=H[a+120>>2];H[197455]=0;H[b+8>>2]=c+4;b=H[197455];H[197455]=0;if((b|0)==1){break Dd}}H[e+40>>2]=0;H[e+32>>2]=0;H[e+36>>2]=0;Jd:{Kd:{Ld:{Md:{Nd:{Od:{Pd:{h=(q|0)==(v|0);if(!h){Qd:{o=q-v|0;Rd:{if((o|0)<0){H[197455]=0;ia(1808,e+32|0);a=H[197455];H[197455]=0;if((a|0)!=1){break xd}break Rd}H[197455]=0;c=aa(899,o|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Qd}}f=$()|0;_()|0;a=H[e+32>>2];if(!a){break yd}H[e+36>>2]=a;Kb(a);break yd}H[e+32>>2]=c;i=o>>2;H[e+40>>2]=c+(i<<2);q=Ob(c,v,o);if(o){H[e+72>>2]=0;H[e+64>>2]=0;H[e+68>>2]=0;c=(o+q|0)-q|0;if(c>>>0>=1073741821){H[197455]=0;ia(1869,e- -64|0);a=H[197455];H[197455]=0;if((a|0)!=1){break xd}break Ad}H[197455]=0;u=aa(899,c<<2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Ad}m=c>>2;b=m>>>0>1?m:1;g=b&1;f=0;if(c>>>0>=8){l=b&-2;b=0;while(1){d=u+(f<<4)|0;c=q+(f<<2)|0;M[d>>3]=G[c>>1];M[d+8>>3]=G[c+2>>1];c=f|1;d=u+(c<<4)|0;c=q+(c<<2)|0;M[d>>3]=G[c>>1];M[d+8>>3]=G[c+2>>1];f=f+2|0;b=b+2|0;if((l|0)!=(b|0)){continue}break}}if(g){c=u+(f<<4)|0;b=q+(f<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1]}c=m<<4;if(c){w=M[u+8>>3];r=M[u>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Fd}b=(c+u|0)-u|0;if(b>>>0>=17){b=b>>4;c=b>>>0>2?b:2;f=1;while(1){b=u+(f<<4)|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Fd}f=f+1|0;if((c|0)!=(f|0)){continue}break}}if(s&8192){H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break Fd}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break Fd}}Kb(u)}H[e+36>>2]=q;Kb(q);m=H[a+208>>2];if(!m){break Jd}d=0;H[e+8>>2]=0;H[e>>2]=0;H[e+4>>2]=0;if(h){break Md}if((o|0)>=0){break Pd}H[197455]=0;ia(1808,e|0);a=H[197455];H[197455]=0;if((a|0)!=1){break xd}break Od}m=H[a+208>>2];if(!m){break Jd}d=0;H[e+8>>2]=0;H[e>>2]=0;H[e+4>>2]=0;break Md}H[197455]=0;d=aa(899,o|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Nd}}f=$()|0;_()|0;d=H[e>>2];if(d){break Bd}break yd}H[e>>2]=d;H[e+8>>2]=(i<<2)+d;s=Ob(d,v,o);b=s+o|0;H[e+4>>2]=b;if(o){break Ld}}H[e+24>>2]=0;H[e+16>>2]=0;H[e+20>>2]=0;break Kd}H[e+72>>2]=0;H[e+64>>2]=0;H[e+68>>2]=0;c=b-s|0;if(c>>>0>=1073741821){H[197455]=0;ia(1869,e- -64|0);a=H[197455];H[197455]=0;if((a|0)!=1){break xd}break Cd}H[197455]=0;q=aa(899,c<<2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Cd}h=c>>2;b=h>>>0>1?h:1;i=b&1;f=0;if(c>>>0>=8){g=b&-2;b=0;while(1){l=q+(f<<4)|0;c=s+(f<<2)|0;M[l>>3]=G[c>>1];M[l+8>>3]=G[c+2>>1];c=f|1;l=q+(c<<4)|0;c=s+(c<<2)|0;M[l>>3]=G[c>>1];M[l+8>>3]=G[c+2>>1];f=f+2|0;b=b+2|0;if((g|0)!=(b|0)){continue}break}}if(i){c=q+(f<<4)|0;b=s+(f<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1]}H[e+16>>2]=q;b=q+(h<<4)|0;H[e+24>>2]=b;H[e+20>>2]=b}b=H[H[m>>2]+540>>2];H[197455]=0;ga(b|0,m|0,t|0,e+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ed}b=H[e+16>>2];if(b){H[e+20>>2]=b;Kb(b)}if(!d){break Jd}H[e+4>>2]=d;Kb(d)}b=H[p+28>>2];if(b){c=H[a+120>>2];H[197455]=0;if(H[c+8>>2]==(b+4|0)){H[c+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Dd}}b=H[a+120>>2];H[197455]=0;if((n|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Dd}F[a+213|0]=1}Kb(v)}xb=e+80|0;break ad}f=$()|0;_()|0;Kb(u);break zd}f=$()|0;_()|0;a=H[e+16>>2];if(a){H[e+20>>2]=a;Kb(a)}if(!d){break yd}break Bd}f=$()|0;_()|0;break yd}f=$()|0;_()|0;a=H[e+64>>2];if(!a){break Bd}H[e+68>>2]=a;Kb(a)}H[e+4>>2]=d;Kb(d);break yd}f=$()|0;_()|0;a=H[e+64>>2];if(!a){break zd}H[e+68>>2]=a;Kb(a)}H[e+36>>2]=q;Kb(q)}Kb(v);break a}X()}n=j&65535;E=xb-80|0;xb=E;Sd:{Td:{Ud:{Vd:{Wd:{Xd:{Yd:{Zd:{_d:{$d:{l=H[a>>2]-12|0;b=H[l>>2]+a|0;c=H[b+8>>2];ae:{if(c+3>>>0>=K[b+12>>2]){break ae}i=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4;if(!i){break ae}H[E+56>>2]=0;H[E+48>>2]=0;H[E+52>>2]=0;be:{ce:{if(i>>>0>=268435456){H[197455]=0;ia(1869,E+48|0);a=H[197455];H[197455]=0;if((a|0)==1){break ce}break Td}H[197455]=0;c=i<<4;v=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break be}}a=$()|0;_()|0;b=H[E+48>>2];if(b){H[E+52>>2]=b;Kb(b)}break d}q=n&255;H[E+48>>2]=v;f=c+v|0;H[E+56>>2]=f;H[E+52>>2]=f;e=a+4|0;k=0;while(1){c=v+(k<<4)|0;g=e+H[l>>2]|0;b=H[g+4>>2];d=H[g+8>>2];if(b+3>>>0>=d>>>0){r=0}else{y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());b=b+4|0;H[g+4>>2]=b;r=+y}M[c>>3]=r;if(d>>>0>b+3>>>0){y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());H[g+4>>2]=b+4;r=+y}else{r=0}M[c+8>>3]=r;k=k+1|0;if((i|0)!=(k|0)){continue}break}c=a+236|0;k=H[c>>2];de:{if(!k){break de}b=c;while(1){d=q>>>0>K[k+16>>2];b=d?b:k;k=H[(d<<2)+k>>2];if(k){continue}break}if((b|0)==(c|0)|q>>>0>2]){break de}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Zd}if((d|0)!=2){break de}p=H[b+20>>2];if(!p){break de}b=H[a+120>>2];H[197455]=0;i=p+4|0;H[b+12>>2]=i;b=H[197455];H[197455]=0;if((b|0)==1){break Zd}c=H[p+28>>2];if(c){b=H[a+120>>2];H[197455]=0;H[b+8>>2]=c+4;b=H[197455];H[197455]=0;if((b|0)==1){break Zd}}H[E+40>>2]=0;H[E+32>>2]=0;H[E+36>>2]=0;ee:{fe:{ge:{he:{ie:{je:{ke:{g=(f|0)==(v|0);if(!g){le:{u=f-v|0;me:{if((u|0)<0){H[197455]=0;ia(1869,E+32|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Td}break me}H[197455]=0;c=aa(899,u|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break le}}k=$()|0;_()|0;a=H[E+32>>2];if(!a){break Ud}H[E+36>>2]=a;Kb(a);break Ud}H[E+32>>2]=c;l=u>>4;H[E+40>>2]=c+(l<<4);o=Ob(c,v,u);if(u){H[E+72>>2]=0;H[E+64>>2]=0;H[E+68>>2]=0;c=(o+u|0)-o|0;if((c|0)<0){H[197455]=0;ia(1869,E- -64|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Td}break Wd}H[197455]=0;j=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Wd}m=c>>4;b=m>>>0>1?m:1;f=b&3;d=0;k=0;if(b-1>>>0>=3){e=b&-4;h=0;while(1){t=k<<4;c=t+j|0;s=o+t|0;b=H[s+4>>2];H[c>>2]=H[s>>2];H[c+4>>2]=b;b=H[s+12>>2];H[c+8>>2]=H[s+8>>2];H[c+12>>2]=b;b=t|16;c=b+j|0;s=b+o|0;b=H[s+12>>2];H[c+8>>2]=H[s+8>>2];H[c+12>>2]=b;b=H[s+4>>2];H[c>>2]=H[s>>2];H[c+4>>2]=b;b=t|32;c=b+j|0;s=b+o|0;b=H[s+12>>2];H[c+8>>2]=H[s+8>>2];H[c+12>>2]=b;b=H[s+4>>2];H[c>>2]=H[s>>2];H[c+4>>2]=b;b=t|48;c=b+j|0;s=b+o|0;b=H[s+12>>2];H[c+8>>2]=H[s+8>>2];H[c+12>>2]=b;b=H[s+4>>2];H[c>>2]=H[s>>2];H[c+4>>2]=b;k=k+4|0;h=h+4|0;if((e|0)!=(h|0)){continue}break}}if(f){while(1){b=k<<4;c=b+j|0;e=b+o|0;b=H[e+4>>2];H[c>>2]=H[e>>2];H[c+4>>2]=b;b=H[e+12>>2];H[c+8>>2]=H[e+8>>2];H[c+12>>2]=b;k=k+1|0;d=d+1|0;if((f|0)!=(d|0)){continue}break}}c=m<<4;if(c){w=M[j+8>>3];r=M[j>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break $d}b=(c+j|0)-j|0;if(b>>>0>=17){b=b>>4;c=b>>>0>2?b:2;k=1;while(1){b=j+(k<<4)|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break $d}k=k+1|0;if((c|0)!=(k|0)){continue}break}}if(n&8192){H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break $d}}H[197455]=0;ka(1872,a|0,1,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break $d}}Kb(j)}H[E+36>>2]=o;Kb(o);j=H[a+208>>2];if(!j){break ee}f=0;H[E+8>>2]=0;H[E>>2]=0;H[E+4>>2]=0;if(g){break he}if((u|0)>=0){break ke}H[197455]=0;ia(1869,E|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Td}break je}j=H[a+208>>2];if(!j){break ee}f=0;H[E+8>>2]=0;H[E>>2]=0;H[E+4>>2]=0;break he}H[197455]=0;f=aa(899,u|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break ie}}k=$()|0;_()|0;f=H[E>>2];if(f){break Xd}break Ud}H[E>>2]=f;H[E+8>>2]=(l<<4)+f;s=Ob(f,v,u);b=s+u|0;H[E+4>>2]=b;if(u){break ge}}H[E+24>>2]=0;H[E+16>>2]=0;H[E+20>>2]=0;break fe}H[E+72>>2]=0;H[E+64>>2]=0;H[E+68>>2]=0;c=b-s|0;if((c|0)<0){H[197455]=0;ia(1869,E- -64|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Td}break Yd}H[197455]=0;t=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Yd}g=c>>4;b=g>>>0>1?g:1;l=b&3;d=0;k=0;if(b-1>>>0>=3){e=b&-4;h=0;while(1){n=k<<4;c=n+t|0;m=n+s|0;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=n|16;c=b+t|0;m=b+s|0;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;b=n|32;c=b+t|0;m=b+s|0;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;b=n|48;c=b+t|0;m=b+s|0;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;k=k+4|0;h=h+4|0;if((e|0)!=(h|0)){continue}break}}if(l){while(1){b=k<<4;c=b+t|0;e=b+s|0;b=H[e+4>>2];H[c>>2]=H[e>>2];H[c+4>>2]=b;b=H[e+12>>2];H[c+8>>2]=H[e+8>>2];H[c+12>>2]=b;k=k+1|0;d=d+1|0;if((l|0)!=(d|0)){continue}break}}H[E+16>>2]=t;b=t+(g<<4)|0;H[E+24>>2]=b;H[E+20>>2]=b}b=H[H[j>>2]+540>>2];H[197455]=0;ga(b|0,j|0,q|0,E+16|0);b=H[197455];H[197455]=0;if((b|0)==1){break _d}b=H[E+16>>2];if(b){H[E+20>>2]=b;Kb(b)}if(!f){break ee}H[E+4>>2]=f;Kb(f)}b=H[p+28>>2];if(b){c=H[a+120>>2];H[197455]=0;if(H[c+8>>2]==(b+4|0)){H[c+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Zd}}b=H[a+120>>2];H[197455]=0;if((i|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Zd}F[a+213|0]=1}Kb(v)}xb=E+80|0;break Sd}k=$()|0;_()|0;Kb(j);break Vd}k=$()|0;_()|0;a=H[E+16>>2];if(a){H[E+20>>2]=a;Kb(a)}if(!f){break Ud}break Xd}k=$()|0;_()|0;break Ud}k=$()|0;_()|0;a=H[E+64>>2];if(!a){break Xd}H[E+68>>2]=a;Kb(a)}H[E+4>>2]=f;Kb(f);break Ud}k=$()|0;_()|0;a=H[E+64>>2];if(!a){break Vd}H[E+68>>2]=a;Kb(a)}H[E+36>>2]=o;Kb(o)}Kb(v);ea(k|0);X()}X()}}F[a+213|0]=1;break k;case 20:v=0;f=xb-48|0;xb=f;b=H[H[a>>2]-12>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){v=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}b=j&65535;ne:{oe:{pe:{qe:{re:{c=a+236|0;e=H[c>>2];se:{te:{if(!e){break te}g=b&255;b=c;while(1){d=g>>>0>K[e+16>>2];b=d?b:e;e=H[(d<<2)+e>>2];if(e){continue}break}if((b|0)==(c|0)|g>>>0>2]){break te}d=H[b+20>>2];if((zb[H[H[d>>2]+12>>2]](d)|0)!=3){break te}l=H[b+20>>2];if(!l){break te}e=H[c>>2];if(!e){break se}b=c;while(1){d=K[e+16>>2]>>0;b=d?b:e;e=H[(d<<2)+e>>2];if(e){continue}break}if((b|0)==(c|0)|K[b+16>>2]>v>>>0){break se}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break se}e=H[b+20>>2];if(!e){break se}d=e+4|0;H[H[a+120>>2]+12>>2]=d;b=H[e+28>>2];if(b){H[H[a+120>>2]+8>>2]=b+4}b=f+40|0;H[b>>2]=399272;H[197455]=0;m=f+24|0;H[m+4>>2]=0;H[m+8>>2]=0;H[m+12>>2]=0;H[m>>2]=424816;c=H[197455];H[197455]=0;ue:{if((c|0)!=1){H[197455]=0;i=f+8|0;H[i+4>>2]=0;H[i+8>>2]=0;H[i+12>>2]=0;H[i>>2]=424816;c=H[197455];H[197455]=0;if((c|0)==1){break re}H[197455]=0;wa(1882,b|0,m|0,i|0,l+4|0,e|0);b=H[197455];H[197455]=0;if((b|0)==1){break qe}b=H[a+208>>2];H[197455]=0;ka(1883,m|0,b|0,1,0);b=H[197455];H[197455]=0;if((b|0)==1){break qe}b=H[a+208>>2];H[197455]=0;ka(1883,i|0,b|0,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break qe}c=H[a+208>>2];if(!c){break ue}b=H[H[c>>2]+544>>2];H[197455]=0;ka(b|0,c|0,g|0,v|0,m|0);b=H[197455];H[197455]=0;if((b|0)!=1){break ue}break qe}e=$()|0;_()|0;break oe}b=H[e+28>>2];if(b){c=H[a+120>>2];H[197455]=0;if(H[c+8>>2]==(b+4|0)){H[c+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break qe}}b=H[a+120>>2];H[197455]=0;if((d|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break qe}oe(i);oe(m)}F[a+213|0]=1}xb=f+48|0;break ne}e=$()|0;_()|0;break pe}e=$()|0;_()|0;oe(i)}oe(m)}ea(e|0);X()}break k;case 16:ve:{if(j&16384){c=j&65535;J=0;z=0;D=0;e=xb-32|0;xb=e;d=H[a>>2]-12|0;b=H[d>>2]+a|0;k=b+8|0;j=H[k>>2];f=H[b+12>>2];if(f>>>0<=j+3>>>0){A=0}else{y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[b+8>>2]=j+4;b=H[d>>2]+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2];A=+y}if(j+3>>>0>>0){y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[k>>2]=j+4;b=H[d>>2]+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2];D=+y}if(j+1>>>0>=f>>>0){w=0}else{b=(I[j|0]|I[j+1|0]<<8)<<16>>16;j=j+2|0;H[k>>2]=j;w=+(b|0)}if(j+1>>>0>>0){b=(I[j|0]|I[j+1|0]<<8)<<16>>16;j=j+2|0;H[k>>2]=j;J=+(b|0)}if(j+1>>>0>=f>>>0){r=0}else{b=(I[j|0]|I[j+1|0]<<8)<<16>>16;j=j+2|0;H[k>>2]=j;r=+(b|0)}if(j+1>>>0>>0){b=(I[j|0]|I[j+1|0]<<8)<<16>>16;H[k>>2]=j+2;z=+(b|0)}b=H[a+208>>2];if(b){M[e+24>>3]=z;M[e+16>>3]=r;M[e+8>>3]=J;M[e>>3]=w;zb[H[H[b>>2]+548>>2]](b,c&255,A,D,e)}xb=e+32|0;break ve}d=j&65535;D=0;l=xb+-64|0;xb=l;H[l+56>>2]=0;H[l+60>>2]=0;H[l+48>>2]=0;H[l+52>>2]=0;H[l+40>>2]=0;H[l+44>>2]=0;H[l+32>>2]=0;H[l+36>>2]=0;e=H[a>>2]-12|0;f=H[e>>2];b=f+a|0;h=b+8|0;j=H[h>>2];c=H[b+12>>2];if(c>>>0<=j+3>>>0){r=0}else{y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[b+8>>2]=j+4;f=H[e>>2];b=f+a|0;c=H[b+12>>2];h=b+8|0;j=H[h>>2];r=+y}if(j+3>>>0>>0){y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[h>>2]=j+4;D=+y;f=H[e>>2]}Ae((f+a|0)+4|0,l+32|0);b=H[a+208>>2];if(b){M[l+24>>3]=M[l+56>>3];M[l+16>>3]=M[l+48>>3];M[l+8>>3]=M[l+40>>3];M[l>>3]=M[l+32>>3];zb[H[H[b>>2]+548>>2]](b,d&255,r,D,l)}xb=l- -64|0}F[a+213|0]=1;break k;case 10:we:{if(j&16384){b=j&65535;s=xb-16|0;xb=s;xe:{ye:{ze:{Ae:{c=H[H[a>>2]-12>>2]+a|0;d=H[c+8>>2];Be:{if(d+3>>>0>=K[c+12>>2]){break Be}e=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[c+8>>2]=d+4;if(!e){break Be}c=a+236|0;f=H[c>>2];if(!f){break Be}h=b&255;b=c;while(1){d=h>>>0>K[f+16>>2];b=d?b:f;f=H[(d<<2)+f>>2];if(f){continue}break}if((b|0)==(c|0)|h>>>0>2]){break Be}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break Be}i=H[b+20>>2];if(!i){break Be}g=i+4|0;H[H[a+120>>2]+12>>2]=g;b=H[i+28>>2];if(b){H[H[a+120>>2]+8>>2]=b+4}H[s+8>>2]=0;H[s>>2]=0;H[s+4>>2]=0;Ce:{De:{if(e>>>0>=134217728){H[197455]=0;ia(1884,s|0);a=H[197455];H[197455]=0;if((a|0)==1){break De}X()}H[197455]=0;c=e<<5;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Ce}}f=$()|0;_()|0;a=H[s>>2];if(!a){break xe}H[s+4>>2]=a;Kb(a);break xe}H[s>>2]=d;b=c+d|0;H[s+8>>2]=b;Nb(d,0,c);H[s+4>>2]=b;l=e>>>0>1?e:1;c=a+4|0;v=0;while(1){n=c+H[H[a>>2]-12>>2]|0;b=H[n+4>>2];f=H[n+8>>2];Ee:{if(b+1>>>0>=f>>>0){m=0;break Ee}m=(I[b|0]|I[b+1|0]<<8)<<16>>16;b=b+2|0;H[n+4>>2]=b}e=0;Fe:{if(f>>>0<=b+1>>>0){j=0;break Fe}j=(I[b|0]|I[b+1|0]<<8)<<16>>16;b=b+2|0;H[n+4>>2]=b}if(f>>>0>b+1>>>0){e=(I[b|0]|I[b+1|0]<<8)<<16>>16;b=b+2|0;H[n+4>>2]=b}k=0;if(f>>>0>b+1>>>0){k=(I[b|0]|I[b+1|0]<<8)<<16>>16;H[n+4>>2]=b+2}b=v<<5;d=b+d|0;M[d+24>>3]=k<<16>>16;M[d+16>>3]=e<<16>>16;M[d+8>>3]=j<<16>>16;M[d>>3]=m<<16>>16;H[197455]=0;d=H[s>>2];ka(1885,a|0,b+d|0,1,0);b=H[197455];H[197455]=0;if((b|0)==1){break ze}v=v+1|0;if((l|0)!=(v|0)){continue}break}c=H[a+208>>2];if(c){b=H[H[c>>2]+552>>2];H[197455]=0;ga(b|0,c|0,h|0,s|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ae}}b=H[i+28>>2];if(b){c=H[a+120>>2];H[197455]=0;if(H[c+8>>2]==(b+4|0)){H[c+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Ae}}b=H[a+120>>2];H[197455]=0;if((g|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Ae}b=H[s>>2];if(!b){break Be}H[s+4>>2]=b;Kb(b)}xb=s+16|0;break we}f=$()|0;_()|0;d=H[s>>2];break ye}f=$()|0;_()|0}if(!d){break xe}H[s+4>>2]=d;Kb(d);break a}break a}b=j&65535;m=xb-48|0;xb=m;Ge:{He:{Ie:{Je:{Ke:{c=H[H[a>>2]-12>>2]+a|0;d=H[c+8>>2];Le:{if(d+3>>>0>=K[c+12>>2]){break Le}e=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[c+8>>2]=d+4;if(!e){break Le}c=a+236|0;k=H[c>>2];if(!k){break Le}i=b&255;b=c;while(1){d=i>>>0>K[k+16>>2];b=d?b:k;k=H[(d<<2)+k>>2];if(k){continue}break}if((b|0)==(c|0)|i>>>0>2]){break Le}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=2){break Le}f=H[b+20>>2];if(!f){break Le}l=f+4|0;H[H[a+120>>2]+12>>2]=l;b=H[f+28>>2];if(b){H[H[a+120>>2]+8>>2]=b+4}H[m+40>>2]=0;H[m+32>>2]=0;H[m+36>>2]=0;Me:{Ne:{if(e>>>0>=134217728){H[197455]=0;ia(1884,m+32|0);a=H[197455];H[197455]=0;if((a|0)==1){break Ne}X()}H[197455]=0;c=e<<5;k=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Me}}b=$()|0;_()|0;a=H[m+32>>2];if(!a){break He}H[m+36>>2]=a;Kb(a);break He}H[m+32>>2]=k;b=c+k|0;H[m+40>>2]=b;Nb(k,0,c);H[m+36>>2]=b;H[m+24>>2]=0;H[m+28>>2]=0;H[m+16>>2]=0;H[m+20>>2]=0;H[m+8>>2]=0;H[m+12>>2]=0;H[m>>2]=0;H[m+4>>2]=0;e=e>>>0>1?e:1;d=a+4|0;b=0;while(1){c=H[H[a>>2]-12>>2];H[197455]=0;Ae(c+d|0,m);c=H[197455];H[197455]=0;if((c|0)==1){break Je}A=M[m>>3];w=M[m+8>>3];r=M[m+16>>3];c=b<<5;g=c+k|0;M[g+24>>3]=M[m+24>>3];M[g+16>>3]=r;M[g+8>>3]=w;M[g>>3]=A;H[197455]=0;k=H[m+32>>2];ka(1885,a|0,c+k|0,1,0);c=H[197455];H[197455]=0;if((c|0)==1){break Je}b=b+1|0;if((e|0)!=(b|0)){continue}break}c=H[a+208>>2];if(c){b=H[H[c>>2]+552>>2];H[197455]=0;ga(b|0,c|0,i|0,m+32|0);b=H[197455];H[197455]=0;if((b|0)==1){break Ke}}b=H[f+28>>2];if(b){c=H[a+120>>2];H[197455]=0;if(H[c+8>>2]==(b+4|0)){H[c+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Ke}}b=H[a+120>>2];H[197455]=0;if((l|0)==H[b+12>>2]){H[b+12>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Ke}b=H[m+32>>2];if(!b){break Le}H[m+36>>2]=b;Kb(b)}xb=m+48|0;break Ge}b=$()|0;_()|0;k=H[m+32>>2];break Ie}b=$()|0;_()|0}if(!k){break He}H[m+36>>2]=k;Kb(k);ea(b|0);X()}ea(b|0);X()}}F[a+213|0]=1;break k;case 27:u=0;e=0;n=xb-80|0;xb=n;H[n+72>>2]=0;H[n+76>>2]=0;b=n- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[n+56>>2]=0;H[n+60>>2]=0;H[n+48>>2]=0;H[n+52>>2]=0;d=H[a>>2]-12|0;c=H[d>>2]+a|0;o=c+8|0;h=H[o>>2];b=H[c+12>>2];if(b>>>0>h+3>>>0){u=I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24);H[c+8>>2]=h+4;c=H[d>>2]+a|0;b=H[c+12>>2];o=c+8|0;h=H[o>>2]}if(h+3>>>0>>0){e=I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24);H[o>>2]=h+4;c=H[d>>2]+a|0;b=H[c+12>>2];o=c+8|0;h=H[o>>2]}f=j&65535;Oe:{Pe:{Qe:{if(h+3>>>0>=b>>>0){break Qe}m=I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24);H[o>>2]=h+4;if(!m){break Qe}Ae((H[d>>2]+a|0)+4|0,n+48|0);c=m+1|0;b=c+c|0;i=Qb(b>>>0>>0?-1:b);G[i+(m<<1)>>1]=0;g=H[H[a>>2]-12>>2]+a|0;l=H[g+12>>2];b=H[g+8>>2];c=(l-b|0)/2|0;d=c>>>0>>0?c:m;Re:{if(!d){break Re}if(l>>>0>b+1>>>0){h=0;if((d|0)!=1){c=d&-2;v=0;while(1){Se:{if(l>>>0<=b+1>>>0){o=0;break Se}o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[g+8>>2]=b}G[i+(h<<1)>>1]=o;o=0;if(l>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[g+8>>2]=b}G[i+((h|1)<<1)>>1]=o;h=h+2|0;v=v+2|0;if((c|0)!=(v|0)){continue}break}}if(!(d&1)){break Re}o=0;if(l>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;H[g+8>>2]=b+2}G[i+(h<<1)>>1]=o;break Re}Nb(i,0,d<<1)}H[n+40>>2]=0;H[n+32>>2]=0;H[n+36>>2]=0;H[197455]=0;ga(1887,n+16|0,i|0,m|0);b=H[197455];H[197455]=0;if((b|0)==1){break Pe}H[n+40>>2]=H[n+24>>2];b=H[n+20>>2];H[n+32>>2]=H[n+16>>2];H[n+36>>2]=b;Kb(i);Te:{if(!H[a+208>>2]){break Te}c=a+236|0;h=H[c>>2];if(!h){break Te}i=f&255;b=c;while(1){d=i>>>0>K[h+16>>2];b=d?b:h;h=H[(d<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|i>>>0>2]){break Te}l=H[b+20>>2];d=H[H[l>>2]+12>>2];H[197455]=0;l=aa(d|0,l|0)|0;d=H[197455];H[197455]=0;if((d|0)==1){break Pe}if((l|0)!=6){break Te}d=H[b+20>>2];if(!d){break Te}b=H[a+120>>2];v=0;H[197455]=0;g=d+4|0;H[b+16>>2]=g;b=H[197455];H[197455]=0;if((b|0)==1){break Pe}h=H[c>>2];Ue:{if(!h){break Ue}b=c;while(1){d=K[h+16>>2]>>0;b=d?b:h;h=H[(d<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|K[b+16>>2]>e>>>0){break Ue}l=H[b+20>>2];d=H[H[l>>2]+12>>2];H[197455]=0;l=aa(d|0,l|0)|0;d=H[197455];H[197455]=0;if((d|0)==1){break Pe}if((l|0)!=7){break Ue}v=H[b+20>>2]}b=H[a+120>>2];H[197455]=0;l=H[b+600>>2];b=H[197455];H[197455]=0;if((b|0)==1){break Pe}Ve:{if(!v){break Ve}h=0;We:{Xe:{switch(H[v+8>>2]-1|0){case 0:M[n+48>>3]=M[n+48>>3]+M[n+64>>3]*.5;h=6;break We;case 1:break Xe;default:break We}}M[n+48>>3]=M[n+64>>3]+M[n+48>>3];h=2}Ye:{Ze:{_e:{switch(H[v+12>>2]-1|0){case 0:D=M[n+72>>3]*.5;z=M[n+56>>3];h=h|1536;break Ze;case 1:break _e;default:break Ye}}D=M[n+56>>3];z=M[n+72>>3];h=h|512}M[n+56>>3]=z+D}b=H[a+120>>2];H[197455]=0;H[b+600>>2]=h;b=H[197455];H[197455]=0;if((b|0)!=1){break Ve}break Pe}$e:{if(f<<16>>16<0){F[n+19|0]=u>>>24;F[n+16|0]=u>>>16;b=u<<8|(u&65280)>>>8;F[n+17|0]=b;F[n+18|0]=b>>>8;c=H[a+120>>2];H[197455]=0;b=H[197455];H[197455]=0;if((b|0)==1){break Pe}H[n+12>>2]=I[c+592|0]|I[c+593|0]<<8|(I[c+594|0]<<16|I[c+595|0]<<24);b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[n+16|0];F[b+593|0]=I[n+17|0];F[b+594|0]=I[n+18|0];F[b+595|0]=I[n+19|0];b=H[197455];H[197455]=0;if((b|0)==1){break Pe}c=H[a+208>>2];b=H[H[c>>2]+20>>2];H[197455]=0;d=b;b=I[n+43|0];Qa(d|0,c|0,n+32|0,(b<<24>>24<0?H[n+36>>2]:b)|0,+M[n+48>>3],+M[n+56>>3],0,2,1,1);break $e}h=H[c>>2];if(!h){break Te}b=c;while(1){d=K[h+16>>2]>>0;b=d?b:h;h=H[(d<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|K[b+16>>2]>u>>>0){break Te}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Pe}if((d|0)!=1){break Te}b=H[b+20>>2];if(!b){break Te}F[n+18|0]=I[b+8|0];F[n+17|0]=I[b+9|0];F[n+16|0]=I[b+10|0];F[n+19|0]=I[b+11|0];c=H[a+120>>2];H[197455]=0;b=H[197455];H[197455]=0;if((b|0)==1){break Pe}H[n+12>>2]=I[c+592|0]|I[c+593|0]<<8|(I[c+594|0]<<16|I[c+595|0]<<24);b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[n+16|0];F[b+593|0]=I[n+17|0];F[b+594|0]=I[n+18|0];F[b+595|0]=I[n+19|0];b=H[197455];H[197455]=0;if((b|0)==1){break Pe}c=H[a+208>>2];b=H[H[c>>2]+20>>2];H[197455]=0;d=b;b=I[n+43|0];r=M[n+48>>3];Qa(d|0,c|0,n+32|0,(b<<24>>24<0?H[n+36>>2]:b)|0,+r,+r,0,2,1,1)}b=H[197455];H[197455]=0;if((b|0)==1){break Pe}c=H[a+208>>2];if(c){b=H[H[c>>2]+556>>2];H[197455]=0;Fa(b|0,c|0,i|0,u|0,e|0,n+32|0,n+48|0);b=H[197455];H[197455]=0;if((b|0)==1){break Pe}}b=H[a+120>>2];H[197455]=0;F[b+592|0]=I[n+12|0];F[b+593|0]=I[n+13|0];F[b+594|0]=I[n+14|0];F[b+595|0]=I[n+15|0];b=H[197455];H[197455]=0;if((b|0)==1){break Pe}b=H[a+120>>2];H[197455]=0;H[b+600>>2]=l;b=H[197455];H[197455]=0;if((b|0)==1){break Pe}b=H[a+120>>2];H[197455]=0;if((g|0)==H[b+16>>2]){H[b+16>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Pe}F[a+213|0]=1}if(F[n+43|0]>=0){break Qe}Kb(H[n+32>>2])}xb=n+80|0;break Oe}a=$()|0;_()|0;if(F[n+43|0]<0){Kb(H[n+32>>2])}break d}break k;case 21:b=j&65535;af:{if(j&2048){f=xb-16|0;xb=f;d=H[a>>2]-12|0;b=H[d>>2]+a|0;h=b+8|0;k=H[h>>2];c=H[b+12>>2];if(c>>>0>k+3>>>0){H[b+8>>2]=k+4;b=H[d>>2]+a|0;c=H[b+12>>2];h=b+8|0;k=H[h>>2]}if(k+3>>>0>>0){H[h>>2]=k+4;b=H[d>>2]+a|0;c=H[b+12>>2];h=b+8|0;k=H[h>>2]}bf:{cf:{if(k+3>>>0>=c>>>0){break cf}b=F[k+3|0];H[h>>2]=k+4;H[f+8>>2]=0;H[f>>2]=0;H[f+4>>2]=0;if((b|0)>=0){break cf}H[197455]=0;ia(1867,f|0);a=H[197455];H[197455]=0;if((a|0)!=1){break bf}break f}xb=f+16|0;break af}X()}if(b&16384){f=xb-16|0;xb=f;d=H[a>>2]-12|0;b=H[d>>2]+a|0;h=b+8|0;k=H[h>>2];c=H[b+12>>2];if(c>>>0>k+3>>>0){H[b+8>>2]=k+4;b=H[d>>2]+a|0;c=H[b+12>>2];h=b+8|0;k=H[h>>2]}if(k+3>>>0>>0){H[h>>2]=k+4;b=H[d>>2]+a|0;c=H[b+12>>2];h=b+8|0;k=H[h>>2]}df:{ef:{if(k+3>>>0>=c>>>0){break ef}b=I[k+3|0];H[h>>2]=k+4;H[f+8>>2]=0;H[f>>2]=0;H[f+4>>2]=0;if(b>>>0<64){break ef}H[197455]=0;ia(1808,f|0);a=H[197455];H[197455]=0;if((a|0)!=1){break df}break f}xb=f+16|0;break af}X()}f=xb-16|0;xb=f;d=H[a>>2]-12|0;b=H[d>>2]+a|0;h=b+8|0;k=H[h>>2];c=H[b+12>>2];if(c>>>0>k+3>>>0){H[b+8>>2]=k+4;b=H[d>>2]+a|0;c=H[b+12>>2];h=b+8|0;k=H[h>>2]}if(k+3>>>0>>0){H[h>>2]=k+4;b=H[d>>2]+a|0;c=H[b+12>>2];h=b+8|0;k=H[h>>2]}ff:{gf:{hf:{if(k+3>>>0>=c>>>0){break hf}b=I[k+3|0];H[h>>2]=k+4;H[f+8>>2]=0;H[f>>2]=0;H[f+4>>2]=0;if(b>>>0<16){break hf}H[197455]=0;ia(1869,f|0);a=H[197455];H[197455]=0;if((a|0)!=1){break gf}break f}xb=f+16|0;break ff}X()}}F[a+213|0]=1;break k;case 13:jf:{if(j&16384){h=0;o=0;u=0;n=xb-128|0;xb=n;c=H[a>>2]-12|0;e=H[c>>2]+a|0;f=e+8|0;b=H[f>>2];d=H[e+12>>2];if(d>>>0>b+3>>>0){h=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[e+8>>2]=b+4;b=H[c>>2]+a|0;d=H[b+12>>2];f=b+8|0;b=H[f>>2]}if(b+1>>>0>>0){o=(I[b|0]|I[b+1|0]<<8)<<16>>16;b=b+2|0;H[f>>2]=b}v=0;kf:{if(b+1>>>0>=d>>>0){m=0;break kf}m=(I[b|0]|I[b+1|0]<<8)<<16>>16;b=b+2|0;H[f>>2]=b}if(b+1>>>0>>0){v=(I[b|0]|I[b+1|0]<<8)<<16>>16;b=b+2|0;H[f>>2]=b}if(b+1>>>0>>0){u=(I[b|0]|I[b+1|0]<<8)<<16>>16;H[f>>2]=b+2}i=m<<16>>16;f=i+(u<<16>>16)|0;g=o<<16>>16;l=g+(v<<16>>16)|0;lf:{mf:{if((j&65535)<<16>>16<0){H[n+56>>2]=0;H[n+60>>2]=0;b=n- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[n+72>>2]=0;H[n+76>>2]=0;H[n+80>>2]=0;H[n+84>>2]=0;H[n+88>>2]=0;H[n+92>>2]=0;H[n+120>>2]=0;H[n+124>>2]=0;H[n+48>>2]=0;H[n+52>>2]=0;H[n+112>>2]=0;H[n+116>>2]=0;H[n+44>>2]=418012;H[n+40>>2]=417944;H[n+48>>2]=h;b=H[a+120>>2];H[197455]=0;d=n+40|4;H[b+8>>2]=d;b=H[197455];H[197455]=0;if((b|0)==1){break lf}b=H[a+120>>2];H[197455]=0;c=H[b+680>>2];b=H[197455];H[197455]=0;if((b|0)==1){break lf}H[197455]=0;b=(c|0)==1;Ya(1891,a|0,g|0,(b?i:f)|0,l|0,(b?f:i)|0,0,360);b=H[197455];H[197455]=0;if((b|0)==1){break lf}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break lf}nf:{c=H[a+208>>2];if(!c){break nf}M[n+32>>3]=u<<16>>16;M[n+24>>3]=v<<16>>16;M[n+16>>3]=m<<16>>16;M[n+8>>3]=o<<16>>16;b=H[H[c>>2]+564>>2];H[197455]=0;ga(b|0,c|0,h|0,n+8|0);b=H[197455];H[197455]=0;if((b|0)!=1){break nf}break lf}b=H[a+120>>2];H[197455]=0;if((d|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break lf}H[n+44>>2]=418012;H[n+40>>2]=417944;if(F[n+127|0]>=0){break mf}Kb(H[n+116>>2]);break mf}c=a+236|0;d=H[c>>2];if(!d){break mf}b=c;while(1){e=K[d+16>>2]>>0;b=e?b:d;d=H[(e<<2)+d>>2];if(d){continue}break}if((b|0)==(c|0)|K[b+16>>2]>h>>>0){break mf}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=1){break mf}b=H[b+20>>2];if(!b){break mf}c=b+4|0;H[H[a+120>>2]+8>>2]=c;of:{if(H[H[a+120>>2]+680>>2]==1){Sf(a,g,i,l,f,0,360);break of}Sf(a,g,f,l,i,0,360)}Rf(a,0,1,1);b=H[a+208>>2];if(b){M[n+64>>3]=u<<16>>16;M[n+56>>3]=v<<16>>16;M[n+48>>3]=m<<16>>16;M[n+40>>3]=o<<16>>16;zb[H[H[b>>2]+564>>2]](b,h,n+40|0)}b=H[a+120>>2];if((c|0)==H[b+8>>2]){H[b+8>>2]=0}}xb=n+128|0;break jf}a=$()|0;_()|0;H[n+44>>2]=418012;H[n+40>>2]=417944;if(F[n+127|0]<0){Kb(H[n+116>>2])}break d}d=j&65535;m=0;i=xb-160|0;xb=i;H[i+152>>2]=0;H[i+156>>2]=0;H[i+144>>2]=0;H[i+148>>2]=0;H[i+136>>2]=0;H[i+140>>2]=0;H[i+128>>2]=0;H[i+132>>2]=0;c=H[a>>2]-12|0;b=H[c>>2];e=b+a|0;l=H[e+8>>2];if(l+3>>>0>2]){m=I[l|0]|I[l+1|0]<<8|(I[l+2|0]<<16|I[l+3|0]<<24);H[e+8>>2]=l+4;b=H[c>>2]}Ae((a+b|0)+4|0,i+128|0);A=M[i+136>>3];r=A+M[i+152>>3];pf:{if(P(r)<2147483648){g=~~r;break pf}g=-2147483648}c=d<<16;w=M[i+128>>3];r=w+M[i+144>>3];qf:{if(P(r)<2147483648){e=~~r;break qf}e=-2147483648}c=c>>16;if(P(A)<2147483648){l=~~A}else{l=-2147483648}c=(c|0)>=0;if(P(w)<2147483648){d=~~w}else{d=-2147483648}rf:{sf:{tf:{if(!c){H[i+56>>2]=0;H[i+60>>2]=0;b=i- -64|0;H[b>>2]=0;H[b+4>>2]=0;H[i+72>>2]=0;H[i+76>>2]=0;H[i+80>>2]=0;H[i+84>>2]=0;H[i+88>>2]=0;H[i+92>>2]=0;H[i+120>>2]=0;H[i+124>>2]=0;H[i+48>>2]=0;H[i+52>>2]=0;H[i+112>>2]=0;H[i+116>>2]=0;H[i+44>>2]=418012;H[i+40>>2]=417944;H[i+48>>2]=m;b=H[a+120>>2];H[197455]=0;f=i+40|4;H[b+8>>2]=f;b=H[197455];H[197455]=0;if((b|0)==1){break sf}b=H[a+120>>2];H[197455]=0;c=H[b+680>>2];b=H[197455];H[197455]=0;if((b|0)==1){break sf}H[197455]=0;b=(c|0)==1;Ya(1891,a|0,d|0,(b?l:g)|0,e|0,(b?g:l)|0,0,360);b=H[197455];H[197455]=0;if((b|0)==1){break sf}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break sf}uf:{c=H[a+208>>2];if(!c){break uf}M[i+32>>3]=M[i+152>>3];M[i+24>>3]=M[i+144>>3];M[i+16>>3]=M[i+136>>3];M[i+8>>3]=M[i+128>>3];b=H[H[c>>2]+564>>2];H[197455]=0;ga(b|0,c|0,m|0,i+8|0);b=H[197455];H[197455]=0;if((b|0)!=1){break uf}break sf}b=H[a+120>>2];H[197455]=0;if((f|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break sf}H[i+44>>2]=418012;H[i+40>>2]=417944;if(F[i+127|0]>=0){break tf}Kb(H[i+116>>2]);break tf}c=a+236|0;k=H[c>>2];if(!k){break tf}b=c;while(1){f=K[k+16>>2]>>0;b=f?b:k;k=H[(f<<2)+k>>2];if(k){continue}break}if((b|0)==(c|0)|K[b+16>>2]>m>>>0){break tf}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=1){break tf}b=H[b+20>>2];if(!b){break tf}c=b+4|0;H[H[a+120>>2]+8>>2]=c;vf:{if(H[H[a+120>>2]+680>>2]==1){Sf(a,d,l,e,g,0,360);break vf}Sf(a,d,g,e,l,0,360)}Rf(a,0,1,1);b=H[a+208>>2];if(b){M[i+64>>3]=M[i+152>>3];M[i+56>>3]=M[i+144>>3];M[i+48>>3]=M[i+136>>3];M[i+40>>3]=M[i+128>>3];zb[H[H[b>>2]+564>>2]](b,m,i+40|0)}b=H[a+120>>2];if((c|0)==H[b+8>>2]){H[b+8>>2]=0}}xb=i+160|0;break rf}a=$()|0;_()|0;H[i+44>>2]=418012;H[i+40>>2]=417944;if(F[i+127|0]<0){Kb(H[i+116>>2])}break d}}F[a+213|0]=1;break k;case 19:l=j&65535;j=0;i=xb-96|0;xb=i;b=H[H[a>>2]-12>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){j=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}wf:{xf:{c=a+236|0;e=H[c>>2];yf:{if(!e){break yf}f=l&255;b=c;while(1){d=f>>>0>K[e+16>>2];b=d?b:e;e=H[(d<<2)+e>>2];if(e){continue}break}if((b|0)==(c|0)|f>>>0>2]){break yf}d=H[b+20>>2];if((zb[H[H[d>>2]+12>>2]](d)|0)!=3){break yf}g=H[b+20>>2];if(!g){break yf}zf:{if(l<<16>>16<0){H[i+24>>2]=0;H[i+28>>2]=0;H[i+32>>2]=0;H[i+36>>2]=0;H[i+40>>2]=0;H[i+44>>2]=0;H[i+48>>2]=0;H[i+52>>2]=0;H[i+56>>2]=0;H[i+60>>2]=0;H[i+88>>2]=0;H[i+92>>2]=0;H[i+16>>2]=0;H[i+20>>2]=0;H[i+80>>2]=0;H[i+84>>2]=0;H[i+12>>2]=418012;H[i+8>>2]=417944;H[i+16>>2]=j;b=H[a+120>>2];H[197455]=0;c=i+8|4;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break xf}b=H[a+208>>2];H[197455]=0;ka(1883,g+4|0,b|0,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break xf}d=H[a+208>>2];if(d){b=H[H[d>>2]+568>>2];H[197455]=0;ka(b|0,d|0,f|0,j|0,g|0);b=H[197455];H[197455]=0;if((b|0)==1){break xf}}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break xf}H[i+12>>2]=418012;H[i+8>>2]=417944;if(F[i+95|0]>=0){break zf}Kb(H[i+84>>2]);break zf}e=H[c>>2];if(!e){break yf}b=c;while(1){d=K[e+16>>2]>>0;b=d?b:e;e=H[(d<<2)+e>>2];if(e){continue}break}if((b|0)==(c|0)|K[b+16>>2]>j>>>0){break yf}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=1){break yf}b=H[b+20>>2];if(!b){break yf}c=b+4|0;H[H[a+120>>2]+8>>2]=c;bz(g+4|0,H[a+208>>2],0,1);b=H[a+208>>2];if(b){zb[H[H[b>>2]+568>>2]](b,f,j,g)}b=H[a+120>>2];if((c|0)==H[b+8>>2]){H[b+8>>2]=0}}F[a+213|0]=1}xb=i+96|0;break wf}a=$()|0;_()|0;H[i+12>>2]=418012;H[i+8>>2]=417944;if(F[i+95|0]<0){Kb(H[i+84>>2])}break d}break k;case 15:Af:{if(j&16384){J=0;z=0;b=0;D=0;e=xb-32|0;xb=e;d=H[a>>2]-12|0;c=H[d>>2]+a|0;k=c+8|0;j=H[k>>2];f=H[c+12>>2];if(f>>>0>j+3>>>0){b=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[c+8>>2]=j+4;c=H[d>>2]+a|0;f=H[c+12>>2];k=c+8|0;j=H[k>>2]}if(j+3>>>0>=f>>>0){A=0}else{y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[k>>2]=j+4;c=H[d>>2]+a|0;f=H[c+12>>2];k=c+8|0;j=H[k>>2];A=+y}if(j+3>>>0>>0){y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[k>>2]=j+4;c=H[d>>2]+a|0;f=H[c+12>>2];k=c+8|0;j=H[k>>2];D=+y}if(j+1>>>0>=f>>>0){w=0}else{c=(I[j|0]|I[j+1|0]<<8)<<16>>16;j=j+2|0;H[k>>2]=j;w=+(c|0)}if(j+1>>>0>>0){c=(I[j|0]|I[j+1|0]<<8)<<16>>16;j=j+2|0;H[k>>2]=j;J=+(c|0)}if(j+1>>>0>=f>>>0){r=0}else{c=(I[j|0]|I[j+1|0]<<8)<<16>>16;j=j+2|0;H[k>>2]=j;r=+(c|0)}if(j+1>>>0>>0){c=(I[j|0]|I[j+1|0]<<8)<<16>>16;H[k>>2]=j+2;z=+(c|0)}c=H[a+208>>2];if(c){M[e+24>>3]=z;M[e+16>>3]=r;M[e+8>>3]=J;M[e>>3]=w;zb[H[H[c>>2]+572>>2]](c,b,A,D,e)}xb=e+32|0;break Af}b=0;D=0;l=xb+-64|0;xb=l;H[l+56>>2]=0;H[l+60>>2]=0;H[l+48>>2]=0;H[l+52>>2]=0;H[l+40>>2]=0;H[l+44>>2]=0;H[l+32>>2]=0;H[l+36>>2]=0;e=H[a>>2]-12|0;c=H[e>>2];d=c+a|0;k=d+8|0;j=H[k>>2];f=H[d+12>>2];if(f>>>0>j+3>>>0){b=I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24);H[d+8>>2]=j+4;c=H[e>>2];d=c+a|0;f=H[d+12>>2];k=d+8|0;j=H[k>>2]}if(j+3>>>0>=f>>>0){r=0}else{y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[k>>2]=j+4;c=H[e>>2];d=c+a|0;f=H[d+12>>2];k=d+8|0;j=H[k>>2];r=+y}if(j+3>>>0>>0){y=(x(2,I[j|0]|I[j+1|0]<<8|(I[j+2|0]<<16|I[j+3|0]<<24)),B());H[k>>2]=j+4;D=+y;c=H[e>>2]}Ae((a+c|0)+4|0,l+32|0);c=H[a+208>>2];if(c){M[l+24>>3]=M[l+56>>3];M[l+16>>3]=M[l+48>>3];M[l+8>>3]=M[l+40>>3];M[l>>3]=M[l+32>>3];zb[H[H[c>>2]+572>>2]](c,b,r,D,l)}xb=l- -64|0}F[a+213|0]=1;break k;case 11:i=j&65535;Bf:{if(j&2048){u=0;d=xb-144|0;xb=d;c=H[a>>2]-12|0;e=H[c>>2]+a|0;b=e+8|0;f=H[b>>2];v=H[e+12>>2];if(v>>>0>f+3>>>0){u=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[e+8>>2]=f+4;b=H[c>>2]+a|0;v=H[b+12>>2];b=b+8|0;f=H[b>>2]}Cf:{Df:{Ef:{Ff:{Gf:{Hf:{If:{Jf:{if(f+3>>>0>=v>>>0){break Jf}p=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[b>>2]=f+4;if(p>>>0<2){break Jf}H[d+136>>2]=0;H[d+128>>2]=0;H[d+132>>2]=0;if((p|0)<0){H[197455]=0;ia(1867,d+128|0);a=H[197455];H[197455]=0;if((a|0)==1){break e}break Cf}H[197455]=0;n=aa(899,p|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break e}H[d+128>>2]=n;o=0;H[d+96>>2]=0;Kf:{if(!p){H[d+120>>2]=0;H[d+112>>2]=0;H[d+116>>2]=0;break Kf}H[197455]=0;c=aa(899,p|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){f=$()|0;_()|0;a=H[d+96>>2];if(!a){break Df}H[d+100>>2]=a;Kb(a);break Df}H[d+96>>2]=c;H[d+104>>2]=c+p;h=Ob(c,n,p);H[d+16>>2]=0;H[d+8>>2]=0;H[d+12>>2]=0;if(p>>>0>=268435456){H[197455]=0;ia(1869,d+8|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Cf}break Ef}H[197455]=0;c=p<<4;o=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Ef}f=c+o|0;Lf:{if(p>>>0<2){break Lf}b=1;c=p-1|0;l=c&1;if((p|0)!=2){e=c&-2;v=0;while(1){s=(b<<4)+o|0;m=s-16|0;g=H[m+4>>2];c=H[m>>2];H[s+16>>2]=c;H[s+20>>2]=g;H[s>>2]=c;H[s+4>>2]=g;g=H[m+12>>2];c=H[m+8>>2];H[s+24>>2]=c;H[s+28>>2]=g;H[s+8>>2]=c;H[s+12>>2]=g;b=b+2|0;v=v+2|0;if((e|0)!=(v|0)){continue}break}}if(!l){break Lf}e=(b<<4)+o|0;c=e-16|0;b=H[c+4>>2];H[e>>2]=H[c>>2];H[e+4>>2]=b;b=H[c+12>>2];H[e+8>>2]=H[c+8>>2];H[e+12>>2]=b}H[d+120>>2]=f;H[d+116>>2]=f;H[d+112>>2]=o;H[d+100>>2]=h;Kb(h)}Mf:{if(i<<16>>16<0){H[d+24>>2]=0;H[d+28>>2]=0;H[d+32>>2]=0;H[d+36>>2]=0;H[d+40>>2]=0;H[d+44>>2]=0;H[d+48>>2]=0;H[d+52>>2]=0;H[d+56>>2]=0;H[d+60>>2]=0;H[d+88>>2]=0;H[d+92>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0;H[d+80>>2]=0;H[d+84>>2]=0;H[d+12>>2]=418012;H[d+8>>2]=417944;H[d+16>>2]=u;b=H[a+120>>2];H[197455]=0;c=d+8|4;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break Gf}w=M[o+8>>3];r=M[o>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Gf}f=1;Nf:{if(p>>>0>1){while(1){b=(f<<4)+o|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Nf}f=f+1|0;if((p|0)!=(f|0)){continue}break}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break Gf}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break Gf}e=H[a+208>>2];if(e){b=H[H[e>>2]+576>>2];H[197455]=0;ga(b|0,e|0,u|0,d+112|0);b=H[197455];H[197455]=0;if((b|0)==1){break Gf}}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Gf}H[d+12>>2]=418012;H[d+8>>2]=417944;if(F[d+95|0]>=0){break Mf}Kb(H[d+84>>2]);break Mf}break Gf}c=a+236|0;f=H[c>>2];if(!f){break Mf}b=c;while(1){e=K[f+16>>2]>>0;b=e?b:f;f=H[(e<<2)+f>>2];if(f){continue}break}if((b|0)==(c|0)|K[b+16>>2]>u>>>0){break Mf}e=H[b+20>>2];c=H[H[e>>2]+12>>2];H[197455]=0;e=aa(c|0,e|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break If}if((e|0)!=1){break Mf}c=H[b+20>>2];if(!c){break Mf}b=H[a+120>>2];H[197455]=0;c=c+4|0;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break If}w=M[o+8>>3];r=M[o>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break If}f=1;if(p>>>0>1){while(1){b=(f<<4)+o|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Hf}f=f+1|0;if((p|0)!=(f|0)){continue}break}}e=H[a+208>>2];if(e){b=H[H[e>>2]+576>>2];H[197455]=0;ga(b|0,e|0,u|0,d+112|0);b=H[197455];H[197455]=0;if((b|0)==1){break If}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break If}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break If}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break If}}b=H[d+112>>2];if(b){H[d+116>>2]=b;Kb(b)}Kb(n)}xb=d+144|0;break Bf}f=$()|0;_()|0;break Ff}f=$()|0;_()|0;break Ff}f=$()|0;_()|0;H[d+12>>2]=418012;H[d+8>>2]=417944;if(F[d+95|0]>=0){break Ff}Kb(H[d+84>>2])}a=H[d+112>>2];if(!a){break Df}H[d+116>>2]=a;Kb(a);break Df}f=$()|0;_()|0;a=H[d+8>>2];if(a){H[d+12>>2]=a;Kb(a)}H[d+100>>2]=h;Kb(h)}Kb(n);break a}X()}if(i&16384){g=j&65535;v=0;d=xb-144|0;xb=d;f=H[a>>2]-12|0;c=H[f>>2]+a|0;b=c+8|0;h=H[b>>2];j=H[c+12>>2];if(j>>>0>h+3>>>0){v=I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24);H[c+8>>2]=h+4;b=H[f>>2]+a|0;j=H[b+12>>2];b=b+8|0;h=H[b>>2]}Of:{Pf:{Qf:{Rf:{Sf:{Tf:{Uf:{Vf:{if(h+3>>>0>=j>>>0){break Vf}s=I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24);H[b>>2]=h+4;if(s>>>0<2){break Vf}H[d+136>>2]=0;H[d+128>>2]=0;H[d+132>>2]=0;if(s>>>0>=1073741824){H[197455]=0;ia(1808,d+128|0);a=H[197455];H[197455]=0;if((a|0)==1){break e}break Of}H[197455]=0;c=s<<2;e=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break e}H[d+128>>2]=e;m=c+e|0;H[d+136>>2]=m;h=0;n=Nb(e,0,c);H[d+132>>2]=m;e=a+4|0;while(1){l=n+(h<<2)|0;i=e+H[f>>2]|0;o=H[i+4>>2];c=H[i+8>>2];Wf:{if(o+1>>>0>=c>>>0){b=0;break Wf}b=I[o|0]|I[o+1|0]<<8;o=o+2|0;H[i+4>>2]=o}G[l>>1]=b;b=0;if(c>>>0>o+1>>>0){b=I[o|0]|I[o+1|0]<<8;H[i+4>>2]=o+2}G[l+2>>1]=b;h=h+1|0;if((s|0)!=(h|0)){continue}break}o=0;H[d+104>>2]=0;H[d+96>>2]=0;H[d+100>>2]=0;Xf:{if((n|0)==(m|0)){H[d+120>>2]=0;H[d+112>>2]=0;H[d+116>>2]=0;break Xf}Yf:{e=m-n|0;Zf:{if((e|0)<0){H[197455]=0;ia(1808,d+96|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Of}break Zf}H[197455]=0;c=aa(899,e|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Yf}}h=$()|0;_()|0;a=H[d+96>>2];if(!a){break Pf}H[d+100>>2]=a;Kb(a);break Pf}H[d+96>>2]=c;H[d+104>>2]=c+(e>>2<<2);i=Ob(c,n,e);_f:{if(e){H[d+16>>2]=0;H[d+8>>2]=0;H[d+12>>2]=0;c=(e+i|0)-i|0;if(c>>>0>=1073741821){H[197455]=0;ia(1869,d+8|0);a=H[197455];H[197455]=0;if((a|0)!=1){break Of}break Qf}H[197455]=0;o=aa(899,c<<2)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Qf}f=c>>2;b=f>>>0>1?f:1;l=b&1;h=0;if(c>>>0>=8){e=b&-2;j=0;while(1){c=(h<<4)+o|0;b=i+(h<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];b=h|1;c=(b<<4)+o|0;b=i+(b<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1];h=h+2|0;j=j+2|0;if((e|0)!=(j|0)){continue}break}}if(l){c=(h<<4)+o|0;b=i+(h<<2)|0;M[c>>3]=G[b>>1];M[c+8>>3]=G[b+2>>1]}H[d+112>>2]=o;b=(f<<4)+o|0;H[d+120>>2]=b;H[d+116>>2]=b;break _f}H[d+120>>2]=0;H[d+112>>2]=0;H[d+116>>2]=0}H[d+100>>2]=i;Kb(i)}$f:{if(g<<16>>16<0){H[d+24>>2]=0;H[d+28>>2]=0;H[d+32>>2]=0;H[d+36>>2]=0;H[d+40>>2]=0;H[d+44>>2]=0;H[d+48>>2]=0;H[d+52>>2]=0;H[d+56>>2]=0;H[d+60>>2]=0;H[d+88>>2]=0;H[d+92>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0;H[d+80>>2]=0;H[d+84>>2]=0;H[d+12>>2]=418012;H[d+8>>2]=417944;H[d+16>>2]=v;b=H[a+120>>2];H[197455]=0;c=d+8|4;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break Sf}w=M[o+8>>3];r=M[o>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Sf}h=1;ag:{if(s>>>0>1){while(1){b=(h<<4)+o|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break ag}h=h+1|0;if((s|0)!=(h|0)){continue}break}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break Sf}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break Sf}e=H[a+208>>2];if(e){b=H[H[e>>2]+576>>2];H[197455]=0;ga(b|0,e|0,v|0,d+112|0);b=H[197455];H[197455]=0;if((b|0)==1){break Sf}}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Sf}H[d+12>>2]=418012;H[d+8>>2]=417944;if(F[d+95|0]>=0){break $f}Kb(H[d+84>>2]);break $f}break Sf}c=a+236|0;h=H[c>>2];if(!h){break $f}b=c;while(1){e=K[h+16>>2]>>0;b=e?b:h;h=H[(e<<2)+h>>2];if(h){continue}break}if((b|0)==(c|0)|K[b+16>>2]>v>>>0){break $f}e=H[b+20>>2];c=H[H[e>>2]+12>>2];H[197455]=0;e=aa(c|0,e|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Uf}if((e|0)!=1){break $f}c=H[b+20>>2];if(!c){break $f}b=H[a+120>>2];H[197455]=0;c=c+4|0;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break Uf}w=M[o+8>>3];r=M[o>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Uf}h=1;if(s>>>0>1){while(1){b=(h<<4)+o|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break Tf}h=h+1|0;if((s|0)!=(h|0)){continue}break}}e=H[a+208>>2];if(e){b=H[H[e>>2]+576>>2];H[197455]=0;ga(b|0,e|0,v|0,d+112|0);b=H[197455];H[197455]=0;if((b|0)==1){break Uf}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break Uf}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break Uf}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Uf}}b=H[d+112>>2];if(b){H[d+116>>2]=b;Kb(b)}Kb(n)}xb=d+144|0;break Bf}h=$()|0;_()|0;break Rf}h=$()|0;_()|0;break Rf}h=$()|0;_()|0;H[d+12>>2]=418012;H[d+8>>2]=417944;if(F[d+95|0]>=0){break Rf}Kb(H[d+84>>2])}a=H[d+112>>2];if(!a){break Pf}H[d+116>>2]=a;Kb(a);break Pf}h=$()|0;_()|0;a=H[d+8>>2];if(a){H[d+12>>2]=a;Kb(a)}H[d+100>>2]=i;Kb(i)}Kb(n);ea(h|0);X()}X()}v=0;t=xb-144|0;xb=t;f=H[a>>2]-12|0;c=H[f>>2]+a|0;d=c+8|0;g=H[d>>2];b=H[c+12>>2];if(b>>>0>g+3>>>0){v=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[c+8>>2]=g+4;c=H[f>>2]+a|0;b=H[c+12>>2];d=c+8|0;g=H[d>>2]}l=j&65535;bg:{cg:{dg:{eg:{fg:{gg:{hg:{ig:{jg:{if(g+3>>>0>=b>>>0){break jg}p=I[g|0]|I[g+1|0]<<8|(I[g+2|0]<<16|I[g+3|0]<<24);H[d>>2]=g+4;if(p>>>0<2){break jg}H[t+136>>2]=0;H[t+128>>2]=0;H[t+132>>2]=0;kg:{lg:{if(p>>>0>=268435456){H[197455]=0;ia(1869,t+128|0);a=H[197455];H[197455]=0;if((a|0)==1){break lg}break cg}H[197455]=0;c=p<<4;s=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break kg}}a=$()|0;_()|0;b=H[t+128>>2];if(b){H[t+132>>2]=b;Kb(b)}break d}H[t+128>>2]=s;m=c+s|0;H[t+136>>2]=m;H[t+132>>2]=m;e=a+4|0;g=0;while(1){c=s+(g<<4)|0;i=e+H[f>>2]|0;b=H[i+4>>2];d=H[i+8>>2];if(b+3>>>0>=d>>>0){r=0}else{y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());b=b+4|0;H[i+4>>2]=b;r=+y}M[c>>3]=r;if(d>>>0>b+3>>>0){y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());H[i+4>>2]=b+4;r=+y}else{r=0}M[c+8>>3]=r;g=g+1|0;if((p|0)!=(g|0)){continue}break}d=0;H[t+104>>2]=0;H[t+96>>2]=0;H[t+100>>2]=0;mg:{if((m|0)==(s|0)){H[t+120>>2]=0;H[t+112>>2]=0;H[t+116>>2]=0;break mg}ng:{e=m-s|0;og:{if((e|0)<0){H[197455]=0;ia(1869,t+96|0);a=H[197455];H[197455]=0;if((a|0)!=1){break cg}break og}H[197455]=0;c=aa(899,e|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break ng}}g=$()|0;_()|0;a=H[t+96>>2];if(!a){break dg}H[t+100>>2]=a;Kb(a);break dg}H[t+96>>2]=c;H[t+104>>2]=c+(e>>4<<4);q=Ob(c,s,e);pg:{if(e){H[t+16>>2]=0;H[t+8>>2]=0;H[t+12>>2]=0;c=(e+q|0)-q|0;if((c|0)<0){H[197455]=0;ia(1869,t+8|0);a=H[197455];H[197455]=0;if((a|0)!=1){break cg}break eg}H[197455]=0;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break eg}i=c>>4;b=i>>>0>1?i:1;f=b&3;k=0;g=0;if(b-1>>>0>=3){e=b&-4;h=0;while(1){n=g<<4;c=n+d|0;m=n+q|0;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=n|16;c=b+d|0;m=b+q|0;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;b=n|32;c=b+d|0;m=b+q|0;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;b=n|48;c=b+d|0;m=b+q|0;b=H[m+12>>2];H[c+8>>2]=H[m+8>>2];H[c+12>>2]=b;b=H[m+4>>2];H[c>>2]=H[m>>2];H[c+4>>2]=b;g=g+4|0;h=h+4|0;if((e|0)!=(h|0)){continue}break}}if(f){while(1){b=g<<4;c=b+d|0;e=b+q|0;b=H[e+4>>2];H[c>>2]=H[e>>2];H[c+4>>2]=b;b=H[e+12>>2];H[c+8>>2]=H[e+8>>2];H[c+12>>2]=b;g=g+1|0;k=k+1|0;if((f|0)!=(k|0)){continue}break}}H[t+112>>2]=d;b=(i<<4)+d|0;H[t+120>>2]=b;H[t+116>>2]=b;break pg}H[t+120>>2]=0;H[t+112>>2]=0;H[t+116>>2]=0}H[t+100>>2]=q;Kb(q)}qg:{if(l<<16>>16<0){H[t+24>>2]=0;H[t+28>>2]=0;H[t+32>>2]=0;H[t+36>>2]=0;H[t+40>>2]=0;H[t+44>>2]=0;H[t+48>>2]=0;H[t+52>>2]=0;H[t+56>>2]=0;H[t+60>>2]=0;H[t+88>>2]=0;H[t+92>>2]=0;H[t+16>>2]=0;H[t+20>>2]=0;H[t+80>>2]=0;H[t+84>>2]=0;H[t+12>>2]=418012;H[t+8>>2]=417944;H[t+16>>2]=v;b=H[a+120>>2];H[197455]=0;c=t+8|4;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break gg}w=M[d+8>>3];r=M[d>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break gg}g=1;rg:{if(p>>>0>1){while(1){b=(g<<4)+d|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break rg}g=g+1|0;if((p|0)!=(g|0)){continue}break}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break gg}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break gg}d=H[a+208>>2];if(d){b=H[H[d>>2]+576>>2];H[197455]=0;ga(b|0,d|0,v|0,t+112|0);b=H[197455];H[197455]=0;if((b|0)==1){break gg}}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break gg}H[t+12>>2]=418012;H[t+8>>2]=417944;if(F[t+95|0]>=0){break qg}Kb(H[t+84>>2]);break qg}break gg}c=a+236|0;g=H[c>>2];if(!g){break qg}b=c;while(1){e=K[g+16>>2]>>0;b=e?b:g;g=H[(e<<2)+g>>2];if(g){continue}break}if((b|0)==(c|0)|K[b+16>>2]>v>>>0){break qg}e=H[b+20>>2];c=H[H[e>>2]+12>>2];H[197455]=0;e=aa(c|0,e|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break ig}if((e|0)!=1){break qg}c=H[b+20>>2];if(!c){break qg}b=H[a+120>>2];H[197455]=0;c=c+4|0;H[b+8>>2]=c;b=H[197455];H[197455]=0;if((b|0)==1){break ig}w=M[d+8>>3];r=M[d>>3];H[197455]=0;ta(1870,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break ig}g=1;if(p>>>0>1){while(1){b=(g<<4)+d|0;w=M[b+8>>3];r=M[b>>3];H[197455]=0;ta(1881,a|0,+r,+w);b=H[197455];H[197455]=0;if((b|0)==1){break hg}g=g+1|0;if((p|0)!=(g|0)){continue}break}}d=H[a+208>>2];if(d){b=H[H[d>>2]+576>>2];H[197455]=0;ga(b|0,d|0,v|0,t+112|0);b=H[197455];H[197455]=0;if((b|0)==1){break ig}}H[197455]=0;ia(1865,a|0);b=H[197455];H[197455]=0;if((b|0)==1){break ig}H[197455]=0;ka(1872,a|0,0,1,1);b=H[197455];H[197455]=0;if((b|0)==1){break ig}b=H[a+120>>2];H[197455]=0;if((c|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break ig}}b=H[t+112>>2];if(b){H[t+116>>2]=b;Kb(b)}Kb(s)}xb=t+144|0;break bg}g=$()|0;_()|0;break fg}g=$()|0;_()|0;break fg}g=$()|0;_()|0;H[t+12>>2]=418012;H[t+8>>2]=417944;if(F[t+95|0]>=0){break fg}Kb(H[t+84>>2])}a=H[t+112>>2];if(!a){break dg}H[t+116>>2]=a;Kb(a);break dg}g=$()|0;_()|0;a=H[t+8>>2];if(a){H[t+12>>2]=a;Kb(a)}H[t+100>>2]=q;Kb(q)}Kb(s);break b}X()}}F[a+213|0]=1;break k;case 9:sg:{if(j&16384){u=0;m=xb-112|0;xb=m;f=H[a>>2];c=f-12|0;d=H[c>>2]+a|0;o=d+8|0;b=H[o>>2];v=H[d+12>>2];if(v>>>0>b+3>>>0){u=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+8>>2]=b+4;b=H[c>>2]+a|0;v=H[b+12>>2];o=b+8|0;b=H[o>>2]}e=j&65535;tg:{ug:{vg:{wg:{xg:{yg:{if(b+3>>>0>=v>>>0){break yg}g=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[o>>2]=b+4;if(!g){break yg}H[m+104>>2]=0;H[m+96>>2]=0;H[m+100>>2]=0;zg:{Ag:{if(g>>>0>=134217728){H[197455]=0;ia(1884,m+96|0);a=H[197455];H[197455]=0;if((a|0)==1){break Ag}X()}H[197455]=0;c=g<<5;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break zg}}f=$()|0;_()|0;a=H[m+96>>2];if(!a){break tg}H[m+100>>2]=a;Kb(a);break tg}H[m+96>>2]=d;b=c+d|0;H[m+104>>2]=b;v=0;Nb(d,0,c);H[m+100>>2]=b;d=a+4|0;while(1){i=d+H[f-12>>2]|0;o=H[i+4>>2];l=H[i+8>>2];Bg:{if(o+1>>>0>=l>>>0){k=0;break Bg}k=(I[o|0]|I[o+1|0]<<8)<<16>>16;o=o+2|0;H[i+4>>2]=o}f=0;Cg:{if(l>>>0<=o+1>>>0){c=0;break Cg}c=(I[o|0]|I[o+1|0]<<8)<<16>>16;o=o+2|0;H[i+4>>2]=o}if(l>>>0>o+1>>>0){f=(I[o|0]|I[o+1|0]<<8)<<16>>16;o=o+2|0;H[i+4>>2]=o}b=0;if(l>>>0>o+1>>>0){b=(I[o|0]|I[o+1|0]<<8)<<16>>16;H[i+4>>2]=o+2}l=H[m+96>>2]+(v<<5)|0;M[l+24>>3]=b<<16>>16;M[l+16>>3]=f<<16>>16;M[l+8>>3]=c<<16>>16;M[l>>3]=k<<16>>16;v=v+1|0;if((g|0)!=(v|0)){f=H[a>>2];continue}break}Dg:{if(e<<16>>16<0){H[m+24>>2]=0;H[m+28>>2]=0;H[m+32>>2]=0;H[m+36>>2]=0;H[m+40>>2]=0;H[m+44>>2]=0;H[m+48>>2]=0;H[m+52>>2]=0;H[m+56>>2]=0;H[m+60>>2]=0;H[m+88>>2]=0;H[m+92>>2]=0;H[m+16>>2]=0;H[m+20>>2]=0;H[m+80>>2]=0;H[m+84>>2]=0;H[m+12>>2]=418012;H[m+8>>2]=417944;H[m+16>>2]=u;b=H[a+120>>2];H[197455]=0;d=m+8|4;H[b+8>>2]=d;b=H[197455];H[197455]=0;Eg:{if((b|0)==1){break Eg}f=H[m+96>>2];c=H[m+100>>2];if((f|0)!=(c|0)){while(1){H[197455]=0;ka(1885,a|0,f|0,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break vg}f=f+32|0;if((c|0)!=(f|0)){continue}break}}c=H[a+208>>2];if(c){b=H[H[c>>2]+580>>2];H[197455]=0;ga(b|0,c|0,u|0,m+96|0);b=H[197455];H[197455]=0;if((b|0)==1){break Eg}}b=H[a+120>>2];H[197455]=0;if((d|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Eg}H[m+12>>2]=418012;H[m+8>>2]=417944;if(F[m+95|0]>=0){break Dg}Kb(H[m+84>>2]);break Dg}break vg}c=a+236|0;f=H[c>>2];if(!f){break Dg}b=c;while(1){d=K[f+16>>2]>>0;b=d?b:f;f=H[(d<<2)+f>>2];if(f){continue}break}if((b|0)==(c|0)|K[b+16>>2]>u>>>0){break Dg}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break xg}if((d|0)!=1){break Dg}c=H[b+20>>2];if(!c){break Dg}b=H[a+120>>2];H[197455]=0;d=c+4|0;H[b+8>>2]=d;b=H[197455];H[197455]=0;if((b|0)==1){break xg}f=H[m+96>>2];c=H[m+100>>2];if((f|0)!=(c|0)){while(1){H[197455]=0;ka(1885,a|0,f|0,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break wg}f=f+32|0;if((c|0)!=(f|0)){continue}break}}c=H[a+208>>2];if(c){b=H[H[c>>2]+580>>2];H[197455]=0;ga(b|0,c|0,u|0,m+96|0);b=H[197455];H[197455]=0;if((b|0)==1){break xg}}b=H[a+120>>2];H[197455]=0;if((d|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break xg}}b=H[m+96>>2];if(!b){break yg}H[m+100>>2]=b;Kb(b)}xb=m+112|0;break sg}f=$()|0;_()|0;break ug}f=$()|0;_()|0;break ug}f=$()|0;_()|0;H[m+12>>2]=418012;H[m+8>>2]=417944;if(F[m+95|0]>=0){break ug}Kb(H[m+84>>2])}a=H[m+96>>2];if(!a){break tg}H[m+100>>2]=a;Kb(a);break a}break a}l=j&65535;i=xb-144|0;xb=i;e=H[a>>2];c=e-12|0;d=H[c>>2]+a|0;k=d+8|0;b=H[k>>2];f=H[d+12>>2];Fg:{if(f>>>0<=b+3>>>0){j=0;break Fg}j=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+8>>2]=b+4;b=H[c>>2]+a|0;f=H[b+12>>2];k=b+8|0;b=H[k>>2]}Gg:{Hg:{Ig:{Jg:{Kg:{Lg:{Mg:{Ng:{if(b+3>>>0>=f>>>0){break Ng}g=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[k>>2]=b+4;if(!g){break Ng}H[i+136>>2]=0;H[i+128>>2]=0;H[i+132>>2]=0;Og:{Pg:{if(g>>>0>=134217728){H[197455]=0;ia(1884,i+128|0);a=H[197455];H[197455]=0;if((a|0)==1){break Pg}X()}H[197455]=0;c=g<<5;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)!=1){break Og}}e=$()|0;_()|0;a=H[i+128>>2];if(!a){break Hg}H[i+132>>2]=a;Kb(a);break Hg}H[i+128>>2]=d;b=c+d|0;H[i+136>>2]=b;Nb(d,0,c);H[i+132>>2]=b;H[i+120>>2]=0;H[i+124>>2]=0;H[i+112>>2]=0;H[i+116>>2]=0;H[i+104>>2]=0;H[i+108>>2]=0;H[i+96>>2]=0;H[i+100>>2]=0;d=a+4|0;b=0;while(1){c=H[e-12>>2];H[197455]=0;Ae(c+d|0,i+96|0);c=H[197455];H[197455]=0;if((c|0)==1){break Mg}A=M[i+96>>3];w=M[i+104>>3];r=M[i+112>>3];c=H[i+128>>2]+(b<<5)|0;M[c+24>>3]=M[i+120>>3];M[c+16>>3]=r;M[c+8>>3]=w;M[c>>3]=A;b=b+1|0;if((g|0)!=(b|0)){e=H[a>>2];continue}break}Qg:{if(l<<16>>16<0){H[i+24>>2]=0;H[i+28>>2]=0;H[i+32>>2]=0;H[i+36>>2]=0;H[i+40>>2]=0;H[i+44>>2]=0;H[i+48>>2]=0;H[i+52>>2]=0;H[i+56>>2]=0;H[i+60>>2]=0;H[i+88>>2]=0;H[i+92>>2]=0;H[i+16>>2]=0;H[i+20>>2]=0;H[i+80>>2]=0;H[i+84>>2]=0;H[i+12>>2]=418012;H[i+8>>2]=417944;H[i+16>>2]=j;b=H[a+120>>2];H[197455]=0;d=i+8|4;H[b+8>>2]=d;b=H[197455];H[197455]=0;Rg:{if((b|0)==1){break Rg}e=H[i+128>>2];c=H[i+132>>2];if((e|0)!=(c|0)){while(1){H[197455]=0;ka(1885,a|0,e|0,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break Jg}e=e+32|0;if((c|0)!=(e|0)){continue}break}}c=H[a+208>>2];if(c){b=H[H[c>>2]+580>>2];H[197455]=0;ga(b|0,c|0,j|0,i+128|0);b=H[197455];H[197455]=0;if((b|0)==1){break Rg}}b=H[a+120>>2];H[197455]=0;if((d|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Rg}H[i+12>>2]=418012;H[i+8>>2]=417944;if(F[i+95|0]>=0){break Qg}Kb(H[i+84>>2]);break Qg}break Jg}c=a+236|0;e=H[c>>2];if(!e){break Qg}b=c;while(1){d=K[e+16>>2]>>0;b=d?b:e;e=H[(d<<2)+e>>2];if(e){continue}break}if((b|0)==(c|0)|K[b+16>>2]>j>>>0){break Qg}d=H[b+20>>2];c=H[H[d>>2]+12>>2];H[197455]=0;d=aa(c|0,d|0)|0;c=H[197455];H[197455]=0;if((c|0)==1){break Lg}if((d|0)!=1){break Qg}c=H[b+20>>2];if(!c){break Qg}b=H[a+120>>2];H[197455]=0;d=c+4|0;H[b+8>>2]=d;b=H[197455];H[197455]=0;if((b|0)==1){break Lg}e=H[i+128>>2];c=H[i+132>>2];if((e|0)!=(c|0)){while(1){H[197455]=0;ka(1885,a|0,e|0,0,1);b=H[197455];H[197455]=0;if((b|0)==1){break Kg}e=e+32|0;if((c|0)!=(e|0)){continue}break}}c=H[a+208>>2];if(c){b=H[H[c>>2]+580>>2];H[197455]=0;ga(b|0,c|0,j|0,i+128|0);b=H[197455];H[197455]=0;if((b|0)==1){break Lg}}b=H[a+120>>2];H[197455]=0;if((d|0)==H[b+8>>2]){H[b+8>>2]=0}b=H[197455];H[197455]=0;if((b|0)==1){break Lg}}b=H[i+128>>2];if(!b){break Ng}H[i+132>>2]=b;Kb(b)}xb=i+144|0;break Gg}e=$()|0;_()|0;break Ig}e=$()|0;_()|0;break Ig}e=$()|0;_()|0;break Ig}e=$()|0;_()|0;H[i+12>>2]=418012;H[i+8>>2]=417944;if(F[i+95|0]>=0){break Ig}Kb(H[i+84>>2])}a=H[i+128>>2];if(!a){break Hg}H[i+132>>2]=a;Kb(a);ea(e|0);X()}ea(e|0);X()}}F[a+213|0]=1;break k;case 18:if(K[c+8>>2]>L+3>>>0){H[c+4>>2]=L+4}F[a+213|0]=1;break k;case 7:l=xb-16|0;xb=l;b=j&65535;s=b&255;Sg:{Tg:{switch((b>>>8&127)-1|0){case 0:xf(a,qz(a),s);break Sg;case 1:d=0;o=0;f=0;g=0;u=H[a>>2];n=u-12|0;b=H[n>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;c=H[n>>2]+a|0;e=H[c+8>>2];Ug:{if(e+3>>>0>2]){b=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[c+8>>2]=e+4;if(b){break Ug}}d=Qb(64);H[d+28>>2]=0;H[d+32>>2]=0;G[d+24>>1]=0;H[d+16>>2]=0;H[d+20>>2]=1072693248;H[d+8>>2]=0;H[d+4>>2]=419196;H[d>>2]=419144;F[d+26|0]=0;H[d+36>>2]=0;H[d+40>>2]=0;H[d+44>>2]=0;H[d+48>>2]=0;H[d+52>>2]=0;H[d+56>>2]=0;H[d+60>>2]=0;b=H[n>>2]+a|0;e=b;c=H[b+12>>2];k=b+8|0;b=H[k>>2];if(c>>>0>b+3>>>0){o=I[b|0]|I[b+1|0]<<8;H[e+8>>2]=b+4;b=H[n>>2]+a|0;c=H[b+12>>2];k=b+8|0;b=H[k>>2]}if(b+3>>>0>>0){H[k>>2]=b+4;b=H[n>>2]+a|0;c=H[b+12>>2];k=b+8|0;b=H[k>>2]}if(b+3>>>0>>0){y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());H[k>>2]=b+4;r=+y}else{r=0}M[d+16>>3]=r;if(o&1){b=H[n>>2]+a|0;H[b+8>>2]=H[b+8>>2]+24}b=0;Vg:{if(!(o&2)){break Vg}c=96;e=H[n>>2]+a|0;i=H[e+8>>2];if(i+3>>>0>2]){c=I[i|0]|I[i+1|0]<<8|(I[i+2|0]<<16|I[i+3|0]<<24);H[e+8>>2]=i+4;if(c>>>0>2){break Vg}c=96-(c<<4)|0}H[d+8>>2]=c;b=c}Wg:{if(!(o&4)){break Wg}k=512;e=H[n>>2]+a|0;i=H[e+8>>2];Xg:{if(i+3>>>0>=K[e+12>>2]){break Xg}c=I[i|0]|I[i+1|0]<<8|(I[i+2|0]<<16|I[i+3|0]<<24);H[e+8>>2]=i+4;Yg:{switch(c|0){case 0:break Xg;case 1:break Yg;default:break Wg}}k=256}b=b|k;H[d+8>>2]=b}Zg:{if(!(o&8)){break Zg}k=8192;e=H[n>>2]+a|0;i=H[e+8>>2];_g:{if(i+3>>>0>=K[e+12>>2]){break _g}c=I[i|0]|I[i+1|0]<<8|(I[i+2|0]<<16|I[i+3|0]<<24);H[e+8>>2]=i+4;$g:{switch(c|0){case 0:break _g;case 1:break $g;default:break Zg}}k=4096}b=b|k;H[d+8>>2]=b}if(o&16){c=H[n>>2]+a|0;e=H[c+8>>2];if(e+3>>>0>2]){y=(x(2,I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24)),B());H[c+8>>2]=e+4;r=+y}else{r=0}M[d+32>>3]=r}if(o&32){c=0;i=H[n>>2]+a|0;e=H[i+8>>2];if(e+3>>>0>2]){c=I[e|0];H[i+8>>2]=e+4}b=c&15|b;H[d+8>>2]=b}ah:{if(!(o&64)){break ah}k=96;e=H[n>>2]+a|0;i=H[e+8>>2];bh:{if(i+3>>>0>=K[e+12>>2]){break bh}c=I[i|0]|I[i+1|0]<<8|(I[i+2|0]<<16|I[i+3|0]<<24);H[e+8>>2]=i+4;ch:{switch(c|0){case 0:break bh;case 2:break ch;default:break ah}}k=64}H[d+8>>2]=b|k}if(o&128){b=H[n>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){y=(x(2,I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24)),B());H[b+8>>2]=c+4;r=+y}else{r=0}M[d+40>>3]=r}dh:{if(!(o&256)){break dh}b=H[n>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){f=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}H[d+52>>2]=f;i=Qb((f&536870911)!=(f|0)?-1:f<<3);H[d+48>>2]=i;if(!f){break dh}e=a+4|0;b=0;while(1){c=i+(b<<3)|0;m=e+H[n>>2]|0;h=H[m+4>>2];if(h+3>>>0>2]){y=(x(2,I[h|0]|I[h+1|0]<<8|(I[h+2|0]<<16|I[h+3|0]<<24)),B());H[m+4>>2]=h+4;r=+y}else{r=0}M[c>>3]=r;b=b+1|0;if((f|0)!=(b|0)){continue}break}}if(o&512){b=H[n>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4}if(o&1024){m=H[n>>2]+a|0;c=m+8|0;b=H[c>>2];eh:{if(b+3>>>0>=K[m+12>>2]){k=0;break eh}i=I[b+3|0];f=I[b+2|0];e=I[b+1|0];c=I[b|0];H[m+8>>2]=b+4;k=e<<10|c<<2|f<<18|i<<26;c=(H[n>>2]+a|0)+8|0;b=H[c>>2]}H[c>>2]=b+k}if(o&2048){k=H[n>>2];e=k+a|0;c=e+8|0;b=H[c>>2];if(b+3>>>0>2]){g=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[e+8>>2]=b+4;k=H[n>>2];c=(k+a|0)+8|0;b=H[c>>2]}f=H[(a+k|0)+4>>2];H[c>>2]=b+4;fh:{gh:{hh:{ih:{e=H[n>>2]+a|0;i=H[e+8>>2];if(i+3>>>0>=K[e+12>>2]){break ih}c=I[i|0]|I[i+1|0]<<8|(I[i+2|0]<<16|I[i+3|0]<<24);H[e+8>>2]=i+4;switch(c|0){case 1:break hh;case 0:break ih;default:break fh}}c=Qb(96);H[c+88>>2]=0;H[c>>2]=419324;oz((H[n>>2]+a|0)+4|0,c);if(H[c+4>>2]-1>>>0>1){break gh}e=H[H[a>>2]-12>>2]+a|0;H[e+8>>2]=H[e+8>>2]+4;fa=c,ma=oj(a),H[fa+88>>2]=ma;break gh}c=Qb(96);H[c>>2]=419432;nz((H[n>>2]+a|0)+4|0,c)}H[d+56>>2]=c}u=H[a>>2];e=H[u-12>>2]+a|0;c=H[e+8>>2];H[e+8>>2]=c+(H[e+4>>2]+(b+g-(c+f)|0)|0)}if(o&4096){i=u-12|0;k=H[i>>2];e=k+a|0;c=e+8|0;b=H[c>>2];jh:{if(b+3>>>0>=K[e+12>>2]){g=0;break jh}g=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[e+8>>2]=b+4;k=H[i>>2];c=(k+a|0)+8|0;b=H[c>>2]}f=H[(a+k|0)+4>>2];H[c>>2]=b+4;kh:{lh:{mh:{nh:{e=H[i>>2]+a|0;m=H[e+8>>2];if(m+3>>>0>=K[e+12>>2]){break nh}c=I[m|0]|I[m+1|0]<<8|(I[m+2|0]<<16|I[m+3|0]<<24);H[e+8>>2]=m+4;switch(c|0){case 1:break mh;case 0:break nh;default:break kh}}c=Qb(96);H[c+88>>2]=0;H[c>>2]=419324;oz((H[i>>2]+a|0)+4|0,c);if(H[c+4>>2]-1>>>0>1){break lh}e=H[H[a>>2]-12>>2]+a|0;H[e+8>>2]=H[e+8>>2]+4;fa=c,ma=oj(a),H[fa+88>>2]=ma;break lh}c=Qb(96);H[c>>2]=419432;nz((H[i>>2]+a|0)+4|0,c)}H[d+60>>2]=c}e=H[H[a>>2]-12>>2]+a|0;c=H[e+8>>2];H[e+8>>2]=c+(H[e+4>>2]+(b+g-(c+f)|0)|0)}fa=d,ma=qz(a),H[fa+28>>2]=ma}xf(a,d,s);break Sg;case 2:if(b<<16>>16<0){oh:{ph:{c=a+236|0;k=H[c>>2];if(!k){break ph}b=c;while(1){d=s>>>0>K[k+16>>2];b=d?b:k;k=H[(d<<2)+k>>2];if(k){continue}break}if((b|0)==(c|0)|s>>>0>2]){break ph}c=H[b+20>>2];if((zb[H[H[c>>2]+12>>2]](c)|0)!=255){break ph}k=H[b+20>>2];if(!k){break ph}pz(a,k);break oh}k=Qb(16);H[k+12>>2]=0;H[k+4>>2]=0;H[k+8>>2]=0;H[k>>2]=419096;pz(a,k);xf(a,k,s)}c=H[k+12>>2];if((c|0)!=H[k+8>>2]){break Sg}d=H[H[a>>2]-12>>2]+a|0;H[l+8>>2]=H[d+12>>2];b=H[d+8>>2];H[l>>2]=H[d+4>>2];H[l+4>>2]=b;b=H[k+4>>2];H[d+4>>2]=b;H[d+8>>2]=b;H[d+12>>2]=b+c;xf(a,oj(a),s);b=H[l+4>>2];c=H[H[a>>2]-12>>2]+a|0;H[c+4>>2]=H[l>>2];H[c+8>>2]=b;H[c+12>>2]=H[l+8>>2];break Sg}xf(a,oj(a),s);break Sg;case 3:n=xb-16|0;xb=n;d=Qb(16);H[d+4>>2]=0;H[d+8>>2]=0;H[d>>2]=419784;H[d+12>>2]=0;e=H[a>>2]-12|0;b=H[e>>2]+a|0;c=b;k=H[b+12>>2];j=b+8|0;b=H[j>>2];if(k>>>0>b+3>>>0){H[c+8>>2]=b+4;b=H[e>>2]+a|0;k=H[b+12>>2];j=b+8|0;b=H[j>>2]}qh:{rh:{sh:{th:{uh:{if(b+3>>>0>=k>>>0){H[n+12>>2]=0;g=1;break uh}c=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[j>>2]=b+4;H[n+12>>2]=0;g=c+1|0;if(c>>>0>g>>>0){break th}}i=d+4|0;b=0;while(1){f=Qf(a,n+12|0);vh:{if(!f){break vh}if(H[d+12>>2]!=(b|0)){H[b>>2]=f;b=b+4|0;H[d+8>>2]=b;break vh}m=H[i>>2];h=b-m|0;c=h>>2;e=c+1|0;if(e>>>0>=1073741824){break sh}j=c<<2;b=h>>1;e=h>>>0<2147483644?b>>>0>e>>>0?b:e:1073741823;if(e){if(e>>>0>=1073741824){break rh}c=Qb(e<<2)}else{c=0}b=j+c|0;H[b>>2]=f;b=b+4|0;if((h|0)>0){Ob(c,m,h)}H[d+12>>2]=c+(e<<2);H[d+8>>2]=b;H[d+4>>2]=c;if(!m){break vh}Kb(m)}if(K[n+12>>2]>>0){continue}break}}xb=n+16|0;b=d;break qh}bd(i);X()}Td(413892);X()}xf(a,b,s);break Sg;case 4:u=0;wh:{if(!(b>>>15|0)){e=Qb(32);H[e+12>>2]=0;H[e+4>>2]=0;H[e+8>>2]=0;H[e+16>>2]=0;H[e+20>>2]=0;H[e>>2]=418992;H[e+24>>2]=0;H[e+28>>2]=0;c=H[a>>2]-12|0;b=H[c>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;b=H[c>>2]+a|0;d=H[b+8>>2];xh:{if(d+3>>>0>=K[b+12>>2]){break xh}c=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[b+8>>2]=d+4;b=c-1|0;if(b>>>0<=1){H[e+16>>2]=c}yh:{switch(b|0){case 0:Rp(a,e,1);xf(a,e,s);break wh;case 1:break yh;default:break xh}}Qp(a,e,1)}xf(a,e,s);break wh}zh:{Ah:{Bh:{d=a+236|0;b=H[d>>2];Ch:{if(!b){break Ch}c=d;while(1){e=s>>>0>K[b+16>>2];c=e?c:b;b=H[(e<<2)+b>>2];if(b){continue}break}if((c|0)==(d|0)){break Ch}if(s>>>0>=K[c+16>>2]){break Bh}}g=H[a+116>>2];d=Qb(32);H[d+12>>2]=0;H[d+4>>2]=0;H[d+8>>2]=0;H[d+16>>2]=0;H[d+20>>2]=0;H[d>>2]=418992;H[d+24>>2]=0;H[d+28>>2]=0;b=-16;e=H[a>>2]-12|0;c=H[e>>2]+a|0;f=H[c+8>>2];if(f+3>>>0>2]){b=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[c+8>>2]=f+4;b=b-16|0}c=Qb(b);H[d+12>>2]=b;H[d+4>>2]=c;b=H[e>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;b=H[e>>2]+a|0;e=H[b+8>>2];Dh:{if(e+3>>>0>=K[b+12>>2]){break Dh}c=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[b+8>>2]=e+4;b=c-1|0;if(b>>>0<=1){H[d+16>>2]=c}Eh:{switch(b|0){case 0:Rp(a,d,0);break Dh;case 1:break Eh;default:break Dh}}Qp(a,d,0)}xf(a,d,s);b=H[d+16>>2];e=g-20|0;if((b|0)==2){break Ah}e=(b|0)==1?g-32|0:g;break Ah}e=H[a+116>>2];b=H[H[a>>2]-12>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;b=H[c+20>>2];if((zb[H[H[b>>2]+12>>2]](b)|0)!=5){break zh}d=H[c+20>>2];e=e-4|0}h=Qb(e);m=H[H[a>>2]-12>>2]+a|0;i=H[m+12>>2];c=H[m+8>>2];b=i-c|0;f=b>>>0>>0?b:e;Fh:{if(!f){break Fh}b=0;if((f|0)!=1){g=f&-2;while(1){Gh:{if(c>>>0>=i>>>0){j=0;break Gh}j=I[c|0];c=c+1|0;H[m+8>>2]=c}F[b+h|0]=j;j=0;if(c>>>0>>0){j=I[c|0];c=c+1|0;H[m+8>>2]=c}F[h+(b|1)|0]=j;b=b+2|0;u=u+2|0;if((g|0)!=(u|0)){continue}break}}if(!(f&1)){break Fh}j=0;if(c>>>0>>0){j=I[c|0];H[m+8>>2]=c+1}F[b+h|0]=j}b=H[d+12>>2];j=H[d+4>>2];Hh:{Ih:{if(!(b|(j|!e))){j=Qb(e);H[d+12>>2]=e;H[d+4>>2]=j;b=e;break Ih}if(!b){break Hh}}c=H[d+8>>2];b=c+e>>>0>b>>>0?b-c|0:e;Ob(c+j|0,h,b);H[d+8>>2]=b+H[d+8>>2]}Kb(h)}}break Sg;case 5:o=0;h=xb-16|0;xb=h;g=H[a>>2]-12|0;b=H[g>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;c=Qb(40);H[c+4>>2]=419568;H[c>>2]=419508;H[c+16>>2]=0;H[c+20>>2]=0;F[c+35|0]=0;H[c+24>>2]=0;b=H[g>>2]+a|0;e=b;k=H[b+12>>2];d=b+8|0;b=H[d>>2];if(k>>>0<=b+3>>>0){r=0}else{y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());H[e+8>>2]=b+4;b=H[g>>2]+a|0;k=H[b+12>>2];d=b+8|0;b=H[d>>2];r=+y}M[c+8>>3]=r;if(b+3>>>0>>0){o=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d>>2]=b+4;b=H[g>>2]+a|0;k=H[b+12>>2];d=b+8|0;b=H[d>>2]}H[c+16>>2]=o;Jh:{if(b+3>>>0>=k>>>0){break Jh}e=I[b|0];H[d>>2]=b+4;if(e&1){F[c+20|0]=1}if(e&2){F[c+21|0]=1}if(e&8){F[c+23|0]=1}if(!(e&4)){break Jh}F[c+22|0]=1}b=H[g>>2]+a|0;H[b+8>>2]=H[b+8>>2]+4;d=0;b=H[g>>2]+a|0;e=H[b+8>>2];if(e+3>>>0>2]){d=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[b+8>>2]=e+4}e=d+1|0;b=e+e|0;n=Qb(b>>>0>>0?-1:b);G[n+(d<<1)>>1]=0;m=H[g>>2]+a|0;i=H[m+12>>2];b=H[m+8>>2];e=(i-b|0)/2|0;g=d>>>0>e>>>0?e:d;Kh:{if(!g){break Kh}if(i>>>0>b+1>>>0){f=0;if((g|0)!=1){e=g&-2;o=0;while(1){Lh:{if(i>>>0<=b+1>>>0){j=0;break Lh}j=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[m+8>>2]=b}G[n+(f<<1)>>1]=j;j=0;if(i>>>0>b+1>>>0){j=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[m+8>>2]=b}G[n+((f|1)<<1)>>1]=j;f=f+2|0;o=o+2|0;if((e|0)!=(o|0)){continue}break}}if(!(g&1)){break Kh}j=0;if(i>>>0>b+1>>>0){j=I[b|0]|I[b+1|0]<<8;H[m+8>>2]=b+2}G[n+(f<<1)>>1]=j;break Kh}Nb(n,0,g<<1)}zk(h,n,d);H[c+32>>2]=H[h+8>>2];b=H[h+4>>2];H[c+24>>2]=H[h>>2];H[c+28>>2]=b;Kb(n);xb=h+16|0;xf(a,c,s);break Sg;case 6:e=Qb(56);H[e>>2]=424336;d=0;D=0;h=H[H[a>>2]-12>>2]+a|0;c=H[h+8>>2];b=c+4|0;H[h+8>>2]=b;m=H[h+12>>2];if(m>>>0>c+7>>>0){b=c+8|0;c=I[c+4|0]|I[c+5|0]<<8|(I[c+6|0]<<16|I[c+7|0]<<24)}else{c=0}H[e+4>>2]=c;c=b+4|0;H[h+8>>2]=c;if(m>>>0>b+7>>>0){d=I[b+4|0]|I[b+5|0]<<8|(I[b+6|0]<<16|I[b+7|0]<<24);c=b+8|0;H[h+8>>2]=c}H[e+8>>2]=d;b=0;if(m>>>0>c+3>>>0){b=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);c=c+4|0}H[e+12>>2]=b;b=c+8|0;H[h+8>>2]=b;if(m>>>0>c+11>>>0){D=+(x(2,I[c+8|0]|I[c+9|0]<<8|(I[c+10|0]<<16|I[c+11|0]<<24)),B());b=c+12|0}M[e+16>>3]=D;c=b+4|0;H[h+8>>2]=c;if(m>>>0>b+7>>>0){y=(x(2,I[b+4|0]|I[b+5|0]<<8|(I[b+6|0]<<16|I[b+7|0]<<24)),B());c=b+8|0;H[h+8>>2]=c;r=+y}else{r=0}M[e+24>>3]=r;Mh:{if(m>>>0<=c+3>>>0){b=c;r=0;break Mh}y=(x(2,I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24)),B());b=c+4|0;H[h+8>>2]=b;r=+y}M[e+32>>3]=r;if(m>>>0>b+3>>>0){y=(x(2,I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24)),B());b=b+4|0;H[h+8>>2]=b;r=+y}else{r=0}M[e+40>>3]=r;c=0;Nh:{if(m>>>0<=b+3>>>0){d=0;break Nh}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[h+8>>2]=b}H[e+48>>2]=d;Oh:{if(m>>>0<=b+3>>>0){d=b;break Oh}i=I[b+3|0];f=I[b+2|0];g=I[b+1|0];c=I[b|0];d=b+4|0;H[h+8>>2]=d;c=g<<10|c<<2|f<<18|i<<26}b=0;if(m>>>0>d+3>>>0){b=I[d+1|0]<<11|I[d|0]<<3|I[d+2|0]<<19|I[d+3|0]<<27;d=d+4|0}H[h+8>>2]=(c+d|0)+b;xf(a,e,s);break Sg;case 7:break Tg;default:break Sg}}e=Qb(16);H[e+8>>2]=0;H[e>>2]=424408;j=0;o=0;g=H[H[a>>2]-12>>2]+a|0;c=H[g+8>>2];d=c+8|0;H[g+8>>2]=d;b=H[g+12>>2];Ph:{if(b>>>0>c+11>>>0){j=I[c+8|0]|I[c+9|0]<<8|(I[c+10|0]<<16|I[c+11|0]<<24);d=c+12|0;H[g+8>>2]=d;if(j>>>0>4){break Ph}}H[e+4>>2]=j;if(b>>>0>d>>>0){o=I[d|0];H[g+8>>2]=d+1}F[e+8|0]=o;d=0;j=0;b=H[g+8>>2];if(b>>>0>2]){j=I[b|0];H[g+8>>2]=b+1}F[e+9|0]=j;b=H[g+8>>2];if(b>>>0>2]){d=I[b|0];H[g+8>>2]=b+1}F[e+10|0]=d;d=0;j=0;b=H[g+8>>2];if(b>>>0>2]){j=I[b|0];H[g+8>>2]=b+1}F[e+11|0]=j;b=H[g+8>>2];if(K[g+12>>2]>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0}H[e+12>>2]=d;H[g+8>>2]=b+4}xf(a,e,s)}xb=l+16|0;break k;case 55:H[C+40>>2]=0;H[C+44>>2]=0;H[C+32>>2]=0;H[C+36>>2]=0;b=0;e=0;l=H[l>>2]+N|0;c=H[l+8>>2];k=H[l+4>>2];if(c>>>0>k+3>>>0){e=I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24);k=k+4|0;H[l+4>>2]=k}H[C+32>>2]=e;if(c>>>0>k+1>>>0){b=I[k|0]|I[k+1|0]<<8;k=k+2|0;H[l+4>>2]=k}G[C+36>>1]=b;b=0;if(c>>>0>k+1>>>0){b=I[k|0]|I[k+1|0]<<8;k=k+2|0;H[l+4>>2]=k}G[C+38>>1]=b;b=c-k|0;b=b>>>0<8?b:8;Qh:{if(!b){break Qh}if(c>>>0>k>>>0){k=k+1|0;H[l+4>>2]=k}if((b|0)==1){break Qh}if(c>>>0>k>>>0){k=k+1|0;H[l+4>>2]=k}if((b|0)==2){break Qh}if(c>>>0>k>>>0){k=k+1|0;H[l+4>>2]=k}if((b|0)==3){break Qh}if(c>>>0>k>>>0){k=k+1|0;H[l+4>>2]=k}if((b|0)==4){break Qh}if(c>>>0>k>>>0){k=k+1|0;H[l+4>>2]=k}if((b|0)==5){break Qh}if(c>>>0>k>>>0){k=k+1|0;H[l+4>>2]=k}if((b|0)==6){break Qh}e=(b|0)!=7;b=c>>>0>k>>>0;d=b?k+1|0:k;c=e&d>>>0>>0;k=c?d+1|0:d;if(!(b|c)){break Qh}H[l+4>>2]=k}b=I[k+4|0]|I[k+5|0]<<8|(I[k+6|0]<<16|I[k+7|0]<<24);H[C+40>>2]=I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24);H[C+44>>2]=b;c=H[H[a>>2]-12>>2]+N|0;b=H[c+4>>2];if(b+3>>>0>=K[c+8>>2]){break k}H[c+4>>2]=b+4;break k;case 28:k=H[c+8>>2];e=L;if(k>>>0>e+3>>>0){H[c+4>>2]=L+4;c=H[l>>2]+N|0;b=c+4|0;k=H[c+8>>2];e=H[c+4>>2]}if(e+3>>>0>=k>>>0){break k}H[b>>2]=e+4;break k;case 38:H[C+56>>2]=0;H[C+60>>2]=0;H[C+48>>2]=0;H[C+52>>2]=0;H[C+40>>2]=0;H[C+44>>2]=0;H[C+32>>2]=0;H[C+36>>2]=0;H[C+24>>2]=0;H[C+28>>2]=0;H[C+16>>2]=0;H[C+20>>2]=0;H[C+8>>2]=0;H[C+12>>2]=0;H[C>>2]=0;H[C+4>>2]=0;Ae(H[l>>2]+N|0,C+32|0);Ae(H[H[a>>2]-12>>2]+N|0,C);c=H[H[a>>2]-12>>2]+N|0;b=H[c+4>>2];if(b+3>>>0>=K[c+8>>2]){break k}H[c+4>>2]=b+4;break k;case 39:if(K[c+8>>2]<=L+3>>>0){break k}H[c+4>>2]=L+4;break k;case 40:if(K[c+8>>2]<=L+3>>>0){break k}H[c+4>>2]=L+4;break k;case 37:e=0;if(K[c+8>>2]>L+3>>>0){e=I[L|0]|I[L+1|0]<<8|(I[L+2|0]<<16|I[L+3|0]<<24);H[c+4>>2]=L+4}Xy(T,e);H[a+120>>2]=H[T>>2];b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}break k;case 36:e=0;if(K[c+8>>2]>L+3>>>0){e=I[L|0]|I[L+1|0]<<8|(I[L+2|0]<<16|I[L+3|0]<<24);H[c+4>>2]=L+4}Yy(T,e);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}break k;case 57:if(j<<16>>16<0){m=xb-16|0;xb=m;H[m>>2]=0;i=j&32767;Rh:{if(!i){break Rh}H[197455]=0;c=i<<2;d=aa(899,c|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){a=$()|0;_()|0;b=H[m>>2];if(b){H[m+4>>2]=b;Kb(b)}break d}H[m>>2]=d;b=c+d|0;H[m+8>>2]=b;u=0;g=Nb(d,0,c);H[m+4>>2]=b;f=0;d=a+4|0;l=H[a>>2]-12|0;h=d+H[l>>2]|0;b=H[h+4>>2];if(b>>>0>2]){f=I[b|0];H[h+4>>2]=b+1}c=H[m>>2];F[g|0]=f;b=H[h+4>>2];if(b>>>0>2]){u=I[b|0];H[h+4>>2]=b+1}F[g+1|0]=u;e=0;u=0;b=H[h+4>>2];if(b>>>0>2]){u=I[b|0];H[h+4>>2]=b+1}F[g+2|0]=u;b=H[h+4>>2];if(b>>>0>2]){e=I[b|0];H[h+4>>2]=b+1}F[g+3|0]=e;e=1;if(i>>>0>1){b=i>>>0>1?i:1;while(1){j=0;u=0;i=d+H[l>>2]|0;g=H[i+4>>2];if(g>>>0>2]){u=I[g|0];H[i+4>>2]=g+1}f=c+(e<<2)|0;F[f|0]=u;g=H[i+4>>2];if(g>>>0>2]){j=I[g|0];H[i+4>>2]=g+1}F[f+1|0]=j;j=0;u=0;g=H[i+4>>2];if(g>>>0>2]){u=I[g|0];H[i+4>>2]=g+1}F[f+2|0]=u;g=H[i+4>>2];if(g>>>0>2]){j=I[g|0];H[i+4>>2]=g+1}F[f+3|0]=j;e=e+1|0;if((b|0)!=(e|0)){continue}break}}b=H[m>>2];if(!b){break Rh}Kb(b)}xb=m+16|0;break k}v=0;m=xb-16|0;xb=m;H[m>>2]=0;Sh:{Th:{g=j&32767;if(g){H[197455]=0;d=g<<3;c=aa(899,d|0)|0;b=H[197455];H[197455]=0;if((b|0)==1){break Th}H[m>>2]=c;l=c+d|0;H[m+8>>2]=l;e=g-1&536870911;d=g&3;Uh:{if(!d){b=c;break Uh}b=c;while(1){G[b>>1]=0;G[b+2>>1]=0;G[b+4>>1]=1024;G[b+6>>1]=1024;b=b+8|0;v=v+1|0;if((d|0)!=(v|0)){continue}break}}if(e>>>0>=3){while(1){G[b+24>>1]=0;G[b+26>>1]=0;G[b+28>>1]=1024;G[b+30>>1]=1024;G[b+16>>1]=0;G[b+18>>1]=0;G[b+20>>1]=1024;G[b+22>>1]=1024;G[b+8>>1]=0;G[b+10>>1]=0;G[b+12>>1]=1024;G[b+14>>1]=1024;G[b>>1]=0;G[b+2>>1]=0;G[b+4>>1]=1024;G[b+6>>1]=1024;b=b+32|0;if((l|0)!=(b|0)){continue}break}}H[m+4>>2]=l;if(g){l=g>>>0>1?g:1;e=a+4|0;d=H[a>>2]-12|0;v=0;while(1){f=c+(v<<3)|0;i=e+H[d>>2]|0;b=H[i+4>>2];g=H[i+8>>2];Vh:{if(b+1>>>0>=g>>>0){o=0;break Vh}o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[i+4>>2]=b}G[f>>1]=o;o=0;Wh:{if(g>>>0<=b+1>>>0){k=0;break Wh}k=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[i+4>>2]=b}G[f+2>>1]=k;if(g>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;b=b+2|0;H[i+4>>2]=b}G[f+4>>1]=o;o=0;if(g>>>0>b+1>>>0){o=I[b|0]|I[b+1|0]<<8;H[i+4>>2]=b+2}G[f+6>>1]=o;v=v+1|0;if((l|0)!=(v|0)){continue}break}}Kb(c)}xb=m+16|0;break Sh}a=$()|0;_()|0;b=H[m>>2];if(b){H[m+4>>2]=b;Kb(b)}break d}break k;case 56:e=xb-48|0;xb=e;H[e+16>>2]=0;H[e+20>>2]=0;H[e+40>>2]=0;H[e+44>>2]=0;H[e+8>>2]=0;H[e+12>>2]=0;H[e>>2]=0;H[e+4>>2]=1072693248;H[e+32>>2]=0;H[e+36>>2]=0;H[e+24>>2]=0;H[e+28>>2]=1072693248;d=H[a>>2]-12|0;c=H[d>>2];b=c+a|0;k=b+8|0;j=H[k>>2];f=H[b+12>>2];if(j>>>0>>0){H[b+8>>2]=j+1;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(f>>>0>j>>>0){H[k>>2]=j+1;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(f>>>0>j>>>0){H[k>>2]=j+1;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(f>>>0>j>>>0){H[k>>2]=j+1;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(j+1>>>0>>0){H[k>>2]=j+2;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(j+1>>>0>>0){H[k>>2]=j+2;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(j+1>>>0>>0){H[k>>2]=j+2;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(f>>>0>j>>>0){H[k>>2]=j+1;c=H[d>>2];b=c+a|0;f=H[b+12>>2];k=b+8|0;j=H[k>>2]}if(f>>>0>j>>>0){H[k>>2]=j+1;c=H[d>>2]}lg((a+c|0)+4|0,e);xb=e+48|0;break k;case 43:H[C+32>>2]=0;H[C+36>>2]=1072693248;H[C+48>>2]=0;H[C+52>>2]=0;H[C+40>>2]=0;H[C+44>>2]=0;H[C+56>>2]=0;H[C+60>>2]=1072693248;H[R+8>>2]=0;H[R+12>>2]=0;H[R>>2]=0;H[R+4>>2]=0;b=C+32|0;lg(H[l>>2]+N|0,b);xh(H[a+120>>2],b,j&8192?3:2);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;break k;case 42:b=H[a+120>>2];H[b+400>>2]=0;H[b+404>>2]=1072693248;H[b+408>>2]=0;H[b+412>>2]=0;H[b+416>>2]=0;H[b+420>>2]=0;H[b+432>>2]=0;H[b+436>>2]=0;H[b+424>>2]=0;H[b+428>>2]=1072693248;H[b+440>>2]=0;H[b+444>>2]=0;W=M[b+624>>3];Y=+(H[b+664>>2]>>31|1);z=W*Y;U=z*0+0;Z=M[b+632>>3];Q=+(H[b+668>>2]>>31|1);A=Z*Q;r=A+0;D=U+r*0;J=U*0+r;w=D*0+J;M[b+568>>3]=w;r=z+0;V=A*0+0;z=r+V*0;A=r*0+V;r=z+A*0;M[b+544>>3]=r;M[b+520>>3]=w;M[b+496>>3]=r;w=D+J*0;M[b+560>>3]=w;r=z*0+A;M[b+552>>3]=r;M[b+512>>3]=w;M[b+504>>3]=r;w=U+ +H[b+656>>2];r=V+ +H[b+660>>2];A=w+r*0+0;r=w*0+r+0;w=A*0+r-Z*+H[b+644>>2]*Q;M[b+584>>3]=w;r=A+r*0-W*+H[b+640>>2]*Y;M[b+576>>3]=r;M[b+536>>3]=w;M[b+528>>3]=r;b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;break k;case 46:z=0;if(K[c+8>>2]>L+3>>>0){y=(x(2,I[L|0]|I[L+1|0]<<8|(I[L+2|0]<<16|I[L+3|0]<<24)),B());H[c+4>>2]=L+4;z=+y*.017453292519943295}w=ze(z);M[C+56>>3]=w;r=ne(z);M[C+40>>3]=r;M[C+32>>3]=w;M[C+48>>3]=-r;H[R+8>>2]=0;H[R+12>>2]=0;H[R>>2]=0;H[R+4>>2]=0;xh(H[a+120>>2],C+32|0,j&8192?3:2);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;break k;case 45:D=0;d=xb-48|0;xb=d;b=H[a>>2]-12|0;c=H[b>>2]+a|0;f=c+8|0;k=H[f>>2];h=H[c+12>>2];if(h>>>0<=k+3>>>0){r=0}else{y=(x(2,I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24)),B());H[c+8>>2]=k+4;b=H[b>>2]+a|0;h=H[b+12>>2];f=b+8|0;k=H[f>>2];r=+y}if(k+3>>>0>>0){y=(x(2,I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24)),B());H[f>>2]=k+4;D=+y}H[d+16>>2]=0;H[d+20>>2]=0;H[d+40>>2]=0;H[d+44>>2]=0;H[d+8>>2]=0;H[d+12>>2]=0;M[d>>3]=r;H[d+32>>2]=0;H[d+36>>2]=0;M[d+24>>3]=D;xh(H[a+120>>2],d,j&8192?3:2);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;xb=d+48|0;break k;case 47:z=0;d=xb-48|0;xb=d;b=H[H[a>>2]-12>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){y=(x(2,I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24)),B());H[b+8>>2]=c+4;z=+y}M[a+224>>3]=z;Xh:{Yh:{Zh:{switch((j&255)-3|0){case 0:r=+O(O(K[a+216>>2])*O(72));break Yh;case 1:r=+K[a+216>>2];break Yh;case 2:r=+O(O(K[a+216>>2])/O(300));break Yh;case 3:break Zh;default:break Xh}}r=+O(O(K[a+216>>2])/O(25.399999618530273))}z=z*r;M[a+224>>3]=z}H[d+16>>2]=0;H[d+20>>2]=0;H[d+40>>2]=0;H[d+44>>2]=0;H[d+8>>2]=0;H[d+12>>2]=0;M[d>>3]=z;H[d+32>>2]=0;H[d+36>>2]=0;M[d+24>>3]=z;xh(H[a+120>>2],d,2);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;xb=d+48|0;break k;case 41:H[C+32>>2]=0;H[C+36>>2]=1072693248;H[C+48>>2]=0;H[C+52>>2]=0;H[C+40>>2]=0;H[C+44>>2]=0;H[C+56>>2]=0;H[C+60>>2]=1072693248;H[R+8>>2]=0;H[R+12>>2]=0;H[R>>2]=0;H[R+4>>2]=0;b=C+32|0;lg(H[l>>2]+N|0,b);r=M[a+224>>3];M[C+32>>3]=r*M[C+32>>3];M[C+40>>3]=r*M[C+40>>3];M[C+48>>3]=r*M[C+48>>3];M[C+56>>3]=r*M[C+56>>3];M[C+64>>3]=r*M[C+64>>3];M[C+72>>3]=r*M[C+72>>3];xh(H[a+120>>2],b,4);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;break k;case 44:break l;default:break k}}D=0;d=xb-48|0;xb=d;b=H[a>>2]-12|0;c=H[b>>2]+a|0;f=c+8|0;k=H[f>>2];h=H[c+12>>2];if(h>>>0<=k+3>>>0){r=0}else{y=(x(2,I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24)),B());H[c+8>>2]=k+4;b=H[b>>2]+a|0;h=H[b+12>>2];f=b+8|0;k=H[f>>2];r=+y}if(k+3>>>0>>0){y=(x(2,I[k|0]|I[k+1|0]<<8|(I[k+2|0]<<16|I[k+3|0]<<24)),B());H[f>>2]=k+4;D=+y}H[d+16>>2]=0;H[d+20>>2]=0;H[d+8>>2]=0;H[d+12>>2]=0;H[d>>2]=0;H[d+4>>2]=1072693248;M[d+40>>3]=D;M[d+32>>3]=r;H[d+24>>2]=0;H[d+28>>2]=1072693248;xh(H[a+120>>2],d,j&8192?3:2);b=H[a+208>>2];if(b){zb[H[H[b>>2]+84>>2]](b)}F[a+213|0]=1;xb=d+48|0}e=H[a>>2];b=e-12|0;d=H[b>>2]+N|0;c=H[d+4>>2];H[d+4>>2]=c+(H[d>>2]+(H[a+116>>2]+L-(c+ca)|0)|0);H[a+116>>2]=0;b=H[b>>2];d=N+b|0;c=H[d+8>>2];k=H[d+4>>2];if(c-k>>>0<12){break i}if(!I[a+212|0]){continue}break}}a=H[e-12>>2]+a|0;if(!I[a+29|0]){H[a+8>>2]=H[a+4>>2]}xb=C+80|0;return}a=$()|0;_()|0;b=H[d+32>>2];if(b){H[d+36>>2]=b;Kb(b)}break d}a=$()|0;_()|0;b=H[e+48>>2];if(b){H[e+52>>2]=b;Kb(b)}break d}a=$()|0;_()|0;b=H[f>>2];if(b){H[f+4>>2]=b;Kb(b)}break d}a=$()|0;_()|0;b=H[d+128>>2];if(b){H[d+132>>2]=b;Kb(b)}}ea(a|0);X()}ea(l|0);X()}ea(g|0);X()}ea(f|0);X()}
-function g0(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,y=0,z=0,A=0,C=0,D=0,E=0,L=0,Q=0,R=0,S=0,U=O(0),V=0,W=0,Y=0,Z=0,fa=0;h=xb-160|0;xb=h;b=H[H[a>>2]-12>>2]+a|0;if(!H[b+4>>2]){F[b+29|0]=1}Y=a+29|0;v=a+4|0;Z=a+8|0;q=H[a>>2];d=H[q-12>>2];a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{while(1){m:{g=a+d|0;e=g+8|0;d=H[e>>2];f=H[g+12>>2];if(d>>>0>=f>>>0){break m}if(f-d>>>0<=7){F[g+29|0]=1;break l}b=q-12|0;n:{if(d+3>>>0>=f>>>0){c=0;break n}c=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[g+8>>2]=d+4;d=H[b>>2]+v|0;e=d+4|0;f=H[d+8>>2];d=H[d+4>>2]}o:{if(d+3>>>0>=f>>>0){break o}i=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[e>>2]=d+4;if(!i){break o}e=H[b>>2]+a|0;V=H[e+8>>2];d=i-8|0;if(d>>>0>H[e+12>>2]-V>>>0){F[e+29|0]=1;break l}fa=H[e+4>>2];H[a+116>>2]=d;if(c-123>>>0<=4294967173){if(H[a+36>>2]==1179469088&H[a+40>>2]==65536){break m}F[(H[b>>2]+a|0)+29|0]=1;break l}if(!((c|0)==1|W)){F[(H[b>>2]+a|0)+29|0]=1;break l}p:{q:{switch(c-1|0){case 113:H[h+8>>2]=0;H[h+12>>2]=0;H[h>>2]=0;H[h+4>>2]=0;H[h+48>>2]=0;H[h+52>>2]=1072693248;H[h+64>>2]=0;H[h+68>>2]=0;H[h+56>>2]=0;H[h+60>>2]=0;H[h+72>>2]=0;H[h+76>>2]=1072693248;F[h+95|0]=0;F[h+96|0]=0;F[h+97|0]=0;F[h+98|0]=0;H[h+88>>2]=0;H[h+92>>2]=0;H[h+80>>2]=0;H[h+84>>2]=0;f=0;e=0;d=H[b>>2]+v|0;Be(d,h);c=H[d+8>>2];b=H[d+4>>2];if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+16>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+20>>2]=f;f=0;r:{if(c>>>0<=b+3>>>0){e=0;break r}e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+24>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+28>>2]=f;f=0;e=0;if(b>>>0>>0){e=I[b|0];H[d+4>>2]=b+1}F[h+32|0]=e;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+33|0]=f;f=0;b=0;c=H[d+4>>2];if(c>>>0>2]){b=I[c|0];H[d+4>>2]=c+1}F[h+34|0]=b;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+35|0]=f;b=0;c=H[d+8>>2];f=H[d+4>>2];s:{if(c>>>0<=f+3>>>0){e=0;break s}e=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);f=f+4|0;H[d+4>>2]=f}H[h+36>>2]=e;if(c>>>0>f+3>>>0){b=I[f|0]|I[f+1|0]<<8|(I[f+2|0]<<16|I[f+3|0]<<24);H[d+4>>2]=f+4}H[h+40>>2]=b;lg(d,h+48|0);f=0;b=0;c=H[d+4>>2];if(c>>>0>2]){b=I[c|0];H[d+4>>2]=c+1}F[h+96|0]=b;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+97|0]=f;f=0;b=0;c=H[d+4>>2];if(c>>>0>2]){b=I[c|0];H[d+4>>2]=c+1}F[h+98|0]=b;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+99|0]=f;f=0;c=H[d+8>>2];b=H[d+4>>2];t:{if(c>>>0<=b+3>>>0){e=0;break t}e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+100>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+104>>2]=f;f=0;u:{if(c>>>0<=b+3>>>0){e=0;break u}e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+108>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+112>>2]=f;f=0;v:{if(c>>>0<=b+3>>>0){e=0;break v}e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+116>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+120>>2]=f;f=0;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+4>>2]=b+4}H[h+124>>2]=f;b=H[a+216>>2];if(I[b+213|0]?b:0){break p}b=H[a+208>>2];if(b){zb[H[H[b>>2]+112>>2]](b,h,(H[H[a>>2]-12>>2]+a|0)+4|0)}q=0;i=xb-16|0;xb=i;H[i+12>>2]=0;w:{if(!(!(zb[H[H[a>>2]+132>>2]](a,H[h+104>>2],H[h+108>>2],H[h+112>>2],H[h+116>>2],108,i+12|0,i+8|0,i+4|0)|0)|!H[a+208>>2])){x:{if(!I[h+35|0]){d=H[i+4>>2];if(!d){d=0;break x}c=H[i+8>>2];if(!c){break x}while(1){e=0;if(c){while(1){F[(H[i+12>>2]+(N(c,q)+e<<2)|0)+3|0]=I[h+34|0];e=e+1|0;c=H[i+8>>2];if(e>>>0>>0){continue}break}d=H[i+4>>2]}else{c=0}q=q+1|0;if(q>>>0>>0){continue}break}break x}d=H[i+4>>2];if(!d){d=0;break x}c=H[i+8>>2];if(!c){break x}j=+I[h+34|0]/255;while(1){e=0;if(c){while(1){b=H[i+12>>2]+(N(c,q)+e<<2)|0;l=j*+I[b+3|0];y:{if(l<4294967296&l>=0){c=~~l>>>0;break y}c=0}F[b+3|0]=c;e=e+1|0;c=H[i+8>>2];if(e>>>0>>0){continue}break}d=H[i+4>>2]}else{c=0}q=q+1|0;if(q>>>0>>0){continue}break}}e=H[i+12>>2];g=H[a+208>>2];b=e;if(!g){break w}c=H[h+16>>2];l=+(c|0);b=H[h+20>>2];j=+(b|0);zb[H[H[g>>2]+16>>2]](g,l,j,+(c+H[h+24>>2]|0)-l,+(b+H[h+28>>2]|0)-j,e,H[i+8>>2],d)}b=H[i+12>>2]}if(b){Kb(b)}xb=i+16|0;break p;case 75:H[h+8>>2]=0;H[h+12>>2]=0;H[h>>2]=0;H[h+4>>2]=0;H[h+48>>2]=0;H[h+52>>2]=1072693248;H[h+64>>2]=0;H[h+68>>2]=0;H[h+56>>2]=0;H[h+60>>2]=0;H[h+72>>2]=0;H[h+76>>2]=1072693248;F[h+95|0]=0;F[h+96|0]=0;F[h+97|0]=0;F[h+98|0]=0;H[h+88>>2]=0;H[h+92>>2]=0;H[h+80>>2]=0;H[h+84>>2]=0;f=0;e=0;d=H[b>>2]+v|0;Be(d,h);c=H[d+8>>2];b=H[d+4>>2];if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+16>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+20>>2]=e;e=0;z:{if(c>>>0<=b+3>>>0){f=0;break z}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+24>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+28>>2]=e;e=0;A:{if(c>>>0<=b+3>>>0){f=0;break A}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+32>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+36>>2]=e;e=0;f=0;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+4>>2]=b+4}H[h+40>>2]=f;lg(d,h+48|0);b=H[d+4>>2];if(b>>>0>2]){e=I[b|0];H[d+4>>2]=b+1}F[h+96|0]=e;f=0;b=0;c=H[d+4>>2];if(c>>>0>2]){b=I[c|0];H[d+4>>2]=c+1}F[h+97|0]=b;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+98|0]=f;e=0;f=0;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+99|0]=f;c=H[d+8>>2];b=H[d+4>>2];if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+100>>2]=e;e=0;B:{if(c>>>0<=b+3>>>0){f=0;break B}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+104>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+108>>2]=e;e=0;C:{if(c>>>0<=b+3>>>0){f=0;break C}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+112>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+4>>2]=b+4}H[h+116>>2]=e;b=H[a+216>>2];if(I[b+213|0]?b:0){break p}b=H[a+208>>2];if(b){zb[H[H[b>>2]+120>>2]](b,h,(H[H[a>>2]-12>>2]+a|0)+4|0)}g=xb-16|0;xb=g;H[g+12>>2]=0;D:{if(!(zb[H[H[a>>2]+132>>2]](a,H[h+104>>2],H[h+108>>2],H[h+112>>2],H[h+116>>2],100,g+12|0,g+8|0,g+4|0)|0)){break D}d=H[a+208>>2];if(!d){break D}c=H[h+16>>2];l=+(c|0);b=H[h+20>>2];j=+(b|0);zb[H[H[d>>2]+16>>2]](d,l,j,+(c+H[h+24>>2]|0)-l,+(b+H[h+28>>2]|0)-j,H[g+12>>2],H[g+8>>2],H[g+4>>2])}E:{F:{if(H[a+208>>2]){G:{H:{b=H[h+32>>2];if((b|0)<=10485960){if((b|0)==66){break H}if((b|0)!=5898313){break G}b=H[H[a+120>>2]+8>>2];if(!b){break G}c=Qb(4);H[g+12>>2]=c;F[c|0]=I[b+10|0];F[c+1|0]=I[b+9|0];b=I[b+8|0];F[c+3|0]=30;F[c+2|0]=b;H[g+4>>2]=1;H[g+8>>2]=1;break G}if((b|0)!=10485961){if((b|0)!=15728673){if((b|0)!=16711778){break G}b=Qb(4);H[g+12>>2]=b;F[b|0]=255;F[b+1|0]=255;F[b+2|0]=255;F[b+3|0]=255;H[g+4>>2]=1;H[g+8>>2]=1;break G}b=H[H[a+120>>2]+8>>2];if(!b){break G}c=Qb(4);H[g+12>>2]=c;F[c|0]=I[b+10|0];F[c+1|0]=I[b+9|0];b=I[b+8|0];F[c+3|0]=255;F[c+2|0]=b;H[g+4>>2]=1;H[g+8>>2]=1;break G}b=H[H[a+120>>2]+8>>2];if(!b){break G}c=Qb(4);H[g+12>>2]=c;F[c|0]=I[b+10|0];F[c+1|0]=I[b+9|0];b=I[b+8|0];F[c+3|0]=30;F[c+2|0]=b;H[g+4>>2]=1;H[g+8>>2]=1;break G}b=Qb(4);H[g+12>>2]=b;F[b|0]=0;F[b+1|0]=0;F[b+2|0]=0;F[b+3|0]=255;H[g+4>>2]=1;H[g+8>>2]=1}c=H[g+12>>2];if(!c){break E}e=H[a+208>>2];if(!e){break F}d=H[h+16>>2];l=+(d|0);b=H[h+20>>2];j=+(b|0);zb[H[H[e>>2]+16>>2]](e,l,j,+(d+H[h+24>>2]|0)-l,+(b+H[h+28>>2]|0)-j,c,H[g+8>>2],H[g+4>>2])}c=H[g+12>>2];if(!c){break E}}Kb(c)}xb=g+16|0;break p;case 80:H[h+8>>2]=0;H[h+12>>2]=0;H[h>>2]=0;H[h+4>>2]=0;d=0;f=0;e=H[b>>2]+v|0;Be(e,h);c=H[e+8>>2];b=H[e+4>>2];if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+16>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+20>>2]=f;f=0;I:{if(c>>>0<=b+3>>>0){d=0;break I}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+24>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+28>>2]=f;f=0;J:{if(c>>>0<=b+3>>>0){d=0;break J}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+32>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+36>>2]=f;f=0;K:{if(c>>>0<=b+3>>>0){d=0;break K}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+40>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+44>>2]=f;f=0;L:{if(c>>>0<=b+3>>>0){d=0;break L}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+48>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+52>>2]=f;f=0;M:{if(c>>>0<=b+3>>>0){d=0;break M}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+56>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+60>>2]=f;f=0;N:{if(c>>>0<=b+3>>>0){d=0;break N}d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+64>>2]=d;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[e+4>>2]=b+4}H[h+68>>2]=f;b=H[a+216>>2];if(I[b+213|0]?b:0){break p}b=H[a+208>>2];if(b){zb[H[H[b>>2]+116>>2]](b,h,(H[H[a>>2]-12>>2]+a|0)+4|0)}g=xb-16|0;xb=g;H[g+12>>2]=0;O:{if(!(!(zb[H[H[a>>2]+132>>2]](a,H[h+40>>2],H[h+44>>2],H[h+48>>2],H[h+52>>2],80,g+12|0,g+8|0,g+4|0)|0)|!H[a+208>>2])){kq(H[h+60>>2],g+12|0,H[g+8>>2],H[g+4>>2]);d=H[g+12>>2];e=H[a+208>>2];b=d;if(!e){break O}c=H[h+16>>2];l=+(c|0);b=H[h+20>>2];j=+(b|0);zb[H[H[e>>2]+16>>2]](e,l,j,+(c+H[h+64>>2]|0)-l,+(b+H[h+68>>2]|0)-j,d,H[g+8>>2],H[g+4>>2])}b=H[g+12>>2]}if(b){Kb(b)}xb=g+16|0;break p;case 79:H[h+8>>2]=0;H[h+12>>2]=0;H[h>>2]=0;H[h+4>>2]=0;d=0;f=0;e=H[b>>2]+v|0;Be(e,h);c=H[e+8>>2];b=H[e+4>>2];if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+16>>2]=f;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+20>>2]=d;d=0;P:{if(c>>>0<=b+3>>>0){f=0;break P}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+24>>2]=f;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+28>>2]=d;d=0;Q:{if(c>>>0<=b+3>>>0){f=0;break Q}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+32>>2]=f;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+36>>2]=d;d=0;R:{if(c>>>0<=b+3>>>0){f=0;break R}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+40>>2]=f;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+44>>2]=d;d=0;S:{if(c>>>0<=b+3>>>0){f=0;break S}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+48>>2]=f;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+52>>2]=d;d=0;T:{if(c>>>0<=b+3>>>0){f=0;break T}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+56>>2]=f;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[e+4>>2]=b}H[h+60>>2]=d;d=0;if(c>>>0>b+3>>>0){d=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[e+4>>2]=b+4}H[h+64>>2]=d;b=H[a+216>>2];if(I[b+213|0]?b:0){break p}b=H[a+208>>2];if(b){zb[H[H[b>>2]+124>>2]](b,h,(H[H[a>>2]-12>>2]+a|0)+4|0)}c=xb-16|0;xb=c;H[c+12>>2]=0;U:{if(!(zb[H[H[a>>2]+132>>2]](a,H[h+40>>2],H[h+44>>2],H[h+48>>2],H[h+52>>2],76,c+12|0,c+8|0,c+4|0)|0)){break U}b=H[a+208>>2];if(!b){break U}l=+H[h>>2];j=+H[h+4>>2];zb[H[H[b>>2]+16>>2]](b,l,j,+H[h+8>>2]-l,+H[h+12>>2]-j,H[c+12>>2],H[c+8>>2],H[c+4>>2])}b=H[c+12>>2];if(b){Kb(b)}xb=c+16|0;break p;case 76:H[h+8>>2]=0;H[h+12>>2]=0;H[h>>2]=0;H[h+4>>2]=0;H[h+48>>2]=0;H[h+52>>2]=1072693248;H[h+64>>2]=0;H[h+68>>2]=0;H[h+56>>2]=0;H[h+60>>2]=0;H[h+72>>2]=0;H[h+76>>2]=1072693248;F[h+95|0]=0;F[h+96|0]=0;F[h+97|0]=0;F[h+98|0]=0;H[h+88>>2]=0;H[h+92>>2]=0;H[h+80>>2]=0;H[h+84>>2]=0;f=0;e=0;d=H[b>>2]+v|0;Be(d,h);c=H[d+8>>2];b=H[d+4>>2];if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+16>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+20>>2]=e;e=0;V:{if(c>>>0<=b+3>>>0){f=0;break V}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+24>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+28>>2]=e;e=0;W:{if(c>>>0<=b+3>>>0){f=0;break W}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+32>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+36>>2]=e;e=0;f=0;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+4>>2]=b+4}H[h+40>>2]=f;lg(d,h+48|0);b=H[d+4>>2];if(b>>>0>2]){e=I[b|0];H[d+4>>2]=b+1}F[h+96|0]=e;f=0;b=0;c=H[d+4>>2];if(c>>>0>2]){b=I[c|0];H[d+4>>2]=c+1}F[h+97|0]=b;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+98|0]=f;e=0;f=0;b=H[d+4>>2];if(b>>>0>2]){f=I[b|0];H[d+4>>2]=b+1}F[h+99|0]=f;c=H[d+8>>2];b=H[d+4>>2];if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+100>>2]=e;e=0;X:{if(c>>>0<=b+3>>>0){f=0;break X}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+104>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+108>>2]=e;e=0;Y:{if(c>>>0<=b+3>>>0){f=0;break Y}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+112>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+116>>2]=e;e=0;Z:{if(c>>>0<=b+3>>>0){f=0;break Z}f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+4>>2]=b}H[h+120>>2]=f;if(c>>>0>b+3>>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+4>>2]=b+4}H[h+124>>2]=e;b=H[a+216>>2];if(I[b+213|0]?b:0){break p}b=H[a+208>>2];if(b){zb[H[H[b>>2]+128>>2]](b,h,(H[H[a>>2]-12>>2]+a|0)+4|0)}g=xb-16|0;xb=g;H[g+12>>2]=0;_:{if(!(!(zb[H[H[a>>2]+132>>2]](a,H[h+104>>2],H[h+108>>2],H[h+112>>2],H[h+116>>2],108,g+12|0,g+8|0,g+4|0)|0)|!H[a+208>>2])){kq(H[h+32>>2],g+12|0,H[g+8>>2],H[g+4>>2]);d=H[g+12>>2];e=H[a+208>>2];b=d;if(!e){break _}c=H[h+16>>2];l=+(c|0);b=H[h+20>>2];j=+(b|0);zb[H[H[e>>2]+16>>2]](e,l,j,+(c+H[h+24>>2]|0)-l,+(b+H[h+28>>2]|0)-j,d,H[g+8>>2],H[g+4>>2])}b=H[g+12>>2]}if(b){Kb(b)}xb=g+16|0;break p;case 28:f=0;e=0;k=xb-16|0;xb=k;H[k+8>>2]=0;H[k+12>>2]=0;d=H[H[a>>2]-12>>2]+a|0;b=H[d+8>>2];c=H[d+12>>2];if(b+3>>>0>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+8>>2]=b}H[k>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+8>>2]=b}H[k+4>>2]=f;f=0;$:{if(c>>>0<=b+3>>>0){e=0;break $}e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+8>>2]=b}H[k+8>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+8>>2]=b+4}H[k+12>>2]=f;b=H[a+216>>2];if(!(I[b+213|0]?b:0)){i=xb+-64|0;xb=i;c=H[k+8>>2];b=H[k>>2];d=(c|0)>(b|0);e=(d?1:-1)+c|0;H[k+8>>2]=e;d=b+(d?-1:1)|0;H[k>>2]=d;c=H[k+4>>2];b=H[k+12>>2];g=(c|0)<(b|0);c=(g?-1:1)+c|0;H[k+4>>2]=c;b=b+(g?1:-1)|0;H[k+12>>2]=b;M[i+40>>3]=c|0;M[i+48>>3]=e|0;M[i+56>>3]=b|0;M[i+32>>3]=d|0;c=zb[H[H[a>>2]+36>>2]](a)|0;b=H[c>>2];M[i+8>>3]=H[c+4>>2];M[i>>3]=b|0;b=H[c+8>>2];M[i+24>>3]=H[c+12>>2];M[i+16>>3]=b|0;b=H[a+208>>2];aa:{if(!b){break aa}zb[H[H[b>>2]+284>>2]](b,k);b=H[a+208>>2];zb[H[H[b>>2]+68>>2]](b,i+32|0,i);b=H[a+208>>2];if(!b){break aa}zb[H[H[b>>2]+84>>2]](b)}xb=i- -64|0}xb=k+16|0;break p;case 74:d=0;f=0;g=xb-16|0;xb=g;b=H[a>>2]-12|0;c=H[b>>2]+a|0;e=H[c+8>>2];if(e+3>>>0>2]){d=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[c+8>>2]=e+4}H[g+12>>2]=d;b=H[b>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){f=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}H[g+8>>2]=f;b=H[a+216>>2];if(!(I[b+213|0]?b:0)){c=g+12|0;b=g+8|0;d=H[a+208>>2];if(d){zb[H[H[d>>2]+288>>2]](d,c,b,(H[H[a>>2]-12>>2]+a|0)+4|0);b=H[a+208>>2];zb[H[H[b>>2]+60>>2]](b)}b=H[H[a>>2]-12>>2]+a|0;H[b+8>>2]=(H[a+116>>2]+H[b+8>>2]|0)-8}xb=g+16|0;break p;case 29:f=0;e=0;g=xb-16|0;xb=g;H[g+8>>2]=0;H[g+12>>2]=0;d=H[H[a>>2]-12>>2]+a|0;b=H[d+8>>2];c=H[d+12>>2];if(b+3>>>0>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+8>>2]=b}H[g>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+8>>2]=b}H[g+4>>2]=f;f=0;ba:{if(c>>>0<=b+3>>>0){e=0;break ba}e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[d+8>>2]=b}H[g+8>>2]=e;if(c>>>0>b+3>>>0){f=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[d+8>>2]=b+4}H[g+12>>2]=f;b=H[a+216>>2];if(!(I[b+213|0]?b:0)){c=xb-32|0;xb=c;b=H[g>>2];M[c+8>>3]=H[g+4>>2];M[c>>3]=b|0;b=H[g+8>>2];M[c+24>>3]=H[g+12>>2];M[c+16>>3]=b|0;b=H[a+208>>2];if(b){zb[H[H[b>>2]+312>>2]](b,g);b=H[a+208>>2];zb[H[H[b>>2]+64>>2]](b,c)}xb=c+32|0}xb=g+16|0;break p;case 66:d=0;b=H[b>>2]+v|0;c=H[b+4>>2];if(c+3>>>0>2]){d=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+4>>2]=c+4}H[h>>2]=d;b=H[a+216>>2];if(I[b+213|0]?b:0){break p}b=H[a+208>>2];ca:{if(!b){break ca}zb[H[H[b>>2]+276>>2]](b,h);c=H[a+156>>2];if(!c){break ca}b=H[a+208>>2];zb[H[H[b>>2]+72>>2]](b,c,H[h>>2],H[a+120>>2]+496|0);b=H[a+156>>2];if(b){zb[H[H[b>>2]+4>>2]](b);H[a+156>>2]=0}b=H[a+208>>2];if(!b){break ca}zb[H[H[b>>2]+84>>2]](b)}break p;case 27:b=H[a+208>>2];da:{if(!b){break da}zb[H[H[b>>2]+292>>2]](b);b=H[a+208>>2];zb[H[H[b>>2]+60>>2]](b);b=H[a+208>>2];if(!b){break da}zb[H[H[b>>2]+84>>2]](b)}break p;case 0:b=0;d=0;Be((H[H[a>>2]-12>>2]+a|0)+4|0,a+4|0);Be((H[H[a>>2]-12>>2]+a|0)+4|0,a+20|0);i=H[a>>2]-12|0;c=H[i>>2]+a|0;e=H[c+8>>2];if(e+3>>>0>2]){b=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[c+8>>2]=e+4}H[a+36>>2]=b;b=H[i>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){d=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}H[a+40>>2]=d;d=0;b=0;c=H[i>>2]+a|0;e=H[c+8>>2];if(e+3>>>0>2]){b=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[c+8>>2]=e+4}H[a+44>>2]=b;b=H[i>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){d=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}H[a+48>>2]=d;d=0;b=0;c=H[i>>2]+a|0;e=H[c+8>>2];if(e+1>>>0>2]){b=I[e|0]|I[e+1|0]<<8;H[c+8>>2]=e+2}G[a+52>>1]=b;b=H[i>>2]+a|0;c=H[b+8>>2];if(c+1>>>0>2]){d=I[c|0]|I[c+1|0]<<8;H[b+8>>2]=c+2}G[a+54>>1]=d;d=0;b=0;c=H[i>>2]+a|0;e=H[c+8>>2];if(e+3>>>0>2]){b=I[e|0]|I[e+1|0]<<8|(I[e+2|0]<<16|I[e+3|0]<<24);H[c+8>>2]=e+4}H[a+56>>2]=b;b=H[i>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){d=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}H[a+60>>2]=d;e=0;d=0;b=H[i>>2]+a|0;c=H[b+8>>2];if(c+3>>>0>2]){d=I[c|0]|I[c+1|0]<<8|(I[c+2|0]<<16|I[c+3|0]<<24);H[b+8>>2]=c+4}H[a+64>>2]=d;g=H[i>>2]+a|0;b=H[g+8>>2];d=H[g+12>>2];if(b+3>>>0>>0){e=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);b=b+4|0;H[g+8>>2]=b}H[a+68>>2]=e;e=0;c=0;if(d>>>0>b+3>>>0){c=I[b|0]|I[b+1|0]<<8|(I[b+2|0]<<16|I[b+3|0]<<24);H[g+8>>2]=b+4}H[a+72>>2]=c;g=H[i>>2]+a|0;d=H[g+8>>2];c=H[g+12>>2];if(d+3>>>0>>0){e=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);d=d+4|0;H[g+8>>2]=d}H[a+76>>2]=e;b=0;if(c>>>0>d+3>>>0){b=I[d|0]|I[d+1|0]<<8|(I[d+2|0]<<16|I[d+3|0]<<24);H[g+8>>2]=d+4}H[a+80>>2]=b;ea:{if(!(H[a+36>>2]==1179469088&H[a+40>>2]==65536)){F[(H[H[a>>2]-12>>2]+a|0)+29|0]=1;break ea}b=H[H[a>>2]-12>>2]+a|0;H[b+8>>2]=(H[a+116>>2]+H[b+8>>2]|0)-80;A=+H[a+76>>2];e=a+68|0;w=+H[e>>2];y=+H[a+20>>2]/100/A*w;j=T(y+.5);fa:{if(P(j)<2147483648){c=~~j;break fa}c=-2147483648}H[a+84>>2]=c;s=+H[a+80>>2];p=+H[a+72>>2];l=+H[a+24>>2]/100/s*p;j=T(l+.5);ga:{if(P(j)<2147483648){b=~~j;break ga}b=-2147483648}H[a+104>>2]=b;H[a+100>>2]=c;H[a+88>>2]=b;j=T(+H[a+28>>2]/100/A*w-y+.5);ha:{if(P(j)<2147483648){d=~~j;break ha}d=-2147483648}c=d+c|0;H[a+92>>2]=c;j=T(+H[a+32>>2]/100/s*p-l+.5);ia:{if(P(j)<2147483648){d=~~j;break ia}d=-2147483648}b=d+b|0;H[a+112>>2]=b;H[a+108>>2]=c;H[a+96>>2]=b;Vy(H[a+120>>2],e);Uy(H[a+120>>2],e);b=H[a+208>>2];if(b){zb[H[H[b>>2]+8>>2]](b);b=H[a+208>>2];zb[H[H[b>>2]+108>>2]](b,a+4|0)}}break p;case 13:d=H[b>>2]+v|0;g=d;e=d+4|0;c=H[d+8>>2];d=H[d+4>>2];if(c>>>0>d+3>>>0){H[g+4>>2]=d+4;d=H[b>>2]+v|0;e=d+4|0;c=H[d+8>>2];d=H[d+4>>2]}if(d+3>>>0>>0){H[e>>2]=d+4;e=H[b>>2]+Z|0;d=H[e>>2]}H[e>>2]=(d+i|0)-20;c=H[b>>2]+v|0;b=H[c+4>>2];if(b+3>>>0