UNPKG

ef-infinite-canvas

Version:

An infinite version of the html canvas

1,714 lines 209 kB
var di = Object.defineProperty; var fi = (s, t, e) => t in s ? di(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; var a = (s, t, e) => fi(s, typeof t != "symbol" ? t + "" : t, e); let gi = class { constructor(t) { this.viewBox = t; } restore() { this.viewBox.restoreState(); } save() { this.viewBox.saveState(); } reset() { this.viewBox.resetState(); } }; const Y = class Y { constructor(t, e) { this.x = t, this.y = e; } mod() { return Math.sqrt(this.modSq()); } modSq() { return this.x * this.x + this.y * this.y; } minus(t) { return new Y(this.x - t.x, this.y - t.y); } plus(t) { return new Y(this.x + t.x, this.y + t.y); } dot(t) { return this.x * t.x + this.y * t.y; } cross(t) { return this.x * t.y - this.y * t.x; } equals(t) { return this.x === t.x && this.y === t.y; } getPerpendicular() { return new Y(-this.y, this.x); } scale(t) { return new Y(t * this.x, t * this.y); } projectOn(t) { return t.scale(this.dot(t) / t.modSq()); } matrix(t, e, n, i) { return new Y(t * this.x + e * this.y, n * this.x + i * this.y); } inSameDirectionAs(t) { return this.cross(t) === 0 && this.dot(t) >= 0; } isInOppositeDirectionAs(t) { return this.cross(t) === 0 && this.dot(t) < 0; } isOnSameSideOfOriginAs(t, e) { return this.isInSmallerAngleBetweenPoints(t, e) || t.isInSmallerAngleBetweenPoints(this, e) || e.isInSmallerAngleBetweenPoints(this, t); } isInSmallerAngleBetweenPoints(t, e) { const n = t.cross(e); return n > 0 ? t.cross(this) >= 0 && this.cross(e) >= 0 : n < 0 ? t.cross(this) <= 0 && this.cross(e) <= 0 : t.dot(e) > 0 ? this.cross(t) === 0 && this.dot(t) > 0 : !0; } }; a(Y, "origin", new Y(0, 0)); let h = Y; function ct(s) { return s.toFixed(10).replace(/\.?0+$/, ""); } const b = class b { constructor(t, e, n, i, r, o) { a(this, "scale"); this.a = t, this.b = e, this.c = n, this.d = i, this.e = r, this.f = o, this.scale = Math.sqrt(t * i - e * n); } getMaximumLineWidthScale() { const t = this.a + this.c, e = this.b + this.d, n = this.a - this.c, i = this.b - this.d; return Math.sqrt(Math.max(t * t + e * e, n * n + i * i)); } getRotationAngle() { const t = this.a / this.scale, e = this.b / this.scale; if (t === 0) return e > 0 ? Math.PI / 2 : 3 * Math.PI / 2; const n = Math.atan(e / t); return t > 0 ? e > 0 ? n : e === 0 ? 0 : 2 * Math.PI + n : e > 0 ? Math.PI + n : e === 0 ? Math.PI : Math.PI + n; } applyToPointAtInfinity(t) { return { direction: this.untranslated().apply(t.direction) }; } apply(t) { return new h(this.a * t.x + this.c * t.y + this.e, this.b * t.x + this.d * t.y + this.f); } untranslated() { const { x: t, y: e } = this.apply(h.origin); return this.before(b.translation(-t, -e)); } before(t) { const e = t.a * this.a + t.c * this.b, n = t.b * this.a + t.d * this.b, i = t.a * this.c + t.c * this.d, r = t.b * this.c + t.d * this.d, o = t.a * this.e + t.c * this.f + t.e, c = t.b * this.e + t.d * this.f + t.f; return new b(e, n, i, r, o, c); } equals(t) { return this.a === t.a && this.b === t.b && this.c === t.c && this.d === t.d && this.e === t.e && this.f === t.f; } inverse() { var t = this.a * this.d - this.b * this.c; if (t == 0) throw new Error("error calculating inverse: zero determinant"); const e = this.d / t, n = -this.b / t, i = -this.c / t, r = this.a / t, o = (this.c * this.f - this.d * this.e) / t, c = (this.b * this.e - this.a * this.f) / t; return new b(e, n, i, r, o, c); } static translation(t, e) { return new b(1, 0, 0, 1, t, e); } static scale(t) { return new b(t, 0, 0, t, 0, 0); } static zoom(t, e, n, i, r) { const o = 1 - n; return i !== void 0 ? new b(n, 0, 0, n, t * o + i, e * o + r) : new b(n, 0, 0, n, t * o, e * o); } static translateZoom(t, e, n, i, r, o, c, u) { const l = n - t, f = i - e, d = l * l + f * f; if (d === 0) throw new Error("divide by 0"); const m = c - r, w = u - o, C = m * m + w * w, S = Math.sqrt(C / d); return b.zoom(t, e, S, r - t, o - e); } static rotation(t, e, n) { const i = Math.cos(n), r = Math.sin(n), o = 1 - i; return new b( i, r, -r, i, t * o + e * r, -t * r + e * o ); } static translateRotateZoom(t, e, n, i, r, o, c, u) { const l = n - t, f = i - e, d = l * l + f * f; if (d === 0) throw new Error("divide by 0"); const m = c - r, w = u - o, C = t * i - e * n, S = n * l + i * f, L = t * l + e * f, V = (l * m + f * w) / d, j = (l * w - f * m) / d, Q = -j, Pt = V, Ct = (r * S - c * L - C * w) / d, It = (o * S - u * L + C * m) / d; return new b(V, j, Q, Pt, Ct, It); } static create(t) { if (t instanceof b) return t; const { a: e, b: n, c: i, d: r, e: o, f: c } = t; return new b(e, n, i, r, o, c); } toString() { return `x: (${ct(this.a)}, ${ct(this.b)}), y: (${ct(this.c)}, ${ct(this.d)}), d: (${ct(this.e)}, ${ct(this.f)})`; } }; a(b, "identity", new b(1, 0, 0, 1, 0, 0)); let v = b; class y { constructor(t, e) { this.propertyName = t, this.noopInstruction = e; } changeInstanceValue(t, e) { return this.valuesAreEqual(t[this.propertyName], e) ? t : t.changeProperty(this.propertyName, e); } isEqualForInstances(t, e) { return this.valuesAreEqual(t[this.propertyName], e[this.propertyName]); } getInstructionToChange(t, e) { return this.valuesAreEqual(t[this.propertyName], e[this.propertyName]) ? this.noopInstruction : this.changeToNewValue(e[this.propertyName]); } valueIsTransformableForInstance(t) { return !0; } } const x = () => { }; class mi extends y { valuesAreEqual(t, e) { return t.equals(e); } changeToNewValue(t) { return (e, n) => { const { a: i, b: r, c: o, d: c, e: u, f: l } = n.getTransformationForInstruction(t); e.setTransform(i, r, o, c, u, l); }; } } const Gt = new mi("transformation", x); class pi { constructor(t) { this.viewBox = t; } getTransform() { if (DOMMatrix) { const t = this.viewBox.state.current.transformation; return new DOMMatrix([ t.a, t.b, t.c, t.d, t.e, t.f ]); } } resetTransform() { this.viewBox.changeState((t) => Gt.changeInstanceValue(t, v.identity)); } rotate(t) { this.addTransformation(v.rotation(0, 0, t)); } scale(t, e) { this.addTransformation(new v(t, 0, 0, e, 0, 0)); } setTransform(t, e, n, i, r, o) { let c, u, l, f, d, m; typeof t == "number" ? (c = t, u = e, l = n, f = i, d = r, m = o) : t.a !== void 0 ? (c = t.a, u = t.b, l = t.c, f = t.d, d = t.e, m = t.f) : (c = t.m11, u = t.m12, l = t.m21, f = t.m22, d = t.m41, m = t.m42), this.viewBox.changeState((w) => Gt.changeInstanceValue(w, new v(c, u, l, f, d, m))); } transform(t, e, n, i, r, o) { this.addTransformation(new v(t, e, n, i, r, o)); } translate(t, e) { this.addTransformation(v.translation(t, e)); } addTransformation(t) { const e = this.viewBox.state.current.transformation, n = t.before(e); this.viewBox.changeState((i) => Gt.changeInstanceValue(i, n)); } } class vi extends y { valuesAreEqual(t, e) { return t === e; } changeToNewValue(t) { return (e) => e.globalAlpha = t; } } const wn = new vi("globalAlpha", x); class wi extends y { valuesAreEqual(t, e) { return t === e; } changeToNewValue(t) { return (e) => e.globalCompositeOperation = t; } } const Pn = new wi("globalCompositeOperation", x); class Pi { constructor(t) { this.viewBox = t; } get globalAlpha() { return this.viewBox.state.current.globalAlpha; } set globalAlpha(t) { this.viewBox.changeState((e) => wn.changeInstanceValue(e, t)); } get globalCompositeOperation() { return this.viewBox.state.current.globalCompositeOperation; } set globalCompositeOperation(t) { this.viewBox.changeState((e) => Pn.changeInstanceValue(e, t)); } } class Ci extends y { valuesAreEqual(t, e) { return t === e; } changeToNewValue(t) { return (e) => { e.imageSmoothingEnabled = t; }; } } const Cn = new Ci("imageSmoothingEnabled", x); class Ii extends y { valuesAreEqual(t, e) { return t === e; } changeToNewValue(t) { return (e) => { e.imageSmoothingQuality = t; }; } } const In = new Ii("imageSmoothingQuality", x); class Ti { constructor(t) { this.viewBox = t; } get imageSmoothingEnabled() { return this.viewBox.state.current.imageSmoothingEnabled; } set imageSmoothingEnabled(t) { this.viewBox.changeState((e) => Cn.changeInstanceValue(e, t)); } get imageSmoothingQuality() { return this.viewBox.state.current.imageSmoothingQuality; } set imageSmoothingQuality(t) { this.viewBox.changeState((e) => In.changeInstanceValue(e, t)); } } class Xt { } class Tn extends Xt { constructor(t) { super(), this.fillStrokeStyle = t; } setTransform(t) { this.fillStrokeStyle.setTransform(t); } getInstructionToSetUntransformed(t) { return (e) => { e[t] = this.fillStrokeStyle; }; } getInstructionToSetTransformed(t) { return (e) => { e[t] = this.fillStrokeStyle; }; } } class Sn { constructor(t) { this.propName = t; } changeInstanceValue(t, e) { return t.changeProperty(this.propName, e); } isEqualForInstances(t, e) { return t[this.propName] === e[this.propName]; } getInstructionToChange(t, e) { const n = e[this.propName]; return this.isEqualForInstances(t, e) ? !(n instanceof Xt) || t.fillAndStrokeStylesTransformed === e.fillAndStrokeStylesTransformed ? () => { } : e.fillAndStrokeStylesTransformed ? n.getInstructionToSetTransformed(this.propName) : n.getInstructionToSetUntransformed(this.propName) : n instanceof Xt ? e.fillAndStrokeStylesTransformed ? n.getInstructionToSetTransformed(this.propName) : n.getInstructionToSetUntransformed(this.propName) : (i) => { i[this.propName] = e[this.propName]; }; } valueIsTransformableForInstance(t) { return !(t[this.propName] instanceof Tn); } } const yn = new Sn("fillStyle"), xn = new Sn("strokeStyle"); class Si { constructor(t) { this.viewBox = t; } set fillStyle(t) { this.viewBox.changeState((e) => yn.changeInstanceValue(e, t)); } set strokeStyle(t) { this.viewBox.changeState((e) => xn.changeInstanceValue(e, t)); } createLinearGradient(t, e, n, i) { return this.viewBox.createLinearGradient(t, e, n, i); } createPattern(t, e) { return this.viewBox.createPattern(t, e); } createRadialGradient(t, e, n, i, r, o) { return this.viewBox.createRadialGradient(t, e, n, i, r, o); } createConicGradient(t, e, n) { return this.viewBox.createConicGradient(t, e, n); } } class yi extends y { valuesAreEqual(t, e) { return t === e; } changeToNewValue(t) { return (e) => { e.shadowColor = t; }; } } const bn = new yi("shadowColor", x); class xi extends y { changeToNewValue(t) { return (e, n) => { const i = v.translation(t.x, t.y), r = n.translateInfiniteCanvasContextTransformationToBitmapTransformation(i), { x: o, y: c } = r.apply(h.origin); e.shadowOffsetX = o, e.shadowOffsetY = c; }; } valuesAreEqual(t, e) { return t.x === e.x && t.y == e.y; } } const Ce = new xi("shadowOffset", x); class bi extends y { changeToNewValue(t) { return (e, n) => { const i = v.translation(t, 0), o = n.translateInfiniteCanvasContextTransformationToBitmapTransformation(i).apply(h.origin).mod(); e.shadowBlur = o; }; } valuesAreEqual(t, e) { return t === e; } } const On = new bi("shadowBlur", x); class Oi { constructor(t) { this.viewBox = t; } get shadowBlur() { return this.viewBox.state.current.shadowBlur; } set shadowBlur(t) { this.viewBox.changeState((e) => On.changeInstanceValue(e, t)); } get shadowOffsetX() { return this.viewBox.state.current.shadowOffset.x; } set shadowOffsetX(t) { const e = new h(t, this.viewBox.state.current.shadowOffset.y); this.viewBox.changeState((n) => Ce.changeInstanceValue(n, e)); } get shadowOffsetY() { return this.viewBox.state.current.shadowOffset.y; } set shadowOffsetY(t) { const e = new h(this.viewBox.state.current.shadowOffset.x, t); this.viewBox.changeState((n) => Ce.changeInstanceValue(n, e)); } get shadowColor() { return this.viewBox.state.current.shadowColor; } set shadowColor(t) { this.viewBox.changeState((e) => bn.changeInstanceValue(e, t)); } } const Ln = "[+-]?(?:\\d*\\.)?\\d+(?:e[+-]?\\d+)?", Bn = "[+-]?(?:0*\\.)?0+(?:e[+-]?\\d+)?", An = "(?:ch|em|ex|ic|rem|vh|vw|vmax|vmin|vb|vi|cqw|cqh|cqi|cqb|cqmin|cqmax|px|cm|mm|Q|in|pc|pt)", Yt = `(?:${Bn}|${Ln}${An})`, Dn = `blur\\((${Yt})\\)`, _e = "[^())\\s]+(?:\\([^)]*?\\))?", En = `drop-shadow\\((${Yt})\\s+(${Yt})\\s*?(?:(?:(${Yt})\\s*?(${_e})?)|(${_e}))?\\)`, tn = `${Dn}|${En}`; function W(s, t) { const e = s.match(new RegExp(`(?:(${Bn})|(${Ln})(${An}))`)); return e[1] ? 0 : t.getNumberOfPixels(Number.parseFloat(e[2]), e[3]); } class en { constructor(t) { this.stringRepresentation = t; } toTransformedString() { return this.stringRepresentation; } getShadowOffset() { return null; } } class Oe { constructor(t, e) { this.stringRepresentation = t, this.size = e; } toTransformedString(t) { return `blur(${t.translateInfiniteCanvasContextTransformationToBitmapTransformation(v.translation(this.size, 0)).apply(h.origin).mod()}px)`; } getShadowOffset() { return null; } static tryCreate(t, e) { const n = t.match(new RegExp(Dn)); return n === null ? null : new Oe(t, W(n[1], e)); } } class lt { constructor(t, e, n, i, r) { this.stringRepresentation = t, this.offsetX = e, this.offsetY = n, this.blurRadius = i, this.color = r; } toTransformedString(t) { const e = t.translateInfiniteCanvasContextTransformationToBitmapTransformation(v.translation(this.offsetX, this.offsetY)), { x: n, y: i } = e.apply(h.origin); if (this.blurRadius !== null) { const o = t.translateInfiniteCanvasContextTransformationToBitmapTransformation(v.translation(this.blurRadius, 0)).apply(h.origin).mod(); return this.color ? `drop-shadow(${n}px ${i}px ${o}px ${this.color})` : `drop-shadow(${n}px ${i}px ${o}px)`; } return this.color ? `drop-shadow(${n}px ${i}px ${this.color})` : `drop-shadow(${n}px ${i}px)`; } getShadowOffset() { return new h(this.offsetX, this.offsetY); } static tryCreate(t, e) { const n = t.match(new RegExp(En)); return n === null ? null : n[5] ? new lt( t, W(n[1], e), W(n[2], e), null, n[5] ) : n[4] ? new lt( t, W(n[1], e), W(n[2], e), W(n[3], e), n[4] ) : n[3] ? new lt( t, W(n[1], e), W(n[2], e), W(n[3], e), null ) : new lt( t, W(n[1], e), W(n[2], e), null, null ); } } const yt = class yt { constructor(t, e) { this.stringRepresentation = t, this.parts = e; } toString() { return this.parts.map((t) => t.stringRepresentation).join(" "); } toTransformedString(t) { return this.parts.map((e) => e.toTransformedString(t)).join(" "); } getShadowOffset() { for (const t of this.parts) { const e = t.getShadowOffset(); if (e !== null) return e; } return null; } static create(t, e) { const i = t.match(new RegExp(`${tn}|((?!\\s|${tn}).)+`, "g")).map((r) => this.createPart(r, e)); return new yt(t, i); } static createPart(t, e) { let n = Oe.tryCreate(t, e); return n !== null || (n = lt.tryCreate(t, e), n != null) ? n : new en(t); } }; a(yt, "none", new yt("none", [new en("none")])); let Ut = yt; class Li extends y { valuesAreEqual(t, e) { return t.stringRepresentation === e.stringRepresentation; } changeToNewValue(t) { return (e, n) => e.filter = t.toTransformedString(n); } } const Rn = new Li("filter", x); class Bi { constructor(t, e) { this.viewBox = t, this.cssLengthConverterFactory = e; } get filter() { return this.viewBox.state.current.filter.stringRepresentation; } set filter(t) { const e = Ut.create(t, this.cssLengthConverterFactory.create()); this.viewBox.changeState((n) => Rn.changeInstanceValue(n, e)); } } class Ai { constructor(t) { this.viewBox = t; } clearRect(t, e, n, i) { this.viewBox.clearArea(t, e, n, i); } fillRect(t, e, n, i) { let r = (o) => o.fill(); this.viewBox.fillRect(t, e, n, i, r); } strokeRect(t, e, n, i) { this.viewBox.strokeRect(t, e, n, i); } } class Di { constructor(t) { this.viewBox = t; } isFillRule(t) { return t === "evenodd" || t === "nonzero"; } beginPath() { this.viewBox.beginPath(); } clip(t, e) { let n = this.isFillRule(t) ? (i) => { i.clip(t); } : (i) => { i.clip(); }; this.viewBox.clipPath(n); } fill(t, e) { if ((!t || this.isFillRule(t)) && !this.viewBox.currentPathCanBeFilled()) return; let n = this.isFillRule(t) ? (i) => { i.fill(t); } : (i) => { i.fill(); }; this.viewBox.fillPath(n); } isPointInPath(t, e, n, i) { return !0; } isPointInStroke(t, e, n) { return !0; } stroke(t) { this.viewBox.strokePath(); } } class Ei { drawFocusIfNeeded(t, e) { } scrollPathIntoView(t) { } } var z = /* @__PURE__ */ ((s) => (s[s.None = 0] = "None", s[s.Relative = 1] = "Relative", s[s.Absolute = 2] = "Absolute", s))(z || {}), T = /* @__PURE__ */ ((s) => (s[s.Positive = 0] = "Positive", s[s.Negative = 1] = "Negative", s))(T || {}); const $t = { direction: new h(0, 1) }, Kt = { direction: new h(0, -1) }, jt = { direction: new h(-1, 0) }, Qt = { direction: new h(1, 0) }; function Ri(s, t, e, n) { const i = e.minus(s), r = n.cross(t), o = n.getPerpendicular().dot(i) / r; return s.plus(t.scale(o)); } class st { constructor(t, e, n) { a(this, "leftNormal"); a(this, "rightNormal"); this.point = t, this.leftHalfPlane = e, this.rightHalfPlane = n, this.leftNormal = e.normalTowardInterior, this.rightNormal = n.normalTowardInterior; } replaceLeftHalfPlane(t) { return new st(this.point, t, this.rightHalfPlane); } replaceRightHalfPlane(t) { return new st(this.point, this.leftHalfPlane, t); } isContainedByHalfPlaneWithNormal(t) { return t.isInSmallerAngleBetweenPoints(this.leftNormal, this.rightNormal); } containsPoint(t) { return this.leftHalfPlane.containsPoint(t) && this.rightHalfPlane.containsPoint(t); } containsLineSegmentWithDirection(t) { return this.containsPoint(this.point.plus(t)) || this.containsPoint(this.point.minus(t)); } isContainedByVertex(t) { return this.isContainedByHalfPlaneWithNormal(t.leftNormal) && this.isContainedByHalfPlaneWithNormal(t.rightNormal); } getContainingHalfPlaneThroughPoint(t) { let e = t.minus(this.point).getPerpendicular(); if (e.cross(this.leftHalfPlane.normalTowardInterior) === 0) return this.leftHalfPlane; if (e.cross(this.rightHalfPlane.normalTowardInterior) === 0) return this.rightHalfPlane; const n = this.leftNormal.plus(this.rightNormal); return e.dot(n) <= 0 && (e = e.scale(-1)), new P(t, e); } static create(t, e, n) { return e.normalTowardInterior.cross(n.normalTowardInterior) >= 0 ? new st(t, e, n) : new st(t, n, e); } } class P { constructor(t, e) { a(this, "lengthOfNormal"); this.base = t, this.normalTowardInterior = e, this.lengthOfNormal = e.mod(); } getDistanceFromEdge(t) { return t.minus(this.base).dot(this.normalTowardInterior) / this.lengthOfNormal; } transform(t) { const e = t.apply(this.base), n = t.apply(this.base.plus(this.normalTowardInterior.getPerpendicular())), i = t.apply(this.base.plus(this.normalTowardInterior)); return P.throughPointsAndContainingPoint(e, n, i); } complement() { return new P(this.base, this.normalTowardInterior.scale(-1)); } expandByDistance(t) { const e = this.base.plus(this.normalTowardInterior.scale(-t / this.normalTowardInterior.mod())); return new P(e, this.normalTowardInterior); } expandToIncludePoint(t) { return this.containsPoint(t) ? this : new P(t, this.normalTowardInterior); } containsPoint(t) { return this.getDistanceFromEdge(t) >= 0; } interiorContainsPoint(t) { return this.getDistanceFromEdge(t) > 0; } containsInfinityInDirection(t) { return t.dot(this.normalTowardInterior) >= 0; } isContainedByHalfPlane(t) { return this.normalTowardInterior.inSameDirectionAs(t.normalTowardInterior) && t.getDistanceFromEdge(this.base) >= 0; } intersectWithLine(t, e) { return { point: Ri(this.base, this.normalTowardInterior.getPerpendicular(), t, e), halfPlane: this }; } isParallelToLine(t, e) { return this.normalTowardInterior.getPerpendicular().cross(e) === 0; } getIntersectionWith(t) { const e = this.intersectWithLine(t.base, t.normalTowardInterior.getPerpendicular()); return st.create(e.point, this, t); } static throughPointsAndContainingPoint(t, e, n) { const i = P.withBorderPoints(t, e); for (let r of i) if (r.containsPoint(n)) return r; } static withBorderPointAndInfinityInDirection(t, e) { return P.withBorderPoints(t, t.plus(e)); } static withBorderPoints(t, e) { const n = e.minus(t).getPerpendicular(); return [ new P(t, n), new P(t, n.scale(-1)) ]; } } class Fi { getVertices() { return []; } expandToIncludePoint(t) { return this; } expandToIncludePolygon(t) { return this; } expandToIncludeInfinityInDirection(t) { return this; } expandByDistance(t) { return this; } intersects(t) { return !0; } expandToInclude(t) { return this; } transform(t) { return this; } intersectWithLineSegment(t) { return t; } contains(t) { return !0; } intersectWith(t) { return t; } join(t) { return this; } intersectWithRay(t) { return t; } intersectWithLine(t) { return t; } intersectWithConvexPolygon(t) { return t; } isContainedByRay(t) { return !1; } isContainedByLineSegment(t) { return !1; } isContainedByLine(t) { return !1; } isContainedByConvexPolygon(t) { return !1; } intersectsRay(t) { return !0; } intersectsLineSegment(t) { return !0; } intersectsLine(t) { return !0; } intersectsConvexPolygon(t) { return !0; } } const pt = new Fi(); class Wi { getVertices() { return []; } intersectWith(t) { return this; } join(t) { return t; } intersectWithConvexPolygon(t) { return this; } intersects(t) { return !1; } intersectWithLineSegment(t) { return this; } intersectWithRay(t) { return this; } intersectWithLine(t) { return this; } expandToInclude(t) { return t; } transform(t) { return this; } contains(t) { return !1; } isContainedByConvexPolygon(t) { return !0; } isContainedByRay(t) { return !0; } isContainedByLineSegment(t) { return !0; } isContainedByLine(t) { return !0; } intersectsRay(t) { return !1; } intersectsConvexPolygon(t) { return !1; } intersectsLineSegment(t) { return !1; } intersectsLine(t) { return !1; } expandByDistance(t) { return this; } expandToIncludePoint(t) { return this; } expandToIncludeInfinityInDirection(t) { return this; } expandToIncludePolygon(t) { return t; } } const A = new Wi(); class p { constructor(t, e) { a(this, "halfPlanes"); this.vertices = e, this.halfPlanes = t, this.vertices = this.vertices || p.getVertices(this.halfPlanes); } findVertex(t) { for (let e of this.vertices) if (e.point.equals(t)) return e; } intersects(t) { return t.intersectsConvexPolygon(this); } intersectWith(t) { return t.intersectWithConvexPolygon(this); } join(t) { if (this.contains(t)) return this; if (t.contains(this)) return t; let e = t; for (let n of this.vertices) e = e.expandToIncludePoint(n.point); for (let n of this.getPointsAtInfinityFromHalfPlanes()) this.containsInfinityInDirection(n) && (e = e.expandToIncludeInfinityInDirection(n)); return e; } intersectWithRay(t) { return t.intersectWithConvexPolygon(this); } intersectWithLine(t) { return t.intersectWithConvexPolygon(this); } intersectWithLineSegment(t) { return t.intersectWithConvexPolygon(this); } contains(t) { return t.isContainedByConvexPolygon(this); } containsHalfPlane(t) { for (let e of this.halfPlanes) if (!t.isContainedByHalfPlane(e)) return !1; return !0; } isContainedByHalfPlane(t) { for (let n of this.vertices) if (!t.containsPoint(n.point)) return !1; const e = t.complement(); for (let n of this.halfPlanes) if (n.isContainedByHalfPlane(t)) return !0; for (let n of this.halfPlanes) { const i = this.getVerticesOnHalfPlane(n); if (i.length <= 1 && (n.isContainedByHalfPlane(e) || e.isContainedByHalfPlane(n))) return !1; const r = n.getIntersectionWith(t), o = i.find((c) => c.point.equals(r.point)); if (o) { if (!o.isContainedByHalfPlaneWithNormal(t.normalTowardInterior)) return !1; } else { if (i.length === 0) return !1; if (this.containsPoint(r.point)) return !1; } } return !this.containsHalfPlane(t); } getVertices() { return this.vertices.map((t) => t.point); } expandToIncludePoint(t) { if (this.vertices.length === 0) { const f = this.halfPlanes.map((d) => d.expandToIncludePoint(t)); return new p(f); } const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(); let i = null, r = null; const o = [], c = /* @__PURE__ */ new Set(); for (const f of this.vertices) { const d = f.leftHalfPlane; n.has(d) ? n.delete(d) : e.add(d); const m = f.rightHalfPlane; if (e.has(m) ? e.delete(m) : n.add(m), d.containsPoint(t)) { if (c.add(d), m.containsPoint(t)) { c.add(m), o.push(f); continue; } i = f; continue; } m.containsPoint(t) && (c.add(m), r = f); } if (o.length === this.vertices.length) return this; let u, l; if (i === null) { const f = [...e][0]; if (!f) return this; u = f.expandToIncludePoint(t); } else u = i.getContainingHalfPlaneThroughPoint(t), u !== i.leftHalfPlane && o.push(i.replaceRightHalfPlane(u)); if (r === null) { const f = [...n][0]; if (!f) return this; l = f.expandToIncludePoint(t); } else l = r.getContainingHalfPlaneThroughPoint(t), l !== r.rightHalfPlane && o.push(r.replaceLeftHalfPlane(l)); return c.add(u), c.add(l), o.push(new st(t, u, l)), new p([...c], o); } expandToIncludeInfinityInDirection(t) { if (this.containsInfinityInDirection(t)) return this; let e = this.halfPlanes.filter((n) => n.containsInfinityInDirection(t)).concat(this.getTangentPlanesThroughInfinityInDirection(t)); return e = p.getHalfPlanesNotContainingAnyOther(e), e.length === 0 ? pt : new p(e); } getIntersectionsWithLine(t, e) { const n = []; for (let i of this.halfPlanes) { if (i.isParallelToLine(t, e)) continue; const r = i.intersectWithLine(t, e), o = this.findVertex(r.point); o && !o.containsLineSegmentWithDirection(e) || this.containsPoint(r.point) && n.push(r); } return n; } expandByDistance(t) { return new p(this.halfPlanes.map((e) => e.expandByDistance(t))); } transform(t) { return new p(this.halfPlanes.map((e) => e.transform(t))); } intersectWithConvexPolygon(t) { if (t.isContainedByConvexPolygon(this)) return t; if (this.isContainedByConvexPolygon(t)) return this; if (this.isOutsideConvexPolygon(t)) return A; const e = p.getHalfPlanesNotContainingAnyOther(this.halfPlanes.concat(t.halfPlanes)), r = p.groupVerticesByPoint(p.getVertices(e)).map((c) => p.getVerticesNotContainingAnyOther(c)).reduce((c, u) => c.concat(u), []); if (r.length === 0) return new p(e); const o = p.getHalfPlanes(r); return new p(o); } containsInfinityInDirection(t) { for (let e of this.halfPlanes) if (!e.containsInfinityInDirection(t)) return !1; return !0; } containsPoint(t) { for (let e of this.halfPlanes) if (!e.containsPoint(t)) return !1; return !0; } intersectsRay(t) { return t.intersectsConvexPolygon(this); } intersectsLineSegment(t) { return t.intersectsConvexPolygon(this); } intersectsLine(t) { return t.intersectsConvexPolygon(this); } intersectsConvexPolygon(t) { return this.isContainedByConvexPolygon(t) || t.isContainedByConvexPolygon(this) ? !0 : !this.isOutsideConvexPolygon(t); } isOutsideConvexPolygon(t) { for (let e of t.halfPlanes) if (this.isContainedByHalfPlane(e.complement())) return !0; for (let e of this.halfPlanes) if (t.isContainedByHalfPlane(e.complement())) return !0; return !1; } getVerticesOnHalfPlane(t) { const e = []; for (let n of this.vertices) (n.leftHalfPlane === t || n.rightHalfPlane === t) && e.push(n); return e; } hasAtMostOneVertex(t) { let e = 0; for (let n of this.vertices) if ((n.leftHalfPlane === t || n.rightHalfPlane === t) && (e++, e > 1)) return !1; return !0; } getTangentPlanesThroughInfinityInDirection(t) { const e = []; for (let n of this.vertices) { const i = P.withBorderPointAndInfinityInDirection(n.point, t); for (let r of i) this.isContainedByHalfPlane(r) && e.push(r); } return e; } getPointsAtInfinityFromHalfPlanes() { const t = []; for (let e of this.halfPlanes) { const n = e.normalTowardInterior, i = n.getPerpendicular(); t.push(n), t.push(i), t.push(i.scale(-1)); } return t; } isContainedByRay(t) { return !1; } isContainedByLineSegment(t) { return !1; } isContainedByLine(t) { return !1; } isContainedByConvexPolygon(t) { for (let e of t.halfPlanes) if (!this.isContainedByHalfPlane(e)) return !1; return !0; } static getHalfPlanes(t) { const e = []; for (let n of t) e.indexOf(n.leftHalfPlane) === -1 && e.push(n.leftHalfPlane), e.indexOf(n.rightHalfPlane) === -1 && e.push(n.rightHalfPlane); return e; } static getVerticesNotContainingAnyOther(t) { const e = []; for (let n = 0; n < t.length; n++) { let i = !0; for (let r = 0; r < t.length; r++) if (n !== r && t[r].isContainedByVertex(t[n])) { i = !1; break; } i && e.push(t[n]); } return e; } static getHalfPlanesNotContainingAnyOther(t) { const e = []; for (let n of t) { let i = !0; for (let r of e) if (r.isContainedByHalfPlane(n)) { i = !1; break; } i && e.push(n); } return e; } static groupVerticesByPoint(t) { const e = []; for (let n of t) { let i; for (let r of e) if (r[0].point.equals(n.point)) { i = r; break; } i ? i.push(n) : e.push([n]); } return e; } static getVertices(t) { const e = []; for (let n = 0; n < t.length; n++) for (let i = n + 1; i < t.length; i++) { const r = t[n], o = t[i]; if (r.complement().isContainedByHalfPlane(o)) continue; const c = r.getIntersectionWith(o); let u = !0; for (let l = 0; l < t.length; l++) { if (l === n || l === i) continue; if (!t[l].containsPoint(c.point)) { u = !1; break; } } u && e.push(c); } return e; } static createTriangleWithInfinityInTwoDirections(t, e, n) { const i = e.getPerpendicular(), r = n.getPerpendicular(); return e.cross(n) < 0 ? new p([ new P(t, i.scale(-1)), new P(t, r) ]) : new p([ new P(t, i), new P(t, r.scale(-1)) ]); } static createFromHalfPlane(t) { return new p([t]); } static createTriangleWithInfinityInDirection(t, e, n) { const i = e.minus(t).projectOn(n.getPerpendicular()); return new p([ new P(t, i), new P(e, i.scale(-1)), P.throughPointsAndContainingPoint(t, e, t.plus(n)) ]); } static createTriangle(t, e, n) { return new p([ P.throughPointsAndContainingPoint(t, e, n), P.throughPointsAndContainingPoint(t, n, e), P.throughPointsAndContainingPoint(e, n, t) ]); } } function $(...s) { return (...t) => { for (const e of s) e && e(...t); }; } function ki(s, t) { return t ? (e, n) => { e.save(), t(e, n), s(e, n), e.restore(); } : s; } function Hi(s) { return s === z.Relative ? (t, e) => { const { a: n, b: i, c: r, d: o, e: c, f: u } = e.getBitmapTransformationToTransformedInfiniteCanvasContext(); t.transform(n, i, r, o, c, u); } : s === z.Absolute ? (t, e) => { const { a: n, b: i, c: r, d: o, e: c, f: u } = e.getBitmapTransformationToInfiniteCanvasContext(); t.setTransform(n, i, r, o, c, u); } : null; } function Vi(s, t) { let e = s.area; return e && t.lineWidth > 0 && (e = e.expandByDistance(t.lineWidth / 2)), e; } function Mi(s) { return { lineWidth: s.current.getMaximumLineWidth(), lineDashPeriod: s.current.getLineDashPeriod(), shadowOffsets: s.current.getShadowOffsets() }; } function Ni(s) { return { lineWidth: 0, lineDashPeriod: 0, shadowOffsets: s.current.getShadowOffsets() }; } class M { constructor(t, e, n, i, r, o, c) { this.instruction = t, this.area = e, this.build = n, this.takeClippingRegionIntoAccount = i, this.transformationKind = r, this.state = o, this.tempState = c; } static forStrokingPath(t, e, n) { return M.forPath(t, e, Mi, n); } static forFillingPath(t, e, n) { return M.forPath(t, e, Ni, n); } static forPath(t, e, n, i) { const r = e.current.isTransformable(), o = r ? z.None : z.Relative, c = e.currentlyTransformed(r), u = n(c), l = i(c), f = Vi(l, u); return new M( t, f, (d) => l.drawPath(d, c, u), !0, o, c ); } getDrawnArea() { let t = this.area; const e = this.state; if (e.current.shadowBlur !== 0 || !e.current.shadowOffset.equals(h.origin)) { const n = t.expandByDistance(e.current.shadowBlur).transform(v.translation(e.current.shadowOffset.x, e.current.shadowOffset.y)); t = t.join(n); } return e.current.clippingRegion && this.takeClippingRegionIntoAccount && (t = t.intersectWith(e.current.clippingRegion)), t; } getModifiedInstruction() { let t = Hi(this.transformationKind); if (this.tempState) { const n = this.takeClippingRegionIntoAccount ? this.state.getInstructionToConvertToStateWithClippedPath(this.tempState) : this.state.getInstructionToConvertToState(this.tempState); t = $(t, n); } return ki(this.instruction, t); } } class Le { constructor(t) { a(this, "added", []); a(this, "addedLast"); this.initiallyWithState = t; } get length() { return this.added.length; } get currentlyWithState() { return this.addedLast ? this.addedLast : this.initiallyWithState; } reconstructState(t, e) { e.setInitialState(t); } get stateOfFirstInstruction() { return this.initiallyWithState.stateOfFirstInstruction; } get state() { return this.currentlyWithState.state; } get initialState() { return this.initiallyWithState.initialState; } addClippedPath(t) { this.currentlyWithState.addClippedPath(t); } add(t) { this.added.push(t), this.addedLast = t; } removeAll(t) { let e; for (; (e = this.added.findIndex(t)) > -1; ) this.removeAtIndex(e); } contains(t) { return !!this.added.find(t); } setInitialState(t) { this.initiallyWithState.setInitialState(t); } setInitialStateWithClippedPaths(t) { this.initiallyWithState.setInitialStateWithClippedPaths(t); } beforeIndex(t) { return t === 0 ? this.initiallyWithState.state : this.added[t - 1].state; } removeAtIndex(t) { t === this.added.length - 1 ? this.added.length === 1 ? this.addedLast = void 0 : this.addedLast = this.added[t - 1] : this.reconstructState(this.beforeIndex(t), this.added[t + 1]), this.added.splice(t, 1); } } class Be { constructor(t, e) { a(this, "stateConversion"); this.initialState = t, this.state = e, this.stateConversion = () => { }; } setInitialState(t) { this.initialState = t; const e = this.initialState.getInstructionToConvertToState(this.state); this.stateConversion = e; } get stateOfFirstInstruction() { return this.state; } addClippedPath(t) { this.state = this.state.withClippedPath(t); } setInitialStateWithClippedPaths(t) { this.initialState = t; const e = this.initialState.getInstructionToConvertToStateWithClippedPath(this.state); this.stateConversion = e; } } class K extends Be { constructor(t, e, n, i) { super(t, e), this.instruction = n, this.stateConversion = i; } execute(t, e) { this.stateConversion && this.stateConversion(t, e), this.instruction(t, e); } static create(t, e) { return new K(t, t, e, () => { }); } } class mt extends Be { constructor(t, e, n, i) { super(t, e), this.instruction = n, this.stateConversion = i; } makeExecutable() { return new K(this.initialState, this.state, this.instruction, this.stateConversion); } static create(t, e) { return new mt(t, t, e, () => { }); } } function I(s) { return s.direction !== void 0; } function _(s, t) { return I(s) ? t.applyToPointAtInfinity(s) : t.apply(s); } class zi { constructor(t, e) { this.areaBuilder = t, this.transformation = e; } addPosition(t) { this.areaBuilder.addPosition(_(t, this.transformation)); } } class Ae { constructor(t, e) { this.base = t, this.direction = e; } pointIsOnSameLine(t) { return t.minus(this.base).cross(this.direction) === 0; } comesBefore(t, e) { return e.minus(t).dot(this.direction) >= 0; } lineSegmentIsOnSameLine(t) { return this.direction.cross(t.direction) === 0 && this.pointIsOnSameLine(t.point1); } expandLineByDistance(t) { const e = this.direction.getPerpendicular(), n = new P(this.base, e).expandByDistance(t), i = new P(this.base, e.scale(-1)).expandByDistance(t); return new p([n, i]); } getPointsInSameDirection(t, e) { return this.comesBefore(e, t) ? { point1: e, point2: t } : { point1: t, point2: e }; } pointIsBetweenPoints(t, e, n) { return t.minus(e).dot(this.direction) * t.minus(n).dot(this.direction) <= 0; } intersectsConvexPolygon(t) { if (this.isContainedByConvexPolygon(t)) return !0; const e = t.getIntersectionsWithLine(this.base, this.direction); for (let n of e) if (this.interiorContainsPoint(n.point)) return !0; return !1; } } class ae extends Ae { getVertices() { return []; } intersectWith(t) { return t.intersectWithLine(this); } join(t) { return t.expandToIncludeInfinityInDirection(this.direction).expandToIncludeInfinityInDirection(this.direction.scale(-1)); } intersectWithConvexPolygon(t) { if (!this.intersectsConvexPolygon(t)) return A; if (this.isContainedByConvexPolygon(t)) return this; const e = t.getIntersectionsWithLine(this.base, this.direction); let n, i; for (let r of e) (!n && !i || !n && this.comesBefore(r.point, i) || !i && this.comesBefore(n, r.point) || n && i && this.pointIsBetweenPoints(r.point, n, i)) && (r.halfPlane.normalTowardInterior.dot(this.direction) > 0 ? n = r.point : i = r.point); return n && i ? new E(n, i) : n ? new N(n, this.direction) : new N(i, this.direction.scale(-1)); } intersectWithLine(t) { return this.intersectsLine(t) ? this : A; } intersectWithLineSegment(t) { return this.lineSegmentIsOnSameLine(t) ? t : A; } intersectWithRay(t) { return this.intersectsRay(t) ? t : A; } isContainedByConvexPolygon(t) { return t.containsPoint(this.base) && t.containsInfinityInDirection(this.direction) && t.containsInfinityInDirection(this.direction.scale(-1)); } isContainedByLine(t) { return this.intersectsSubsetOfLine(t); } isContainedByLineSegment(t) { return !1; } isContainedByRay(t) { return !1; } contains(t) { return t.isContainedByLine(this); } intersectsLine(t) { return this.intersectsSubsetOfLine(t); } intersectsSubsetOfLine(t) { return this.pointIsOnSameLine(t.base) && this.direction.cross(t.direction) === 0; } intersectsLineSegment(t) { return this.lineSegmentIsOnSameLine(t); } intersectsRay(t) { return this.intersectsSubsetOfLine(t); } intersects(t) { return t.intersectsLine(this); } expandToIncludePoint(t) { return this.pointIsOnSameLine(t) ? this : p.createTriangleWithInfinityInDirection(this.base, t, this.direction).expandToIncludeInfinityInDirection(this.direction.scale(-1)); } expandByDistance(t) { return this.expandLineByDistance(t); } expandToIncludeInfinityInDirection(t) { const e = t.cross(this.direction), n = this.direction.getPerpendicular(); return e === 0 ? this : e > 0 ? p.createFromHalfPlane(new P(this.base, n.scale(-1))) : p.createFromHalfPlane(new P(this.base, n)); } transform(t) { const e = t.apply(this.base); return new ae(e, t.apply(this.base.plus(this.direction)).minus(e)); } interiorContainsPoint(t) { return this.pointIsOnSameLine(t); } } class N extends Ae { getVertices() { return [this.base]; } intersectWith(t) { return t.intersectWithRay(this); } join(t) { return t.expandToIncludePoint(this.base).expandToIncludeInfinityInDirection(this.direction); } intersectWithConvexPolygon(t) { if (!this.intersectsConvexPolygon(t)) return A; if (this.isContainedByConvexPolygon(t)) return this; const e = t.getIntersectionsWithLine(this.base, this.direction); let n = this.base, i; for (let r of e) (!i && this.comesBefore(n, r.point) || i && this.pointIsBetweenPoints(r.point, n, i)) && (r.halfPlane.normalTowardInterior.dot(this.direction) > 0 ? n = r.point : i = r.point); return i ? new E(n, i) : new N(n, this.direction); } intersectWithRay(t) { return this.isContainedByRay(t) ? this : t.isContainedByRay(this) ? t : this.interiorContainsPoint(t.base) ? new E(this.base, t.base) : A; } intersectWithLine(t) { return t.intersectWithRay(this); } intersectWithLineSegment(t) { if (t.isContainedByRay(this)) return t; if (!this.lineSegmentIsOnSameLine(t)) return A; let { point2: e } = this.getPointsInSameDirection(t.point1, t.point2); return this.comesBefore(e, this.base) ? A : new E(this.base, e); } isContainedByConvexPolygon(t) { return t.containsPoint(this.base) && t.containsInfinityInDirection(this.direction); } isContainedByRay(t) { return t.containsPoint(this.base) && t.containsInfinityInDirection(this.direction); } isContainedByLine(t) { return t.intersectsSubsetOfLine(this); } isContainedByLineSegment(t) { return !1; } contains(t) { return t.isContainedByRay(this); } intersectsRay(t) { return this.isContainedByRay(t) || t.isContainedByRay(this) || this.interiorContainsPoint(t.base); } intersectsLine(t) { return t.intersectsSubsetOfLine(this); } intersectsLineSegment(t) { if (t.isContainedByRay(this)) return !0; if (!this.lineSegmentIsOnSameLine(t)) return !1; let { point2: e } = this.getPointsInSameDirection(t.point1, t.point2); return !this.comesBefore(e, this.base); } intersects(t) { return t.intersectsRay(this); } expandToIncludePoint(t) { return this.containsPoint(t) ? this : this.pointIsOnSameLine(t) ? new N(t, this.direction) : p.createTriangleWithInfinityInDirection(this.base, t, this.direction); } expandByDistance(t) { const e = this.expandLineByDistance(t), n = new P(this.base, this.direction).expandByDistance(t); return e.intersectWithConvexPolygon(new p([n])); } expandToIncludeInfinityInDirection(t) { return t.inSameDirectionAs(this.direction) ? this : this.direction.cross(t) === 0 ? new ae(this.base, this.direction) : p.createTriangleWithInfinityInTwoDirections(this.base, this.direction, t); } transform(t) { const e = t.apply(this.base); return new N(e, t.apply(this.base.plus(this.direction)).minus(e)); } interiorContainsPoint(t) { return this.pointIsOnSameLine(t) && !this.comesBefore(t, this.base); } containsInfinityInDirection(t) { return this.direction.inSameDirectionAs(t); } containsPoint(t) { return this.pointIsOnSameLine(t) && this.comesBefore(this.base, t); } } class E extends Ae { constructor(t, e) { super(t, e.minus(t)), this.point1 = t, this.point2 = e; } getVertices() { return [this.point1, this.point2]; } join(t) { return t.expandToIncludePoint(this.point1).expandToIncludePoint(this.point2); } intersectWith(t) { return t.intersectWithLineSegment(this); } intersectWithLineSegment(t) { if (this.isContainedByLineSegment(t)) return this; if (t.isContainedByLineSegment(this)) return t; if (!this.lineSegmentIsOnSameLine(t)) return A; let { point1: e, point2: n } = this.getPointsInSameDirection(t.point1, t.point2); return this.comesBefore(n, this.point1) || this.comesBefore(this.point2, e) ? A : this.comesBefore(this.point1, e) ? new E(e, this.point2) : new E(this.point1, n); } intersectWithRay(t) { return t.intersectWithLineSegment(this); } intersectWithLine(t) { return t.intersectWithLineSegment(this); } isContainedByRay(t) { return t.containsPoint(this.point1) && t.containsPoint(this.point2); } isContainedByLine(t) { return t.intersectsSubsetOfLine(this); } isContainedByLineSegment(t) { return t.containsPoint(this.point1) && t.containsPoint(this.point2); } intersectWithConvexPolygon(t) { if (!this.intersectsConvexPolygon(t)) return A; if (this.isContainedByConvexPolygon(t)) return this; const e = t.getIntersectionsWithLine(this.point1, this.direction); let n = this.point1, i = this.point2; for (let r of e) this.pointIsBetweenPoints(r.point, n, i) && (r.halfPlane.normalTowardInterior.dot(this.direction) > 0 ? n = r.point : i = r.point); return new E(n, i); } isContainedByConvexPolygon(t) { return t.containsPoint(this.point1) && t.containsPoint(this.point2); } contains(t) { return t.isContainedByLineSegment(this); } pointIsStrictlyBetweenPoints(t, e, n) { return t.minus(e).dot(this.direction) * t.minus(n).dot(this.direction) < 0; } containsPoint(t) { return this.pointIsOnSameLine(t) && this.pointIsBetweenPoints(t, this.point1, this.point2); } interiorContainsPoint(t) { return this.pointIsOnSameLine(t) && this.pointIsStrictlyBetweenPoints(t, this.point1, this.point2); } intersectsRay(t) { return t.intersectsLineSegment(this); } intersectsLineSegment(t) { if (this.isContainedByLineSegment(t) || t.isContainedByLineSegment(this)) return !0; if (!this.lineSegmentIsOnSameLine(t)) return !1; const { point1: e, point2: n } = this.getPointsInSameDirection(t.point1, t.point2); return !this.comesBefore(n, this.point1) && !this.comesBefore(this.point2, e); } intersectsLine(t) { return t.intersectsSubsetOfLine(this); } intersects(t) { return t.intersectsLineSegment(this); } expandByDistance(t) { const e = this.expandLineByDistance(t), n = new P(this.base, this.direction).expandByDistance(t), i = new P(this.point2, this.direction.scale(-1)).expandByDistance(t); return e.intersectWithConvexPolygon(new p([n, i])); } expandToIncludePoint(t) { return this.containsPoint(t) ? this : this.pointIsOnSameLine(t) ? this.comesBefore(t, this.point1) ? new E(t, this.point2) : new E(this.point1, t) : p.createTriangle(this.point1, t, this.point2); } expandToIncludeInfinityInDirection(t) { return t.inSameDirectionAs(this.direction) ? new N(this.point1, t) : t.cross(this.direction) === 0 ? new N(this.point2, t) : p.createTriangleWithInfinityInDirection(this.point1, this.point2, t); } transform(t) { return new E(t.apply(this.point1), t.apply(this.point2)); } } class qi { addPoint(t) { return pt; } addPointAtInfinity(t) { return this; } addArea(t) { return pt; } } const De = new qi(); class Ie { constructor(t) { this.towardsMiddle = t; } addPoint(t) { return p.createFromHalfPlane(new P(t, this.towardsMiddle)); } addPointAtInfinity(t) { return t.dot(this.towardsMiddle) >= 0 ? this : De; } addArea(t) { const e = this.towardsMiddle.getPerpendicular(); return t.expandToIncludeInfinityInDirection(this.towardsMiddle).expandToIncludeInfinityInDirection(e).expandToIncludeInfinityInDirection(e.scale(-1)); } } class Jt { constructor(t, e) { this.direction1 = t, this.direction2 = e; } addPoint(t) { return p.createTriangleWithInfinityInTwoDirections(t, this.directio