Instantly share code, notes, and snippets.
Created
March 6, 2025 19:28
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save kucukkanat/d6a20744f4c7bf03aa5032f70c8ce41c to your computer and use it in GitHub Desktop.
succefy-cv-button.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Fv = Object.defineProperty; | |
| var ig = (n) => { | |
| throw TypeError(n); | |
| }; | |
| var $v = (n, t, e) => t in n ? Fv(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; | |
| var G = (n, t, e) => $v(n, typeof t != "symbol" ? t + "" : t, e), Td = (n, t, e) => t.has(n) || ig("Cannot " + e); | |
| var o = (n, t, e) => (Td(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? ig("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), p = (n, t, e, s) => (Td(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), v = (n, t, e) => (Td(n, t, "access private method"), e); | |
| var xe = (n, t, e, s) => ({ | |
| set _(i) { | |
| p(n, t, i, e); | |
| }, | |
| get _() { | |
| return o(n, t, s); | |
| } | |
| }); | |
| /** | |
| * @license | |
| * Copyright 2019 Google LLC | |
| * SPDX-License-Identifier: BSD-3-Clause | |
| */ | |
| const zh = globalThis, Ep = zh.ShadowRoot && (zh.ShadyCSS === void 0 || zh.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, xp = Symbol(), ng = /* @__PURE__ */ new WeakMap(); | |
| let sm = class { | |
| constructor(t, e, s) { | |
| if (this._$cssResult$ = !0, s !== xp) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); | |
| this.cssText = t, this.t = e; | |
| } | |
| get styleSheet() { | |
| let t = this.o; | |
| const e = this.t; | |
| if (Ep && t === void 0) { | |
| const s = e !== void 0 && e.length === 1; | |
| s && (t = ng.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && ng.set(e, t)); | |
| } | |
| return t; | |
| } | |
| toString() { | |
| return this.cssText; | |
| } | |
| }; | |
| const jv = (n) => new sm(typeof n == "string" ? n : n + "", void 0, xp), Bv = (n, ...t) => { | |
| const e = n.length === 1 ? n[0] : t.reduce((s, i, r) => s + ((a) => { | |
| if (a._$cssResult$ === !0) return a.cssText; | |
| if (typeof a == "number") return a; | |
| throw Error("Value passed to 'css' function must be a 'css' function result: " + a + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); | |
| })(i) + n[r + 1], n[0]); | |
| return new sm(e, n, xp); | |
| }, Hv = (n, t) => { | |
| if (Ep) n.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet); | |
| else for (const e of t) { | |
| const s = document.createElement("style"), i = zh.litNonce; | |
| i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, n.appendChild(s); | |
| } | |
| }, rg = Ep ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((t) => { | |
| let e = ""; | |
| for (const s of t.cssRules) e += s.cssText; | |
| return jv(e); | |
| })(n) : n; | |
| /** | |
| * @license | |
| * Copyright 2017 Google LLC | |
| * SPDX-License-Identifier: BSD-3-Clause | |
| */ | |
| const { is: Uv, defineProperty: zv, getOwnPropertyDescriptor: Vv, getOwnPropertyNames: Gv, getOwnPropertySymbols: qv, getPrototypeOf: Wv } = Object, On = globalThis, ag = On.trustedTypes, Xv = ag ? ag.emptyScript : "", Cd = On.reactiveElementPolyfillSupport, Tl = (n, t) => n, Au = { toAttribute(n, t) { | |
| switch (t) { | |
| case Boolean: | |
| n = n ? Xv : null; | |
| break; | |
| case Object: | |
| case Array: | |
| n = n == null ? n : JSON.stringify(n); | |
| } | |
| return n; | |
| }, fromAttribute(n, t) { | |
| let e = n; | |
| switch (t) { | |
| case Boolean: | |
| e = n !== null; | |
| break; | |
| case Number: | |
| e = n === null ? null : Number(n); | |
| break; | |
| case Object: | |
| case Array: | |
| try { | |
| e = JSON.parse(n); | |
| } catch { | |
| e = null; | |
| } | |
| } | |
| return e; | |
| } }, Tp = (n, t) => !Uv(n, t), og = { attribute: !0, type: String, converter: Au, reflect: !1, hasChanged: Tp }; | |
| Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), On.litPropertyMetadata ?? (On.litPropertyMetadata = /* @__PURE__ */ new WeakMap()); | |
| class Aa extends HTMLElement { | |
| static addInitializer(t) { | |
| this._$Ei(), (this.l ?? (this.l = [])).push(t); | |
| } | |
| static get observedAttributes() { | |
| return this.finalize(), this._$Eh && [...this._$Eh.keys()]; | |
| } | |
| static createProperty(t, e = og) { | |
| if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) { | |
| const s = Symbol(), i = this.getPropertyDescriptor(t, s, e); | |
| i !== void 0 && zv(this.prototype, t, i); | |
| } | |
| } | |
| static getPropertyDescriptor(t, e, s) { | |
| const { get: i, set: r } = Vv(this.prototype, t) ?? { get() { | |
| return this[e]; | |
| }, set(a) { | |
| this[e] = a; | |
| } }; | |
| return { get() { | |
| return i == null ? void 0 : i.call(this); | |
| }, set(a) { | |
| const l = i == null ? void 0 : i.call(this); | |
| r.call(this, a), this.requestUpdate(t, l, s); | |
| }, configurable: !0, enumerable: !0 }; | |
| } | |
| static getPropertyOptions(t) { | |
| return this.elementProperties.get(t) ?? og; | |
| } | |
| static _$Ei() { | |
| if (this.hasOwnProperty(Tl("elementProperties"))) return; | |
| const t = Wv(this); | |
| t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties); | |
| } | |
| static finalize() { | |
| if (this.hasOwnProperty(Tl("finalized"))) return; | |
| if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(Tl("properties"))) { | |
| const e = this.properties, s = [...Gv(e), ...qv(e)]; | |
| for (const i of s) this.createProperty(i, e[i]); | |
| } | |
| const t = this[Symbol.metadata]; | |
| if (t !== null) { | |
| const e = litPropertyMetadata.get(t); | |
| if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i); | |
| } | |
| this._$Eh = /* @__PURE__ */ new Map(); | |
| for (const [e, s] of this.elementProperties) { | |
| const i = this._$Eu(e, s); | |
| i !== void 0 && this._$Eh.set(i, e); | |
| } | |
| this.elementStyles = this.finalizeStyles(this.styles); | |
| } | |
| static finalizeStyles(t) { | |
| const e = []; | |
| if (Array.isArray(t)) { | |
| const s = new Set(t.flat(1 / 0).reverse()); | |
| for (const i of s) e.unshift(rg(i)); | |
| } else t !== void 0 && e.push(rg(t)); | |
| return e; | |
| } | |
| static _$Eu(t, e) { | |
| const s = e.attribute; | |
| return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0; | |
| } | |
| constructor() { | |
| super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev(); | |
| } | |
| _$Ev() { | |
| var t; | |
| this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this)); | |
| } | |
| addController(t) { | |
| var e; | |
| (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t)); | |
| } | |
| removeController(t) { | |
| var e; | |
| (e = this._$EO) == null || e.delete(t); | |
| } | |
| _$E_() { | |
| const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties; | |
| for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]); | |
| t.size > 0 && (this._$Ep = t); | |
| } | |
| createRenderRoot() { | |
| const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); | |
| return Hv(t, this.constructor.elementStyles), t; | |
| } | |
| connectedCallback() { | |
| var t; | |
| this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => { | |
| var s; | |
| return (s = e.hostConnected) == null ? void 0 : s.call(e); | |
| }); | |
| } | |
| enableUpdating(t) { | |
| } | |
| disconnectedCallback() { | |
| var t; | |
| (t = this._$EO) == null || t.forEach((e) => { | |
| var s; | |
| return (s = e.hostDisconnected) == null ? void 0 : s.call(e); | |
| }); | |
| } | |
| attributeChangedCallback(t, e, s) { | |
| this._$AK(t, s); | |
| } | |
| _$EC(t, e) { | |
| var r; | |
| const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s); | |
| if (i !== void 0 && s.reflect === !0) { | |
| const a = (((r = s.converter) == null ? void 0 : r.toAttribute) !== void 0 ? s.converter : Au).toAttribute(e, s.type); | |
| this._$Em = t, a == null ? this.removeAttribute(i) : this.setAttribute(i, a), this._$Em = null; | |
| } | |
| } | |
| _$AK(t, e) { | |
| var r; | |
| const s = this.constructor, i = s._$Eh.get(t); | |
| if (i !== void 0 && this._$Em !== i) { | |
| const a = s.getPropertyOptions(i), l = typeof a.converter == "function" ? { fromAttribute: a.converter } : ((r = a.converter) == null ? void 0 : r.fromAttribute) !== void 0 ? a.converter : Au; | |
| this._$Em = i, this[i] = l.fromAttribute(e, a.type), this._$Em = null; | |
| } | |
| } | |
| requestUpdate(t, e, s) { | |
| if (t !== void 0) { | |
| if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? Tp)(this[t], e)) return; | |
| this.P(t, e, s); | |
| } | |
| this.isUpdatePending === !1 && (this._$ES = this._$ET()); | |
| } | |
| P(t, e, s) { | |
| this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t); | |
| } | |
| async _$ET() { | |
| this.isUpdatePending = !0; | |
| try { | |
| await this._$ES; | |
| } catch (e) { | |
| Promise.reject(e); | |
| } | |
| const t = this.scheduleUpdate(); | |
| return t != null && await t, !this.isUpdatePending; | |
| } | |
| scheduleUpdate() { | |
| return this.performUpdate(); | |
| } | |
| performUpdate() { | |
| var s; | |
| if (!this.isUpdatePending) return; | |
| if (!this.hasUpdated) { | |
| if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) { | |
| for (const [r, a] of this._$Ep) this[r] = a; | |
| this._$Ep = void 0; | |
| } | |
| const i = this.constructor.elementProperties; | |
| if (i.size > 0) for (const [r, a] of i) a.wrapped !== !0 || this._$AL.has(r) || this[r] === void 0 || this.P(r, this[r], a); | |
| } | |
| let t = !1; | |
| const e = this._$AL; | |
| try { | |
| t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => { | |
| var r; | |
| return (r = i.hostUpdate) == null ? void 0 : r.call(i); | |
| }), this.update(e)) : this._$EU(); | |
| } catch (i) { | |
| throw t = !1, this._$EU(), i; | |
| } | |
| t && this._$AE(e); | |
| } | |
| willUpdate(t) { | |
| } | |
| _$AE(t) { | |
| var e; | |
| (e = this._$EO) == null || e.forEach((s) => { | |
| var i; | |
| return (i = s.hostUpdated) == null ? void 0 : i.call(s); | |
| }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); | |
| } | |
| _$EU() { | |
| this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; | |
| } | |
| get updateComplete() { | |
| return this.getUpdateComplete(); | |
| } | |
| getUpdateComplete() { | |
| return this._$ES; | |
| } | |
| shouldUpdate(t) { | |
| return !0; | |
| } | |
| update(t) { | |
| this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU(); | |
| } | |
| updated(t) { | |
| } | |
| firstUpdated(t) { | |
| } | |
| } | |
| Aa.elementStyles = [], Aa.shadowRootOptions = { mode: "open" }, Aa[Tl("elementProperties")] = /* @__PURE__ */ new Map(), Aa[Tl("finalized")] = /* @__PURE__ */ new Map(), Cd == null || Cd({ ReactiveElement: Aa }), (On.reactiveElementVersions ?? (On.reactiveElementVersions = [])).push("2.0.4"); | |
| /** | |
| * @license | |
| * Copyright 2017 Google LLC | |
| * SPDX-License-Identifier: BSD-3-Clause | |
| */ | |
| const Cl = globalThis, wu = Cl.trustedTypes, lg = wu ? wu.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, im = "$lit$", tn = `lit$${Math.random().toFixed(9).slice(2)}$`, nm = "?" + tn, Zv = `<${nm}>`, la = document, Ml = () => la.createComment(""), Nl = (n) => n === null || typeof n != "object" && typeof n != "function", Cp = Array.isArray, Yv = (n) => Cp(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", kd = `[ | |
| \f\r]`, el = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, cg = /-->/g, hg = />/g, Wn = RegExp(`>|${kd}(?:([^\\s"'>=/]+)(${kd}*=${kd}*(?:[^ | |
| \f\r"'\`<>=]|("|')|))|$)`, "g"), ug = /'/g, dg = /"/g, rm = /^(?:script|style|textarea|title)$/i, Kv = (n) => (t, ...e) => ({ _$litType$: n, strings: t, values: e }), Jv = Kv(1), Uo = Symbol.for("lit-noChange"), ae = Symbol.for("lit-nothing"), fg = /* @__PURE__ */ new WeakMap(), er = la.createTreeWalker(la, 129); | |
| function am(n, t) { | |
| if (!Cp(n) || !n.hasOwnProperty("raw")) throw Error("invalid template strings array"); | |
| return lg !== void 0 ? lg.createHTML(t) : t; | |
| } | |
| const Qv = (n, t) => { | |
| const e = n.length - 1, s = []; | |
| let i, r = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = el; | |
| for (let l = 0; l < e; l++) { | |
| const c = n[l]; | |
| let h, u, d = -1, f = 0; | |
| for (; f < c.length && (a.lastIndex = f, u = a.exec(c), u !== null); ) f = a.lastIndex, a === el ? u[1] === "!--" ? a = cg : u[1] !== void 0 ? a = hg : u[2] !== void 0 ? (rm.test(u[2]) && (i = RegExp("</" + u[2], "g")), a = Wn) : u[3] !== void 0 && (a = Wn) : a === Wn ? u[0] === ">" ? (a = i ?? el, d = -1) : u[1] === void 0 ? d = -2 : (d = a.lastIndex - u[2].length, h = u[1], a = u[3] === void 0 ? Wn : u[3] === '"' ? dg : ug) : a === dg || a === ug ? a = Wn : a === cg || a === hg ? a = el : (a = Wn, i = void 0); | |
| const g = a === Wn && n[l + 1].startsWith("/>") ? " " : ""; | |
| r += a === el ? c + Zv : d >= 0 ? (s.push(h), c.slice(0, d) + im + c.slice(d) + tn + g) : c + tn + (d === -2 ? l : g); | |
| } | |
| return [am(n, r + (n[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s]; | |
| }; | |
| class Ol { | |
| constructor({ strings: t, _$litType$: e }, s) { | |
| let i; | |
| this.parts = []; | |
| let r = 0, a = 0; | |
| const l = t.length - 1, c = this.parts, [h, u] = Qv(t, e); | |
| if (this.el = Ol.createElement(h, s), er.currentNode = this.el.content, e === 2 || e === 3) { | |
| const d = this.el.content.firstChild; | |
| d.replaceWith(...d.childNodes); | |
| } | |
| for (; (i = er.nextNode()) !== null && c.length < l; ) { | |
| if (i.nodeType === 1) { | |
| if (i.hasAttributes()) for (const d of i.getAttributeNames()) if (d.endsWith(im)) { | |
| const f = u[a++], g = i.getAttribute(d).split(tn), m = /([.?@])?(.*)/.exec(f); | |
| c.push({ type: 1, index: r, name: m[2], strings: g, ctor: m[1] === "." ? e_ : m[1] === "?" ? s_ : m[1] === "@" ? i_ : dd }), i.removeAttribute(d); | |
| } else d.startsWith(tn) && (c.push({ type: 6, index: r }), i.removeAttribute(d)); | |
| if (rm.test(i.tagName)) { | |
| const d = i.textContent.split(tn), f = d.length - 1; | |
| if (f > 0) { | |
| i.textContent = wu ? wu.emptyScript : ""; | |
| for (let g = 0; g < f; g++) i.append(d[g], Ml()), er.nextNode(), c.push({ type: 2, index: ++r }); | |
| i.append(d[f], Ml()); | |
| } | |
| } | |
| } else if (i.nodeType === 8) if (i.data === nm) c.push({ type: 2, index: r }); | |
| else { | |
| let d = -1; | |
| for (; (d = i.data.indexOf(tn, d + 1)) !== -1; ) c.push({ type: 7, index: r }), d += tn.length - 1; | |
| } | |
| r++; | |
| } | |
| } | |
| static createElement(t, e) { | |
| const s = la.createElement("template"); | |
| return s.innerHTML = t, s; | |
| } | |
| } | |
| function zo(n, t, e = n, s) { | |
| var a, l; | |
| if (t === Uo) return t; | |
| let i = s !== void 0 ? (a = e._$Co) == null ? void 0 : a[s] : e._$Cl; | |
| const r = Nl(t) ? void 0 : t._$litDirective$; | |
| return (i == null ? void 0 : i.constructor) !== r && ((l = i == null ? void 0 : i._$AO) == null || l.call(i, !1), r === void 0 ? i = void 0 : (i = new r(n), i._$AT(n, e, s)), s !== void 0 ? (e._$Co ?? (e._$Co = []))[s] = i : e._$Cl = i), i !== void 0 && (t = zo(n, i._$AS(n, t.values), i, s)), t; | |
| } | |
| class t_ { | |
| constructor(t, e) { | |
| this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e; | |
| } | |
| get parentNode() { | |
| return this._$AM.parentNode; | |
| } | |
| get _$AU() { | |
| return this._$AM._$AU; | |
| } | |
| u(t) { | |
| const { el: { content: e }, parts: s } = this._$AD, i = ((t == null ? void 0 : t.creationScope) ?? la).importNode(e, !0); | |
| er.currentNode = i; | |
| let r = er.nextNode(), a = 0, l = 0, c = s[0]; | |
| for (; c !== void 0; ) { | |
| if (a === c.index) { | |
| let h; | |
| c.type === 2 ? h = new Ph(r, r.nextSibling, this, t) : c.type === 1 ? h = new c.ctor(r, c.name, c.strings, this, t) : c.type === 6 && (h = new n_(r, this, t)), this._$AV.push(h), c = s[++l]; | |
| } | |
| a !== (c == null ? void 0 : c.index) && (r = er.nextNode(), a++); | |
| } | |
| return er.currentNode = la, i; | |
| } | |
| p(t) { | |
| let e = 0; | |
| for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++; | |
| } | |
| } | |
| class Ph { | |
| get _$AU() { | |
| var t; | |
| return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv; | |
| } | |
| constructor(t, e, s, i) { | |
| this.type = 2, this._$AH = ae, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = (i == null ? void 0 : i.isConnected) ?? !0; | |
| } | |
| get parentNode() { | |
| let t = this._$AA.parentNode; | |
| const e = this._$AM; | |
| return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t; | |
| } | |
| get startNode() { | |
| return this._$AA; | |
| } | |
| get endNode() { | |
| return this._$AB; | |
| } | |
| _$AI(t, e = this) { | |
| t = zo(this, t, e), Nl(t) ? t === ae || t == null || t === "" ? (this._$AH !== ae && this._$AR(), this._$AH = ae) : t !== this._$AH && t !== Uo && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Yv(t) ? this.k(t) : this._(t); | |
| } | |
| O(t) { | |
| return this._$AA.parentNode.insertBefore(t, this._$AB); | |
| } | |
| T(t) { | |
| this._$AH !== t && (this._$AR(), this._$AH = this.O(t)); | |
| } | |
| _(t) { | |
| this._$AH !== ae && Nl(this._$AH) ? this._$AA.nextSibling.data = t : this.T(la.createTextNode(t)), this._$AH = t; | |
| } | |
| $(t) { | |
| var r; | |
| const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = Ol.createElement(am(s.h, s.h[0]), this.options)), s); | |
| if (((r = this._$AH) == null ? void 0 : r._$AD) === i) this._$AH.p(e); | |
| else { | |
| const a = new t_(i, this), l = a.u(this.options); | |
| a.p(e), this.T(l), this._$AH = a; | |
| } | |
| } | |
| _$AC(t) { | |
| let e = fg.get(t.strings); | |
| return e === void 0 && fg.set(t.strings, e = new Ol(t)), e; | |
| } | |
| k(t) { | |
| Cp(this._$AH) || (this._$AH = [], this._$AR()); | |
| const e = this._$AH; | |
| let s, i = 0; | |
| for (const r of t) i === e.length ? e.push(s = new Ph(this.O(Ml()), this.O(Ml()), this, this.options)) : s = e[i], s._$AI(r), i++; | |
| i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i); | |
| } | |
| _$AR(t = this._$AA.nextSibling, e) { | |
| var s; | |
| for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) { | |
| const i = t.nextSibling; | |
| t.remove(), t = i; | |
| } | |
| } | |
| setConnected(t) { | |
| var e; | |
| this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t)); | |
| } | |
| } | |
| class dd { | |
| get tagName() { | |
| return this.element.tagName; | |
| } | |
| get _$AU() { | |
| return this._$AM._$AU; | |
| } | |
| constructor(t, e, s, i, r) { | |
| this.type = 1, this._$AH = ae, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = r, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = ae; | |
| } | |
| _$AI(t, e = this, s, i) { | |
| const r = this.strings; | |
| let a = !1; | |
| if (r === void 0) t = zo(this, t, e, 0), a = !Nl(t) || t !== this._$AH && t !== Uo, a && (this._$AH = t); | |
| else { | |
| const l = t; | |
| let c, h; | |
| for (t = r[0], c = 0; c < r.length - 1; c++) h = zo(this, l[s + c], e, c), h === Uo && (h = this._$AH[c]), a || (a = !Nl(h) || h !== this._$AH[c]), h === ae ? t = ae : t !== ae && (t += (h ?? "") + r[c + 1]), this._$AH[c] = h; | |
| } | |
| a && !i && this.j(t); | |
| } | |
| j(t) { | |
| t === ae ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ""); | |
| } | |
| } | |
| class e_ extends dd { | |
| constructor() { | |
| super(...arguments), this.type = 3; | |
| } | |
| j(t) { | |
| this.element[this.name] = t === ae ? void 0 : t; | |
| } | |
| } | |
| class s_ extends dd { | |
| constructor() { | |
| super(...arguments), this.type = 4; | |
| } | |
| j(t) { | |
| this.element.toggleAttribute(this.name, !!t && t !== ae); | |
| } | |
| } | |
| class i_ extends dd { | |
| constructor(t, e, s, i, r) { | |
| super(t, e, s, i, r), this.type = 5; | |
| } | |
| _$AI(t, e = this) { | |
| if ((t = zo(this, t, e, 0) ?? ae) === Uo) return; | |
| const s = this._$AH, i = t === ae && s !== ae || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, r = t !== ae && (s === ae || i); | |
| i && this.element.removeEventListener(this.name, this, s), r && this.element.addEventListener(this.name, this, t), this._$AH = t; | |
| } | |
| handleEvent(t) { | |
| var e; | |
| typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t); | |
| } | |
| } | |
| let n_ = class { | |
| constructor(t, e, s) { | |
| this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s; | |
| } | |
| get _$AU() { | |
| return this._$AM._$AU; | |
| } | |
| _$AI(t) { | |
| zo(this, t); | |
| } | |
| }; | |
| const Id = Cl.litHtmlPolyfillSupport; | |
| Id == null || Id(Ol, Ph), (Cl.litHtmlVersions ?? (Cl.litHtmlVersions = [])).push("3.2.1"); | |
| const r_ = (n, t, e) => { | |
| const s = (e == null ? void 0 : e.renderBefore) ?? t; | |
| let i = s._$litPart$; | |
| if (i === void 0) { | |
| const r = (e == null ? void 0 : e.renderBefore) ?? null; | |
| s._$litPart$ = i = new Ph(t.insertBefore(Ml(), r), r, void 0, e ?? {}); | |
| } | |
| return i._$AI(n), i; | |
| }; | |
| /** | |
| * @license | |
| * Copyright 2017 Google LLC | |
| * SPDX-License-Identifier: BSD-3-Clause | |
| */ | |
| let kl = class extends Aa { | |
| constructor() { | |
| super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; | |
| } | |
| createRenderRoot() { | |
| var e; | |
| const t = super.createRenderRoot(); | |
| return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t; | |
| } | |
| update(t) { | |
| const e = this.render(); | |
| this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = r_(e, this.renderRoot, this.renderOptions); | |
| } | |
| connectedCallback() { | |
| var t; | |
| super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0); | |
| } | |
| disconnectedCallback() { | |
| var t; | |
| super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1); | |
| } | |
| render() { | |
| return Uo; | |
| } | |
| }; | |
| var tm; | |
| kl._$litElement$ = !0, kl.finalized = !0, (tm = globalThis.litElementHydrateSupport) == null || tm.call(globalThis, { LitElement: kl }); | |
| const Rd = globalThis.litElementPolyfillSupport; | |
| Rd == null || Rd({ LitElement: kl }); | |
| (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1"); | |
| /** | |
| * @license | |
| * Copyright 2017 Google LLC | |
| * SPDX-License-Identifier: BSD-3-Clause | |
| */ | |
| const a_ = (n) => (t, e) => { | |
| e !== void 0 ? e.addInitializer(() => { | |
| customElements.define(n, t); | |
| }) : customElements.define(n, t); | |
| }; | |
| /** | |
| * @license | |
| * Copyright 2017 Google LLC | |
| * SPDX-License-Identifier: BSD-3-Clause | |
| */ | |
| const o_ = { attribute: !0, type: String, converter: Au, reflect: !1, hasChanged: Tp }, l_ = (n = o_, t, e) => { | |
| const { kind: s, metadata: i } = e; | |
| let r = globalThis.litPropertyMetadata.get(i); | |
| if (r === void 0 && globalThis.litPropertyMetadata.set(i, r = /* @__PURE__ */ new Map()), r.set(e.name, n), s === "accessor") { | |
| const { name: a } = e; | |
| return { set(l) { | |
| const c = t.get.call(this); | |
| t.set.call(this, l), this.requestUpdate(a, c, n); | |
| }, init(l) { | |
| return l !== void 0 && this.P(a, void 0, n), l; | |
| } }; | |
| } | |
| if (s === "setter") { | |
| const { name: a } = e; | |
| return function(l) { | |
| const c = this[a]; | |
| t.call(this, l), this.requestUpdate(a, c, n); | |
| }; | |
| } | |
| throw Error("Unsupported decorator location: " + s); | |
| }; | |
| function c_(n) { | |
| return (t, e) => typeof e == "object" ? l_(n, t, e) : ((s, i, r) => { | |
| const a = i.hasOwnProperty(r); | |
| return i.constructor.createProperty(r, a ? { ...s, wrapped: !0 } : s), a ? Object.getOwnPropertyDescriptor(i, r) : void 0; | |
| })(n, t, e); | |
| } | |
| var om = "vercel.ai.error", h_ = Symbol.for(om), lm, u_ = class cm extends Error { | |
| /** | |
| * Creates an AI SDK Error. | |
| * | |
| * @param {Object} params - The parameters for creating the error. | |
| * @param {string} params.name - The name of the error. | |
| * @param {string} params.message - The error message. | |
| * @param {unknown} [params.cause] - The underlying cause of the error. | |
| */ | |
| constructor({ | |
| name: t, | |
| message: e, | |
| cause: s | |
| }) { | |
| super(e), this[lm] = !0, this.name = t, this.cause = s; | |
| } | |
| /** | |
| * Checks if the given error is an AI SDK Error. | |
| * @param {unknown} error - The error to check. | |
| * @returns {boolean} True if the error is an AI SDK Error, false otherwise. | |
| */ | |
| static isInstance(t) { | |
| return cm.hasMarker(t, om); | |
| } | |
| static hasMarker(t, e) { | |
| const s = Symbol.for(e); | |
| return t != null && typeof t == "object" && s in t && typeof t[s] == "boolean" && t[s] === !0; | |
| } | |
| }; | |
| lm = h_; | |
| var ht = u_, hm = "AI_APICallError", um = `vercel.ai.error.${hm}`, d_ = Symbol.for(um), dm, hi = class extends ht { | |
| constructor({ | |
| message: n, | |
| url: t, | |
| requestBodyValues: e, | |
| statusCode: s, | |
| responseHeaders: i, | |
| responseBody: r, | |
| cause: a, | |
| isRetryable: l = s != null && (s === 408 || // request timeout | |
| s === 409 || // conflict | |
| s === 429 || // too many requests | |
| s >= 500), | |
| // server error | |
| data: c | |
| }) { | |
| super({ name: hm, message: n, cause: a }), this[dm] = !0, this.url = t, this.requestBodyValues = e, this.statusCode = s, this.responseHeaders = i, this.responseBody = r, this.isRetryable = l, this.data = c; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, um); | |
| } | |
| }; | |
| dm = d_; | |
| var fm = "AI_EmptyResponseBodyError", pm = `vercel.ai.error.${fm}`, f_ = Symbol.for(pm), gm, p_ = class extends ht { | |
| // used in isInstance | |
| constructor({ message: n = "Empty response body" } = {}) { | |
| super({ name: fm, message: n }), this[gm] = !0; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, pm); | |
| } | |
| }; | |
| gm = f_; | |
| function mm(n) { | |
| return n == null ? "unknown error" : typeof n == "string" ? n : n instanceof Error ? n.message : JSON.stringify(n); | |
| } | |
| var ym = "AI_InvalidArgumentError", bm = `vercel.ai.error.${ym}`, g_ = Symbol.for(bm), vm, m_ = class extends ht { | |
| constructor({ | |
| message: t, | |
| cause: e, | |
| argument: s | |
| }) { | |
| super({ name: ym, message: t, cause: e }), this[vm] = !0, this.argument = s; | |
| } | |
| static isInstance(t) { | |
| return ht.hasMarker(t, bm); | |
| } | |
| }; | |
| vm = g_; | |
| var _m = "AI_InvalidPromptError", Am = `vercel.ai.error.${_m}`, y_ = Symbol.for(Am), wm, Zn = class extends ht { | |
| constructor({ | |
| prompt: n, | |
| message: t, | |
| cause: e | |
| }) { | |
| super({ name: _m, message: `Invalid prompt: ${t}`, cause: e }), this[wm] = !0, this.prompt = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Am); | |
| } | |
| }; | |
| wm = y_; | |
| var Sm = "AI_InvalidResponseDataError", Em = `vercel.ai.error.${Sm}`, b_ = Symbol.for(Em), xm, Pd = class extends ht { | |
| constructor({ | |
| data: n, | |
| message: t = `Invalid response data: ${JSON.stringify(n)}.` | |
| }) { | |
| super({ name: Sm, message: t }), this[xm] = !0, this.data = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Em); | |
| } | |
| }; | |
| xm = b_; | |
| var Tm = "AI_JSONParseError", Cm = `vercel.ai.error.${Tm}`, v_ = Symbol.for(Cm), km, Ll = class extends ht { | |
| constructor({ text: n, cause: t }) { | |
| super({ | |
| name: Tm, | |
| message: `JSON parsing failed: Text: ${n}. | |
| Error message: ${mm(t)}`, | |
| cause: t | |
| }), this[km] = !0, this.text = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Cm); | |
| } | |
| }; | |
| km = v_; | |
| var Im = "AI_LoadAPIKeyError", Rm = `vercel.ai.error.${Im}`, __ = Symbol.for(Rm), Pm, Dh = class extends ht { | |
| // used in isInstance | |
| constructor({ message: n }) { | |
| super({ name: Im, message: n }), this[Pm] = !0; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Rm); | |
| } | |
| }; | |
| Pm = __; | |
| var Mm = "AI_TooManyEmbeddingValuesForCallError", Nm = `vercel.ai.error.${Mm}`, A_ = Symbol.for(Nm), Om, w_ = class extends ht { | |
| constructor(n) { | |
| super({ | |
| name: Mm, | |
| message: `Too many values for a single embedding call. The ${n.provider} model "${n.modelId}" can only embed up to ${n.maxEmbeddingsPerCall} values per call, but ${n.values.length} values were provided.` | |
| }), this[Om] = !0, this.provider = n.provider, this.modelId = n.modelId, this.maxEmbeddingsPerCall = n.maxEmbeddingsPerCall, this.values = n.values; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Nm); | |
| } | |
| }; | |
| Om = A_; | |
| var Lm = "AI_TypeValidationError", Dm = `vercel.ai.error.${Lm}`, S_ = Symbol.for(Dm), Fm, E_ = class Yd extends ht { | |
| constructor({ value: t, cause: e }) { | |
| super({ | |
| name: Lm, | |
| message: `Type validation failed: Value: ${JSON.stringify(t)}. | |
| Error message: ${mm(e)}`, | |
| cause: e | |
| }), this[Fm] = !0, this.value = t; | |
| } | |
| static isInstance(t) { | |
| return ht.hasMarker(t, Dm); | |
| } | |
| /** | |
| * Wraps an error into a TypeValidationError. | |
| * If the cause is already a TypeValidationError with the same value, it returns the cause. | |
| * Otherwise, it creates a new TypeValidationError. | |
| * | |
| * @param {Object} params - The parameters for wrapping the error. | |
| * @param {unknown} params.value - The value that failed validation. | |
| * @param {unknown} params.cause - The original error or cause of the validation failure. | |
| * @returns {TypeValidationError} A TypeValidationError instance. | |
| */ | |
| static wrap({ | |
| value: t, | |
| cause: e | |
| }) { | |
| return Yd.isInstance(e) && e.value === t ? e : new Yd({ value: t, cause: e }); | |
| } | |
| }; | |
| Fm = S_; | |
| var Zi = E_, $m = "AI_UnsupportedFunctionalityError", jm = `vercel.ai.error.${$m}`, x_ = Symbol.for(jm), Bm, oe = class extends ht { | |
| constructor({ | |
| functionality: n, | |
| message: t = `'${n}' functionality not supported.` | |
| }) { | |
| super({ name: $m, message: t }), this[Bm] = !0, this.functionality = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, jm); | |
| } | |
| }; | |
| Bm = x_; | |
| function Su(n) { | |
| return n === null || typeof n == "string" || typeof n == "number" || typeof n == "boolean" ? !0 : Array.isArray(n) ? n.every(Su) : typeof n == "object" ? Object.entries(n).every( | |
| ([t, e]) => typeof t == "string" && Su(e) | |
| ) : !1; | |
| } | |
| function pg(n) { | |
| return Array.isArray(n) && n.every(Su); | |
| } | |
| function Kd(n) { | |
| return n != null && typeof n == "object" && Object.entries(n).every( | |
| ([t, e]) => typeof t == "string" && Su(e) | |
| ); | |
| } | |
| let T_ = (n, t = 21) => (e = t) => { | |
| let s = "", i = e | 0; | |
| for (; i--; ) | |
| s += n[Math.random() * n.length | 0]; | |
| return s; | |
| }; | |
| function C_(n) { | |
| return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n; | |
| } | |
| var Xn = { exports: {} }, gg; | |
| function k_() { | |
| if (gg) return Xn.exports; | |
| gg = 1; | |
| const n = typeof Buffer < "u", t = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, e = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/; | |
| function s(l, c, h) { | |
| h == null && c !== null && typeof c == "object" && (h = c, c = void 0), n && Buffer.isBuffer(l) && (l = l.toString()), l && l.charCodeAt(0) === 65279 && (l = l.slice(1)); | |
| const u = JSON.parse(l, c); | |
| if (u === null || typeof u != "object") | |
| return u; | |
| const d = h && h.protoAction || "error", f = h && h.constructorAction || "error"; | |
| if (d === "ignore" && f === "ignore") | |
| return u; | |
| if (d !== "ignore" && f !== "ignore") { | |
| if (t.test(l) === !1 && e.test(l) === !1) | |
| return u; | |
| } else if (d !== "ignore" && f === "ignore") { | |
| if (t.test(l) === !1) | |
| return u; | |
| } else if (e.test(l) === !1) | |
| return u; | |
| return i(u, { protoAction: d, constructorAction: f, safe: h && h.safe }); | |
| } | |
| function i(l, { protoAction: c = "error", constructorAction: h = "error", safe: u } = {}) { | |
| let d = [l]; | |
| for (; d.length; ) { | |
| const f = d; | |
| d = []; | |
| for (const g of f) { | |
| if (c !== "ignore" && Object.prototype.hasOwnProperty.call(g, "__proto__")) { | |
| if (u === !0) | |
| return null; | |
| if (c === "error") | |
| throw new SyntaxError("Object contains forbidden prototype property"); | |
| delete g.__proto__; | |
| } | |
| if (h !== "ignore" && Object.prototype.hasOwnProperty.call(g, "constructor") && Object.prototype.hasOwnProperty.call(g.constructor, "prototype")) { | |
| if (u === !0) | |
| return null; | |
| if (h === "error") | |
| throw new SyntaxError("Object contains forbidden prototype property"); | |
| delete g.constructor; | |
| } | |
| for (const m in g) { | |
| const y = g[m]; | |
| y && typeof y == "object" && d.push(y); | |
| } | |
| } | |
| } | |
| return l; | |
| } | |
| function r(l, c, h) { | |
| const u = Error.stackTraceLimit; | |
| Error.stackTraceLimit = 0; | |
| try { | |
| return s(l, c, h); | |
| } finally { | |
| Error.stackTraceLimit = u; | |
| } | |
| } | |
| function a(l, c) { | |
| const h = Error.stackTraceLimit; | |
| Error.stackTraceLimit = 0; | |
| try { | |
| return s(l, c, { safe: !0 }); | |
| } catch { | |
| return null; | |
| } finally { | |
| Error.stackTraceLimit = h; | |
| } | |
| } | |
| return Xn.exports = r, Xn.exports.default = r, Xn.exports.parse = r, Xn.exports.safeParse = a, Xn.exports.scan = i, Xn.exports; | |
| } | |
| var I_ = k_(); | |
| const kp = /* @__PURE__ */ C_(I_); | |
| var R_ = Object.defineProperty, P_ = (n, t, e) => t in n ? R_(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, Fh = (n, t, e) => P_(n, typeof t != "symbol" ? t + "" : t, e); | |
| class mg extends Error { | |
| constructor(t, e) { | |
| super(t), Fh(this, "type"), Fh(this, "field"), Fh(this, "value"), Fh(this, "line"), this.name = "ParseError", this.type = e.type, this.field = e.field, this.value = e.value, this.line = e.line; | |
| } | |
| } | |
| function Md(n) { | |
| } | |
| function M_(n) { | |
| const { onEvent: t = Md, onError: e = Md, onRetry: s = Md, onComment: i } = n; | |
| let r = "", a = !0, l, c = "", h = ""; | |
| function u(y) { | |
| const _ = a ? y.replace(/^\xEF\xBB\xBF/, "") : y, [A, S] = N_(`${r}${_}`); | |
| for (const E of A) | |
| d(E); | |
| r = S, a = !1; | |
| } | |
| function d(y) { | |
| if (y === "") { | |
| g(); | |
| return; | |
| } | |
| if (y.startsWith(":")) { | |
| i && i(y.slice(y.startsWith(": ") ? 2 : 1)); | |
| return; | |
| } | |
| const _ = y.indexOf(":"); | |
| if (_ !== -1) { | |
| const A = y.slice(0, _), S = y[_ + 1] === " " ? 2 : 1, E = y.slice(_ + S); | |
| f(A, E, y); | |
| return; | |
| } | |
| f(y, "", y); | |
| } | |
| function f(y, _, A) { | |
| switch (y) { | |
| case "event": | |
| h = _; | |
| break; | |
| case "data": | |
| c = `${c}${_} | |
| `; | |
| break; | |
| case "id": | |
| l = _.includes("\0") ? void 0 : _; | |
| break; | |
| case "retry": | |
| /^\d+$/.test(_) ? s(parseInt(_, 10)) : e( | |
| new mg(`Invalid \`retry\` value: "${_}"`, { | |
| type: "invalid-retry", | |
| value: _, | |
| line: A | |
| }) | |
| ); | |
| break; | |
| default: | |
| e( | |
| new mg( | |
| `Unknown field "${y.length > 20 ? `${y.slice(0, 20)}…` : y}"`, | |
| { type: "unknown-field", field: y, value: _, line: A } | |
| ) | |
| ); | |
| break; | |
| } | |
| } | |
| function g() { | |
| c.length > 0 && t({ | |
| id: l, | |
| event: h || void 0, | |
| // If the data buffer's last character is a U+000A LINE FEED (LF) character, | |
| // then remove the last character from the data buffer. | |
| data: c.endsWith(` | |
| `) ? c.slice(0, -1) : c | |
| }), l = void 0, c = "", h = ""; | |
| } | |
| function m(y = {}) { | |
| r && y.consume && d(r), l = void 0, c = "", h = "", r = ""; | |
| } | |
| return { feed: u, reset: m }; | |
| } | |
| function N_(n) { | |
| const t = []; | |
| let e = ""; | |
| const s = n.length; | |
| for (let i = 0; i < s; i++) { | |
| const r = n[i]; | |
| r === "\r" && n[i + 1] === ` | |
| ` ? (t.push(e), e = "", i++) : r === "\r" || r === ` | |
| ` ? (t.push(e), e = "") : e += r; | |
| } | |
| return [t, e]; | |
| } | |
| class O_ extends TransformStream { | |
| constructor({ onError: t, onRetry: e, onComment: s } = {}) { | |
| let i; | |
| super({ | |
| start(r) { | |
| i = M_({ | |
| onEvent: (a) => { | |
| r.enqueue(a); | |
| }, | |
| onError(a) { | |
| t === "terminate" ? r.error(a) : typeof t == "function" && t(a); | |
| }, | |
| onRetry: e, | |
| onComment: s | |
| }); | |
| }, | |
| transform(r) { | |
| i.feed(r); | |
| } | |
| }); | |
| } | |
| } | |
| function Vo(...n) { | |
| return n.reduce( | |
| (t, e) => ({ | |
| ...t, | |
| ...e ?? {} | |
| }), | |
| {} | |
| ); | |
| } | |
| function L_(n) { | |
| return new ReadableStream({ | |
| /** | |
| * Called when the consumer wants to pull more data from the stream. | |
| * | |
| * @param {ReadableStreamDefaultController<T>} controller - The controller to enqueue data into the stream. | |
| * @returns {Promise<void>} | |
| */ | |
| async pull(t) { | |
| try { | |
| const { value: e, done: s } = await n.next(); | |
| s ? t.close() : t.enqueue(e); | |
| } catch (e) { | |
| t.error(e); | |
| } | |
| }, | |
| /** | |
| * Called when the consumer cancels the stream. | |
| */ | |
| cancel() { | |
| } | |
| }); | |
| } | |
| async function D_(n) { | |
| return n == null ? Promise.resolve() : new Promise((t) => setTimeout(t, n)); | |
| } | |
| function fd(n) { | |
| const t = {}; | |
| return n.headers.forEach((e, s) => { | |
| t[s] = e; | |
| }), t; | |
| } | |
| var ya = ({ | |
| prefix: n, | |
| size: t = 16, | |
| alphabet: e = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", | |
| separator: s = "-" | |
| } = {}) => { | |
| const i = T_(e, t); | |
| if (n == null) | |
| return i; | |
| if (e.includes(s)) | |
| throw new m_({ | |
| argument: "separator", | |
| message: `The separator "${s}" must not be part of the alphabet "${e}".` | |
| }); | |
| return (r) => `${n}${s}${i(r)}`; | |
| }, sl = ya(); | |
| function F_(n) { | |
| return n == null ? "unknown error" : typeof n == "string" ? n : n instanceof Error ? n.message : JSON.stringify(n); | |
| } | |
| function $_(n) { | |
| return Object.fromEntries( | |
| Object.entries(n).filter(([t, e]) => e != null) | |
| ); | |
| } | |
| function Vh(n) { | |
| return n instanceof Error && (n.name === "AbortError" || n.name === "TimeoutError"); | |
| } | |
| function j_({ | |
| apiKey: n, | |
| environmentVariableName: t, | |
| apiKeyParameterName: e = "apiKey", | |
| description: s | |
| }) { | |
| if (typeof n == "string") | |
| return n; | |
| if (n != null) | |
| throw new Dh({ | |
| message: `${s} API key must be a string.` | |
| }); | |
| if (typeof process > "u") | |
| throw new Dh({ | |
| message: `${s} API key is missing. Pass it using the '${e}' parameter. Environment variables is not supported in this environment.` | |
| }); | |
| if (n = process.env[t], n == null) | |
| throw new Dh({ | |
| message: `${s} API key is missing. Pass it using the '${e}' parameter or the ${t} environment variable.` | |
| }); | |
| if (typeof n != "string") | |
| throw new Dh({ | |
| message: `${s} API key must be a string. The value of the ${t} environment variable is not a string.` | |
| }); | |
| return n; | |
| } | |
| var Eu = Symbol.for("vercel.ai.validator"); | |
| function B_(n) { | |
| return { [Eu]: !0, validate: n }; | |
| } | |
| function H_(n) { | |
| return typeof n == "object" && n !== null && Eu in n && n[Eu] === !0 && "validate" in n; | |
| } | |
| function U_(n) { | |
| return H_(n) ? n : z_(n); | |
| } | |
| function z_(n) { | |
| return B_((t) => { | |
| const e = n.safeParse(t); | |
| return e.success ? { success: !0, value: e.data } : { success: !1, error: e.error }; | |
| }); | |
| } | |
| function V_({ | |
| value: n, | |
| schema: t | |
| }) { | |
| const e = ca({ value: n, schema: t }); | |
| if (!e.success) | |
| throw Zi.wrap({ value: n, cause: e.error }); | |
| return e.value; | |
| } | |
| function ca({ | |
| value: n, | |
| schema: t | |
| }) { | |
| const e = U_(t); | |
| try { | |
| if (e.validate == null) | |
| return { success: !0, value: n }; | |
| const s = e.validate(n); | |
| return s.success ? s : { | |
| success: !1, | |
| error: Zi.wrap({ value: n, cause: s.error }) | |
| }; | |
| } catch (s) { | |
| return { | |
| success: !1, | |
| error: Zi.wrap({ value: n, cause: s }) | |
| }; | |
| } | |
| } | |
| function G_({ | |
| text: n, | |
| schema: t | |
| }) { | |
| try { | |
| const e = kp.parse(n); | |
| return t == null ? e : V_({ value: e, schema: t }); | |
| } catch (e) { | |
| throw Ll.isInstance(e) || Zi.isInstance(e) ? e : new Ll({ text: n, cause: e }); | |
| } | |
| } | |
| function Go({ | |
| text: n, | |
| schema: t | |
| }) { | |
| try { | |
| const e = kp.parse(n); | |
| if (t == null) | |
| return { success: !0, value: e, rawValue: e }; | |
| const s = ca({ value: e, schema: t }); | |
| return s.success ? { ...s, rawValue: e } : s; | |
| } catch (e) { | |
| return { | |
| success: !1, | |
| error: Ll.isInstance(e) ? e : new Ll({ text: n, cause: e }) | |
| }; | |
| } | |
| } | |
| function yg(n) { | |
| try { | |
| return kp.parse(n), !0; | |
| } catch { | |
| return !1; | |
| } | |
| } | |
| var q_ = () => globalThis.fetch, qo = async ({ | |
| url: n, | |
| headers: t, | |
| body: e, | |
| failedResponseHandler: s, | |
| successfulResponseHandler: i, | |
| abortSignal: r, | |
| fetch: a | |
| }) => W_({ | |
| url: n, | |
| headers: { | |
| "Content-Type": "application/json", | |
| ...t | |
| }, | |
| body: { | |
| content: JSON.stringify(e), | |
| values: e | |
| }, | |
| failedResponseHandler: s, | |
| successfulResponseHandler: i, | |
| abortSignal: r, | |
| fetch: a | |
| }), W_ = async ({ | |
| url: n, | |
| headers: t = {}, | |
| body: e, | |
| successfulResponseHandler: s, | |
| failedResponseHandler: i, | |
| abortSignal: r, | |
| fetch: a = q_() | |
| }) => { | |
| try { | |
| const l = await a(n, { | |
| method: "POST", | |
| headers: $_(t), | |
| body: e.content, | |
| signal: r | |
| }), c = fd(l); | |
| if (!l.ok) { | |
| let h; | |
| try { | |
| h = await i({ | |
| response: l, | |
| url: n, | |
| requestBodyValues: e.values | |
| }); | |
| } catch (u) { | |
| throw Vh(u) || hi.isInstance(u) ? u : new hi({ | |
| message: "Failed to process error response", | |
| cause: u, | |
| statusCode: l.status, | |
| url: n, | |
| responseHeaders: c, | |
| requestBodyValues: e.values | |
| }); | |
| } | |
| throw h.value; | |
| } | |
| try { | |
| return await s({ | |
| response: l, | |
| url: n, | |
| requestBodyValues: e.values | |
| }); | |
| } catch (h) { | |
| throw h instanceof Error && (Vh(h) || hi.isInstance(h)) ? h : new hi({ | |
| message: "Failed to process successful response", | |
| cause: h, | |
| statusCode: l.status, | |
| url: n, | |
| responseHeaders: c, | |
| requestBodyValues: e.values | |
| }); | |
| } | |
| } catch (l) { | |
| if (Vh(l)) | |
| throw l; | |
| if (l instanceof TypeError && l.message === "fetch failed") { | |
| const c = l.cause; | |
| if (c != null) | |
| throw new hi({ | |
| message: `Cannot connect to API: ${c.message}`, | |
| cause: c, | |
| url: n, | |
| requestBodyValues: e.values, | |
| isRetryable: !0 | |
| // retry when network error | |
| }); | |
| } | |
| throw l; | |
| } | |
| }, X_ = ({ | |
| errorSchema: n, | |
| errorToMessage: t, | |
| isRetryable: e | |
| }) => async ({ response: s, url: i, requestBodyValues: r }) => { | |
| const a = await s.text(), l = fd(s); | |
| if (a.trim() === "") | |
| return { | |
| responseHeaders: l, | |
| value: new hi({ | |
| message: s.statusText, | |
| url: i, | |
| requestBodyValues: r, | |
| statusCode: s.status, | |
| responseHeaders: l, | |
| responseBody: a, | |
| isRetryable: e == null ? void 0 : e(s) | |
| }) | |
| }; | |
| try { | |
| const c = G_({ | |
| text: a, | |
| schema: n | |
| }); | |
| return { | |
| responseHeaders: l, | |
| value: new hi({ | |
| message: t(c), | |
| url: i, | |
| requestBodyValues: r, | |
| statusCode: s.status, | |
| responseHeaders: l, | |
| responseBody: a, | |
| data: c, | |
| isRetryable: e == null ? void 0 : e(s, c) | |
| }) | |
| }; | |
| } catch { | |
| return { | |
| responseHeaders: l, | |
| value: new hi({ | |
| message: s.statusText, | |
| url: i, | |
| requestBodyValues: r, | |
| statusCode: s.status, | |
| responseHeaders: l, | |
| responseBody: a, | |
| isRetryable: e == null ? void 0 : e(s) | |
| }) | |
| }; | |
| } | |
| }, Hm = (n) => async ({ response: t }) => { | |
| const e = fd(t); | |
| if (t.body == null) | |
| throw new p_({}); | |
| return { | |
| responseHeaders: e, | |
| value: t.body.pipeThrough(new TextDecoderStream()).pipeThrough(new O_()).pipeThrough( | |
| new TransformStream({ | |
| transform({ data: s }, i) { | |
| s !== "[DONE]" && i.enqueue( | |
| Go({ | |
| text: s, | |
| schema: n | |
| }) | |
| ); | |
| } | |
| }) | |
| ) | |
| }; | |
| }, pd = (n) => async ({ response: t, url: e, requestBodyValues: s }) => { | |
| const i = await t.text(), r = Go({ | |
| text: i, | |
| schema: n | |
| }), a = fd(t); | |
| if (!r.success) | |
| throw new hi({ | |
| message: "Invalid JSON response", | |
| cause: r.error, | |
| statusCode: t.status, | |
| responseHeaders: a, | |
| responseBody: i, | |
| url: e, | |
| requestBodyValues: s | |
| }); | |
| return { | |
| responseHeaders: a, | |
| value: r.value, | |
| rawValue: r.rawValue | |
| }; | |
| }, { btoa: Z_, atob: Y_ } = globalThis; | |
| function K_(n) { | |
| const t = n.replace(/-/g, "+").replace(/_/g, "/"), e = Y_(t); | |
| return Uint8Array.from(e, (s) => s.codePointAt(0)); | |
| } | |
| function Jd(n) { | |
| let t = ""; | |
| for (let e = 0; e < n.length; e++) | |
| t += String.fromCodePoint(n[e]); | |
| return Z_(t); | |
| } | |
| function J_(n) { | |
| return n == null ? void 0 : n.replace(/\/$/, ""); | |
| } | |
| const Q_ = Symbol("Let zodToJsonSchema decide on which parser to use"), bg = { | |
| name: void 0, | |
| $refStrategy: "root", | |
| basePath: ["#"], | |
| effectStrategy: "input", | |
| pipeStrategy: "all", | |
| dateStrategy: "format:date-time", | |
| mapStrategy: "entries", | |
| removeAdditionalStrategy: "passthrough", | |
| definitionPath: "definitions", | |
| target: "jsonSchema7", | |
| strictUnions: !1, | |
| definitions: {}, | |
| errorMessages: !1, | |
| markdownDescription: !1, | |
| patternStrategy: "escape", | |
| applyRegexFlags: !1, | |
| emailStrategy: "format:email", | |
| base64Strategy: "contentEncoding:base64", | |
| nameStrategy: "ref" | |
| }, tA = (n) => typeof n == "string" ? { | |
| ...bg, | |
| name: n | |
| } : { | |
| ...bg, | |
| ...n | |
| }, eA = (n) => { | |
| const t = tA(n), e = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath; | |
| return { | |
| ...t, | |
| currentPath: e, | |
| propertyPath: void 0, | |
| seen: new Map(Object.entries(t.definitions).map(([s, i]) => [ | |
| i._def, | |
| { | |
| def: i._def, | |
| path: [...t.basePath, t.definitionPath, s], | |
| // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now. | |
| jsonSchema: void 0 | |
| } | |
| ])) | |
| }; | |
| }; | |
| function Um(n, t, e, s) { | |
| s != null && s.errorMessages && e && (n.errorMessage = { | |
| ...n.errorMessage, | |
| [t]: e | |
| }); | |
| } | |
| function _t(n, t, e, s, i) { | |
| n[t] = e, Um(n, t, s, i); | |
| } | |
| var ct; | |
| (function(n) { | |
| n.assertEqual = (i) => i; | |
| function t(i) { | |
| } | |
| n.assertIs = t; | |
| function e(i) { | |
| throw new Error(); | |
| } | |
| n.assertNever = e, n.arrayToEnum = (i) => { | |
| const r = {}; | |
| for (const a of i) | |
| r[a] = a; | |
| return r; | |
| }, n.getValidEnumValues = (i) => { | |
| const r = n.objectKeys(i).filter((l) => typeof i[i[l]] != "number"), a = {}; | |
| for (const l of r) | |
| a[l] = i[l]; | |
| return n.objectValues(a); | |
| }, n.objectValues = (i) => n.objectKeys(i).map(function(r) { | |
| return i[r]; | |
| }), n.objectKeys = typeof Object.keys == "function" ? (i) => Object.keys(i) : (i) => { | |
| const r = []; | |
| for (const a in i) | |
| Object.prototype.hasOwnProperty.call(i, a) && r.push(a); | |
| return r; | |
| }, n.find = (i, r) => { | |
| for (const a of i) | |
| if (r(a)) | |
| return a; | |
| }, n.isInteger = typeof Number.isInteger == "function" ? (i) => Number.isInteger(i) : (i) => typeof i == "number" && isFinite(i) && Math.floor(i) === i; | |
| function s(i, r = " | ") { | |
| return i.map((a) => typeof a == "string" ? `'${a}'` : a).join(r); | |
| } | |
| n.joinValues = s, n.jsonStringifyReplacer = (i, r) => typeof r == "bigint" ? r.toString() : r; | |
| })(ct || (ct = {})); | |
| var Qd; | |
| (function(n) { | |
| n.mergeShapes = (t, e) => ({ | |
| ...t, | |
| ...e | |
| // second overwrites first | |
| }); | |
| })(Qd || (Qd = {})); | |
| const L = ct.arrayToEnum([ | |
| "string", | |
| "nan", | |
| "number", | |
| "integer", | |
| "float", | |
| "boolean", | |
| "date", | |
| "bigint", | |
| "symbol", | |
| "function", | |
| "undefined", | |
| "null", | |
| "array", | |
| "object", | |
| "unknown", | |
| "promise", | |
| "void", | |
| "never", | |
| "map", | |
| "set" | |
| ]), _i = (n) => { | |
| switch (typeof n) { | |
| case "undefined": | |
| return L.undefined; | |
| case "string": | |
| return L.string; | |
| case "number": | |
| return isNaN(n) ? L.nan : L.number; | |
| case "boolean": | |
| return L.boolean; | |
| case "function": | |
| return L.function; | |
| case "bigint": | |
| return L.bigint; | |
| case "symbol": | |
| return L.symbol; | |
| case "object": | |
| return Array.isArray(n) ? L.array : n === null ? L.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? L.promise : typeof Map < "u" && n instanceof Map ? L.map : typeof Set < "u" && n instanceof Set ? L.set : typeof Date < "u" && n instanceof Date ? L.date : L.object; | |
| default: | |
| return L.unknown; | |
| } | |
| }, I = ct.arrayToEnum([ | |
| "invalid_type", | |
| "invalid_literal", | |
| "custom", | |
| "invalid_union", | |
| "invalid_union_discriminator", | |
| "invalid_enum_value", | |
| "unrecognized_keys", | |
| "invalid_arguments", | |
| "invalid_return_type", | |
| "invalid_date", | |
| "invalid_string", | |
| "too_small", | |
| "too_big", | |
| "invalid_intersection_types", | |
| "not_multiple_of", | |
| "not_finite" | |
| ]), sA = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:"); | |
| class rs extends Error { | |
| get errors() { | |
| return this.issues; | |
| } | |
| constructor(t) { | |
| super(), this.issues = [], this.addIssue = (s) => { | |
| this.issues = [...this.issues, s]; | |
| }, this.addIssues = (s = []) => { | |
| this.issues = [...this.issues, ...s]; | |
| }; | |
| const e = new.target.prototype; | |
| Object.setPrototypeOf ? Object.setPrototypeOf(this, e) : this.__proto__ = e, this.name = "ZodError", this.issues = t; | |
| } | |
| format(t) { | |
| const e = t || function(r) { | |
| return r.message; | |
| }, s = { _errors: [] }, i = (r) => { | |
| for (const a of r.issues) | |
| if (a.code === "invalid_union") | |
| a.unionErrors.map(i); | |
| else if (a.code === "invalid_return_type") | |
| i(a.returnTypeError); | |
| else if (a.code === "invalid_arguments") | |
| i(a.argumentsError); | |
| else if (a.path.length === 0) | |
| s._errors.push(e(a)); | |
| else { | |
| let l = s, c = 0; | |
| for (; c < a.path.length; ) { | |
| const h = a.path[c]; | |
| c === a.path.length - 1 ? (l[h] = l[h] || { _errors: [] }, l[h]._errors.push(e(a))) : l[h] = l[h] || { _errors: [] }, l = l[h], c++; | |
| } | |
| } | |
| }; | |
| return i(this), s; | |
| } | |
| static assert(t) { | |
| if (!(t instanceof rs)) | |
| throw new Error(`Not a ZodError: ${t}`); | |
| } | |
| toString() { | |
| return this.message; | |
| } | |
| get message() { | |
| return JSON.stringify(this.issues, ct.jsonStringifyReplacer, 2); | |
| } | |
| get isEmpty() { | |
| return this.issues.length === 0; | |
| } | |
| flatten(t = (e) => e.message) { | |
| const e = {}, s = []; | |
| for (const i of this.issues) | |
| i.path.length > 0 ? (e[i.path[0]] = e[i.path[0]] || [], e[i.path[0]].push(t(i))) : s.push(t(i)); | |
| return { formErrors: s, fieldErrors: e }; | |
| } | |
| get formErrors() { | |
| return this.flatten(); | |
| } | |
| } | |
| rs.create = (n) => new rs(n); | |
| const Wo = (n, t) => { | |
| let e; | |
| switch (n.code) { | |
| case I.invalid_type: | |
| n.received === L.undefined ? e = "Required" : e = `Expected ${n.expected}, received ${n.received}`; | |
| break; | |
| case I.invalid_literal: | |
| e = `Invalid literal value, expected ${JSON.stringify(n.expected, ct.jsonStringifyReplacer)}`; | |
| break; | |
| case I.unrecognized_keys: | |
| e = `Unrecognized key(s) in object: ${ct.joinValues(n.keys, ", ")}`; | |
| break; | |
| case I.invalid_union: | |
| e = "Invalid input"; | |
| break; | |
| case I.invalid_union_discriminator: | |
| e = `Invalid discriminator value. Expected ${ct.joinValues(n.options)}`; | |
| break; | |
| case I.invalid_enum_value: | |
| e = `Invalid enum value. Expected ${ct.joinValues(n.options)}, received '${n.received}'`; | |
| break; | |
| case I.invalid_arguments: | |
| e = "Invalid function arguments"; | |
| break; | |
| case I.invalid_return_type: | |
| e = "Invalid function return type"; | |
| break; | |
| case I.invalid_date: | |
| e = "Invalid date"; | |
| break; | |
| case I.invalid_string: | |
| typeof n.validation == "object" ? "includes" in n.validation ? (e = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (e = `${e} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? e = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? e = `Invalid input: must end with "${n.validation.endsWith}"` : ct.assertNever(n.validation) : n.validation !== "regex" ? e = `Invalid ${n.validation}` : e = "Invalid"; | |
| break; | |
| case I.too_small: | |
| n.type === "array" ? e = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? e = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? e = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? e = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : e = "Invalid input"; | |
| break; | |
| case I.too_big: | |
| n.type === "array" ? e = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? e = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? e = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? e = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? e = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : e = "Invalid input"; | |
| break; | |
| case I.custom: | |
| e = "Invalid input"; | |
| break; | |
| case I.invalid_intersection_types: | |
| e = "Intersection results could not be merged"; | |
| break; | |
| case I.not_multiple_of: | |
| e = `Number must be a multiple of ${n.multipleOf}`; | |
| break; | |
| case I.not_finite: | |
| e = "Number must be finite"; | |
| break; | |
| default: | |
| e = t.defaultError, ct.assertNever(n); | |
| } | |
| return { message: e }; | |
| }; | |
| let zm = Wo; | |
| function iA(n) { | |
| zm = n; | |
| } | |
| function xu() { | |
| return zm; | |
| } | |
| const Tu = (n) => { | |
| const { data: t, path: e, errorMaps: s, issueData: i } = n, r = [...e, ...i.path || []], a = { | |
| ...i, | |
| path: r | |
| }; | |
| if (i.message !== void 0) | |
| return { | |
| ...i, | |
| path: r, | |
| message: i.message | |
| }; | |
| let l = ""; | |
| const c = s.filter((h) => !!h).slice().reverse(); | |
| for (const h of c) | |
| l = h(a, { data: t, defaultError: l }).message; | |
| return { | |
| ...i, | |
| path: r, | |
| message: l | |
| }; | |
| }, nA = []; | |
| function O(n, t) { | |
| const e = xu(), s = Tu({ | |
| issueData: t, | |
| data: n.data, | |
| path: n.path, | |
| errorMaps: [ | |
| n.common.contextualErrorMap, | |
| // contextual error map is first priority | |
| n.schemaErrorMap, | |
| // then schema-bound map if available | |
| e, | |
| // then global override map | |
| e === Wo ? void 0 : Wo | |
| // then global default map | |
| ].filter((i) => !!i) | |
| }); | |
| n.common.issues.push(s); | |
| } | |
| class Ee { | |
| constructor() { | |
| this.value = "valid"; | |
| } | |
| dirty() { | |
| this.value === "valid" && (this.value = "dirty"); | |
| } | |
| abort() { | |
| this.value !== "aborted" && (this.value = "aborted"); | |
| } | |
| static mergeArray(t, e) { | |
| const s = []; | |
| for (const i of e) { | |
| if (i.status === "aborted") | |
| return W; | |
| i.status === "dirty" && t.dirty(), s.push(i.value); | |
| } | |
| return { status: t.value, value: s }; | |
| } | |
| static async mergeObjectAsync(t, e) { | |
| const s = []; | |
| for (const i of e) { | |
| const r = await i.key, a = await i.value; | |
| s.push({ | |
| key: r, | |
| value: a | |
| }); | |
| } | |
| return Ee.mergeObjectSync(t, s); | |
| } | |
| static mergeObjectSync(t, e) { | |
| const s = {}; | |
| for (const i of e) { | |
| const { key: r, value: a } = i; | |
| if (r.status === "aborted" || a.status === "aborted") | |
| return W; | |
| r.status === "dirty" && t.dirty(), a.status === "dirty" && t.dirty(), r.value !== "__proto__" && (typeof a.value < "u" || i.alwaysSet) && (s[r.value] = a.value); | |
| } | |
| return { status: t.value, value: s }; | |
| } | |
| } | |
| const W = Object.freeze({ | |
| status: "aborted" | |
| }), Ra = (n) => ({ status: "dirty", value: n }), Le = (n) => ({ status: "valid", value: n }), tf = (n) => n.status === "aborted", ef = (n) => n.status === "dirty", ha = (n) => n.status === "valid", Dl = (n) => typeof Promise < "u" && n instanceof Promise; | |
| function Cu(n, t, e, s) { | |
| if (typeof t == "function" ? n !== t || !0 : !t.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | |
| return t.get(n); | |
| } | |
| function Vm(n, t, e, s, i) { | |
| if (typeof t == "function" ? n !== t || !0 : !t.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | |
| return t.set(n, e), e; | |
| } | |
| var B; | |
| (function(n) { | |
| n.errToObj = (t) => typeof t == "string" ? { message: t } : t || {}, n.toString = (t) => typeof t == "string" ? t : t == null ? void 0 : t.message; | |
| })(B || (B = {})); | |
| var ll, cl; | |
| class ui { | |
| constructor(t, e, s, i) { | |
| this._cachedPath = [], this.parent = t, this.data = e, this._path = s, this._key = i; | |
| } | |
| get path() { | |
| return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath; | |
| } | |
| } | |
| const vg = (n, t) => { | |
| if (ha(t)) | |
| return { success: !0, data: t.value }; | |
| if (!n.common.issues.length) | |
| throw new Error("Validation failed but no issues detected."); | |
| return { | |
| success: !1, | |
| get error() { | |
| if (this._error) | |
| return this._error; | |
| const e = new rs(n.common.issues); | |
| return this._error = e, this._error; | |
| } | |
| }; | |
| }; | |
| function J(n) { | |
| if (!n) | |
| return {}; | |
| const { errorMap: t, invalid_type_error: e, required_error: s, description: i } = n; | |
| if (t && (e || s)) | |
| throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); | |
| return t ? { errorMap: t, description: i } : { errorMap: (a, l) => { | |
| var c, h; | |
| const { message: u } = n; | |
| return a.code === "invalid_enum_value" ? { message: u ?? l.defaultError } : typeof l.data > "u" ? { message: (c = u ?? s) !== null && c !== void 0 ? c : l.defaultError } : a.code !== "invalid_type" ? { message: l.defaultError } : { message: (h = u ?? e) !== null && h !== void 0 ? h : l.defaultError }; | |
| }, description: i }; | |
| } | |
| class nt { | |
| get description() { | |
| return this._def.description; | |
| } | |
| _getType(t) { | |
| return _i(t.data); | |
| } | |
| _getOrReturnCtx(t, e) { | |
| return e || { | |
| common: t.parent.common, | |
| data: t.data, | |
| parsedType: _i(t.data), | |
| schemaErrorMap: this._def.errorMap, | |
| path: t.path, | |
| parent: t.parent | |
| }; | |
| } | |
| _processInputParams(t) { | |
| return { | |
| status: new Ee(), | |
| ctx: { | |
| common: t.parent.common, | |
| data: t.data, | |
| parsedType: _i(t.data), | |
| schemaErrorMap: this._def.errorMap, | |
| path: t.path, | |
| parent: t.parent | |
| } | |
| }; | |
| } | |
| _parseSync(t) { | |
| const e = this._parse(t); | |
| if (Dl(e)) | |
| throw new Error("Synchronous parse encountered promise."); | |
| return e; | |
| } | |
| _parseAsync(t) { | |
| const e = this._parse(t); | |
| return Promise.resolve(e); | |
| } | |
| parse(t, e) { | |
| const s = this.safeParse(t, e); | |
| if (s.success) | |
| return s.data; | |
| throw s.error; | |
| } | |
| safeParse(t, e) { | |
| var s; | |
| const i = { | |
| common: { | |
| issues: [], | |
| async: (s = e == null ? void 0 : e.async) !== null && s !== void 0 ? s : !1, | |
| contextualErrorMap: e == null ? void 0 : e.errorMap | |
| }, | |
| path: (e == null ? void 0 : e.path) || [], | |
| schemaErrorMap: this._def.errorMap, | |
| parent: null, | |
| data: t, | |
| parsedType: _i(t) | |
| }, r = this._parseSync({ data: t, path: i.path, parent: i }); | |
| return vg(i, r); | |
| } | |
| "~validate"(t) { | |
| var e, s; | |
| const i = { | |
| common: { | |
| issues: [], | |
| async: !!this["~standard"].async | |
| }, | |
| path: [], | |
| schemaErrorMap: this._def.errorMap, | |
| parent: null, | |
| data: t, | |
| parsedType: _i(t) | |
| }; | |
| if (!this["~standard"].async) | |
| try { | |
| const r = this._parseSync({ data: t, path: [], parent: i }); | |
| return ha(r) ? { | |
| value: r.value | |
| } : { | |
| issues: i.common.issues | |
| }; | |
| } catch (r) { | |
| !((s = (e = r == null ? void 0 : r.message) === null || e === void 0 ? void 0 : e.toLowerCase()) === null || s === void 0) && s.includes("encountered") && (this["~standard"].async = !0), i.common = { | |
| issues: [], | |
| async: !0 | |
| }; | |
| } | |
| return this._parseAsync({ data: t, path: [], parent: i }).then((r) => ha(r) ? { | |
| value: r.value | |
| } : { | |
| issues: i.common.issues | |
| }); | |
| } | |
| async parseAsync(t, e) { | |
| const s = await this.safeParseAsync(t, e); | |
| if (s.success) | |
| return s.data; | |
| throw s.error; | |
| } | |
| async safeParseAsync(t, e) { | |
| const s = { | |
| common: { | |
| issues: [], | |
| contextualErrorMap: e == null ? void 0 : e.errorMap, | |
| async: !0 | |
| }, | |
| path: (e == null ? void 0 : e.path) || [], | |
| schemaErrorMap: this._def.errorMap, | |
| parent: null, | |
| data: t, | |
| parsedType: _i(t) | |
| }, i = this._parse({ data: t, path: s.path, parent: s }), r = await (Dl(i) ? i : Promise.resolve(i)); | |
| return vg(s, r); | |
| } | |
| refine(t, e) { | |
| const s = (i) => typeof e == "string" || typeof e > "u" ? { message: e } : typeof e == "function" ? e(i) : e; | |
| return this._refinement((i, r) => { | |
| const a = t(i), l = () => r.addIssue({ | |
| code: I.custom, | |
| ...s(i) | |
| }); | |
| return typeof Promise < "u" && a instanceof Promise ? a.then((c) => c ? !0 : (l(), !1)) : a ? !0 : (l(), !1); | |
| }); | |
| } | |
| refinement(t, e) { | |
| return this._refinement((s, i) => t(s) ? !0 : (i.addIssue(typeof e == "function" ? e(s, i) : e), !1)); | |
| } | |
| _refinement(t) { | |
| return new Bs({ | |
| schema: this, | |
| typeName: R.ZodEffects, | |
| effect: { type: "refinement", refinement: t } | |
| }); | |
| } | |
| superRefine(t) { | |
| return this._refinement(t); | |
| } | |
| constructor(t) { | |
| this.spa = this.safeParseAsync, this._def = t, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = { | |
| version: 1, | |
| vendor: "zod", | |
| validate: (e) => this["~validate"](e) | |
| }; | |
| } | |
| optional() { | |
| return js.create(this, this._def); | |
| } | |
| nullable() { | |
| return jn.create(this, this._def); | |
| } | |
| nullish() { | |
| return this.nullable().optional(); | |
| } | |
| array() { | |
| return $s.create(this); | |
| } | |
| promise() { | |
| return Zo.create(this, this._def); | |
| } | |
| or(t) { | |
| return Bl.create([this, t], this._def); | |
| } | |
| and(t) { | |
| return Hl.create(this, t, this._def); | |
| } | |
| transform(t) { | |
| return new Bs({ | |
| ...J(this._def), | |
| schema: this, | |
| typeName: R.ZodEffects, | |
| effect: { type: "transform", transform: t } | |
| }); | |
| } | |
| default(t) { | |
| const e = typeof t == "function" ? t : () => t; | |
| return new ql({ | |
| ...J(this._def), | |
| innerType: this, | |
| defaultValue: e, | |
| typeName: R.ZodDefault | |
| }); | |
| } | |
| brand() { | |
| return new Ip({ | |
| typeName: R.ZodBranded, | |
| type: this, | |
| ...J(this._def) | |
| }); | |
| } | |
| catch(t) { | |
| const e = typeof t == "function" ? t : () => t; | |
| return new Wl({ | |
| ...J(this._def), | |
| innerType: this, | |
| catchValue: e, | |
| typeName: R.ZodCatch | |
| }); | |
| } | |
| describe(t) { | |
| const e = this.constructor; | |
| return new e({ | |
| ...this._def, | |
| description: t | |
| }); | |
| } | |
| pipe(t) { | |
| return Mh.create(this, t); | |
| } | |
| readonly() { | |
| return Xl.create(this); | |
| } | |
| isOptional() { | |
| return this.safeParse(void 0).success; | |
| } | |
| isNullable() { | |
| return this.safeParse(null).success; | |
| } | |
| } | |
| const rA = /^c[^\s-]{8,}$/i, aA = /^[0-9a-z]+$/, oA = /^[0-9A-HJKMNP-TV-Z]{26}$/i, lA = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, cA = /^[a-z0-9_-]{21}$/i, hA = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, uA = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, dA = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, fA = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$"; | |
| let Nd; | |
| const pA = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, gA = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, mA = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, yA = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, bA = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, vA = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Gm = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", _A = new RegExp(`^${Gm}$`); | |
| function qm(n) { | |
| let t = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d"; | |
| return n.precision ? t = `${t}\\.\\d{${n.precision}}` : n.precision == null && (t = `${t}(\\.\\d+)?`), t; | |
| } | |
| function AA(n) { | |
| return new RegExp(`^${qm(n)}$`); | |
| } | |
| function Wm(n) { | |
| let t = `${Gm}T${qm(n)}`; | |
| const e = []; | |
| return e.push(n.local ? "Z?" : "Z"), n.offset && e.push("([+-]\\d{2}:?\\d{2})"), t = `${t}(${e.join("|")})`, new RegExp(`^${t}$`); | |
| } | |
| function wA(n, t) { | |
| return !!((t === "v4" || !t) && pA.test(n) || (t === "v6" || !t) && mA.test(n)); | |
| } | |
| function SA(n, t) { | |
| if (!hA.test(n)) | |
| return !1; | |
| try { | |
| const [e] = n.split("."), s = e.replace(/-/g, "+").replace(/_/g, "/").padEnd(e.length + (4 - e.length % 4) % 4, "="), i = JSON.parse(atob(s)); | |
| return !(typeof i != "object" || i === null || !i.typ || !i.alg || t && i.alg !== t); | |
| } catch { | |
| return !1; | |
| } | |
| } | |
| function EA(n, t) { | |
| return !!((t === "v4" || !t) && gA.test(n) || (t === "v6" || !t) && yA.test(n)); | |
| } | |
| class Ds extends nt { | |
| _parse(t) { | |
| if (this._def.coerce && (t.data = String(t.data)), this._getType(t) !== L.string) { | |
| const r = this._getOrReturnCtx(t); | |
| return O(r, { | |
| code: I.invalid_type, | |
| expected: L.string, | |
| received: r.parsedType | |
| }), W; | |
| } | |
| const s = new Ee(); | |
| let i; | |
| for (const r of this._def.checks) | |
| if (r.kind === "min") | |
| t.data.length < r.value && (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.too_small, | |
| minimum: r.value, | |
| type: "string", | |
| inclusive: !0, | |
| exact: !1, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "max") | |
| t.data.length > r.value && (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.too_big, | |
| maximum: r.value, | |
| type: "string", | |
| inclusive: !0, | |
| exact: !1, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "length") { | |
| const a = t.data.length > r.value, l = t.data.length < r.value; | |
| (a || l) && (i = this._getOrReturnCtx(t, i), a ? O(i, { | |
| code: I.too_big, | |
| maximum: r.value, | |
| type: "string", | |
| inclusive: !0, | |
| exact: !0, | |
| message: r.message | |
| }) : l && O(i, { | |
| code: I.too_small, | |
| minimum: r.value, | |
| type: "string", | |
| inclusive: !0, | |
| exact: !0, | |
| message: r.message | |
| }), s.dirty()); | |
| } else if (r.kind === "email") | |
| dA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "email", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "emoji") | |
| Nd || (Nd = new RegExp(fA, "u")), Nd.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "emoji", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "uuid") | |
| lA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "uuid", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "nanoid") | |
| cA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "nanoid", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "cuid") | |
| rA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "cuid", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "cuid2") | |
| aA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "cuid2", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "ulid") | |
| oA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "ulid", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()); | |
| else if (r.kind === "url") | |
| try { | |
| new URL(t.data); | |
| } catch { | |
| i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "url", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty(); | |
| } | |
| else r.kind === "regex" ? (r.regex.lastIndex = 0, r.regex.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "regex", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty())) : r.kind === "trim" ? t.data = t.data.trim() : r.kind === "includes" ? t.data.includes(r.value, r.position) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.invalid_string, | |
| validation: { includes: r.value, position: r.position }, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "toLowerCase" ? t.data = t.data.toLowerCase() : r.kind === "toUpperCase" ? t.data = t.data.toUpperCase() : r.kind === "startsWith" ? t.data.startsWith(r.value) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.invalid_string, | |
| validation: { startsWith: r.value }, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "endsWith" ? t.data.endsWith(r.value) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.invalid_string, | |
| validation: { endsWith: r.value }, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "datetime" ? Wm(r).test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.invalid_string, | |
| validation: "datetime", | |
| message: r.message | |
| }), s.dirty()) : r.kind === "date" ? _A.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.invalid_string, | |
| validation: "date", | |
| message: r.message | |
| }), s.dirty()) : r.kind === "time" ? AA(r).test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.invalid_string, | |
| validation: "time", | |
| message: r.message | |
| }), s.dirty()) : r.kind === "duration" ? uA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "duration", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "ip" ? wA(t.data, r.version) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "ip", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "jwt" ? SA(t.data, r.alg) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "jwt", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "cidr" ? EA(t.data, r.version) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "cidr", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "base64" ? bA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "base64", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()) : r.kind === "base64url" ? vA.test(t.data) || (i = this._getOrReturnCtx(t, i), O(i, { | |
| validation: "base64url", | |
| code: I.invalid_string, | |
| message: r.message | |
| }), s.dirty()) : ct.assertNever(r); | |
| return { status: s.value, value: t.data }; | |
| } | |
| _regex(t, e, s) { | |
| return this.refinement((i) => t.test(i), { | |
| validation: e, | |
| code: I.invalid_string, | |
| ...B.errToObj(s) | |
| }); | |
| } | |
| _addCheck(t) { | |
| return new Ds({ | |
| ...this._def, | |
| checks: [...this._def.checks, t] | |
| }); | |
| } | |
| email(t) { | |
| return this._addCheck({ kind: "email", ...B.errToObj(t) }); | |
| } | |
| url(t) { | |
| return this._addCheck({ kind: "url", ...B.errToObj(t) }); | |
| } | |
| emoji(t) { | |
| return this._addCheck({ kind: "emoji", ...B.errToObj(t) }); | |
| } | |
| uuid(t) { | |
| return this._addCheck({ kind: "uuid", ...B.errToObj(t) }); | |
| } | |
| nanoid(t) { | |
| return this._addCheck({ kind: "nanoid", ...B.errToObj(t) }); | |
| } | |
| cuid(t) { | |
| return this._addCheck({ kind: "cuid", ...B.errToObj(t) }); | |
| } | |
| cuid2(t) { | |
| return this._addCheck({ kind: "cuid2", ...B.errToObj(t) }); | |
| } | |
| ulid(t) { | |
| return this._addCheck({ kind: "ulid", ...B.errToObj(t) }); | |
| } | |
| base64(t) { | |
| return this._addCheck({ kind: "base64", ...B.errToObj(t) }); | |
| } | |
| base64url(t) { | |
| return this._addCheck({ | |
| kind: "base64url", | |
| ...B.errToObj(t) | |
| }); | |
| } | |
| jwt(t) { | |
| return this._addCheck({ kind: "jwt", ...B.errToObj(t) }); | |
| } | |
| ip(t) { | |
| return this._addCheck({ kind: "ip", ...B.errToObj(t) }); | |
| } | |
| cidr(t) { | |
| return this._addCheck({ kind: "cidr", ...B.errToObj(t) }); | |
| } | |
| datetime(t) { | |
| var e, s; | |
| return typeof t == "string" ? this._addCheck({ | |
| kind: "datetime", | |
| precision: null, | |
| offset: !1, | |
| local: !1, | |
| message: t | |
| }) : this._addCheck({ | |
| kind: "datetime", | |
| precision: typeof (t == null ? void 0 : t.precision) > "u" ? null : t == null ? void 0 : t.precision, | |
| offset: (e = t == null ? void 0 : t.offset) !== null && e !== void 0 ? e : !1, | |
| local: (s = t == null ? void 0 : t.local) !== null && s !== void 0 ? s : !1, | |
| ...B.errToObj(t == null ? void 0 : t.message) | |
| }); | |
| } | |
| date(t) { | |
| return this._addCheck({ kind: "date", message: t }); | |
| } | |
| time(t) { | |
| return typeof t == "string" ? this._addCheck({ | |
| kind: "time", | |
| precision: null, | |
| message: t | |
| }) : this._addCheck({ | |
| kind: "time", | |
| precision: typeof (t == null ? void 0 : t.precision) > "u" ? null : t == null ? void 0 : t.precision, | |
| ...B.errToObj(t == null ? void 0 : t.message) | |
| }); | |
| } | |
| duration(t) { | |
| return this._addCheck({ kind: "duration", ...B.errToObj(t) }); | |
| } | |
| regex(t, e) { | |
| return this._addCheck({ | |
| kind: "regex", | |
| regex: t, | |
| ...B.errToObj(e) | |
| }); | |
| } | |
| includes(t, e) { | |
| return this._addCheck({ | |
| kind: "includes", | |
| value: t, | |
| position: e == null ? void 0 : e.position, | |
| ...B.errToObj(e == null ? void 0 : e.message) | |
| }); | |
| } | |
| startsWith(t, e) { | |
| return this._addCheck({ | |
| kind: "startsWith", | |
| value: t, | |
| ...B.errToObj(e) | |
| }); | |
| } | |
| endsWith(t, e) { | |
| return this._addCheck({ | |
| kind: "endsWith", | |
| value: t, | |
| ...B.errToObj(e) | |
| }); | |
| } | |
| min(t, e) { | |
| return this._addCheck({ | |
| kind: "min", | |
| value: t, | |
| ...B.errToObj(e) | |
| }); | |
| } | |
| max(t, e) { | |
| return this._addCheck({ | |
| kind: "max", | |
| value: t, | |
| ...B.errToObj(e) | |
| }); | |
| } | |
| length(t, e) { | |
| return this._addCheck({ | |
| kind: "length", | |
| value: t, | |
| ...B.errToObj(e) | |
| }); | |
| } | |
| /** | |
| * Equivalent to `.min(1)` | |
| */ | |
| nonempty(t) { | |
| return this.min(1, B.errToObj(t)); | |
| } | |
| trim() { | |
| return new Ds({ | |
| ...this._def, | |
| checks: [...this._def.checks, { kind: "trim" }] | |
| }); | |
| } | |
| toLowerCase() { | |
| return new Ds({ | |
| ...this._def, | |
| checks: [...this._def.checks, { kind: "toLowerCase" }] | |
| }); | |
| } | |
| toUpperCase() { | |
| return new Ds({ | |
| ...this._def, | |
| checks: [...this._def.checks, { kind: "toUpperCase" }] | |
| }); | |
| } | |
| get isDatetime() { | |
| return !!this._def.checks.find((t) => t.kind === "datetime"); | |
| } | |
| get isDate() { | |
| return !!this._def.checks.find((t) => t.kind === "date"); | |
| } | |
| get isTime() { | |
| return !!this._def.checks.find((t) => t.kind === "time"); | |
| } | |
| get isDuration() { | |
| return !!this._def.checks.find((t) => t.kind === "duration"); | |
| } | |
| get isEmail() { | |
| return !!this._def.checks.find((t) => t.kind === "email"); | |
| } | |
| get isURL() { | |
| return !!this._def.checks.find((t) => t.kind === "url"); | |
| } | |
| get isEmoji() { | |
| return !!this._def.checks.find((t) => t.kind === "emoji"); | |
| } | |
| get isUUID() { | |
| return !!this._def.checks.find((t) => t.kind === "uuid"); | |
| } | |
| get isNANOID() { | |
| return !!this._def.checks.find((t) => t.kind === "nanoid"); | |
| } | |
| get isCUID() { | |
| return !!this._def.checks.find((t) => t.kind === "cuid"); | |
| } | |
| get isCUID2() { | |
| return !!this._def.checks.find((t) => t.kind === "cuid2"); | |
| } | |
| get isULID() { | |
| return !!this._def.checks.find((t) => t.kind === "ulid"); | |
| } | |
| get isIP() { | |
| return !!this._def.checks.find((t) => t.kind === "ip"); | |
| } | |
| get isCIDR() { | |
| return !!this._def.checks.find((t) => t.kind === "cidr"); | |
| } | |
| get isBase64() { | |
| return !!this._def.checks.find((t) => t.kind === "base64"); | |
| } | |
| get isBase64url() { | |
| return !!this._def.checks.find((t) => t.kind === "base64url"); | |
| } | |
| get minLength() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "min" && (t === null || e.value > t) && (t = e.value); | |
| return t; | |
| } | |
| get maxLength() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "max" && (t === null || e.value < t) && (t = e.value); | |
| return t; | |
| } | |
| } | |
| Ds.create = (n) => { | |
| var t; | |
| return new Ds({ | |
| checks: [], | |
| typeName: R.ZodString, | |
| coerce: (t = n == null ? void 0 : n.coerce) !== null && t !== void 0 ? t : !1, | |
| ...J(n) | |
| }); | |
| }; | |
| function xA(n, t) { | |
| const e = (n.toString().split(".")[1] || "").length, s = (t.toString().split(".")[1] || "").length, i = e > s ? e : s, r = parseInt(n.toFixed(i).replace(".", "")), a = parseInt(t.toFixed(i).replace(".", "")); | |
| return r % a / Math.pow(10, i); | |
| } | |
| class Dn extends nt { | |
| constructor() { | |
| super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf; | |
| } | |
| _parse(t) { | |
| if (this._def.coerce && (t.data = Number(t.data)), this._getType(t) !== L.number) { | |
| const r = this._getOrReturnCtx(t); | |
| return O(r, { | |
| code: I.invalid_type, | |
| expected: L.number, | |
| received: r.parsedType | |
| }), W; | |
| } | |
| let s; | |
| const i = new Ee(); | |
| for (const r of this._def.checks) | |
| r.kind === "int" ? ct.isInteger(t.data) || (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.invalid_type, | |
| expected: "integer", | |
| received: "float", | |
| message: r.message | |
| }), i.dirty()) : r.kind === "min" ? (r.inclusive ? t.data < r.value : t.data <= r.value) && (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.too_small, | |
| minimum: r.value, | |
| type: "number", | |
| inclusive: r.inclusive, | |
| exact: !1, | |
| message: r.message | |
| }), i.dirty()) : r.kind === "max" ? (r.inclusive ? t.data > r.value : t.data >= r.value) && (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.too_big, | |
| maximum: r.value, | |
| type: "number", | |
| inclusive: r.inclusive, | |
| exact: !1, | |
| message: r.message | |
| }), i.dirty()) : r.kind === "multipleOf" ? xA(t.data, r.value) !== 0 && (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.not_multiple_of, | |
| multipleOf: r.value, | |
| message: r.message | |
| }), i.dirty()) : r.kind === "finite" ? Number.isFinite(t.data) || (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.not_finite, | |
| message: r.message | |
| }), i.dirty()) : ct.assertNever(r); | |
| return { status: i.value, value: t.data }; | |
| } | |
| gte(t, e) { | |
| return this.setLimit("min", t, !0, B.toString(e)); | |
| } | |
| gt(t, e) { | |
| return this.setLimit("min", t, !1, B.toString(e)); | |
| } | |
| lte(t, e) { | |
| return this.setLimit("max", t, !0, B.toString(e)); | |
| } | |
| lt(t, e) { | |
| return this.setLimit("max", t, !1, B.toString(e)); | |
| } | |
| setLimit(t, e, s, i) { | |
| return new Dn({ | |
| ...this._def, | |
| checks: [ | |
| ...this._def.checks, | |
| { | |
| kind: t, | |
| value: e, | |
| inclusive: s, | |
| message: B.toString(i) | |
| } | |
| ] | |
| }); | |
| } | |
| _addCheck(t) { | |
| return new Dn({ | |
| ...this._def, | |
| checks: [...this._def.checks, t] | |
| }); | |
| } | |
| int(t) { | |
| return this._addCheck({ | |
| kind: "int", | |
| message: B.toString(t) | |
| }); | |
| } | |
| positive(t) { | |
| return this._addCheck({ | |
| kind: "min", | |
| value: 0, | |
| inclusive: !1, | |
| message: B.toString(t) | |
| }); | |
| } | |
| negative(t) { | |
| return this._addCheck({ | |
| kind: "max", | |
| value: 0, | |
| inclusive: !1, | |
| message: B.toString(t) | |
| }); | |
| } | |
| nonpositive(t) { | |
| return this._addCheck({ | |
| kind: "max", | |
| value: 0, | |
| inclusive: !0, | |
| message: B.toString(t) | |
| }); | |
| } | |
| nonnegative(t) { | |
| return this._addCheck({ | |
| kind: "min", | |
| value: 0, | |
| inclusive: !0, | |
| message: B.toString(t) | |
| }); | |
| } | |
| multipleOf(t, e) { | |
| return this._addCheck({ | |
| kind: "multipleOf", | |
| value: t, | |
| message: B.toString(e) | |
| }); | |
| } | |
| finite(t) { | |
| return this._addCheck({ | |
| kind: "finite", | |
| message: B.toString(t) | |
| }); | |
| } | |
| safe(t) { | |
| return this._addCheck({ | |
| kind: "min", | |
| inclusive: !0, | |
| value: Number.MIN_SAFE_INTEGER, | |
| message: B.toString(t) | |
| })._addCheck({ | |
| kind: "max", | |
| inclusive: !0, | |
| value: Number.MAX_SAFE_INTEGER, | |
| message: B.toString(t) | |
| }); | |
| } | |
| get minValue() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "min" && (t === null || e.value > t) && (t = e.value); | |
| return t; | |
| } | |
| get maxValue() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "max" && (t === null || e.value < t) && (t = e.value); | |
| return t; | |
| } | |
| get isInt() { | |
| return !!this._def.checks.find((t) => t.kind === "int" || t.kind === "multipleOf" && ct.isInteger(t.value)); | |
| } | |
| get isFinite() { | |
| let t = null, e = null; | |
| for (const s of this._def.checks) { | |
| if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf") | |
| return !0; | |
| s.kind === "min" ? (e === null || s.value > e) && (e = s.value) : s.kind === "max" && (t === null || s.value < t) && (t = s.value); | |
| } | |
| return Number.isFinite(e) && Number.isFinite(t); | |
| } | |
| } | |
| Dn.create = (n) => new Dn({ | |
| checks: [], | |
| typeName: R.ZodNumber, | |
| coerce: (n == null ? void 0 : n.coerce) || !1, | |
| ...J(n) | |
| }); | |
| class Fn extends nt { | |
| constructor() { | |
| super(...arguments), this.min = this.gte, this.max = this.lte; | |
| } | |
| _parse(t) { | |
| if (this._def.coerce) | |
| try { | |
| t.data = BigInt(t.data); | |
| } catch { | |
| return this._getInvalidInput(t); | |
| } | |
| if (this._getType(t) !== L.bigint) | |
| return this._getInvalidInput(t); | |
| let s; | |
| const i = new Ee(); | |
| for (const r of this._def.checks) | |
| r.kind === "min" ? (r.inclusive ? t.data < r.value : t.data <= r.value) && (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.too_small, | |
| type: "bigint", | |
| minimum: r.value, | |
| inclusive: r.inclusive, | |
| message: r.message | |
| }), i.dirty()) : r.kind === "max" ? (r.inclusive ? t.data > r.value : t.data >= r.value) && (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.too_big, | |
| type: "bigint", | |
| maximum: r.value, | |
| inclusive: r.inclusive, | |
| message: r.message | |
| }), i.dirty()) : r.kind === "multipleOf" ? t.data % r.value !== BigInt(0) && (s = this._getOrReturnCtx(t, s), O(s, { | |
| code: I.not_multiple_of, | |
| multipleOf: r.value, | |
| message: r.message | |
| }), i.dirty()) : ct.assertNever(r); | |
| return { status: i.value, value: t.data }; | |
| } | |
| _getInvalidInput(t) { | |
| const e = this._getOrReturnCtx(t); | |
| return O(e, { | |
| code: I.invalid_type, | |
| expected: L.bigint, | |
| received: e.parsedType | |
| }), W; | |
| } | |
| gte(t, e) { | |
| return this.setLimit("min", t, !0, B.toString(e)); | |
| } | |
| gt(t, e) { | |
| return this.setLimit("min", t, !1, B.toString(e)); | |
| } | |
| lte(t, e) { | |
| return this.setLimit("max", t, !0, B.toString(e)); | |
| } | |
| lt(t, e) { | |
| return this.setLimit("max", t, !1, B.toString(e)); | |
| } | |
| setLimit(t, e, s, i) { | |
| return new Fn({ | |
| ...this._def, | |
| checks: [ | |
| ...this._def.checks, | |
| { | |
| kind: t, | |
| value: e, | |
| inclusive: s, | |
| message: B.toString(i) | |
| } | |
| ] | |
| }); | |
| } | |
| _addCheck(t) { | |
| return new Fn({ | |
| ...this._def, | |
| checks: [...this._def.checks, t] | |
| }); | |
| } | |
| positive(t) { | |
| return this._addCheck({ | |
| kind: "min", | |
| value: BigInt(0), | |
| inclusive: !1, | |
| message: B.toString(t) | |
| }); | |
| } | |
| negative(t) { | |
| return this._addCheck({ | |
| kind: "max", | |
| value: BigInt(0), | |
| inclusive: !1, | |
| message: B.toString(t) | |
| }); | |
| } | |
| nonpositive(t) { | |
| return this._addCheck({ | |
| kind: "max", | |
| value: BigInt(0), | |
| inclusive: !0, | |
| message: B.toString(t) | |
| }); | |
| } | |
| nonnegative(t) { | |
| return this._addCheck({ | |
| kind: "min", | |
| value: BigInt(0), | |
| inclusive: !0, | |
| message: B.toString(t) | |
| }); | |
| } | |
| multipleOf(t, e) { | |
| return this._addCheck({ | |
| kind: "multipleOf", | |
| value: t, | |
| message: B.toString(e) | |
| }); | |
| } | |
| get minValue() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "min" && (t === null || e.value > t) && (t = e.value); | |
| return t; | |
| } | |
| get maxValue() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "max" && (t === null || e.value < t) && (t = e.value); | |
| return t; | |
| } | |
| } | |
| Fn.create = (n) => { | |
| var t; | |
| return new Fn({ | |
| checks: [], | |
| typeName: R.ZodBigInt, | |
| coerce: (t = n == null ? void 0 : n.coerce) !== null && t !== void 0 ? t : !1, | |
| ...J(n) | |
| }); | |
| }; | |
| class Fl extends nt { | |
| _parse(t) { | |
| if (this._def.coerce && (t.data = !!t.data), this._getType(t) !== L.boolean) { | |
| const s = this._getOrReturnCtx(t); | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.boolean, | |
| received: s.parsedType | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| } | |
| Fl.create = (n) => new Fl({ | |
| typeName: R.ZodBoolean, | |
| coerce: (n == null ? void 0 : n.coerce) || !1, | |
| ...J(n) | |
| }); | |
| class ua extends nt { | |
| _parse(t) { | |
| if (this._def.coerce && (t.data = new Date(t.data)), this._getType(t) !== L.date) { | |
| const r = this._getOrReturnCtx(t); | |
| return O(r, { | |
| code: I.invalid_type, | |
| expected: L.date, | |
| received: r.parsedType | |
| }), W; | |
| } | |
| if (isNaN(t.data.getTime())) { | |
| const r = this._getOrReturnCtx(t); | |
| return O(r, { | |
| code: I.invalid_date | |
| }), W; | |
| } | |
| const s = new Ee(); | |
| let i; | |
| for (const r of this._def.checks) | |
| r.kind === "min" ? t.data.getTime() < r.value && (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.too_small, | |
| message: r.message, | |
| inclusive: !0, | |
| exact: !1, | |
| minimum: r.value, | |
| type: "date" | |
| }), s.dirty()) : r.kind === "max" ? t.data.getTime() > r.value && (i = this._getOrReturnCtx(t, i), O(i, { | |
| code: I.too_big, | |
| message: r.message, | |
| inclusive: !0, | |
| exact: !1, | |
| maximum: r.value, | |
| type: "date" | |
| }), s.dirty()) : ct.assertNever(r); | |
| return { | |
| status: s.value, | |
| value: new Date(t.data.getTime()) | |
| }; | |
| } | |
| _addCheck(t) { | |
| return new ua({ | |
| ...this._def, | |
| checks: [...this._def.checks, t] | |
| }); | |
| } | |
| min(t, e) { | |
| return this._addCheck({ | |
| kind: "min", | |
| value: t.getTime(), | |
| message: B.toString(e) | |
| }); | |
| } | |
| max(t, e) { | |
| return this._addCheck({ | |
| kind: "max", | |
| value: t.getTime(), | |
| message: B.toString(e) | |
| }); | |
| } | |
| get minDate() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "min" && (t === null || e.value > t) && (t = e.value); | |
| return t != null ? new Date(t) : null; | |
| } | |
| get maxDate() { | |
| let t = null; | |
| for (const e of this._def.checks) | |
| e.kind === "max" && (t === null || e.value < t) && (t = e.value); | |
| return t != null ? new Date(t) : null; | |
| } | |
| } | |
| ua.create = (n) => new ua({ | |
| checks: [], | |
| coerce: (n == null ? void 0 : n.coerce) || !1, | |
| typeName: R.ZodDate, | |
| ...J(n) | |
| }); | |
| class ku extends nt { | |
| _parse(t) { | |
| if (this._getType(t) !== L.symbol) { | |
| const s = this._getOrReturnCtx(t); | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.symbol, | |
| received: s.parsedType | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| } | |
| ku.create = (n) => new ku({ | |
| typeName: R.ZodSymbol, | |
| ...J(n) | |
| }); | |
| class $l extends nt { | |
| _parse(t) { | |
| if (this._getType(t) !== L.undefined) { | |
| const s = this._getOrReturnCtx(t); | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.undefined, | |
| received: s.parsedType | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| } | |
| $l.create = (n) => new $l({ | |
| typeName: R.ZodUndefined, | |
| ...J(n) | |
| }); | |
| class jl extends nt { | |
| _parse(t) { | |
| if (this._getType(t) !== L.null) { | |
| const s = this._getOrReturnCtx(t); | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.null, | |
| received: s.parsedType | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| } | |
| jl.create = (n) => new jl({ | |
| typeName: R.ZodNull, | |
| ...J(n) | |
| }); | |
| class Xo extends nt { | |
| constructor() { | |
| super(...arguments), this._any = !0; | |
| } | |
| _parse(t) { | |
| return Le(t.data); | |
| } | |
| } | |
| Xo.create = (n) => new Xo({ | |
| typeName: R.ZodAny, | |
| ...J(n) | |
| }); | |
| class oa extends nt { | |
| constructor() { | |
| super(...arguments), this._unknown = !0; | |
| } | |
| _parse(t) { | |
| return Le(t.data); | |
| } | |
| } | |
| oa.create = (n) => new oa({ | |
| typeName: R.ZodUnknown, | |
| ...J(n) | |
| }); | |
| class Yi extends nt { | |
| _parse(t) { | |
| const e = this._getOrReturnCtx(t); | |
| return O(e, { | |
| code: I.invalid_type, | |
| expected: L.never, | |
| received: e.parsedType | |
| }), W; | |
| } | |
| } | |
| Yi.create = (n) => new Yi({ | |
| typeName: R.ZodNever, | |
| ...J(n) | |
| }); | |
| class Iu extends nt { | |
| _parse(t) { | |
| if (this._getType(t) !== L.undefined) { | |
| const s = this._getOrReturnCtx(t); | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.void, | |
| received: s.parsedType | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| } | |
| Iu.create = (n) => new Iu({ | |
| typeName: R.ZodVoid, | |
| ...J(n) | |
| }); | |
| class $s extends nt { | |
| _parse(t) { | |
| const { ctx: e, status: s } = this._processInputParams(t), i = this._def; | |
| if (e.parsedType !== L.array) | |
| return O(e, { | |
| code: I.invalid_type, | |
| expected: L.array, | |
| received: e.parsedType | |
| }), W; | |
| if (i.exactLength !== null) { | |
| const a = e.data.length > i.exactLength.value, l = e.data.length < i.exactLength.value; | |
| (a || l) && (O(e, { | |
| code: a ? I.too_big : I.too_small, | |
| minimum: l ? i.exactLength.value : void 0, | |
| maximum: a ? i.exactLength.value : void 0, | |
| type: "array", | |
| inclusive: !0, | |
| exact: !0, | |
| message: i.exactLength.message | |
| }), s.dirty()); | |
| } | |
| if (i.minLength !== null && e.data.length < i.minLength.value && (O(e, { | |
| code: I.too_small, | |
| minimum: i.minLength.value, | |
| type: "array", | |
| inclusive: !0, | |
| exact: !1, | |
| message: i.minLength.message | |
| }), s.dirty()), i.maxLength !== null && e.data.length > i.maxLength.value && (O(e, { | |
| code: I.too_big, | |
| maximum: i.maxLength.value, | |
| type: "array", | |
| inclusive: !0, | |
| exact: !1, | |
| message: i.maxLength.message | |
| }), s.dirty()), e.common.async) | |
| return Promise.all([...e.data].map((a, l) => i.type._parseAsync(new ui(e, a, e.path, l)))).then((a) => Ee.mergeArray(s, a)); | |
| const r = [...e.data].map((a, l) => i.type._parseSync(new ui(e, a, e.path, l))); | |
| return Ee.mergeArray(s, r); | |
| } | |
| get element() { | |
| return this._def.type; | |
| } | |
| min(t, e) { | |
| return new $s({ | |
| ...this._def, | |
| minLength: { value: t, message: B.toString(e) } | |
| }); | |
| } | |
| max(t, e) { | |
| return new $s({ | |
| ...this._def, | |
| maxLength: { value: t, message: B.toString(e) } | |
| }); | |
| } | |
| length(t, e) { | |
| return new $s({ | |
| ...this._def, | |
| exactLength: { value: t, message: B.toString(e) } | |
| }); | |
| } | |
| nonempty(t) { | |
| return this.min(1, t); | |
| } | |
| } | |
| $s.create = (n, t) => new $s({ | |
| type: n, | |
| minLength: null, | |
| maxLength: null, | |
| exactLength: null, | |
| typeName: R.ZodArray, | |
| ...J(t) | |
| }); | |
| function wa(n) { | |
| if (n instanceof Dt) { | |
| const t = {}; | |
| for (const e in n.shape) { | |
| const s = n.shape[e]; | |
| t[e] = js.create(wa(s)); | |
| } | |
| return new Dt({ | |
| ...n._def, | |
| shape: () => t | |
| }); | |
| } else return n instanceof $s ? new $s({ | |
| ...n._def, | |
| type: wa(n.element) | |
| }) : n instanceof js ? js.create(wa(n.unwrap())) : n instanceof jn ? jn.create(wa(n.unwrap())) : n instanceof di ? di.create(n.items.map((t) => wa(t))) : n; | |
| } | |
| class Dt extends nt { | |
| constructor() { | |
| super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend; | |
| } | |
| _getCached() { | |
| if (this._cached !== null) | |
| return this._cached; | |
| const t = this._def.shape(), e = ct.objectKeys(t); | |
| return this._cached = { shape: t, keys: e }; | |
| } | |
| _parse(t) { | |
| if (this._getType(t) !== L.object) { | |
| const h = this._getOrReturnCtx(t); | |
| return O(h, { | |
| code: I.invalid_type, | |
| expected: L.object, | |
| received: h.parsedType | |
| }), W; | |
| } | |
| const { status: s, ctx: i } = this._processInputParams(t), { shape: r, keys: a } = this._getCached(), l = []; | |
| if (!(this._def.catchall instanceof Yi && this._def.unknownKeys === "strip")) | |
| for (const h in i.data) | |
| a.includes(h) || l.push(h); | |
| const c = []; | |
| for (const h of a) { | |
| const u = r[h], d = i.data[h]; | |
| c.push({ | |
| key: { status: "valid", value: h }, | |
| value: u._parse(new ui(i, d, i.path, h)), | |
| alwaysSet: h in i.data | |
| }); | |
| } | |
| if (this._def.catchall instanceof Yi) { | |
| const h = this._def.unknownKeys; | |
| if (h === "passthrough") | |
| for (const u of l) | |
| c.push({ | |
| key: { status: "valid", value: u }, | |
| value: { status: "valid", value: i.data[u] } | |
| }); | |
| else if (h === "strict") | |
| l.length > 0 && (O(i, { | |
| code: I.unrecognized_keys, | |
| keys: l | |
| }), s.dirty()); | |
| else if (h !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value."); | |
| } else { | |
| const h = this._def.catchall; | |
| for (const u of l) { | |
| const d = i.data[u]; | |
| c.push({ | |
| key: { status: "valid", value: u }, | |
| value: h._parse( | |
| new ui(i, d, i.path, u) | |
| //, ctx.child(key), value, getParsedType(value) | |
| ), | |
| alwaysSet: u in i.data | |
| }); | |
| } | |
| } | |
| return i.common.async ? Promise.resolve().then(async () => { | |
| const h = []; | |
| for (const u of c) { | |
| const d = await u.key, f = await u.value; | |
| h.push({ | |
| key: d, | |
| value: f, | |
| alwaysSet: u.alwaysSet | |
| }); | |
| } | |
| return h; | |
| }).then((h) => Ee.mergeObjectSync(s, h)) : Ee.mergeObjectSync(s, c); | |
| } | |
| get shape() { | |
| return this._def.shape(); | |
| } | |
| strict(t) { | |
| return B.errToObj, new Dt({ | |
| ...this._def, | |
| unknownKeys: "strict", | |
| ...t !== void 0 ? { | |
| errorMap: (e, s) => { | |
| var i, r, a, l; | |
| const c = (a = (r = (i = this._def).errorMap) === null || r === void 0 ? void 0 : r.call(i, e, s).message) !== null && a !== void 0 ? a : s.defaultError; | |
| return e.code === "unrecognized_keys" ? { | |
| message: (l = B.errToObj(t).message) !== null && l !== void 0 ? l : c | |
| } : { | |
| message: c | |
| }; | |
| } | |
| } : {} | |
| }); | |
| } | |
| strip() { | |
| return new Dt({ | |
| ...this._def, | |
| unknownKeys: "strip" | |
| }); | |
| } | |
| passthrough() { | |
| return new Dt({ | |
| ...this._def, | |
| unknownKeys: "passthrough" | |
| }); | |
| } | |
| // const AugmentFactory = | |
| // <Def extends ZodObjectDef>(def: Def) => | |
| // <Augmentation extends ZodRawShape>( | |
| // augmentation: Augmentation | |
| // ): ZodObject< | |
| // extendShape<ReturnType<Def["shape"]>, Augmentation>, | |
| // Def["unknownKeys"], | |
| // Def["catchall"] | |
| // > => { | |
| // return new ZodObject({ | |
| // ...def, | |
| // shape: () => ({ | |
| // ...def.shape(), | |
| // ...augmentation, | |
| // }), | |
| // }) as any; | |
| // }; | |
| extend(t) { | |
| return new Dt({ | |
| ...this._def, | |
| shape: () => ({ | |
| ...this._def.shape(), | |
| ...t | |
| }) | |
| }); | |
| } | |
| /** | |
| * Prior to [email protected] there was a bug in the | |
| * inferred type of merged objects. Please | |
| * upgrade if you are experiencing issues. | |
| */ | |
| merge(t) { | |
| return new Dt({ | |
| unknownKeys: t._def.unknownKeys, | |
| catchall: t._def.catchall, | |
| shape: () => ({ | |
| ...this._def.shape(), | |
| ...t._def.shape() | |
| }), | |
| typeName: R.ZodObject | |
| }); | |
| } | |
| // merge< | |
| // Incoming extends AnyZodObject, | |
| // Augmentation extends Incoming["shape"], | |
| // NewOutput extends { | |
| // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation | |
| // ? Augmentation[k]["_output"] | |
| // : k extends keyof Output | |
| // ? Output[k] | |
| // : never; | |
| // }, | |
| // NewInput extends { | |
| // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation | |
| // ? Augmentation[k]["_input"] | |
| // : k extends keyof Input | |
| // ? Input[k] | |
| // : never; | |
| // } | |
| // >( | |
| // merging: Incoming | |
| // ): ZodObject< | |
| // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>, | |
| // Incoming["_def"]["unknownKeys"], | |
| // Incoming["_def"]["catchall"], | |
| // NewOutput, | |
| // NewInput | |
| // > { | |
| // const merged: any = new ZodObject({ | |
| // unknownKeys: merging._def.unknownKeys, | |
| // catchall: merging._def.catchall, | |
| // shape: () => | |
| // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), | |
| // typeName: ZodFirstPartyTypeKind.ZodObject, | |
| // }) as any; | |
| // return merged; | |
| // } | |
| setKey(t, e) { | |
| return this.augment({ [t]: e }); | |
| } | |
| // merge<Incoming extends AnyZodObject>( | |
| // merging: Incoming | |
| // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => { | |
| // ZodObject< | |
| // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>, | |
| // Incoming["_def"]["unknownKeys"], | |
| // Incoming["_def"]["catchall"] | |
| // > { | |
| // // const mergedShape = objectUtil.mergeShapes( | |
| // // this._def.shape(), | |
| // // merging._def.shape() | |
| // // ); | |
| // const merged: any = new ZodObject({ | |
| // unknownKeys: merging._def.unknownKeys, | |
| // catchall: merging._def.catchall, | |
| // shape: () => | |
| // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), | |
| // typeName: ZodFirstPartyTypeKind.ZodObject, | |
| // }) as any; | |
| // return merged; | |
| // } | |
| catchall(t) { | |
| return new Dt({ | |
| ...this._def, | |
| catchall: t | |
| }); | |
| } | |
| pick(t) { | |
| const e = {}; | |
| return ct.objectKeys(t).forEach((s) => { | |
| t[s] && this.shape[s] && (e[s] = this.shape[s]); | |
| }), new Dt({ | |
| ...this._def, | |
| shape: () => e | |
| }); | |
| } | |
| omit(t) { | |
| const e = {}; | |
| return ct.objectKeys(this.shape).forEach((s) => { | |
| t[s] || (e[s] = this.shape[s]); | |
| }), new Dt({ | |
| ...this._def, | |
| shape: () => e | |
| }); | |
| } | |
| /** | |
| * @deprecated | |
| */ | |
| deepPartial() { | |
| return wa(this); | |
| } | |
| partial(t) { | |
| const e = {}; | |
| return ct.objectKeys(this.shape).forEach((s) => { | |
| const i = this.shape[s]; | |
| t && !t[s] ? e[s] = i : e[s] = i.optional(); | |
| }), new Dt({ | |
| ...this._def, | |
| shape: () => e | |
| }); | |
| } | |
| required(t) { | |
| const e = {}; | |
| return ct.objectKeys(this.shape).forEach((s) => { | |
| if (t && !t[s]) | |
| e[s] = this.shape[s]; | |
| else { | |
| let r = this.shape[s]; | |
| for (; r instanceof js; ) | |
| r = r._def.innerType; | |
| e[s] = r; | |
| } | |
| }), new Dt({ | |
| ...this._def, | |
| shape: () => e | |
| }); | |
| } | |
| keyof() { | |
| return Xm(ct.objectKeys(this.shape)); | |
| } | |
| } | |
| Dt.create = (n, t) => new Dt({ | |
| shape: () => n, | |
| unknownKeys: "strip", | |
| catchall: Yi.create(), | |
| typeName: R.ZodObject, | |
| ...J(t) | |
| }); | |
| Dt.strictCreate = (n, t) => new Dt({ | |
| shape: () => n, | |
| unknownKeys: "strict", | |
| catchall: Yi.create(), | |
| typeName: R.ZodObject, | |
| ...J(t) | |
| }); | |
| Dt.lazycreate = (n, t) => new Dt({ | |
| shape: n, | |
| unknownKeys: "strip", | |
| catchall: Yi.create(), | |
| typeName: R.ZodObject, | |
| ...J(t) | |
| }); | |
| class Bl extends nt { | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t), s = this._def.options; | |
| function i(r) { | |
| for (const l of r) | |
| if (l.result.status === "valid") | |
| return l.result; | |
| for (const l of r) | |
| if (l.result.status === "dirty") | |
| return e.common.issues.push(...l.ctx.common.issues), l.result; | |
| const a = r.map((l) => new rs(l.ctx.common.issues)); | |
| return O(e, { | |
| code: I.invalid_union, | |
| unionErrors: a | |
| }), W; | |
| } | |
| if (e.common.async) | |
| return Promise.all(s.map(async (r) => { | |
| const a = { | |
| ...e, | |
| common: { | |
| ...e.common, | |
| issues: [] | |
| }, | |
| parent: null | |
| }; | |
| return { | |
| result: await r._parseAsync({ | |
| data: e.data, | |
| path: e.path, | |
| parent: a | |
| }), | |
| ctx: a | |
| }; | |
| })).then(i); | |
| { | |
| let r; | |
| const a = []; | |
| for (const c of s) { | |
| const h = { | |
| ...e, | |
| common: { | |
| ...e.common, | |
| issues: [] | |
| }, | |
| parent: null | |
| }, u = c._parseSync({ | |
| data: e.data, | |
| path: e.path, | |
| parent: h | |
| }); | |
| if (u.status === "valid") | |
| return u; | |
| u.status === "dirty" && !r && (r = { result: u, ctx: h }), h.common.issues.length && a.push(h.common.issues); | |
| } | |
| if (r) | |
| return e.common.issues.push(...r.ctx.common.issues), r.result; | |
| const l = a.map((c) => new rs(c)); | |
| return O(e, { | |
| code: I.invalid_union, | |
| unionErrors: l | |
| }), W; | |
| } | |
| } | |
| get options() { | |
| return this._def.options; | |
| } | |
| } | |
| Bl.create = (n, t) => new Bl({ | |
| options: n, | |
| typeName: R.ZodUnion, | |
| ...J(t) | |
| }); | |
| const pi = (n) => n instanceof zl ? pi(n.schema) : n instanceof Bs ? pi(n.innerType()) : n instanceof Vl ? [n.value] : n instanceof $n ? n.options : n instanceof Gl ? ct.objectValues(n.enum) : n instanceof ql ? pi(n._def.innerType) : n instanceof $l ? [void 0] : n instanceof jl ? [null] : n instanceof js ? [void 0, ...pi(n.unwrap())] : n instanceof jn ? [null, ...pi(n.unwrap())] : n instanceof Ip || n instanceof Xl ? pi(n.unwrap()) : n instanceof Wl ? pi(n._def.innerType) : []; | |
| class gd extends nt { | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t); | |
| if (e.parsedType !== L.object) | |
| return O(e, { | |
| code: I.invalid_type, | |
| expected: L.object, | |
| received: e.parsedType | |
| }), W; | |
| const s = this.discriminator, i = e.data[s], r = this.optionsMap.get(i); | |
| return r ? e.common.async ? r._parseAsync({ | |
| data: e.data, | |
| path: e.path, | |
| parent: e | |
| }) : r._parseSync({ | |
| data: e.data, | |
| path: e.path, | |
| parent: e | |
| }) : (O(e, { | |
| code: I.invalid_union_discriminator, | |
| options: Array.from(this.optionsMap.keys()), | |
| path: [s] | |
| }), W); | |
| } | |
| get discriminator() { | |
| return this._def.discriminator; | |
| } | |
| get options() { | |
| return this._def.options; | |
| } | |
| get optionsMap() { | |
| return this._def.optionsMap; | |
| } | |
| /** | |
| * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. | |
| * However, it only allows a union of objects, all of which need to share a discriminator property. This property must | |
| * have a different value for each object in the union. | |
| * @param discriminator the name of the discriminator property | |
| * @param types an array of object schemas | |
| * @param params | |
| */ | |
| static create(t, e, s) { | |
| const i = /* @__PURE__ */ new Map(); | |
| for (const r of e) { | |
| const a = pi(r.shape[t]); | |
| if (!a.length) | |
| throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`); | |
| for (const l of a) { | |
| if (i.has(l)) | |
| throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`); | |
| i.set(l, r); | |
| } | |
| } | |
| return new gd({ | |
| typeName: R.ZodDiscriminatedUnion, | |
| discriminator: t, | |
| options: e, | |
| optionsMap: i, | |
| ...J(s) | |
| }); | |
| } | |
| } | |
| function sf(n, t) { | |
| const e = _i(n), s = _i(t); | |
| if (n === t) | |
| return { valid: !0, data: n }; | |
| if (e === L.object && s === L.object) { | |
| const i = ct.objectKeys(t), r = ct.objectKeys(n).filter((l) => i.indexOf(l) !== -1), a = { ...n, ...t }; | |
| for (const l of r) { | |
| const c = sf(n[l], t[l]); | |
| if (!c.valid) | |
| return { valid: !1 }; | |
| a[l] = c.data; | |
| } | |
| return { valid: !0, data: a }; | |
| } else if (e === L.array && s === L.array) { | |
| if (n.length !== t.length) | |
| return { valid: !1 }; | |
| const i = []; | |
| for (let r = 0; r < n.length; r++) { | |
| const a = n[r], l = t[r], c = sf(a, l); | |
| if (!c.valid) | |
| return { valid: !1 }; | |
| i.push(c.data); | |
| } | |
| return { valid: !0, data: i }; | |
| } else return e === L.date && s === L.date && +n == +t ? { valid: !0, data: n } : { valid: !1 }; | |
| } | |
| class Hl extends nt { | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t), i = (r, a) => { | |
| if (tf(r) || tf(a)) | |
| return W; | |
| const l = sf(r.value, a.value); | |
| return l.valid ? ((ef(r) || ef(a)) && e.dirty(), { status: e.value, value: l.data }) : (O(s, { | |
| code: I.invalid_intersection_types | |
| }), W); | |
| }; | |
| return s.common.async ? Promise.all([ | |
| this._def.left._parseAsync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }), | |
| this._def.right._parseAsync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }) | |
| ]).then(([r, a]) => i(r, a)) : i(this._def.left._parseSync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }), this._def.right._parseSync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| })); | |
| } | |
| } | |
| Hl.create = (n, t, e) => new Hl({ | |
| left: n, | |
| right: t, | |
| typeName: R.ZodIntersection, | |
| ...J(e) | |
| }); | |
| class di extends nt { | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t); | |
| if (s.parsedType !== L.array) | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.array, | |
| received: s.parsedType | |
| }), W; | |
| if (s.data.length < this._def.items.length) | |
| return O(s, { | |
| code: I.too_small, | |
| minimum: this._def.items.length, | |
| inclusive: !0, | |
| exact: !1, | |
| type: "array" | |
| }), W; | |
| !this._def.rest && s.data.length > this._def.items.length && (O(s, { | |
| code: I.too_big, | |
| maximum: this._def.items.length, | |
| inclusive: !0, | |
| exact: !1, | |
| type: "array" | |
| }), e.dirty()); | |
| const r = [...s.data].map((a, l) => { | |
| const c = this._def.items[l] || this._def.rest; | |
| return c ? c._parse(new ui(s, a, s.path, l)) : null; | |
| }).filter((a) => !!a); | |
| return s.common.async ? Promise.all(r).then((a) => Ee.mergeArray(e, a)) : Ee.mergeArray(e, r); | |
| } | |
| get items() { | |
| return this._def.items; | |
| } | |
| rest(t) { | |
| return new di({ | |
| ...this._def, | |
| rest: t | |
| }); | |
| } | |
| } | |
| di.create = (n, t) => { | |
| if (!Array.isArray(n)) | |
| throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); | |
| return new di({ | |
| items: n, | |
| typeName: R.ZodTuple, | |
| rest: null, | |
| ...J(t) | |
| }); | |
| }; | |
| class Ul extends nt { | |
| get keySchema() { | |
| return this._def.keyType; | |
| } | |
| get valueSchema() { | |
| return this._def.valueType; | |
| } | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t); | |
| if (s.parsedType !== L.object) | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.object, | |
| received: s.parsedType | |
| }), W; | |
| const i = [], r = this._def.keyType, a = this._def.valueType; | |
| for (const l in s.data) | |
| i.push({ | |
| key: r._parse(new ui(s, l, s.path, l)), | |
| value: a._parse(new ui(s, s.data[l], s.path, l)), | |
| alwaysSet: l in s.data | |
| }); | |
| return s.common.async ? Ee.mergeObjectAsync(e, i) : Ee.mergeObjectSync(e, i); | |
| } | |
| get element() { | |
| return this._def.valueType; | |
| } | |
| static create(t, e, s) { | |
| return e instanceof nt ? new Ul({ | |
| keyType: t, | |
| valueType: e, | |
| typeName: R.ZodRecord, | |
| ...J(s) | |
| }) : new Ul({ | |
| keyType: Ds.create(), | |
| valueType: t, | |
| typeName: R.ZodRecord, | |
| ...J(e) | |
| }); | |
| } | |
| } | |
| class Ru extends nt { | |
| get keySchema() { | |
| return this._def.keyType; | |
| } | |
| get valueSchema() { | |
| return this._def.valueType; | |
| } | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t); | |
| if (s.parsedType !== L.map) | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.map, | |
| received: s.parsedType | |
| }), W; | |
| const i = this._def.keyType, r = this._def.valueType, a = [...s.data.entries()].map(([l, c], h) => ({ | |
| key: i._parse(new ui(s, l, s.path, [h, "key"])), | |
| value: r._parse(new ui(s, c, s.path, [h, "value"])) | |
| })); | |
| if (s.common.async) { | |
| const l = /* @__PURE__ */ new Map(); | |
| return Promise.resolve().then(async () => { | |
| for (const c of a) { | |
| const h = await c.key, u = await c.value; | |
| if (h.status === "aborted" || u.status === "aborted") | |
| return W; | |
| (h.status === "dirty" || u.status === "dirty") && e.dirty(), l.set(h.value, u.value); | |
| } | |
| return { status: e.value, value: l }; | |
| }); | |
| } else { | |
| const l = /* @__PURE__ */ new Map(); | |
| for (const c of a) { | |
| const h = c.key, u = c.value; | |
| if (h.status === "aborted" || u.status === "aborted") | |
| return W; | |
| (h.status === "dirty" || u.status === "dirty") && e.dirty(), l.set(h.value, u.value); | |
| } | |
| return { status: e.value, value: l }; | |
| } | |
| } | |
| } | |
| Ru.create = (n, t, e) => new Ru({ | |
| valueType: t, | |
| keyType: n, | |
| typeName: R.ZodMap, | |
| ...J(e) | |
| }); | |
| class da extends nt { | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t); | |
| if (s.parsedType !== L.set) | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.set, | |
| received: s.parsedType | |
| }), W; | |
| const i = this._def; | |
| i.minSize !== null && s.data.size < i.minSize.value && (O(s, { | |
| code: I.too_small, | |
| minimum: i.minSize.value, | |
| type: "set", | |
| inclusive: !0, | |
| exact: !1, | |
| message: i.minSize.message | |
| }), e.dirty()), i.maxSize !== null && s.data.size > i.maxSize.value && (O(s, { | |
| code: I.too_big, | |
| maximum: i.maxSize.value, | |
| type: "set", | |
| inclusive: !0, | |
| exact: !1, | |
| message: i.maxSize.message | |
| }), e.dirty()); | |
| const r = this._def.valueType; | |
| function a(c) { | |
| const h = /* @__PURE__ */ new Set(); | |
| for (const u of c) { | |
| if (u.status === "aborted") | |
| return W; | |
| u.status === "dirty" && e.dirty(), h.add(u.value); | |
| } | |
| return { status: e.value, value: h }; | |
| } | |
| const l = [...s.data.values()].map((c, h) => r._parse(new ui(s, c, s.path, h))); | |
| return s.common.async ? Promise.all(l).then((c) => a(c)) : a(l); | |
| } | |
| min(t, e) { | |
| return new da({ | |
| ...this._def, | |
| minSize: { value: t, message: B.toString(e) } | |
| }); | |
| } | |
| max(t, e) { | |
| return new da({ | |
| ...this._def, | |
| maxSize: { value: t, message: B.toString(e) } | |
| }); | |
| } | |
| size(t, e) { | |
| return this.min(t, e).max(t, e); | |
| } | |
| nonempty(t) { | |
| return this.min(1, t); | |
| } | |
| } | |
| da.create = (n, t) => new da({ | |
| valueType: n, | |
| minSize: null, | |
| maxSize: null, | |
| typeName: R.ZodSet, | |
| ...J(t) | |
| }); | |
| class Na extends nt { | |
| constructor() { | |
| super(...arguments), this.validate = this.implement; | |
| } | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t); | |
| if (e.parsedType !== L.function) | |
| return O(e, { | |
| code: I.invalid_type, | |
| expected: L.function, | |
| received: e.parsedType | |
| }), W; | |
| function s(l, c) { | |
| return Tu({ | |
| data: l, | |
| path: e.path, | |
| errorMaps: [ | |
| e.common.contextualErrorMap, | |
| e.schemaErrorMap, | |
| xu(), | |
| Wo | |
| ].filter((h) => !!h), | |
| issueData: { | |
| code: I.invalid_arguments, | |
| argumentsError: c | |
| } | |
| }); | |
| } | |
| function i(l, c) { | |
| return Tu({ | |
| data: l, | |
| path: e.path, | |
| errorMaps: [ | |
| e.common.contextualErrorMap, | |
| e.schemaErrorMap, | |
| xu(), | |
| Wo | |
| ].filter((h) => !!h), | |
| issueData: { | |
| code: I.invalid_return_type, | |
| returnTypeError: c | |
| } | |
| }); | |
| } | |
| const r = { errorMap: e.common.contextualErrorMap }, a = e.data; | |
| if (this._def.returns instanceof Zo) { | |
| const l = this; | |
| return Le(async function(...c) { | |
| const h = new rs([]), u = await l._def.args.parseAsync(c, r).catch((g) => { | |
| throw h.addIssue(s(c, g)), h; | |
| }), d = await Reflect.apply(a, this, u); | |
| return await l._def.returns._def.type.parseAsync(d, r).catch((g) => { | |
| throw h.addIssue(i(d, g)), h; | |
| }); | |
| }); | |
| } else { | |
| const l = this; | |
| return Le(function(...c) { | |
| const h = l._def.args.safeParse(c, r); | |
| if (!h.success) | |
| throw new rs([s(c, h.error)]); | |
| const u = Reflect.apply(a, this, h.data), d = l._def.returns.safeParse(u, r); | |
| if (!d.success) | |
| throw new rs([i(u, d.error)]); | |
| return d.data; | |
| }); | |
| } | |
| } | |
| parameters() { | |
| return this._def.args; | |
| } | |
| returnType() { | |
| return this._def.returns; | |
| } | |
| args(...t) { | |
| return new Na({ | |
| ...this._def, | |
| args: di.create(t).rest(oa.create()) | |
| }); | |
| } | |
| returns(t) { | |
| return new Na({ | |
| ...this._def, | |
| returns: t | |
| }); | |
| } | |
| implement(t) { | |
| return this.parse(t); | |
| } | |
| strictImplement(t) { | |
| return this.parse(t); | |
| } | |
| static create(t, e, s) { | |
| return new Na({ | |
| args: t || di.create([]).rest(oa.create()), | |
| returns: e || oa.create(), | |
| typeName: R.ZodFunction, | |
| ...J(s) | |
| }); | |
| } | |
| } | |
| class zl extends nt { | |
| get schema() { | |
| return this._def.getter(); | |
| } | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t); | |
| return this._def.getter()._parse({ data: e.data, path: e.path, parent: e }); | |
| } | |
| } | |
| zl.create = (n, t) => new zl({ | |
| getter: n, | |
| typeName: R.ZodLazy, | |
| ...J(t) | |
| }); | |
| class Vl extends nt { | |
| _parse(t) { | |
| if (t.data !== this._def.value) { | |
| const e = this._getOrReturnCtx(t); | |
| return O(e, { | |
| received: e.data, | |
| code: I.invalid_literal, | |
| expected: this._def.value | |
| }), W; | |
| } | |
| return { status: "valid", value: t.data }; | |
| } | |
| get value() { | |
| return this._def.value; | |
| } | |
| } | |
| Vl.create = (n, t) => new Vl({ | |
| value: n, | |
| typeName: R.ZodLiteral, | |
| ...J(t) | |
| }); | |
| function Xm(n, t) { | |
| return new $n({ | |
| values: n, | |
| typeName: R.ZodEnum, | |
| ...J(t) | |
| }); | |
| } | |
| class $n extends nt { | |
| constructor() { | |
| super(...arguments), ll.set(this, void 0); | |
| } | |
| _parse(t) { | |
| if (typeof t.data != "string") { | |
| const e = this._getOrReturnCtx(t), s = this._def.values; | |
| return O(e, { | |
| expected: ct.joinValues(s), | |
| received: e.parsedType, | |
| code: I.invalid_type | |
| }), W; | |
| } | |
| if (Cu(this, ll) || Vm(this, ll, new Set(this._def.values)), !Cu(this, ll).has(t.data)) { | |
| const e = this._getOrReturnCtx(t), s = this._def.values; | |
| return O(e, { | |
| received: e.data, | |
| code: I.invalid_enum_value, | |
| options: s | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| get options() { | |
| return this._def.values; | |
| } | |
| get enum() { | |
| const t = {}; | |
| for (const e of this._def.values) | |
| t[e] = e; | |
| return t; | |
| } | |
| get Values() { | |
| const t = {}; | |
| for (const e of this._def.values) | |
| t[e] = e; | |
| return t; | |
| } | |
| get Enum() { | |
| const t = {}; | |
| for (const e of this._def.values) | |
| t[e] = e; | |
| return t; | |
| } | |
| extract(t, e = this._def) { | |
| return $n.create(t, { | |
| ...this._def, | |
| ...e | |
| }); | |
| } | |
| exclude(t, e = this._def) { | |
| return $n.create(this.options.filter((s) => !t.includes(s)), { | |
| ...this._def, | |
| ...e | |
| }); | |
| } | |
| } | |
| ll = /* @__PURE__ */ new WeakMap(); | |
| $n.create = Xm; | |
| class Gl extends nt { | |
| constructor() { | |
| super(...arguments), cl.set(this, void 0); | |
| } | |
| _parse(t) { | |
| const e = ct.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(t); | |
| if (s.parsedType !== L.string && s.parsedType !== L.number) { | |
| const i = ct.objectValues(e); | |
| return O(s, { | |
| expected: ct.joinValues(i), | |
| received: s.parsedType, | |
| code: I.invalid_type | |
| }), W; | |
| } | |
| if (Cu(this, cl) || Vm(this, cl, new Set(ct.getValidEnumValues(this._def.values))), !Cu(this, cl).has(t.data)) { | |
| const i = ct.objectValues(e); | |
| return O(s, { | |
| received: s.data, | |
| code: I.invalid_enum_value, | |
| options: i | |
| }), W; | |
| } | |
| return Le(t.data); | |
| } | |
| get enum() { | |
| return this._def.values; | |
| } | |
| } | |
| cl = /* @__PURE__ */ new WeakMap(); | |
| Gl.create = (n, t) => new Gl({ | |
| values: n, | |
| typeName: R.ZodNativeEnum, | |
| ...J(t) | |
| }); | |
| class Zo extends nt { | |
| unwrap() { | |
| return this._def.type; | |
| } | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t); | |
| if (e.parsedType !== L.promise && e.common.async === !1) | |
| return O(e, { | |
| code: I.invalid_type, | |
| expected: L.promise, | |
| received: e.parsedType | |
| }), W; | |
| const s = e.parsedType === L.promise ? e.data : Promise.resolve(e.data); | |
| return Le(s.then((i) => this._def.type.parseAsync(i, { | |
| path: e.path, | |
| errorMap: e.common.contextualErrorMap | |
| }))); | |
| } | |
| } | |
| Zo.create = (n, t) => new Zo({ | |
| type: n, | |
| typeName: R.ZodPromise, | |
| ...J(t) | |
| }); | |
| class Bs extends nt { | |
| innerType() { | |
| return this._def.schema; | |
| } | |
| sourceType() { | |
| return this._def.schema._def.typeName === R.ZodEffects ? this._def.schema.sourceType() : this._def.schema; | |
| } | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t), i = this._def.effect || null, r = { | |
| addIssue: (a) => { | |
| O(s, a), a.fatal ? e.abort() : e.dirty(); | |
| }, | |
| get path() { | |
| return s.path; | |
| } | |
| }; | |
| if (r.addIssue = r.addIssue.bind(r), i.type === "preprocess") { | |
| const a = i.transform(s.data, r); | |
| if (s.common.async) | |
| return Promise.resolve(a).then(async (l) => { | |
| if (e.value === "aborted") | |
| return W; | |
| const c = await this._def.schema._parseAsync({ | |
| data: l, | |
| path: s.path, | |
| parent: s | |
| }); | |
| return c.status === "aborted" ? W : c.status === "dirty" || e.value === "dirty" ? Ra(c.value) : c; | |
| }); | |
| { | |
| if (e.value === "aborted") | |
| return W; | |
| const l = this._def.schema._parseSync({ | |
| data: a, | |
| path: s.path, | |
| parent: s | |
| }); | |
| return l.status === "aborted" ? W : l.status === "dirty" || e.value === "dirty" ? Ra(l.value) : l; | |
| } | |
| } | |
| if (i.type === "refinement") { | |
| const a = (l) => { | |
| const c = i.refinement(l, r); | |
| if (s.common.async) | |
| return Promise.resolve(c); | |
| if (c instanceof Promise) | |
| throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); | |
| return l; | |
| }; | |
| if (s.common.async === !1) { | |
| const l = this._def.schema._parseSync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }); | |
| return l.status === "aborted" ? W : (l.status === "dirty" && e.dirty(), a(l.value), { status: e.value, value: l.value }); | |
| } else | |
| return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((l) => l.status === "aborted" ? W : (l.status === "dirty" && e.dirty(), a(l.value).then(() => ({ status: e.value, value: l.value })))); | |
| } | |
| if (i.type === "transform") | |
| if (s.common.async === !1) { | |
| const a = this._def.schema._parseSync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }); | |
| if (!ha(a)) | |
| return a; | |
| const l = i.transform(a.value, r); | |
| if (l instanceof Promise) | |
| throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead."); | |
| return { status: e.value, value: l }; | |
| } else | |
| return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((a) => ha(a) ? Promise.resolve(i.transform(a.value, r)).then((l) => ({ status: e.value, value: l })) : a); | |
| ct.assertNever(i); | |
| } | |
| } | |
| Bs.create = (n, t, e) => new Bs({ | |
| schema: n, | |
| typeName: R.ZodEffects, | |
| effect: t, | |
| ...J(e) | |
| }); | |
| Bs.createWithPreprocess = (n, t, e) => new Bs({ | |
| schema: t, | |
| effect: { type: "preprocess", transform: n }, | |
| typeName: R.ZodEffects, | |
| ...J(e) | |
| }); | |
| class js extends nt { | |
| _parse(t) { | |
| return this._getType(t) === L.undefined ? Le(void 0) : this._def.innerType._parse(t); | |
| } | |
| unwrap() { | |
| return this._def.innerType; | |
| } | |
| } | |
| js.create = (n, t) => new js({ | |
| innerType: n, | |
| typeName: R.ZodOptional, | |
| ...J(t) | |
| }); | |
| class jn extends nt { | |
| _parse(t) { | |
| return this._getType(t) === L.null ? Le(null) : this._def.innerType._parse(t); | |
| } | |
| unwrap() { | |
| return this._def.innerType; | |
| } | |
| } | |
| jn.create = (n, t) => new jn({ | |
| innerType: n, | |
| typeName: R.ZodNullable, | |
| ...J(t) | |
| }); | |
| class ql extends nt { | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t); | |
| let s = e.data; | |
| return e.parsedType === L.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({ | |
| data: s, | |
| path: e.path, | |
| parent: e | |
| }); | |
| } | |
| removeDefault() { | |
| return this._def.innerType; | |
| } | |
| } | |
| ql.create = (n, t) => new ql({ | |
| innerType: n, | |
| typeName: R.ZodDefault, | |
| defaultValue: typeof t.default == "function" ? t.default : () => t.default, | |
| ...J(t) | |
| }); | |
| class Wl extends nt { | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t), s = { | |
| ...e, | |
| common: { | |
| ...e.common, | |
| issues: [] | |
| } | |
| }, i = this._def.innerType._parse({ | |
| data: s.data, | |
| path: s.path, | |
| parent: { | |
| ...s | |
| } | |
| }); | |
| return Dl(i) ? i.then((r) => ({ | |
| status: "valid", | |
| value: r.status === "valid" ? r.value : this._def.catchValue({ | |
| get error() { | |
| return new rs(s.common.issues); | |
| }, | |
| input: s.data | |
| }) | |
| })) : { | |
| status: "valid", | |
| value: i.status === "valid" ? i.value : this._def.catchValue({ | |
| get error() { | |
| return new rs(s.common.issues); | |
| }, | |
| input: s.data | |
| }) | |
| }; | |
| } | |
| removeCatch() { | |
| return this._def.innerType; | |
| } | |
| } | |
| Wl.create = (n, t) => new Wl({ | |
| innerType: n, | |
| typeName: R.ZodCatch, | |
| catchValue: typeof t.catch == "function" ? t.catch : () => t.catch, | |
| ...J(t) | |
| }); | |
| class Pu extends nt { | |
| _parse(t) { | |
| if (this._getType(t) !== L.nan) { | |
| const s = this._getOrReturnCtx(t); | |
| return O(s, { | |
| code: I.invalid_type, | |
| expected: L.nan, | |
| received: s.parsedType | |
| }), W; | |
| } | |
| return { status: "valid", value: t.data }; | |
| } | |
| } | |
| Pu.create = (n) => new Pu({ | |
| typeName: R.ZodNaN, | |
| ...J(n) | |
| }); | |
| const TA = Symbol("zod_brand"); | |
| class Ip extends nt { | |
| _parse(t) { | |
| const { ctx: e } = this._processInputParams(t), s = e.data; | |
| return this._def.type._parse({ | |
| data: s, | |
| path: e.path, | |
| parent: e | |
| }); | |
| } | |
| unwrap() { | |
| return this._def.type; | |
| } | |
| } | |
| class Mh extends nt { | |
| _parse(t) { | |
| const { status: e, ctx: s } = this._processInputParams(t); | |
| if (s.common.async) | |
| return (async () => { | |
| const r = await this._def.in._parseAsync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }); | |
| return r.status === "aborted" ? W : r.status === "dirty" ? (e.dirty(), Ra(r.value)) : this._def.out._parseAsync({ | |
| data: r.value, | |
| path: s.path, | |
| parent: s | |
| }); | |
| })(); | |
| { | |
| const i = this._def.in._parseSync({ | |
| data: s.data, | |
| path: s.path, | |
| parent: s | |
| }); | |
| return i.status === "aborted" ? W : i.status === "dirty" ? (e.dirty(), { | |
| status: "dirty", | |
| value: i.value | |
| }) : this._def.out._parseSync({ | |
| data: i.value, | |
| path: s.path, | |
| parent: s | |
| }); | |
| } | |
| } | |
| static create(t, e) { | |
| return new Mh({ | |
| in: t, | |
| out: e, | |
| typeName: R.ZodPipeline | |
| }); | |
| } | |
| } | |
| class Xl extends nt { | |
| _parse(t) { | |
| const e = this._def.innerType._parse(t), s = (i) => (ha(i) && (i.value = Object.freeze(i.value)), i); | |
| return Dl(e) ? e.then((i) => s(i)) : s(e); | |
| } | |
| unwrap() { | |
| return this._def.innerType; | |
| } | |
| } | |
| Xl.create = (n, t) => new Xl({ | |
| innerType: n, | |
| typeName: R.ZodReadonly, | |
| ...J(t) | |
| }); | |
| function _g(n, t) { | |
| const e = typeof n == "function" ? n(t) : typeof n == "string" ? { message: n } : n; | |
| return typeof e == "string" ? { message: e } : e; | |
| } | |
| function Zm(n, t = {}, e) { | |
| return n ? Xo.create().superRefine((s, i) => { | |
| var r, a; | |
| const l = n(s); | |
| if (l instanceof Promise) | |
| return l.then((c) => { | |
| var h, u; | |
| if (!c) { | |
| const d = _g(t, s), f = (u = (h = d.fatal) !== null && h !== void 0 ? h : e) !== null && u !== void 0 ? u : !0; | |
| i.addIssue({ code: "custom", ...d, fatal: f }); | |
| } | |
| }); | |
| if (!l) { | |
| const c = _g(t, s), h = (a = (r = c.fatal) !== null && r !== void 0 ? r : e) !== null && a !== void 0 ? a : !0; | |
| i.addIssue({ code: "custom", ...c, fatal: h }); | |
| } | |
| }) : Xo.create(); | |
| } | |
| const CA = { | |
| object: Dt.lazycreate | |
| }; | |
| var R; | |
| (function(n) { | |
| n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly"; | |
| })(R || (R = {})); | |
| const kA = (n, t = { | |
| message: `Input not instance of ${n.name}` | |
| }) => Zm((e) => e instanceof n, t), Ym = Ds.create, Km = Dn.create, IA = Pu.create, RA = Fn.create, Jm = Fl.create, PA = ua.create, MA = ku.create, NA = $l.create, OA = jl.create, LA = Xo.create, DA = oa.create, FA = Yi.create, $A = Iu.create, jA = $s.create, BA = Dt.create, HA = Dt.strictCreate, UA = Bl.create, zA = gd.create, VA = Hl.create, GA = di.create, qA = Ul.create, WA = Ru.create, XA = da.create, ZA = Na.create, YA = zl.create, KA = Vl.create, JA = $n.create, QA = Gl.create, tw = Zo.create, Ag = Bs.create, ew = js.create, sw = jn.create, iw = Bs.createWithPreprocess, nw = Mh.create, rw = () => Ym().optional(), aw = () => Km().optional(), ow = () => Jm().optional(), lw = { | |
| string: (n) => Ds.create({ ...n, coerce: !0 }), | |
| number: (n) => Dn.create({ ...n, coerce: !0 }), | |
| boolean: (n) => Fl.create({ | |
| ...n, | |
| coerce: !0 | |
| }), | |
| bigint: (n) => Fn.create({ ...n, coerce: !0 }), | |
| date: (n) => ua.create({ ...n, coerce: !0 }) | |
| }, cw = W; | |
| var w = /* @__PURE__ */ Object.freeze({ | |
| __proto__: null, | |
| defaultErrorMap: Wo, | |
| setErrorMap: iA, | |
| getErrorMap: xu, | |
| makeIssue: Tu, | |
| EMPTY_PATH: nA, | |
| addIssueToContext: O, | |
| ParseStatus: Ee, | |
| INVALID: W, | |
| DIRTY: Ra, | |
| OK: Le, | |
| isAborted: tf, | |
| isDirty: ef, | |
| isValid: ha, | |
| isAsync: Dl, | |
| get util() { | |
| return ct; | |
| }, | |
| get objectUtil() { | |
| return Qd; | |
| }, | |
| ZodParsedType: L, | |
| getParsedType: _i, | |
| ZodType: nt, | |
| datetimeRegex: Wm, | |
| ZodString: Ds, | |
| ZodNumber: Dn, | |
| ZodBigInt: Fn, | |
| ZodBoolean: Fl, | |
| ZodDate: ua, | |
| ZodSymbol: ku, | |
| ZodUndefined: $l, | |
| ZodNull: jl, | |
| ZodAny: Xo, | |
| ZodUnknown: oa, | |
| ZodNever: Yi, | |
| ZodVoid: Iu, | |
| ZodArray: $s, | |
| ZodObject: Dt, | |
| ZodUnion: Bl, | |
| ZodDiscriminatedUnion: gd, | |
| ZodIntersection: Hl, | |
| ZodTuple: di, | |
| ZodRecord: Ul, | |
| ZodMap: Ru, | |
| ZodSet: da, | |
| ZodFunction: Na, | |
| ZodLazy: zl, | |
| ZodLiteral: Vl, | |
| ZodEnum: $n, | |
| ZodNativeEnum: Gl, | |
| ZodPromise: Zo, | |
| ZodEffects: Bs, | |
| ZodTransformer: Bs, | |
| ZodOptional: js, | |
| ZodNullable: jn, | |
| ZodDefault: ql, | |
| ZodCatch: Wl, | |
| ZodNaN: Pu, | |
| BRAND: TA, | |
| ZodBranded: Ip, | |
| ZodPipeline: Mh, | |
| ZodReadonly: Xl, | |
| custom: Zm, | |
| Schema: nt, | |
| ZodSchema: nt, | |
| late: CA, | |
| get ZodFirstPartyTypeKind() { | |
| return R; | |
| }, | |
| coerce: lw, | |
| any: LA, | |
| array: jA, | |
| bigint: RA, | |
| boolean: Jm, | |
| date: PA, | |
| discriminatedUnion: zA, | |
| effect: Ag, | |
| enum: JA, | |
| function: ZA, | |
| instanceof: kA, | |
| intersection: VA, | |
| lazy: YA, | |
| literal: KA, | |
| map: WA, | |
| nan: IA, | |
| nativeEnum: QA, | |
| never: FA, | |
| null: OA, | |
| nullable: sw, | |
| number: Km, | |
| object: BA, | |
| oboolean: ow, | |
| onumber: aw, | |
| optional: ew, | |
| ostring: rw, | |
| pipeline: nw, | |
| preprocess: iw, | |
| promise: tw, | |
| record: qA, | |
| set: XA, | |
| strictObject: HA, | |
| string: Ym, | |
| symbol: MA, | |
| transformer: Ag, | |
| tuple: GA, | |
| undefined: NA, | |
| union: UA, | |
| unknown: DA, | |
| void: $A, | |
| NEVER: cw, | |
| ZodIssueCode: I, | |
| quotelessJson: sA, | |
| ZodError: rs | |
| }); | |
| function hw() { | |
| return {}; | |
| } | |
| function uw(n, t) { | |
| var s, i, r; | |
| const e = { | |
| type: "array" | |
| }; | |
| return (s = n.type) != null && s._def && ((r = (i = n.type) == null ? void 0 : i._def) == null ? void 0 : r.typeName) !== R.ZodAny && (e.items = ft(n.type._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "items"] | |
| })), n.minLength && _t(e, "minItems", n.minLength.value, n.minLength.message, t), n.maxLength && _t(e, "maxItems", n.maxLength.value, n.maxLength.message, t), n.exactLength && (_t(e, "minItems", n.exactLength.value, n.exactLength.message, t), _t(e, "maxItems", n.exactLength.value, n.exactLength.message, t)), e; | |
| } | |
| function dw(n, t) { | |
| const e = { | |
| type: "integer", | |
| format: "int64" | |
| }; | |
| if (!n.checks) | |
| return e; | |
| for (const s of n.checks) | |
| switch (s.kind) { | |
| case "min": | |
| t.target === "jsonSchema7" ? s.inclusive ? _t(e, "minimum", s.value, s.message, t) : _t(e, "exclusiveMinimum", s.value, s.message, t) : (s.inclusive || (e.exclusiveMinimum = !0), _t(e, "minimum", s.value, s.message, t)); | |
| break; | |
| case "max": | |
| t.target === "jsonSchema7" ? s.inclusive ? _t(e, "maximum", s.value, s.message, t) : _t(e, "exclusiveMaximum", s.value, s.message, t) : (s.inclusive || (e.exclusiveMaximum = !0), _t(e, "maximum", s.value, s.message, t)); | |
| break; | |
| case "multipleOf": | |
| _t(e, "multipleOf", s.value, s.message, t); | |
| break; | |
| } | |
| return e; | |
| } | |
| function fw() { | |
| return { | |
| type: "boolean" | |
| }; | |
| } | |
| function Qm(n, t) { | |
| return ft(n.type._def, t); | |
| } | |
| const pw = (n, t) => ft(n.innerType._def, t); | |
| function ty(n, t, e) { | |
| const s = e ?? t.dateStrategy; | |
| if (Array.isArray(s)) | |
| return { | |
| anyOf: s.map((i, r) => ty(n, t, i)) | |
| }; | |
| switch (s) { | |
| case "string": | |
| case "format:date-time": | |
| return { | |
| type: "string", | |
| format: "date-time" | |
| }; | |
| case "format:date": | |
| return { | |
| type: "string", | |
| format: "date" | |
| }; | |
| case "integer": | |
| return gw(n, t); | |
| } | |
| } | |
| const gw = (n, t) => { | |
| const e = { | |
| type: "integer", | |
| format: "unix-time" | |
| }; | |
| if (t.target === "openApi3") | |
| return e; | |
| for (const s of n.checks) | |
| switch (s.kind) { | |
| case "min": | |
| _t( | |
| e, | |
| "minimum", | |
| s.value, | |
| // This is in milliseconds | |
| s.message, | |
| t | |
| ); | |
| break; | |
| case "max": | |
| _t( | |
| e, | |
| "maximum", | |
| s.value, | |
| // This is in milliseconds | |
| s.message, | |
| t | |
| ); | |
| break; | |
| } | |
| return e; | |
| }; | |
| function mw(n, t) { | |
| return { | |
| ...ft(n.innerType._def, t), | |
| default: n.defaultValue() | |
| }; | |
| } | |
| function yw(n, t) { | |
| return t.effectStrategy === "input" ? ft(n.schema._def, t) : {}; | |
| } | |
| function bw(n) { | |
| return { | |
| type: "string", | |
| enum: Array.from(n.values) | |
| }; | |
| } | |
| const vw = (n) => "type" in n && n.type === "string" ? !1 : "allOf" in n; | |
| function _w(n, t) { | |
| const e = [ | |
| ft(n.left._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "allOf", "0"] | |
| }), | |
| ft(n.right._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "allOf", "1"] | |
| }) | |
| ].filter((r) => !!r); | |
| let s = t.target === "jsonSchema2019-09" ? { unevaluatedProperties: !1 } : void 0; | |
| const i = []; | |
| return e.forEach((r) => { | |
| if (vw(r)) | |
| i.push(...r.allOf), r.unevaluatedProperties === void 0 && (s = void 0); | |
| else { | |
| let a = r; | |
| if ("additionalProperties" in r && r.additionalProperties === !1) { | |
| const { additionalProperties: l, ...c } = r; | |
| a = c; | |
| } else | |
| s = void 0; | |
| i.push(a); | |
| } | |
| }), i.length ? { | |
| allOf: i, | |
| ...s | |
| } : void 0; | |
| } | |
| function Aw(n, t) { | |
| const e = typeof n.value; | |
| return e !== "bigint" && e !== "number" && e !== "boolean" && e !== "string" ? { | |
| type: Array.isArray(n.value) ? "array" : "object" | |
| } : t.target === "openApi3" ? { | |
| type: e === "bigint" ? "integer" : e, | |
| enum: [n.value] | |
| } : { | |
| type: e === "bigint" ? "integer" : e, | |
| const: n.value | |
| }; | |
| } | |
| let Od; | |
| const _s = { | |
| /** | |
| * `c` was changed to `[cC]` to replicate /i flag | |
| */ | |
| cuid: /^[cC][^\s-]{8,}$/, | |
| cuid2: /^[0-9a-z]+$/, | |
| ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/, | |
| /** | |
| * `a-z` was added to replicate /i flag | |
| */ | |
| email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/, | |
| /** | |
| * Constructed a valid Unicode RegExp | |
| * | |
| * Lazily instantiate since this type of regex isn't supported | |
| * in all envs (e.g. React Native). | |
| * | |
| * See: | |
| * https://github.com/colinhacks/zod/issues/2433 | |
| * Fix in Zod: | |
| * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b | |
| */ | |
| emoji: () => (Od === void 0 && (Od = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), Od), | |
| /** | |
| * Unused | |
| */ | |
| uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/, | |
| /** | |
| * Unused | |
| */ | |
| ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, | |
| ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, | |
| /** | |
| * Unused | |
| */ | |
| ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, | |
| ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, | |
| base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, | |
| base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, | |
| nanoid: /^[a-zA-Z0-9_-]{21}$/, | |
| jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/ | |
| }; | |
| function ey(n, t) { | |
| const e = { | |
| type: "string" | |
| }; | |
| if (n.checks) | |
| for (const s of n.checks) | |
| switch (s.kind) { | |
| case "min": | |
| _t(e, "minLength", typeof e.minLength == "number" ? Math.max(e.minLength, s.value) : s.value, s.message, t); | |
| break; | |
| case "max": | |
| _t(e, "maxLength", typeof e.maxLength == "number" ? Math.min(e.maxLength, s.value) : s.value, s.message, t); | |
| break; | |
| case "email": | |
| switch (t.emailStrategy) { | |
| case "format:email": | |
| As(e, "email", s.message, t); | |
| break; | |
| case "format:idn-email": | |
| As(e, "idn-email", s.message, t); | |
| break; | |
| case "pattern:zod": | |
| Te(e, _s.email, s.message, t); | |
| break; | |
| } | |
| break; | |
| case "url": | |
| As(e, "uri", s.message, t); | |
| break; | |
| case "uuid": | |
| As(e, "uuid", s.message, t); | |
| break; | |
| case "regex": | |
| Te(e, s.regex, s.message, t); | |
| break; | |
| case "cuid": | |
| Te(e, _s.cuid, s.message, t); | |
| break; | |
| case "cuid2": | |
| Te(e, _s.cuid2, s.message, t); | |
| break; | |
| case "startsWith": | |
| Te(e, RegExp(`^${Ld(s.value, t)}`), s.message, t); | |
| break; | |
| case "endsWith": | |
| Te(e, RegExp(`${Ld(s.value, t)}$`), s.message, t); | |
| break; | |
| case "datetime": | |
| As(e, "date-time", s.message, t); | |
| break; | |
| case "date": | |
| As(e, "date", s.message, t); | |
| break; | |
| case "time": | |
| As(e, "time", s.message, t); | |
| break; | |
| case "duration": | |
| As(e, "duration", s.message, t); | |
| break; | |
| case "length": | |
| _t(e, "minLength", typeof e.minLength == "number" ? Math.max(e.minLength, s.value) : s.value, s.message, t), _t(e, "maxLength", typeof e.maxLength == "number" ? Math.min(e.maxLength, s.value) : s.value, s.message, t); | |
| break; | |
| case "includes": { | |
| Te(e, RegExp(Ld(s.value, t)), s.message, t); | |
| break; | |
| } | |
| case "ip": { | |
| s.version !== "v6" && As(e, "ipv4", s.message, t), s.version !== "v4" && As(e, "ipv6", s.message, t); | |
| break; | |
| } | |
| case "base64url": | |
| Te(e, _s.base64url, s.message, t); | |
| break; | |
| case "jwt": | |
| Te(e, _s.jwt, s.message, t); | |
| break; | |
| case "cidr": { | |
| s.version !== "v6" && Te(e, _s.ipv4Cidr, s.message, t), s.version !== "v4" && Te(e, _s.ipv6Cidr, s.message, t); | |
| break; | |
| } | |
| case "emoji": | |
| Te(e, _s.emoji(), s.message, t); | |
| break; | |
| case "ulid": { | |
| Te(e, _s.ulid, s.message, t); | |
| break; | |
| } | |
| case "base64": { | |
| switch (t.base64Strategy) { | |
| case "format:binary": { | |
| As(e, "binary", s.message, t); | |
| break; | |
| } | |
| case "contentEncoding:base64": { | |
| _t(e, "contentEncoding", "base64", s.message, t); | |
| break; | |
| } | |
| case "pattern:zod": { | |
| Te(e, _s.base64, s.message, t); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "nanoid": | |
| Te(e, _s.nanoid, s.message, t); | |
| } | |
| return e; | |
| } | |
| function Ld(n, t) { | |
| return t.patternStrategy === "escape" ? Sw(n) : n; | |
| } | |
| const ww = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"); | |
| function Sw(n) { | |
| let t = ""; | |
| for (let e = 0; e < n.length; e++) | |
| ww.has(n[e]) || (t += "\\"), t += n[e]; | |
| return t; | |
| } | |
| function As(n, t, e, s) { | |
| var i; | |
| n.format || (i = n.anyOf) != null && i.some((r) => r.format) ? (n.anyOf || (n.anyOf = []), n.format && (n.anyOf.push({ | |
| format: n.format, | |
| ...n.errorMessage && s.errorMessages && { | |
| errorMessage: { format: n.errorMessage.format } | |
| } | |
| }), delete n.format, n.errorMessage && (delete n.errorMessage.format, Object.keys(n.errorMessage).length === 0 && delete n.errorMessage)), n.anyOf.push({ | |
| format: t, | |
| ...e && s.errorMessages && { errorMessage: { format: e } } | |
| })) : _t(n, "format", t, e, s); | |
| } | |
| function Te(n, t, e, s) { | |
| var i; | |
| n.pattern || (i = n.allOf) != null && i.some((r) => r.pattern) ? (n.allOf || (n.allOf = []), n.pattern && (n.allOf.push({ | |
| pattern: n.pattern, | |
| ...n.errorMessage && s.errorMessages && { | |
| errorMessage: { pattern: n.errorMessage.pattern } | |
| } | |
| }), delete n.pattern, n.errorMessage && (delete n.errorMessage.pattern, Object.keys(n.errorMessage).length === 0 && delete n.errorMessage)), n.allOf.push({ | |
| pattern: wg(t, s), | |
| ...e && s.errorMessages && { errorMessage: { pattern: e } } | |
| })) : _t(n, "pattern", wg(t, s), e, s); | |
| } | |
| function wg(n, t) { | |
| var c; | |
| if (!t.applyRegexFlags || !n.flags) | |
| return n.source; | |
| const e = { | |
| i: n.flags.includes("i"), | |
| m: n.flags.includes("m"), | |
| s: n.flags.includes("s") | |
| // `.` matches newlines | |
| }, s = e.i ? n.source.toLowerCase() : n.source; | |
| let i = "", r = !1, a = !1, l = !1; | |
| for (let h = 0; h < s.length; h++) { | |
| if (r) { | |
| i += s[h], r = !1; | |
| continue; | |
| } | |
| if (e.i) { | |
| if (a) { | |
| if (s[h].match(/[a-z]/)) { | |
| l ? (i += s[h], i += `${s[h - 2]}-${s[h]}`.toUpperCase(), l = !1) : s[h + 1] === "-" && ((c = s[h + 2]) != null && c.match(/[a-z]/)) ? (i += s[h], l = !0) : i += `${s[h]}${s[h].toUpperCase()}`; | |
| continue; | |
| } | |
| } else if (s[h].match(/[a-z]/)) { | |
| i += `[${s[h]}${s[h].toUpperCase()}]`; | |
| continue; | |
| } | |
| } | |
| if (e.m) { | |
| if (s[h] === "^") { | |
| i += `(^|(?<=[\r | |
| ]))`; | |
| continue; | |
| } else if (s[h] === "$") { | |
| i += `($|(?=[\r | |
| ]))`; | |
| continue; | |
| } | |
| } | |
| if (e.s && s[h] === ".") { | |
| i += a ? `${s[h]}\r | |
| ` : `[${s[h]}\r | |
| ]`; | |
| continue; | |
| } | |
| i += s[h], s[h] === "\\" ? r = !0 : a && s[h] === "]" ? a = !1 : !a && s[h] === "[" && (a = !0); | |
| } | |
| try { | |
| new RegExp(i); | |
| } catch { | |
| return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`), n.source; | |
| } | |
| return i; | |
| } | |
| function sy(n, t) { | |
| var s, i, r, a, l, c; | |
| if (t.target === "openAi" && console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."), t.target === "openApi3" && ((s = n.keyType) == null ? void 0 : s._def.typeName) === R.ZodEnum) | |
| return { | |
| type: "object", | |
| required: n.keyType._def.values, | |
| properties: n.keyType._def.values.reduce((h, u) => ({ | |
| ...h, | |
| [u]: ft(n.valueType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "properties", u] | |
| }) ?? {} | |
| }), {}), | |
| additionalProperties: !1 | |
| }; | |
| const e = { | |
| type: "object", | |
| additionalProperties: ft(n.valueType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "additionalProperties"] | |
| }) ?? {} | |
| }; | |
| if (t.target === "openApi3") | |
| return e; | |
| if (((i = n.keyType) == null ? void 0 : i._def.typeName) === R.ZodString && ((r = n.keyType._def.checks) != null && r.length)) { | |
| const { type: h, ...u } = ey(n.keyType._def, t); | |
| return { | |
| ...e, | |
| propertyNames: u | |
| }; | |
| } else { | |
| if (((a = n.keyType) == null ? void 0 : a._def.typeName) === R.ZodEnum) | |
| return { | |
| ...e, | |
| propertyNames: { | |
| enum: n.keyType._def.values | |
| } | |
| }; | |
| if (((l = n.keyType) == null ? void 0 : l._def.typeName) === R.ZodBranded && n.keyType._def.type._def.typeName === R.ZodString && ((c = n.keyType._def.type._def.checks) != null && c.length)) { | |
| const { type: h, ...u } = Qm(n.keyType._def, t); | |
| return { | |
| ...e, | |
| propertyNames: u | |
| }; | |
| } | |
| } | |
| return e; | |
| } | |
| function Ew(n, t) { | |
| if (t.mapStrategy === "record") | |
| return sy(n, t); | |
| const e = ft(n.keyType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "items", "items", "0"] | |
| }) || {}, s = ft(n.valueType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "items", "items", "1"] | |
| }) || {}; | |
| return { | |
| type: "array", | |
| maxItems: 125, | |
| items: { | |
| type: "array", | |
| items: [e, s], | |
| minItems: 2, | |
| maxItems: 2 | |
| } | |
| }; | |
| } | |
| function xw(n) { | |
| const t = n.values, s = Object.keys(n.values).filter((r) => typeof t[t[r]] != "number").map((r) => t[r]), i = Array.from(new Set(s.map((r) => typeof r))); | |
| return { | |
| type: i.length === 1 ? i[0] === "string" ? "string" : "number" : ["string", "number"], | |
| enum: s | |
| }; | |
| } | |
| function Tw() { | |
| return { | |
| not: {} | |
| }; | |
| } | |
| function Cw(n) { | |
| return n.target === "openApi3" ? { | |
| enum: ["null"], | |
| nullable: !0 | |
| } : { | |
| type: "null" | |
| }; | |
| } | |
| const Mu = { | |
| ZodString: "string", | |
| ZodNumber: "number", | |
| ZodBigInt: "integer", | |
| ZodBoolean: "boolean", | |
| ZodNull: "null" | |
| }; | |
| function kw(n, t) { | |
| if (t.target === "openApi3") | |
| return Sg(n, t); | |
| const e = n.options instanceof Map ? Array.from(n.options.values()) : n.options; | |
| if (e.every((s) => s._def.typeName in Mu && (!s._def.checks || !s._def.checks.length))) { | |
| const s = e.reduce((i, r) => { | |
| const a = Mu[r._def.typeName]; | |
| return a && !i.includes(a) ? [...i, a] : i; | |
| }, []); | |
| return { | |
| type: s.length > 1 ? s : s[0] | |
| }; | |
| } else if (e.every((s) => s._def.typeName === "ZodLiteral" && !s.description)) { | |
| const s = e.reduce((i, r) => { | |
| const a = typeof r._def.value; | |
| switch (a) { | |
| case "string": | |
| case "number": | |
| case "boolean": | |
| return [...i, a]; | |
| case "bigint": | |
| return [...i, "integer"]; | |
| case "object": | |
| if (r._def.value === null) | |
| return [...i, "null"]; | |
| case "symbol": | |
| case "undefined": | |
| case "function": | |
| default: | |
| return i; | |
| } | |
| }, []); | |
| if (s.length === e.length) { | |
| const i = s.filter((r, a, l) => l.indexOf(r) === a); | |
| return { | |
| type: i.length > 1 ? i : i[0], | |
| enum: e.reduce((r, a) => r.includes(a._def.value) ? r : [...r, a._def.value], []) | |
| }; | |
| } | |
| } else if (e.every((s) => s._def.typeName === "ZodEnum")) | |
| return { | |
| type: "string", | |
| enum: e.reduce((s, i) => [ | |
| ...s, | |
| ...i._def.values.filter((r) => !s.includes(r)) | |
| ], []) | |
| }; | |
| return Sg(n, t); | |
| } | |
| const Sg = (n, t) => { | |
| const e = (n.options instanceof Map ? Array.from(n.options.values()) : n.options).map((s, i) => ft(s._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "anyOf", `${i}`] | |
| })).filter((s) => !!s && (!t.strictUnions || typeof s == "object" && Object.keys(s).length > 0)); | |
| return e.length ? { anyOf: e } : void 0; | |
| }; | |
| function Iw(n, t) { | |
| if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(n.innerType._def.typeName) && (!n.innerType._def.checks || !n.innerType._def.checks.length)) | |
| return t.target === "openApi3" ? { | |
| type: Mu[n.innerType._def.typeName], | |
| nullable: !0 | |
| } : { | |
| type: [ | |
| Mu[n.innerType._def.typeName], | |
| "null" | |
| ] | |
| }; | |
| if (t.target === "openApi3") { | |
| const s = ft(n.innerType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath] | |
| }); | |
| return s && "$ref" in s ? { allOf: [s], nullable: !0 } : s && { ...s, nullable: !0 }; | |
| } | |
| const e = ft(n.innerType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "anyOf", "0"] | |
| }); | |
| return e && { anyOf: [e, { type: "null" }] }; | |
| } | |
| function Rw(n, t) { | |
| const e = { | |
| type: "number" | |
| }; | |
| if (!n.checks) | |
| return e; | |
| for (const s of n.checks) | |
| switch (s.kind) { | |
| case "int": | |
| e.type = "integer", Um(e, "type", s.message, t); | |
| break; | |
| case "min": | |
| t.target === "jsonSchema7" ? s.inclusive ? _t(e, "minimum", s.value, s.message, t) : _t(e, "exclusiveMinimum", s.value, s.message, t) : (s.inclusive || (e.exclusiveMinimum = !0), _t(e, "minimum", s.value, s.message, t)); | |
| break; | |
| case "max": | |
| t.target === "jsonSchema7" ? s.inclusive ? _t(e, "maximum", s.value, s.message, t) : _t(e, "exclusiveMaximum", s.value, s.message, t) : (s.inclusive || (e.exclusiveMaximum = !0), _t(e, "maximum", s.value, s.message, t)); | |
| break; | |
| case "multipleOf": | |
| _t(e, "multipleOf", s.value, s.message, t); | |
| break; | |
| } | |
| return e; | |
| } | |
| function Pw(n, t) { | |
| return t.removeAdditionalStrategy === "strict" ? n.catchall._def.typeName === "ZodNever" ? n.unknownKeys !== "strict" : ft(n.catchall._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "additionalProperties"] | |
| }) ?? !0 : n.catchall._def.typeName === "ZodNever" ? n.unknownKeys === "passthrough" : ft(n.catchall._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "additionalProperties"] | |
| }) ?? !0; | |
| } | |
| function Mw(n, t) { | |
| const e = t.target === "openAi", s = { | |
| type: "object", | |
| ...Object.entries(n.shape()).reduce((i, [r, a]) => { | |
| if (a === void 0 || a._def === void 0) | |
| return i; | |
| let l = a.isOptional(); | |
| l && e && (a instanceof js && (a = a._def.innerType), a.isNullable() || (a = a.nullable()), l = !1); | |
| const c = ft(a._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "properties", r], | |
| propertyPath: [...t.currentPath, "properties", r] | |
| }); | |
| return c === void 0 ? i : { | |
| properties: { ...i.properties, [r]: c }, | |
| required: l ? i.required : [...i.required, r] | |
| }; | |
| }, { properties: {}, required: [] }), | |
| additionalProperties: Pw(n, t) | |
| }; | |
| return s.required.length || delete s.required, s; | |
| } | |
| const Nw = (n, t) => { | |
| var s; | |
| if (t.currentPath.toString() === ((s = t.propertyPath) == null ? void 0 : s.toString())) | |
| return ft(n.innerType._def, t); | |
| const e = ft(n.innerType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "anyOf", "1"] | |
| }); | |
| return e ? { | |
| anyOf: [ | |
| { | |
| not: {} | |
| }, | |
| e | |
| ] | |
| } : {}; | |
| }, Ow = (n, t) => { | |
| if (t.pipeStrategy === "input") | |
| return ft(n.in._def, t); | |
| if (t.pipeStrategy === "output") | |
| return ft(n.out._def, t); | |
| const e = ft(n.in._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "allOf", "0"] | |
| }), s = ft(n.out._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "allOf", e ? "1" : "0"] | |
| }); | |
| return { | |
| allOf: [e, s].filter((i) => i !== void 0) | |
| }; | |
| }; | |
| function Lw(n, t) { | |
| return ft(n.type._def, t); | |
| } | |
| function Dw(n, t) { | |
| const s = { | |
| type: "array", | |
| uniqueItems: !0, | |
| items: ft(n.valueType._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "items"] | |
| }) | |
| }; | |
| return n.minSize && _t(s, "minItems", n.minSize.value, n.minSize.message, t), n.maxSize && _t(s, "maxItems", n.maxSize.value, n.maxSize.message, t), s; | |
| } | |
| function Fw(n, t) { | |
| return n.rest ? { | |
| type: "array", | |
| minItems: n.items.length, | |
| items: n.items.map((e, s) => ft(e._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "items", `${s}`] | |
| })).reduce((e, s) => s === void 0 ? e : [...e, s], []), | |
| additionalItems: ft(n.rest._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "additionalItems"] | |
| }) | |
| } : { | |
| type: "array", | |
| minItems: n.items.length, | |
| maxItems: n.items.length, | |
| items: n.items.map((e, s) => ft(e._def, { | |
| ...t, | |
| currentPath: [...t.currentPath, "items", `${s}`] | |
| })).reduce((e, s) => s === void 0 ? e : [...e, s], []) | |
| }; | |
| } | |
| function $w() { | |
| return { | |
| not: {} | |
| }; | |
| } | |
| function jw() { | |
| return {}; | |
| } | |
| const Bw = (n, t) => ft(n.innerType._def, t), Hw = (n, t, e) => { | |
| switch (t) { | |
| case R.ZodString: | |
| return ey(n, e); | |
| case R.ZodNumber: | |
| return Rw(n, e); | |
| case R.ZodObject: | |
| return Mw(n, e); | |
| case R.ZodBigInt: | |
| return dw(n, e); | |
| case R.ZodBoolean: | |
| return fw(); | |
| case R.ZodDate: | |
| return ty(n, e); | |
| case R.ZodUndefined: | |
| return $w(); | |
| case R.ZodNull: | |
| return Cw(e); | |
| case R.ZodArray: | |
| return uw(n, e); | |
| case R.ZodUnion: | |
| case R.ZodDiscriminatedUnion: | |
| return kw(n, e); | |
| case R.ZodIntersection: | |
| return _w(n, e); | |
| case R.ZodTuple: | |
| return Fw(n, e); | |
| case R.ZodRecord: | |
| return sy(n, e); | |
| case R.ZodLiteral: | |
| return Aw(n, e); | |
| case R.ZodEnum: | |
| return bw(n); | |
| case R.ZodNativeEnum: | |
| return xw(n); | |
| case R.ZodNullable: | |
| return Iw(n, e); | |
| case R.ZodOptional: | |
| return Nw(n, e); | |
| case R.ZodMap: | |
| return Ew(n, e); | |
| case R.ZodSet: | |
| return Dw(n, e); | |
| case R.ZodLazy: | |
| return () => n.getter()._def; | |
| case R.ZodPromise: | |
| return Lw(n, e); | |
| case R.ZodNaN: | |
| case R.ZodNever: | |
| return Tw(); | |
| case R.ZodEffects: | |
| return yw(n, e); | |
| case R.ZodAny: | |
| return hw(); | |
| case R.ZodUnknown: | |
| return jw(); | |
| case R.ZodDefault: | |
| return mw(n, e); | |
| case R.ZodBranded: | |
| return Qm(n, e); | |
| case R.ZodReadonly: | |
| return Bw(n, e); | |
| case R.ZodCatch: | |
| return pw(n, e); | |
| case R.ZodPipeline: | |
| return Ow(n, e); | |
| case R.ZodFunction: | |
| case R.ZodVoid: | |
| case R.ZodSymbol: | |
| return; | |
| default: | |
| return /* @__PURE__ */ ((s) => { | |
| })(); | |
| } | |
| }; | |
| function ft(n, t, e = !1) { | |
| var l; | |
| const s = t.seen.get(n); | |
| if (t.override) { | |
| const c = (l = t.override) == null ? void 0 : l.call(t, n, t, s, e); | |
| if (c !== Q_) | |
| return c; | |
| } | |
| if (s && !e) { | |
| const c = Uw(s, t); | |
| if (c !== void 0) | |
| return c; | |
| } | |
| const i = { def: n, path: t.currentPath, jsonSchema: void 0 }; | |
| t.seen.set(n, i); | |
| const r = Hw(n, n.typeName, t), a = typeof r == "function" ? ft(r(), t) : r; | |
| if (a && Vw(n, t, a), t.postProcess) { | |
| const c = t.postProcess(a, n, t); | |
| return i.jsonSchema = a, c; | |
| } | |
| return i.jsonSchema = a, a; | |
| } | |
| const Uw = (n, t) => { | |
| switch (t.$refStrategy) { | |
| case "root": | |
| return { $ref: n.path.join("/") }; | |
| case "relative": | |
| return { $ref: zw(t.currentPath, n.path) }; | |
| case "none": | |
| case "seen": | |
| return n.path.length < t.currentPath.length && n.path.every((e, s) => t.currentPath[s] === e) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), {}) : t.$refStrategy === "seen" ? {} : void 0; | |
| } | |
| }, zw = (n, t) => { | |
| let e = 0; | |
| for (; e < n.length && e < t.length && n[e] === t[e]; e++) | |
| ; | |
| return [(n.length - e).toString(), ...t.slice(e)].join("/"); | |
| }, Vw = (n, t, e) => (n.description && (e.description = n.description, t.markdownDescription && (e.markdownDescription = n.description)), e), Gw = (n, t) => { | |
| const e = eA(t), s = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((c, [h, u]) => ({ | |
| ...c, | |
| [h]: ft(u._def, { | |
| ...e, | |
| currentPath: [...e.basePath, e.definitionPath, h] | |
| }, !0) ?? {} | |
| }), {}) : void 0, i = typeof t == "string" ? t : (t == null ? void 0 : t.nameStrategy) === "title" || t == null ? void 0 : t.name, r = ft(n._def, i === void 0 ? e : { | |
| ...e, | |
| currentPath: [...e.basePath, e.definitionPath, i] | |
| }, !1) ?? {}, a = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0; | |
| a !== void 0 && (r.title = a); | |
| const l = i === void 0 ? s ? { | |
| ...r, | |
| [e.definitionPath]: s | |
| } : r : { | |
| $ref: [ | |
| ...e.$refStrategy === "relative" ? [] : e.basePath, | |
| e.definitionPath, | |
| i | |
| ].join("/"), | |
| [e.definitionPath]: { | |
| ...s, | |
| [i]: r | |
| } | |
| }; | |
| return e.target === "jsonSchema7" ? l.$schema = "http://json-schema.org/draft-07/schema#" : (e.target === "jsonSchema2019-09" || e.target === "openAi") && (l.$schema = "https://json-schema.org/draft/2019-09/schema#"), e.target === "openAi" && ("anyOf" in l || "oneOf" in l || "allOf" in l || "type" in l && Array.isArray(l.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), l; | |
| }; | |
| var Zl = { | |
| code: "0", | |
| name: "text", | |
| parse: (n) => { | |
| if (typeof n != "string") | |
| throw new Error('"text" parts expect a string value.'); | |
| return { type: "text", value: n }; | |
| } | |
| }, Yl = { | |
| code: "3", | |
| name: "error", | |
| parse: (n) => { | |
| if (typeof n != "string") | |
| throw new Error('"error" parts expect a string value.'); | |
| return { type: "error", value: n }; | |
| } | |
| }, Kl = { | |
| code: "4", | |
| name: "assistant_message", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("id" in n) || !("role" in n) || !("content" in n) || typeof n.id != "string" || typeof n.role != "string" || n.role !== "assistant" || !Array.isArray(n.content) || !n.content.every( | |
| (t) => t != null && typeof t == "object" && "type" in t && t.type === "text" && "text" in t && t.text != null && typeof t.text == "object" && "value" in t.text && typeof t.text.value == "string" | |
| )) | |
| throw new Error( | |
| '"assistant_message" parts expect an object with an "id", "role", and "content" property.' | |
| ); | |
| return { | |
| type: "assistant_message", | |
| value: n | |
| }; | |
| } | |
| }, Jl = { | |
| code: "5", | |
| name: "assistant_control_data", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("threadId" in n) || !("messageId" in n) || typeof n.threadId != "string" || typeof n.messageId != "string") | |
| throw new Error( | |
| '"assistant_control_data" parts expect an object with a "threadId" and "messageId" property.' | |
| ); | |
| return { | |
| type: "assistant_control_data", | |
| value: { | |
| threadId: n.threadId, | |
| messageId: n.messageId | |
| } | |
| }; | |
| } | |
| }, Ql = { | |
| code: "6", | |
| name: "data_message", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("role" in n) || !("data" in n) || typeof n.role != "string" || n.role !== "data") | |
| throw new Error( | |
| '"data_message" parts expect an object with a "role" and "data" property.' | |
| ); | |
| return { | |
| type: "data_message", | |
| value: n | |
| }; | |
| } | |
| }, qw = [ | |
| Zl, | |
| Yl, | |
| Kl, | |
| Jl, | |
| Ql | |
| ]; | |
| Zl.code + "", Yl.code + "", Kl.code + "", Jl.code + "", Ql.code + ""; | |
| Zl.name + "", Zl.code, Yl.name + "", Yl.code, Kl.name + "", Kl.code, Jl.name + "", Jl.code, Ql.name + "", Ql.code; | |
| qw.map((n) => n.code); | |
| function Ww(n) { | |
| const t = ["ROOT"]; | |
| let e = -1, s = null; | |
| function i(c, h, u) { | |
| switch (c) { | |
| case '"': { | |
| e = h, t.pop(), t.push(u), t.push("INSIDE_STRING"); | |
| break; | |
| } | |
| case "f": | |
| case "t": | |
| case "n": { | |
| e = h, s = h, t.pop(), t.push(u), t.push("INSIDE_LITERAL"); | |
| break; | |
| } | |
| case "-": { | |
| t.pop(), t.push(u), t.push("INSIDE_NUMBER"); | |
| break; | |
| } | |
| case "0": | |
| case "1": | |
| case "2": | |
| case "3": | |
| case "4": | |
| case "5": | |
| case "6": | |
| case "7": | |
| case "8": | |
| case "9": { | |
| e = h, t.pop(), t.push(u), t.push("INSIDE_NUMBER"); | |
| break; | |
| } | |
| case "{": { | |
| e = h, t.pop(), t.push(u), t.push("INSIDE_OBJECT_START"); | |
| break; | |
| } | |
| case "[": { | |
| e = h, t.pop(), t.push(u), t.push("INSIDE_ARRAY_START"); | |
| break; | |
| } | |
| } | |
| } | |
| function r(c, h) { | |
| switch (c) { | |
| case ",": { | |
| t.pop(), t.push("INSIDE_OBJECT_AFTER_COMMA"); | |
| break; | |
| } | |
| case "}": { | |
| e = h, t.pop(); | |
| break; | |
| } | |
| } | |
| } | |
| function a(c, h) { | |
| switch (c) { | |
| case ",": { | |
| t.pop(), t.push("INSIDE_ARRAY_AFTER_COMMA"); | |
| break; | |
| } | |
| case "]": { | |
| e = h, t.pop(); | |
| break; | |
| } | |
| } | |
| } | |
| for (let c = 0; c < n.length; c++) { | |
| const h = n[c]; | |
| switch (t[t.length - 1]) { | |
| case "ROOT": | |
| i(h, c, "FINISH"); | |
| break; | |
| case "INSIDE_OBJECT_START": { | |
| switch (h) { | |
| case '"': { | |
| t.pop(), t.push("INSIDE_OBJECT_KEY"); | |
| break; | |
| } | |
| case "}": { | |
| e = c, t.pop(); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_OBJECT_AFTER_COMMA": { | |
| switch (h) { | |
| case '"': { | |
| t.pop(), t.push("INSIDE_OBJECT_KEY"); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_OBJECT_KEY": { | |
| switch (h) { | |
| case '"': { | |
| t.pop(), t.push("INSIDE_OBJECT_AFTER_KEY"); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_OBJECT_AFTER_KEY": { | |
| switch (h) { | |
| case ":": { | |
| t.pop(), t.push("INSIDE_OBJECT_BEFORE_VALUE"); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_OBJECT_BEFORE_VALUE": { | |
| i(h, c, "INSIDE_OBJECT_AFTER_VALUE"); | |
| break; | |
| } | |
| case "INSIDE_OBJECT_AFTER_VALUE": { | |
| r(h, c); | |
| break; | |
| } | |
| case "INSIDE_STRING": { | |
| switch (h) { | |
| case '"': { | |
| t.pop(), e = c; | |
| break; | |
| } | |
| case "\\": { | |
| t.push("INSIDE_STRING_ESCAPE"); | |
| break; | |
| } | |
| default: | |
| e = c; | |
| } | |
| break; | |
| } | |
| case "INSIDE_ARRAY_START": { | |
| switch (h) { | |
| case "]": { | |
| e = c, t.pop(); | |
| break; | |
| } | |
| default: { | |
| e = c, i(h, c, "INSIDE_ARRAY_AFTER_VALUE"); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_ARRAY_AFTER_VALUE": { | |
| switch (h) { | |
| case ",": { | |
| t.pop(), t.push("INSIDE_ARRAY_AFTER_COMMA"); | |
| break; | |
| } | |
| case "]": { | |
| e = c, t.pop(); | |
| break; | |
| } | |
| default: { | |
| e = c; | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_ARRAY_AFTER_COMMA": { | |
| i(h, c, "INSIDE_ARRAY_AFTER_VALUE"); | |
| break; | |
| } | |
| case "INSIDE_STRING_ESCAPE": { | |
| t.pop(), e = c; | |
| break; | |
| } | |
| case "INSIDE_NUMBER": { | |
| switch (h) { | |
| case "0": | |
| case "1": | |
| case "2": | |
| case "3": | |
| case "4": | |
| case "5": | |
| case "6": | |
| case "7": | |
| case "8": | |
| case "9": { | |
| e = c; | |
| break; | |
| } | |
| case "e": | |
| case "E": | |
| case "-": | |
| case ".": | |
| break; | |
| case ",": { | |
| t.pop(), t[t.length - 1] === "INSIDE_ARRAY_AFTER_VALUE" && a(h, c), t[t.length - 1] === "INSIDE_OBJECT_AFTER_VALUE" && r(h, c); | |
| break; | |
| } | |
| case "}": { | |
| t.pop(), t[t.length - 1] === "INSIDE_OBJECT_AFTER_VALUE" && r(h, c); | |
| break; | |
| } | |
| case "]": { | |
| t.pop(), t[t.length - 1] === "INSIDE_ARRAY_AFTER_VALUE" && a(h, c); | |
| break; | |
| } | |
| default: { | |
| t.pop(); | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| case "INSIDE_LITERAL": { | |
| const d = n.substring(s, c + 1); | |
| !"false".startsWith(d) && !"true".startsWith(d) && !"null".startsWith(d) ? (t.pop(), t[t.length - 1] === "INSIDE_OBJECT_AFTER_VALUE" ? r(h, c) : t[t.length - 1] === "INSIDE_ARRAY_AFTER_VALUE" && a(h, c)) : e = c; | |
| break; | |
| } | |
| } | |
| } | |
| let l = n.slice(0, e + 1); | |
| for (let c = t.length - 1; c >= 0; c--) | |
| switch (t[c]) { | |
| case "INSIDE_STRING": { | |
| l += '"'; | |
| break; | |
| } | |
| case "INSIDE_OBJECT_KEY": | |
| case "INSIDE_OBJECT_AFTER_KEY": | |
| case "INSIDE_OBJECT_AFTER_COMMA": | |
| case "INSIDE_OBJECT_START": | |
| case "INSIDE_OBJECT_BEFORE_VALUE": | |
| case "INSIDE_OBJECT_AFTER_VALUE": { | |
| l += "}"; | |
| break; | |
| } | |
| case "INSIDE_ARRAY_START": | |
| case "INSIDE_ARRAY_AFTER_COMMA": | |
| case "INSIDE_ARRAY_AFTER_VALUE": { | |
| l += "]"; | |
| break; | |
| } | |
| case "INSIDE_LITERAL": { | |
| const u = n.substring(s, n.length); | |
| "true".startsWith(u) ? l += "true".slice(u.length) : "false".startsWith(u) ? l += "false".slice(u.length) : "null".startsWith(u) && (l += "null".slice(u.length)); | |
| } | |
| } | |
| return l; | |
| } | |
| function Xw(n) { | |
| if (n === void 0) | |
| return { value: void 0, state: "undefined-input" }; | |
| let t = Go({ text: n }); | |
| return t.success ? { value: t.value, state: "successful-parse" } : (t = Go({ text: Ww(n) }), t.success ? { value: t.value, state: "repaired-parse" } : { value: void 0, state: "failed-parse" }); | |
| } | |
| var Zw = { | |
| code: "0", | |
| name: "text", | |
| parse: (n) => { | |
| if (typeof n != "string") | |
| throw new Error('"text" parts expect a string value.'); | |
| return { type: "text", value: n }; | |
| } | |
| }, Yw = { | |
| code: "2", | |
| name: "data", | |
| parse: (n) => { | |
| if (!Array.isArray(n)) | |
| throw new Error('"data" parts expect an array value.'); | |
| return { type: "data", value: n }; | |
| } | |
| }, Kw = { | |
| code: "3", | |
| name: "error", | |
| parse: (n) => { | |
| if (typeof n != "string") | |
| throw new Error('"error" parts expect a string value.'); | |
| return { type: "error", value: n }; | |
| } | |
| }, Jw = { | |
| code: "8", | |
| name: "message_annotations", | |
| parse: (n) => { | |
| if (!Array.isArray(n)) | |
| throw new Error('"message_annotations" parts expect an array value.'); | |
| return { type: "message_annotations", value: n }; | |
| } | |
| }, Qw = { | |
| code: "9", | |
| name: "tool_call", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("toolCallId" in n) || typeof n.toolCallId != "string" || !("toolName" in n) || typeof n.toolName != "string" || !("args" in n) || typeof n.args != "object") | |
| throw new Error( | |
| '"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.' | |
| ); | |
| return { | |
| type: "tool_call", | |
| value: n | |
| }; | |
| } | |
| }, t0 = { | |
| code: "a", | |
| name: "tool_result", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("toolCallId" in n) || typeof n.toolCallId != "string" || !("result" in n)) | |
| throw new Error( | |
| '"tool_result" parts expect an object with a "toolCallId" and a "result" property.' | |
| ); | |
| return { | |
| type: "tool_result", | |
| value: n | |
| }; | |
| } | |
| }, e0 = { | |
| code: "b", | |
| name: "tool_call_streaming_start", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("toolCallId" in n) || typeof n.toolCallId != "string" || !("toolName" in n) || typeof n.toolName != "string") | |
| throw new Error( | |
| '"tool_call_streaming_start" parts expect an object with a "toolCallId" and "toolName" property.' | |
| ); | |
| return { | |
| type: "tool_call_streaming_start", | |
| value: n | |
| }; | |
| } | |
| }, s0 = { | |
| code: "c", | |
| name: "tool_call_delta", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("toolCallId" in n) || typeof n.toolCallId != "string" || !("argsTextDelta" in n) || typeof n.argsTextDelta != "string") | |
| throw new Error( | |
| '"tool_call_delta" parts expect an object with a "toolCallId" and "argsTextDelta" property.' | |
| ); | |
| return { | |
| type: "tool_call_delta", | |
| value: n | |
| }; | |
| } | |
| }, i0 = { | |
| code: "d", | |
| name: "finish_message", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("finishReason" in n) || typeof n.finishReason != "string") | |
| throw new Error( | |
| '"finish_message" parts expect an object with a "finishReason" property.' | |
| ); | |
| const t = { | |
| finishReason: n.finishReason | |
| }; | |
| return "usage" in n && n.usage != null && typeof n.usage == "object" && "promptTokens" in n.usage && "completionTokens" in n.usage && (t.usage = { | |
| promptTokens: typeof n.usage.promptTokens == "number" ? n.usage.promptTokens : Number.NaN, | |
| completionTokens: typeof n.usage.completionTokens == "number" ? n.usage.completionTokens : Number.NaN | |
| }), { | |
| type: "finish_message", | |
| value: t | |
| }; | |
| } | |
| }, n0 = { | |
| code: "e", | |
| name: "finish_step", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("finishReason" in n) || typeof n.finishReason != "string") | |
| throw new Error( | |
| '"finish_step" parts expect an object with a "finishReason" property.' | |
| ); | |
| const t = { | |
| finishReason: n.finishReason, | |
| isContinued: !1 | |
| }; | |
| return "usage" in n && n.usage != null && typeof n.usage == "object" && "promptTokens" in n.usage && "completionTokens" in n.usage && (t.usage = { | |
| promptTokens: typeof n.usage.promptTokens == "number" ? n.usage.promptTokens : Number.NaN, | |
| completionTokens: typeof n.usage.completionTokens == "number" ? n.usage.completionTokens : Number.NaN | |
| }), "isContinued" in n && typeof n.isContinued == "boolean" && (t.isContinued = n.isContinued), { | |
| type: "finish_step", | |
| value: t | |
| }; | |
| } | |
| }, r0 = { | |
| code: "f", | |
| name: "start_step", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("messageId" in n) || typeof n.messageId != "string") | |
| throw new Error( | |
| '"start_step" parts expect an object with an "id" property.' | |
| ); | |
| return { | |
| type: "start_step", | |
| value: { | |
| messageId: n.messageId | |
| } | |
| }; | |
| } | |
| }, a0 = { | |
| code: "g", | |
| name: "reasoning", | |
| parse: (n) => { | |
| if (typeof n != "string") | |
| throw new Error('"reasoning" parts expect a string value.'); | |
| return { type: "reasoning", value: n }; | |
| } | |
| }, o0 = { | |
| code: "h", | |
| name: "source", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object") | |
| throw new Error('"source" parts expect a Source object.'); | |
| return { | |
| type: "source", | |
| value: n | |
| }; | |
| } | |
| }, l0 = { | |
| code: "i", | |
| name: "redacted_reasoning", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("data" in n) || typeof n.data != "string") | |
| throw new Error( | |
| '"redacted_reasoning" parts expect an object with a "data" property.' | |
| ); | |
| return { type: "redacted_reasoning", value: { data: n.data } }; | |
| } | |
| }, c0 = { | |
| code: "j", | |
| name: "reasoning_signature", | |
| parse: (n) => { | |
| if (n == null || typeof n != "object" || !("signature" in n) || typeof n.signature != "string") | |
| throw new Error( | |
| '"reasoning_signature" parts expect an object with a "signature" property.' | |
| ); | |
| return { | |
| type: "reasoning_signature", | |
| value: { signature: n.signature } | |
| }; | |
| } | |
| }, md = [ | |
| Zw, | |
| Yw, | |
| Kw, | |
| Jw, | |
| Qw, | |
| t0, | |
| e0, | |
| s0, | |
| i0, | |
| n0, | |
| r0, | |
| a0, | |
| o0, | |
| l0, | |
| c0 | |
| ]; | |
| Object.fromEntries( | |
| md.map((n) => [n.code, n]) | |
| ); | |
| Object.fromEntries( | |
| md.map((n) => [n.name, n.code]) | |
| ); | |
| md.map((n) => n.code); | |
| function iy(n, t) { | |
| const e = md.find((s) => s.name === n); | |
| if (!e) | |
| throw new Error(`Invalid stream part type: ${n}`); | |
| return `${e.code}:${JSON.stringify(t)} | |
| `; | |
| } | |
| function h0(n, t) { | |
| var e; | |
| const s = (e = void 0) != null ? e : !1; | |
| return u0( | |
| Gw(n, { | |
| $refStrategy: s ? "root" : "none", | |
| target: "jsonSchema7" | |
| // note: openai mode breaks various gemini conversions | |
| }), | |
| { | |
| validate: (i) => { | |
| const r = n.safeParse(i); | |
| return r.success ? { success: !0, value: r.data } : { success: !1, error: r.error }; | |
| } | |
| } | |
| ); | |
| } | |
| var nf = Symbol.for("vercel.ai.schema"); | |
| function u0(n, { | |
| validate: t | |
| } = {}) { | |
| return { | |
| [nf]: !0, | |
| _type: void 0, | |
| // should never be used directly | |
| [Eu]: !0, | |
| jsonSchema: n, | |
| validate: t | |
| }; | |
| } | |
| function d0(n) { | |
| return typeof n == "object" && n !== null && nf in n && n[nf] === !0 && "jsonSchema" in n && "validate" in n; | |
| } | |
| function rf(n) { | |
| return d0(n) ? n : h0(n); | |
| } | |
| var f0 = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {}, sr = "1.9.0", Eg = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/; | |
| function p0(n) { | |
| var t = /* @__PURE__ */ new Set([n]), e = /* @__PURE__ */ new Set(), s = n.match(Eg); | |
| if (!s) | |
| return function() { | |
| return !1; | |
| }; | |
| var i = { | |
| major: +s[1], | |
| minor: +s[2], | |
| patch: +s[3], | |
| prerelease: s[4] | |
| }; | |
| if (i.prerelease != null) | |
| return function(c) { | |
| return c === n; | |
| }; | |
| function r(l) { | |
| return e.add(l), !1; | |
| } | |
| function a(l) { | |
| return t.add(l), !0; | |
| } | |
| return function(c) { | |
| if (t.has(c)) | |
| return !0; | |
| if (e.has(c)) | |
| return !1; | |
| var h = c.match(Eg); | |
| if (!h) | |
| return r(c); | |
| var u = { | |
| major: +h[1], | |
| minor: +h[2], | |
| patch: +h[3], | |
| prerelease: h[4] | |
| }; | |
| return u.prerelease != null || i.major !== u.major ? r(c) : i.major === 0 ? i.minor === u.minor && i.patch <= u.patch ? a(c) : r(c) : i.minor <= u.minor ? a(c) : r(c); | |
| }; | |
| } | |
| var g0 = p0(sr), m0 = sr.split(".")[0], tc = Symbol.for("opentelemetry.js.api." + m0), ec = f0; | |
| function Rp(n, t, e, s) { | |
| var i; | |
| s === void 0 && (s = !1); | |
| var r = ec[tc] = (i = ec[tc]) !== null && i !== void 0 ? i : { | |
| version: sr | |
| }; | |
| if (!s && r[n]) { | |
| var a = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + n); | |
| return e.error(a.stack || a.message), !1; | |
| } | |
| if (r.version !== sr) { | |
| var a = new Error("@opentelemetry/api: Registration of version v" + r.version + " for " + n + " does not match previously registered API v" + sr); | |
| return e.error(a.stack || a.message), !1; | |
| } | |
| return r[n] = t, e.debug("@opentelemetry/api: Registered a global for " + n + " v" + sr + "."), !0; | |
| } | |
| function sc(n) { | |
| var t, e, s = (t = ec[tc]) === null || t === void 0 ? void 0 : t.version; | |
| if (!(!s || !g0(s))) | |
| return (e = ec[tc]) === null || e === void 0 ? void 0 : e[n]; | |
| } | |
| function Pp(n, t) { | |
| t.debug("@opentelemetry/api: Unregistering a global for " + n + " v" + sr + "."); | |
| var e = ec[tc]; | |
| e && delete e[n]; | |
| } | |
| var y0 = function(n, t) { | |
| var e = typeof Symbol == "function" && n[Symbol.iterator]; | |
| if (!e) return n; | |
| var s = e.call(n), i, r = [], a; | |
| try { | |
| for (; (t === void 0 || t-- > 0) && !(i = s.next()).done; ) r.push(i.value); | |
| } catch (l) { | |
| a = { error: l }; | |
| } finally { | |
| try { | |
| i && !i.done && (e = s.return) && e.call(s); | |
| } finally { | |
| if (a) throw a.error; | |
| } | |
| } | |
| return r; | |
| }, b0 = function(n, t, e) { | |
| if (e || arguments.length === 2) for (var s = 0, i = t.length, r; s < i; s++) | |
| (r || !(s in t)) && (r || (r = Array.prototype.slice.call(t, 0, s)), r[s] = t[s]); | |
| return n.concat(r || Array.prototype.slice.call(t)); | |
| }, v0 = ( | |
| /** @class */ | |
| function() { | |
| function n(t) { | |
| this._namespace = t.namespace || "DiagComponentLogger"; | |
| } | |
| return n.prototype.debug = function() { | |
| for (var t = [], e = 0; e < arguments.length; e++) | |
| t[e] = arguments[e]; | |
| return il("debug", this._namespace, t); | |
| }, n.prototype.error = function() { | |
| for (var t = [], e = 0; e < arguments.length; e++) | |
| t[e] = arguments[e]; | |
| return il("error", this._namespace, t); | |
| }, n.prototype.info = function() { | |
| for (var t = [], e = 0; e < arguments.length; e++) | |
| t[e] = arguments[e]; | |
| return il("info", this._namespace, t); | |
| }, n.prototype.warn = function() { | |
| for (var t = [], e = 0; e < arguments.length; e++) | |
| t[e] = arguments[e]; | |
| return il("warn", this._namespace, t); | |
| }, n.prototype.verbose = function() { | |
| for (var t = [], e = 0; e < arguments.length; e++) | |
| t[e] = arguments[e]; | |
| return il("verbose", this._namespace, t); | |
| }, n; | |
| }() | |
| ); | |
| function il(n, t, e) { | |
| var s = sc("diag"); | |
| if (s) | |
| return e.unshift(t), s[n].apply(s, b0([], y0(e), !1)); | |
| } | |
| var es; | |
| (function(n) { | |
| n[n.NONE = 0] = "NONE", n[n.ERROR = 30] = "ERROR", n[n.WARN = 50] = "WARN", n[n.INFO = 60] = "INFO", n[n.DEBUG = 70] = "DEBUG", n[n.VERBOSE = 80] = "VERBOSE", n[n.ALL = 9999] = "ALL"; | |
| })(es || (es = {})); | |
| function _0(n, t) { | |
| n < es.NONE ? n = es.NONE : n > es.ALL && (n = es.ALL), t = t || {}; | |
| function e(s, i) { | |
| var r = t[s]; | |
| return typeof r == "function" && n >= i ? r.bind(t) : function() { | |
| }; | |
| } | |
| return { | |
| error: e("error", es.ERROR), | |
| warn: e("warn", es.WARN), | |
| info: e("info", es.INFO), | |
| debug: e("debug", es.DEBUG), | |
| verbose: e("verbose", es.VERBOSE) | |
| }; | |
| } | |
| var A0 = function(n, t) { | |
| var e = typeof Symbol == "function" && n[Symbol.iterator]; | |
| if (!e) return n; | |
| var s = e.call(n), i, r = [], a; | |
| try { | |
| for (; (t === void 0 || t-- > 0) && !(i = s.next()).done; ) r.push(i.value); | |
| } catch (l) { | |
| a = { error: l }; | |
| } finally { | |
| try { | |
| i && !i.done && (e = s.return) && e.call(s); | |
| } finally { | |
| if (a) throw a.error; | |
| } | |
| } | |
| return r; | |
| }, w0 = function(n, t, e) { | |
| if (e || arguments.length === 2) for (var s = 0, i = t.length, r; s < i; s++) | |
| (r || !(s in t)) && (r || (r = Array.prototype.slice.call(t, 0, s)), r[s] = t[s]); | |
| return n.concat(r || Array.prototype.slice.call(t)); | |
| }, S0 = "diag", Nu = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| function t(i) { | |
| return function() { | |
| for (var r = [], a = 0; a < arguments.length; a++) | |
| r[a] = arguments[a]; | |
| var l = sc("diag"); | |
| if (l) | |
| return l[i].apply(l, w0([], A0(r), !1)); | |
| }; | |
| } | |
| var e = this, s = function(i, r) { | |
| var a, l, c; | |
| if (r === void 0 && (r = { logLevel: es.INFO }), i === e) { | |
| var h = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation"); | |
| return e.error((a = h.stack) !== null && a !== void 0 ? a : h.message), !1; | |
| } | |
| typeof r == "number" && (r = { | |
| logLevel: r | |
| }); | |
| var u = sc("diag"), d = _0((l = r.logLevel) !== null && l !== void 0 ? l : es.INFO, i); | |
| if (u && !r.suppressOverrideMessage) { | |
| var f = (c = new Error().stack) !== null && c !== void 0 ? c : "<failed to generate stacktrace>"; | |
| u.warn("Current logger will be overwritten from " + f), d.warn("Current logger will overwrite one already registered from " + f); | |
| } | |
| return Rp("diag", d, e, !0); | |
| }; | |
| e.setLogger = s, e.disable = function() { | |
| Pp(S0, e); | |
| }, e.createComponentLogger = function(i) { | |
| return new v0(i); | |
| }, e.verbose = t("verbose"), e.debug = t("debug"), e.info = t("info"), e.warn = t("warn"), e.error = t("error"); | |
| } | |
| return n.instance = function() { | |
| return this._instance || (this._instance = new n()), this._instance; | |
| }, n; | |
| }() | |
| ); | |
| function E0(n) { | |
| return Symbol.for(n); | |
| } | |
| var x0 = ( | |
| /** @class */ | |
| /* @__PURE__ */ function() { | |
| function n(t) { | |
| var e = this; | |
| e._currentContext = t ? new Map(t) : /* @__PURE__ */ new Map(), e.getValue = function(s) { | |
| return e._currentContext.get(s); | |
| }, e.setValue = function(s, i) { | |
| var r = new n(e._currentContext); | |
| return r._currentContext.set(s, i), r; | |
| }, e.deleteValue = function(s) { | |
| var i = new n(e._currentContext); | |
| return i._currentContext.delete(s), i; | |
| }; | |
| } | |
| return n; | |
| }() | |
| ), T0 = new x0(), C0 = function(n, t) { | |
| var e = typeof Symbol == "function" && n[Symbol.iterator]; | |
| if (!e) return n; | |
| var s = e.call(n), i, r = [], a; | |
| try { | |
| for (; (t === void 0 || t-- > 0) && !(i = s.next()).done; ) r.push(i.value); | |
| } catch (l) { | |
| a = { error: l }; | |
| } finally { | |
| try { | |
| i && !i.done && (e = s.return) && e.call(s); | |
| } finally { | |
| if (a) throw a.error; | |
| } | |
| } | |
| return r; | |
| }, k0 = function(n, t, e) { | |
| if (e || arguments.length === 2) for (var s = 0, i = t.length, r; s < i; s++) | |
| (r || !(s in t)) && (r || (r = Array.prototype.slice.call(t, 0, s)), r[s] = t[s]); | |
| return n.concat(r || Array.prototype.slice.call(t)); | |
| }, I0 = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| } | |
| return n.prototype.active = function() { | |
| return T0; | |
| }, n.prototype.with = function(t, e, s) { | |
| for (var i = [], r = 3; r < arguments.length; r++) | |
| i[r - 3] = arguments[r]; | |
| return e.call.apply(e, k0([s], C0(i), !1)); | |
| }, n.prototype.bind = function(t, e) { | |
| return e; | |
| }, n.prototype.enable = function() { | |
| return this; | |
| }, n.prototype.disable = function() { | |
| return this; | |
| }, n; | |
| }() | |
| ), R0 = function(n, t) { | |
| var e = typeof Symbol == "function" && n[Symbol.iterator]; | |
| if (!e) return n; | |
| var s = e.call(n), i, r = [], a; | |
| try { | |
| for (; (t === void 0 || t-- > 0) && !(i = s.next()).done; ) r.push(i.value); | |
| } catch (l) { | |
| a = { error: l }; | |
| } finally { | |
| try { | |
| i && !i.done && (e = s.return) && e.call(s); | |
| } finally { | |
| if (a) throw a.error; | |
| } | |
| } | |
| return r; | |
| }, P0 = function(n, t, e) { | |
| if (e || arguments.length === 2) for (var s = 0, i = t.length, r; s < i; s++) | |
| (r || !(s in t)) && (r || (r = Array.prototype.slice.call(t, 0, s)), r[s] = t[s]); | |
| return n.concat(r || Array.prototype.slice.call(t)); | |
| }, Dd = "context", M0 = new I0(), ny = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| } | |
| return n.getInstance = function() { | |
| return this._instance || (this._instance = new n()), this._instance; | |
| }, n.prototype.setGlobalContextManager = function(t) { | |
| return Rp(Dd, t, Nu.instance()); | |
| }, n.prototype.active = function() { | |
| return this._getContextManager().active(); | |
| }, n.prototype.with = function(t, e, s) { | |
| for (var i, r = [], a = 3; a < arguments.length; a++) | |
| r[a - 3] = arguments[a]; | |
| return (i = this._getContextManager()).with.apply(i, P0([t, e, s], R0(r), !1)); | |
| }, n.prototype.bind = function(t, e) { | |
| return this._getContextManager().bind(t, e); | |
| }, n.prototype._getContextManager = function() { | |
| return sc(Dd) || M0; | |
| }, n.prototype.disable = function() { | |
| this._getContextManager().disable(), Pp(Dd, Nu.instance()); | |
| }, n; | |
| }() | |
| ), af; | |
| (function(n) { | |
| n[n.NONE = 0] = "NONE", n[n.SAMPLED = 1] = "SAMPLED"; | |
| })(af || (af = {})); | |
| var ry = "0000000000000000", ay = "00000000000000000000000000000000", N0 = { | |
| traceId: ay, | |
| spanId: ry, | |
| traceFlags: af.NONE | |
| }, Il = ( | |
| /** @class */ | |
| function() { | |
| function n(t) { | |
| t === void 0 && (t = N0), this._spanContext = t; | |
| } | |
| return n.prototype.spanContext = function() { | |
| return this._spanContext; | |
| }, n.prototype.setAttribute = function(t, e) { | |
| return this; | |
| }, n.prototype.setAttributes = function(t) { | |
| return this; | |
| }, n.prototype.addEvent = function(t, e) { | |
| return this; | |
| }, n.prototype.addLink = function(t) { | |
| return this; | |
| }, n.prototype.addLinks = function(t) { | |
| return this; | |
| }, n.prototype.setStatus = function(t) { | |
| return this; | |
| }, n.prototype.updateName = function(t) { | |
| return this; | |
| }, n.prototype.end = function(t) { | |
| }, n.prototype.isRecording = function() { | |
| return !1; | |
| }, n.prototype.recordException = function(t, e) { | |
| }, n; | |
| }() | |
| ), Mp = E0("OpenTelemetry Context Key SPAN"); | |
| function Np(n) { | |
| return n.getValue(Mp) || void 0; | |
| } | |
| function O0() { | |
| return Np(ny.getInstance().active()); | |
| } | |
| function Op(n, t) { | |
| return n.setValue(Mp, t); | |
| } | |
| function L0(n) { | |
| return n.deleteValue(Mp); | |
| } | |
| function D0(n, t) { | |
| return Op(n, new Il(t)); | |
| } | |
| function oy(n) { | |
| var t; | |
| return (t = Np(n)) === null || t === void 0 ? void 0 : t.spanContext(); | |
| } | |
| var F0 = /^([0-9a-f]{32})$/i, $0 = /^[0-9a-f]{16}$/i; | |
| function j0(n) { | |
| return F0.test(n) && n !== ay; | |
| } | |
| function B0(n) { | |
| return $0.test(n) && n !== ry; | |
| } | |
| function ly(n) { | |
| return j0(n.traceId) && B0(n.spanId); | |
| } | |
| function H0(n) { | |
| return new Il(n); | |
| } | |
| var Fd = ny.getInstance(), cy = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| } | |
| return n.prototype.startSpan = function(t, e, s) { | |
| s === void 0 && (s = Fd.active()); | |
| var i = !!(e != null && e.root); | |
| if (i) | |
| return new Il(); | |
| var r = s && oy(s); | |
| return U0(r) && ly(r) ? new Il(r) : new Il(); | |
| }, n.prototype.startActiveSpan = function(t, e, s, i) { | |
| var r, a, l; | |
| if (!(arguments.length < 2)) { | |
| arguments.length === 2 ? l = e : arguments.length === 3 ? (r = e, l = s) : (r = e, a = s, l = i); | |
| var c = a ?? Fd.active(), h = this.startSpan(t, r, c), u = Op(c, h); | |
| return Fd.with(u, l, void 0, h); | |
| } | |
| }, n; | |
| }() | |
| ); | |
| function U0(n) { | |
| return typeof n == "object" && typeof n.spanId == "string" && typeof n.traceId == "string" && typeof n.traceFlags == "number"; | |
| } | |
| var z0 = new cy(), V0 = ( | |
| /** @class */ | |
| function() { | |
| function n(t, e, s, i) { | |
| this._provider = t, this.name = e, this.version = s, this.options = i; | |
| } | |
| return n.prototype.startSpan = function(t, e, s) { | |
| return this._getTracer().startSpan(t, e, s); | |
| }, n.prototype.startActiveSpan = function(t, e, s, i) { | |
| var r = this._getTracer(); | |
| return Reflect.apply(r.startActiveSpan, r, arguments); | |
| }, n.prototype._getTracer = function() { | |
| if (this._delegate) | |
| return this._delegate; | |
| var t = this._provider.getDelegateTracer(this.name, this.version, this.options); | |
| return t ? (this._delegate = t, this._delegate) : z0; | |
| }, n; | |
| }() | |
| ), G0 = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| } | |
| return n.prototype.getTracer = function(t, e, s) { | |
| return new cy(); | |
| }, n; | |
| }() | |
| ), q0 = new G0(), xg = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| } | |
| return n.prototype.getTracer = function(t, e, s) { | |
| var i; | |
| return (i = this.getDelegateTracer(t, e, s)) !== null && i !== void 0 ? i : new V0(this, t, e, s); | |
| }, n.prototype.getDelegate = function() { | |
| var t; | |
| return (t = this._delegate) !== null && t !== void 0 ? t : q0; | |
| }, n.prototype.setDelegate = function(t) { | |
| this._delegate = t; | |
| }, n.prototype.getDelegateTracer = function(t, e, s) { | |
| var i; | |
| return (i = this._delegate) === null || i === void 0 ? void 0 : i.getTracer(t, e, s); | |
| }, n; | |
| }() | |
| ), Ou; | |
| (function(n) { | |
| n[n.UNSET = 0] = "UNSET", n[n.OK = 1] = "OK", n[n.ERROR = 2] = "ERROR"; | |
| })(Ou || (Ou = {})); | |
| var $d = "trace", W0 = ( | |
| /** @class */ | |
| function() { | |
| function n() { | |
| this._proxyTracerProvider = new xg(), this.wrapSpanContext = H0, this.isSpanContextValid = ly, this.deleteSpan = L0, this.getSpan = Np, this.getActiveSpan = O0, this.getSpanContext = oy, this.setSpan = Op, this.setSpanContext = D0; | |
| } | |
| return n.getInstance = function() { | |
| return this._instance || (this._instance = new n()), this._instance; | |
| }, n.prototype.setGlobalTracerProvider = function(t) { | |
| var e = Rp($d, this._proxyTracerProvider, Nu.instance()); | |
| return e && this._proxyTracerProvider.setDelegate(t), e; | |
| }, n.prototype.getTracerProvider = function() { | |
| return sc($d) || this._proxyTracerProvider; | |
| }, n.prototype.getTracer = function(t, e) { | |
| return this.getTracerProvider().getTracer(t, e); | |
| }, n.prototype.disable = function() { | |
| Pp($d, Nu.instance()), this._proxyTracerProvider = new xg(); | |
| }, n; | |
| }() | |
| ), X0 = W0.getInstance(), Z0 = Object.defineProperty, Lp = (n, t) => { | |
| for (var e in t) | |
| Z0(n, e, { get: t[e], enumerable: !0 }); | |
| }; | |
| function Dp(n, { | |
| contentType: t, | |
| dataStreamVersion: e | |
| }) { | |
| const s = new Headers(n ?? {}); | |
| return s.has("Content-Type") || s.set("Content-Type", t), e !== void 0 && s.set("X-Vercel-AI-Data-Stream", e), s; | |
| } | |
| var hy = "AI_InvalidArgumentError", uy = `vercel.ai.error.${hy}`, Y0 = Symbol.for(uy), dy, Rt = class extends ht { | |
| constructor({ | |
| parameter: n, | |
| value: t, | |
| message: e | |
| }) { | |
| super({ | |
| name: hy, | |
| message: `Invalid argument for parameter ${n}: ${e}` | |
| }), this[dy] = !0, this.parameter = n, this.value = t; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, uy); | |
| } | |
| }; | |
| dy = Y0; | |
| var fy = "AI_RetryError", py = `vercel.ai.error.${fy}`, K0 = Symbol.for(py), gy, Tg = class extends ht { | |
| constructor({ | |
| message: n, | |
| reason: t, | |
| errors: e | |
| }) { | |
| super({ name: fy, message: n }), this[gy] = !0, this.reason = t, this.errors = e, this.lastError = e[e.length - 1]; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, py); | |
| } | |
| }; | |
| gy = K0; | |
| var J0 = ({ | |
| maxRetries: n = 2, | |
| initialDelayInMs: t = 2e3, | |
| backoffFactor: e = 2 | |
| } = {}) => async (s) => my(s, { | |
| maxRetries: n, | |
| delayInMs: t, | |
| backoffFactor: e | |
| }); | |
| async function my(n, { | |
| maxRetries: t, | |
| delayInMs: e, | |
| backoffFactor: s | |
| }, i = []) { | |
| try { | |
| return await n(); | |
| } catch (r) { | |
| if (Vh(r) || t === 0) | |
| throw r; | |
| const a = F_(r), l = [...i, r], c = l.length; | |
| if (c > t) | |
| throw new Tg({ | |
| message: `Failed after ${c} attempts. Last error: ${a}`, | |
| reason: "maxRetriesExceeded", | |
| errors: l | |
| }); | |
| if (r instanceof Error && hi.isInstance(r) && r.isRetryable === !0 && c <= t) | |
| return await D_(e), my( | |
| n, | |
| { maxRetries: t, delayInMs: s * e, backoffFactor: s }, | |
| l | |
| ); | |
| throw c === 1 ? r : new Tg({ | |
| message: `Failed after ${c} attempts with non-retryable error: '${a}'`, | |
| reason: "errorNotRetryable", | |
| errors: l | |
| }); | |
| } | |
| } | |
| function Q0({ | |
| maxRetries: n | |
| }) { | |
| if (n != null) { | |
| if (!Number.isInteger(n)) | |
| throw new Rt({ | |
| parameter: "maxRetries", | |
| value: n, | |
| message: "maxRetries must be an integer" | |
| }); | |
| if (n < 0) | |
| throw new Rt({ | |
| parameter: "maxRetries", | |
| value: n, | |
| message: "maxRetries must be >= 0" | |
| }); | |
| } | |
| const t = n ?? 2; | |
| return { | |
| maxRetries: t, | |
| retry: J0({ maxRetries: t }) | |
| }; | |
| } | |
| function jd({ | |
| operationId: n, | |
| telemetry: t | |
| }) { | |
| return { | |
| // standardized operation and resource name: | |
| "operation.name": `${n}${(t == null ? void 0 : t.functionId) != null ? ` ${t.functionId}` : ""}`, | |
| "resource.name": t == null ? void 0 : t.functionId, | |
| // detailed, AI SDK specific data: | |
| "ai.operationId": n, | |
| "ai.telemetry.functionId": t == null ? void 0 : t.functionId | |
| }; | |
| } | |
| function tS({ | |
| model: n, | |
| settings: t, | |
| telemetry: e, | |
| headers: s | |
| }) { | |
| var i; | |
| return { | |
| "ai.model.provider": n.provider, | |
| "ai.model.id": n.modelId, | |
| // settings: | |
| ...Object.entries(t).reduce((r, [a, l]) => (r[`ai.settings.${a}`] = l, r), {}), | |
| // add metadata as attributes: | |
| ...Object.entries((i = e == null ? void 0 : e.metadata) != null ? i : {}).reduce( | |
| (r, [a, l]) => (r[`ai.telemetry.metadata.${a}`] = l, r), | |
| {} | |
| ), | |
| // request headers | |
| ...Object.entries(s ?? {}).reduce((r, [a, l]) => (l !== void 0 && (r[`ai.request.headers.${a}`] = l), r), {}) | |
| }; | |
| } | |
| var eS = { | |
| startSpan() { | |
| return $h; | |
| }, | |
| startActiveSpan(n, t, e, s) { | |
| if (typeof t == "function") | |
| return t($h); | |
| if (typeof e == "function") | |
| return e($h); | |
| if (typeof s == "function") | |
| return s($h); | |
| } | |
| }, $h = { | |
| spanContext() { | |
| return sS; | |
| }, | |
| setAttribute() { | |
| return this; | |
| }, | |
| setAttributes() { | |
| return this; | |
| }, | |
| addEvent() { | |
| return this; | |
| }, | |
| addLink() { | |
| return this; | |
| }, | |
| addLinks() { | |
| return this; | |
| }, | |
| setStatus() { | |
| return this; | |
| }, | |
| updateName() { | |
| return this; | |
| }, | |
| end() { | |
| return this; | |
| }, | |
| isRecording() { | |
| return !1; | |
| }, | |
| recordException() { | |
| return this; | |
| } | |
| }, sS = { | |
| traceId: "", | |
| spanId: "", | |
| traceFlags: 0 | |
| }; | |
| function iS({ | |
| isEnabled: n = !1, | |
| tracer: t | |
| } = {}) { | |
| return n ? t || X0.getTracer("ai") : eS; | |
| } | |
| function Bd({ | |
| name: n, | |
| tracer: t, | |
| attributes: e, | |
| fn: s, | |
| endWhenDone: i = !0 | |
| }) { | |
| return t.startActiveSpan(n, { attributes: e }, async (r) => { | |
| try { | |
| const a = await s(r); | |
| return i && r.end(), a; | |
| } catch (a) { | |
| try { | |
| a instanceof Error ? (r.recordException({ | |
| name: a.name, | |
| message: a.message, | |
| stack: a.stack | |
| }), r.setStatus({ | |
| code: Ou.ERROR, | |
| message: a.message | |
| })) : r.setStatus({ code: Ou.ERROR }); | |
| } finally { | |
| r.end(); | |
| } | |
| throw a; | |
| } | |
| }); | |
| } | |
| function va({ | |
| telemetry: n, | |
| attributes: t | |
| }) { | |
| return (n == null ? void 0 : n.isEnabled) !== !0 ? {} : Object.entries(t).reduce((e, [s, i]) => { | |
| if (i === void 0) | |
| return e; | |
| if (typeof i == "object" && "input" in i && typeof i.input == "function") { | |
| if ((n == null ? void 0 : n.recordInputs) === !1) | |
| return e; | |
| const r = i.input(); | |
| return r === void 0 ? e : { ...e, [s]: r }; | |
| } | |
| if (typeof i == "object" && "output" in i && typeof i.output == "function") { | |
| if ((n == null ? void 0 : n.recordOutputs) === !1) | |
| return e; | |
| const r = i.output(); | |
| return r === void 0 ? e : { ...e, [s]: r }; | |
| } | |
| return { ...e, [s]: i }; | |
| }, {}); | |
| } | |
| var yy = "AI_NoObjectGeneratedError", by = `vercel.ai.error.${yy}`, nS = Symbol.for(by), vy, en = class extends ht { | |
| constructor({ | |
| message: n = "No object generated.", | |
| cause: t, | |
| text: e, | |
| response: s, | |
| usage: i | |
| }) { | |
| super({ name: yy, message: n, cause: t }), this[vy] = !0, this.text = e, this.response = s, this.usage = i; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, by); | |
| } | |
| }; | |
| vy = nS; | |
| var _y = "AI_DownloadError", Ay = `vercel.ai.error.${_y}`, rS = Symbol.for(Ay), wy, Hd = class extends ht { | |
| constructor({ | |
| url: n, | |
| statusCode: t, | |
| statusText: e, | |
| cause: s, | |
| message: i = s == null ? `Failed to download ${n}: ${t} ${e}` : `Failed to download ${n}: ${s}` | |
| }) { | |
| super({ name: _y, message: i, cause: s }), this[wy] = !0, this.url = n, this.statusCode = t, this.statusText = e; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Ay); | |
| } | |
| }; | |
| wy = rS; | |
| async function aS({ | |
| url: n, | |
| fetchImplementation: t = fetch | |
| }) { | |
| var e; | |
| const s = n.toString(); | |
| try { | |
| const i = await t(s); | |
| if (!i.ok) | |
| throw new Hd({ | |
| url: s, | |
| statusCode: i.status, | |
| statusText: i.statusText | |
| }); | |
| return { | |
| data: new Uint8Array(await i.arrayBuffer()), | |
| mimeType: (e = i.headers.get("content-type")) != null ? e : void 0 | |
| }; | |
| } catch (i) { | |
| throw Hd.isInstance(i) ? i : new Hd({ url: s, cause: i }); | |
| } | |
| } | |
| var oS = [ | |
| { mimeType: "image/gif", bytes: [71, 73, 70] }, | |
| { mimeType: "image/png", bytes: [137, 80, 78, 71] }, | |
| { mimeType: "image/jpeg", bytes: [255, 216] }, | |
| { mimeType: "image/webp", bytes: [82, 73, 70, 70] } | |
| ]; | |
| function lS(n) { | |
| for (const { bytes: t, mimeType: e } of oS) | |
| if (n.length >= t.length && t.every((s, i) => n[i] === s)) | |
| return e; | |
| } | |
| var Sy = "AI_InvalidDataContentError", Ey = `vercel.ai.error.${Sy}`, cS = Symbol.for(Ey), xy, Cg = class extends ht { | |
| constructor({ | |
| content: n, | |
| cause: t, | |
| message: e = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof n}.` | |
| }) { | |
| super({ name: Sy, message: e, cause: t }), this[xy] = !0, this.content = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Ey); | |
| } | |
| }; | |
| xy = cS; | |
| var Ty = w.union([ | |
| w.string(), | |
| w.instanceof(Uint8Array), | |
| w.instanceof(ArrayBuffer), | |
| w.custom( | |
| // Buffer might not be available in some environments such as CloudFlare: | |
| (n) => { | |
| var t, e; | |
| return (e = (t = globalThis.Buffer) == null ? void 0 : t.isBuffer(n)) != null ? e : !1; | |
| }, | |
| { message: "Must be a Buffer" } | |
| ) | |
| ]); | |
| function hS(n) { | |
| return typeof n == "string" ? n : n instanceof ArrayBuffer ? Jd(new Uint8Array(n)) : Jd(n); | |
| } | |
| function Lu(n) { | |
| if (n instanceof Uint8Array) | |
| return n; | |
| if (typeof n == "string") | |
| try { | |
| return K_(n); | |
| } catch (t) { | |
| throw new Cg({ | |
| message: "Invalid data content. Content string is not a base64-encoded media.", | |
| content: n, | |
| cause: t | |
| }); | |
| } | |
| if (n instanceof ArrayBuffer) | |
| return new Uint8Array(n); | |
| throw new Cg({ content: n }); | |
| } | |
| function uS(n) { | |
| try { | |
| return new TextDecoder().decode(n); | |
| } catch { | |
| throw new Error("Error decoding Uint8Array to text"); | |
| } | |
| } | |
| var Cy = "AI_InvalidMessageRoleError", ky = `vercel.ai.error.${Cy}`, dS = Symbol.for(ky), Iy, fS = class extends ht { | |
| constructor({ | |
| role: n, | |
| message: t = `Invalid message role: '${n}'. Must be one of: "system", "user", "assistant", "tool".` | |
| }) { | |
| super({ name: Cy, message: t }), this[Iy] = !0, this.role = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, ky); | |
| } | |
| }; | |
| Iy = dS; | |
| function pS(n) { | |
| try { | |
| const [t, e] = n.split(","); | |
| return { | |
| mimeType: t.split(";")[0].split(":")[1], | |
| base64Content: e | |
| }; | |
| } catch { | |
| return { | |
| mimeType: void 0, | |
| base64Content: void 0 | |
| }; | |
| } | |
| } | |
| async function kg({ | |
| prompt: n, | |
| modelSupportsImageUrls: t = !0, | |
| modelSupportsUrl: e = () => !1, | |
| downloadImplementation: s = aS | |
| }) { | |
| const i = await mS( | |
| n.messages, | |
| s, | |
| t, | |
| e | |
| ); | |
| return [ | |
| ...n.system != null ? [{ role: "system", content: n.system }] : [], | |
| ...n.messages.map( | |
| (r) => gS(r, i) | |
| ) | |
| ]; | |
| } | |
| function gS(n, t) { | |
| var e, s, i, r, a, l; | |
| const c = n.role; | |
| switch (c) { | |
| case "system": | |
| return { | |
| role: "system", | |
| content: n.content, | |
| providerMetadata: (e = n.providerOptions) != null ? e : n.experimental_providerMetadata | |
| }; | |
| case "user": | |
| return typeof n.content == "string" ? { | |
| role: "user", | |
| content: [{ type: "text", text: n.content }], | |
| providerMetadata: (s = n.providerOptions) != null ? s : n.experimental_providerMetadata | |
| } : { | |
| role: "user", | |
| content: n.content.map((h) => yS(h, t)).filter((h) => h.type !== "text" || h.text !== ""), | |
| providerMetadata: (i = n.providerOptions) != null ? i : n.experimental_providerMetadata | |
| }; | |
| case "assistant": | |
| return typeof n.content == "string" ? { | |
| role: "assistant", | |
| content: [{ type: "text", text: n.content }], | |
| providerMetadata: (r = n.providerOptions) != null ? r : n.experimental_providerMetadata | |
| } : { | |
| role: "assistant", | |
| content: n.content.filter( | |
| // remove empty text parts: | |
| (h) => h.type !== "text" || h.text !== "" | |
| ).map((h) => { | |
| const { experimental_providerMetadata: u, providerOptions: d, ...f } = h; | |
| return { | |
| ...f, | |
| providerMetadata: d ?? u | |
| }; | |
| }), | |
| providerMetadata: (a = n.providerOptions) != null ? a : n.experimental_providerMetadata | |
| }; | |
| case "tool": | |
| return { | |
| role: "tool", | |
| content: n.content.map((h) => { | |
| var u; | |
| return { | |
| type: "tool-result", | |
| toolCallId: h.toolCallId, | |
| toolName: h.toolName, | |
| result: h.result, | |
| content: h.experimental_content, | |
| isError: h.isError, | |
| providerMetadata: (u = h.providerOptions) != null ? u : h.experimental_providerMetadata | |
| }; | |
| }), | |
| providerMetadata: (l = n.providerOptions) != null ? l : n.experimental_providerMetadata | |
| }; | |
| default: { | |
| const h = c; | |
| throw new fS({ role: h }); | |
| } | |
| } | |
| } | |
| async function mS(n, t, e, s) { | |
| const i = n.filter((a) => a.role === "user").map((a) => a.content).filter( | |
| (a) => Array.isArray(a) | |
| ).flat().filter( | |
| (a) => a.type === "image" || a.type === "file" | |
| ).filter( | |
| (a) => !(a.type === "image" && e === !0) | |
| ).map((a) => a.type === "image" ? a.image : a.data).map( | |
| (a) => ( | |
| // support string urls: | |
| typeof a == "string" && (a.startsWith("http:") || a.startsWith("https:")) ? new URL(a) : a | |
| ) | |
| ).filter((a) => a instanceof URL).filter((a) => !s(a)), r = await Promise.all( | |
| i.map(async (a) => ({ | |
| url: a, | |
| data: await t({ url: a }) | |
| })) | |
| ); | |
| return Object.fromEntries( | |
| r.map(({ url: a, data: l }) => [a.toString(), l]) | |
| ); | |
| } | |
| function yS(n, t) { | |
| var e, s, i, r; | |
| if (n.type === "text") | |
| return { | |
| type: "text", | |
| text: n.text, | |
| providerMetadata: (e = n.providerOptions) != null ? e : n.experimental_providerMetadata | |
| }; | |
| let a = n.mimeType, l, c, h; | |
| const u = n.type; | |
| switch (u) { | |
| case "image": | |
| l = n.image; | |
| break; | |
| case "file": | |
| l = n.data; | |
| break; | |
| default: | |
| throw new Error(`Unsupported part type: ${u}`); | |
| } | |
| try { | |
| c = typeof l == "string" ? new URL(l) : l; | |
| } catch { | |
| c = l; | |
| } | |
| if (c instanceof URL) | |
| if (c.protocol === "data:") { | |
| const { mimeType: d, base64Content: f } = pS( | |
| c.toString() | |
| ); | |
| if (d == null || f == null) | |
| throw new Error(`Invalid data URL format in part ${u}`); | |
| a = d, h = Lu(f); | |
| } else { | |
| const d = t[c.toString()]; | |
| d ? (h = d.data, a ?? (a = d.mimeType)) : h = c; | |
| } | |
| else | |
| h = Lu(c); | |
| switch (u) { | |
| case "image": | |
| return h instanceof Uint8Array && (a = (s = lS(h)) != null ? s : a), { | |
| type: "image", | |
| image: h, | |
| mimeType: a, | |
| providerMetadata: (i = n.providerOptions) != null ? i : n.experimental_providerMetadata | |
| }; | |
| case "file": { | |
| if (a == null) | |
| throw new Error("Mime type is missing for file part"); | |
| return { | |
| type: "file", | |
| data: h instanceof Uint8Array ? hS(h) : h, | |
| mimeType: a, | |
| providerMetadata: (r = n.providerOptions) != null ? r : n.experimental_providerMetadata | |
| }; | |
| } | |
| } | |
| } | |
| function Ig({ | |
| maxTokens: n, | |
| temperature: t, | |
| topP: e, | |
| topK: s, | |
| presencePenalty: i, | |
| frequencyPenalty: r, | |
| stopSequences: a, | |
| seed: l | |
| }) { | |
| if (n != null) { | |
| if (!Number.isInteger(n)) | |
| throw new Rt({ | |
| parameter: "maxTokens", | |
| value: n, | |
| message: "maxTokens must be an integer" | |
| }); | |
| if (n < 1) | |
| throw new Rt({ | |
| parameter: "maxTokens", | |
| value: n, | |
| message: "maxTokens must be >= 1" | |
| }); | |
| } | |
| if (t != null && typeof t != "number") | |
| throw new Rt({ | |
| parameter: "temperature", | |
| value: t, | |
| message: "temperature must be a number" | |
| }); | |
| if (e != null && typeof e != "number") | |
| throw new Rt({ | |
| parameter: "topP", | |
| value: e, | |
| message: "topP must be a number" | |
| }); | |
| if (s != null && typeof s != "number") | |
| throw new Rt({ | |
| parameter: "topK", | |
| value: s, | |
| message: "topK must be a number" | |
| }); | |
| if (i != null && typeof i != "number") | |
| throw new Rt({ | |
| parameter: "presencePenalty", | |
| value: i, | |
| message: "presencePenalty must be a number" | |
| }); | |
| if (r != null && typeof r != "number") | |
| throw new Rt({ | |
| parameter: "frequencyPenalty", | |
| value: r, | |
| message: "frequencyPenalty must be a number" | |
| }); | |
| if (l != null && !Number.isInteger(l)) | |
| throw new Rt({ | |
| parameter: "seed", | |
| value: l, | |
| message: "seed must be an integer" | |
| }); | |
| return { | |
| maxTokens: n, | |
| temperature: t ?? 0, | |
| topP: e, | |
| topK: s, | |
| presencePenalty: i, | |
| frequencyPenalty: r, | |
| stopSequences: a != null && a.length > 0 ? a : void 0, | |
| seed: l | |
| }; | |
| } | |
| function bS(n) { | |
| var t, e, s; | |
| const i = []; | |
| for (const r of n) { | |
| let a; | |
| try { | |
| a = new URL(r.url); | |
| } catch { | |
| throw new Error(`Invalid URL: ${r.url}`); | |
| } | |
| switch (a.protocol) { | |
| case "http:": | |
| case "https:": { | |
| if ((t = r.contentType) != null && t.startsWith("image/")) | |
| i.push({ type: "image", image: a }); | |
| else { | |
| if (!r.contentType) | |
| throw new Error( | |
| "If the attachment is not an image, it must specify a content type" | |
| ); | |
| i.push({ | |
| type: "file", | |
| data: a, | |
| mimeType: r.contentType | |
| }); | |
| } | |
| break; | |
| } | |
| case "data:": { | |
| let l, c, h; | |
| try { | |
| [l, c] = r.url.split(","), h = l.split(";")[0].split(":")[1]; | |
| } catch { | |
| throw new Error(`Error processing data URL: ${r.url}`); | |
| } | |
| if (h == null || c == null) | |
| throw new Error(`Invalid data URL format: ${r.url}`); | |
| if ((e = r.contentType) != null && e.startsWith("image/")) | |
| i.push({ | |
| type: "image", | |
| image: Lu(c) | |
| }); | |
| else if ((s = r.contentType) != null && s.startsWith("text/")) | |
| i.push({ | |
| type: "text", | |
| text: uS( | |
| Lu(c) | |
| ) | |
| }); | |
| else { | |
| if (!r.contentType) | |
| throw new Error( | |
| "If the attachment is not an image or text, it must specify a content type" | |
| ); | |
| i.push({ | |
| type: "file", | |
| data: c, | |
| mimeType: r.contentType | |
| }); | |
| } | |
| break; | |
| } | |
| default: | |
| throw new Error(`Unsupported URL protocol: ${a.protocol}`); | |
| } | |
| } | |
| return i; | |
| } | |
| var Ry = "AI_MessageConversionError", Py = `vercel.ai.error.${Ry}`, vS = Symbol.for(Py), My, Ud = class extends ht { | |
| constructor({ | |
| originalMessage: n, | |
| message: t | |
| }) { | |
| super({ name: Ry, message: t }), this[My] = !0, this.originalMessage = n; | |
| } | |
| static isInstance(n) { | |
| return ht.hasMarker(n, Py); | |
| } | |
| }; | |
| My = vS; | |
| function _S(n, t) { | |
| var e, s; | |
| const i = (e = t == null ? void 0 : t.tools) != null ? e : {}, r = []; | |
| for (let a = 0; a < n.length; a++) { | |
| const l = n[a], c = a === n.length - 1, { role: h, content: u, experimental_attachments: d } = l; | |
| switch (h) { | |
| case "system": { | |
| r.push({ | |
| role: "system", | |
| content: u | |
| }); | |
| break; | |
| } | |
| case "user": { | |
| r.push({ | |
| role: "user", | |
| content: d ? [ | |
| { type: "text", text: u }, | |
| ...bS(d) | |
| ] : u | |
| }); | |
| break; | |
| } | |
| case "assistant": { | |
| if (l.parts != null) { | |
| let m = function() { | |
| const S = []; | |
| for (const x of A) | |
| switch (x.type) { | |
| case "text": | |
| S.push({ | |
| type: "text", | |
| text: x.text | |
| }); | |
| break; | |
| case "reasoning": { | |
| for (const T of x.details) | |
| switch (T.type) { | |
| case "text": | |
| S.push({ | |
| type: "reasoning", | |
| text: T.text, | |
| signature: T.signature | |
| }); | |
| break; | |
| case "redacted": | |
| S.push({ | |
| type: "redacted-reasoning", | |
| data: T.data | |
| }); | |
| break; | |
| } | |
| break; | |
| } | |
| case "tool-invocation": | |
| S.push({ | |
| type: "tool-call", | |
| toolCallId: x.toolInvocation.toolCallId, | |
| toolName: x.toolInvocation.toolName, | |
| args: x.toolInvocation.args | |
| }); | |
| break; | |
| default: { | |
| const T = x; | |
| throw new Error(`Unsupported part: ${T}`); | |
| } | |
| } | |
| r.push({ | |
| role: "assistant", | |
| content: S | |
| }); | |
| const E = A.filter( | |
| (x) => x.type === "tool-invocation" | |
| ).map((x) => x.toolInvocation); | |
| E.length > 0 && r.push({ | |
| role: "tool", | |
| content: E.map( | |
| (x) => { | |
| if (!("result" in x)) | |
| throw new Ud({ | |
| originalMessage: l, | |
| message: "ToolInvocation must have a result: " + JSON.stringify(x) | |
| }); | |
| const { toolCallId: T, toolName: k, result: C } = x, P = i[k]; | |
| return (P == null ? void 0 : P.experimental_toToolResultContent) != null ? { | |
| type: "tool-result", | |
| toolCallId: T, | |
| toolName: k, | |
| result: P.experimental_toToolResultContent(C), | |
| experimental_content: P.experimental_toToolResultContent(C) | |
| } : { | |
| type: "tool-result", | |
| toolCallId: T, | |
| toolName: k, | |
| result: C | |
| }; | |
| } | |
| ) | |
| }), A = [], _ = !1, y++; | |
| }, y = 0, _ = !1, A = []; | |
| for (const S of l.parts) | |
| switch (S.type) { | |
| case "reasoning": | |
| A.push(S); | |
| break; | |
| case "text": { | |
| _ && m(), A.push(S); | |
| break; | |
| } | |
| case "tool-invocation": { | |
| ((s = S.toolInvocation.step) != null ? s : 0) !== y && m(), A.push(S), _ = !0; | |
| break; | |
| } | |
| } | |
| m(); | |
| break; | |
| } | |
| const f = l.toolInvocations; | |
| if (f == null || f.length === 0) { | |
| r.push({ role: "assistant", content: u }); | |
| break; | |
| } | |
| const g = f.reduce((m, y) => { | |
| var _; | |
| return Math.max(m, (_ = y.step) != null ? _ : 0); | |
| }, 0); | |
| for (let m = 0; m <= g; m++) { | |
| const y = f.filter( | |
| (_) => { | |
| var A; | |
| return ((A = _.step) != null ? A : 0) === m; | |
| } | |
| ); | |
| y.length !== 0 && (r.push({ | |
| role: "assistant", | |
| content: [ | |
| ...c && u && m === 0 ? [{ type: "text", text: u }] : [], | |
| ...y.map( | |
| ({ toolCallId: _, toolName: A, args: S }) => ({ | |
| type: "tool-call", | |
| toolCallId: _, | |
| toolName: A, | |
| args: S | |
| }) | |
| ) | |
| ] | |
| }), r.push({ | |
| role: "tool", | |
| content: y.map((_) => { | |
| if (!("result" in _)) | |
| throw new Ud({ | |
| originalMessage: l, | |
| message: "ToolInvocation must have a result: " + JSON.stringify(_) | |
| }); | |
| const { toolCallId: A, toolName: S, result: E } = _, x = i[S]; | |
| return (x == null ? void 0 : x.experimental_toToolResultContent) != null ? { | |
| type: "tool-result", | |
| toolCallId: A, | |
| toolName: S, | |
| result: x.experimental_toToolResultContent(E), | |
| experimental_content: x.experimental_toToolResultContent(E) | |
| } : { | |
| type: "tool-result", | |
| toolCallId: A, | |
| toolName: S, | |
| result: E | |
| }; | |
| }) | |
| })); | |
| } | |
| u && !c && r.push({ role: "assistant", content: u }); | |
| break; | |
| } | |
| case "data": | |
| break; | |
| default: { | |
| const f = h; | |
| throw new Ud({ | |
| originalMessage: l, | |
| message: `Unsupported role: ${f}` | |
| }); | |
| } | |
| } | |
| } | |
| return r; | |
| } | |
| function AS(n) { | |
| if (!Array.isArray(n)) | |
| return "other"; | |
| if (n.length === 0) | |
| return "messages"; | |
| const t = n.map(wS); | |
| return t.some((e) => e === "has-ui-specific-parts") ? "ui-messages" : t.every( | |
| (e) => e === "has-core-specific-parts" || e === "message" | |
| ) ? "messages" : "other"; | |
| } | |
| function wS(n) { | |
| return typeof n == "object" && n !== null && (n.role === "function" || // UI-only role | |
| n.role === "data" || // UI-only role | |
| "toolInvocations" in n || // UI-specific field | |
| "experimental_attachments" in n) ? "has-ui-specific-parts" : typeof n == "object" && n !== null && "content" in n && (Array.isArray(n.content) || // Core messages can have array content | |
| "experimental_providerMetadata" in n || "providerOptions" in n) ? "has-core-specific-parts" : typeof n == "object" && n !== null && "role" in n && "content" in n && typeof n.content == "string" && ["system", "user", "assistant", "tool"].includes(n.role) ? "message" : "other"; | |
| } | |
| var of = w.lazy( | |
| () => w.union([ | |
| w.null(), | |
| w.string(), | |
| w.number(), | |
| w.boolean(), | |
| w.record(w.string(), of), | |
| w.array(of) | |
| ]) | |
| ), Bt = w.record( | |
| w.string(), | |
| w.record(w.string(), of) | |
| ), SS = w.array( | |
| w.union([ | |
| w.object({ type: w.literal("text"), text: w.string() }), | |
| w.object({ | |
| type: w.literal("image"), | |
| data: w.string(), | |
| mimeType: w.string().optional() | |
| }) | |
| ]) | |
| ), Ny = w.object({ | |
| type: w.literal("text"), | |
| text: w.string(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), ES = w.object({ | |
| type: w.literal("image"), | |
| image: w.union([Ty, w.instanceof(URL)]), | |
| mimeType: w.string().optional(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), xS = w.object({ | |
| type: w.literal("file"), | |
| data: w.union([Ty, w.instanceof(URL)]), | |
| mimeType: w.string(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), TS = w.object({ | |
| type: w.literal("reasoning"), | |
| text: w.string(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), CS = w.object({ | |
| type: w.literal("redacted-reasoning"), | |
| data: w.string(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), kS = w.object({ | |
| type: w.literal("tool-call"), | |
| toolCallId: w.string(), | |
| toolName: w.string(), | |
| args: w.unknown(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), IS = w.object({ | |
| type: w.literal("tool-result"), | |
| toolCallId: w.string(), | |
| toolName: w.string(), | |
| result: w.unknown(), | |
| content: SS.optional(), | |
| isError: w.boolean().optional(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), RS = w.object({ | |
| role: w.literal("system"), | |
| content: w.string(), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), PS = w.object({ | |
| role: w.literal("user"), | |
| content: w.union([ | |
| w.string(), | |
| w.array(w.union([Ny, ES, xS])) | |
| ]), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), MS = w.object({ | |
| role: w.literal("assistant"), | |
| content: w.union([ | |
| w.string(), | |
| w.array( | |
| w.union([ | |
| Ny, | |
| TS, | |
| CS, | |
| kS | |
| ]) | |
| ) | |
| ]), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), NS = w.object({ | |
| role: w.literal("tool"), | |
| content: w.array(IS), | |
| providerOptions: Bt.optional(), | |
| experimental_providerMetadata: Bt.optional() | |
| }), OS = w.union([ | |
| RS, | |
| PS, | |
| MS, | |
| NS | |
| ]); | |
| function Rg({ | |
| prompt: n, | |
| tools: t | |
| }) { | |
| if (n.prompt == null && n.messages == null) | |
| throw new Zn({ | |
| prompt: n, | |
| message: "prompt or messages must be defined" | |
| }); | |
| if (n.prompt != null && n.messages != null) | |
| throw new Zn({ | |
| prompt: n, | |
| message: "prompt and messages cannot be defined at the same time" | |
| }); | |
| if (n.system != null && typeof n.system != "string") | |
| throw new Zn({ | |
| prompt: n, | |
| message: "system must be a string" | |
| }); | |
| if (n.prompt != null) { | |
| if (typeof n.prompt != "string") | |
| throw new Zn({ | |
| prompt: n, | |
| message: "prompt must be a string" | |
| }); | |
| return { | |
| type: "prompt", | |
| system: n.system, | |
| messages: [ | |
| { | |
| role: "user", | |
| content: n.prompt | |
| } | |
| ] | |
| }; | |
| } | |
| if (n.messages != null) { | |
| const e = AS(n.messages); | |
| if (e === "other") | |
| throw new Zn({ | |
| prompt: n, | |
| message: "messages must be an array of CoreMessage or UIMessage" | |
| }); | |
| const s = e === "ui-messages" ? _S(n.messages, { | |
| tools: t | |
| }) : n.messages, i = ca({ | |
| value: s, | |
| schema: w.array(OS) | |
| }); | |
| if (!i.success) | |
| throw new Zn({ | |
| prompt: n, | |
| message: "messages must be an array of CoreMessage or UIMessage", | |
| cause: i.error | |
| }); | |
| return { | |
| type: "messages", | |
| messages: s, | |
| system: n.system | |
| }; | |
| } | |
| throw new Error("unreachable"); | |
| } | |
| function _a({ | |
| promptTokens: n, | |
| completionTokens: t | |
| }) { | |
| return { | |
| promptTokens: n, | |
| completionTokens: t, | |
| totalTokens: n + t | |
| }; | |
| } | |
| var LS = "JSON schema:", DS = "You MUST answer with a JSON object that matches the JSON schema above.", FS = "You MUST answer with JSON."; | |
| function lf({ | |
| prompt: n, | |
| schema: t, | |
| schemaPrefix: e = t != null ? LS : void 0, | |
| schemaSuffix: s = t != null ? DS : FS | |
| }) { | |
| return [ | |
| n != null && n.length > 0 ? n : void 0, | |
| n != null && n.length > 0 ? "" : void 0, | |
| // add a newline if prompt is not null | |
| e, | |
| t != null ? JSON.stringify(t) : void 0, | |
| s | |
| ].filter((i) => i != null).join(` | |
| `); | |
| } | |
| function $S(n) { | |
| const t = n.pipeThrough(new TransformStream()); | |
| return t[Symbol.asyncIterator] = () => { | |
| const e = t.getReader(); | |
| return { | |
| async next() { | |
| const { done: s, value: i } = await e.read(); | |
| return s ? { done: !0, value: void 0 } : { done: !1, value: i }; | |
| } | |
| }; | |
| }, t; | |
| } | |
| var jS = { | |
| type: "no-schema", | |
| jsonSchema: void 0, | |
| validatePartialResult({ value: n, textDelta: t }) { | |
| return { success: !0, value: { partial: n, textDelta: t } }; | |
| }, | |
| validateFinalResult(n, t) { | |
| return n === void 0 ? { | |
| success: !1, | |
| error: new en({ | |
| message: "No object generated: response did not match schema.", | |
| text: t.text, | |
| response: t.response, | |
| usage: t.usage | |
| }) | |
| } : { success: !0, value: n }; | |
| }, | |
| createElementStream() { | |
| throw new oe({ | |
| functionality: "element streams in no-schema mode" | |
| }); | |
| } | |
| }, BS = (n) => ({ | |
| type: "object", | |
| jsonSchema: n.jsonSchema, | |
| validatePartialResult({ value: t, textDelta: e }) { | |
| return { | |
| success: !0, | |
| value: { | |
| // Note: currently no validation of partial results: | |
| partial: t, | |
| textDelta: e | |
| } | |
| }; | |
| }, | |
| validateFinalResult(t) { | |
| return ca({ value: t, schema: n }); | |
| }, | |
| createElementStream() { | |
| throw new oe({ | |
| functionality: "element streams in object mode" | |
| }); | |
| } | |
| }), HS = (n) => { | |
| const { $schema: t, ...e } = n.jsonSchema; | |
| return { | |
| type: "enum", | |
| // wrap in object that contains array of elements, since most LLMs will not | |
| // be able to generate an array directly: | |
| // possible future optimization: use arrays directly when model supports grammar-guided generation | |
| jsonSchema: { | |
| $schema: "http://json-schema.org/draft-07/schema#", | |
| type: "object", | |
| properties: { | |
| elements: { type: "array", items: e } | |
| }, | |
| required: ["elements"], | |
| additionalProperties: !1 | |
| }, | |
| validatePartialResult({ value: s, latestObject: i, isFirstDelta: r, isFinalDelta: a }) { | |
| var l; | |
| if (!Kd(s) || !pg(s.elements)) | |
| return { | |
| success: !1, | |
| error: new Zi({ | |
| value: s, | |
| cause: "value must be an object that contains an array of elements" | |
| }) | |
| }; | |
| const c = s.elements, h = []; | |
| for (let f = 0; f < c.length; f++) { | |
| const g = c[f], m = ca({ value: g, schema: n }); | |
| if (!(f === c.length - 1 && !a)) { | |
| if (!m.success) | |
| return m; | |
| h.push(m.value); | |
| } | |
| } | |
| const u = (l = i == null ? void 0 : i.length) != null ? l : 0; | |
| let d = ""; | |
| return r && (d += "["), u > 0 && (d += ","), d += h.slice(u).map((f) => JSON.stringify(f)).join(","), a && (d += "]"), { | |
| success: !0, | |
| value: { | |
| partial: h, | |
| textDelta: d | |
| } | |
| }; | |
| }, | |
| validateFinalResult(s) { | |
| if (!Kd(s) || !pg(s.elements)) | |
| return { | |
| success: !1, | |
| error: new Zi({ | |
| value: s, | |
| cause: "value must be an object that contains an array of elements" | |
| }) | |
| }; | |
| const i = s.elements; | |
| for (const r of i) { | |
| const a = ca({ value: r, schema: n }); | |
| if (!a.success) | |
| return a; | |
| } | |
| return { success: !0, value: i }; | |
| }, | |
| createElementStream(s) { | |
| let i = 0; | |
| return $S( | |
| s.pipeThrough( | |
| new TransformStream({ | |
| transform(r, a) { | |
| switch (r.type) { | |
| case "object": { | |
| const l = r.object; | |
| for (; i < l.length; i++) | |
| a.enqueue(l[i]); | |
| break; | |
| } | |
| case "text-delta": | |
| case "finish": | |
| case "error": | |
| break; | |
| default: { | |
| const l = r; | |
| throw new Error( | |
| `Unsupported chunk type: ${l}` | |
| ); | |
| } | |
| } | |
| } | |
| }) | |
| ) | |
| ); | |
| } | |
| }; | |
| }, US = (n) => ({ | |
| type: "enum", | |
| // wrap in object that contains result, since most LLMs will not | |
| // be able to generate an enum value directly: | |
| // possible future optimization: use enums directly when model supports top-level enums | |
| jsonSchema: { | |
| $schema: "http://json-schema.org/draft-07/schema#", | |
| type: "object", | |
| properties: { | |
| result: { type: "string", enum: n } | |
| }, | |
| required: ["result"], | |
| additionalProperties: !1 | |
| }, | |
| validateFinalResult(t) { | |
| if (!Kd(t) || typeof t.result != "string") | |
| return { | |
| success: !1, | |
| error: new Zi({ | |
| value: t, | |
| cause: 'value must be an object that contains a string in the "result" property.' | |
| }) | |
| }; | |
| const e = t.result; | |
| return n.includes(e) ? { success: !0, value: e } : { | |
| success: !1, | |
| error: new Zi({ | |
| value: t, | |
| cause: "value must be a string in the enum" | |
| }) | |
| }; | |
| }, | |
| validatePartialResult() { | |
| throw new oe({ | |
| functionality: "partial results in enum mode" | |
| }); | |
| }, | |
| createElementStream() { | |
| throw new oe({ | |
| functionality: "element streams in enum mode" | |
| }); | |
| } | |
| }); | |
| function zS({ | |
| output: n, | |
| schema: t, | |
| enumValues: e | |
| }) { | |
| switch (n) { | |
| case "object": | |
| return BS(rf(t)); | |
| case "array": | |
| return HS(rf(t)); | |
| case "enum": | |
| return US(e); | |
| case "no-schema": | |
| return jS; | |
| default: { | |
| const s = n; | |
| throw new Error(`Unsupported output: ${s}`); | |
| } | |
| } | |
| } | |
| function VS({ | |
| output: n, | |
| mode: t, | |
| schema: e, | |
| schemaName: s, | |
| schemaDescription: i, | |
| enumValues: r | |
| }) { | |
| if (n != null && n !== "object" && n !== "array" && n !== "enum" && n !== "no-schema") | |
| throw new Rt({ | |
| parameter: "output", | |
| value: n, | |
| message: "Invalid output type." | |
| }); | |
| if (n === "no-schema") { | |
| if (t === "auto" || t === "tool") | |
| throw new Rt({ | |
| parameter: "mode", | |
| value: t, | |
| message: 'Mode must be "json" for no-schema output.' | |
| }); | |
| if (e != null) | |
| throw new Rt({ | |
| parameter: "schema", | |
| value: e, | |
| message: "Schema is not supported for no-schema output." | |
| }); | |
| if (i != null) | |
| throw new Rt({ | |
| parameter: "schemaDescription", | |
| value: i, | |
| message: "Schema description is not supported for no-schema output." | |
| }); | |
| if (s != null) | |
| throw new Rt({ | |
| parameter: "schemaName", | |
| value: s, | |
| message: "Schema name is not supported for no-schema output." | |
| }); | |
| if (r != null) | |
| throw new Rt({ | |
| parameter: "enumValues", | |
| value: r, | |
| message: "Enum values are not supported for no-schema output." | |
| }); | |
| } | |
| if (n === "object") { | |
| if (e == null) | |
| throw new Rt({ | |
| parameter: "schema", | |
| value: e, | |
| message: "Schema is required for object output." | |
| }); | |
| if (r != null) | |
| throw new Rt({ | |
| parameter: "enumValues", | |
| value: r, | |
| message: "Enum values are not supported for object output." | |
| }); | |
| } | |
| if (n === "array") { | |
| if (e == null) | |
| throw new Rt({ | |
| parameter: "schema", | |
| value: e, | |
| message: "Element schema is required for array output." | |
| }); | |
| if (r != null) | |
| throw new Rt({ | |
| parameter: "enumValues", | |
| value: r, | |
| message: "Enum values are not supported for array output." | |
| }); | |
| } | |
| if (n === "enum") { | |
| if (e != null) | |
| throw new Rt({ | |
| parameter: "schema", | |
| value: e, | |
| message: "Schema is not supported for enum output." | |
| }); | |
| if (i != null) | |
| throw new Rt({ | |
| parameter: "schemaDescription", | |
| value: i, | |
| message: "Schema description is not supported for enum output." | |
| }); | |
| if (s != null) | |
| throw new Rt({ | |
| parameter: "schemaName", | |
| value: s, | |
| message: "Schema name is not supported for enum output." | |
| }); | |
| if (r == null) | |
| throw new Rt({ | |
| parameter: "enumValues", | |
| value: r, | |
| message: "Enum values are required for enum output." | |
| }); | |
| for (const a of r) | |
| if (typeof a != "string") | |
| throw new Rt({ | |
| parameter: "enumValues", | |
| value: a, | |
| message: "Enum values must be strings." | |
| }); | |
| } | |
| } | |
| var GS = ya({ prefix: "aiobj", size: 24 }); | |
| async function qS({ | |
| model: n, | |
| enum: t, | |
| // rename bc enum is reserved by typescript | |
| schema: e, | |
| schemaName: s, | |
| schemaDescription: i, | |
| mode: r, | |
| output: a = "object", | |
| system: l, | |
| prompt: c, | |
| messages: h, | |
| maxRetries: u, | |
| abortSignal: d, | |
| headers: f, | |
| experimental_repairText: g, | |
| experimental_telemetry: m, | |
| experimental_providerMetadata: y, | |
| providerOptions: _ = y, | |
| _internal: { | |
| generateId: A = GS, | |
| currentDate: S = () => /* @__PURE__ */ new Date() | |
| } = {}, | |
| ...E | |
| }) { | |
| VS({ | |
| output: a, | |
| mode: r, | |
| schema: e, | |
| schemaName: s, | |
| schemaDescription: i, | |
| enumValues: t | |
| }); | |
| const { maxRetries: x, retry: T } = Q0({ maxRetries: u }), k = zS({ | |
| output: a, | |
| schema: e, | |
| enumValues: t | |
| }); | |
| k.type === "no-schema" && r === void 0 && (r = "json"); | |
| const C = tS({ | |
| model: n, | |
| telemetry: m, | |
| headers: f, | |
| settings: { ...E, maxRetries: x } | |
| }), P = iS(m); | |
| return Bd({ | |
| name: "ai.generateObject", | |
| attributes: va({ | |
| telemetry: m, | |
| attributes: { | |
| ...jd({ | |
| operationId: "ai.generateObject", | |
| telemetry: m | |
| }), | |
| ...C, | |
| // specific settings that only make sense on the outer level: | |
| "ai.prompt": { | |
| input: () => JSON.stringify({ system: l, prompt: c, messages: h }) | |
| }, | |
| "ai.schema": k.jsonSchema != null ? { input: () => JSON.stringify(k.jsonSchema) } : void 0, | |
| "ai.schema.name": s, | |
| "ai.schema.description": i, | |
| "ai.settings.output": k.type, | |
| "ai.settings.mode": r | |
| } | |
| }), | |
| tracer: P, | |
| fn: async (j) => { | |
| var Z, V, dt, gt; | |
| (r === "auto" || r == null) && (r = n.defaultObjectGenerationMode); | |
| let Y, xt, M, z, ot, kt, yt, Q, Vt; | |
| switch (r) { | |
| case "json": { | |
| const Tt = Rg({ | |
| prompt: { | |
| system: k.jsonSchema == null ? lf({ prompt: l }) : n.supportsStructuredOutputs ? l : lf({ | |
| prompt: l, | |
| schema: k.jsonSchema | |
| }), | |
| prompt: c, | |
| messages: h | |
| }, | |
| tools: void 0 | |
| }), St = await kg({ | |
| prompt: Tt, | |
| modelSupportsImageUrls: n.supportsImageUrls, | |
| modelSupportsUrl: (Z = n.supportsUrl) == null ? void 0 : Z.bind(n) | |
| // support 'this' context | |
| }), tt = await T( | |
| () => Bd({ | |
| name: "ai.generateObject.doGenerate", | |
| attributes: va({ | |
| telemetry: m, | |
| attributes: { | |
| ...jd({ | |
| operationId: "ai.generateObject.doGenerate", | |
| telemetry: m | |
| }), | |
| ...C, | |
| "ai.prompt.format": { | |
| input: () => Tt.type | |
| }, | |
| "ai.prompt.messages": { | |
| input: () => JSON.stringify(St) | |
| }, | |
| "ai.settings.mode": r, | |
| // standardized gen-ai llm span attributes: | |
| "gen_ai.system": n.provider, | |
| "gen_ai.request.model": n.modelId, | |
| "gen_ai.request.frequency_penalty": E.frequencyPenalty, | |
| "gen_ai.request.max_tokens": E.maxTokens, | |
| "gen_ai.request.presence_penalty": E.presencePenalty, | |
| "gen_ai.request.temperature": E.temperature, | |
| "gen_ai.request.top_k": E.topK, | |
| "gen_ai.request.top_p": E.topP | |
| } | |
| }), | |
| tracer: P, | |
| fn: async (Qt) => { | |
| var Vn, Gn, Ko, Jo, Qo, tl; | |
| const le = await n.doGenerate({ | |
| mode: { | |
| type: "object-json", | |
| schema: k.jsonSchema, | |
| name: s, | |
| description: i | |
| }, | |
| ...Ig(E), | |
| inputFormat: Tt.type, | |
| prompt: St, | |
| providerMetadata: _, | |
| abortSignal: d, | |
| headers: f | |
| }), zs = { | |
| id: (Gn = (Vn = le.response) == null ? void 0 : Vn.id) != null ? Gn : A(), | |
| timestamp: (Jo = (Ko = le.response) == null ? void 0 : Ko.timestamp) != null ? Jo : S(), | |
| modelId: (tl = (Qo = le.response) == null ? void 0 : Qo.modelId) != null ? tl : n.modelId | |
| }; | |
| if (le.text === void 0) | |
| throw new en({ | |
| message: "No object generated: the model did not return a response.", | |
| response: zs, | |
| usage: _a(le.usage) | |
| }); | |
| return Qt.setAttributes( | |
| va({ | |
| telemetry: m, | |
| attributes: { | |
| "ai.response.finishReason": le.finishReason, | |
| "ai.response.object": { output: () => le.text }, | |
| "ai.response.id": zs.id, | |
| "ai.response.model": zs.modelId, | |
| "ai.response.timestamp": zs.timestamp.toISOString(), | |
| "ai.usage.promptTokens": le.usage.promptTokens, | |
| "ai.usage.completionTokens": le.usage.completionTokens, | |
| // standardized gen-ai llm span attributes: | |
| "gen_ai.response.finish_reasons": [le.finishReason], | |
| "gen_ai.response.id": zs.id, | |
| "gen_ai.response.model": zs.modelId, | |
| "gen_ai.usage.prompt_tokens": le.usage.promptTokens, | |
| "gen_ai.usage.completion_tokens": le.usage.completionTokens | |
| } | |
| }) | |
| ), { ...le, objectText: le.text, responseData: zs }; | |
| } | |
| }) | |
| ); | |
| Y = tt.objectText, xt = tt.finishReason, M = tt.usage, z = tt.warnings, ot = tt.rawResponse, Q = tt.logprobs, Vt = tt.providerMetadata, yt = (V = tt.request) != null ? V : {}, kt = tt.responseData; | |
| break; | |
| } | |
| case "tool": { | |
| const Tt = Rg({ | |
| prompt: { system: l, prompt: c, messages: h }, | |
| tools: void 0 | |
| }), St = await kg({ | |
| prompt: Tt, | |
| modelSupportsImageUrls: n.supportsImageUrls, | |
| modelSupportsUrl: (dt = n.supportsUrl) == null ? void 0 : dt.bind(n) | |
| // support 'this' context, | |
| }), tt = Tt.type, Qt = await T( | |
| () => Bd({ | |
| name: "ai.generateObject.doGenerate", | |
| attributes: va({ | |
| telemetry: m, | |
| attributes: { | |
| ...jd({ | |
| operationId: "ai.generateObject.doGenerate", | |
| telemetry: m | |
| }), | |
| ...C, | |
| "ai.prompt.format": { | |
| input: () => tt | |
| }, | |
| "ai.prompt.messages": { | |
| input: () => JSON.stringify(St) | |
| }, | |
| "ai.settings.mode": r, | |
| // standardized gen-ai llm span attributes: | |
| "gen_ai.system": n.provider, | |
| "gen_ai.request.model": n.modelId, | |
| "gen_ai.request.frequency_penalty": E.frequencyPenalty, | |
| "gen_ai.request.max_tokens": E.maxTokens, | |
| "gen_ai.request.presence_penalty": E.presencePenalty, | |
| "gen_ai.request.temperature": E.temperature, | |
| "gen_ai.request.top_k": E.topK, | |
| "gen_ai.request.top_p": E.topP | |
| } | |
| }), | |
| tracer: P, | |
| fn: async (Vn) => { | |
| var Gn, Ko, Jo, Qo, tl, le, zs, sg; | |
| const os = await n.doGenerate({ | |
| mode: { | |
| type: "object-tool", | |
| tool: { | |
| type: "function", | |
| name: s ?? "json", | |
| description: i ?? "Respond with a JSON object.", | |
| parameters: k.jsonSchema | |
| } | |
| }, | |
| ...Ig(E), | |
| inputFormat: tt, | |
| prompt: St, | |
| providerMetadata: _, | |
| abortSignal: d, | |
| headers: f | |
| }), xd = (Ko = (Gn = os.toolCalls) == null ? void 0 : Gn[0]) == null ? void 0 : Ko.args, qn = { | |
| id: (Qo = (Jo = os.response) == null ? void 0 : Jo.id) != null ? Qo : A(), | |
| timestamp: (le = (tl = os.response) == null ? void 0 : tl.timestamp) != null ? le : S(), | |
| modelId: (sg = (zs = os.response) == null ? void 0 : zs.modelId) != null ? sg : n.modelId | |
| }; | |
| if (xd === void 0) | |
| throw new en({ | |
| message: "No object generated: the tool was not called.", | |
| response: qn, | |
| usage: _a(os.usage) | |
| }); | |
| return Vn.setAttributes( | |
| va({ | |
| telemetry: m, | |
| attributes: { | |
| "ai.response.finishReason": os.finishReason, | |
| "ai.response.object": { output: () => xd }, | |
| "ai.response.id": qn.id, | |
| "ai.response.model": qn.modelId, | |
| "ai.response.timestamp": qn.timestamp.toISOString(), | |
| "ai.usage.promptTokens": os.usage.promptTokens, | |
| "ai.usage.completionTokens": os.usage.completionTokens, | |
| // standardized gen-ai llm span attributes: | |
| "gen_ai.response.finish_reasons": [os.finishReason], | |
| "gen_ai.response.id": qn.id, | |
| "gen_ai.response.model": qn.modelId, | |
| "gen_ai.usage.input_tokens": os.usage.promptTokens, | |
| "gen_ai.usage.output_tokens": os.usage.completionTokens | |
| } | |
| }) | |
| ), { ...os, objectText: xd, responseData: qn }; | |
| } | |
| }) | |
| ); | |
| Y = Qt.objectText, xt = Qt.finishReason, M = Qt.usage, z = Qt.warnings, ot = Qt.rawResponse, Q = Qt.logprobs, Vt = Qt.providerMetadata, yt = (gt = Qt.request) != null ? gt : {}, kt = Qt.responseData; | |
| break; | |
| } | |
| case void 0: | |
| throw new Error( | |
| "Model does not have a default object generation mode." | |
| ); | |
| default: { | |
| const Tt = r; | |
| throw new Error(`Unsupported mode: ${Tt}`); | |
| } | |
| } | |
| function $t(Tt) { | |
| const St = Go({ text: Tt }); | |
| if (!St.success) | |
| throw new en({ | |
| message: "No object generated: could not parse the response.", | |
| cause: St.error, | |
| text: Tt, | |
| response: kt, | |
| usage: _a(M) | |
| }); | |
| const tt = k.validateFinalResult( | |
| St.value, | |
| { | |
| text: Tt, | |
| response: kt, | |
| usage: _a(M) | |
| } | |
| ); | |
| if (!tt.success) | |
| throw new en({ | |
| message: "No object generated: response did not match schema.", | |
| cause: tt.error, | |
| text: Tt, | |
| response: kt, | |
| usage: _a(M) | |
| }); | |
| return tt.value; | |
| } | |
| let vs; | |
| try { | |
| vs = $t(Y); | |
| } catch (Tt) { | |
| if (g != null && en.isInstance(Tt) && (Ll.isInstance(Tt.cause) || Zi.isInstance(Tt.cause))) { | |
| const St = await g({ | |
| text: Y, | |
| error: Tt.cause | |
| }); | |
| if (St === null) | |
| throw Tt; | |
| vs = $t(St); | |
| } else | |
| throw Tt; | |
| } | |
| return j.setAttributes( | |
| va({ | |
| telemetry: m, | |
| attributes: { | |
| "ai.response.finishReason": xt, | |
| "ai.response.object": { | |
| output: () => JSON.stringify(vs) | |
| }, | |
| "ai.usage.promptTokens": M.promptTokens, | |
| "ai.usage.completionTokens": M.completionTokens | |
| } | |
| }) | |
| ), new WS({ | |
| object: vs, | |
| finishReason: xt, | |
| usage: _a(M), | |
| warnings: z, | |
| request: yt, | |
| response: { | |
| ...kt, | |
| headers: ot == null ? void 0 : ot.headers, | |
| body: ot == null ? void 0 : ot.body | |
| }, | |
| logprobs: Q, | |
| providerMetadata: Vt | |
| }); | |
| } | |
| }); | |
| } | |
| var WS = class { | |
| constructor(n) { | |
| this.object = n.object, this.finishReason = n.finishReason, this.usage = n.usage, this.warnings = n.warnings, this.providerMetadata = n.providerMetadata, this.experimental_providerMetadata = n.providerMetadata, this.response = n.response, this.request = n.request, this.logprobs = n.logprobs; | |
| } | |
| toJsonResponse(n) { | |
| var t; | |
| return new Response(JSON.stringify(this.object), { | |
| status: (t = n == null ? void 0 : n.status) != null ? t : 200, | |
| headers: Dp(n == null ? void 0 : n.headers, { | |
| contentType: "application/json; charset=utf-8" | |
| }) | |
| }); | |
| } | |
| }; | |
| ya({ prefix: "aiobj", size: 24 }); | |
| ya({ | |
| prefix: "aitxt", | |
| size: 24 | |
| }); | |
| ya({ | |
| prefix: "msg", | |
| size: 24 | |
| }); | |
| var XS = {}; | |
| Lp(XS, { | |
| object: () => YS, | |
| text: () => ZS | |
| }); | |
| var ZS = () => ({ | |
| type: "text", | |
| responseFormat: () => ({ type: "text" }), | |
| injectIntoSystemPrompt({ system: n }) { | |
| return n; | |
| }, | |
| parsePartial({ text: n }) { | |
| return { partial: n }; | |
| }, | |
| parseOutput({ text: n }) { | |
| return n; | |
| } | |
| }), YS = ({ | |
| schema: n | |
| }) => { | |
| const t = rf(n); | |
| return { | |
| type: "object", | |
| responseFormat: ({ model: e }) => ({ | |
| type: "json", | |
| schema: e.supportsStructuredOutputs ? t.jsonSchema : void 0 | |
| }), | |
| injectIntoSystemPrompt({ system: e, model: s }) { | |
| return s.supportsStructuredOutputs ? e : lf({ | |
| prompt: e, | |
| schema: t.jsonSchema | |
| }); | |
| }, | |
| parsePartial({ text: e }) { | |
| const s = Xw(e); | |
| switch (s.state) { | |
| case "failed-parse": | |
| case "undefined-input": | |
| return; | |
| case "repaired-parse": | |
| case "successful-parse": | |
| return { | |
| // Note: currently no validation of partial results: | |
| partial: s.value | |
| }; | |
| default: { | |
| const i = s.state; | |
| throw new Error(`Unsupported parse state: ${i}`); | |
| } | |
| } | |
| }, | |
| parseOutput({ text: e }, s) { | |
| const i = Go({ text: e }); | |
| if (!i.success) | |
| throw new en({ | |
| message: "No object generated: could not parse the response.", | |
| cause: i.error, | |
| text: e, | |
| response: s.response, | |
| usage: s.usage | |
| }); | |
| const r = ca({ | |
| value: i.value, | |
| schema: t | |
| }); | |
| if (!r.success) | |
| throw new en({ | |
| message: "No object generated: response did not match schema.", | |
| cause: r.error, | |
| text: e, | |
| response: s.response, | |
| usage: s.usage | |
| }); | |
| return r.value; | |
| } | |
| }; | |
| }; | |
| function Oy(n, t) { | |
| const e = n.getReader(), s = t.getReader(); | |
| let i, r, a = !1, l = !1; | |
| async function c(u) { | |
| try { | |
| i == null && (i = e.read()); | |
| const d = await i; | |
| i = void 0, d.done ? u.close() : u.enqueue(d.value); | |
| } catch (d) { | |
| u.error(d); | |
| } | |
| } | |
| async function h(u) { | |
| try { | |
| r == null && (r = s.read()); | |
| const d = await r; | |
| r = void 0, d.done ? u.close() : u.enqueue(d.value); | |
| } catch (d) { | |
| u.error(d); | |
| } | |
| } | |
| return new ReadableStream({ | |
| async pull(u) { | |
| try { | |
| if (a) { | |
| await h(u); | |
| return; | |
| } | |
| if (l) { | |
| await c(u); | |
| return; | |
| } | |
| i == null && (i = e.read()), r == null && (r = s.read()); | |
| const { result: d, reader: f } = await Promise.race([ | |
| i.then((g) => ({ result: g, reader: e })), | |
| r.then((g) => ({ result: g, reader: s })) | |
| ]); | |
| d.done || u.enqueue(d.value), f === e ? (i = void 0, d.done && (await h(u), a = !0)) : (r = void 0, d.done && (l = !0, await c(u))); | |
| } catch (d) { | |
| u.error(d); | |
| } | |
| }, | |
| cancel() { | |
| e.cancel(), s.cancel(); | |
| } | |
| }); | |
| } | |
| ya({ | |
| prefix: "aitxt", | |
| size: 24 | |
| }); | |
| ya({ | |
| prefix: "msg", | |
| size: 24 | |
| }); | |
| var KS = {}; | |
| Lp(KS, { | |
| mergeIntoDataStream: () => tE, | |
| toDataStream: () => JS, | |
| toDataStreamResponse: () => QS | |
| }); | |
| function Ly(n = {}) { | |
| const t = new TextEncoder(); | |
| let e = ""; | |
| return new TransformStream({ | |
| async start() { | |
| n.onStart && await n.onStart(); | |
| }, | |
| async transform(s, i) { | |
| i.enqueue(t.encode(s)), e += s, n.onToken && await n.onToken(s), n.onText && typeof s == "string" && await n.onText(s); | |
| }, | |
| async flush() { | |
| n.onCompletion && await n.onCompletion(e), n.onFinal && await n.onFinal(e); | |
| } | |
| }); | |
| } | |
| function Fp(n, t) { | |
| return n.pipeThrough( | |
| new TransformStream({ | |
| transform: async (e, s) => { | |
| var i; | |
| if (typeof e == "string") { | |
| s.enqueue(e); | |
| return; | |
| } | |
| if ("event" in e) { | |
| e.event === "on_chat_model_stream" && Pg( | |
| (i = e.data) == null ? void 0 : i.chunk, | |
| s | |
| ); | |
| return; | |
| } | |
| Pg(e, s); | |
| } | |
| }) | |
| ).pipeThrough(Ly(t)).pipeThrough(new TextDecoderStream()).pipeThrough( | |
| new TransformStream({ | |
| transform: async (e, s) => { | |
| s.enqueue(iy("text", e)); | |
| } | |
| }) | |
| ); | |
| } | |
| function JS(n, t) { | |
| return Fp(n, t).pipeThrough( | |
| new TextEncoderStream() | |
| ); | |
| } | |
| function QS(n, t) { | |
| var e; | |
| const s = Fp( | |
| n, | |
| t == null ? void 0 : t.callbacks | |
| ).pipeThrough(new TextEncoderStream()), i = t == null ? void 0 : t.data, r = t == null ? void 0 : t.init, a = i ? Oy(i.stream, s) : s; | |
| return new Response(a, { | |
| status: (e = r == null ? void 0 : r.status) != null ? e : 200, | |
| statusText: r == null ? void 0 : r.statusText, | |
| headers: Dp(r == null ? void 0 : r.headers, { | |
| contentType: "text/plain; charset=utf-8", | |
| dataStreamVersion: "v1" | |
| }) | |
| }); | |
| } | |
| function tE(n, t) { | |
| t.dataStream.merge(Fp(n, t.callbacks)); | |
| } | |
| function Pg(n, t) { | |
| if (typeof n.content == "string") | |
| t.enqueue(n.content); | |
| else { | |
| const e = n.content; | |
| for (const s of e) | |
| s.type === "text" && t.enqueue(s.text); | |
| } | |
| } | |
| var eE = {}; | |
| Lp(eE, { | |
| mergeIntoDataStream: () => nE, | |
| toDataStream: () => sE, | |
| toDataStreamResponse: () => iE | |
| }); | |
| function $p(n, t) { | |
| const e = rE(); | |
| return L_(n[Symbol.asyncIterator]()).pipeThrough( | |
| new TransformStream({ | |
| async transform(s, i) { | |
| i.enqueue(e(s.delta)); | |
| } | |
| }) | |
| ).pipeThrough(Ly(t)).pipeThrough(new TextDecoderStream()).pipeThrough( | |
| new TransformStream({ | |
| transform: async (s, i) => { | |
| i.enqueue(iy("text", s)); | |
| } | |
| }) | |
| ); | |
| } | |
| function sE(n, t) { | |
| return $p(n, t).pipeThrough( | |
| new TextEncoderStream() | |
| ); | |
| } | |
| function iE(n, t = {}) { | |
| var e; | |
| const { init: s, data: i, callbacks: r } = t, a = $p(n, r).pipeThrough( | |
| new TextEncoderStream() | |
| ), l = i ? Oy(i.stream, a) : a; | |
| return new Response(l, { | |
| status: (e = s == null ? void 0 : s.status) != null ? e : 200, | |
| statusText: s == null ? void 0 : s.statusText, | |
| headers: Dp(s == null ? void 0 : s.headers, { | |
| contentType: "text/plain; charset=utf-8", | |
| dataStreamVersion: "v1" | |
| }) | |
| }); | |
| } | |
| function nE(n, t) { | |
| t.dataStream.merge($p(n, t.callbacks)); | |
| } | |
| function rE() { | |
| let n = !0; | |
| return (t) => (n && (t = t.trimStart(), t && (n = !1)), t); | |
| } | |
| function aE({ | |
| prompt: n, | |
| useLegacyFunctionCalling: t = !1, | |
| systemMessageMode: e = "system" | |
| }) { | |
| const s = []; | |
| for (const { role: i, content: r } of n) | |
| switch (i) { | |
| case "system": { | |
| switch (e) { | |
| case "system": { | |
| s.push({ role: "system", content: r }); | |
| break; | |
| } | |
| case "developer": { | |
| s.push({ role: "developer", content: r }); | |
| break; | |
| } | |
| case "remove": | |
| break; | |
| default: { | |
| const a = e; | |
| throw new Error( | |
| `Unsupported system message mode: ${a}` | |
| ); | |
| } | |
| } | |
| break; | |
| } | |
| case "user": { | |
| if (r.length === 1 && r[0].type === "text") { | |
| s.push({ role: "user", content: r[0].text }); | |
| break; | |
| } | |
| s.push({ | |
| role: "user", | |
| content: r.map((a) => { | |
| var l, c, h; | |
| switch (a.type) { | |
| case "text": | |
| return { type: "text", text: a.text }; | |
| case "image": | |
| return { | |
| type: "image_url", | |
| image_url: { | |
| url: a.image instanceof URL ? a.image.toString() : `data:${(l = a.mimeType) != null ? l : "image/jpeg"};base64,${Jd(a.image)}`, | |
| // OpenAI specific extension: image detail | |
| detail: (h = (c = a.providerMetadata) == null ? void 0 : c.openai) == null ? void 0 : h.imageDetail | |
| } | |
| }; | |
| case "file": { | |
| if (a.data instanceof URL) | |
| throw new oe({ | |
| functionality: "'File content parts with URL data' functionality not supported." | |
| }); | |
| switch (a.mimeType) { | |
| case "audio/wav": | |
| return { | |
| type: "input_audio", | |
| input_audio: { data: a.data, format: "wav" } | |
| }; | |
| case "audio/mp3": | |
| case "audio/mpeg": | |
| return { | |
| type: "input_audio", | |
| input_audio: { data: a.data, format: "mp3" } | |
| }; | |
| default: | |
| throw new oe({ | |
| functionality: `File content part type ${a.mimeType} in user messages` | |
| }); | |
| } | |
| } | |
| } | |
| }) | |
| }); | |
| break; | |
| } | |
| case "assistant": { | |
| let a = ""; | |
| const l = []; | |
| for (const c of r) | |
| switch (c.type) { | |
| case "text": { | |
| a += c.text; | |
| break; | |
| } | |
| case "redacted-reasoning": | |
| case "reasoning": | |
| break; | |
| case "tool-call": { | |
| l.push({ | |
| id: c.toolCallId, | |
| type: "function", | |
| function: { | |
| name: c.toolName, | |
| arguments: JSON.stringify(c.args) | |
| } | |
| }); | |
| break; | |
| } | |
| default: { | |
| const h = c; | |
| throw new Error(`Unsupported part: ${h}`); | |
| } | |
| } | |
| if (t) { | |
| if (l.length > 1) | |
| throw new oe({ | |
| functionality: "useLegacyFunctionCalling with multiple tool calls in one message" | |
| }); | |
| s.push({ | |
| role: "assistant", | |
| content: a, | |
| function_call: l.length > 0 ? l[0].function : void 0 | |
| }); | |
| } else | |
| s.push({ | |
| role: "assistant", | |
| content: a, | |
| tool_calls: l.length > 0 ? l : void 0 | |
| }); | |
| break; | |
| } | |
| case "tool": { | |
| for (const a of r) | |
| t ? s.push({ | |
| role: "function", | |
| name: a.toolName, | |
| content: JSON.stringify(a.result) | |
| }) : s.push({ | |
| role: "tool", | |
| tool_call_id: a.toolCallId, | |
| content: JSON.stringify(a.result) | |
| }); | |
| break; | |
| } | |
| default: { | |
| const a = i; | |
| throw new Error(`Unsupported role: ${a}`); | |
| } | |
| } | |
| return s; | |
| } | |
| function Mg(n) { | |
| var t, e; | |
| return (e = (t = n == null ? void 0 : n.content) == null ? void 0 : t.map(({ token: s, logprob: i, top_logprobs: r }) => ({ | |
| token: s, | |
| logprob: i, | |
| topLogprobs: r ? r.map(({ token: a, logprob: l }) => ({ | |
| token: a, | |
| logprob: l | |
| })) : [] | |
| }))) != null ? e : void 0; | |
| } | |
| function Du(n) { | |
| switch (n) { | |
| case "stop": | |
| return "stop"; | |
| case "length": | |
| return "length"; | |
| case "content_filter": | |
| return "content-filter"; | |
| case "function_call": | |
| case "tool_calls": | |
| return "tool-calls"; | |
| default: | |
| return "unknown"; | |
| } | |
| } | |
| var jp = w.object({ | |
| error: w.object({ | |
| message: w.string(), | |
| // The additional information below is handled loosely to support | |
| // OpenAI-compatible providers that have slightly different error | |
| // responses: | |
| type: w.string().nullish(), | |
| param: w.any().nullish(), | |
| code: w.union([w.string(), w.number()]).nullish() | |
| }) | |
| }), Yo = X_({ | |
| errorSchema: jp, | |
| errorToMessage: (n) => n.error.message | |
| }); | |
| function Fu({ | |
| id: n, | |
| model: t, | |
| created: e | |
| }) { | |
| return { | |
| id: n ?? void 0, | |
| modelId: t ?? void 0, | |
| timestamp: e != null ? new Date(e * 1e3) : void 0 | |
| }; | |
| } | |
| function oE({ | |
| mode: n, | |
| useLegacyFunctionCalling: t = !1, | |
| structuredOutputs: e | |
| }) { | |
| var s; | |
| const i = (s = n.tools) != null && s.length ? n.tools : void 0, r = []; | |
| if (i == null) | |
| return { tools: void 0, tool_choice: void 0, toolWarnings: r }; | |
| const a = n.toolChoice; | |
| if (t) { | |
| const h = []; | |
| for (const d of i) | |
| d.type === "provider-defined" ? r.push({ type: "unsupported-tool", tool: d }) : h.push({ | |
| name: d.name, | |
| description: d.description, | |
| parameters: d.parameters | |
| }); | |
| if (a == null) | |
| return { | |
| functions: h, | |
| function_call: void 0, | |
| toolWarnings: r | |
| }; | |
| switch (a.type) { | |
| case "auto": | |
| case "none": | |
| case void 0: | |
| return { | |
| functions: h, | |
| function_call: void 0, | |
| toolWarnings: r | |
| }; | |
| case "required": | |
| throw new oe({ | |
| functionality: "useLegacyFunctionCalling and toolChoice: required" | |
| }); | |
| default: | |
| return { | |
| functions: h, | |
| function_call: { name: a.toolName }, | |
| toolWarnings: r | |
| }; | |
| } | |
| } | |
| const l = []; | |
| for (const h of i) | |
| h.type === "provider-defined" ? r.push({ type: "unsupported-tool", tool: h }) : l.push({ | |
| type: "function", | |
| function: { | |
| name: h.name, | |
| description: h.description, | |
| parameters: h.parameters, | |
| strict: e ? !0 : void 0 | |
| } | |
| }); | |
| if (a == null) | |
| return { tools: l, tool_choice: void 0, toolWarnings: r }; | |
| const c = a.type; | |
| switch (c) { | |
| case "auto": | |
| case "none": | |
| case "required": | |
| return { tools: l, tool_choice: c, toolWarnings: r }; | |
| case "tool": | |
| return { | |
| tools: l, | |
| tool_choice: { | |
| type: "function", | |
| function: { | |
| name: a.toolName | |
| } | |
| }, | |
| toolWarnings: r | |
| }; | |
| default: { | |
| const h = c; | |
| throw new oe({ | |
| functionality: `Unsupported tool choice type: ${h}` | |
| }); | |
| } | |
| } | |
| } | |
| var lE = class { | |
| constructor(n, t, e) { | |
| this.specificationVersion = "v1", this.modelId = n, this.settings = t, this.config = e; | |
| } | |
| get supportsStructuredOutputs() { | |
| var n; | |
| return (n = this.settings.structuredOutputs) != null ? n : cf(this.modelId); | |
| } | |
| get defaultObjectGenerationMode() { | |
| return uE(this.modelId) ? "tool" : this.supportsStructuredOutputs ? "json" : "tool"; | |
| } | |
| get provider() { | |
| return this.config.provider; | |
| } | |
| get supportsImageUrls() { | |
| return !this.settings.downloadImages; | |
| } | |
| getArgs({ | |
| mode: n, | |
| prompt: t, | |
| maxTokens: e, | |
| temperature: s, | |
| topP: i, | |
| topK: r, | |
| frequencyPenalty: a, | |
| presencePenalty: l, | |
| stopSequences: c, | |
| responseFormat: h, | |
| seed: u, | |
| providerMetadata: d | |
| }) { | |
| var f, g, m, y, _, A, S, E; | |
| const x = n.type, T = []; | |
| r != null && T.push({ | |
| type: "unsupported-setting", | |
| setting: "topK" | |
| }), (h == null ? void 0 : h.type) === "json" && h.schema != null && !this.supportsStructuredOutputs && T.push({ | |
| type: "unsupported-setting", | |
| setting: "responseFormat", | |
| details: "JSON response format schema is only supported with structuredOutputs" | |
| }); | |
| const k = this.settings.useLegacyFunctionCalling; | |
| if (k && this.settings.parallelToolCalls === !0) | |
| throw new oe({ | |
| functionality: "useLegacyFunctionCalling with parallelToolCalls" | |
| }); | |
| if (k && this.supportsStructuredOutputs) | |
| throw new oe({ | |
| functionality: "structuredOutputs with useLegacyFunctionCalling" | |
| }); | |
| Ng(this.modelId) === "remove" && t.some((P) => P.role === "system") && T.push({ | |
| type: "other", | |
| message: "system messages are removed for this model" | |
| }); | |
| const C = { | |
| // model id: | |
| model: this.modelId, | |
| // model specific settings: | |
| logit_bias: this.settings.logitBias, | |
| logprobs: this.settings.logprobs === !0 || typeof this.settings.logprobs == "number" ? !0 : void 0, | |
| top_logprobs: typeof this.settings.logprobs == "number" ? this.settings.logprobs : typeof this.settings.logprobs == "boolean" && this.settings.logprobs ? 0 : void 0, | |
| user: this.settings.user, | |
| parallel_tool_calls: this.settings.parallelToolCalls, | |
| // standardized settings: | |
| max_tokens: e, | |
| temperature: s, | |
| top_p: i, | |
| frequency_penalty: a, | |
| presence_penalty: l, | |
| response_format: (h == null ? void 0 : h.type) === "json" ? this.supportsStructuredOutputs && h.schema != null ? { | |
| type: "json_schema", | |
| json_schema: { | |
| schema: h.schema, | |
| strict: !0, | |
| name: (f = h.name) != null ? f : "response", | |
| description: h.description | |
| } | |
| } : { type: "json_object" } : void 0, | |
| stop: c, | |
| seed: u, | |
| // openai specific settings: | |
| // TODO remove in next major version; we auto-map maxTokens now | |
| max_completion_tokens: (g = d == null ? void 0 : d.openai) == null ? void 0 : g.maxCompletionTokens, | |
| store: (m = d == null ? void 0 : d.openai) == null ? void 0 : m.store, | |
| metadata: (y = d == null ? void 0 : d.openai) == null ? void 0 : y.metadata, | |
| prediction: (_ = d == null ? void 0 : d.openai) == null ? void 0 : _.prediction, | |
| reasoning_effort: (S = (A = d == null ? void 0 : d.openai) == null ? void 0 : A.reasoningEffort) != null ? S : this.settings.reasoningEffort, | |
| // messages: | |
| messages: aE({ | |
| prompt: t, | |
| useLegacyFunctionCalling: k, | |
| systemMessageMode: Ng(this.modelId) | |
| }) | |
| }; | |
| switch (cf(this.modelId) && (C.temperature != null && (C.temperature = void 0, T.push({ | |
| type: "unsupported-setting", | |
| setting: "temperature", | |
| details: "temperature is not supported for reasoning models" | |
| })), C.top_p != null && (C.top_p = void 0, T.push({ | |
| type: "unsupported-setting", | |
| setting: "topP", | |
| details: "topP is not supported for reasoning models" | |
| })), C.frequency_penalty != null && (C.frequency_penalty = void 0, T.push({ | |
| type: "unsupported-setting", | |
| setting: "frequencyPenalty", | |
| details: "frequencyPenalty is not supported for reasoning models" | |
| })), C.presence_penalty != null && (C.presence_penalty = void 0, T.push({ | |
| type: "unsupported-setting", | |
| setting: "presencePenalty", | |
| details: "presencePenalty is not supported for reasoning models" | |
| })), C.logit_bias != null && (C.logit_bias = void 0, T.push({ | |
| type: "other", | |
| message: "logitBias is not supported for reasoning models" | |
| })), C.logprobs != null && (C.logprobs = void 0, T.push({ | |
| type: "other", | |
| message: "logprobs is not supported for reasoning models" | |
| })), C.top_logprobs != null && (C.top_logprobs = void 0, T.push({ | |
| type: "other", | |
| message: "topLogprobs is not supported for reasoning models" | |
| })), C.max_tokens != null && (C.max_completion_tokens == null && (C.max_completion_tokens = C.max_tokens), C.max_tokens = void 0)), x) { | |
| case "regular": { | |
| const { tools: P, tool_choice: j, functions: Z, function_call: V, toolWarnings: dt } = oE({ | |
| mode: n, | |
| useLegacyFunctionCalling: k, | |
| structuredOutputs: this.supportsStructuredOutputs | |
| }); | |
| return { | |
| args: { | |
| ...C, | |
| tools: P, | |
| tool_choice: j, | |
| functions: Z, | |
| function_call: V | |
| }, | |
| warnings: [...T, ...dt] | |
| }; | |
| } | |
| case "object-json": | |
| return { | |
| args: { | |
| ...C, | |
| response_format: this.supportsStructuredOutputs && n.schema != null ? { | |
| type: "json_schema", | |
| json_schema: { | |
| schema: n.schema, | |
| strict: !0, | |
| name: (E = n.name) != null ? E : "response", | |
| description: n.description | |
| } | |
| } : { type: "json_object" } | |
| }, | |
| warnings: T | |
| }; | |
| case "object-tool": | |
| return { | |
| args: k ? { | |
| ...C, | |
| function_call: { | |
| name: n.tool.name | |
| }, | |
| functions: [ | |
| { | |
| name: n.tool.name, | |
| description: n.tool.description, | |
| parameters: n.tool.parameters | |
| } | |
| ] | |
| } : { | |
| ...C, | |
| tool_choice: { | |
| type: "function", | |
| function: { name: n.tool.name } | |
| }, | |
| tools: [ | |
| { | |
| type: "function", | |
| function: { | |
| name: n.tool.name, | |
| description: n.tool.description, | |
| parameters: n.tool.parameters, | |
| strict: this.supportsStructuredOutputs ? !0 : void 0 | |
| } | |
| } | |
| ] | |
| }, | |
| warnings: T | |
| }; | |
| default: { | |
| const P = x; | |
| throw new Error(`Unsupported type: ${P}`); | |
| } | |
| } | |
| } | |
| async doGenerate(n) { | |
| var t, e, s, i, r, a, l, c; | |
| const { args: h, warnings: u } = this.getArgs(n), { | |
| responseHeaders: d, | |
| value: f, | |
| rawValue: g | |
| } = await qo({ | |
| url: this.config.url({ | |
| path: "/chat/completions", | |
| modelId: this.modelId | |
| }), | |
| headers: Vo(this.config.headers(), n.headers), | |
| body: h, | |
| failedResponseHandler: Yo, | |
| successfulResponseHandler: pd( | |
| cE | |
| ), | |
| abortSignal: n.abortSignal, | |
| fetch: this.config.fetch | |
| }), { messages: m, ...y } = h, _ = f.choices[0], A = (t = f.usage) == null ? void 0 : t.completion_tokens_details, S = (e = f.usage) == null ? void 0 : e.prompt_tokens_details, E = { openai: {} }; | |
| return (A == null ? void 0 : A.reasoning_tokens) != null && (E.openai.reasoningTokens = A == null ? void 0 : A.reasoning_tokens), (A == null ? void 0 : A.accepted_prediction_tokens) != null && (E.openai.acceptedPredictionTokens = A == null ? void 0 : A.accepted_prediction_tokens), (A == null ? void 0 : A.rejected_prediction_tokens) != null && (E.openai.rejectedPredictionTokens = A == null ? void 0 : A.rejected_prediction_tokens), (S == null ? void 0 : S.cached_tokens) != null && (E.openai.cachedPromptTokens = S == null ? void 0 : S.cached_tokens), { | |
| text: (s = _.message.content) != null ? s : void 0, | |
| toolCalls: this.settings.useLegacyFunctionCalling && _.message.function_call ? [ | |
| { | |
| toolCallType: "function", | |
| toolCallId: sl(), | |
| toolName: _.message.function_call.name, | |
| args: _.message.function_call.arguments | |
| } | |
| ] : (i = _.message.tool_calls) == null ? void 0 : i.map((x) => { | |
| var T; | |
| return { | |
| toolCallType: "function", | |
| toolCallId: (T = x.id) != null ? T : sl(), | |
| toolName: x.function.name, | |
| args: x.function.arguments | |
| }; | |
| }), | |
| finishReason: Du(_.finish_reason), | |
| usage: { | |
| promptTokens: (a = (r = f.usage) == null ? void 0 : r.prompt_tokens) != null ? a : NaN, | |
| completionTokens: (c = (l = f.usage) == null ? void 0 : l.completion_tokens) != null ? c : NaN | |
| }, | |
| rawCall: { rawPrompt: m, rawSettings: y }, | |
| rawResponse: { headers: d, body: g }, | |
| request: { body: JSON.stringify(h) }, | |
| response: Fu(f), | |
| warnings: u, | |
| logprobs: Mg(_.logprobs), | |
| providerMetadata: E | |
| }; | |
| } | |
| async doStream(n) { | |
| if (this.settings.simulateStreaming) { | |
| const y = await this.doGenerate(n); | |
| return { | |
| stream: new ReadableStream({ | |
| start(A) { | |
| if (A.enqueue({ type: "response-metadata", ...y.response }), y.text && A.enqueue({ | |
| type: "text-delta", | |
| textDelta: y.text | |
| }), y.toolCalls) | |
| for (const S of y.toolCalls) | |
| A.enqueue({ | |
| type: "tool-call-delta", | |
| toolCallType: "function", | |
| toolCallId: S.toolCallId, | |
| toolName: S.toolName, | |
| argsTextDelta: S.args | |
| }), A.enqueue({ | |
| type: "tool-call", | |
| ...S | |
| }); | |
| A.enqueue({ | |
| type: "finish", | |
| finishReason: y.finishReason, | |
| usage: y.usage, | |
| logprobs: y.logprobs, | |
| providerMetadata: y.providerMetadata | |
| }), A.close(); | |
| } | |
| }), | |
| rawCall: y.rawCall, | |
| rawResponse: y.rawResponse, | |
| warnings: y.warnings | |
| }; | |
| } | |
| const { args: t, warnings: e } = this.getArgs(n), s = { | |
| ...t, | |
| stream: !0, | |
| // only include stream_options when in strict compatibility mode: | |
| stream_options: this.config.compatibility === "strict" ? { include_usage: !0 } : void 0 | |
| }, { responseHeaders: i, value: r } = await qo({ | |
| url: this.config.url({ | |
| path: "/chat/completions", | |
| modelId: this.modelId | |
| }), | |
| headers: Vo(this.config.headers(), n.headers), | |
| body: s, | |
| failedResponseHandler: Yo, | |
| successfulResponseHandler: Hm( | |
| hE | |
| ), | |
| abortSignal: n.abortSignal, | |
| fetch: this.config.fetch | |
| }), { messages: a, ...l } = t, c = []; | |
| let h = "unknown", u = { | |
| promptTokens: void 0, | |
| completionTokens: void 0 | |
| }, d, f = !0; | |
| const { useLegacyFunctionCalling: g } = this.settings, m = { openai: {} }; | |
| return { | |
| stream: r.pipeThrough( | |
| new TransformStream({ | |
| transform(y, _) { | |
| var A, S, E, x, T, k, C, P, j, Z, V, dt; | |
| if (!y.success) { | |
| h = "error", _.enqueue({ type: "error", error: y.error }); | |
| return; | |
| } | |
| const gt = y.value; | |
| if ("error" in gt) { | |
| h = "error", _.enqueue({ type: "error", error: gt.error }); | |
| return; | |
| } | |
| if (f && (f = !1, _.enqueue({ | |
| type: "response-metadata", | |
| ...Fu(gt) | |
| })), gt.usage != null) { | |
| const { | |
| prompt_tokens: ot, | |
| completion_tokens: kt, | |
| prompt_tokens_details: yt, | |
| completion_tokens_details: Q | |
| } = gt.usage; | |
| u = { | |
| promptTokens: ot ?? void 0, | |
| completionTokens: kt ?? void 0 | |
| }, (Q == null ? void 0 : Q.reasoning_tokens) != null && (m.openai.reasoningTokens = Q == null ? void 0 : Q.reasoning_tokens), (Q == null ? void 0 : Q.accepted_prediction_tokens) != null && (m.openai.acceptedPredictionTokens = Q == null ? void 0 : Q.accepted_prediction_tokens), (Q == null ? void 0 : Q.rejected_prediction_tokens) != null && (m.openai.rejectedPredictionTokens = Q == null ? void 0 : Q.rejected_prediction_tokens), (yt == null ? void 0 : yt.cached_tokens) != null && (m.openai.cachedPromptTokens = yt == null ? void 0 : yt.cached_tokens); | |
| } | |
| const Y = gt.choices[0]; | |
| if ((Y == null ? void 0 : Y.finish_reason) != null && (h = Du(Y.finish_reason)), (Y == null ? void 0 : Y.delta) == null) | |
| return; | |
| const xt = Y.delta; | |
| xt.content != null && _.enqueue({ | |
| type: "text-delta", | |
| textDelta: xt.content | |
| }); | |
| const M = Mg( | |
| Y == null ? void 0 : Y.logprobs | |
| ); | |
| M != null && M.length && (d === void 0 && (d = []), d.push(...M)); | |
| const z = g && xt.function_call != null ? [ | |
| { | |
| type: "function", | |
| id: sl(), | |
| function: xt.function_call, | |
| index: 0 | |
| } | |
| ] : xt.tool_calls; | |
| if (z != null) | |
| for (const ot of z) { | |
| const kt = ot.index; | |
| if (c[kt] == null) { | |
| if (ot.type !== "function") | |
| throw new Pd({ | |
| data: ot, | |
| message: "Expected 'function' type." | |
| }); | |
| if (ot.id == null) | |
| throw new Pd({ | |
| data: ot, | |
| message: "Expected 'id' to be a string." | |
| }); | |
| if (((A = ot.function) == null ? void 0 : A.name) == null) | |
| throw new Pd({ | |
| data: ot, | |
| message: "Expected 'function.name' to be a string." | |
| }); | |
| c[kt] = { | |
| id: ot.id, | |
| type: "function", | |
| function: { | |
| name: ot.function.name, | |
| arguments: (S = ot.function.arguments) != null ? S : "" | |
| }, | |
| hasFinished: !1 | |
| }; | |
| const Q = c[kt]; | |
| ((E = Q.function) == null ? void 0 : E.name) != null && ((x = Q.function) == null ? void 0 : x.arguments) != null && (Q.function.arguments.length > 0 && _.enqueue({ | |
| type: "tool-call-delta", | |
| toolCallType: "function", | |
| toolCallId: Q.id, | |
| toolName: Q.function.name, | |
| argsTextDelta: Q.function.arguments | |
| }), yg(Q.function.arguments) && (_.enqueue({ | |
| type: "tool-call", | |
| toolCallType: "function", | |
| toolCallId: (T = Q.id) != null ? T : sl(), | |
| toolName: Q.function.name, | |
| args: Q.function.arguments | |
| }), Q.hasFinished = !0)); | |
| continue; | |
| } | |
| const yt = c[kt]; | |
| yt.hasFinished || (((k = ot.function) == null ? void 0 : k.arguments) != null && (yt.function.arguments += (P = (C = ot.function) == null ? void 0 : C.arguments) != null ? P : ""), _.enqueue({ | |
| type: "tool-call-delta", | |
| toolCallType: "function", | |
| toolCallId: yt.id, | |
| toolName: yt.function.name, | |
| argsTextDelta: (j = ot.function.arguments) != null ? j : "" | |
| }), ((Z = yt.function) == null ? void 0 : Z.name) != null && ((V = yt.function) == null ? void 0 : V.arguments) != null && yg(yt.function.arguments) && (_.enqueue({ | |
| type: "tool-call", | |
| toolCallType: "function", | |
| toolCallId: (dt = yt.id) != null ? dt : sl(), | |
| toolName: yt.function.name, | |
| args: yt.function.arguments | |
| }), yt.hasFinished = !0)); | |
| } | |
| }, | |
| flush(y) { | |
| var _, A; | |
| y.enqueue({ | |
| type: "finish", | |
| finishReason: h, | |
| logprobs: d, | |
| usage: { | |
| promptTokens: (_ = u.promptTokens) != null ? _ : NaN, | |
| completionTokens: (A = u.completionTokens) != null ? A : NaN | |
| }, | |
| ...m != null ? { providerMetadata: m } : {} | |
| }); | |
| } | |
| }) | |
| ), | |
| rawCall: { rawPrompt: a, rawSettings: l }, | |
| rawResponse: { headers: i }, | |
| request: { body: JSON.stringify(s) }, | |
| warnings: e | |
| }; | |
| } | |
| }, Dy = w.object({ | |
| prompt_tokens: w.number().nullish(), | |
| completion_tokens: w.number().nullish(), | |
| prompt_tokens_details: w.object({ | |
| cached_tokens: w.number().nullish() | |
| }).nullish(), | |
| completion_tokens_details: w.object({ | |
| reasoning_tokens: w.number().nullish(), | |
| accepted_prediction_tokens: w.number().nullish(), | |
| rejected_prediction_tokens: w.number().nullish() | |
| }).nullish() | |
| }).nullish(), cE = w.object({ | |
| id: w.string().nullish(), | |
| created: w.number().nullish(), | |
| model: w.string().nullish(), | |
| choices: w.array( | |
| w.object({ | |
| message: w.object({ | |
| role: w.literal("assistant").nullish(), | |
| content: w.string().nullish(), | |
| function_call: w.object({ | |
| arguments: w.string(), | |
| name: w.string() | |
| }).nullish(), | |
| tool_calls: w.array( | |
| w.object({ | |
| id: w.string().nullish(), | |
| type: w.literal("function"), | |
| function: w.object({ | |
| name: w.string(), | |
| arguments: w.string() | |
| }) | |
| }) | |
| ).nullish() | |
| }), | |
| index: w.number(), | |
| logprobs: w.object({ | |
| content: w.array( | |
| w.object({ | |
| token: w.string(), | |
| logprob: w.number(), | |
| top_logprobs: w.array( | |
| w.object({ | |
| token: w.string(), | |
| logprob: w.number() | |
| }) | |
| ) | |
| }) | |
| ).nullable() | |
| }).nullish(), | |
| finish_reason: w.string().nullish() | |
| }) | |
| ), | |
| usage: Dy | |
| }), hE = w.union([ | |
| w.object({ | |
| id: w.string().nullish(), | |
| created: w.number().nullish(), | |
| model: w.string().nullish(), | |
| choices: w.array( | |
| w.object({ | |
| delta: w.object({ | |
| role: w.enum(["assistant"]).nullish(), | |
| content: w.string().nullish(), | |
| function_call: w.object({ | |
| name: w.string().optional(), | |
| arguments: w.string().optional() | |
| }).nullish(), | |
| tool_calls: w.array( | |
| w.object({ | |
| index: w.number(), | |
| id: w.string().nullish(), | |
| type: w.literal("function").optional(), | |
| function: w.object({ | |
| name: w.string().nullish(), | |
| arguments: w.string().nullish() | |
| }) | |
| }) | |
| ).nullish() | |
| }).nullish(), | |
| logprobs: w.object({ | |
| content: w.array( | |
| w.object({ | |
| token: w.string(), | |
| logprob: w.number(), | |
| top_logprobs: w.array( | |
| w.object({ | |
| token: w.string(), | |
| logprob: w.number() | |
| }) | |
| ) | |
| }) | |
| ).nullable() | |
| }).nullish(), | |
| finish_reason: w.string().nullable().optional(), | |
| index: w.number() | |
| }) | |
| ), | |
| usage: Dy | |
| }), | |
| jp | |
| ]); | |
| function cf(n) { | |
| return n === "o1" || n.startsWith("o1-") || n === "o3" || n.startsWith("o3-"); | |
| } | |
| function uE(n) { | |
| return n.startsWith("gpt-4o-audio-preview"); | |
| } | |
| function Ng(n) { | |
| var t, e; | |
| return cf(n) ? (e = (t = dE[n]) == null ? void 0 : t.systemMessageMode) != null ? e : "developer" : "system"; | |
| } | |
| var dE = { | |
| "o1-mini": { | |
| systemMessageMode: "remove" | |
| }, | |
| "o1-mini-2024-09-12": { | |
| systemMessageMode: "remove" | |
| }, | |
| "o1-preview": { | |
| systemMessageMode: "remove" | |
| }, | |
| "o1-preview-2024-09-12": { | |
| systemMessageMode: "remove" | |
| }, | |
| "o3-mini": { | |
| systemMessageMode: "developer" | |
| }, | |
| "o3-mini-2025-01-31": { | |
| systemMessageMode: "developer" | |
| } | |
| }; | |
| function fE({ | |
| prompt: n, | |
| inputFormat: t, | |
| user: e = "user", | |
| assistant: s = "assistant" | |
| }) { | |
| if (t === "prompt" && n.length === 1 && n[0].role === "user" && n[0].content.length === 1 && n[0].content[0].type === "text") | |
| return { prompt: n[0].content[0].text }; | |
| let i = ""; | |
| n[0].role === "system" && (i += `${n[0].content} | |
| `, n = n.slice(1)); | |
| for (const { role: r, content: a } of n) | |
| switch (r) { | |
| case "system": | |
| throw new Zn({ | |
| message: "Unexpected system message in prompt: ${content}", | |
| prompt: n | |
| }); | |
| case "user": { | |
| const l = a.map((c) => { | |
| switch (c.type) { | |
| case "text": | |
| return c.text; | |
| case "image": | |
| throw new oe({ | |
| functionality: "images" | |
| }); | |
| } | |
| }).join(""); | |
| i += `${e}: | |
| ${l} | |
| `; | |
| break; | |
| } | |
| case "assistant": { | |
| const l = a.map((c) => { | |
| switch (c.type) { | |
| case "text": | |
| return c.text; | |
| case "tool-call": | |
| throw new oe({ | |
| functionality: "tool-call messages" | |
| }); | |
| } | |
| }).join(""); | |
| i += `${s}: | |
| ${l} | |
| `; | |
| break; | |
| } | |
| case "tool": | |
| throw new oe({ | |
| functionality: "tool messages" | |
| }); | |
| default: { | |
| const l = r; | |
| throw new Error(`Unsupported role: ${l}`); | |
| } | |
| } | |
| return i += `${s}: | |
| `, { | |
| prompt: i, | |
| stopSequences: [` | |
| ${e}:`] | |
| }; | |
| } | |
| function Og(n) { | |
| return n == null ? void 0 : n.tokens.map((t, e) => ({ | |
| token: t, | |
| logprob: n.token_logprobs[e], | |
| topLogprobs: n.top_logprobs ? Object.entries(n.top_logprobs[e]).map( | |
| ([s, i]) => ({ | |
| token: s, | |
| logprob: i | |
| }) | |
| ) : [] | |
| })); | |
| } | |
| var pE = class { | |
| constructor(n, t, e) { | |
| this.specificationVersion = "v1", this.defaultObjectGenerationMode = void 0, this.modelId = n, this.settings = t, this.config = e; | |
| } | |
| get provider() { | |
| return this.config.provider; | |
| } | |
| getArgs({ | |
| mode: n, | |
| inputFormat: t, | |
| prompt: e, | |
| maxTokens: s, | |
| temperature: i, | |
| topP: r, | |
| topK: a, | |
| frequencyPenalty: l, | |
| presencePenalty: c, | |
| stopSequences: h, | |
| responseFormat: u, | |
| seed: d | |
| }) { | |
| var f; | |
| const g = n.type, m = []; | |
| a != null && m.push({ | |
| type: "unsupported-setting", | |
| setting: "topK" | |
| }), u != null && u.type !== "text" && m.push({ | |
| type: "unsupported-setting", | |
| setting: "responseFormat", | |
| details: "JSON response format is not supported." | |
| }); | |
| const { prompt: y, stopSequences: _ } = fE({ prompt: e, inputFormat: t }), A = [..._ ?? [], ...h ?? []], S = { | |
| // model id: | |
| model: this.modelId, | |
| // model specific settings: | |
| echo: this.settings.echo, | |
| logit_bias: this.settings.logitBias, | |
| logprobs: typeof this.settings.logprobs == "number" ? this.settings.logprobs : typeof this.settings.logprobs == "boolean" && this.settings.logprobs ? 0 : void 0, | |
| suffix: this.settings.suffix, | |
| user: this.settings.user, | |
| // standardized settings: | |
| max_tokens: s, | |
| temperature: i, | |
| top_p: r, | |
| frequency_penalty: l, | |
| presence_penalty: c, | |
| seed: d, | |
| // prompt: | |
| prompt: y, | |
| // stop sequences: | |
| stop: A.length > 0 ? A : void 0 | |
| }; | |
| switch (g) { | |
| case "regular": { | |
| if ((f = n.tools) != null && f.length) | |
| throw new oe({ | |
| functionality: "tools" | |
| }); | |
| if (n.toolChoice) | |
| throw new oe({ | |
| functionality: "toolChoice" | |
| }); | |
| return { args: S, warnings: m }; | |
| } | |
| case "object-json": | |
| throw new oe({ | |
| functionality: "object-json mode" | |
| }); | |
| case "object-tool": | |
| throw new oe({ | |
| functionality: "object-tool mode" | |
| }); | |
| default: { | |
| const E = g; | |
| throw new Error(`Unsupported type: ${E}`); | |
| } | |
| } | |
| } | |
| async doGenerate(n) { | |
| const { args: t, warnings: e } = this.getArgs(n), { | |
| responseHeaders: s, | |
| value: i, | |
| rawValue: r | |
| } = await qo({ | |
| url: this.config.url({ | |
| path: "/completions", | |
| modelId: this.modelId | |
| }), | |
| headers: Vo(this.config.headers(), n.headers), | |
| body: t, | |
| failedResponseHandler: Yo, | |
| successfulResponseHandler: pd( | |
| gE | |
| ), | |
| abortSignal: n.abortSignal, | |
| fetch: this.config.fetch | |
| }), { prompt: a, ...l } = t, c = i.choices[0]; | |
| return { | |
| text: c.text, | |
| usage: { | |
| promptTokens: i.usage.prompt_tokens, | |
| completionTokens: i.usage.completion_tokens | |
| }, | |
| finishReason: Du(c.finish_reason), | |
| logprobs: Og(c.logprobs), | |
| rawCall: { rawPrompt: a, rawSettings: l }, | |
| rawResponse: { headers: s, body: r }, | |
| response: Fu(i), | |
| warnings: e, | |
| request: { body: JSON.stringify(t) } | |
| }; | |
| } | |
| async doStream(n) { | |
| const { args: t, warnings: e } = this.getArgs(n), s = { | |
| ...t, | |
| stream: !0, | |
| // only include stream_options when in strict compatibility mode: | |
| stream_options: this.config.compatibility === "strict" ? { include_usage: !0 } : void 0 | |
| }, { responseHeaders: i, value: r } = await qo({ | |
| url: this.config.url({ | |
| path: "/completions", | |
| modelId: this.modelId | |
| }), | |
| headers: Vo(this.config.headers(), n.headers), | |
| body: s, | |
| failedResponseHandler: Yo, | |
| successfulResponseHandler: Hm( | |
| mE | |
| ), | |
| abortSignal: n.abortSignal, | |
| fetch: this.config.fetch | |
| }), { prompt: a, ...l } = t; | |
| let c = "unknown", h = { | |
| promptTokens: Number.NaN, | |
| completionTokens: Number.NaN | |
| }, u, d = !0; | |
| return { | |
| stream: r.pipeThrough( | |
| new TransformStream({ | |
| transform(f, g) { | |
| if (!f.success) { | |
| c = "error", g.enqueue({ type: "error", error: f.error }); | |
| return; | |
| } | |
| const m = f.value; | |
| if ("error" in m) { | |
| c = "error", g.enqueue({ type: "error", error: m.error }); | |
| return; | |
| } | |
| d && (d = !1, g.enqueue({ | |
| type: "response-metadata", | |
| ...Fu(m) | |
| })), m.usage != null && (h = { | |
| promptTokens: m.usage.prompt_tokens, | |
| completionTokens: m.usage.completion_tokens | |
| }); | |
| const y = m.choices[0]; | |
| (y == null ? void 0 : y.finish_reason) != null && (c = Du(y.finish_reason)), (y == null ? void 0 : y.text) != null && g.enqueue({ | |
| type: "text-delta", | |
| textDelta: y.text | |
| }); | |
| const _ = Og( | |
| y == null ? void 0 : y.logprobs | |
| ); | |
| _ != null && _.length && (u === void 0 && (u = []), u.push(..._)); | |
| }, | |
| flush(f) { | |
| f.enqueue({ | |
| type: "finish", | |
| finishReason: c, | |
| logprobs: u, | |
| usage: h | |
| }); | |
| } | |
| }) | |
| ), | |
| rawCall: { rawPrompt: a, rawSettings: l }, | |
| rawResponse: { headers: i }, | |
| warnings: e, | |
| request: { body: JSON.stringify(s) } | |
| }; | |
| } | |
| }, gE = w.object({ | |
| id: w.string().nullish(), | |
| created: w.number().nullish(), | |
| model: w.string().nullish(), | |
| choices: w.array( | |
| w.object({ | |
| text: w.string(), | |
| finish_reason: w.string(), | |
| logprobs: w.object({ | |
| tokens: w.array(w.string()), | |
| token_logprobs: w.array(w.number()), | |
| top_logprobs: w.array(w.record(w.string(), w.number())).nullable() | |
| }).nullish() | |
| }) | |
| ), | |
| usage: w.object({ | |
| prompt_tokens: w.number(), | |
| completion_tokens: w.number() | |
| }) | |
| }), mE = w.union([ | |
| w.object({ | |
| id: w.string().nullish(), | |
| created: w.number().nullish(), | |
| model: w.string().nullish(), | |
| choices: w.array( | |
| w.object({ | |
| text: w.string(), | |
| finish_reason: w.string().nullish(), | |
| index: w.number(), | |
| logprobs: w.object({ | |
| tokens: w.array(w.string()), | |
| token_logprobs: w.array(w.number()), | |
| top_logprobs: w.array(w.record(w.string(), w.number())).nullable() | |
| }).nullish() | |
| }) | |
| ), | |
| usage: w.object({ | |
| prompt_tokens: w.number(), | |
| completion_tokens: w.number() | |
| }).nullish() | |
| }), | |
| jp | |
| ]), yE = class { | |
| constructor(n, t, e) { | |
| this.specificationVersion = "v1", this.modelId = n, this.settings = t, this.config = e; | |
| } | |
| get provider() { | |
| return this.config.provider; | |
| } | |
| get maxEmbeddingsPerCall() { | |
| var n; | |
| return (n = this.settings.maxEmbeddingsPerCall) != null ? n : 2048; | |
| } | |
| get supportsParallelCalls() { | |
| var n; | |
| return (n = this.settings.supportsParallelCalls) != null ? n : !0; | |
| } | |
| async doEmbed({ | |
| values: n, | |
| headers: t, | |
| abortSignal: e | |
| }) { | |
| if (n.length > this.maxEmbeddingsPerCall) | |
| throw new w_({ | |
| provider: this.provider, | |
| modelId: this.modelId, | |
| maxEmbeddingsPerCall: this.maxEmbeddingsPerCall, | |
| values: n | |
| }); | |
| const { responseHeaders: s, value: i } = await qo({ | |
| url: this.config.url({ | |
| path: "/embeddings", | |
| modelId: this.modelId | |
| }), | |
| headers: Vo(this.config.headers(), t), | |
| body: { | |
| model: this.modelId, | |
| input: n, | |
| encoding_format: "float", | |
| dimensions: this.settings.dimensions, | |
| user: this.settings.user | |
| }, | |
| failedResponseHandler: Yo, | |
| successfulResponseHandler: pd( | |
| bE | |
| ), | |
| abortSignal: e, | |
| fetch: this.config.fetch | |
| }); | |
| return { | |
| embeddings: i.data.map((r) => r.embedding), | |
| usage: i.usage ? { tokens: i.usage.prompt_tokens } : void 0, | |
| rawResponse: { headers: s } | |
| }; | |
| } | |
| }, bE = w.object({ | |
| data: w.array(w.object({ embedding: w.array(w.number()) })), | |
| usage: w.object({ prompt_tokens: w.number() }).nullish() | |
| }), vE = { | |
| "dall-e-3": 1, | |
| "dall-e-2": 10 | |
| }, _E = class { | |
| constructor(n, t, e) { | |
| this.modelId = n, this.settings = t, this.config = e, this.specificationVersion = "v1"; | |
| } | |
| get maxImagesPerCall() { | |
| var n, t; | |
| return (t = (n = this.settings.maxImagesPerCall) != null ? n : vE[this.modelId]) != null ? t : 1; | |
| } | |
| get provider() { | |
| return this.config.provider; | |
| } | |
| async doGenerate({ | |
| prompt: n, | |
| n: t, | |
| size: e, | |
| aspectRatio: s, | |
| seed: i, | |
| providerOptions: r, | |
| headers: a, | |
| abortSignal: l | |
| }) { | |
| var c, h, u, d; | |
| const f = []; | |
| s != null && f.push({ | |
| type: "unsupported-setting", | |
| setting: "aspectRatio", | |
| details: "This model does not support aspect ratio. Use `size` instead." | |
| }), i != null && f.push({ type: "unsupported-setting", setting: "seed" }); | |
| const g = (u = (h = (c = this.config._internal) == null ? void 0 : c.currentDate) == null ? void 0 : h.call(c)) != null ? u : /* @__PURE__ */ new Date(), { value: m, responseHeaders: y } = await qo({ | |
| url: this.config.url({ | |
| path: "/images/generations", | |
| modelId: this.modelId | |
| }), | |
| headers: Vo(this.config.headers(), a), | |
| body: { | |
| model: this.modelId, | |
| prompt: n, | |
| n: t, | |
| size: e, | |
| ...(d = r.openai) != null ? d : {}, | |
| response_format: "b64_json" | |
| }, | |
| failedResponseHandler: Yo, | |
| successfulResponseHandler: pd( | |
| AE | |
| ), | |
| abortSignal: l, | |
| fetch: this.config.fetch | |
| }); | |
| return { | |
| images: m.data.map((_) => _.b64_json), | |
| warnings: f, | |
| response: { | |
| timestamp: g, | |
| modelId: this.modelId, | |
| headers: y | |
| } | |
| }; | |
| } | |
| }, AE = w.object({ | |
| data: w.array(w.object({ b64_json: w.string() })) | |
| }); | |
| function Fy(n = {}) { | |
| var t, e, s; | |
| const i = (t = J_(n.baseURL)) != null ? t : "https://api.openai.com/v1", r = (e = n.compatibility) != null ? e : "compatible", a = (s = n.name) != null ? s : "openai", l = () => ({ | |
| Authorization: `Bearer ${j_({ | |
| apiKey: n.apiKey, | |
| environmentVariableName: "OPENAI_API_KEY", | |
| description: "OpenAI" | |
| })}`, | |
| "OpenAI-Organization": n.organization, | |
| "OpenAI-Project": n.project, | |
| ...n.headers | |
| }), c = (m, y = {}) => new lE(m, y, { | |
| provider: `${a}.chat`, | |
| url: ({ path: _ }) => `${i}${_}`, | |
| headers: l, | |
| compatibility: r, | |
| fetch: n.fetch | |
| }), h = (m, y = {}) => new pE(m, y, { | |
| provider: `${a}.completion`, | |
| url: ({ path: _ }) => `${i}${_}`, | |
| headers: l, | |
| compatibility: r, | |
| fetch: n.fetch | |
| }), u = (m, y = {}) => new yE(m, y, { | |
| provider: `${a}.embedding`, | |
| url: ({ path: _ }) => `${i}${_}`, | |
| headers: l, | |
| fetch: n.fetch | |
| }), d = (m, y = {}) => new _E(m, y, { | |
| provider: `${a}.image`, | |
| url: ({ path: _ }) => `${i}${_}`, | |
| headers: l, | |
| fetch: n.fetch | |
| }), f = (m, y) => { | |
| if (new.target) | |
| throw new Error( | |
| "The OpenAI model function cannot be called with the new keyword." | |
| ); | |
| return m === "gpt-3.5-turbo-instruct" ? h( | |
| m, | |
| y | |
| ) : c(m, y); | |
| }, g = function(m, y) { | |
| return f(m, y); | |
| }; | |
| return g.languageModel = f, g.chat = c, g.completion = h, g.embedding = u, g.textEmbedding = u, g.textEmbeddingModel = u, g.image = d, g.imageModel = d, g; | |
| } | |
| Fy({ | |
| compatibility: "strict" | |
| // strict for OpenAI API | |
| }); | |
| var Rl = {}; | |
| Rl.d = (n, t) => { | |
| for (var e in t) | |
| Rl.o(t, e) && !Rl.o(n, e) && Object.defineProperty(n, e, { enumerable: !0, get: t[e] }); | |
| }; | |
| Rl.o = (n, t) => Object.prototype.hasOwnProperty.call(n, t); | |
| var X = globalThis.pdfjsLib = {}; | |
| Rl.d(X, { | |
| AbortException: () => ( | |
| /* reexport */ | |
| Bn | |
| ), | |
| AnnotationEditorLayer: () => ( | |
| /* reexport */ | |
| bp | |
| ), | |
| AnnotationEditorParamsType: () => ( | |
| /* reexport */ | |
| lt | |
| ), | |
| AnnotationEditorType: () => ( | |
| /* reexport */ | |
| et | |
| ), | |
| AnnotationEditorUIManager: () => ( | |
| /* reexport */ | |
| pa | |
| ), | |
| AnnotationLayer: () => ( | |
| /* reexport */ | |
| mT | |
| ), | |
| AnnotationMode: () => ( | |
| /* reexport */ | |
| sn | |
| ), | |
| ColorPicker: () => ( | |
| /* reexport */ | |
| zu | |
| ), | |
| DOMSVGFactory: () => ( | |
| /* reexport */ | |
| Xp | |
| ), | |
| DrawLayer: () => ( | |
| /* reexport */ | |
| Ap | |
| ), | |
| FeatureTest: () => ( | |
| /* reexport */ | |
| Me | |
| ), | |
| GlobalWorkerOptions: () => ( | |
| /* reexport */ | |
| qi | |
| ), | |
| ImageKind: () => ( | |
| /* reexport */ | |
| Gh | |
| ), | |
| InvalidPDFException: () => ( | |
| /* reexport */ | |
| uf | |
| ), | |
| MissingPDFException: () => ( | |
| /* reexport */ | |
| ic | |
| ), | |
| OPS: () => ( | |
| /* reexport */ | |
| Ss | |
| ), | |
| OutputScale: () => ( | |
| /* reexport */ | |
| ff | |
| ), | |
| PDFDataRangeTransport: () => ( | |
| /* reexport */ | |
| jb | |
| ), | |
| PDFDateString: () => ( | |
| /* reexport */ | |
| Vp | |
| ), | |
| PDFWorker: () => ( | |
| /* reexport */ | |
| La | |
| ), | |
| PasswordResponses: () => ( | |
| /* reexport */ | |
| xE | |
| ), | |
| PermissionFlag: () => ( | |
| /* reexport */ | |
| EE | |
| ), | |
| PixelsPerInch: () => ( | |
| /* reexport */ | |
| Hn | |
| ), | |
| RenderingCancelledException: () => ( | |
| /* reexport */ | |
| Up | |
| ), | |
| TextLayer: () => ( | |
| /* reexport */ | |
| nc | |
| ), | |
| TouchManager: () => ( | |
| /* reexport */ | |
| Hu | |
| ), | |
| UnexpectedResponseException: () => ( | |
| /* reexport */ | |
| $u | |
| ), | |
| Util: () => ( | |
| /* reexport */ | |
| U | |
| ), | |
| VerbosityLevel: () => ( | |
| /* reexport */ | |
| yd | |
| ), | |
| XfaLayer: () => ( | |
| /* reexport */ | |
| Hb | |
| ), | |
| build: () => ( | |
| /* reexport */ | |
| Yx | |
| ), | |
| createValidAbsoluteUrl: () => ( | |
| /* reexport */ | |
| IE | |
| ), | |
| fetchData: () => ( | |
| /* reexport */ | |
| Ad | |
| ), | |
| getDocument: () => ( | |
| /* reexport */ | |
| Hx | |
| ), | |
| getFilenameFromUrl: () => ( | |
| /* reexport */ | |
| $E | |
| ), | |
| getPdfFilenameFromUrl: () => ( | |
| /* reexport */ | |
| jE | |
| ), | |
| getXfaPageViewport: () => ( | |
| /* reexport */ | |
| BE | |
| ), | |
| isDataScheme: () => ( | |
| /* reexport */ | |
| wd | |
| ), | |
| isPdfFile: () => ( | |
| /* reexport */ | |
| zp | |
| ), | |
| noContextMenu: () => ( | |
| /* reexport */ | |
| Hs | |
| ), | |
| normalizeUnicode: () => ( | |
| /* reexport */ | |
| LE | |
| ), | |
| setLayerDimensions: () => ( | |
| /* reexport */ | |
| fa | |
| ), | |
| shadow: () => ( | |
| /* reexport */ | |
| at | |
| ), | |
| stopEvent: () => ( | |
| /* reexport */ | |
| ns | |
| ), | |
| version: () => ( | |
| /* reexport */ | |
| Zx | |
| ) | |
| }); | |
| const Se = typeof process == "object" && process + "" == "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser"), $y = [1, 0, 0, 1, 0, 0], hf = [1e-3, 0, 0, 1e-3, 0, 0], wE = 1e7, zd = 1.35, ss = { | |
| ANY: 1, | |
| DISPLAY: 2, | |
| PRINT: 4, | |
| ANNOTATIONS_FORMS: 16, | |
| ANNOTATIONS_STORAGE: 32, | |
| ANNOTATIONS_DISABLE: 64, | |
| IS_EDITING: 128, | |
| OPLIST: 256 | |
| }, sn = { | |
| DISABLE: 0, | |
| ENABLE: 1, | |
| ENABLE_FORMS: 2, | |
| ENABLE_STORAGE: 3 | |
| }, SE = "pdfjs_internal_editor_", et = { | |
| DISABLE: -1, | |
| NONE: 0, | |
| FREETEXT: 3, | |
| HIGHLIGHT: 9, | |
| STAMP: 13, | |
| INK: 15 | |
| }, lt = { | |
| RESIZE: 1, | |
| CREATE: 2, | |
| FREETEXT_SIZE: 11, | |
| FREETEXT_COLOR: 12, | |
| FREETEXT_OPACITY: 13, | |
| INK_COLOR: 21, | |
| INK_THICKNESS: 22, | |
| INK_OPACITY: 23, | |
| HIGHLIGHT_COLOR: 31, | |
| HIGHLIGHT_DEFAULT_COLOR: 32, | |
| HIGHLIGHT_THICKNESS: 33, | |
| HIGHLIGHT_FREE: 34, | |
| HIGHLIGHT_SHOW_ALL: 35, | |
| DRAW_STEP: 41 | |
| }, EE = { | |
| PRINT: 4, | |
| MODIFY_CONTENTS: 8, | |
| COPY: 16, | |
| MODIFY_ANNOTATIONS: 32, | |
| FILL_INTERACTIVE_FORMS: 256, | |
| COPY_FOR_ACCESSIBILITY: 512, | |
| ASSEMBLE: 1024, | |
| PRINT_HIGH_QUALITY: 2048 | |
| }, ge = { | |
| FILL: 0, | |
| STROKE: 1, | |
| FILL_STROKE: 2, | |
| INVISIBLE: 3, | |
| FILL_STROKE_MASK: 3, | |
| ADD_TO_PATH_FLAG: 4 | |
| }, Gh = { | |
| GRAYSCALE_1BPP: 1, | |
| RGB_24BPP: 2, | |
| RGBA_32BPP: 3 | |
| }, Xt = { | |
| TEXT: 1, | |
| LINK: 2, | |
| FREETEXT: 3, | |
| LINE: 4, | |
| SQUARE: 5, | |
| CIRCLE: 6, | |
| POLYGON: 7, | |
| POLYLINE: 8, | |
| HIGHLIGHT: 9, | |
| UNDERLINE: 10, | |
| SQUIGGLY: 11, | |
| STRIKEOUT: 12, | |
| STAMP: 13, | |
| CARET: 14, | |
| INK: 15, | |
| POPUP: 16, | |
| FILEATTACHMENT: 17, | |
| WIDGET: 20 | |
| }, nl = { | |
| SOLID: 1, | |
| DASHED: 2, | |
| BEVELED: 3, | |
| INSET: 4, | |
| UNDERLINE: 5 | |
| }, yd = { | |
| ERRORS: 0, | |
| WARNINGS: 1, | |
| INFOS: 5 | |
| }, Ss = { | |
| dependency: 1, | |
| setLineWidth: 2, | |
| setLineCap: 3, | |
| setLineJoin: 4, | |
| setMiterLimit: 5, | |
| setDash: 6, | |
| setRenderingIntent: 7, | |
| setFlatness: 8, | |
| setGState: 9, | |
| save: 10, | |
| restore: 11, | |
| transform: 12, | |
| moveTo: 13, | |
| lineTo: 14, | |
| curveTo: 15, | |
| curveTo2: 16, | |
| curveTo3: 17, | |
| closePath: 18, | |
| rectangle: 19, | |
| stroke: 20, | |
| closeStroke: 21, | |
| fill: 22, | |
| eoFill: 23, | |
| fillStroke: 24, | |
| eoFillStroke: 25, | |
| closeFillStroke: 26, | |
| closeEOFillStroke: 27, | |
| endPath: 28, | |
| clip: 29, | |
| eoClip: 30, | |
| beginText: 31, | |
| endText: 32, | |
| setCharSpacing: 33, | |
| setWordSpacing: 34, | |
| setHScale: 35, | |
| setLeading: 36, | |
| setFont: 37, | |
| setTextRenderingMode: 38, | |
| setTextRise: 39, | |
| moveText: 40, | |
| setLeadingMoveText: 41, | |
| setTextMatrix: 42, | |
| nextLine: 43, | |
| showText: 44, | |
| showSpacedText: 45, | |
| nextLineShowText: 46, | |
| nextLineSetSpacingShowText: 47, | |
| setCharWidth: 48, | |
| setCharWidthAndBounds: 49, | |
| setStrokeColorSpace: 50, | |
| setFillColorSpace: 51, | |
| setStrokeColor: 52, | |
| setStrokeColorN: 53, | |
| setFillColor: 54, | |
| setFillColorN: 55, | |
| setStrokeGray: 56, | |
| setFillGray: 57, | |
| setStrokeRGBColor: 58, | |
| setFillRGBColor: 59, | |
| setStrokeCMYKColor: 60, | |
| setFillCMYKColor: 61, | |
| shadingFill: 62, | |
| beginInlineImage: 63, | |
| beginImageData: 64, | |
| endInlineImage: 65, | |
| paintXObject: 66, | |
| markPoint: 67, | |
| markPointProps: 68, | |
| beginMarkedContent: 69, | |
| beginMarkedContentProps: 70, | |
| endMarkedContent: 71, | |
| beginCompat: 72, | |
| endCompat: 73, | |
| paintFormXObjectBegin: 74, | |
| paintFormXObjectEnd: 75, | |
| beginGroup: 76, | |
| endGroup: 77, | |
| beginAnnotation: 80, | |
| endAnnotation: 81, | |
| paintImageMaskXObject: 83, | |
| paintImageMaskXObjectGroup: 84, | |
| paintImageXObject: 85, | |
| paintInlineImageXObject: 86, | |
| paintInlineImageXObjectGroup: 87, | |
| paintImageXObjectRepeat: 88, | |
| paintImageMaskXObjectRepeat: 89, | |
| paintSolidColorImageMask: 90, | |
| constructPath: 91, | |
| setStrokeTransparent: 92, | |
| setFillTransparent: 93 | |
| }, xE = { | |
| NEED_PASSWORD: 1, | |
| INCORRECT_PASSWORD: 2 | |
| }; | |
| let bd = yd.WARNINGS; | |
| function TE(n) { | |
| Number.isInteger(n) && (bd = n); | |
| } | |
| function CE() { | |
| return bd; | |
| } | |
| function vd(n) { | |
| bd >= yd.INFOS && console.log(`Info: ${n}`); | |
| } | |
| function st(n) { | |
| bd >= yd.WARNINGS && console.log(`Warning: ${n}`); | |
| } | |
| function Et(n) { | |
| throw new Error(n); | |
| } | |
| function qt(n, t) { | |
| n || Et(t); | |
| } | |
| function kE(n) { | |
| switch (n == null ? void 0 : n.protocol) { | |
| case "http:": | |
| case "https:": | |
| case "ftp:": | |
| case "mailto:": | |
| case "tel:": | |
| return !0; | |
| default: | |
| return !1; | |
| } | |
| } | |
| function IE(n, t = null, e = null) { | |
| if (!n) | |
| return null; | |
| try { | |
| if (e && typeof n == "string") { | |
| if (e.addDefaultProtocol && n.startsWith("www.")) { | |
| const i = n.match(/\./g); | |
| (i == null ? void 0 : i.length) >= 2 && (n = `http://${n}`); | |
| } | |
| if (e.tryConvertEncoding) | |
| try { | |
| n = OE(n); | |
| } catch { | |
| } | |
| } | |
| const s = t ? new URL(n, t) : new URL(n); | |
| if (kE(s)) | |
| return s; | |
| } catch { | |
| } | |
| return null; | |
| } | |
| function at(n, t, e, s = !1) { | |
| return Object.defineProperty(n, t, { | |
| value: e, | |
| enumerable: !s, | |
| configurable: !0, | |
| writable: !1 | |
| }), e; | |
| } | |
| const zn = function() { | |
| function t(e, s) { | |
| this.message = e, this.name = s; | |
| } | |
| return t.prototype = new Error(), t.constructor = t, t; | |
| }(); | |
| class Lg extends zn { | |
| constructor(t, e) { | |
| super(t, "PasswordException"), this.code = e; | |
| } | |
| } | |
| class Vd extends zn { | |
| constructor(t, e) { | |
| super(t, "UnknownErrorException"), this.details = e; | |
| } | |
| } | |
| class uf extends zn { | |
| constructor(t) { | |
| super(t, "InvalidPDFException"); | |
| } | |
| } | |
| class ic extends zn { | |
| constructor(t) { | |
| super(t, "MissingPDFException"); | |
| } | |
| } | |
| class $u extends zn { | |
| constructor(t, e) { | |
| super(t, "UnexpectedResponseException"), this.status = e; | |
| } | |
| } | |
| class RE extends zn { | |
| constructor(t) { | |
| super(t, "FormatError"); | |
| } | |
| } | |
| class Bn extends zn { | |
| constructor(t) { | |
| super(t, "AbortException"); | |
| } | |
| } | |
| function jy(n) { | |
| (typeof n != "object" || (n == null ? void 0 : n.length) === void 0) && Et("Invalid argument for bytesToString"); | |
| const t = n.length, e = 8192; | |
| if (t < e) | |
| return String.fromCharCode.apply(null, n); | |
| const s = []; | |
| for (let i = 0; i < t; i += e) { | |
| const r = Math.min(i + e, t), a = n.subarray(i, r); | |
| s.push(String.fromCharCode.apply(null, a)); | |
| } | |
| return s.join(""); | |
| } | |
| function _d(n) { | |
| typeof n != "string" && Et("Invalid argument for stringToBytes"); | |
| const t = n.length, e = new Uint8Array(t); | |
| for (let s = 0; s < t; ++s) | |
| e[s] = n.charCodeAt(s) & 255; | |
| return e; | |
| } | |
| function PE(n) { | |
| return String.fromCharCode(n >> 24 & 255, n >> 16 & 255, n >> 8 & 255, n & 255); | |
| } | |
| function Bp(n) { | |
| const t = /* @__PURE__ */ Object.create(null); | |
| for (const [e, s] of n) | |
| t[e] = s; | |
| return t; | |
| } | |
| function ME() { | |
| const n = new Uint8Array(4); | |
| return n[0] = 1, new Uint32Array(n.buffer, 0, 1)[0] === 1; | |
| } | |
| function NE() { | |
| try { | |
| return new Function(""), !0; | |
| } catch { | |
| return !1; | |
| } | |
| } | |
| class Me { | |
| static get isLittleEndian() { | |
| return at(this, "isLittleEndian", ME()); | |
| } | |
| static get isEvalSupported() { | |
| return at(this, "isEvalSupported", NE()); | |
| } | |
| static get isOffscreenCanvasSupported() { | |
| return at(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas < "u"); | |
| } | |
| static get isImageDecoderSupported() { | |
| return at(this, "isImageDecoderSupported", typeof ImageDecoder < "u"); | |
| } | |
| static get platform() { | |
| return typeof navigator < "u" && typeof (navigator == null ? void 0 : navigator.platform) == "string" ? at(this, "platform", { | |
| isMac: navigator.platform.includes("Mac"), | |
| isWindows: navigator.platform.includes("Win"), | |
| isFirefox: typeof (navigator == null ? void 0 : navigator.userAgent) == "string" && navigator.userAgent.includes("Firefox") | |
| }) : at(this, "platform", { | |
| isMac: !1, | |
| isWindows: !1, | |
| isFirefox: !1 | |
| }); | |
| } | |
| static get isCSSRoundSupported() { | |
| var t, e; | |
| return at(this, "isCSSRoundSupported", (e = (t = globalThis.CSS) == null ? void 0 : t.supports) == null ? void 0 : e.call(t, "width: round(1.5px, 1px)")); | |
| } | |
| } | |
| const Gd = Array.from(Array(256).keys(), (n) => n.toString(16).padStart(2, "0")); | |
| var Wi, qh, df; | |
| class U { | |
| static makeHexColor(t, e, s) { | |
| return `#${Gd[t]}${Gd[e]}${Gd[s]}`; | |
| } | |
| static scaleMinMax(t, e) { | |
| let s; | |
| t[0] ? (t[0] < 0 && (s = e[0], e[0] = e[2], e[2] = s), e[0] *= t[0], e[2] *= t[0], t[3] < 0 && (s = e[1], e[1] = e[3], e[3] = s), e[1] *= t[3], e[3] *= t[3]) : (s = e[0], e[0] = e[1], e[1] = s, s = e[2], e[2] = e[3], e[3] = s, t[1] < 0 && (s = e[1], e[1] = e[3], e[3] = s), e[1] *= t[1], e[3] *= t[1], t[2] < 0 && (s = e[0], e[0] = e[2], e[2] = s), e[0] *= t[2], e[2] *= t[2]), e[0] += t[4], e[1] += t[5], e[2] += t[4], e[3] += t[5]; | |
| } | |
| static transform(t, e) { | |
| return [t[0] * e[0] + t[2] * e[1], t[1] * e[0] + t[3] * e[1], t[0] * e[2] + t[2] * e[3], t[1] * e[2] + t[3] * e[3], t[0] * e[4] + t[2] * e[5] + t[4], t[1] * e[4] + t[3] * e[5] + t[5]]; | |
| } | |
| static applyTransform(t, e) { | |
| const s = t[0] * e[0] + t[1] * e[2] + e[4], i = t[0] * e[1] + t[1] * e[3] + e[5]; | |
| return [s, i]; | |
| } | |
| static applyInverseTransform(t, e) { | |
| const s = e[0] * e[3] - e[1] * e[2], i = (t[0] * e[3] - t[1] * e[2] + e[2] * e[5] - e[4] * e[3]) / s, r = (-t[0] * e[1] + t[1] * e[0] + e[4] * e[1] - e[5] * e[0]) / s; | |
| return [i, r]; | |
| } | |
| static getAxialAlignedBoundingBox(t, e) { | |
| const s = this.applyTransform(t, e), i = this.applyTransform(t.slice(2, 4), e), r = this.applyTransform([t[0], t[3]], e), a = this.applyTransform([t[2], t[1]], e); | |
| return [Math.min(s[0], i[0], r[0], a[0]), Math.min(s[1], i[1], r[1], a[1]), Math.max(s[0], i[0], r[0], a[0]), Math.max(s[1], i[1], r[1], a[1])]; | |
| } | |
| static inverseTransform(t) { | |
| const e = t[0] * t[3] - t[1] * t[2]; | |
| return [t[3] / e, -t[1] / e, -t[2] / e, t[0] / e, (t[2] * t[5] - t[4] * t[3]) / e, (t[4] * t[1] - t[5] * t[0]) / e]; | |
| } | |
| static singularValueDecompose2dScale(t) { | |
| const e = [t[0], t[2], t[1], t[3]], s = t[0] * e[0] + t[1] * e[2], i = t[0] * e[1] + t[1] * e[3], r = t[2] * e[0] + t[3] * e[2], a = t[2] * e[1] + t[3] * e[3], l = (s + a) / 2, c = Math.sqrt((s + a) ** 2 - 4 * (s * a - r * i)) / 2, h = l + c || 1, u = l - c || 1; | |
| return [Math.sqrt(h), Math.sqrt(u)]; | |
| } | |
| static normalizeRect(t) { | |
| const e = t.slice(0); | |
| return t[0] > t[2] && (e[0] = t[2], e[2] = t[0]), t[1] > t[3] && (e[1] = t[3], e[3] = t[1]), e; | |
| } | |
| static intersect(t, e) { | |
| const s = Math.max(Math.min(t[0], t[2]), Math.min(e[0], e[2])), i = Math.min(Math.max(t[0], t[2]), Math.max(e[0], e[2])); | |
| if (s > i) | |
| return null; | |
| const r = Math.max(Math.min(t[1], t[3]), Math.min(e[1], e[3])), a = Math.min(Math.max(t[1], t[3]), Math.max(e[1], e[3])); | |
| return r > a ? null : [s, r, i, a]; | |
| } | |
| static bezierBoundingBox(t, e, s, i, r, a, l, c, h) { | |
| return h ? (h[0] = Math.min(h[0], t, l), h[1] = Math.min(h[1], e, c), h[2] = Math.max(h[2], t, l), h[3] = Math.max(h[3], e, c)) : h = [Math.min(t, l), Math.min(e, c), Math.max(t, l), Math.max(e, c)], v(this, Wi, df).call(this, t, s, r, l, e, i, a, c, 3 * (-t + 3 * (s - r) + l), 6 * (t - 2 * s + r), 3 * (s - t), h), v(this, Wi, df).call(this, t, s, r, l, e, i, a, c, 3 * (-e + 3 * (i - a) + c), 6 * (e - 2 * i + a), 3 * (i - e), h), h; | |
| } | |
| } | |
| Wi = new WeakSet(), qh = function(t, e, s, i, r, a, l, c, h, u) { | |
| if (h <= 0 || h >= 1) | |
| return; | |
| const d = 1 - h, f = h * h, g = f * h, m = d * (d * (d * t + 3 * h * e) + 3 * f * s) + g * i, y = d * (d * (d * r + 3 * h * a) + 3 * f * l) + g * c; | |
| u[0] = Math.min(u[0], m), u[1] = Math.min(u[1], y), u[2] = Math.max(u[2], m), u[3] = Math.max(u[3], y); | |
| }, df = function(t, e, s, i, r, a, l, c, h, u, d, f) { | |
| if (Math.abs(h) < 1e-12) { | |
| Math.abs(u) >= 1e-12 && v(this, Wi, qh).call(this, t, e, s, i, r, a, l, c, -d / u, f); | |
| return; | |
| } | |
| const g = u ** 2 - 4 * d * h; | |
| if (g < 0) | |
| return; | |
| const m = Math.sqrt(g), y = 2 * h; | |
| v(this, Wi, qh).call(this, t, e, s, i, r, a, l, c, (-u + m) / y, f), v(this, Wi, qh).call(this, t, e, s, i, r, a, l, c, (-u - m) / y, f); | |
| }, b(U, Wi); | |
| function OE(n) { | |
| return decodeURIComponent(escape(n)); | |
| } | |
| let qd = null, Dg = null; | |
| function LE(n) { | |
| return qd || (qd = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu, Dg = /* @__PURE__ */ new Map([["ſt", "ſt"]])), n.replaceAll(qd, (t, e, s) => e ? e.normalize("NFKC") : Dg.get(s)); | |
| } | |
| function DE() { | |
| if (typeof crypto.randomUUID == "function") | |
| return crypto.randomUUID(); | |
| const n = new Uint8Array(32); | |
| return crypto.getRandomValues(n), jy(n); | |
| } | |
| const Hp = "pdfjs_internal_id_"; | |
| function FE(n) { | |
| return Uint8Array.prototype.toBase64 ? n.toBase64() : btoa(jy(n)); | |
| } | |
| typeof Promise.try != "function" && (Promise.try = function(n, ...t) { | |
| return new Promise((e) => { | |
| e(n(...t)); | |
| }); | |
| }); | |
| const gi = "http://www.w3.org/2000/svg", Qn = class Qn { | |
| }; | |
| G(Qn, "CSS", 96), G(Qn, "PDF", 72), G(Qn, "PDF_TO_CSS_UNITS", Qn.CSS / Qn.PDF); | |
| let Hn = Qn; | |
| async function Ad(n, t = "text") { | |
| if (hl(n, document.baseURI)) { | |
| const e = await fetch(n); | |
| if (!e.ok) | |
| throw new Error(e.statusText); | |
| switch (t) { | |
| case "arraybuffer": | |
| return e.arrayBuffer(); | |
| case "blob": | |
| return e.blob(); | |
| case "json": | |
| return e.json(); | |
| } | |
| return e.text(); | |
| } | |
| return new Promise((e, s) => { | |
| const i = new XMLHttpRequest(); | |
| i.open("GET", n, !0), i.responseType = t, i.onreadystatechange = () => { | |
| if (i.readyState === XMLHttpRequest.DONE) { | |
| if (i.status === 200 || i.status === 0) { | |
| switch (t) { | |
| case "arraybuffer": | |
| case "blob": | |
| case "json": | |
| e(i.response); | |
| return; | |
| } | |
| e(i.responseText); | |
| return; | |
| } | |
| s(new Error(i.statusText)); | |
| } | |
| }, i.send(null); | |
| }); | |
| } | |
| class Nh { | |
| constructor({ | |
| viewBox: t, | |
| userUnit: e, | |
| scale: s, | |
| rotation: i, | |
| offsetX: r = 0, | |
| offsetY: a = 0, | |
| dontFlip: l = !1 | |
| }) { | |
| this.viewBox = t, this.userUnit = e, this.scale = s, this.rotation = i, this.offsetX = r, this.offsetY = a, s *= e; | |
| const c = (t[2] + t[0]) / 2, h = (t[3] + t[1]) / 2; | |
| let u, d, f, g; | |
| switch (i %= 360, i < 0 && (i += 360), i) { | |
| case 180: | |
| u = -1, d = 0, f = 0, g = 1; | |
| break; | |
| case 90: | |
| u = 0, d = 1, f = 1, g = 0; | |
| break; | |
| case 270: | |
| u = 0, d = -1, f = -1, g = 0; | |
| break; | |
| case 0: | |
| u = 1, d = 0, f = 0, g = -1; | |
| break; | |
| default: | |
| throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees."); | |
| } | |
| l && (f = -f, g = -g); | |
| let m, y, _, A; | |
| u === 0 ? (m = Math.abs(h - t[1]) * s + r, y = Math.abs(c - t[0]) * s + a, _ = (t[3] - t[1]) * s, A = (t[2] - t[0]) * s) : (m = Math.abs(c - t[0]) * s + r, y = Math.abs(h - t[1]) * s + a, _ = (t[2] - t[0]) * s, A = (t[3] - t[1]) * s), this.transform = [u * s, d * s, f * s, g * s, m - u * s * c - f * s * h, y - d * s * c - g * s * h], this.width = _, this.height = A; | |
| } | |
| get rawDims() { | |
| const { | |
| userUnit: t, | |
| viewBox: e | |
| } = this, s = e.map((i) => i * t); | |
| return at(this, "rawDims", { | |
| pageWidth: s[2] - s[0], | |
| pageHeight: s[3] - s[1], | |
| pageX: s[0], | |
| pageY: s[1] | |
| }); | |
| } | |
| clone({ | |
| scale: t = this.scale, | |
| rotation: e = this.rotation, | |
| offsetX: s = this.offsetX, | |
| offsetY: i = this.offsetY, | |
| dontFlip: r = !1 | |
| } = {}) { | |
| return new Nh({ | |
| viewBox: this.viewBox.slice(), | |
| userUnit: this.userUnit, | |
| scale: t, | |
| rotation: e, | |
| offsetX: s, | |
| offsetY: i, | |
| dontFlip: r | |
| }); | |
| } | |
| convertToViewportPoint(t, e) { | |
| return U.applyTransform([t, e], this.transform); | |
| } | |
| convertToViewportRectangle(t) { | |
| const e = U.applyTransform([t[0], t[1]], this.transform), s = U.applyTransform([t[2], t[3]], this.transform); | |
| return [e[0], e[1], s[0], s[1]]; | |
| } | |
| convertToPdfPoint(t, e) { | |
| return U.applyInverseTransform([t, e], this.transform); | |
| } | |
| } | |
| class Up extends zn { | |
| constructor(t, e = 0) { | |
| super(t, "RenderingCancelledException"), this.extraDelay = e; | |
| } | |
| } | |
| function wd(n) { | |
| const t = n.length; | |
| let e = 0; | |
| for (; e < t && n[e].trim() === ""; ) | |
| e++; | |
| return n.substring(e, e + 5).toLowerCase() === "data:"; | |
| } | |
| function zp(n) { | |
| return typeof n == "string" && /\.pdf$/i.test(n); | |
| } | |
| function $E(n) { | |
| return [n] = n.split(/[#?]/, 1), n.substring(n.lastIndexOf("/") + 1); | |
| } | |
| function jE(n, t = "document.pdf") { | |
| if (typeof n != "string") | |
| return t; | |
| if (wd(n)) | |
| return st('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'), t; | |
| const e = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/, s = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i, i = e.exec(n); | |
| let r = s.exec(i[1]) || s.exec(i[2]) || s.exec(i[3]); | |
| if (r && (r = r[0], r.includes("%"))) | |
| try { | |
| r = s.exec(decodeURIComponent(r))[0]; | |
| } catch { | |
| } | |
| return r || t; | |
| } | |
| class Fg { | |
| constructor() { | |
| G(this, "started", /* @__PURE__ */ Object.create(null)); | |
| G(this, "times", []); | |
| } | |
| time(t) { | |
| t in this.started && st(`Timer is already running for ${t}`), this.started[t] = Date.now(); | |
| } | |
| timeEnd(t) { | |
| t in this.started || st(`Timer has not been started for ${t}`), this.times.push({ | |
| name: t, | |
| start: this.started[t], | |
| end: Date.now() | |
| }), delete this.started[t]; | |
| } | |
| toString() { | |
| const t = []; | |
| let e = 0; | |
| for (const { | |
| name: s | |
| } of this.times) | |
| e = Math.max(s.length, e); | |
| for (const { | |
| name: s, | |
| start: i, | |
| end: r | |
| } of this.times) | |
| t.push(`${s.padEnd(e)} ${r - i}ms | |
| `); | |
| return t.join(""); | |
| } | |
| } | |
| function hl(n, t) { | |
| try { | |
| const { | |
| protocol: e | |
| } = t ? new URL(n, t) : new URL(n); | |
| return e === "http:" || e === "https:"; | |
| } catch { | |
| return !1; | |
| } | |
| } | |
| function Hs(n) { | |
| n.preventDefault(); | |
| } | |
| function ns(n) { | |
| n.preventDefault(), n.stopPropagation(); | |
| } | |
| var ac; | |
| class Vp { | |
| static toDateObject(t) { | |
| if (!t || typeof t != "string") | |
| return null; | |
| o(this, ac) || p(this, ac, new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")); | |
| const e = o(this, ac).exec(t); | |
| if (!e) | |
| return null; | |
| const s = parseInt(e[1], 10); | |
| let i = parseInt(e[2], 10); | |
| i = i >= 1 && i <= 12 ? i - 1 : 0; | |
| let r = parseInt(e[3], 10); | |
| r = r >= 1 && r <= 31 ? r : 1; | |
| let a = parseInt(e[4], 10); | |
| a = a >= 0 && a <= 23 ? a : 0; | |
| let l = parseInt(e[5], 10); | |
| l = l >= 0 && l <= 59 ? l : 0; | |
| let c = parseInt(e[6], 10); | |
| c = c >= 0 && c <= 59 ? c : 0; | |
| const h = e[7] || "Z"; | |
| let u = parseInt(e[8], 10); | |
| u = u >= 0 && u <= 23 ? u : 0; | |
| let d = parseInt(e[9], 10) || 0; | |
| return d = d >= 0 && d <= 59 ? d : 0, h === "-" ? (a += u, l += d) : h === "+" && (a -= u, l -= d), new Date(Date.UTC(s, i, r, a, l, c)); | |
| } | |
| } | |
| ac = new WeakMap(), b(Vp, ac); | |
| function BE(n, { | |
| scale: t = 1, | |
| rotation: e = 0 | |
| }) { | |
| const { | |
| width: s, | |
| height: i | |
| } = n.attributes.style, r = [0, 0, parseInt(s), parseInt(i)]; | |
| return new Nh({ | |
| viewBox: r, | |
| userUnit: 1, | |
| scale: t, | |
| rotation: e | |
| }); | |
| } | |
| function Gp(n) { | |
| if (n.startsWith("#")) { | |
| const t = parseInt(n.slice(1), 16); | |
| return [(t & 16711680) >> 16, (t & 65280) >> 8, t & 255]; | |
| } | |
| return n.startsWith("rgb(") ? n.slice(4, -1).split(",").map((t) => parseInt(t)) : n.startsWith("rgba(") ? n.slice(5, -1).split(",").map((t) => parseInt(t)).slice(0, 3) : (st(`Not a valid color format: "${n}"`), [0, 0, 0]); | |
| } | |
| function HE(n) { | |
| const t = document.createElement("span"); | |
| t.style.visibility = "hidden", document.body.append(t); | |
| for (const e of n.keys()) { | |
| t.style.color = e; | |
| const s = window.getComputedStyle(t).color; | |
| n.set(e, Gp(s)); | |
| } | |
| t.remove(); | |
| } | |
| function Mt(n) { | |
| const { | |
| a: t, | |
| b: e, | |
| c: s, | |
| d: i, | |
| e: r, | |
| f: a | |
| } = n.getTransform(); | |
| return [t, e, s, i, r, a]; | |
| } | |
| function Vs(n) { | |
| const { | |
| a: t, | |
| b: e, | |
| c: s, | |
| d: i, | |
| e: r, | |
| f: a | |
| } = n.getTransform().invertSelf(); | |
| return [t, e, s, i, r, a]; | |
| } | |
| function fa(n, t, e = !1, s = !0) { | |
| if (t instanceof Nh) { | |
| const { | |
| pageWidth: i, | |
| pageHeight: r | |
| } = t.rawDims, { | |
| style: a | |
| } = n, l = Me.isCSSRoundSupported, c = `var(--scale-factor) * ${i}px`, h = `var(--scale-factor) * ${r}px`, u = l ? `round(down, ${c}, var(--scale-round-x, 1px))` : `calc(${c})`, d = l ? `round(down, ${h}, var(--scale-round-y, 1px))` : `calc(${h})`; | |
| !e || t.rotation % 180 === 0 ? (a.width = u, a.height = d) : (a.width = d, a.height = u); | |
| } | |
| s && n.setAttribute("data-main-rotation", t.rotation); | |
| } | |
| class ff { | |
| constructor() { | |
| const t = window.devicePixelRatio || 1; | |
| this.sx = t, this.sy = t; | |
| } | |
| get scaled() { | |
| return this.sx !== 1 || this.sy !== 1; | |
| } | |
| get symmetric() { | |
| return this.sx === this.sy; | |
| } | |
| } | |
| var nn, ir, Es, nr, oc, lc, Wu, By, Ne, Hy, Uy, Wh, zy, gf; | |
| const bi = class bi { | |
| constructor(t) { | |
| b(this, Ne); | |
| b(this, nn, null); | |
| b(this, ir, null); | |
| b(this, Es); | |
| b(this, nr, null); | |
| b(this, oc, null); | |
| p(this, Es, t), o(bi, lc) || p(bi, lc, Object.freeze({ | |
| freetext: "pdfjs-editor-remove-freetext-button", | |
| highlight: "pdfjs-editor-remove-highlight-button", | |
| ink: "pdfjs-editor-remove-ink-button", | |
| stamp: "pdfjs-editor-remove-stamp-button" | |
| })); | |
| } | |
| render() { | |
| const t = p(this, nn, document.createElement("div")); | |
| t.classList.add("editToolbar", "hidden"), t.setAttribute("role", "toolbar"); | |
| const e = o(this, Es)._uiManager._signal; | |
| t.addEventListener("contextmenu", Hs, { | |
| signal: e | |
| }), t.addEventListener("pointerdown", v(bi, Wu, By), { | |
| signal: e | |
| }); | |
| const s = p(this, nr, document.createElement("div")); | |
| s.className = "buttons", t.append(s); | |
| const i = o(this, Es).toolbarPosition; | |
| if (i) { | |
| const { | |
| style: r | |
| } = t, a = o(this, Es)._uiManager.direction === "ltr" ? 1 - i[0] : i[0]; | |
| r.insetInlineEnd = `${100 * a}%`, r.top = `calc(${100 * i[1]}% + var(--editor-toolbar-vert-offset))`; | |
| } | |
| return v(this, Ne, zy).call(this), t; | |
| } | |
| get div() { | |
| return o(this, nn); | |
| } | |
| hide() { | |
| var t; | |
| o(this, nn).classList.add("hidden"), (t = o(this, ir)) == null || t.hideDropdown(); | |
| } | |
| show() { | |
| var t; | |
| o(this, nn).classList.remove("hidden"), (t = o(this, oc)) == null || t.shown(); | |
| } | |
| async addAltText(t) { | |
| const e = await t.render(); | |
| v(this, Ne, Wh).call(this, e), o(this, nr).prepend(e, o(this, Ne, gf)), p(this, oc, t); | |
| } | |
| addColorPicker(t) { | |
| p(this, ir, t); | |
| const e = t.renderButton(); | |
| v(this, Ne, Wh).call(this, e), o(this, nr).prepend(e, o(this, Ne, gf)); | |
| } | |
| remove() { | |
| var t; | |
| o(this, nn).remove(), (t = o(this, ir)) == null || t.destroy(), p(this, ir, null); | |
| } | |
| }; | |
| nn = new WeakMap(), ir = new WeakMap(), Es = new WeakMap(), nr = new WeakMap(), oc = new WeakMap(), lc = new WeakMap(), Wu = new WeakSet(), By = function(t) { | |
| t.stopPropagation(); | |
| }, Ne = new WeakSet(), Hy = function(t) { | |
| o(this, Es)._focusEventsAllowed = !1, ns(t); | |
| }, Uy = function(t) { | |
| o(this, Es)._focusEventsAllowed = !0, ns(t); | |
| }, Wh = function(t) { | |
| const e = o(this, Es)._uiManager._signal; | |
| t.addEventListener("focusin", v(this, Ne, Hy).bind(this), { | |
| capture: !0, | |
| signal: e | |
| }), t.addEventListener("focusout", v(this, Ne, Uy).bind(this), { | |
| capture: !0, | |
| signal: e | |
| }), t.addEventListener("contextmenu", Hs, { | |
| signal: e | |
| }); | |
| }, zy = function() { | |
| const { | |
| editorType: t, | |
| _uiManager: e | |
| } = o(this, Es), s = document.createElement("button"); | |
| s.className = "delete", s.tabIndex = 0, s.setAttribute("data-l10n-id", o(bi, lc)[t]), v(this, Ne, Wh).call(this, s), s.addEventListener("click", (i) => { | |
| e.delete(); | |
| }, { | |
| signal: e._signal | |
| }), o(this, nr).append(s); | |
| }, gf = function() { | |
| const t = document.createElement("div"); | |
| return t.className = "divider", t; | |
| }, b(bi, Wu), b(bi, lc, null); | |
| let pf = bi; | |
| var cc, rr, ar, Un, Vy, Gy, qy; | |
| class UE { | |
| constructor(t) { | |
| b(this, Un); | |
| b(this, cc, null); | |
| b(this, rr, null); | |
| b(this, ar); | |
| p(this, ar, t); | |
| } | |
| show(t, e, s) { | |
| const [i, r] = v(this, Un, Gy).call(this, e, s), { | |
| style: a | |
| } = o(this, rr) || p(this, rr, v(this, Un, Vy).call(this)); | |
| t.append(o(this, rr)), a.insetInlineEnd = `${100 * i}%`, a.top = `calc(${100 * r}% + var(--editor-toolbar-vert-offset))`; | |
| } | |
| hide() { | |
| o(this, rr).remove(); | |
| } | |
| } | |
| cc = new WeakMap(), rr = new WeakMap(), ar = new WeakMap(), Un = new WeakSet(), Vy = function() { | |
| const t = p(this, rr, document.createElement("div")); | |
| t.className = "editToolbar", t.setAttribute("role", "toolbar"), t.addEventListener("contextmenu", Hs, { | |
| signal: o(this, ar)._signal | |
| }); | |
| const e = p(this, cc, document.createElement("div")); | |
| return e.className = "buttons", t.append(e), v(this, Un, qy).call(this), t; | |
| }, Gy = function(t, e) { | |
| let s = 0, i = 0; | |
| for (const r of t) { | |
| const a = r.y + r.height; | |
| if (a < s) | |
| continue; | |
| const l = r.x + (e ? r.width : 0); | |
| if (a > s) { | |
| i = l, s = a; | |
| continue; | |
| } | |
| e ? l > i && (i = l) : l < i && (i = l); | |
| } | |
| return [e ? 1 - i : i, s]; | |
| }, qy = function() { | |
| const t = document.createElement("button"); | |
| t.className = "highlightButton", t.tabIndex = 0, t.setAttribute("data-l10n-id", "pdfjs-highlight-floating-button1"); | |
| const e = document.createElement("span"); | |
| t.append(e), e.className = "visuallyHidden", e.setAttribute("data-l10n-id", "pdfjs-highlight-floating-button-label"); | |
| const s = o(this, ar)._signal; | |
| t.addEventListener("contextmenu", Hs, { | |
| signal: s | |
| }), t.addEventListener("click", () => { | |
| o(this, ar).highlightSelection("floating_button"); | |
| }, { | |
| signal: s | |
| }), o(this, cc).append(t); | |
| }; | |
| function ju(n, t, e) { | |
| for (const s of e) | |
| t.addEventListener(s, n[s].bind(n)); | |
| } | |
| var Xu; | |
| class zE { | |
| constructor() { | |
| b(this, Xu, 0); | |
| } | |
| get id() { | |
| return `${SE}${xe(this, Xu)._++}`; | |
| } | |
| } | |
| Xu = new WeakMap(); | |
| var Da, hc, be, Fa, Xh; | |
| const Yp = class Yp { | |
| constructor() { | |
| b(this, Fa); | |
| b(this, Da, DE()); | |
| b(this, hc, 0); | |
| b(this, be, null); | |
| } | |
| static get _isSVGFittingCanvas() { | |
| const t = 'data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>', s = new OffscreenCanvas(1, 3).getContext("2d", { | |
| willReadFrequently: !0 | |
| }), i = new Image(); | |
| i.src = t; | |
| const r = i.decode().then(() => (s.drawImage(i, 0, 0, 1, 1, 0, 0, 1, 3), new Uint32Array(s.getImageData(0, 0, 1, 1).data.buffer)[0] === 0)); | |
| return at(this, "_isSVGFittingCanvas", r); | |
| } | |
| async getFromFile(t) { | |
| const { | |
| lastModified: e, | |
| name: s, | |
| size: i, | |
| type: r | |
| } = t; | |
| return v(this, Fa, Xh).call(this, `${e}_${s}_${i}_${r}`, t); | |
| } | |
| async getFromUrl(t) { | |
| return v(this, Fa, Xh).call(this, t, t); | |
| } | |
| async getFromBlob(t, e) { | |
| const s = await e; | |
| return v(this, Fa, Xh).call(this, t, s); | |
| } | |
| async getFromId(t) { | |
| o(this, be) || p(this, be, /* @__PURE__ */ new Map()); | |
| const e = o(this, be).get(t); | |
| if (!e) | |
| return null; | |
| if (e.bitmap) | |
| return e.refCounter += 1, e; | |
| if (e.file) | |
| return this.getFromFile(e.file); | |
| if (e.blobPromise) { | |
| const { | |
| blobPromise: s | |
| } = e; | |
| return delete e.blobPromise, this.getFromBlob(e.id, s); | |
| } | |
| return this.getFromUrl(e.url); | |
| } | |
| getFromCanvas(t, e) { | |
| o(this, be) || p(this, be, /* @__PURE__ */ new Map()); | |
| let s = o(this, be).get(t); | |
| if (s != null && s.bitmap) | |
| return s.refCounter += 1, s; | |
| const i = new OffscreenCanvas(e.width, e.height); | |
| return i.getContext("2d").drawImage(e, 0, 0), s = { | |
| bitmap: i.transferToImageBitmap(), | |
| id: `image_${o(this, Da)}_${xe(this, hc)._++}`, | |
| refCounter: 1, | |
| isSvg: !1 | |
| }, o(this, be).set(t, s), o(this, be).set(s.id, s), s; | |
| } | |
| getSvgUrl(t) { | |
| const e = o(this, be).get(t); | |
| return e != null && e.isSvg ? e.svgUrl : null; | |
| } | |
| deleteId(t) { | |
| var i; | |
| o(this, be) || p(this, be, /* @__PURE__ */ new Map()); | |
| const e = o(this, be).get(t); | |
| if (!e || (e.refCounter -= 1, e.refCounter !== 0)) | |
| return; | |
| const { | |
| bitmap: s | |
| } = e; | |
| if (!e.url && !e.file) { | |
| const r = new OffscreenCanvas(s.width, s.height); | |
| r.getContext("bitmaprenderer").transferFromImageBitmap(s), e.blobPromise = r.convertToBlob(); | |
| } | |
| (i = s.close) == null || i.call(s), e.bitmap = null; | |
| } | |
| isValidId(t) { | |
| return t.startsWith(`image_${o(this, Da)}_`); | |
| } | |
| }; | |
| Da = new WeakMap(), hc = new WeakMap(), be = new WeakMap(), Fa = new WeakSet(), Xh = async function(t, e) { | |
| o(this, be) || p(this, be, /* @__PURE__ */ new Map()); | |
| let s = o(this, be).get(t); | |
| if (s === null) | |
| return null; | |
| if (s != null && s.bitmap) | |
| return s.refCounter += 1, s; | |
| try { | |
| s || (s = { | |
| bitmap: null, | |
| id: `image_${o(this, Da)}_${xe(this, hc)._++}`, | |
| refCounter: 0, | |
| isSvg: !1 | |
| }); | |
| let i; | |
| if (typeof e == "string" ? (s.url = e, i = await Ad(e, "blob")) : e instanceof File ? i = s.file = e : e instanceof Blob && (i = e), i.type === "image/svg+xml") { | |
| const r = Yp._isSVGFittingCanvas, a = new FileReader(), l = new Image(), c = new Promise((h, u) => { | |
| l.onload = () => { | |
| s.bitmap = l, s.isSvg = !0, h(); | |
| }, a.onload = async () => { | |
| const d = s.svgUrl = a.result; | |
| l.src = await r ? `${d}#svgView(preserveAspectRatio(none))` : d; | |
| }, l.onerror = a.onerror = u; | |
| }); | |
| a.readAsDataURL(i), await c; | |
| } else | |
| s.bitmap = await createImageBitmap(i); | |
| s.refCounter = 1; | |
| } catch (i) { | |
| st(i), s = null; | |
| } | |
| return o(this, be).set(t, s), s && o(this, be).set(s.id, s), s; | |
| }; | |
| let mf = Yp; | |
| var Ht, rn, uc, Ot; | |
| class VE { | |
| constructor(t = 128) { | |
| b(this, Ht, []); | |
| b(this, rn, !1); | |
| b(this, uc); | |
| b(this, Ot, -1); | |
| p(this, uc, t); | |
| } | |
| add({ | |
| cmd: t, | |
| undo: e, | |
| post: s, | |
| mustExec: i, | |
| type: r = NaN, | |
| overwriteIfSameType: a = !1, | |
| keepUndo: l = !1 | |
| }) { | |
| if (i && t(), o(this, rn)) | |
| return; | |
| const c = { | |
| cmd: t, | |
| undo: e, | |
| post: s, | |
| type: r | |
| }; | |
| if (o(this, Ot) === -1) { | |
| o(this, Ht).length > 0 && (o(this, Ht).length = 0), p(this, Ot, 0), o(this, Ht).push(c); | |
| return; | |
| } | |
| if (a && o(this, Ht)[o(this, Ot)].type === r) { | |
| l && (c.undo = o(this, Ht)[o(this, Ot)].undo), o(this, Ht)[o(this, Ot)] = c; | |
| return; | |
| } | |
| const h = o(this, Ot) + 1; | |
| h === o(this, uc) ? o(this, Ht).splice(0, 1) : (p(this, Ot, h), h < o(this, Ht).length && o(this, Ht).splice(h)), o(this, Ht).push(c); | |
| } | |
| undo() { | |
| if (o(this, Ot) === -1) | |
| return; | |
| p(this, rn, !0); | |
| const { | |
| undo: t, | |
| post: e | |
| } = o(this, Ht)[o(this, Ot)]; | |
| t(), e == null || e(), p(this, rn, !1), p(this, Ot, o(this, Ot) - 1); | |
| } | |
| redo() { | |
| if (o(this, Ot) < o(this, Ht).length - 1) { | |
| p(this, Ot, o(this, Ot) + 1), p(this, rn, !0); | |
| const { | |
| cmd: t, | |
| post: e | |
| } = o(this, Ht)[o(this, Ot)]; | |
| t(), e == null || e(), p(this, rn, !1); | |
| } | |
| } | |
| hasSomethingToUndo() { | |
| return o(this, Ot) !== -1; | |
| } | |
| hasSomethingToRedo() { | |
| return o(this, Ot) < o(this, Ht).length - 1; | |
| } | |
| cleanType(t) { | |
| if (o(this, Ot) !== -1) { | |
| for (let e = o(this, Ot); e >= 0; e--) | |
| if (o(this, Ht)[e].type !== t) { | |
| o(this, Ht).splice(e + 1, o(this, Ot) - e), p(this, Ot, e); | |
| return; | |
| } | |
| o(this, Ht).length = 0, p(this, Ot, -1); | |
| } | |
| } | |
| destroy() { | |
| p(this, Ht, null); | |
| } | |
| } | |
| Ht = new WeakMap(), rn = new WeakMap(), uc = new WeakMap(), Ot = new WeakMap(); | |
| var Zu, Wy; | |
| class Oh { | |
| constructor(t) { | |
| b(this, Zu); | |
| this.buffer = [], this.callbacks = /* @__PURE__ */ new Map(), this.allKeys = /* @__PURE__ */ new Set(); | |
| const { | |
| isMac: e | |
| } = Me.platform; | |
| for (const [s, i, r = {}] of t) | |
| for (const a of s) { | |
| const l = a.startsWith("mac+"); | |
| e && l ? (this.callbacks.set(a.slice(4), { | |
| callback: i, | |
| options: r | |
| }), this.allKeys.add(a.split("+").at(-1))) : !e && !l && (this.callbacks.set(a, { | |
| callback: i, | |
| options: r | |
| }), this.allKeys.add(a.split("+").at(-1))); | |
| } | |
| } | |
| exec(t, e) { | |
| if (!this.allKeys.has(e.key)) | |
| return; | |
| const s = this.callbacks.get(v(this, Zu, Wy).call(this, e)); | |
| if (!s) | |
| return; | |
| const { | |
| callback: i, | |
| options: { | |
| bubbles: r = !1, | |
| args: a = [], | |
| checker: l = null | |
| } | |
| } = s; | |
| l && !l(t, e) || (i.bind(t, ...a, e)(), r || ns(e)); | |
| } | |
| } | |
| Zu = new WeakSet(), Wy = function(t) { | |
| t.altKey && this.buffer.push("alt"), t.ctrlKey && this.buffer.push("ctrl"), t.metaKey && this.buffer.push("meta"), t.shiftKey && this.buffer.push("shift"), this.buffer.push(t.key); | |
| const e = this.buffer.join("+"); | |
| return this.buffer.length = 0, e; | |
| }; | |
| const Yu = class Yu { | |
| get _colors() { | |
| const t = /* @__PURE__ */ new Map([["CanvasText", null], ["Canvas", null]]); | |
| return HE(t), at(this, "_colors", t); | |
| } | |
| convert(t) { | |
| const e = Gp(t); | |
| if (!window.matchMedia("(forced-colors: active)").matches) | |
| return e; | |
| for (const [s, i] of this._colors) | |
| if (i.every((r, a) => r === e[a])) | |
| return Yu._colorsMapping.get(s); | |
| return e; | |
| } | |
| getHexCode(t) { | |
| const e = this._colors.get(t); | |
| return e ? U.makeHexColor(...e) : t; | |
| } | |
| }; | |
| G(Yu, "_colorsMapping", /* @__PURE__ */ new Map([["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]]])); | |
| let yf = Yu; | |
| var $a, ze, Yt, ce, ja, Ai, Ba, cs, an, or, Ha, lr, Ws, xs, cr, dc, fc, Ua, pc, Xs, on, za, ln, Zs, Ku, cn, gc, hn, hr, mc, yc, te, bt, wi, ur, bc, vc, un, Ys, Si, _c, hs, N, Zh, bf, Xy, Zy, Yh, Yy, Ky, Jy, vf, Qy, _f, Af, tb, Ce, mi, eb, sb, wf, ib, ul, Sf; | |
| const Pa = class Pa { | |
| constructor(t, e, s, i, r, a, l, c, h, u, d, f, g) { | |
| b(this, N); | |
| b(this, $a, new AbortController()); | |
| b(this, ze, null); | |
| b(this, Yt, /* @__PURE__ */ new Map()); | |
| b(this, ce, /* @__PURE__ */ new Map()); | |
| b(this, ja, null); | |
| b(this, Ai, null); | |
| b(this, Ba, null); | |
| b(this, cs, new VE()); | |
| b(this, an, null); | |
| b(this, or, null); | |
| b(this, Ha, 0); | |
| b(this, lr, /* @__PURE__ */ new Set()); | |
| b(this, Ws, null); | |
| b(this, xs, null); | |
| b(this, cr, /* @__PURE__ */ new Set()); | |
| G(this, "_editorUndoBar", null); | |
| b(this, dc, !1); | |
| b(this, fc, !1); | |
| b(this, Ua, !1); | |
| b(this, pc, null); | |
| b(this, Xs, null); | |
| b(this, on, null); | |
| b(this, za, null); | |
| b(this, ln, !1); | |
| b(this, Zs, null); | |
| b(this, Ku, new zE()); | |
| b(this, cn, !1); | |
| b(this, gc, !1); | |
| b(this, hn, null); | |
| b(this, hr, null); | |
| b(this, mc, null); | |
| b(this, yc, null); | |
| b(this, te, et.NONE); | |
| b(this, bt, /* @__PURE__ */ new Set()); | |
| b(this, wi, null); | |
| b(this, ur, null); | |
| b(this, bc, null); | |
| b(this, vc, { | |
| isEditing: !1, | |
| isEmpty: !0, | |
| hasSomethingToUndo: !1, | |
| hasSomethingToRedo: !1, | |
| hasSelectedEditor: !1, | |
| hasSelectedText: !1 | |
| }); | |
| b(this, un, [0, 0]); | |
| b(this, Ys, null); | |
| b(this, Si, null); | |
| b(this, _c, null); | |
| b(this, hs, null); | |
| const m = this._signal = o(this, $a).signal; | |
| p(this, Si, t), p(this, _c, e), p(this, ja, s), this._eventBus = i, i._on("editingaction", this.onEditingAction.bind(this), { | |
| signal: m | |
| }), i._on("pagechanging", this.onPageChanging.bind(this), { | |
| signal: m | |
| }), i._on("scalechanging", this.onScaleChanging.bind(this), { | |
| signal: m | |
| }), i._on("rotationchanging", this.onRotationChanging.bind(this), { | |
| signal: m | |
| }), i._on("setpreference", this.onSetPreference.bind(this), { | |
| signal: m | |
| }), i._on("switchannotationeditorparams", (y) => this.updateParams(y.type, y.value), { | |
| signal: m | |
| }), v(this, N, Yy).call(this), v(this, N, tb).call(this), v(this, N, vf).call(this), p(this, Ai, r.annotationStorage), p(this, pc, r.filterFactory), p(this, ur, a), p(this, za, l || null), p(this, dc, c), p(this, fc, h), p(this, Ua, u), p(this, yc, d || null), this.viewParameters = { | |
| realScale: Hn.PDF_TO_CSS_UNITS, | |
| rotation: 0 | |
| }, this.isShiftKeyDown = !1, this._editorUndoBar = f || null, this._supportsPinchToZoom = g !== !1; | |
| } | |
| static get _keyboardManager() { | |
| const t = Pa.prototype, e = (a) => o(a, Si).contains(document.activeElement) && document.activeElement.tagName !== "BUTTON" && a.hasSomethingToControl(), s = (a, { | |
| target: l | |
| }) => { | |
| if (l instanceof HTMLInputElement) { | |
| const { | |
| type: c | |
| } = l; | |
| return c !== "text" && c !== "number"; | |
| } | |
| return !0; | |
| }, i = this.TRANSLATE_SMALL, r = this.TRANSLATE_BIG; | |
| return at(this, "_keyboardManager", new Oh([[["ctrl+a", "mac+meta+a"], t.selectAll, { | |
| checker: s | |
| }], [["ctrl+z", "mac+meta+z"], t.undo, { | |
| checker: s | |
| }], [["ctrl+y", "ctrl+shift+z", "mac+meta+shift+z", "ctrl+shift+Z", "mac+meta+shift+Z"], t.redo, { | |
| checker: s | |
| }], [["Backspace", "alt+Backspace", "ctrl+Backspace", "shift+Backspace", "mac+Backspace", "mac+alt+Backspace", "mac+ctrl+Backspace", "Delete", "ctrl+Delete", "shift+Delete", "mac+Delete"], t.delete, { | |
| checker: s | |
| }], [["Enter", "mac+Enter"], t.addNewEditorFromKeyboard, { | |
| checker: (a, { | |
| target: l | |
| }) => !(l instanceof HTMLButtonElement) && o(a, Si).contains(l) && !a.isEnterHandled | |
| }], [[" ", "mac+ "], t.addNewEditorFromKeyboard, { | |
| checker: (a, { | |
| target: l | |
| }) => !(l instanceof HTMLButtonElement) && o(a, Si).contains(document.activeElement) | |
| }], [["Escape", "mac+Escape"], t.unselectAll], [["ArrowLeft", "mac+ArrowLeft"], t.translateSelectedEditors, { | |
| args: [-i, 0], | |
| checker: e | |
| }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], t.translateSelectedEditors, { | |
| args: [-r, 0], | |
| checker: e | |
| }], [["ArrowRight", "mac+ArrowRight"], t.translateSelectedEditors, { | |
| args: [i, 0], | |
| checker: e | |
| }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], t.translateSelectedEditors, { | |
| args: [r, 0], | |
| checker: e | |
| }], [["ArrowUp", "mac+ArrowUp"], t.translateSelectedEditors, { | |
| args: [0, -i], | |
| checker: e | |
| }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], t.translateSelectedEditors, { | |
| args: [0, -r], | |
| checker: e | |
| }], [["ArrowDown", "mac+ArrowDown"], t.translateSelectedEditors, { | |
| args: [0, i], | |
| checker: e | |
| }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], t.translateSelectedEditors, { | |
| args: [0, r], | |
| checker: e | |
| }]])); | |
| } | |
| destroy() { | |
| var t, e, s, i, r; | |
| (t = o(this, hs)) == null || t.resolve(), p(this, hs, null), (e = o(this, $a)) == null || e.abort(), p(this, $a, null), this._signal = null; | |
| for (const a of o(this, ce).values()) | |
| a.destroy(); | |
| o(this, ce).clear(), o(this, Yt).clear(), o(this, cr).clear(), p(this, ze, null), o(this, bt).clear(), o(this, cs).destroy(), (s = o(this, ja)) == null || s.destroy(), (i = o(this, Zs)) == null || i.hide(), p(this, Zs, null), o(this, Xs) && (clearTimeout(o(this, Xs)), p(this, Xs, null)), o(this, Ys) && (clearTimeout(o(this, Ys)), p(this, Ys, null)), (r = this._editorUndoBar) == null || r.destroy(); | |
| } | |
| combinedSignal(t) { | |
| return AbortSignal.any([this._signal, t.signal]); | |
| } | |
| get mlManager() { | |
| return o(this, yc); | |
| } | |
| get useNewAltTextFlow() { | |
| return o(this, fc); | |
| } | |
| get useNewAltTextWhenAddingImage() { | |
| return o(this, Ua); | |
| } | |
| get hcmFilter() { | |
| return at(this, "hcmFilter", o(this, ur) ? o(this, pc).addHCMFilter(o(this, ur).foreground, o(this, ur).background) : "none"); | |
| } | |
| get direction() { | |
| return at(this, "direction", getComputedStyle(o(this, Si)).direction); | |
| } | |
| get highlightColors() { | |
| return at(this, "highlightColors", o(this, za) ? new Map(o(this, za).split(",").map((t) => t.split("=").map((e) => e.trim()))) : null); | |
| } | |
| get highlightColorNames() { | |
| return at(this, "highlightColorNames", this.highlightColors ? new Map(Array.from(this.highlightColors, (t) => t.reverse())) : null); | |
| } | |
| setCurrentDrawingSession(t) { | |
| t ? (this.unselectAll(), this.disableUserSelect(!0)) : this.disableUserSelect(!1), p(this, or, t); | |
| } | |
| setMainHighlightColorPicker(t) { | |
| p(this, mc, t); | |
| } | |
| editAltText(t, e = !1) { | |
| var s; | |
| (s = o(this, ja)) == null || s.editAltText(this, t, e); | |
| } | |
| switchToMode(t, e) { | |
| this._eventBus.on("annotationeditormodechanged", e, { | |
| once: !0, | |
| signal: this._signal | |
| }), this._eventBus.dispatch("showannotationeditorui", { | |
| source: this, | |
| mode: t | |
| }); | |
| } | |
| setPreference(t, e) { | |
| this._eventBus.dispatch("setpreference", { | |
| source: this, | |
| name: t, | |
| value: e | |
| }); | |
| } | |
| onSetPreference({ | |
| name: t, | |
| value: e | |
| }) { | |
| switch (t) { | |
| case "enableNewAltTextWhenAddingImage": | |
| p(this, Ua, e); | |
| break; | |
| } | |
| } | |
| onPageChanging({ | |
| pageNumber: t | |
| }) { | |
| p(this, Ha, t - 1); | |
| } | |
| focusMainContainer() { | |
| o(this, Si).focus(); | |
| } | |
| findParent(t, e) { | |
| for (const s of o(this, ce).values()) { | |
| const { | |
| x: i, | |
| y: r, | |
| width: a, | |
| height: l | |
| } = s.div.getBoundingClientRect(); | |
| if (t >= i && t <= i + a && e >= r && e <= r + l) | |
| return s; | |
| } | |
| return null; | |
| } | |
| disableUserSelect(t = !1) { | |
| o(this, _c).classList.toggle("noUserSelect", t); | |
| } | |
| addShouldRescale(t) { | |
| o(this, cr).add(t); | |
| } | |
| removeShouldRescale(t) { | |
| o(this, cr).delete(t); | |
| } | |
| onScaleChanging({ | |
| scale: t | |
| }) { | |
| var e; | |
| this.commitOrRemove(), this.viewParameters.realScale = t * Hn.PDF_TO_CSS_UNITS; | |
| for (const s of o(this, cr)) | |
| s.onScaleChanging(); | |
| (e = o(this, or)) == null || e.onScaleChanging(); | |
| } | |
| onRotationChanging({ | |
| pagesRotation: t | |
| }) { | |
| this.commitOrRemove(), this.viewParameters.rotation = t; | |
| } | |
| highlightSelection(t = "") { | |
| const e = document.getSelection(); | |
| if (!e || e.isCollapsed) | |
| return; | |
| const { | |
| anchorNode: s, | |
| anchorOffset: i, | |
| focusNode: r, | |
| focusOffset: a | |
| } = e, l = e.toString(), h = v(this, N, Zh).call(this, e).closest(".textLayer"), u = this.getSelectionBoxes(h); | |
| if (!u) | |
| return; | |
| e.empty(); | |
| const d = v(this, N, bf).call(this, h), f = o(this, te) === et.NONE, g = () => { | |
| d == null || d.createAndAddNewEditor({ | |
| x: 0, | |
| y: 0 | |
| }, !1, { | |
| methodOfCreation: t, | |
| boxes: u, | |
| anchorNode: s, | |
| anchorOffset: i, | |
| focusNode: r, | |
| focusOffset: a, | |
| text: l | |
| }), f && this.showAllEditors("highlight", !0, !0); | |
| }; | |
| if (f) { | |
| this.switchToMode(et.HIGHLIGHT, g); | |
| return; | |
| } | |
| g(); | |
| } | |
| addToAnnotationStorage(t) { | |
| !t.isEmpty() && o(this, Ai) && !o(this, Ai).has(t.id) && o(this, Ai).setValue(t.id, t); | |
| } | |
| blur() { | |
| if (this.isShiftKeyDown = !1, o(this, ln) && (p(this, ln, !1), v(this, N, Yh).call(this, "main_toolbar")), !this.hasSelection) | |
| return; | |
| const { | |
| activeElement: t | |
| } = document; | |
| for (const e of o(this, bt)) | |
| if (e.div.contains(t)) { | |
| p(this, hr, [e, t]), e._focusEventsAllowed = !1; | |
| break; | |
| } | |
| } | |
| focus() { | |
| if (!o(this, hr)) | |
| return; | |
| const [t, e] = o(this, hr); | |
| p(this, hr, null), e.addEventListener("focusin", () => { | |
| t._focusEventsAllowed = !0; | |
| }, { | |
| once: !0, | |
| signal: this._signal | |
| }), e.focus(); | |
| } | |
| addEditListeners() { | |
| v(this, N, vf).call(this), v(this, N, _f).call(this); | |
| } | |
| removeEditListeners() { | |
| v(this, N, Qy).call(this), v(this, N, Af).call(this); | |
| } | |
| dragOver(t) { | |
| for (const { | |
| type: e | |
| } of t.dataTransfer.items) | |
| for (const s of o(this, xs)) | |
| if (s.isHandlingMimeForPasting(e)) { | |
| t.dataTransfer.dropEffect = "copy", t.preventDefault(); | |
| return; | |
| } | |
| } | |
| drop(t) { | |
| for (const e of t.dataTransfer.items) | |
| for (const s of o(this, xs)) | |
| if (s.isHandlingMimeForPasting(e.type)) { | |
| s.paste(e, this.currentLayer), t.preventDefault(); | |
| return; | |
| } | |
| } | |
| copy(t) { | |
| var s; | |
| if (t.preventDefault(), (s = o(this, ze)) == null || s.commitOrRemove(), !this.hasSelection) | |
| return; | |
| const e = []; | |
| for (const i of o(this, bt)) { | |
| const r = i.serialize(!0); | |
| r && e.push(r); | |
| } | |
| e.length !== 0 && t.clipboardData.setData("application/pdfjs", JSON.stringify(e)); | |
| } | |
| cut(t) { | |
| this.copy(t), this.delete(); | |
| } | |
| async paste(t) { | |
| t.preventDefault(); | |
| const { | |
| clipboardData: e | |
| } = t; | |
| for (const r of e.items) | |
| for (const a of o(this, xs)) | |
| if (a.isHandlingMimeForPasting(r.type)) { | |
| a.paste(r, this.currentLayer); | |
| return; | |
| } | |
| let s = e.getData("application/pdfjs"); | |
| if (!s) | |
| return; | |
| try { | |
| s = JSON.parse(s); | |
| } catch (r) { | |
| st(`paste: "${r.message}".`); | |
| return; | |
| } | |
| if (!Array.isArray(s)) | |
| return; | |
| this.unselectAll(); | |
| const i = this.currentLayer; | |
| try { | |
| const r = []; | |
| for (const c of s) { | |
| const h = await i.deserialize(c); | |
| if (!h) | |
| return; | |
| r.push(h); | |
| } | |
| const a = () => { | |
| for (const c of r) | |
| v(this, N, wf).call(this, c); | |
| v(this, N, Sf).call(this, r); | |
| }, l = () => { | |
| for (const c of r) | |
| c.remove(); | |
| }; | |
| this.addCommands({ | |
| cmd: a, | |
| undo: l, | |
| mustExec: !0 | |
| }); | |
| } catch (r) { | |
| st(`paste: "${r.message}".`); | |
| } | |
| } | |
| keydown(t) { | |
| !this.isShiftKeyDown && t.key === "Shift" && (this.isShiftKeyDown = !0), o(this, te) !== et.NONE && !this.isEditorHandlingKeyboard && Pa._keyboardManager.exec(this, t); | |
| } | |
| keyup(t) { | |
| this.isShiftKeyDown && t.key === "Shift" && (this.isShiftKeyDown = !1, o(this, ln) && (p(this, ln, !1), v(this, N, Yh).call(this, "main_toolbar"))); | |
| } | |
| onEditingAction({ | |
| name: t | |
| }) { | |
| switch (t) { | |
| case "undo": | |
| case "redo": | |
| case "delete": | |
| case "selectAll": | |
| this[t](); | |
| break; | |
| case "highlightSelection": | |
| this.highlightSelection("context_menu"); | |
| break; | |
| } | |
| } | |
| setEditingState(t) { | |
| t ? (v(this, N, Ky).call(this), v(this, N, _f).call(this), v(this, N, Ce).call(this, { | |
| isEditing: o(this, te) !== et.NONE, | |
| isEmpty: v(this, N, ul).call(this), | |
| hasSomethingToUndo: o(this, cs).hasSomethingToUndo(), | |
| hasSomethingToRedo: o(this, cs).hasSomethingToRedo(), | |
| hasSelectedEditor: !1 | |
| })) : (v(this, N, Jy).call(this), v(this, N, Af).call(this), v(this, N, Ce).call(this, { | |
| isEditing: !1 | |
| }), this.disableUserSelect(!1)); | |
| } | |
| registerEditorTypes(t) { | |
| if (!o(this, xs)) { | |
| p(this, xs, t); | |
| for (const e of o(this, xs)) | |
| v(this, N, mi).call(this, e.defaultPropertiesToUpdate); | |
| } | |
| } | |
| getId() { | |
| return o(this, Ku).id; | |
| } | |
| get currentLayer() { | |
| return o(this, ce).get(o(this, Ha)); | |
| } | |
| getLayer(t) { | |
| return o(this, ce).get(t); | |
| } | |
| get currentPageIndex() { | |
| return o(this, Ha); | |
| } | |
| addLayer(t) { | |
| o(this, ce).set(t.pageIndex, t), o(this, cn) ? t.enable() : t.disable(); | |
| } | |
| removeLayer(t) { | |
| o(this, ce).delete(t.pageIndex); | |
| } | |
| async updateMode(t, e = null, s = !1) { | |
| var i; | |
| if (o(this, te) !== t && !(o(this, hs) && (await o(this, hs).promise, !o(this, hs)))) { | |
| if (p(this, hs, Promise.withResolvers()), p(this, te, t), t === et.NONE) { | |
| this.setEditingState(!1), v(this, N, sb).call(this), (i = this._editorUndoBar) == null || i.hide(), o(this, hs).resolve(); | |
| return; | |
| } | |
| this.setEditingState(!0), await v(this, N, eb).call(this), this.unselectAll(); | |
| for (const r of o(this, ce).values()) | |
| r.updateMode(t); | |
| if (!e) { | |
| s && this.addNewEditorFromKeyboard(), o(this, hs).resolve(); | |
| return; | |
| } | |
| for (const r of o(this, Yt).values()) | |
| r.annotationElementId === e ? (this.setSelected(r), r.enterInEditMode()) : r.unselect(); | |
| o(this, hs).resolve(); | |
| } | |
| } | |
| addNewEditorFromKeyboard() { | |
| this.currentLayer.canCreateNewEmptyEditor() && this.currentLayer.addNewEditor(); | |
| } | |
| updateToolbar(t) { | |
| t !== o(this, te) && this._eventBus.dispatch("switchannotationeditormode", { | |
| source: this, | |
| mode: t | |
| }); | |
| } | |
| updateParams(t, e) { | |
| var s; | |
| if (o(this, xs)) { | |
| switch (t) { | |
| case lt.CREATE: | |
| this.currentLayer.addNewEditor(); | |
| return; | |
| case lt.HIGHLIGHT_DEFAULT_COLOR: | |
| (s = o(this, mc)) == null || s.updateColor(e); | |
| break; | |
| case lt.HIGHLIGHT_SHOW_ALL: | |
| this._eventBus.dispatch("reporttelemetry", { | |
| source: this, | |
| details: { | |
| type: "editing", | |
| data: { | |
| type: "highlight", | |
| action: "toggle_visibility" | |
| } | |
| } | |
| }), (o(this, bc) || p(this, bc, /* @__PURE__ */ new Map())).set(t, e), this.showAllEditors("highlight", e); | |
| break; | |
| } | |
| for (const i of o(this, bt)) | |
| i.updateParams(t, e); | |
| for (const i of o(this, xs)) | |
| i.updateDefaultParams(t, e); | |
| } | |
| } | |
| showAllEditors(t, e, s = !1) { | |
| var r; | |
| for (const a of o(this, Yt).values()) | |
| a.editorType === t && a.show(e); | |
| (((r = o(this, bc)) == null ? void 0 : r.get(lt.HIGHLIGHT_SHOW_ALL)) ?? !0) !== e && v(this, N, mi).call(this, [[lt.HIGHLIGHT_SHOW_ALL, e]]); | |
| } | |
| enableWaiting(t = !1) { | |
| if (o(this, gc) !== t) { | |
| p(this, gc, t); | |
| for (const e of o(this, ce).values()) | |
| t ? e.disableClick() : e.enableClick(), e.div.classList.toggle("waiting", t); | |
| } | |
| } | |
| getEditors(t) { | |
| const e = []; | |
| for (const s of o(this, Yt).values()) | |
| s.pageIndex === t && e.push(s); | |
| return e; | |
| } | |
| getEditor(t) { | |
| return o(this, Yt).get(t); | |
| } | |
| addEditor(t) { | |
| o(this, Yt).set(t.id, t); | |
| } | |
| removeEditor(t) { | |
| var e; | |
| t.div.contains(document.activeElement) && (o(this, Xs) && clearTimeout(o(this, Xs)), p(this, Xs, setTimeout(() => { | |
| this.focusMainContainer(), p(this, Xs, null); | |
| }, 0))), o(this, Yt).delete(t.id), this.unselect(t), (!t.annotationElementId || !o(this, lr).has(t.annotationElementId)) && ((e = o(this, Ai)) == null || e.remove(t.id)); | |
| } | |
| addDeletedAnnotationElement(t) { | |
| o(this, lr).add(t.annotationElementId), this.addChangedExistingAnnotation(t), t.deleted = !0; | |
| } | |
| isDeletedAnnotationElement(t) { | |
| return o(this, lr).has(t); | |
| } | |
| removeDeletedAnnotationElement(t) { | |
| o(this, lr).delete(t.annotationElementId), this.removeChangedExistingAnnotation(t), t.deleted = !1; | |
| } | |
| setActiveEditor(t) { | |
| o(this, ze) !== t && (p(this, ze, t), t && v(this, N, mi).call(this, t.propertiesToUpdate)); | |
| } | |
| updateUI(t) { | |
| o(this, N, ib) === t && v(this, N, mi).call(this, t.propertiesToUpdate); | |
| } | |
| updateUIForDefaultProperties(t) { | |
| v(this, N, mi).call(this, t.defaultPropertiesToUpdate); | |
| } | |
| toggleSelected(t) { | |
| if (o(this, bt).has(t)) { | |
| o(this, bt).delete(t), t.unselect(), v(this, N, Ce).call(this, { | |
| hasSelectedEditor: this.hasSelection | |
| }); | |
| return; | |
| } | |
| o(this, bt).add(t), t.select(), v(this, N, mi).call(this, t.propertiesToUpdate), v(this, N, Ce).call(this, { | |
| hasSelectedEditor: !0 | |
| }); | |
| } | |
| setSelected(t) { | |
| var e; | |
| (e = o(this, or)) == null || e.commitOrRemove(); | |
| for (const s of o(this, bt)) | |
| s !== t && s.unselect(); | |
| o(this, bt).clear(), o(this, bt).add(t), t.select(), v(this, N, mi).call(this, t.propertiesToUpdate), v(this, N, Ce).call(this, { | |
| hasSelectedEditor: !0 | |
| }); | |
| } | |
| isSelected(t) { | |
| return o(this, bt).has(t); | |
| } | |
| get firstSelectedEditor() { | |
| return o(this, bt).values().next().value; | |
| } | |
| unselect(t) { | |
| t.unselect(), o(this, bt).delete(t), v(this, N, Ce).call(this, { | |
| hasSelectedEditor: this.hasSelection | |
| }); | |
| } | |
| get hasSelection() { | |
| return o(this, bt).size !== 0; | |
| } | |
| get isEnterHandled() { | |
| return o(this, bt).size === 1 && this.firstSelectedEditor.isEnterHandled; | |
| } | |
| undo() { | |
| var t; | |
| o(this, cs).undo(), v(this, N, Ce).call(this, { | |
| hasSomethingToUndo: o(this, cs).hasSomethingToUndo(), | |
| hasSomethingToRedo: !0, | |
| isEmpty: v(this, N, ul).call(this) | |
| }), (t = this._editorUndoBar) == null || t.hide(); | |
| } | |
| redo() { | |
| o(this, cs).redo(), v(this, N, Ce).call(this, { | |
| hasSomethingToUndo: !0, | |
| hasSomethingToRedo: o(this, cs).hasSomethingToRedo(), | |
| isEmpty: v(this, N, ul).call(this) | |
| }); | |
| } | |
| addCommands(t) { | |
| o(this, cs).add(t), v(this, N, Ce).call(this, { | |
| hasSomethingToUndo: !0, | |
| hasSomethingToRedo: !1, | |
| isEmpty: v(this, N, ul).call(this) | |
| }); | |
| } | |
| cleanUndoStack(t) { | |
| o(this, cs).cleanType(t); | |
| } | |
| delete() { | |
| var r; | |
| this.commitOrRemove(); | |
| const t = (r = this.currentLayer) == null ? void 0 : r.endDrawingSession(!0); | |
| if (!this.hasSelection && !t) | |
| return; | |
| const e = t ? [t] : [...o(this, bt)], s = () => { | |
| var a; | |
| (a = this._editorUndoBar) == null || a.show(i, e.length === 1 ? e[0].editorType : e.length); | |
| for (const l of e) | |
| l.remove(); | |
| }, i = () => { | |
| for (const a of e) | |
| v(this, N, wf).call(this, a); | |
| }; | |
| this.addCommands({ | |
| cmd: s, | |
| undo: i, | |
| mustExec: !0 | |
| }); | |
| } | |
| commitOrRemove() { | |
| var t; | |
| (t = o(this, ze)) == null || t.commitOrRemove(); | |
| } | |
| hasSomethingToControl() { | |
| return o(this, ze) || this.hasSelection; | |
| } | |
| selectAll() { | |
| for (const t of o(this, bt)) | |
| t.commit(); | |
| v(this, N, Sf).call(this, o(this, Yt).values()); | |
| } | |
| unselectAll() { | |
| var t; | |
| if (!(o(this, ze) && (o(this, ze).commitOrRemove(), o(this, te) !== et.NONE)) && !((t = o(this, or)) != null && t.commitOrRemove()) && this.hasSelection) { | |
| for (const e of o(this, bt)) | |
| e.unselect(); | |
| o(this, bt).clear(), v(this, N, Ce).call(this, { | |
| hasSelectedEditor: !1 | |
| }); | |
| } | |
| } | |
| translateSelectedEditors(t, e, s = !1) { | |
| if (s || this.commitOrRemove(), !this.hasSelection) | |
| return; | |
| o(this, un)[0] += t, o(this, un)[1] += e; | |
| const [i, r] = o(this, un), a = [...o(this, bt)], l = 1e3; | |
| o(this, Ys) && clearTimeout(o(this, Ys)), p(this, Ys, setTimeout(() => { | |
| p(this, Ys, null), o(this, un)[0] = o(this, un)[1] = 0, this.addCommands({ | |
| cmd: () => { | |
| for (const c of a) | |
| o(this, Yt).has(c.id) && c.translateInPage(i, r); | |
| }, | |
| undo: () => { | |
| for (const c of a) | |
| o(this, Yt).has(c.id) && c.translateInPage(-i, -r); | |
| }, | |
| mustExec: !1 | |
| }); | |
| }, l)); | |
| for (const c of a) | |
| c.translateInPage(t, e); | |
| } | |
| setUpDragSession() { | |
| if (this.hasSelection) { | |
| this.disableUserSelect(!0), p(this, Ws, /* @__PURE__ */ new Map()); | |
| for (const t of o(this, bt)) | |
| o(this, Ws).set(t, { | |
| savedX: t.x, | |
| savedY: t.y, | |
| savedPageIndex: t.pageIndex, | |
| newX: 0, | |
| newY: 0, | |
| newPageIndex: -1 | |
| }); | |
| } | |
| } | |
| endDragSession() { | |
| if (!o(this, Ws)) | |
| return !1; | |
| this.disableUserSelect(!1); | |
| const t = o(this, Ws); | |
| p(this, Ws, null); | |
| let e = !1; | |
| for (const [{ | |
| x: i, | |
| y: r, | |
| pageIndex: a | |
| }, l] of t) | |
| l.newX = i, l.newY = r, l.newPageIndex = a, e || (e = i !== l.savedX || r !== l.savedY || a !== l.savedPageIndex); | |
| if (!e) | |
| return !1; | |
| const s = (i, r, a, l) => { | |
| if (o(this, Yt).has(i.id)) { | |
| const c = o(this, ce).get(l); | |
| c ? i._setParentAndPosition(c, r, a) : (i.pageIndex = l, i.x = r, i.y = a); | |
| } | |
| }; | |
| return this.addCommands({ | |
| cmd: () => { | |
| for (const [i, { | |
| newX: r, | |
| newY: a, | |
| newPageIndex: l | |
| }] of t) | |
| s(i, r, a, l); | |
| }, | |
| undo: () => { | |
| for (const [i, { | |
| savedX: r, | |
| savedY: a, | |
| savedPageIndex: l | |
| }] of t) | |
| s(i, r, a, l); | |
| }, | |
| mustExec: !0 | |
| }), !0; | |
| } | |
| dragSelectedEditors(t, e) { | |
| if (o(this, Ws)) | |
| for (const s of o(this, Ws).keys()) | |
| s.drag(t, e); | |
| } | |
| rebuild(t) { | |
| if (t.parent === null) { | |
| const e = this.getLayer(t.pageIndex); | |
| e ? (e.changeParent(t), e.addOrRebuild(t)) : (this.addEditor(t), this.addToAnnotationStorage(t), t.rebuild()); | |
| } else | |
| t.parent.addOrRebuild(t); | |
| } | |
| get isEditorHandlingKeyboard() { | |
| var t; | |
| return ((t = this.getActive()) == null ? void 0 : t.shouldGetKeyboardEvents()) || o(this, bt).size === 1 && this.firstSelectedEditor.shouldGetKeyboardEvents(); | |
| } | |
| isActive(t) { | |
| return o(this, ze) === t; | |
| } | |
| getActive() { | |
| return o(this, ze); | |
| } | |
| getMode() { | |
| return o(this, te); | |
| } | |
| get imageManager() { | |
| return at(this, "imageManager", new mf()); | |
| } | |
| getSelectionBoxes(t) { | |
| if (!t) | |
| return null; | |
| const e = document.getSelection(); | |
| for (let h = 0, u = e.rangeCount; h < u; h++) | |
| if (!t.contains(e.getRangeAt(h).commonAncestorContainer)) | |
| return null; | |
| const { | |
| x: s, | |
| y: i, | |
| width: r, | |
| height: a | |
| } = t.getBoundingClientRect(); | |
| let l; | |
| switch (t.getAttribute("data-main-rotation")) { | |
| case "90": | |
| l = (h, u, d, f) => ({ | |
| x: (u - i) / a, | |
| y: 1 - (h + d - s) / r, | |
| width: f / a, | |
| height: d / r | |
| }); | |
| break; | |
| case "180": | |
| l = (h, u, d, f) => ({ | |
| x: 1 - (h + d - s) / r, | |
| y: 1 - (u + f - i) / a, | |
| width: d / r, | |
| height: f / a | |
| }); | |
| break; | |
| case "270": | |
| l = (h, u, d, f) => ({ | |
| x: 1 - (u + f - i) / a, | |
| y: (h - s) / r, | |
| width: f / a, | |
| height: d / r | |
| }); | |
| break; | |
| default: | |
| l = (h, u, d, f) => ({ | |
| x: (h - s) / r, | |
| y: (u - i) / a, | |
| width: d / r, | |
| height: f / a | |
| }); | |
| break; | |
| } | |
| const c = []; | |
| for (let h = 0, u = e.rangeCount; h < u; h++) { | |
| const d = e.getRangeAt(h); | |
| if (!d.collapsed) | |
| for (const { | |
| x: f, | |
| y: g, | |
| width: m, | |
| height: y | |
| } of d.getClientRects()) | |
| m === 0 || y === 0 || c.push(l(f, g, m, y)); | |
| } | |
| return c.length === 0 ? null : c; | |
| } | |
| addChangedExistingAnnotation({ | |
| annotationElementId: t, | |
| id: e | |
| }) { | |
| (o(this, Ba) || p(this, Ba, /* @__PURE__ */ new Map())).set(t, e); | |
| } | |
| removeChangedExistingAnnotation({ | |
| annotationElementId: t | |
| }) { | |
| var e; | |
| (e = o(this, Ba)) == null || e.delete(t); | |
| } | |
| renderAnnotationElement(t) { | |
| var i; | |
| const e = (i = o(this, Ba)) == null ? void 0 : i.get(t.data.id); | |
| if (!e) | |
| return; | |
| const s = o(this, Ai).getRawValue(e); | |
| s && (o(this, te) === et.NONE && !s.hasBeenModified || s.renderAnnotationElement(t)); | |
| } | |
| }; | |
| $a = new WeakMap(), ze = new WeakMap(), Yt = new WeakMap(), ce = new WeakMap(), ja = new WeakMap(), Ai = new WeakMap(), Ba = new WeakMap(), cs = new WeakMap(), an = new WeakMap(), or = new WeakMap(), Ha = new WeakMap(), lr = new WeakMap(), Ws = new WeakMap(), xs = new WeakMap(), cr = new WeakMap(), dc = new WeakMap(), fc = new WeakMap(), Ua = new WeakMap(), pc = new WeakMap(), Xs = new WeakMap(), on = new WeakMap(), za = new WeakMap(), ln = new WeakMap(), Zs = new WeakMap(), Ku = new WeakMap(), cn = new WeakMap(), gc = new WeakMap(), hn = new WeakMap(), hr = new WeakMap(), mc = new WeakMap(), yc = new WeakMap(), te = new WeakMap(), bt = new WeakMap(), wi = new WeakMap(), ur = new WeakMap(), bc = new WeakMap(), vc = new WeakMap(), un = new WeakMap(), Ys = new WeakMap(), Si = new WeakMap(), _c = new WeakMap(), hs = new WeakMap(), N = new WeakSet(), Zh = function({ | |
| anchorNode: t | |
| }) { | |
| return t.nodeType === Node.TEXT_NODE ? t.parentElement : t; | |
| }, bf = function(t) { | |
| const { | |
| currentLayer: e | |
| } = this; | |
| if (e.hasTextLayer(t)) | |
| return e; | |
| for (const s of o(this, ce).values()) | |
| if (s.hasTextLayer(t)) | |
| return s; | |
| return null; | |
| }, Xy = function() { | |
| const t = document.getSelection(); | |
| if (!t || t.isCollapsed) | |
| return; | |
| const s = v(this, N, Zh).call(this, t).closest(".textLayer"), i = this.getSelectionBoxes(s); | |
| i && (o(this, Zs) || p(this, Zs, new UE(this)), o(this, Zs).show(s, i, this.direction === "ltr")); | |
| }, Zy = function() { | |
| var r, a, l; | |
| const t = document.getSelection(); | |
| if (!t || t.isCollapsed) { | |
| o(this, wi) && ((r = o(this, Zs)) == null || r.hide(), p(this, wi, null), v(this, N, Ce).call(this, { | |
| hasSelectedText: !1 | |
| })); | |
| return; | |
| } | |
| const { | |
| anchorNode: e | |
| } = t; | |
| if (e === o(this, wi)) | |
| return; | |
| const i = v(this, N, Zh).call(this, t).closest(".textLayer"); | |
| if (!i) { | |
| o(this, wi) && ((a = o(this, Zs)) == null || a.hide(), p(this, wi, null), v(this, N, Ce).call(this, { | |
| hasSelectedText: !1 | |
| })); | |
| return; | |
| } | |
| if ((l = o(this, Zs)) == null || l.hide(), p(this, wi, e), v(this, N, Ce).call(this, { | |
| hasSelectedText: !0 | |
| }), !(o(this, te) !== et.HIGHLIGHT && o(this, te) !== et.NONE) && (o(this, te) === et.HIGHLIGHT && this.showAllEditors("highlight", !0, !0), p(this, ln, this.isShiftKeyDown), !this.isShiftKeyDown)) { | |
| const c = o(this, te) === et.HIGHLIGHT ? v(this, N, bf).call(this, i) : null; | |
| c == null || c.toggleDrawing(); | |
| const h = new AbortController(), u = this.combinedSignal(h), d = (f) => { | |
| f.type === "pointerup" && f.button !== 0 || (h.abort(), c == null || c.toggleDrawing(!0), f.type === "pointerup" && v(this, N, Yh).call(this, "main_toolbar")); | |
| }; | |
| window.addEventListener("pointerup", d, { | |
| signal: u | |
| }), window.addEventListener("blur", d, { | |
| signal: u | |
| }); | |
| } | |
| }, Yh = function(t = "") { | |
| o(this, te) === et.HIGHLIGHT ? this.highlightSelection(t) : o(this, dc) && v(this, N, Xy).call(this); | |
| }, Yy = function() { | |
| document.addEventListener("selectionchange", v(this, N, Zy).bind(this), { | |
| signal: this._signal | |
| }); | |
| }, Ky = function() { | |
| if (o(this, on)) | |
| return; | |
| p(this, on, new AbortController()); | |
| const t = this.combinedSignal(o(this, on)); | |
| window.addEventListener("focus", this.focus.bind(this), { | |
| signal: t | |
| }), window.addEventListener("blur", this.blur.bind(this), { | |
| signal: t | |
| }); | |
| }, Jy = function() { | |
| var t; | |
| (t = o(this, on)) == null || t.abort(), p(this, on, null); | |
| }, vf = function() { | |
| if (o(this, hn)) | |
| return; | |
| p(this, hn, new AbortController()); | |
| const t = this.combinedSignal(o(this, hn)); | |
| window.addEventListener("keydown", this.keydown.bind(this), { | |
| signal: t | |
| }), window.addEventListener("keyup", this.keyup.bind(this), { | |
| signal: t | |
| }); | |
| }, Qy = function() { | |
| var t; | |
| (t = o(this, hn)) == null || t.abort(), p(this, hn, null); | |
| }, _f = function() { | |
| if (o(this, an)) | |
| return; | |
| p(this, an, new AbortController()); | |
| const t = this.combinedSignal(o(this, an)); | |
| document.addEventListener("copy", this.copy.bind(this), { | |
| signal: t | |
| }), document.addEventListener("cut", this.cut.bind(this), { | |
| signal: t | |
| }), document.addEventListener("paste", this.paste.bind(this), { | |
| signal: t | |
| }); | |
| }, Af = function() { | |
| var t; | |
| (t = o(this, an)) == null || t.abort(), p(this, an, null); | |
| }, tb = function() { | |
| const t = this._signal; | |
| document.addEventListener("dragover", this.dragOver.bind(this), { | |
| signal: t | |
| }), document.addEventListener("drop", this.drop.bind(this), { | |
| signal: t | |
| }); | |
| }, Ce = function(t) { | |
| Object.entries(t).some(([s, i]) => o(this, vc)[s] !== i) && (this._eventBus.dispatch("annotationeditorstateschanged", { | |
| source: this, | |
| details: Object.assign(o(this, vc), t) | |
| }), o(this, te) === et.HIGHLIGHT && t.hasSelectedEditor === !1 && v(this, N, mi).call(this, [[lt.HIGHLIGHT_FREE, !0]])); | |
| }, mi = function(t) { | |
| this._eventBus.dispatch("annotationeditorparamschanged", { | |
| source: this, | |
| details: t | |
| }); | |
| }, eb = async function() { | |
| if (!o(this, cn)) { | |
| p(this, cn, !0); | |
| const t = []; | |
| for (const e of o(this, ce).values()) | |
| t.push(e.enable()); | |
| await Promise.all(t); | |
| for (const e of o(this, Yt).values()) | |
| e.enable(); | |
| } | |
| }, sb = function() { | |
| if (this.unselectAll(), o(this, cn)) { | |
| p(this, cn, !1); | |
| for (const t of o(this, ce).values()) | |
| t.disable(); | |
| for (const t of o(this, Yt).values()) | |
| t.disable(); | |
| } | |
| }, wf = function(t) { | |
| const e = o(this, ce).get(t.pageIndex); | |
| e ? e.addOrRebuild(t) : (this.addEditor(t), this.addToAnnotationStorage(t)); | |
| }, ib = function() { | |
| let t = null; | |
| for (t of o(this, bt)) | |
| ; | |
| return t; | |
| }, ul = function() { | |
| if (o(this, Yt).size === 0) | |
| return !0; | |
| if (o(this, Yt).size === 1) | |
| for (const t of o(this, Yt).values()) | |
| return t.isEmpty(); | |
| return !1; | |
| }, Sf = function(t) { | |
| for (const e of o(this, bt)) | |
| e.unselect(); | |
| o(this, bt).clear(); | |
| for (const e of t) | |
| e.isEmpty() || (o(this, bt).add(e), e.select()); | |
| v(this, N, Ce).call(this, { | |
| hasSelectedEditor: this.hasSelection | |
| }); | |
| }, G(Pa, "TRANSLATE_SMALL", 1), G(Pa, "TRANSLATE_BIG", 10); | |
| let pa = Pa; | |
| var ee, Ks, Ts, Va, Js, Ve, Ga, Qs, je, Ei, dr, ti, dn, Fs, dl, Kh; | |
| const ke = class ke { | |
| constructor(t) { | |
| b(this, Fs); | |
| b(this, ee, null); | |
| b(this, Ks, !1); | |
| b(this, Ts, null); | |
| b(this, Va, null); | |
| b(this, Js, null); | |
| b(this, Ve, null); | |
| b(this, Ga, !1); | |
| b(this, Qs, null); | |
| b(this, je, null); | |
| b(this, Ei, null); | |
| b(this, dr, null); | |
| b(this, ti, !1); | |
| p(this, je, t), p(this, ti, t._uiManager.useNewAltTextFlow), o(ke, dn) || p(ke, dn, Object.freeze({ | |
| added: "pdfjs-editor-new-alt-text-added-button", | |
| "added-label": "pdfjs-editor-new-alt-text-added-button-label", | |
| missing: "pdfjs-editor-new-alt-text-missing-button", | |
| "missing-label": "pdfjs-editor-new-alt-text-missing-button-label", | |
| review: "pdfjs-editor-new-alt-text-to-review-button", | |
| "review-label": "pdfjs-editor-new-alt-text-to-review-button-label" | |
| })); | |
| } | |
| static initialize(t) { | |
| ke._l10n ?? (ke._l10n = t); | |
| } | |
| async render() { | |
| const t = p(this, Ts, document.createElement("button")); | |
| t.className = "altText", t.tabIndex = "0"; | |
| const e = p(this, Va, document.createElement("span")); | |
| t.append(e), o(this, ti) ? (t.classList.add("new"), t.setAttribute("data-l10n-id", o(ke, dn).missing), e.setAttribute("data-l10n-id", o(ke, dn)["missing-label"])) : (t.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-button"), e.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-button-label")); | |
| const s = o(this, je)._uiManager._signal; | |
| t.addEventListener("contextmenu", Hs, { | |
| signal: s | |
| }), t.addEventListener("pointerdown", (r) => r.stopPropagation(), { | |
| signal: s | |
| }); | |
| const i = (r) => { | |
| r.preventDefault(), o(this, je)._uiManager.editAltText(o(this, je)), o(this, ti) && o(this, je)._reportTelemetry({ | |
| action: "pdfjs.image.alt_text.image_status_label_clicked", | |
| data: { | |
| label: o(this, Fs, dl) | |
| } | |
| }); | |
| }; | |
| return t.addEventListener("click", i, { | |
| capture: !0, | |
| signal: s | |
| }), t.addEventListener("keydown", (r) => { | |
| r.target === t && r.key === "Enter" && (p(this, Ga, !0), i(r)); | |
| }, { | |
| signal: s | |
| }), await v(this, Fs, Kh).call(this), t; | |
| } | |
| finish() { | |
| o(this, Ts) && (o(this, Ts).focus({ | |
| focusVisible: o(this, Ga) | |
| }), p(this, Ga, !1)); | |
| } | |
| isEmpty() { | |
| return o(this, ti) ? o(this, ee) === null : !o(this, ee) && !o(this, Ks); | |
| } | |
| hasData() { | |
| return o(this, ti) ? o(this, ee) !== null || !!o(this, Ei) : this.isEmpty(); | |
| } | |
| get guessedText() { | |
| return o(this, Ei); | |
| } | |
| async setGuessedText(t) { | |
| o(this, ee) === null && (p(this, Ei, t), p(this, dr, await ke._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer", { | |
| generatedAltText: t | |
| })), v(this, Fs, Kh).call(this)); | |
| } | |
| toggleAltTextBadge(t = !1) { | |
| var e; | |
| if (!o(this, ti) || o(this, ee)) { | |
| (e = o(this, Qs)) == null || e.remove(), p(this, Qs, null); | |
| return; | |
| } | |
| if (!o(this, Qs)) { | |
| const s = p(this, Qs, document.createElement("div")); | |
| s.className = "noAltTextBadge", o(this, je).div.append(s); | |
| } | |
| o(this, Qs).classList.toggle("hidden", !t); | |
| } | |
| serialize(t) { | |
| let e = o(this, ee); | |
| return !t && o(this, Ei) === e && (e = o(this, dr)), { | |
| altText: e, | |
| decorative: o(this, Ks), | |
| guessedText: o(this, Ei), | |
| textWithDisclaimer: o(this, dr) | |
| }; | |
| } | |
| get data() { | |
| return { | |
| altText: o(this, ee), | |
| decorative: o(this, Ks) | |
| }; | |
| } | |
| set data({ | |
| altText: t, | |
| decorative: e, | |
| guessedText: s, | |
| textWithDisclaimer: i, | |
| cancel: r = !1 | |
| }) { | |
| s && (p(this, Ei, s), p(this, dr, i)), !(o(this, ee) === t && o(this, Ks) === e) && (r || (p(this, ee, t), p(this, Ks, e)), v(this, Fs, Kh).call(this)); | |
| } | |
| toggle(t = !1) { | |
| o(this, Ts) && (!t && o(this, Ve) && (clearTimeout(o(this, Ve)), p(this, Ve, null)), o(this, Ts).disabled = !t); | |
| } | |
| shown() { | |
| o(this, je)._reportTelemetry({ | |
| action: "pdfjs.image.alt_text.image_status_label_displayed", | |
| data: { | |
| label: o(this, Fs, dl) | |
| } | |
| }); | |
| } | |
| destroy() { | |
| var t, e; | |
| (t = o(this, Ts)) == null || t.remove(), p(this, Ts, null), p(this, Va, null), p(this, Js, null), (e = o(this, Qs)) == null || e.remove(), p(this, Qs, null); | |
| } | |
| }; | |
| ee = new WeakMap(), Ks = new WeakMap(), Ts = new WeakMap(), Va = new WeakMap(), Js = new WeakMap(), Ve = new WeakMap(), Ga = new WeakMap(), Qs = new WeakMap(), je = new WeakMap(), Ei = new WeakMap(), dr = new WeakMap(), ti = new WeakMap(), dn = new WeakMap(), Fs = new WeakSet(), dl = function() { | |
| return o(this, ee) && "added" || o(this, ee) === null && this.guessedText && "review" || "missing"; | |
| }, Kh = async function() { | |
| var i, r, a; | |
| const t = o(this, Ts); | |
| if (!t) | |
| return; | |
| if (o(this, ti)) { | |
| if (t.classList.toggle("done", !!o(this, ee)), t.setAttribute("data-l10n-id", o(ke, dn)[o(this, Fs, dl)]), (i = o(this, Va)) == null || i.setAttribute("data-l10n-id", o(ke, dn)[`${o(this, Fs, dl)}-label`]), !o(this, ee)) { | |
| (r = o(this, Js)) == null || r.remove(); | |
| return; | |
| } | |
| } else { | |
| if (!o(this, ee) && !o(this, Ks)) { | |
| t.classList.remove("done"), (a = o(this, Js)) == null || a.remove(); | |
| return; | |
| } | |
| t.classList.add("done"), t.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-edit-button"); | |
| } | |
| let e = o(this, Js); | |
| if (!e) { | |
| p(this, Js, e = document.createElement("span")), e.className = "tooltip", e.setAttribute("role", "tooltip"), e.id = `alt-text-tooltip-${o(this, je).id}`; | |
| const l = 100, c = o(this, je)._uiManager._signal; | |
| c.addEventListener("abort", () => { | |
| clearTimeout(o(this, Ve)), p(this, Ve, null); | |
| }, { | |
| once: !0 | |
| }), t.addEventListener("mouseenter", () => { | |
| p(this, Ve, setTimeout(() => { | |
| p(this, Ve, null), o(this, Js).classList.add("show"), o(this, je)._reportTelemetry({ | |
| action: "alt_text_tooltip" | |
| }); | |
| }, l)); | |
| }, { | |
| signal: c | |
| }), t.addEventListener("mouseleave", () => { | |
| var h; | |
| o(this, Ve) && (clearTimeout(o(this, Ve)), p(this, Ve, null)), (h = o(this, Js)) == null || h.classList.remove("show"); | |
| }, { | |
| signal: c | |
| }); | |
| } | |
| o(this, Ks) ? e.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-decorative-tooltip") : (e.removeAttribute("data-l10n-id"), e.textContent = o(this, ee)), e.parentNode || t.append(e); | |
| const s = o(this, je).getImageForAltText(); | |
| s == null || s.setAttribute("aria-describedby", e.id); | |
| }, b(ke, dn, null), G(ke, "_l10n", null); | |
| let Bu = ke; | |
| var Ac, fr, wc, Sc, Ec, xc, Tc, qa, xi, pr, fn, Ki, nb, rb, Ef; | |
| const Kp = class Kp { | |
| constructor({ | |
| container: t, | |
| isPinchingDisabled: e = null, | |
| isPinchingStopped: s = null, | |
| onPinchStart: i = null, | |
| onPinching: r = null, | |
| onPinchEnd: a = null, | |
| signal: l | |
| }) { | |
| b(this, Ki); | |
| b(this, Ac); | |
| b(this, fr, !1); | |
| b(this, wc, null); | |
| b(this, Sc); | |
| b(this, Ec); | |
| b(this, xc); | |
| b(this, Tc); | |
| b(this, qa); | |
| b(this, xi, null); | |
| b(this, pr); | |
| b(this, fn, null); | |
| p(this, Ac, t), p(this, wc, s), p(this, Sc, e), p(this, Ec, i), p(this, xc, r), p(this, Tc, a), p(this, pr, new AbortController()), p(this, qa, AbortSignal.any([l, o(this, pr).signal])), t.addEventListener("touchstart", v(this, Ki, nb).bind(this), { | |
| passive: !1, | |
| signal: o(this, qa) | |
| }); | |
| } | |
| get MIN_TOUCH_DISTANCE_TO_PINCH() { | |
| return at(this, "MIN_TOUCH_DISTANCE_TO_PINCH", 35 / (window.devicePixelRatio || 1)); | |
| } | |
| destroy() { | |
| var t; | |
| (t = o(this, pr)) == null || t.abort(), p(this, pr, null); | |
| } | |
| }; | |
| Ac = new WeakMap(), fr = new WeakMap(), wc = new WeakMap(), Sc = new WeakMap(), Ec = new WeakMap(), xc = new WeakMap(), Tc = new WeakMap(), qa = new WeakMap(), xi = new WeakMap(), pr = new WeakMap(), fn = new WeakMap(), Ki = new WeakSet(), nb = function(t) { | |
| var i, r, a; | |
| if ((i = o(this, Sc)) != null && i.call(this) || t.touches.length < 2) | |
| return; | |
| if (!o(this, fn)) { | |
| p(this, fn, new AbortController()); | |
| const l = AbortSignal.any([o(this, qa), o(this, fn).signal]), c = o(this, Ac), h = { | |
| signal: l, | |
| passive: !1 | |
| }; | |
| c.addEventListener("touchmove", v(this, Ki, rb).bind(this), h), c.addEventListener("touchend", v(this, Ki, Ef).bind(this), h), c.addEventListener("touchcancel", v(this, Ki, Ef).bind(this), h), (r = o(this, Ec)) == null || r.call(this); | |
| } | |
| if (ns(t), t.touches.length !== 2 || (a = o(this, wc)) != null && a.call(this)) { | |
| p(this, xi, null); | |
| return; | |
| } | |
| let [e, s] = t.touches; | |
| e.identifier > s.identifier && ([e, s] = [s, e]), p(this, xi, { | |
| touch0X: e.screenX, | |
| touch0Y: e.screenY, | |
| touch1X: s.screenX, | |
| touch1Y: s.screenY | |
| }); | |
| }, rb = function(t) { | |
| var x; | |
| if (!o(this, xi) || t.touches.length !== 2) | |
| return; | |
| let [e, s] = t.touches; | |
| e.identifier > s.identifier && ([e, s] = [s, e]); | |
| const { | |
| screenX: i, | |
| screenY: r | |
| } = e, { | |
| screenX: a, | |
| screenY: l | |
| } = s, c = o(this, xi), { | |
| touch0X: h, | |
| touch0Y: u, | |
| touch1X: d, | |
| touch1Y: f | |
| } = c, g = d - h, m = f - u, y = a - i, _ = l - r, A = Math.hypot(y, _) || 1, S = Math.hypot(g, m) || 1; | |
| if (!o(this, fr) && Math.abs(S - A) <= Kp.MIN_TOUCH_DISTANCE_TO_PINCH) | |
| return; | |
| if (c.touch0X = i, c.touch0Y = r, c.touch1X = a, c.touch1Y = l, t.preventDefault(), !o(this, fr)) { | |
| p(this, fr, !0); | |
| return; | |
| } | |
| const E = [(i + a) / 2, (r + l) / 2]; | |
| (x = o(this, xc)) == null || x.call(this, E, S, A); | |
| }, Ef = function(t) { | |
| var e; | |
| o(this, fn).abort(), p(this, fn, null), (e = o(this, Tc)) == null || e.call(this), o(this, xi) && (t.preventDefault(), p(this, xi, null), p(this, fr, !1)); | |
| }; | |
| let Hu = Kp; | |
| var gr, Cs, It, Wa, pn, Cc, mr, he, yr, Ti, gn, kc, br, Ge, Ic, vr, Ci, ei, Xa, Za, us, _r, Rc, Ju, q, xf, Pc, Tf, Jh, ab, ob, Cf, Qh, kf, lb, cb, hb, If, ub, Rf, db, fb, pb, Pf, fl; | |
| const it = class it { | |
| constructor(t) { | |
| b(this, q); | |
| b(this, gr, null); | |
| b(this, Cs, null); | |
| b(this, It, null); | |
| b(this, Wa, !1); | |
| b(this, pn, null); | |
| b(this, Cc, ""); | |
| b(this, mr, !1); | |
| b(this, he, null); | |
| b(this, yr, null); | |
| b(this, Ti, null); | |
| b(this, gn, null); | |
| b(this, kc, ""); | |
| b(this, br, !1); | |
| b(this, Ge, null); | |
| b(this, Ic, !1); | |
| b(this, vr, !1); | |
| b(this, Ci, !1); | |
| b(this, ei, null); | |
| b(this, Xa, 0); | |
| b(this, Za, 0); | |
| b(this, us, null); | |
| b(this, _r, null); | |
| G(this, "_editToolbar", null); | |
| G(this, "_initialOptions", /* @__PURE__ */ Object.create(null)); | |
| G(this, "_initialData", null); | |
| G(this, "_isVisible", !0); | |
| G(this, "_uiManager", null); | |
| G(this, "_focusEventsAllowed", !0); | |
| b(this, Rc, !1); | |
| b(this, Ju, it._zIndex++); | |
| this.parent = t.parent, this.id = t.id, this.width = this.height = null, this.pageIndex = t.parent.pageIndex, this.name = t.name, this.div = null, this._uiManager = t.uiManager, this.annotationElementId = null, this._willKeepAspectRatio = !1, this._initialOptions.isCentered = t.isCentered, this._structTreeParentId = null; | |
| const { | |
| rotation: e, | |
| rawDims: { | |
| pageWidth: s, | |
| pageHeight: i, | |
| pageX: r, | |
| pageY: a | |
| } | |
| } = this.parent.viewport; | |
| this.rotation = e, this.pageRotation = (360 + e - this._uiManager.viewParameters.rotation) % 360, this.pageDimensions = [s, i], this.pageTranslation = [r, a]; | |
| const [l, c] = this.parentDimensions; | |
| this.x = t.x / l, this.y = t.y / c, this.isAttachedToDOM = !1, this.deleted = !1; | |
| } | |
| static get _resizerKeyboardManager() { | |
| const t = it.prototype._resizeWithKeyboard, e = pa.TRANSLATE_SMALL, s = pa.TRANSLATE_BIG; | |
| return at(this, "_resizerKeyboardManager", new Oh([[["ArrowLeft", "mac+ArrowLeft"], t, { | |
| args: [-e, 0] | |
| }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], t, { | |
| args: [-s, 0] | |
| }], [["ArrowRight", "mac+ArrowRight"], t, { | |
| args: [e, 0] | |
| }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], t, { | |
| args: [s, 0] | |
| }], [["ArrowUp", "mac+ArrowUp"], t, { | |
| args: [0, -e] | |
| }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], t, { | |
| args: [0, -s] | |
| }], [["ArrowDown", "mac+ArrowDown"], t, { | |
| args: [0, e] | |
| }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], t, { | |
| args: [0, s] | |
| }], [["Escape", "mac+Escape"], it.prototype._stopResizingWithKeyboard]])); | |
| } | |
| get editorType() { | |
| return Object.getPrototypeOf(this).constructor._type; | |
| } | |
| static get isDrawer() { | |
| return !1; | |
| } | |
| static get _defaultLineColor() { | |
| return at(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText")); | |
| } | |
| static deleteAnnotationElement(t) { | |
| const e = new GE({ | |
| id: t.parent.getNextId(), | |
| parent: t.parent, | |
| uiManager: t._uiManager | |
| }); | |
| e.annotationElementId = t.annotationElementId, e.deleted = !0, e._uiManager.addToAnnotationStorage(e); | |
| } | |
| static initialize(t, e) { | |
| if (it._l10n ?? (it._l10n = t), it._l10nResizer || (it._l10nResizer = Object.freeze({ | |
| topLeft: "pdfjs-editor-resizer-top-left", | |
| topMiddle: "pdfjs-editor-resizer-top-middle", | |
| topRight: "pdfjs-editor-resizer-top-right", | |
| middleRight: "pdfjs-editor-resizer-middle-right", | |
| bottomRight: "pdfjs-editor-resizer-bottom-right", | |
| bottomMiddle: "pdfjs-editor-resizer-bottom-middle", | |
| bottomLeft: "pdfjs-editor-resizer-bottom-left", | |
| middleLeft: "pdfjs-editor-resizer-middle-left" | |
| })), it._borderLineWidth !== -1) | |
| return; | |
| const s = getComputedStyle(document.documentElement); | |
| it._borderLineWidth = parseFloat(s.getPropertyValue("--outline-width")) || 0; | |
| } | |
| static updateDefaultParams(t, e) { | |
| } | |
| static get defaultPropertiesToUpdate() { | |
| return []; | |
| } | |
| static isHandlingMimeForPasting(t) { | |
| return !1; | |
| } | |
| static paste(t, e) { | |
| Et("Not implemented"); | |
| } | |
| get propertiesToUpdate() { | |
| return []; | |
| } | |
| get _isDraggable() { | |
| return o(this, Rc); | |
| } | |
| set _isDraggable(t) { | |
| var e; | |
| p(this, Rc, t), (e = this.div) == null || e.classList.toggle("draggable", t); | |
| } | |
| get isEnterHandled() { | |
| return !0; | |
| } | |
| center() { | |
| const [t, e] = this.pageDimensions; | |
| switch (this.parentRotation) { | |
| case 90: | |
| this.x -= this.height * e / (t * 2), this.y += this.width * t / (e * 2); | |
| break; | |
| case 180: | |
| this.x += this.width / 2, this.y += this.height / 2; | |
| break; | |
| case 270: | |
| this.x += this.height * e / (t * 2), this.y -= this.width * t / (e * 2); | |
| break; | |
| default: | |
| this.x -= this.width / 2, this.y -= this.height / 2; | |
| break; | |
| } | |
| this.fixAndSetPosition(); | |
| } | |
| addCommands(t) { | |
| this._uiManager.addCommands(t); | |
| } | |
| get currentLayer() { | |
| return this._uiManager.currentLayer; | |
| } | |
| setInBackground() { | |
| this.div.style.zIndex = 0; | |
| } | |
| setInForeground() { | |
| this.div.style.zIndex = o(this, Ju); | |
| } | |
| setParent(t) { | |
| t !== null ? (this.pageIndex = t.pageIndex, this.pageDimensions = t.pageDimensions) : v(this, q, fl).call(this), this.parent = t; | |
| } | |
| focusin(t) { | |
| this._focusEventsAllowed && (o(this, br) ? p(this, br, !1) : this.parent.setSelected(this)); | |
| } | |
| focusout(t) { | |
| var s; | |
| if (!this._focusEventsAllowed || !this.isAttachedToDOM) | |
| return; | |
| const e = t.relatedTarget; | |
| e != null && e.closest(`#${this.id}`) || (t.preventDefault(), (s = this.parent) != null && s.isMultipleSelection || this.commitOrRemove()); | |
| } | |
| commitOrRemove() { | |
| this.isEmpty() ? this.remove() : this.commit(); | |
| } | |
| commit() { | |
| this.addToAnnotationStorage(); | |
| } | |
| addToAnnotationStorage() { | |
| this._uiManager.addToAnnotationStorage(this); | |
| } | |
| setAt(t, e, s, i) { | |
| const [r, a] = this.parentDimensions; | |
| [s, i] = this.screenToPageTranslation(s, i), this.x = (t + s) / r, this.y = (e + i) / a, this.fixAndSetPosition(); | |
| } | |
| translate(t, e) { | |
| v(this, q, xf).call(this, this.parentDimensions, t, e); | |
| } | |
| translateInPage(t, e) { | |
| o(this, Ge) || p(this, Ge, [this.x, this.y, this.width, this.height]), v(this, q, xf).call(this, this.pageDimensions, t, e), this.div.scrollIntoView({ | |
| block: "nearest" | |
| }); | |
| } | |
| drag(t, e) { | |
| o(this, Ge) || p(this, Ge, [this.x, this.y, this.width, this.height]); | |
| const { | |
| div: s, | |
| parentDimensions: [i, r] | |
| } = this; | |
| if (this.x += t / i, this.y += e / r, this.parent && (this.x < 0 || this.x > 1 || this.y < 0 || this.y > 1)) { | |
| const { | |
| x: d, | |
| y: f | |
| } = this.div.getBoundingClientRect(); | |
| this.parent.findNewParent(this, d, f) && (this.x -= Math.floor(this.x), this.y -= Math.floor(this.y)); | |
| } | |
| let { | |
| x: a, | |
| y: l | |
| } = this; | |
| const [c, h] = this.getBaseTranslation(); | |
| a += c, l += h; | |
| const { | |
| style: u | |
| } = s; | |
| u.left = `${(100 * a).toFixed(2)}%`, u.top = `${(100 * l).toFixed(2)}%`, this._onTranslating(a, l), s.scrollIntoView({ | |
| block: "nearest" | |
| }); | |
| } | |
| _onTranslating(t, e) { | |
| } | |
| _onTranslated(t, e) { | |
| } | |
| get _hasBeenMoved() { | |
| return !!o(this, Ge) && (o(this, Ge)[0] !== this.x || o(this, Ge)[1] !== this.y); | |
| } | |
| get _hasBeenResized() { | |
| return !!o(this, Ge) && (o(this, Ge)[2] !== this.width || o(this, Ge)[3] !== this.height); | |
| } | |
| getBaseTranslation() { | |
| const [t, e] = this.parentDimensions, { | |
| _borderLineWidth: s | |
| } = it, i = s / t, r = s / e; | |
| switch (this.rotation) { | |
| case 90: | |
| return [-i, r]; | |
| case 180: | |
| return [i, r]; | |
| case 270: | |
| return [i, -r]; | |
| default: | |
| return [-i, -r]; | |
| } | |
| } | |
| get _mustFixPosition() { | |
| return !0; | |
| } | |
| fixAndSetPosition(t = this.rotation) { | |
| const { | |
| div: { | |
| style: e | |
| }, | |
| pageDimensions: [s, i] | |
| } = this; | |
| let { | |
| x: r, | |
| y: a, | |
| width: l, | |
| height: c | |
| } = this; | |
| if (l *= s, c *= i, r *= s, a *= i, this._mustFixPosition) | |
| switch (t) { | |
| case 0: | |
| r = Math.max(0, Math.min(s - l, r)), a = Math.max(0, Math.min(i - c, a)); | |
| break; | |
| case 90: | |
| r = Math.max(0, Math.min(s - c, r)), a = Math.min(i, Math.max(l, a)); | |
| break; | |
| case 180: | |
| r = Math.min(s, Math.max(l, r)), a = Math.min(i, Math.max(c, a)); | |
| break; | |
| case 270: | |
| r = Math.min(s, Math.max(c, r)), a = Math.max(0, Math.min(i - l, a)); | |
| break; | |
| } | |
| this.x = r /= s, this.y = a /= i; | |
| const [h, u] = this.getBaseTranslation(); | |
| r += h, a += u, e.left = `${(100 * r).toFixed(2)}%`, e.top = `${(100 * a).toFixed(2)}%`, this.moveInDOM(); | |
| } | |
| screenToPageTranslation(t, e) { | |
| var s; | |
| return v(s = it, Pc, Tf).call(s, t, e, this.parentRotation); | |
| } | |
| pageTranslationToScreen(t, e) { | |
| var s; | |
| return v(s = it, Pc, Tf).call(s, t, e, 360 - this.parentRotation); | |
| } | |
| get parentScale() { | |
| return this._uiManager.viewParameters.realScale; | |
| } | |
| get parentRotation() { | |
| return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360; | |
| } | |
| get parentDimensions() { | |
| const { | |
| parentScale: t, | |
| pageDimensions: [e, s] | |
| } = this; | |
| return [e * t, s * t]; | |
| } | |
| setDims(t, e) { | |
| const [s, i] = this.parentDimensions, { | |
| style: r | |
| } = this.div; | |
| r.width = `${(100 * t / s).toFixed(2)}%`, o(this, mr) || (r.height = `${(100 * e / i).toFixed(2)}%`); | |
| } | |
| fixDims() { | |
| const { | |
| style: t | |
| } = this.div, { | |
| height: e, | |
| width: s | |
| } = t, i = s.endsWith("%"), r = !o(this, mr) && e.endsWith("%"); | |
| if (i && r) | |
| return; | |
| const [a, l] = this.parentDimensions; | |
| i || (t.width = `${(100 * parseFloat(s) / a).toFixed(2)}%`), !o(this, mr) && !r && (t.height = `${(100 * parseFloat(e) / l).toFixed(2)}%`); | |
| } | |
| getInitialTranslation() { | |
| return [0, 0]; | |
| } | |
| _onResized() { | |
| } | |
| static _round(t) { | |
| return Math.round(t * 1e4) / 1e4; | |
| } | |
| _onResizing() { | |
| } | |
| altTextFinish() { | |
| var t; | |
| (t = o(this, It)) == null || t.finish(); | |
| } | |
| async addEditToolbar() { | |
| return this._editToolbar || o(this, vr) ? this._editToolbar : (this._editToolbar = new pf(this), this.div.append(this._editToolbar.render()), o(this, It) && await this._editToolbar.addAltText(o(this, It)), this._editToolbar); | |
| } | |
| removeEditToolbar() { | |
| var t; | |
| this._editToolbar && (this._editToolbar.remove(), this._editToolbar = null, (t = o(this, It)) == null || t.destroy()); | |
| } | |
| addContainer(t) { | |
| var s; | |
| const e = (s = this._editToolbar) == null ? void 0 : s.div; | |
| e ? e.before(t) : this.div.append(t); | |
| } | |
| getClientDimensions() { | |
| return this.div.getBoundingClientRect(); | |
| } | |
| async addAltTextButton() { | |
| o(this, It) || (Bu.initialize(it._l10n), p(this, It, new Bu(this)), o(this, gr) && (o(this, It).data = o(this, gr), p(this, gr, null)), await this.addEditToolbar()); | |
| } | |
| get altTextData() { | |
| var t; | |
| return (t = o(this, It)) == null ? void 0 : t.data; | |
| } | |
| set altTextData(t) { | |
| o(this, It) && (o(this, It).data = t); | |
| } | |
| get guessedAltText() { | |
| var t; | |
| return (t = o(this, It)) == null ? void 0 : t.guessedText; | |
| } | |
| async setGuessedAltText(t) { | |
| var e; | |
| await ((e = o(this, It)) == null ? void 0 : e.setGuessedText(t)); | |
| } | |
| serializeAltText(t) { | |
| var e; | |
| return (e = o(this, It)) == null ? void 0 : e.serialize(t); | |
| } | |
| hasAltText() { | |
| return !!o(this, It) && !o(this, It).isEmpty(); | |
| } | |
| hasAltTextData() { | |
| var t; | |
| return ((t = o(this, It)) == null ? void 0 : t.hasData()) ?? !1; | |
| } | |
| render() { | |
| var r; | |
| this.div = document.createElement("div"), this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360), this.div.className = this.name, this.div.setAttribute("id", this.id), this.div.tabIndex = o(this, Wa) ? -1 : 0, this._isVisible || this.div.classList.add("hidden"), this.setInForeground(), v(this, q, Rf).call(this); | |
| const [t, e] = this.parentDimensions; | |
| this.parentRotation % 180 !== 0 && (this.div.style.maxWidth = `${(100 * e / t).toFixed(2)}%`, this.div.style.maxHeight = `${(100 * t / e).toFixed(2)}%`); | |
| const [s, i] = this.getInitialTranslation(); | |
| return this.translate(s, i), ju(this, this.div, ["pointerdown"]), this.isResizable && this._uiManager._supportsPinchToZoom && (o(this, _r) || p(this, _r, new Hu({ | |
| container: this.div, | |
| isPinchingDisabled: () => !this.isSelected, | |
| onPinchStart: v(this, q, lb).bind(this), | |
| onPinching: v(this, q, cb).bind(this), | |
| onPinchEnd: v(this, q, hb).bind(this), | |
| signal: this._uiManager._signal | |
| }))), (r = this._uiManager._editorUndoBar) == null || r.hide(), this.div; | |
| } | |
| pointerdown(t) { | |
| const { | |
| isMac: e | |
| } = Me.platform; | |
| if (t.button !== 0 || t.ctrlKey && e) { | |
| t.preventDefault(); | |
| return; | |
| } | |
| if (p(this, br, !0), this._isDraggable) { | |
| v(this, q, ub).call(this, t); | |
| return; | |
| } | |
| v(this, q, If).call(this, t); | |
| } | |
| get isSelected() { | |
| return this._uiManager.isSelected(this); | |
| } | |
| _onStartDragging() { | |
| } | |
| _onStopDragging() { | |
| } | |
| moveInDOM() { | |
| o(this, ei) && clearTimeout(o(this, ei)), p(this, ei, setTimeout(() => { | |
| var t; | |
| p(this, ei, null), (t = this.parent) == null || t.moveEditorInDOM(this); | |
| }, 0)); | |
| } | |
| _setParentAndPosition(t, e, s) { | |
| t.changeParent(this), this.x = e, this.y = s, this.fixAndSetPosition(), this._onTranslated(); | |
| } | |
| getRect(t, e, s = this.rotation) { | |
| const i = this.parentScale, [r, a] = this.pageDimensions, [l, c] = this.pageTranslation, h = t / i, u = e / i, d = this.x * r, f = this.y * a, g = this.width * r, m = this.height * a; | |
| switch (s) { | |
| case 0: | |
| return [d + h + l, a - f - u - m + c, d + h + g + l, a - f - u + c]; | |
| case 90: | |
| return [d + u + l, a - f + h + c, d + u + m + l, a - f + h + g + c]; | |
| case 180: | |
| return [d - h - g + l, a - f + u + c, d - h + l, a - f + u + m + c]; | |
| case 270: | |
| return [d - u - m + l, a - f - h - g + c, d - u + l, a - f - h + c]; | |
| default: | |
| throw new Error("Invalid rotation"); | |
| } | |
| } | |
| getRectInCurrentCoords(t, e) { | |
| const [s, i, r, a] = t, l = r - s, c = a - i; | |
| switch (this.rotation) { | |
| case 0: | |
| return [s, e - a, l, c]; | |
| case 90: | |
| return [s, e - i, c, l]; | |
| case 180: | |
| return [r, e - i, l, c]; | |
| case 270: | |
| return [r, e - a, c, l]; | |
| default: | |
| throw new Error("Invalid rotation"); | |
| } | |
| } | |
| onceAdded(t) { | |
| } | |
| isEmpty() { | |
| return !1; | |
| } | |
| enableEditMode() { | |
| p(this, vr, !0); | |
| } | |
| disableEditMode() { | |
| p(this, vr, !1); | |
| } | |
| isInEditMode() { | |
| return o(this, vr); | |
| } | |
| shouldGetKeyboardEvents() { | |
| return o(this, Ci); | |
| } | |
| needsToBeRebuilt() { | |
| return this.div && !this.isAttachedToDOM; | |
| } | |
| get isOnScreen() { | |
| const { | |
| top: t, | |
| left: e, | |
| bottom: s, | |
| right: i | |
| } = this.getClientDimensions(), { | |
| innerHeight: r, | |
| innerWidth: a | |
| } = window; | |
| return e < a && i > 0 && t < r && s > 0; | |
| } | |
| rebuild() { | |
| v(this, q, Rf).call(this); | |
| } | |
| rotate(t) { | |
| } | |
| resize() { | |
| } | |
| serializeDeleted() { | |
| var t; | |
| return { | |
| id: this.annotationElementId, | |
| deleted: !0, | |
| pageIndex: this.pageIndex, | |
| popupRef: ((t = this._initialData) == null ? void 0 : t.popupRef) || "" | |
| }; | |
| } | |
| serialize(t = !1, e = null) { | |
| Et("An editor must be serializable"); | |
| } | |
| static async deserialize(t, e, s) { | |
| const i = new this.prototype.constructor({ | |
| parent: e, | |
| id: e.getNextId(), | |
| uiManager: s | |
| }); | |
| i.rotation = t.rotation, p(i, gr, t.accessibilityData); | |
| const [r, a] = i.pageDimensions, [l, c, h, u] = i.getRectInCurrentCoords(t.rect, a); | |
| return i.x = l / r, i.y = c / a, i.width = h / r, i.height = u / a, i; | |
| } | |
| get hasBeenModified() { | |
| return !!this.annotationElementId && (this.deleted || this.serialize() !== null); | |
| } | |
| remove() { | |
| var t, e; | |
| if ((t = o(this, gn)) == null || t.abort(), p(this, gn, null), this.isEmpty() || this.commit(), this.parent ? this.parent.remove(this) : this._uiManager.removeEditor(this), o(this, ei) && (clearTimeout(o(this, ei)), p(this, ei, null)), v(this, q, fl).call(this), this.removeEditToolbar(), o(this, us)) { | |
| for (const s of o(this, us).values()) | |
| clearTimeout(s); | |
| p(this, us, null); | |
| } | |
| this.parent = null, (e = o(this, _r)) == null || e.destroy(), p(this, _r, null); | |
| } | |
| get isResizable() { | |
| return !1; | |
| } | |
| makeResizable() { | |
| this.isResizable && (v(this, q, ab).call(this), o(this, he).classList.remove("hidden"), ju(this, this.div, ["keydown"])); | |
| } | |
| get toolbarPosition() { | |
| return null; | |
| } | |
| keydown(t) { | |
| if (!this.isResizable || t.target !== this.div || t.key !== "Enter") | |
| return; | |
| this._uiManager.setSelected(this), p(this, Ti, { | |
| savedX: this.x, | |
| savedY: this.y, | |
| savedWidth: this.width, | |
| savedHeight: this.height | |
| }); | |
| const e = o(this, he).children; | |
| if (!o(this, Cs)) { | |
| p(this, Cs, Array.from(e)); | |
| const a = v(this, q, db).bind(this), l = v(this, q, fb).bind(this), c = this._uiManager._signal; | |
| for (const h of o(this, Cs)) { | |
| const u = h.getAttribute("data-resizer-name"); | |
| h.setAttribute("role", "spinbutton"), h.addEventListener("keydown", a, { | |
| signal: c | |
| }), h.addEventListener("blur", l, { | |
| signal: c | |
| }), h.addEventListener("focus", v(this, q, pb).bind(this, u), { | |
| signal: c | |
| }), h.setAttribute("data-l10n-id", it._l10nResizer[u]); | |
| } | |
| } | |
| const s = o(this, Cs)[0]; | |
| let i = 0; | |
| for (const a of e) { | |
| if (a === s) | |
| break; | |
| i++; | |
| } | |
| const r = (360 - this.rotation + this.parentRotation) % 360 / 90 * (o(this, Cs).length / 4); | |
| if (r !== i) { | |
| if (r < i) | |
| for (let l = 0; l < i - r; l++) | |
| o(this, he).append(o(this, he).firstChild); | |
| else if (r > i) | |
| for (let l = 0; l < r - i; l++) | |
| o(this, he).firstChild.before(o(this, he).lastChild); | |
| let a = 0; | |
| for (const l of e) { | |
| const h = o(this, Cs)[a++].getAttribute("data-resizer-name"); | |
| l.setAttribute("data-l10n-id", it._l10nResizer[h]); | |
| } | |
| } | |
| v(this, q, Pf).call(this, 0), p(this, Ci, !0), o(this, he).firstChild.focus({ | |
| focusVisible: !0 | |
| }), t.preventDefault(), t.stopImmediatePropagation(); | |
| } | |
| _resizeWithKeyboard(t, e) { | |
| o(this, Ci) && v(this, q, kf).call(this, o(this, kc), { | |
| deltaX: t, | |
| deltaY: e, | |
| fromKeyboard: !0 | |
| }); | |
| } | |
| _stopResizingWithKeyboard() { | |
| v(this, q, fl).call(this), this.div.focus(); | |
| } | |
| select() { | |
| var t, e, s; | |
| if (this.makeResizable(), (t = this.div) == null || t.classList.add("selectedEditor"), !this._editToolbar) { | |
| this.addEditToolbar().then(() => { | |
| var i, r; | |
| (i = this.div) != null && i.classList.contains("selectedEditor") && ((r = this._editToolbar) == null || r.show()); | |
| }); | |
| return; | |
| } | |
| (e = this._editToolbar) == null || e.show(), (s = o(this, It)) == null || s.toggleAltTextBadge(!1); | |
| } | |
| unselect() { | |
| var t, e, s, i, r; | |
| (t = o(this, he)) == null || t.classList.add("hidden"), (e = this.div) == null || e.classList.remove("selectedEditor"), (s = this.div) != null && s.contains(document.activeElement) && this._uiManager.currentLayer.div.focus({ | |
| preventScroll: !0 | |
| }), (i = this._editToolbar) == null || i.hide(), (r = o(this, It)) == null || r.toggleAltTextBadge(!0); | |
| } | |
| updateParams(t, e) { | |
| } | |
| disableEditing() { | |
| } | |
| enableEditing() { | |
| } | |
| enterInEditMode() { | |
| } | |
| getImageForAltText() { | |
| return null; | |
| } | |
| get contentDiv() { | |
| return this.div; | |
| } | |
| get isEditing() { | |
| return o(this, Ic); | |
| } | |
| set isEditing(t) { | |
| p(this, Ic, t), this.parent && (t ? (this.parent.setSelected(this), this.parent.setActiveEditor(this)) : this.parent.setActiveEditor(null)); | |
| } | |
| setAspectRatio(t, e) { | |
| p(this, mr, !0); | |
| const s = t / e, { | |
| style: i | |
| } = this.div; | |
| i.aspectRatio = s, i.height = "auto"; | |
| } | |
| static get MIN_SIZE() { | |
| return 16; | |
| } | |
| static canCreateNewEmptyEditor() { | |
| return !0; | |
| } | |
| get telemetryInitialData() { | |
| return { | |
| action: "added" | |
| }; | |
| } | |
| get telemetryFinalData() { | |
| return null; | |
| } | |
| _reportTelemetry(t, e = !1) { | |
| if (e) { | |
| o(this, us) || p(this, us, /* @__PURE__ */ new Map()); | |
| const { | |
| action: s | |
| } = t; | |
| let i = o(this, us).get(s); | |
| i && clearTimeout(i), i = setTimeout(() => { | |
| this._reportTelemetry(t), o(this, us).delete(s), o(this, us).size === 0 && p(this, us, null); | |
| }, it._telemetryTimeout), o(this, us).set(s, i); | |
| return; | |
| } | |
| t.type || (t.type = this.editorType), this._uiManager._eventBus.dispatch("reporttelemetry", { | |
| source: this, | |
| details: { | |
| type: "editing", | |
| data: t | |
| } | |
| }); | |
| } | |
| show(t = this._isVisible) { | |
| this.div.classList.toggle("hidden", !t), this._isVisible = t; | |
| } | |
| enable() { | |
| this.div && (this.div.tabIndex = 0), p(this, Wa, !1); | |
| } | |
| disable() { | |
| this.div && (this.div.tabIndex = -1), p(this, Wa, !0); | |
| } | |
| renderAnnotationElement(t) { | |
| let e = t.container.querySelector(".annotationContent"); | |
| if (!e) | |
| e = document.createElement("div"), e.classList.add("annotationContent", this.editorType), t.container.prepend(e); | |
| else if (e.nodeName === "CANVAS") { | |
| const s = e; | |
| e = document.createElement("div"), e.classList.add("annotationContent", this.editorType), s.before(e); | |
| } | |
| return e; | |
| } | |
| resetAnnotationElement(t) { | |
| const { | |
| firstChild: e | |
| } = t.container; | |
| (e == null ? void 0 : e.nodeName) === "DIV" && e.classList.contains("annotationContent") && e.remove(); | |
| } | |
| }; | |
| gr = new WeakMap(), Cs = new WeakMap(), It = new WeakMap(), Wa = new WeakMap(), pn = new WeakMap(), Cc = new WeakMap(), mr = new WeakMap(), he = new WeakMap(), yr = new WeakMap(), Ti = new WeakMap(), gn = new WeakMap(), kc = new WeakMap(), br = new WeakMap(), Ge = new WeakMap(), Ic = new WeakMap(), vr = new WeakMap(), Ci = new WeakMap(), ei = new WeakMap(), Xa = new WeakMap(), Za = new WeakMap(), us = new WeakMap(), _r = new WeakMap(), Rc = new WeakMap(), Ju = new WeakMap(), q = new WeakSet(), xf = function([t, e], s, i) { | |
| [s, i] = this.screenToPageTranslation(s, i), this.x += s / t, this.y += i / e, this._onTranslating(this.x, this.y), this.fixAndSetPosition(); | |
| }, Pc = new WeakSet(), Tf = function(t, e, s) { | |
| switch (s) { | |
| case 90: | |
| return [e, -t]; | |
| case 180: | |
| return [-t, -e]; | |
| case 270: | |
| return [-e, t]; | |
| default: | |
| return [t, e]; | |
| } | |
| }, Jh = function(t) { | |
| switch (t) { | |
| case 90: { | |
| const [e, s] = this.pageDimensions; | |
| return [0, -e / s, s / e, 0]; | |
| } | |
| case 180: | |
| return [-1, 0, 0, -1]; | |
| case 270: { | |
| const [e, s] = this.pageDimensions; | |
| return [0, e / s, -s / e, 0]; | |
| } | |
| default: | |
| return [1, 0, 0, 1]; | |
| } | |
| }, ab = function() { | |
| if (o(this, he)) | |
| return; | |
| p(this, he, document.createElement("div")), o(this, he).classList.add("resizers"); | |
| const t = this._willKeepAspectRatio ? ["topLeft", "topRight", "bottomRight", "bottomLeft"] : ["topLeft", "topMiddle", "topRight", "middleRight", "bottomRight", "bottomMiddle", "bottomLeft", "middleLeft"], e = this._uiManager._signal; | |
| for (const s of t) { | |
| const i = document.createElement("div"); | |
| o(this, he).append(i), i.classList.add("resizer", s), i.setAttribute("data-resizer-name", s), i.addEventListener("pointerdown", v(this, q, ob).bind(this, s), { | |
| signal: e | |
| }), i.addEventListener("contextmenu", Hs, { | |
| signal: e | |
| }), i.tabIndex = -1; | |
| } | |
| this.div.prepend(o(this, he)); | |
| }, ob = function(t, e) { | |
| var u; | |
| e.preventDefault(); | |
| const { | |
| isMac: s | |
| } = Me.platform; | |
| if (e.button !== 0 || e.ctrlKey && s) | |
| return; | |
| (u = o(this, It)) == null || u.toggle(!1); | |
| const i = this._isDraggable; | |
| this._isDraggable = !1, p(this, yr, [e.screenX, e.screenY]); | |
| const r = new AbortController(), a = this._uiManager.combinedSignal(r); | |
| this.parent.togglePointerEvents(!1), window.addEventListener("pointermove", v(this, q, kf).bind(this, t), { | |
| passive: !0, | |
| capture: !0, | |
| signal: a | |
| }), window.addEventListener("touchmove", ns, { | |
| passive: !1, | |
| signal: a | |
| }), window.addEventListener("contextmenu", Hs, { | |
| signal: a | |
| }), p(this, Ti, { | |
| savedX: this.x, | |
| savedY: this.y, | |
| savedWidth: this.width, | |
| savedHeight: this.height | |
| }); | |
| const l = this.parent.div.style.cursor, c = this.div.style.cursor; | |
| this.div.style.cursor = this.parent.div.style.cursor = window.getComputedStyle(e.target).cursor; | |
| const h = () => { | |
| var d; | |
| r.abort(), this.parent.togglePointerEvents(!0), (d = o(this, It)) == null || d.toggle(!0), this._isDraggable = i, this.parent.div.style.cursor = l, this.div.style.cursor = c, v(this, q, Qh).call(this); | |
| }; | |
| window.addEventListener("pointerup", h, { | |
| signal: a | |
| }), window.addEventListener("blur", h, { | |
| signal: a | |
| }); | |
| }, Cf = function(t, e, s, i) { | |
| this.width = s, this.height = i, this.x = t, this.y = e; | |
| const [r, a] = this.parentDimensions; | |
| this.setDims(r * s, a * i), this.fixAndSetPosition(), this._onResized(); | |
| }, Qh = function() { | |
| if (!o(this, Ti)) | |
| return; | |
| const { | |
| savedX: t, | |
| savedY: e, | |
| savedWidth: s, | |
| savedHeight: i | |
| } = o(this, Ti); | |
| p(this, Ti, null); | |
| const r = this.x, a = this.y, l = this.width, c = this.height; | |
| r === t && a === e && l === s && c === i || this.addCommands({ | |
| cmd: v(this, q, Cf).bind(this, r, a, l, c), | |
| undo: v(this, q, Cf).bind(this, t, e, s, i), | |
| mustExec: !0 | |
| }); | |
| }, kf = function(t, e) { | |
| const [s, i] = this.parentDimensions, r = this.x, a = this.y, l = this.width, c = this.height, h = it.MIN_SIZE / s, u = it.MIN_SIZE / i, d = v(this, q, Jh).call(this, this.rotation), f = (M, z) => [d[0] * M + d[2] * z, d[1] * M + d[3] * z], g = v(this, q, Jh).call(this, 360 - this.rotation), m = (M, z) => [g[0] * M + g[2] * z, g[1] * M + g[3] * z]; | |
| let y, _, A = !1, S = !1; | |
| switch (t) { | |
| case "topLeft": | |
| A = !0, y = (M, z) => [0, 0], _ = (M, z) => [M, z]; | |
| break; | |
| case "topMiddle": | |
| y = (M, z) => [M / 2, 0], _ = (M, z) => [M / 2, z]; | |
| break; | |
| case "topRight": | |
| A = !0, y = (M, z) => [M, 0], _ = (M, z) => [0, z]; | |
| break; | |
| case "middleRight": | |
| S = !0, y = (M, z) => [M, z / 2], _ = (M, z) => [0, z / 2]; | |
| break; | |
| case "bottomRight": | |
| A = !0, y = (M, z) => [M, z], _ = (M, z) => [0, 0]; | |
| break; | |
| case "bottomMiddle": | |
| y = (M, z) => [M / 2, z], _ = (M, z) => [M / 2, 0]; | |
| break; | |
| case "bottomLeft": | |
| A = !0, y = (M, z) => [0, z], _ = (M, z) => [M, 0]; | |
| break; | |
| case "middleLeft": | |
| S = !0, y = (M, z) => [0, z / 2], _ = (M, z) => [M, z / 2]; | |
| break; | |
| } | |
| const E = y(l, c), x = _(l, c); | |
| let T = f(...x); | |
| const k = it._round(r + T[0]), C = it._round(a + T[1]); | |
| let P = 1, j = 1, Z, V; | |
| if (e.fromKeyboard) | |
| ({ | |
| deltaX: Z, | |
| deltaY: V | |
| } = e); | |
| else { | |
| const { | |
| screenX: M, | |
| screenY: z | |
| } = e, [ot, kt] = o(this, yr); | |
| [Z, V] = this.screenToPageTranslation(M - ot, z - kt), o(this, yr)[0] = M, o(this, yr)[1] = z; | |
| } | |
| if ([Z, V] = m(Z / s, V / i), A) { | |
| const M = Math.hypot(l, c); | |
| P = j = Math.max(Math.min(Math.hypot(x[0] - E[0] - Z, x[1] - E[1] - V) / M, 1 / l, 1 / c), h / l, u / c); | |
| } else S ? P = Math.max(h, Math.min(1, Math.abs(x[0] - E[0] - Z))) / l : j = Math.max(u, Math.min(1, Math.abs(x[1] - E[1] - V))) / c; | |
| const dt = it._round(l * P), gt = it._round(c * j); | |
| T = f(..._(dt, gt)); | |
| const Y = k - T[0], xt = C - T[1]; | |
| o(this, Ge) || p(this, Ge, [this.x, this.y, this.width, this.height]), this.width = dt, this.height = gt, this.x = Y, this.y = xt, this.setDims(s * dt, i * gt), this.fixAndSetPosition(), this._onResizing(); | |
| }, lb = function() { | |
| var t; | |
| p(this, Ti, { | |
| savedX: this.x, | |
| savedY: this.y, | |
| savedWidth: this.width, | |
| savedHeight: this.height | |
| }), (t = o(this, It)) == null || t.toggle(!1), this.parent.togglePointerEvents(!1); | |
| }, cb = function(t, e, s) { | |
| let r = 0.7 * (s / e) + 1 - 0.7; | |
| if (r === 1) | |
| return; | |
| const a = v(this, q, Jh).call(this, this.rotation), l = (k, C) => [a[0] * k + a[2] * C, a[1] * k + a[3] * C], [c, h] = this.parentDimensions, u = this.x, d = this.y, f = this.width, g = this.height, m = it.MIN_SIZE / c, y = it.MIN_SIZE / h; | |
| r = Math.max(Math.min(r, 1 / f, 1 / g), m / f, y / g); | |
| const _ = it._round(f * r), A = it._round(g * r); | |
| if (_ === f && A === g) | |
| return; | |
| o(this, Ge) || p(this, Ge, [u, d, f, g]); | |
| const S = l(f / 2, g / 2), E = it._round(u + S[0]), x = it._round(d + S[1]), T = l(_ / 2, A / 2); | |
| this.x = E - T[0], this.y = x - T[1], this.width = _, this.height = A, this.setDims(c * _, h * A), this.fixAndSetPosition(), this._onResizing(); | |
| }, hb = function() { | |
| var t; | |
| (t = o(this, It)) == null || t.toggle(!0), this.parent.togglePointerEvents(!0), v(this, q, Qh).call(this); | |
| }, If = function(t) { | |
| const { | |
| isMac: e | |
| } = Me.platform; | |
| t.ctrlKey && !e || t.shiftKey || t.metaKey && e ? this.parent.toggleSelected(this) : this.parent.setSelected(this); | |
| }, ub = function(t) { | |
| const { | |
| isSelected: e | |
| } = this; | |
| this._uiManager.setUpDragSession(); | |
| let s = !1; | |
| const i = new AbortController(), r = this._uiManager.combinedSignal(i), a = { | |
| capture: !0, | |
| passive: !1, | |
| signal: r | |
| }, l = (h) => { | |
| i.abort(), p(this, pn, null), p(this, br, !1), this._uiManager.endDragSession() || v(this, q, If).call(this, h), s && this._onStopDragging(); | |
| }; | |
| e && (p(this, Xa, t.clientX), p(this, Za, t.clientY), p(this, pn, t.pointerId), p(this, Cc, t.pointerType), window.addEventListener("pointermove", (h) => { | |
| s || (s = !0, this._onStartDragging()); | |
| const { | |
| clientX: u, | |
| clientY: d, | |
| pointerId: f | |
| } = h; | |
| if (f !== o(this, pn)) { | |
| ns(h); | |
| return; | |
| } | |
| const [g, m] = this.screenToPageTranslation(u - o(this, Xa), d - o(this, Za)); | |
| p(this, Xa, u), p(this, Za, d), this._uiManager.dragSelectedEditors(g, m); | |
| }, a), window.addEventListener("touchmove", ns, a), window.addEventListener("pointerdown", (h) => { | |
| h.pointerType === o(this, Cc) && (o(this, _r) || h.isPrimary) && l(h), ns(h); | |
| }, a)); | |
| const c = (h) => { | |
| if (!o(this, pn) || o(this, pn) === h.pointerId) { | |
| l(h); | |
| return; | |
| } | |
| ns(h); | |
| }; | |
| window.addEventListener("pointerup", c, { | |
| signal: r | |
| }), window.addEventListener("blur", c, { | |
| signal: r | |
| }); | |
| }, Rf = function() { | |
| if (o(this, gn) || !this.div) | |
| return; | |
| p(this, gn, new AbortController()); | |
| const t = this._uiManager.combinedSignal(o(this, gn)); | |
| this.div.addEventListener("focusin", this.focusin.bind(this), { | |
| signal: t | |
| }), this.div.addEventListener("focusout", this.focusout.bind(this), { | |
| signal: t | |
| }); | |
| }, db = function(t) { | |
| it._resizerKeyboardManager.exec(this, t); | |
| }, fb = function(t) { | |
| var e; | |
| o(this, Ci) && ((e = t.relatedTarget) == null ? void 0 : e.parentNode) !== o(this, he) && v(this, q, fl).call(this); | |
| }, pb = function(t) { | |
| p(this, kc, o(this, Ci) ? t : ""); | |
| }, Pf = function(t) { | |
| if (o(this, Cs)) | |
| for (const e of o(this, Cs)) | |
| e.tabIndex = t; | |
| }, fl = function() { | |
| p(this, Ci, !1), v(this, q, Pf).call(this, -1), v(this, q, Qh).call(this); | |
| }, b(it, Pc), G(it, "_l10n", null), G(it, "_l10nResizer", null), G(it, "_borderLineWidth", -1), G(it, "_colorManager", new yf()), G(it, "_zIndex", 1), G(it, "_telemetryTimeout", 1e3); | |
| let Ft = it; | |
| class GE extends Ft { | |
| constructor(t) { | |
| super(t), this.annotationElementId = t.annotationElementId, this.deleted = !0; | |
| } | |
| serialize() { | |
| return this.serializeDeleted(); | |
| } | |
| } | |
| const $g = 3285377520, ls = 4294901760, Gs = 65535; | |
| class gb { | |
| constructor(t) { | |
| this.h1 = t ? t & 4294967295 : $g, this.h2 = t ? t & 4294967295 : $g; | |
| } | |
| update(t) { | |
| let e, s; | |
| if (typeof t == "string") { | |
| e = new Uint8Array(t.length * 2), s = 0; | |
| for (let y = 0, _ = t.length; y < _; y++) { | |
| const A = t.charCodeAt(y); | |
| A <= 255 ? e[s++] = A : (e[s++] = A >>> 8, e[s++] = A & 255); | |
| } | |
| } else if (ArrayBuffer.isView(t)) | |
| e = t.slice(), s = e.byteLength; | |
| else | |
| throw new Error("Invalid data format, must be a string or TypedArray."); | |
| const i = s >> 2, r = s - i * 4, a = new Uint32Array(e.buffer, 0, i); | |
| let l = 0, c = 0, h = this.h1, u = this.h2; | |
| const d = 3432918353, f = 461845907, g = d & Gs, m = f & Gs; | |
| for (let y = 0; y < i; y++) | |
| y & 1 ? (l = a[y], l = l * d & ls | l * g & Gs, l = l << 15 | l >>> 17, l = l * f & ls | l * m & Gs, h ^= l, h = h << 13 | h >>> 19, h = h * 5 + 3864292196) : (c = a[y], c = c * d & ls | c * g & Gs, c = c << 15 | c >>> 17, c = c * f & ls | c * m & Gs, u ^= c, u = u << 13 | u >>> 19, u = u * 5 + 3864292196); | |
| switch (l = 0, r) { | |
| case 3: | |
| l ^= e[i * 4 + 2] << 16; | |
| case 2: | |
| l ^= e[i * 4 + 1] << 8; | |
| case 1: | |
| l ^= e[i * 4], l = l * d & ls | l * g & Gs, l = l << 15 | l >>> 17, l = l * f & ls | l * m & Gs, i & 1 ? h ^= l : u ^= l; | |
| } | |
| this.h1 = h, this.h2 = u; | |
| } | |
| hexdigest() { | |
| let t = this.h1, e = this.h2; | |
| return t ^= e >>> 1, t = t * 3981806797 & ls | t * 36045 & Gs, e = e * 4283543511 & ls | ((e << 16 | t >>> 16) * 2950163797 & ls) >>> 16, t ^= e >>> 1, t = t * 444984403 & ls | t * 60499 & Gs, e = e * 3301882366 & ls | ((e << 16 | t >>> 16) * 3120437893 & ls) >>> 16, t ^= e >>> 1, (t >>> 0).toString(16).padStart(8, "0") + (e >>> 0).toString(16).padStart(8, "0"); | |
| } | |
| } | |
| const Mf = Object.freeze({ | |
| map: null, | |
| hash: "", | |
| transfer: void 0 | |
| }); | |
| var Ar, wr, se, Qu, mb; | |
| class qp { | |
| constructor() { | |
| b(this, Qu); | |
| b(this, Ar, !1); | |
| b(this, wr, null); | |
| b(this, se, /* @__PURE__ */ new Map()); | |
| this.onSetModified = null, this.onResetModified = null, this.onAnnotationEditor = null; | |
| } | |
| getValue(t, e) { | |
| const s = o(this, se).get(t); | |
| return s === void 0 ? e : Object.assign(e, s); | |
| } | |
| getRawValue(t) { | |
| return o(this, se).get(t); | |
| } | |
| remove(t) { | |
| if (o(this, se).delete(t), o(this, se).size === 0 && this.resetModified(), typeof this.onAnnotationEditor == "function") { | |
| for (const e of o(this, se).values()) | |
| if (e instanceof Ft) | |
| return; | |
| this.onAnnotationEditor(null); | |
| } | |
| } | |
| setValue(t, e) { | |
| const s = o(this, se).get(t); | |
| let i = !1; | |
| if (s !== void 0) | |
| for (const [r, a] of Object.entries(e)) | |
| s[r] !== a && (i = !0, s[r] = a); | |
| else | |
| i = !0, o(this, se).set(t, e); | |
| i && v(this, Qu, mb).call(this), e instanceof Ft && typeof this.onAnnotationEditor == "function" && this.onAnnotationEditor(e.constructor._type); | |
| } | |
| has(t) { | |
| return o(this, se).has(t); | |
| } | |
| getAll() { | |
| return o(this, se).size > 0 ? Bp(o(this, se)) : null; | |
| } | |
| setAll(t) { | |
| for (const [e, s] of Object.entries(t)) | |
| this.setValue(e, s); | |
| } | |
| get size() { | |
| return o(this, se).size; | |
| } | |
| resetModified() { | |
| o(this, Ar) && (p(this, Ar, !1), typeof this.onResetModified == "function" && this.onResetModified()); | |
| } | |
| get print() { | |
| return new yb(this); | |
| } | |
| get serializable() { | |
| if (o(this, se).size === 0) | |
| return Mf; | |
| const t = /* @__PURE__ */ new Map(), e = new gb(), s = [], i = /* @__PURE__ */ Object.create(null); | |
| let r = !1; | |
| for (const [a, l] of o(this, se)) { | |
| const c = l instanceof Ft ? l.serialize(!1, i) : l; | |
| c && (t.set(a, c), e.update(`${a}:${JSON.stringify(c)}`), r || (r = !!c.bitmap)); | |
| } | |
| if (r) | |
| for (const a of t.values()) | |
| a.bitmap && s.push(a.bitmap); | |
| return t.size > 0 ? { | |
| map: t, | |
| hash: e.hexdigest(), | |
| transfer: s | |
| } : Mf; | |
| } | |
| get editorStats() { | |
| let t = null; | |
| const e = /* @__PURE__ */ new Map(); | |
| for (const s of o(this, se).values()) { | |
| if (!(s instanceof Ft)) | |
| continue; | |
| const i = s.telemetryFinalData; | |
| if (!i) | |
| continue; | |
| const { | |
| type: r | |
| } = i; | |
| e.has(r) || e.set(r, Object.getPrototypeOf(s).constructor), t || (t = /* @__PURE__ */ Object.create(null)); | |
| const a = t[r] || (t[r] = /* @__PURE__ */ new Map()); | |
| for (const [l, c] of Object.entries(i)) { | |
| if (l === "type") | |
| continue; | |
| let h = a.get(l); | |
| h || (h = /* @__PURE__ */ new Map(), a.set(l, h)); | |
| const u = h.get(c) ?? 0; | |
| h.set(c, u + 1); | |
| } | |
| } | |
| for (const [s, i] of e) | |
| t[s] = i.computeTelemetryFinalData(t[s]); | |
| return t; | |
| } | |
| resetModifiedIds() { | |
| p(this, wr, null); | |
| } | |
| get modifiedIds() { | |
| if (o(this, wr)) | |
| return o(this, wr); | |
| const t = []; | |
| for (const e of o(this, se).values()) | |
| !(e instanceof Ft) || !e.annotationElementId || !e.serialize() || t.push(e.annotationElementId); | |
| return p(this, wr, { | |
| ids: new Set(t), | |
| hash: t.join(",") | |
| }); | |
| } | |
| } | |
| Ar = new WeakMap(), wr = new WeakMap(), se = new WeakMap(), Qu = new WeakSet(), mb = function() { | |
| o(this, Ar) || (p(this, Ar, !0), typeof this.onSetModified == "function" && this.onSetModified()); | |
| }; | |
| var Mc; | |
| class yb extends qp { | |
| constructor(e) { | |
| super(); | |
| b(this, Mc); | |
| const { | |
| map: s, | |
| hash: i, | |
| transfer: r | |
| } = e.serializable, a = structuredClone(s, r ? { | |
| transfer: r | |
| } : null); | |
| p(this, Mc, { | |
| map: a, | |
| hash: i, | |
| transfer: r | |
| }); | |
| } | |
| get print() { | |
| Et("Should not call PrintAnnotationStorage.print"); | |
| } | |
| get serializable() { | |
| return o(this, Mc); | |
| } | |
| get modifiedIds() { | |
| return at(this, "modifiedIds", { | |
| ids: /* @__PURE__ */ new Set(), | |
| hash: "" | |
| }); | |
| } | |
| } | |
| Mc = new WeakMap(); | |
| var Ya; | |
| class qE { | |
| constructor({ | |
| ownerDocument: t = globalThis.document, | |
| styleElement: e = null | |
| }) { | |
| b(this, Ya, /* @__PURE__ */ new Set()); | |
| this._document = t, this.nativeFontFaces = /* @__PURE__ */ new Set(), this.styleElement = null, this.loadingRequests = [], this.loadTestFontId = 0; | |
| } | |
| addNativeFontFace(t) { | |
| this.nativeFontFaces.add(t), this._document.fonts.add(t); | |
| } | |
| removeNativeFontFace(t) { | |
| this.nativeFontFaces.delete(t), this._document.fonts.delete(t); | |
| } | |
| insertRule(t) { | |
| this.styleElement || (this.styleElement = this._document.createElement("style"), this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)); | |
| const e = this.styleElement.sheet; | |
| e.insertRule(t, e.cssRules.length); | |
| } | |
| clear() { | |
| for (const t of this.nativeFontFaces) | |
| this._document.fonts.delete(t); | |
| this.nativeFontFaces.clear(), o(this, Ya).clear(), this.styleElement && (this.styleElement.remove(), this.styleElement = null); | |
| } | |
| async loadSystemFont({ | |
| systemFontInfo: t, | |
| _inspectFont: e | |
| }) { | |
| if (!(!t || o(this, Ya).has(t.loadedName))) { | |
| if (qt(!this.disableFontFace, "loadSystemFont shouldn't be called when `disableFontFace` is set."), this.isFontLoadingAPISupported) { | |
| const { | |
| loadedName: s, | |
| src: i, | |
| style: r | |
| } = t, a = new FontFace(s, i, r); | |
| this.addNativeFontFace(a); | |
| try { | |
| await a.load(), o(this, Ya).add(s), e == null || e(t); | |
| } catch { | |
| st(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`), this.removeNativeFontFace(a); | |
| } | |
| return; | |
| } | |
| Et("Not implemented: loadSystemFont without the Font Loading API."); | |
| } | |
| } | |
| async bind(t) { | |
| if (t.attached || t.missingFile && !t.systemFontInfo) | |
| return; | |
| if (t.attached = !0, t.systemFontInfo) { | |
| await this.loadSystemFont(t); | |
| return; | |
| } | |
| if (this.isFontLoadingAPISupported) { | |
| const s = t.createNativeFontFace(); | |
| if (s) { | |
| this.addNativeFontFace(s); | |
| try { | |
| await s.loaded; | |
| } catch (i) { | |
| throw st(`Failed to load font '${s.family}': '${i}'.`), t.disableFontFace = !0, i; | |
| } | |
| } | |
| return; | |
| } | |
| const e = t.createFontFaceRule(); | |
| if (e) { | |
| if (this.insertRule(e), this.isSyncFontLoadingSupported) | |
| return; | |
| await new Promise((s) => { | |
| const i = this._queueLoadingCallback(s); | |
| this._prepareFontLoadEvent(t, i); | |
| }); | |
| } | |
| } | |
| get isFontLoadingAPISupported() { | |
| var e; | |
| const t = !!((e = this._document) != null && e.fonts); | |
| return at(this, "isFontLoadingAPISupported", t); | |
| } | |
| get isSyncFontLoadingSupported() { | |
| let t = !1; | |
| return (Se || typeof navigator < "u" && typeof (navigator == null ? void 0 : navigator.userAgent) == "string" && /Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)) && (t = !0), at(this, "isSyncFontLoadingSupported", t); | |
| } | |
| _queueLoadingCallback(t) { | |
| function e() { | |
| for (qt(!i.done, "completeRequest() cannot be called twice."), i.done = !0; s.length > 0 && s[0].done; ) { | |
| const r = s.shift(); | |
| setTimeout(r.callback, 0); | |
| } | |
| } | |
| const { | |
| loadingRequests: s | |
| } = this, i = { | |
| done: !1, | |
| complete: e, | |
| callback: t | |
| }; | |
| return s.push(i), i; | |
| } | |
| get _loadTestFont() { | |
| const t = atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="); | |
| return at(this, "_loadTestFont", t); | |
| } | |
| _prepareFontLoadEvent(t, e) { | |
| function s(x, T) { | |
| return x.charCodeAt(T) << 24 | x.charCodeAt(T + 1) << 16 | x.charCodeAt(T + 2) << 8 | x.charCodeAt(T + 3) & 255; | |
| } | |
| function i(x, T, k, C) { | |
| const P = x.substring(0, T), j = x.substring(T + k); | |
| return P + C + j; | |
| } | |
| let r, a; | |
| const l = this._document.createElement("canvas"); | |
| l.width = 1, l.height = 1; | |
| const c = l.getContext("2d"); | |
| let h = 0; | |
| function u(x, T) { | |
| if (++h > 30) { | |
| st("Load test font never loaded."), T(); | |
| return; | |
| } | |
| if (c.font = "30px " + x, c.fillText(".", 0, 20), c.getImageData(0, 0, 1, 1).data[3] > 0) { | |
| T(); | |
| return; | |
| } | |
| setTimeout(u.bind(null, x, T)); | |
| } | |
| const d = `lt${Date.now()}${this.loadTestFontId++}`; | |
| let f = this._loadTestFont; | |
| f = i(f, 976, d.length, d); | |
| const m = 16, y = 1482184792; | |
| let _ = s(f, m); | |
| for (r = 0, a = d.length - 3; r < a; r += 4) | |
| _ = _ - y + s(d, r) | 0; | |
| r < d.length && (_ = _ - y + s(d + "XXX", r) | 0), f = i(f, m, 4, PE(_)); | |
| const A = `url(data:font/opentype;base64,${btoa(f)});`, S = `@font-face {font-family:"${d}";src:${A}}`; | |
| this.insertRule(S); | |
| const E = this._document.createElement("div"); | |
| E.style.visibility = "hidden", E.style.width = E.style.height = "10px", E.style.position = "absolute", E.style.top = E.style.left = "0px"; | |
| for (const x of [t.loadedName, d]) { | |
| const T = this._document.createElement("span"); | |
| T.textContent = "Hi", T.style.fontFamily = x, E.append(T); | |
| } | |
| this._document.body.append(E), u(d, () => { | |
| E.remove(), e.complete(); | |
| }); | |
| } | |
| } | |
| Ya = new WeakMap(); | |
| class WE { | |
| constructor(t, { | |
| disableFontFace: e = !1, | |
| fontExtraProperties: s = !1, | |
| inspectFont: i = null | |
| }) { | |
| this.compiledGlyphs = /* @__PURE__ */ Object.create(null); | |
| for (const r in t) | |
| this[r] = t[r]; | |
| this.disableFontFace = e === !0, this.fontExtraProperties = s === !0, this._inspectFont = i; | |
| } | |
| createNativeFontFace() { | |
| var e; | |
| if (!this.data || this.disableFontFace) | |
| return null; | |
| let t; | |
| if (!this.cssFontInfo) | |
| t = new FontFace(this.loadedName, this.data, {}); | |
| else { | |
| const s = { | |
| weight: this.cssFontInfo.fontWeight | |
| }; | |
| this.cssFontInfo.italicAngle && (s.style = `oblique ${this.cssFontInfo.italicAngle}deg`), t = new FontFace(this.cssFontInfo.fontFamily, this.data, s); | |
| } | |
| return (e = this._inspectFont) == null || e.call(this, this), t; | |
| } | |
| createFontFaceRule() { | |
| var s; | |
| if (!this.data || this.disableFontFace) | |
| return null; | |
| const t = `url(data:${this.mimetype};base64,${FE(this.data)});`; | |
| let e; | |
| if (!this.cssFontInfo) | |
| e = `@font-face {font-family:"${this.loadedName}";src:${t}}`; | |
| else { | |
| let i = `font-weight: ${this.cssFontInfo.fontWeight};`; | |
| this.cssFontInfo.italicAngle && (i += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`), e = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`; | |
| } | |
| return (s = this._inspectFont) == null || s.call(this, this, t), e; | |
| } | |
| getPathGenerator(t, e) { | |
| if (this.compiledGlyphs[e] !== void 0) | |
| return this.compiledGlyphs[e]; | |
| const s = this.loadedName + "_path_" + e; | |
| let i; | |
| try { | |
| i = t.get(s); | |
| } catch (a) { | |
| st(`getPathGenerator - ignoring character: "${a}".`); | |
| } | |
| const r = new Path2D(i || ""); | |
| return this.fontExtraProperties || t.delete(s), this.compiledGlyphs[e] = r; | |
| } | |
| } | |
| const jh = { | |
| DATA: 1, | |
| ERROR: 2 | |
| }, Gt = { | |
| CANCEL: 1, | |
| CANCEL_COMPLETE: 2, | |
| CLOSE: 3, | |
| ENQUEUE: 4, | |
| ERROR: 5, | |
| PULL: 6, | |
| PULL_COMPLETE: 7, | |
| START_COMPLETE: 8 | |
| }; | |
| function jg() { | |
| } | |
| function Fe(n) { | |
| if (n instanceof Bn || n instanceof uf || n instanceof ic || n instanceof Lg || n instanceof $u || n instanceof Vd) | |
| return n; | |
| switch (n instanceof Error || typeof n == "object" && n !== null || Et('wrapReason: Expected "reason" to be a (possibly cloned) Error.'), n.name) { | |
| case "AbortException": | |
| return new Bn(n.message); | |
| case "InvalidPDFException": | |
| return new uf(n.message); | |
| case "MissingPDFException": | |
| return new ic(n.message); | |
| case "PasswordException": | |
| return new Lg(n.message, n.code); | |
| case "UnexpectedResponseException": | |
| return new $u(n.message, n.status); | |
| case "UnknownErrorException": | |
| return new Vd(n.message, n.details); | |
| } | |
| return new Vd(n.message, n.toString()); | |
| } | |
| var Ka, bs, bb, vb, _b, tu; | |
| class pl { | |
| constructor(t, e, s) { | |
| b(this, bs); | |
| b(this, Ka, new AbortController()); | |
| this.sourceName = t, this.targetName = e, this.comObj = s, this.callbackId = 1, this.streamId = 1, this.streamSinks = /* @__PURE__ */ Object.create(null), this.streamControllers = /* @__PURE__ */ Object.create(null), this.callbackCapabilities = /* @__PURE__ */ Object.create(null), this.actionHandler = /* @__PURE__ */ Object.create(null), s.addEventListener("message", v(this, bs, bb).bind(this), { | |
| signal: o(this, Ka).signal | |
| }); | |
| } | |
| on(t, e) { | |
| const s = this.actionHandler; | |
| if (s[t]) | |
| throw new Error(`There is already an actionName called "${t}"`); | |
| s[t] = e; | |
| } | |
| send(t, e, s) { | |
| this.comObj.postMessage({ | |
| sourceName: this.sourceName, | |
| targetName: this.targetName, | |
| action: t, | |
| data: e | |
| }, s); | |
| } | |
| sendWithPromise(t, e, s) { | |
| const i = this.callbackId++, r = Promise.withResolvers(); | |
| this.callbackCapabilities[i] = r; | |
| try { | |
| this.comObj.postMessage({ | |
| sourceName: this.sourceName, | |
| targetName: this.targetName, | |
| action: t, | |
| callbackId: i, | |
| data: e | |
| }, s); | |
| } catch (a) { | |
| r.reject(a); | |
| } | |
| return r.promise; | |
| } | |
| sendWithStream(t, e, s, i) { | |
| const r = this.streamId++, a = this.sourceName, l = this.targetName, c = this.comObj; | |
| return new ReadableStream({ | |
| start: (h) => { | |
| const u = Promise.withResolvers(); | |
| return this.streamControllers[r] = { | |
| controller: h, | |
| startCall: u, | |
| pullCall: null, | |
| cancelCall: null, | |
| isClosed: !1 | |
| }, c.postMessage({ | |
| sourceName: a, | |
| targetName: l, | |
| action: t, | |
| streamId: r, | |
| data: e, | |
| desiredSize: h.desiredSize | |
| }, i), u.promise; | |
| }, | |
| pull: (h) => { | |
| const u = Promise.withResolvers(); | |
| return this.streamControllers[r].pullCall = u, c.postMessage({ | |
| sourceName: a, | |
| targetName: l, | |
| stream: Gt.PULL, | |
| streamId: r, | |
| desiredSize: h.desiredSize | |
| }), u.promise; | |
| }, | |
| cancel: (h) => { | |
| qt(h instanceof Error, "cancel must have a valid reason"); | |
| const u = Promise.withResolvers(); | |
| return this.streamControllers[r].cancelCall = u, this.streamControllers[r].isClosed = !0, c.postMessage({ | |
| sourceName: a, | |
| targetName: l, | |
| stream: Gt.CANCEL, | |
| streamId: r, | |
| reason: Fe(h) | |
| }), u.promise; | |
| } | |
| }, s); | |
| } | |
| destroy() { | |
| var t; | |
| (t = o(this, Ka)) == null || t.abort(), p(this, Ka, null); | |
| } | |
| } | |
| Ka = new WeakMap(), bs = new WeakSet(), bb = function({ | |
| data: t | |
| }) { | |
| if (t.targetName !== this.sourceName) | |
| return; | |
| if (t.stream) { | |
| v(this, bs, _b).call(this, t); | |
| return; | |
| } | |
| if (t.callback) { | |
| const s = t.callbackId, i = this.callbackCapabilities[s]; | |
| if (!i) | |
| throw new Error(`Cannot resolve callback ${s}`); | |
| if (delete this.callbackCapabilities[s], t.callback === jh.DATA) | |
| i.resolve(t.data); | |
| else if (t.callback === jh.ERROR) | |
| i.reject(Fe(t.reason)); | |
| else | |
| throw new Error("Unexpected callback case"); | |
| return; | |
| } | |
| const e = this.actionHandler[t.action]; | |
| if (!e) | |
| throw new Error(`Unknown action from worker: ${t.action}`); | |
| if (t.callbackId) { | |
| const s = this.sourceName, i = t.sourceName, r = this.comObj; | |
| Promise.try(e, t.data).then(function(a) { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| callback: jh.DATA, | |
| callbackId: t.callbackId, | |
| data: a | |
| }); | |
| }, function(a) { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| callback: jh.ERROR, | |
| callbackId: t.callbackId, | |
| reason: Fe(a) | |
| }); | |
| }); | |
| return; | |
| } | |
| if (t.streamId) { | |
| v(this, bs, vb).call(this, t); | |
| return; | |
| } | |
| e(t.data); | |
| }, vb = function(t) { | |
| const e = t.streamId, s = this.sourceName, i = t.sourceName, r = this.comObj, a = this, l = this.actionHandler[t.action], c = { | |
| enqueue(h, u = 1, d) { | |
| if (this.isCancelled) | |
| return; | |
| const f = this.desiredSize; | |
| this.desiredSize -= u, f > 0 && this.desiredSize <= 0 && (this.sinkCapability = Promise.withResolvers(), this.ready = this.sinkCapability.promise), r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.ENQUEUE, | |
| streamId: e, | |
| chunk: h | |
| }, d); | |
| }, | |
| close() { | |
| this.isCancelled || (this.isCancelled = !0, r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.CLOSE, | |
| streamId: e | |
| }), delete a.streamSinks[e]); | |
| }, | |
| error(h) { | |
| qt(h instanceof Error, "error must have a valid reason"), !this.isCancelled && (this.isCancelled = !0, r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.ERROR, | |
| streamId: e, | |
| reason: Fe(h) | |
| })); | |
| }, | |
| sinkCapability: Promise.withResolvers(), | |
| onPull: null, | |
| onCancel: null, | |
| isCancelled: !1, | |
| desiredSize: t.desiredSize, | |
| ready: null | |
| }; | |
| c.sinkCapability.resolve(), c.ready = c.sinkCapability.promise, this.streamSinks[e] = c, Promise.try(l, t.data, c).then(function() { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.START_COMPLETE, | |
| streamId: e, | |
| success: !0 | |
| }); | |
| }, function(h) { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.START_COMPLETE, | |
| streamId: e, | |
| reason: Fe(h) | |
| }); | |
| }); | |
| }, _b = function(t) { | |
| const e = t.streamId, s = this.sourceName, i = t.sourceName, r = this.comObj, a = this.streamControllers[e], l = this.streamSinks[e]; | |
| switch (t.stream) { | |
| case Gt.START_COMPLETE: | |
| t.success ? a.startCall.resolve() : a.startCall.reject(Fe(t.reason)); | |
| break; | |
| case Gt.PULL_COMPLETE: | |
| t.success ? a.pullCall.resolve() : a.pullCall.reject(Fe(t.reason)); | |
| break; | |
| case Gt.PULL: | |
| if (!l) { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.PULL_COMPLETE, | |
| streamId: e, | |
| success: !0 | |
| }); | |
| break; | |
| } | |
| l.desiredSize <= 0 && t.desiredSize > 0 && l.sinkCapability.resolve(), l.desiredSize = t.desiredSize, Promise.try(l.onPull || jg).then(function() { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.PULL_COMPLETE, | |
| streamId: e, | |
| success: !0 | |
| }); | |
| }, function(h) { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.PULL_COMPLETE, | |
| streamId: e, | |
| reason: Fe(h) | |
| }); | |
| }); | |
| break; | |
| case Gt.ENQUEUE: | |
| if (qt(a, "enqueue should have stream controller"), a.isClosed) | |
| break; | |
| a.controller.enqueue(t.chunk); | |
| break; | |
| case Gt.CLOSE: | |
| if (qt(a, "close should have stream controller"), a.isClosed) | |
| break; | |
| a.isClosed = !0, a.controller.close(), v(this, bs, tu).call(this, a, e); | |
| break; | |
| case Gt.ERROR: | |
| qt(a, "error should have stream controller"), a.controller.error(Fe(t.reason)), v(this, bs, tu).call(this, a, e); | |
| break; | |
| case Gt.CANCEL_COMPLETE: | |
| t.success ? a.cancelCall.resolve() : a.cancelCall.reject(Fe(t.reason)), v(this, bs, tu).call(this, a, e); | |
| break; | |
| case Gt.CANCEL: | |
| if (!l) | |
| break; | |
| const c = Fe(t.reason); | |
| Promise.try(l.onCancel || jg, c).then(function() { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.CANCEL_COMPLETE, | |
| streamId: e, | |
| success: !0 | |
| }); | |
| }, function(h) { | |
| r.postMessage({ | |
| sourceName: s, | |
| targetName: i, | |
| stream: Gt.CANCEL_COMPLETE, | |
| streamId: e, | |
| reason: Fe(h) | |
| }); | |
| }), l.sinkCapability.reject(c), l.isCancelled = !0, delete this.streamSinks[e]; | |
| break; | |
| default: | |
| throw new Error("Unexpected stream case"); | |
| } | |
| }, tu = async function(t, e) { | |
| var s, i, r; | |
| await Promise.allSettled([(s = t.startCall) == null ? void 0 : s.promise, (i = t.pullCall) == null ? void 0 : i.promise, (r = t.cancelCall) == null ? void 0 : r.promise]), delete this.streamControllers[e]; | |
| }; | |
| var Nc; | |
| class Ab { | |
| constructor({ | |
| enableHWA: t = !1 | |
| }) { | |
| b(this, Nc, !1); | |
| p(this, Nc, t); | |
| } | |
| create(t, e) { | |
| if (t <= 0 || e <= 0) | |
| throw new Error("Invalid canvas size"); | |
| const s = this._createCanvas(t, e); | |
| return { | |
| canvas: s, | |
| context: s.getContext("2d", { | |
| willReadFrequently: !o(this, Nc) | |
| }) | |
| }; | |
| } | |
| reset(t, e, s) { | |
| if (!t.canvas) | |
| throw new Error("Canvas is not specified"); | |
| if (e <= 0 || s <= 0) | |
| throw new Error("Invalid canvas size"); | |
| t.canvas.width = e, t.canvas.height = s; | |
| } | |
| destroy(t) { | |
| if (!t.canvas) | |
| throw new Error("Canvas is not specified"); | |
| t.canvas.width = 0, t.canvas.height = 0, t.canvas = null, t.context = null; | |
| } | |
| _createCanvas(t, e) { | |
| Et("Abstract method `_createCanvas` called."); | |
| } | |
| } | |
| Nc = new WeakMap(); | |
| class XE extends Ab { | |
| constructor({ | |
| ownerDocument: t = globalThis.document, | |
| enableHWA: e = !1 | |
| }) { | |
| super({ | |
| enableHWA: e | |
| }), this._document = t; | |
| } | |
| _createCanvas(t, e) { | |
| const s = this._document.createElement("canvas"); | |
| return s.width = t, s.height = e, s; | |
| } | |
| } | |
| class wb { | |
| constructor({ | |
| baseUrl: t = null, | |
| isCompressed: e = !0 | |
| }) { | |
| this.baseUrl = t, this.isCompressed = e; | |
| } | |
| async fetch({ | |
| name: t | |
| }) { | |
| if (!this.baseUrl) | |
| throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided."); | |
| if (!t) | |
| throw new Error("CMap name must be specified."); | |
| const e = this.baseUrl + t + (this.isCompressed ? ".bcmap" : ""); | |
| return this._fetch(e).then((s) => ({ | |
| cMapData: s, | |
| isCompressed: this.isCompressed | |
| })).catch((s) => { | |
| throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${e}`); | |
| }); | |
| } | |
| async _fetch(t) { | |
| Et("Abstract method `_fetch` called."); | |
| } | |
| } | |
| class Sb extends wb { | |
| async _fetch(t) { | |
| const e = await Ad(t, this.isCompressed ? "arraybuffer" : "text"); | |
| return e instanceof ArrayBuffer ? new Uint8Array(e) : _d(e); | |
| } | |
| } | |
| class Eb { | |
| addFilter(t) { | |
| return "none"; | |
| } | |
| addHCMFilter(t, e) { | |
| return "none"; | |
| } | |
| addAlphaFilter(t) { | |
| return "none"; | |
| } | |
| addLuminosityFilter(t) { | |
| return "none"; | |
| } | |
| addHighlightHCMFilter(t, e, s, i, r) { | |
| return "none"; | |
| } | |
| destroy(t = !1) { | |
| } | |
| } | |
| var Sr, Ja, ki, Ii, ve, Er, xr, D, me, gl, Sa, eu, Ea, xb, Nf, xa, ml, yl, Of, bl; | |
| class ZE extends Eb { | |
| constructor({ | |
| docId: e, | |
| ownerDocument: s = globalThis.document | |
| }) { | |
| super(); | |
| b(this, D); | |
| b(this, Sr); | |
| b(this, Ja); | |
| b(this, ki); | |
| b(this, Ii); | |
| b(this, ve); | |
| b(this, Er); | |
| b(this, xr, 0); | |
| p(this, Ii, e), p(this, ve, s); | |
| } | |
| addFilter(e) { | |
| if (!e) | |
| return "none"; | |
| let s = o(this, D, me).get(e); | |
| if (s) | |
| return s; | |
| const [i, r, a] = v(this, D, eu).call(this, e), l = e.length === 1 ? i : `${i}${r}${a}`; | |
| if (s = o(this, D, me).get(l), s) | |
| return o(this, D, me).set(e, s), s; | |
| const c = `g_${o(this, Ii)}_transfer_map_${xe(this, xr)._++}`, h = v(this, D, Ea).call(this, c); | |
| o(this, D, me).set(e, h), o(this, D, me).set(l, h); | |
| const u = v(this, D, xa).call(this, c); | |
| return v(this, D, yl).call(this, i, r, a, u), h; | |
| } | |
| addHCMFilter(e, s) { | |
| var m; | |
| const i = `${e}-${s}`, r = "base"; | |
| let a = o(this, D, gl).get(r); | |
| if ((a == null ? void 0 : a.key) === i || (a ? ((m = a.filter) == null || m.remove(), a.key = i, a.url = "none", a.filter = null) : (a = { | |
| key: i, | |
| url: "none", | |
| filter: null | |
| }, o(this, D, gl).set(r, a)), !e || !s)) | |
| return a.url; | |
| const l = v(this, D, bl).call(this, e); | |
| e = U.makeHexColor(...l); | |
| const c = v(this, D, bl).call(this, s); | |
| if (s = U.makeHexColor(...c), o(this, D, Sa).style.color = "", e === "#000000" && s === "#ffffff" || e === s) | |
| return a.url; | |
| const h = new Array(256); | |
| for (let y = 0; y <= 255; y++) { | |
| const _ = y / 255; | |
| h[y] = _ <= 0.03928 ? _ / 12.92 : ((_ + 0.055) / 1.055) ** 2.4; | |
| } | |
| const u = h.join(","), d = `g_${o(this, Ii)}_hcm_filter`, f = a.filter = v(this, D, xa).call(this, d); | |
| v(this, D, yl).call(this, u, u, u, f), v(this, D, Nf).call(this, f); | |
| const g = (y, _) => { | |
| const A = l[y] / 255, S = c[y] / 255, E = new Array(_ + 1); | |
| for (let x = 0; x <= _; x++) | |
| E[x] = A + x / _ * (S - A); | |
| return E.join(","); | |
| }; | |
| return v(this, D, yl).call(this, g(0, 5), g(1, 5), g(2, 5), f), a.url = v(this, D, Ea).call(this, d), a.url; | |
| } | |
| addAlphaFilter(e) { | |
| let s = o(this, D, me).get(e); | |
| if (s) | |
| return s; | |
| const [i] = v(this, D, eu).call(this, [e]), r = `alpha_${i}`; | |
| if (s = o(this, D, me).get(r), s) | |
| return o(this, D, me).set(e, s), s; | |
| const a = `g_${o(this, Ii)}_alpha_map_${xe(this, xr)._++}`, l = v(this, D, Ea).call(this, a); | |
| o(this, D, me).set(e, l), o(this, D, me).set(r, l); | |
| const c = v(this, D, xa).call(this, a); | |
| return v(this, D, Of).call(this, i, c), l; | |
| } | |
| addLuminosityFilter(e) { | |
| let s = o(this, D, me).get(e || "luminosity"); | |
| if (s) | |
| return s; | |
| let i, r; | |
| if (e ? ([i] = v(this, D, eu).call(this, [e]), r = `luminosity_${i}`) : r = "luminosity", s = o(this, D, me).get(r), s) | |
| return o(this, D, me).set(e, s), s; | |
| const a = `g_${o(this, Ii)}_luminosity_map_${xe(this, xr)._++}`, l = v(this, D, Ea).call(this, a); | |
| o(this, D, me).set(e, l), o(this, D, me).set(r, l); | |
| const c = v(this, D, xa).call(this, a); | |
| return v(this, D, xb).call(this, c), e && v(this, D, Of).call(this, i, c), l; | |
| } | |
| addHighlightHCMFilter(e, s, i, r, a) { | |
| var S; | |
| const l = `${s}-${i}-${r}-${a}`; | |
| let c = o(this, D, gl).get(e); | |
| if ((c == null ? void 0 : c.key) === l || (c ? ((S = c.filter) == null || S.remove(), c.key = l, c.url = "none", c.filter = null) : (c = { | |
| key: l, | |
| url: "none", | |
| filter: null | |
| }, o(this, D, gl).set(e, c)), !s || !i)) | |
| return c.url; | |
| const [h, u] = [s, i].map(v(this, D, bl).bind(this)); | |
| let d = Math.round(0.2126 * h[0] + 0.7152 * h[1] + 0.0722 * h[2]), f = Math.round(0.2126 * u[0] + 0.7152 * u[1] + 0.0722 * u[2]), [g, m] = [r, a].map(v(this, D, bl).bind(this)); | |
| f < d && ([d, f, g, m] = [f, d, m, g]), o(this, D, Sa).style.color = ""; | |
| const y = (E, x, T) => { | |
| const k = new Array(256), C = (f - d) / T, P = E / 255, j = (x - E) / (255 * T); | |
| let Z = 0; | |
| for (let V = 0; V <= T; V++) { | |
| const dt = Math.round(d + V * C), gt = P + V * j; | |
| for (let Y = Z; Y <= dt; Y++) | |
| k[Y] = gt; | |
| Z = dt + 1; | |
| } | |
| for (let V = Z; V < 256; V++) | |
| k[V] = k[Z - 1]; | |
| return k.join(","); | |
| }, _ = `g_${o(this, Ii)}_hcm_${e}_filter`, A = c.filter = v(this, D, xa).call(this, _); | |
| return v(this, D, Nf).call(this, A), v(this, D, yl).call(this, y(g[0], m[0], 5), y(g[1], m[1], 5), y(g[2], m[2], 5), A), c.url = v(this, D, Ea).call(this, _), c.url; | |
| } | |
| destroy(e = !1) { | |
| var s, i, r, a; | |
| e && ((s = o(this, Er)) != null && s.size) || ((i = o(this, ki)) == null || i.parentNode.parentNode.remove(), p(this, ki, null), (r = o(this, Ja)) == null || r.clear(), p(this, Ja, null), (a = o(this, Er)) == null || a.clear(), p(this, Er, null), p(this, xr, 0)); | |
| } | |
| } | |
| Sr = new WeakMap(), Ja = new WeakMap(), ki = new WeakMap(), Ii = new WeakMap(), ve = new WeakMap(), Er = new WeakMap(), xr = new WeakMap(), D = new WeakSet(), me = function() { | |
| return o(this, Ja) || p(this, Ja, /* @__PURE__ */ new Map()); | |
| }, gl = function() { | |
| return o(this, Er) || p(this, Er, /* @__PURE__ */ new Map()); | |
| }, Sa = function() { | |
| if (!o(this, ki)) { | |
| const e = o(this, ve).createElement("div"), { | |
| style: s | |
| } = e; | |
| s.visibility = "hidden", s.contain = "strict", s.width = s.height = 0, s.position = "absolute", s.top = s.left = 0, s.zIndex = -1; | |
| const i = o(this, ve).createElementNS(gi, "svg"); | |
| i.setAttribute("width", 0), i.setAttribute("height", 0), p(this, ki, o(this, ve).createElementNS(gi, "defs")), e.append(i), i.append(o(this, ki)), o(this, ve).body.append(e); | |
| } | |
| return o(this, ki); | |
| }, eu = function(e) { | |
| if (e.length === 1) { | |
| const h = e[0], u = new Array(256); | |
| for (let f = 0; f < 256; f++) | |
| u[f] = h[f] / 255; | |
| const d = u.join(","); | |
| return [d, d, d]; | |
| } | |
| const [s, i, r] = e, a = new Array(256), l = new Array(256), c = new Array(256); | |
| for (let h = 0; h < 256; h++) | |
| a[h] = s[h] / 255, l[h] = i[h] / 255, c[h] = r[h] / 255; | |
| return [a.join(","), l.join(","), c.join(",")]; | |
| }, Ea = function(e) { | |
| if (o(this, Sr) === void 0) { | |
| p(this, Sr, ""); | |
| const s = o(this, ve).URL; | |
| s !== o(this, ve).baseURI && (wd(s) ? st('#createUrl: ignore "data:"-URL for performance reasons.') : p(this, Sr, s.split("#", 1)[0])); | |
| } | |
| return `url(${o(this, Sr)}#${e})`; | |
| }, xb = function(e) { | |
| const s = o(this, ve).createElementNS(gi, "feColorMatrix"); | |
| s.setAttribute("type", "matrix"), s.setAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"), e.append(s); | |
| }, Nf = function(e) { | |
| const s = o(this, ve).createElementNS(gi, "feColorMatrix"); | |
| s.setAttribute("type", "matrix"), s.setAttribute("values", "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"), e.append(s); | |
| }, xa = function(e) { | |
| const s = o(this, ve).createElementNS(gi, "filter"); | |
| return s.setAttribute("color-interpolation-filters", "sRGB"), s.setAttribute("id", e), o(this, D, Sa).append(s), s; | |
| }, ml = function(e, s, i) { | |
| const r = o(this, ve).createElementNS(gi, s); | |
| r.setAttribute("type", "discrete"), r.setAttribute("tableValues", i), e.append(r); | |
| }, yl = function(e, s, i, r) { | |
| const a = o(this, ve).createElementNS(gi, "feComponentTransfer"); | |
| r.append(a), v(this, D, ml).call(this, a, "feFuncR", e), v(this, D, ml).call(this, a, "feFuncG", s), v(this, D, ml).call(this, a, "feFuncB", i); | |
| }, Of = function(e, s) { | |
| const i = o(this, ve).createElementNS(gi, "feComponentTransfer"); | |
| s.append(i), v(this, D, ml).call(this, i, "feFuncA", e); | |
| }, bl = function(e) { | |
| return o(this, D, Sa).style.color = e, Gp(getComputedStyle(o(this, D, Sa)).getPropertyValue("color")); | |
| }; | |
| class Tb { | |
| constructor({ | |
| baseUrl: t = null | |
| }) { | |
| this.baseUrl = t; | |
| } | |
| async fetch({ | |
| filename: t | |
| }) { | |
| if (!this.baseUrl) | |
| throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided."); | |
| if (!t) | |
| throw new Error("Font filename must be specified."); | |
| const e = `${this.baseUrl}${t}`; | |
| return this._fetch(e).catch((s) => { | |
| throw new Error(`Unable to load font data at: ${e}`); | |
| }); | |
| } | |
| async _fetch(t) { | |
| Et("Abstract method `_fetch` called."); | |
| } | |
| } | |
| class Cb extends Tb { | |
| async _fetch(t) { | |
| const e = await Ad(t, "arraybuffer"); | |
| return new Uint8Array(e); | |
| } | |
| } | |
| Se && st("Please use the `legacy` build in Node.js environments."); | |
| async function kb(n) { | |
| const e = await process.getBuiltinModule("fs").promises.readFile(n); | |
| return new Uint8Array(e); | |
| } | |
| class YE extends Eb { | |
| } | |
| class KE extends Ab { | |
| _createCanvas(t, e) { | |
| return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t, e); | |
| } | |
| } | |
| class JE extends wb { | |
| async _fetch(t) { | |
| return kb(t); | |
| } | |
| } | |
| class QE extends Tb { | |
| async _fetch(t) { | |
| return kb(t); | |
| } | |
| } | |
| const we = { | |
| FILL: "Fill", | |
| STROKE: "Stroke", | |
| SHADING: "Shading" | |
| }; | |
| function Lf(n, t) { | |
| if (!t) | |
| return; | |
| const e = t[2] - t[0], s = t[3] - t[1], i = new Path2D(); | |
| i.rect(t[0], t[1], e, s), n.clip(i); | |
| } | |
| class Wp { | |
| getPattern() { | |
| Et("Abstract method `getPattern` called."); | |
| } | |
| } | |
| class tx extends Wp { | |
| constructor(t) { | |
| super(), this._type = t[1], this._bbox = t[2], this._colorStops = t[3], this._p0 = t[4], this._p1 = t[5], this._r0 = t[6], this._r1 = t[7], this.matrix = null; | |
| } | |
| _createGradient(t) { | |
| let e; | |
| this._type === "axial" ? e = t.createLinearGradient(this._p0[0], this._p0[1], this._p1[0], this._p1[1]) : this._type === "radial" && (e = t.createRadialGradient(this._p0[0], this._p0[1], this._r0, this._p1[0], this._p1[1], this._r1)); | |
| for (const s of this._colorStops) | |
| e.addColorStop(s[0], s[1]); | |
| return e; | |
| } | |
| getPattern(t, e, s, i) { | |
| let r; | |
| if (i === we.STROKE || i === we.FILL) { | |
| const a = e.current.getClippedPathBoundingBox(i, Mt(t)) || [0, 0, 0, 0], l = Math.ceil(a[2] - a[0]) || 1, c = Math.ceil(a[3] - a[1]) || 1, h = e.cachedCanvases.getCanvas("pattern", l, c), u = h.context; | |
| u.clearRect(0, 0, u.canvas.width, u.canvas.height), u.beginPath(), u.rect(0, 0, u.canvas.width, u.canvas.height), u.translate(-a[0], -a[1]), s = U.transform(s, [1, 0, 0, 1, a[0], a[1]]), u.transform(...e.baseTransform), this.matrix && u.transform(...this.matrix), Lf(u, this._bbox), u.fillStyle = this._createGradient(u), u.fill(), r = t.createPattern(h.canvas, "no-repeat"); | |
| const d = new DOMMatrix(s); | |
| r.setTransform(d); | |
| } else | |
| Lf(t, this._bbox), r = this._createGradient(t); | |
| return r; | |
| } | |
| } | |
| function Wd(n, t, e, s, i, r, a, l) { | |
| const c = t.coords, h = t.colors, u = n.data, d = n.width * 4; | |
| let f; | |
| c[e + 1] > c[s + 1] && (f = e, e = s, s = f, f = r, r = a, a = f), c[s + 1] > c[i + 1] && (f = s, s = i, i = f, f = a, a = l, l = f), c[e + 1] > c[s + 1] && (f = e, e = s, s = f, f = r, r = a, a = f); | |
| const g = (c[e] + t.offsetX) * t.scaleX, m = (c[e + 1] + t.offsetY) * t.scaleY, y = (c[s] + t.offsetX) * t.scaleX, _ = (c[s + 1] + t.offsetY) * t.scaleY, A = (c[i] + t.offsetX) * t.scaleX, S = (c[i + 1] + t.offsetY) * t.scaleY; | |
| if (m >= S) | |
| return; | |
| const E = h[r], x = h[r + 1], T = h[r + 2], k = h[a], C = h[a + 1], P = h[a + 2], j = h[l], Z = h[l + 1], V = h[l + 2], dt = Math.round(m), gt = Math.round(S); | |
| let Y, xt, M, z, ot, kt, yt, Q; | |
| for (let Vt = dt; Vt <= gt; Vt++) { | |
| if (Vt < _) { | |
| const tt = Vt < m ? 0 : (m - Vt) / (m - _); | |
| Y = g - (g - y) * tt, xt = E - (E - k) * tt, M = x - (x - C) * tt, z = T - (T - P) * tt; | |
| } else { | |
| let tt; | |
| Vt > S ? tt = 1 : _ === S ? tt = 0 : tt = (_ - Vt) / (_ - S), Y = y - (y - A) * tt, xt = k - (k - j) * tt, M = C - (C - Z) * tt, z = P - (P - V) * tt; | |
| } | |
| let $t; | |
| Vt < m ? $t = 0 : Vt > S ? $t = 1 : $t = (m - Vt) / (m - S), ot = g - (g - A) * $t, kt = E - (E - j) * $t, yt = x - (x - Z) * $t, Q = T - (T - V) * $t; | |
| const vs = Math.round(Math.min(Y, ot)), Tt = Math.round(Math.max(Y, ot)); | |
| let St = d * Vt + vs * 4; | |
| for (let tt = vs; tt <= Tt; tt++) | |
| $t = (Y - tt) / (Y - ot), $t < 0 ? $t = 0 : $t > 1 && ($t = 1), u[St++] = xt - (xt - kt) * $t | 0, u[St++] = M - (M - yt) * $t | 0, u[St++] = z - (z - Q) * $t | 0, u[St++] = 255; | |
| } | |
| } | |
| function ex(n, t, e) { | |
| const s = t.coords, i = t.colors; | |
| let r, a; | |
| switch (t.type) { | |
| case "lattice": | |
| const l = t.verticesPerRow, c = Math.floor(s.length / l) - 1, h = l - 1; | |
| for (r = 0; r < c; r++) { | |
| let u = r * l; | |
| for (let d = 0; d < h; d++, u++) | |
| Wd(n, e, s[u], s[u + 1], s[u + l], i[u], i[u + 1], i[u + l]), Wd(n, e, s[u + l + 1], s[u + 1], s[u + l], i[u + l + 1], i[u + 1], i[u + l]); | |
| } | |
| break; | |
| case "triangles": | |
| for (r = 0, a = s.length; r < a; r += 3) | |
| Wd(n, e, s[r], s[r + 1], s[r + 2], i[r], i[r + 1], i[r + 2]); | |
| break; | |
| default: | |
| throw new Error("illegal figure"); | |
| } | |
| } | |
| class sx extends Wp { | |
| constructor(t) { | |
| super(), this._coords = t[2], this._colors = t[3], this._figures = t[4], this._bounds = t[5], this._bbox = t[7], this._background = t[8], this.matrix = null; | |
| } | |
| _createMeshCanvas(t, e, s) { | |
| const l = Math.floor(this._bounds[0]), c = Math.floor(this._bounds[1]), h = Math.ceil(this._bounds[2]) - l, u = Math.ceil(this._bounds[3]) - c, d = Math.min(Math.ceil(Math.abs(h * t[0] * 1.1)), 3e3), f = Math.min(Math.ceil(Math.abs(u * t[1] * 1.1)), 3e3), g = h / d, m = u / f, y = { | |
| coords: this._coords, | |
| colors: this._colors, | |
| offsetX: -l, | |
| offsetY: -c, | |
| scaleX: 1 / g, | |
| scaleY: 1 / m | |
| }, _ = d + 2 * 2, A = f + 2 * 2, S = s.getCanvas("mesh", _, A), E = S.context, x = E.createImageData(d, f); | |
| if (e) { | |
| const k = x.data; | |
| for (let C = 0, P = k.length; C < P; C += 4) | |
| k[C] = e[0], k[C + 1] = e[1], k[C + 2] = e[2], k[C + 3] = 255; | |
| } | |
| for (const k of this._figures) | |
| ex(x, k, y); | |
| return E.putImageData(x, 2, 2), { | |
| canvas: S.canvas, | |
| offsetX: l - 2 * g, | |
| offsetY: c - 2 * m, | |
| scaleX: g, | |
| scaleY: m | |
| }; | |
| } | |
| getPattern(t, e, s, i) { | |
| Lf(t, this._bbox); | |
| let r; | |
| if (i === we.SHADING) | |
| r = U.singularValueDecompose2dScale(Mt(t)); | |
| else if (r = U.singularValueDecompose2dScale(e.baseTransform), this.matrix) { | |
| const l = U.singularValueDecompose2dScale(this.matrix); | |
| r = [r[0] * l[0], r[1] * l[1]]; | |
| } | |
| const a = this._createMeshCanvas(r, i === we.SHADING ? null : this._background, e.cachedCanvases); | |
| return i !== we.SHADING && (t.setTransform(...e.baseTransform), this.matrix && t.transform(...this.matrix)), t.translate(a.offsetX, a.offsetY), t.scale(a.scaleX, a.scaleY), t.createPattern(a.canvas, "no-repeat"); | |
| } | |
| } | |
| class ix extends Wp { | |
| getPattern() { | |
| return "hotpink"; | |
| } | |
| } | |
| function nx(n) { | |
| switch (n[0]) { | |
| case "RadialAxial": | |
| return new tx(n); | |
| case "Mesh": | |
| return new sx(n); | |
| case "Dummy": | |
| return new ix(); | |
| } | |
| throw new Error(`Unknown IR type: ${n[0]}`); | |
| } | |
| const Bg = { | |
| COLORED: 1, | |
| UNCOLORED: 2 | |
| }, td = class td { | |
| constructor(t, e, s, i, r) { | |
| this.operatorList = t[2], this.matrix = t[3], this.bbox = t[4], this.xstep = t[5], this.ystep = t[6], this.paintType = t[7], this.tilingType = t[8], this.color = e, this.ctx = s, this.canvasGraphicsFactory = i, this.baseTransform = r; | |
| } | |
| createPatternCanvas(t) { | |
| const { | |
| bbox: e, | |
| operatorList: s, | |
| paintType: i, | |
| tilingType: r, | |
| color: a, | |
| canvasGraphicsFactory: l | |
| } = this; | |
| let { | |
| xstep: c, | |
| ystep: h | |
| } = this; | |
| c = Math.abs(c), h = Math.abs(h), vd("TilingType: " + r); | |
| const u = e[0], d = e[1], f = e[2], g = e[3], m = f - u, y = g - d, _ = U.singularValueDecompose2dScale(this.matrix), A = U.singularValueDecompose2dScale(this.baseTransform), S = _[0] * A[0], E = _[1] * A[1]; | |
| let x = m, T = y, k = !1, C = !1; | |
| const P = Math.ceil(c * S), j = Math.ceil(h * E), Z = Math.ceil(m * S), V = Math.ceil(y * E); | |
| P >= Z ? x = c : k = !0, j >= V ? T = h : C = !0; | |
| const dt = this.getSizeAndScale(x, this.ctx.canvas.width, S), gt = this.getSizeAndScale(T, this.ctx.canvas.height, E), Y = t.cachedCanvases.getCanvas("pattern", dt.size, gt.size), xt = Y.context, M = l.createCanvasGraphics(xt); | |
| if (M.groupLevel = t.groupLevel, this.setFillAndStrokeStyleToContext(M, i, a), xt.translate(-dt.scale * u, -gt.scale * d), M.transform(dt.scale, 0, 0, gt.scale, 0, 0), xt.save(), this.clipBbox(M, u, d, f, g), M.baseTransform = Mt(M.ctx), M.executeOperatorList(s), M.endDrawing(), xt.restore(), k || C) { | |
| const z = Y.canvas; | |
| k && (x = c), C && (T = h); | |
| const ot = this.getSizeAndScale(x, this.ctx.canvas.width, S), kt = this.getSizeAndScale(T, this.ctx.canvas.height, E), yt = ot.size, Q = kt.size, Vt = t.cachedCanvases.getCanvas("pattern-workaround", yt, Q), $t = Vt.context, vs = k ? Math.floor(m / c) : 0, Tt = C ? Math.floor(y / h) : 0; | |
| for (let St = 0; St <= vs; St++) | |
| for (let tt = 0; tt <= Tt; tt++) | |
| $t.drawImage(z, yt * St, Q * tt, yt, Q, 0, 0, yt, Q); | |
| return { | |
| canvas: Vt.canvas, | |
| scaleX: ot.scale, | |
| scaleY: kt.scale, | |
| offsetX: u, | |
| offsetY: d | |
| }; | |
| } | |
| return { | |
| canvas: Y.canvas, | |
| scaleX: dt.scale, | |
| scaleY: gt.scale, | |
| offsetX: u, | |
| offsetY: d | |
| }; | |
| } | |
| getSizeAndScale(t, e, s) { | |
| const i = Math.max(td.MAX_PATTERN_SIZE, e); | |
| let r = Math.ceil(t * s); | |
| return r >= i ? r = i : s = r / t, { | |
| scale: s, | |
| size: r | |
| }; | |
| } | |
| clipBbox(t, e, s, i, r) { | |
| const a = i - e, l = r - s; | |
| t.ctx.rect(e, s, a, l), t.current.updateRectMinMax(Mt(t.ctx), [e, s, i, r]), t.clip(), t.endPath(); | |
| } | |
| setFillAndStrokeStyleToContext(t, e, s) { | |
| const i = t.ctx, r = t.current; | |
| switch (e) { | |
| case Bg.COLORED: | |
| const a = this.ctx; | |
| i.fillStyle = a.fillStyle, i.strokeStyle = a.strokeStyle, r.fillColor = a.fillStyle, r.strokeColor = a.strokeStyle; | |
| break; | |
| case Bg.UNCOLORED: | |
| const l = U.makeHexColor(s[0], s[1], s[2]); | |
| i.fillStyle = l, i.strokeStyle = l, r.fillColor = l, r.strokeColor = l; | |
| break; | |
| default: | |
| throw new RE(`Unsupported paint type: ${e}`); | |
| } | |
| } | |
| getPattern(t, e, s, i) { | |
| let r = s; | |
| i !== we.SHADING && (r = U.transform(r, e.baseTransform), this.matrix && (r = U.transform(r, this.matrix))); | |
| const a = this.createPatternCanvas(e); | |
| let l = new DOMMatrix(r); | |
| l = l.translate(a.offsetX, a.offsetY), l = l.scale(1 / a.scaleX, 1 / a.scaleY); | |
| const c = t.createPattern(a.canvas, "repeat"); | |
| return c.setTransform(l), c; | |
| } | |
| }; | |
| G(td, "MAX_PATTERN_SIZE", 3e3); | |
| let Df = td; | |
| function rx({ | |
| src: n, | |
| srcPos: t = 0, | |
| dest: e, | |
| width: s, | |
| height: i, | |
| nonBlackColor: r = 4294967295, | |
| inverseDecode: a = !1 | |
| }) { | |
| const l = Me.isLittleEndian ? 4278190080 : 255, [c, h] = a ? [r, l] : [l, r], u = s >> 3, d = s & 7, f = n.length; | |
| e = new Uint32Array(e.buffer); | |
| let g = 0; | |
| for (let m = 0; m < i; m++) { | |
| for (const _ = t + u; t < _; t++) { | |
| const A = t < f ? n[t] : 255; | |
| e[g++] = A & 128 ? h : c, e[g++] = A & 64 ? h : c, e[g++] = A & 32 ? h : c, e[g++] = A & 16 ? h : c, e[g++] = A & 8 ? h : c, e[g++] = A & 4 ? h : c, e[g++] = A & 2 ? h : c, e[g++] = A & 1 ? h : c; | |
| } | |
| if (d === 0) | |
| continue; | |
| const y = t < f ? n[t++] : 255; | |
| for (let _ = 0; _ < d; _++) | |
| e[g++] = y & 1 << 7 - _ ? h : c; | |
| } | |
| return { | |
| srcPos: t, | |
| destPos: g | |
| }; | |
| } | |
| const Hg = 16, Ug = 100, ax = 15, zg = 10, Vg = 1e3, Ue = 16; | |
| function ox(n, t) { | |
| if (n._removeMirroring) | |
| throw new Error("Context is already forwarding operations."); | |
| n.__originalSave = n.save, n.__originalRestore = n.restore, n.__originalRotate = n.rotate, n.__originalScale = n.scale, n.__originalTranslate = n.translate, n.__originalTransform = n.transform, n.__originalSetTransform = n.setTransform, n.__originalResetTransform = n.resetTransform, n.__originalClip = n.clip, n.__originalMoveTo = n.moveTo, n.__originalLineTo = n.lineTo, n.__originalBezierCurveTo = n.bezierCurveTo, n.__originalRect = n.rect, n.__originalClosePath = n.closePath, n.__originalBeginPath = n.beginPath, n._removeMirroring = () => { | |
| n.save = n.__originalSave, n.restore = n.__originalRestore, n.rotate = n.__originalRotate, n.scale = n.__originalScale, n.translate = n.__originalTranslate, n.transform = n.__originalTransform, n.setTransform = n.__originalSetTransform, n.resetTransform = n.__originalResetTransform, n.clip = n.__originalClip, n.moveTo = n.__originalMoveTo, n.lineTo = n.__originalLineTo, n.bezierCurveTo = n.__originalBezierCurveTo, n.rect = n.__originalRect, n.closePath = n.__originalClosePath, n.beginPath = n.__originalBeginPath, delete n._removeMirroring; | |
| }, n.save = function() { | |
| t.save(), this.__originalSave(); | |
| }, n.restore = function() { | |
| t.restore(), this.__originalRestore(); | |
| }, n.translate = function(s, i) { | |
| t.translate(s, i), this.__originalTranslate(s, i); | |
| }, n.scale = function(s, i) { | |
| t.scale(s, i), this.__originalScale(s, i); | |
| }, n.transform = function(s, i, r, a, l, c) { | |
| t.transform(s, i, r, a, l, c), this.__originalTransform(s, i, r, a, l, c); | |
| }, n.setTransform = function(s, i, r, a, l, c) { | |
| t.setTransform(s, i, r, a, l, c), this.__originalSetTransform(s, i, r, a, l, c); | |
| }, n.resetTransform = function() { | |
| t.resetTransform(), this.__originalResetTransform(); | |
| }, n.rotate = function(s) { | |
| t.rotate(s), this.__originalRotate(s); | |
| }, n.clip = function(s) { | |
| t.clip(s), this.__originalClip(s); | |
| }, n.moveTo = function(e, s) { | |
| t.moveTo(e, s), this.__originalMoveTo(e, s); | |
| }, n.lineTo = function(e, s) { | |
| t.lineTo(e, s), this.__originalLineTo(e, s); | |
| }, n.bezierCurveTo = function(e, s, i, r, a, l) { | |
| t.bezierCurveTo(e, s, i, r, a, l), this.__originalBezierCurveTo(e, s, i, r, a, l); | |
| }, n.rect = function(e, s, i, r) { | |
| t.rect(e, s, i, r), this.__originalRect(e, s, i, r); | |
| }, n.closePath = function() { | |
| t.closePath(), this.__originalClosePath(); | |
| }, n.beginPath = function() { | |
| t.beginPath(), this.__originalBeginPath(); | |
| }; | |
| } | |
| class lx { | |
| constructor(t) { | |
| this.canvasFactory = t, this.cache = /* @__PURE__ */ Object.create(null); | |
| } | |
| getCanvas(t, e, s) { | |
| let i; | |
| return this.cache[t] !== void 0 ? (i = this.cache[t], this.canvasFactory.reset(i, e, s)) : (i = this.canvasFactory.create(e, s), this.cache[t] = i), i; | |
| } | |
| delete(t) { | |
| delete this.cache[t]; | |
| } | |
| clear() { | |
| for (const t in this.cache) { | |
| const e = this.cache[t]; | |
| this.canvasFactory.destroy(e), delete this.cache[t]; | |
| } | |
| } | |
| } | |
| function Bh(n, t, e, s, i, r, a, l, c, h) { | |
| const [u, d, f, g, m, y] = Mt(n); | |
| if (d === 0 && f === 0) { | |
| const S = a * u + m, E = Math.round(S), x = l * g + y, T = Math.round(x), k = (a + c) * u + m, C = Math.abs(Math.round(k) - E) || 1, P = (l + h) * g + y, j = Math.abs(Math.round(P) - T) || 1; | |
| return n.setTransform(Math.sign(u), 0, 0, Math.sign(g), E, T), n.drawImage(t, e, s, i, r, 0, 0, C, j), n.setTransform(u, d, f, g, m, y), [C, j]; | |
| } | |
| if (u === 0 && g === 0) { | |
| const S = l * f + m, E = Math.round(S), x = a * d + y, T = Math.round(x), k = (l + h) * f + m, C = Math.abs(Math.round(k) - E) || 1, P = (a + c) * d + y, j = Math.abs(Math.round(P) - T) || 1; | |
| return n.setTransform(0, Math.sign(d), Math.sign(f), 0, E, T), n.drawImage(t, e, s, i, r, 0, 0, j, C), n.setTransform(u, d, f, g, m, y), [j, C]; | |
| } | |
| n.drawImage(t, e, s, i, r, a, l, c, h); | |
| const _ = Math.hypot(u, d), A = Math.hypot(f, g); | |
| return [_ * c, A * h]; | |
| } | |
| function cx(n) { | |
| const { | |
| width: t, | |
| height: e | |
| } = n; | |
| if (t > Vg || e > Vg) | |
| return null; | |
| const s = 1e3, i = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]), r = t + 1; | |
| let a = new Uint8Array(r * (e + 1)), l, c, h; | |
| const u = t + 7 & -8; | |
| let d = new Uint8Array(u * e), f = 0; | |
| for (const A of n.data) { | |
| let S = 128; | |
| for (; S > 0; ) | |
| d[f++] = A & S ? 0 : 255, S >>= 1; | |
| } | |
| let g = 0; | |
| for (f = 0, d[f] !== 0 && (a[0] = 1, ++g), c = 1; c < t; c++) | |
| d[f] !== d[f + 1] && (a[c] = d[f] ? 2 : 1, ++g), f++; | |
| for (d[f] !== 0 && (a[c] = 2, ++g), l = 1; l < e; l++) { | |
| f = l * u, h = l * r, d[f - u] !== d[f] && (a[h] = d[f] ? 1 : 8, ++g); | |
| let A = (d[f] ? 4 : 0) + (d[f - u] ? 8 : 0); | |
| for (c = 1; c < t; c++) | |
| A = (A >> 2) + (d[f + 1] ? 4 : 0) + (d[f - u + 1] ? 8 : 0), i[A] && (a[h + c] = i[A], ++g), f++; | |
| if (d[f - u] !== d[f] && (a[h + c] = d[f] ? 2 : 4, ++g), g > s) | |
| return null; | |
| } | |
| for (f = u * (e - 1), h = l * r, d[f] !== 0 && (a[h] = 8, ++g), c = 1; c < t; c++) | |
| d[f] !== d[f + 1] && (a[h + c] = d[f] ? 4 : 8, ++g), f++; | |
| if (d[f] !== 0 && (a[h + c] = 4, ++g), g > s) | |
| return null; | |
| const m = new Int32Array([0, r, -1, 0, -r, 0, 0, 0, 1]), y = new Path2D(); | |
| for (l = 0; g && l <= e; l++) { | |
| let A = l * r; | |
| const S = A + t; | |
| for (; A < S && !a[A]; ) | |
| A++; | |
| if (A === S) | |
| continue; | |
| y.moveTo(A % r, l); | |
| const E = A; | |
| let x = a[A]; | |
| do { | |
| const T = m[x]; | |
| do | |
| A += T; | |
| while (!a[A]); | |
| const k = a[A]; | |
| k !== 5 && k !== 10 ? (x = k, a[A] = 0) : (x = k & 51 * x >> 4, a[A] &= x >> 2 | x << 2), y.lineTo(A % r, A / r | 0), a[A] || --g; | |
| } while (E !== A); | |
| --l; | |
| } | |
| return d = null, a = null, function(A) { | |
| A.save(), A.scale(1 / t, -1 / e), A.translate(0, -e), A.fill(y), A.beginPath(), A.restore(); | |
| }; | |
| } | |
| class Gg { | |
| constructor(t, e) { | |
| this.alphaIsShape = !1, this.fontSize = 0, this.fontSizeScale = 1, this.textMatrix = $y, this.textMatrixScale = 1, this.fontMatrix = hf, this.leading = 0, this.x = 0, this.y = 0, this.lineX = 0, this.lineY = 0, this.charSpacing = 0, this.wordSpacing = 0, this.textHScale = 1, this.textRenderingMode = ge.FILL, this.textRise = 0, this.fillColor = "#000000", this.strokeColor = "#000000", this.patternFill = !1, this.patternStroke = !1, this.fillAlpha = 1, this.strokeAlpha = 1, this.lineWidth = 1, this.activeSMask = null, this.transferMaps = "none", this.startNewPathAndClipBox([0, 0, t, e]); | |
| } | |
| clone() { | |
| const t = Object.create(this); | |
| return t.clipBox = this.clipBox.slice(), t; | |
| } | |
| setCurrentPoint(t, e) { | |
| this.x = t, this.y = e; | |
| } | |
| updatePathMinMax(t, e, s) { | |
| [e, s] = U.applyTransform([e, s], t), this.minX = Math.min(this.minX, e), this.minY = Math.min(this.minY, s), this.maxX = Math.max(this.maxX, e), this.maxY = Math.max(this.maxY, s); | |
| } | |
| updateRectMinMax(t, e) { | |
| const s = U.applyTransform(e, t), i = U.applyTransform(e.slice(2), t), r = U.applyTransform([e[0], e[3]], t), a = U.applyTransform([e[2], e[1]], t); | |
| this.minX = Math.min(this.minX, s[0], i[0], r[0], a[0]), this.minY = Math.min(this.minY, s[1], i[1], r[1], a[1]), this.maxX = Math.max(this.maxX, s[0], i[0], r[0], a[0]), this.maxY = Math.max(this.maxY, s[1], i[1], r[1], a[1]); | |
| } | |
| updateScalingPathMinMax(t, e) { | |
| U.scaleMinMax(t, e), this.minX = Math.min(this.minX, e[0]), this.minY = Math.min(this.minY, e[1]), this.maxX = Math.max(this.maxX, e[2]), this.maxY = Math.max(this.maxY, e[3]); | |
| } | |
| updateCurvePathMinMax(t, e, s, i, r, a, l, c, h, u) { | |
| const d = U.bezierBoundingBox(e, s, i, r, a, l, c, h, u); | |
| u || this.updateRectMinMax(t, d); | |
| } | |
| getPathBoundingBox(t = we.FILL, e = null) { | |
| const s = [this.minX, this.minY, this.maxX, this.maxY]; | |
| if (t === we.STROKE) { | |
| e || Et("Stroke bounding box must include transform."); | |
| const i = U.singularValueDecompose2dScale(e), r = i[0] * this.lineWidth / 2, a = i[1] * this.lineWidth / 2; | |
| s[0] -= r, s[1] -= a, s[2] += r, s[3] += a; | |
| } | |
| return s; | |
| } | |
| updateClipFromPath() { | |
| const t = U.intersect(this.clipBox, this.getPathBoundingBox()); | |
| this.startNewPathAndClipBox(t || [0, 0, 0, 0]); | |
| } | |
| isEmptyClip() { | |
| return this.minX === 1 / 0; | |
| } | |
| startNewPathAndClipBox(t) { | |
| this.clipBox = t, this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = 0, this.maxY = 0; | |
| } | |
| getClippedPathBoundingBox(t = we.FILL, e = null) { | |
| return U.intersect(this.clipBox, this.getPathBoundingBox(t, e)); | |
| } | |
| } | |
| function qg(n, t) { | |
| if (t instanceof ImageData) { | |
| n.putImageData(t, 0, 0); | |
| return; | |
| } | |
| const e = t.height, s = t.width, i = e % Ue, r = (e - i) / Ue, a = i === 0 ? r : r + 1, l = n.createImageData(s, Ue); | |
| let c = 0, h; | |
| const u = t.data, d = l.data; | |
| let f, g, m, y; | |
| if (t.kind === Gh.GRAYSCALE_1BPP) { | |
| const _ = u.byteLength, A = new Uint32Array(d.buffer, 0, d.byteLength >> 2), S = A.length, E = s + 7 >> 3, x = 4294967295, T = Me.isLittleEndian ? 4278190080 : 255; | |
| for (f = 0; f < a; f++) { | |
| for (m = f < r ? Ue : i, h = 0, g = 0; g < m; g++) { | |
| const k = _ - c; | |
| let C = 0; | |
| const P = k > E ? s : k * 8 - 7, j = P & -8; | |
| let Z = 0, V = 0; | |
| for (; C < j; C += 8) | |
| V = u[c++], A[h++] = V & 128 ? x : T, A[h++] = V & 64 ? x : T, A[h++] = V & 32 ? x : T, A[h++] = V & 16 ? x : T, A[h++] = V & 8 ? x : T, A[h++] = V & 4 ? x : T, A[h++] = V & 2 ? x : T, A[h++] = V & 1 ? x : T; | |
| for (; C < P; C++) | |
| Z === 0 && (V = u[c++], Z = 128), A[h++] = V & Z ? x : T, Z >>= 1; | |
| } | |
| for (; h < S; ) | |
| A[h++] = 0; | |
| n.putImageData(l, 0, f * Ue); | |
| } | |
| } else if (t.kind === Gh.RGBA_32BPP) { | |
| for (g = 0, y = s * Ue * 4, f = 0; f < r; f++) | |
| d.set(u.subarray(c, c + y)), c += y, n.putImageData(l, 0, g), g += Ue; | |
| f < a && (y = s * i * 4, d.set(u.subarray(c, c + y)), n.putImageData(l, 0, g)); | |
| } else if (t.kind === Gh.RGB_24BPP) | |
| for (m = Ue, y = s * m, f = 0; f < a; f++) { | |
| for (f >= r && (m = i, y = s * m), h = 0, g = y; g--; ) | |
| d[h++] = u[c++], d[h++] = u[c++], d[h++] = u[c++], d[h++] = 255; | |
| n.putImageData(l, 0, f * Ue); | |
| } | |
| else | |
| throw new Error(`bad image kind: ${t.kind}`); | |
| } | |
| function Wg(n, t) { | |
| if (t.bitmap) { | |
| n.drawImage(t.bitmap, 0, 0); | |
| return; | |
| } | |
| const e = t.height, s = t.width, i = e % Ue, r = (e - i) / Ue, a = i === 0 ? r : r + 1, l = n.createImageData(s, Ue); | |
| let c = 0; | |
| const h = t.data, u = l.data; | |
| for (let d = 0; d < a; d++) { | |
| const f = d < r ? Ue : i; | |
| ({ | |
| srcPos: c | |
| } = rx({ | |
| src: h, | |
| srcPos: c, | |
| dest: u, | |
| width: s, | |
| height: f, | |
| nonBlackColor: 0 | |
| })), n.putImageData(l, 0, d * Ue); | |
| } | |
| } | |
| function rl(n, t) { | |
| const e = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font", "filter"]; | |
| for (const s of e) | |
| n[s] !== void 0 && (t[s] = n[s]); | |
| n.setLineDash !== void 0 && (t.setLineDash(n.getLineDash()), t.lineDashOffset = n.lineDashOffset); | |
| } | |
| function Hh(n) { | |
| if (n.strokeStyle = n.fillStyle = "#000000", n.fillRule = "nonzero", n.globalAlpha = 1, n.lineWidth = 1, n.lineCap = "butt", n.lineJoin = "miter", n.miterLimit = 10, n.globalCompositeOperation = "source-over", n.font = "10px sans-serif", n.setLineDash !== void 0 && (n.setLineDash([]), n.lineDashOffset = 0), !Se) { | |
| const { | |
| filter: t | |
| } = n; | |
| t !== "none" && t !== "" && (n.filter = "none"); | |
| } | |
| } | |
| function Xg(n, t) { | |
| if (t) | |
| return !0; | |
| const e = U.singularValueDecompose2dScale(n); | |
| e[0] = Math.fround(e[0]), e[1] = Math.fround(e[1]); | |
| const s = Math.fround((globalThis.devicePixelRatio || 1) * Hn.PDF_TO_CSS_UNITS); | |
| return e[0] <= s && e[1] <= s; | |
| } | |
| const hx = ["butt", "round", "square"], ux = ["miter", "round", "bevel"], dx = {}, Zg = {}; | |
| var Us, Ff, $f, jf; | |
| const Jp = class Jp { | |
| constructor(t, e, s, i, r, { | |
| optionalContentConfig: a, | |
| markedContentStack: l = null | |
| }, c, h) { | |
| b(this, Us); | |
| this.ctx = t, this.current = new Gg(this.ctx.canvas.width, this.ctx.canvas.height), this.stateStack = [], this.pendingClip = null, this.pendingEOFill = !1, this.res = null, this.xobjs = null, this.commonObjs = e, this.objs = s, this.canvasFactory = i, this.filterFactory = r, this.groupStack = [], this.processingType3 = null, this.baseTransform = null, this.baseTransformStack = [], this.groupLevel = 0, this.smaskStack = [], this.smaskCounter = 0, this.tempSMask = null, this.suspendedCtx = null, this.contentVisible = !0, this.markedContentStack = l || [], this.optionalContentConfig = a, this.cachedCanvases = new lx(this.canvasFactory), this.cachedPatterns = /* @__PURE__ */ new Map(), this.annotationCanvasMap = c, this.viewportScale = 1, this.outputScaleX = 1, this.outputScaleY = 1, this.pageColors = h, this._cachedScaleForStroking = [-1, 0], this._cachedGetSinglePixelWidth = null, this._cachedBitmapsMap = /* @__PURE__ */ new Map(); | |
| } | |
| getObject(t, e = null) { | |
| return typeof t == "string" ? t.startsWith("g_") ? this.commonObjs.get(t) : this.objs.get(t) : e; | |
| } | |
| beginDrawing({ | |
| transform: t, | |
| viewport: e, | |
| transparency: s = !1, | |
| background: i = null | |
| }) { | |
| const r = this.ctx.canvas.width, a = this.ctx.canvas.height, l = this.ctx.fillStyle; | |
| if (this.ctx.fillStyle = i || "#ffffff", this.ctx.fillRect(0, 0, r, a), this.ctx.fillStyle = l, s) { | |
| const c = this.cachedCanvases.getCanvas("transparent", r, a); | |
| this.compositeCtx = this.ctx, this.transparentCanvas = c.canvas, this.ctx = c.context, this.ctx.save(), this.ctx.transform(...Mt(this.compositeCtx)); | |
| } | |
| this.ctx.save(), Hh(this.ctx), t && (this.ctx.transform(...t), this.outputScaleX = t[0], this.outputScaleY = t[0]), this.ctx.transform(...e.transform), this.viewportScale = e.scale, this.baseTransform = Mt(this.ctx); | |
| } | |
| executeOperatorList(t, e, s, i) { | |
| const r = t.argsArray, a = t.fnArray; | |
| let l = e || 0; | |
| const c = r.length; | |
| if (c === l) | |
| return l; | |
| const h = c - l > zg && typeof s == "function", u = h ? Date.now() + ax : 0; | |
| let d = 0; | |
| const f = this.commonObjs, g = this.objs; | |
| let m; | |
| for (; ; ) { | |
| if (i !== void 0 && l === i.nextBreakPoint) | |
| return i.breakIt(l, s), l; | |
| if (m = a[l], m !== Ss.dependency) | |
| this[m].apply(this, r[l]); | |
| else | |
| for (const y of r[l]) { | |
| const _ = y.startsWith("g_") ? f : g; | |
| if (!_.has(y)) | |
| return _.get(y, s), l; | |
| } | |
| if (l++, l === c) | |
| return l; | |
| if (h && ++d > zg) { | |
| if (Date.now() > u) | |
| return s(), l; | |
| d = 0; | |
| } | |
| } | |
| } | |
| endDrawing() { | |
| v(this, Us, Ff).call(this), this.cachedCanvases.clear(), this.cachedPatterns.clear(); | |
| for (const t of this._cachedBitmapsMap.values()) { | |
| for (const e of t.values()) | |
| typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement && (e.width = e.height = 0); | |
| t.clear(); | |
| } | |
| this._cachedBitmapsMap.clear(), v(this, Us, $f).call(this); | |
| } | |
| _scaleImage(t, e) { | |
| const s = t.width ?? t.displayWidth, i = t.height ?? t.displayHeight; | |
| let r = Math.max(Math.hypot(e[0], e[1]), 1), a = Math.max(Math.hypot(e[2], e[3]), 1), l = s, c = i, h = "prescale1", u, d; | |
| for (; r > 2 && l > 1 || a > 2 && c > 1; ) { | |
| let f = l, g = c; | |
| r > 2 && l > 1 && (f = l >= 16384 ? Math.floor(l / 2) - 1 || 1 : Math.ceil(l / 2), r /= l / f), a > 2 && c > 1 && (g = c >= 16384 ? Math.floor(c / 2) - 1 || 1 : Math.ceil(c) / 2, a /= c / g), u = this.cachedCanvases.getCanvas(h, f, g), d = u.context, d.clearRect(0, 0, f, g), d.drawImage(t, 0, 0, l, c, 0, 0, f, g), t = u.canvas, l = f, c = g, h = h === "prescale1" ? "prescale2" : "prescale1"; | |
| } | |
| return { | |
| img: t, | |
| paintWidth: l, | |
| paintHeight: c | |
| }; | |
| } | |
| _createMaskCanvas(t) { | |
| const e = this.ctx, { | |
| width: s, | |
| height: i | |
| } = t, r = this.current.fillColor, a = this.current.patternFill, l = Mt(e); | |
| let c, h, u, d; | |
| if ((t.bitmap || t.data) && t.count > 1) { | |
| const P = t.bitmap || t.data.buffer; | |
| h = JSON.stringify(a ? l : [l.slice(0, 4), r]), c = this._cachedBitmapsMap.get(P), c || (c = /* @__PURE__ */ new Map(), this._cachedBitmapsMap.set(P, c)); | |
| const j = c.get(h); | |
| if (j && !a) { | |
| const Z = Math.round(Math.min(l[0], l[2]) + l[4]), V = Math.round(Math.min(l[1], l[3]) + l[5]); | |
| return { | |
| canvas: j, | |
| offsetX: Z, | |
| offsetY: V | |
| }; | |
| } | |
| u = j; | |
| } | |
| u || (d = this.cachedCanvases.getCanvas("maskCanvas", s, i), Wg(d.context, t)); | |
| let f = U.transform(l, [1 / s, 0, 0, -1 / i, 0, 0]); | |
| f = U.transform(f, [1, 0, 0, 1, 0, -i]); | |
| const [g, m, y, _] = U.getAxialAlignedBoundingBox([0, 0, s, i], f), A = Math.round(y - g) || 1, S = Math.round(_ - m) || 1, E = this.cachedCanvases.getCanvas("fillCanvas", A, S), x = E.context, T = g, k = m; | |
| x.translate(-T, -k), x.transform(...f), u || (u = this._scaleImage(d.canvas, Vs(x)), u = u.img, c && a && c.set(h, u)), x.imageSmoothingEnabled = Xg(Mt(x), t.interpolate), Bh(x, u, 0, 0, u.width, u.height, 0, 0, s, i), x.globalCompositeOperation = "source-in"; | |
| const C = U.transform(Vs(x), [1, 0, 0, 1, -T, -k]); | |
| return x.fillStyle = a ? r.getPattern(e, this, C, we.FILL) : r, x.fillRect(0, 0, s, i), c && !a && (this.cachedCanvases.delete("fillCanvas"), c.set(h, E.canvas)), { | |
| canvas: E.canvas, | |
| offsetX: Math.round(T), | |
| offsetY: Math.round(k) | |
| }; | |
| } | |
| setLineWidth(t) { | |
| t !== this.current.lineWidth && (this._cachedScaleForStroking[0] = -1), this.current.lineWidth = t, this.ctx.lineWidth = t; | |
| } | |
| setLineCap(t) { | |
| this.ctx.lineCap = hx[t]; | |
| } | |
| setLineJoin(t) { | |
| this.ctx.lineJoin = ux[t]; | |
| } | |
| setMiterLimit(t) { | |
| this.ctx.miterLimit = t; | |
| } | |
| setDash(t, e) { | |
| const s = this.ctx; | |
| s.setLineDash !== void 0 && (s.setLineDash(t), s.lineDashOffset = e); | |
| } | |
| setRenderingIntent(t) { | |
| } | |
| setFlatness(t) { | |
| } | |
| setGState(t) { | |
| for (const [e, s] of t) | |
| switch (e) { | |
| case "LW": | |
| this.setLineWidth(s); | |
| break; | |
| case "LC": | |
| this.setLineCap(s); | |
| break; | |
| case "LJ": | |
| this.setLineJoin(s); | |
| break; | |
| case "ML": | |
| this.setMiterLimit(s); | |
| break; | |
| case "D": | |
| this.setDash(s[0], s[1]); | |
| break; | |
| case "RI": | |
| this.setRenderingIntent(s); | |
| break; | |
| case "FL": | |
| this.setFlatness(s); | |
| break; | |
| case "Font": | |
| this.setFont(s[0], s[1]); | |
| break; | |
| case "CA": | |
| this.current.strokeAlpha = s; | |
| break; | |
| case "ca": | |
| this.current.fillAlpha = s, this.ctx.globalAlpha = s; | |
| break; | |
| case "BM": | |
| this.ctx.globalCompositeOperation = s; | |
| break; | |
| case "SMask": | |
| this.current.activeSMask = s ? this.tempSMask : null, this.tempSMask = null, this.checkSMaskState(); | |
| break; | |
| case "TR": | |
| this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(s); | |
| break; | |
| } | |
| } | |
| get inSMaskMode() { | |
| return !!this.suspendedCtx; | |
| } | |
| checkSMaskState() { | |
| const t = this.inSMaskMode; | |
| this.current.activeSMask && !t ? this.beginSMaskMode() : !this.current.activeSMask && t && this.endSMaskMode(); | |
| } | |
| beginSMaskMode() { | |
| if (this.inSMaskMode) | |
| throw new Error("beginSMaskMode called while already in smask mode"); | |
| const t = this.ctx.canvas.width, e = this.ctx.canvas.height, s = "smaskGroupAt" + this.groupLevel, i = this.cachedCanvases.getCanvas(s, t, e); | |
| this.suspendedCtx = this.ctx, this.ctx = i.context; | |
| const r = this.ctx; | |
| r.setTransform(...Mt(this.suspendedCtx)), rl(this.suspendedCtx, r), ox(r, this.suspendedCtx), this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]); | |
| } | |
| endSMaskMode() { | |
| if (!this.inSMaskMode) | |
| throw new Error("endSMaskMode called while not in smask mode"); | |
| this.ctx._removeMirroring(), rl(this.ctx, this.suspendedCtx), this.ctx = this.suspendedCtx, this.suspendedCtx = null; | |
| } | |
| compose(t) { | |
| if (!this.current.activeSMask) | |
| return; | |
| t ? (t[0] = Math.floor(t[0]), t[1] = Math.floor(t[1]), t[2] = Math.ceil(t[2]), t[3] = Math.ceil(t[3])) : t = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height]; | |
| const e = this.current.activeSMask, s = this.suspendedCtx; | |
| this.composeSMask(s, e, this.ctx, t), this.ctx.save(), this.ctx.setTransform(1, 0, 0, 1, 0, 0), this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height), this.ctx.restore(); | |
| } | |
| composeSMask(t, e, s, i) { | |
| const r = i[0], a = i[1], l = i[2] - r, c = i[3] - a; | |
| l === 0 || c === 0 || (this.genericComposeSMask(e.context, s, l, c, e.subtype, e.backdrop, e.transferMap, r, a, e.offsetX, e.offsetY), t.save(), t.globalAlpha = 1, t.globalCompositeOperation = "source-over", t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(s.canvas, 0, 0), t.restore()); | |
| } | |
| genericComposeSMask(t, e, s, i, r, a, l, c, h, u, d) { | |
| let f = t.canvas, g = c - u, m = h - d; | |
| if (a) { | |
| const _ = U.makeHexColor(...a); | |
| if (g < 0 || m < 0 || g + s > f.width || m + i > f.height) { | |
| const A = this.cachedCanvases.getCanvas("maskExtension", s, i), S = A.context; | |
| S.drawImage(f, -g, -m), S.globalCompositeOperation = "destination-atop", S.fillStyle = _, S.fillRect(0, 0, s, i), S.globalCompositeOperation = "source-over", f = A.canvas, g = m = 0; | |
| } else { | |
| t.save(), t.globalAlpha = 1, t.setTransform(1, 0, 0, 1, 0, 0); | |
| const A = new Path2D(); | |
| A.rect(g, m, s, i), t.clip(A), t.globalCompositeOperation = "destination-atop", t.fillStyle = _, t.fillRect(g, m, s, i), t.restore(); | |
| } | |
| } | |
| e.save(), e.globalAlpha = 1, e.setTransform(1, 0, 0, 1, 0, 0), r === "Alpha" && l ? e.filter = this.filterFactory.addAlphaFilter(l) : r === "Luminosity" && (e.filter = this.filterFactory.addLuminosityFilter(l)); | |
| const y = new Path2D(); | |
| y.rect(c, h, s, i), e.clip(y), e.globalCompositeOperation = "destination-in", e.drawImage(f, g, m, s, i, c, h, s, i), e.restore(); | |
| } | |
| save() { | |
| this.inSMaskMode ? (rl(this.ctx, this.suspendedCtx), this.suspendedCtx.save()) : this.ctx.save(); | |
| const t = this.current; | |
| this.stateStack.push(t), this.current = t.clone(); | |
| } | |
| restore() { | |
| this.stateStack.length === 0 && this.inSMaskMode && this.endSMaskMode(), this.stateStack.length !== 0 && (this.current = this.stateStack.pop(), this.inSMaskMode ? (this.suspendedCtx.restore(), rl(this.suspendedCtx, this.ctx)) : this.ctx.restore(), this.checkSMaskState(), this.pendingClip = null, this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null); | |
| } | |
| transform(t, e, s, i, r, a) { | |
| this.ctx.transform(t, e, s, i, r, a), this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null; | |
| } | |
| constructPath(t, e, s) { | |
| const i = this.ctx, r = this.current; | |
| let a = r.x, l = r.y, c, h; | |
| const u = Mt(i), d = u[0] === 0 && u[3] === 0 || u[1] === 0 && u[2] === 0, f = d ? s.slice(0) : null; | |
| for (let g = 0, m = 0, y = t.length; g < y; g++) | |
| switch (t[g] | 0) { | |
| case Ss.rectangle: | |
| a = e[m++], l = e[m++]; | |
| const _ = e[m++], A = e[m++], S = a + _, E = l + A; | |
| i.moveTo(a, l), _ === 0 || A === 0 ? i.lineTo(S, E) : (i.lineTo(S, l), i.lineTo(S, E), i.lineTo(a, E)), d || r.updateRectMinMax(u, [a, l, S, E]), i.closePath(); | |
| break; | |
| case Ss.moveTo: | |
| a = e[m++], l = e[m++], i.moveTo(a, l), d || r.updatePathMinMax(u, a, l); | |
| break; | |
| case Ss.lineTo: | |
| a = e[m++], l = e[m++], i.lineTo(a, l), d || r.updatePathMinMax(u, a, l); | |
| break; | |
| case Ss.curveTo: | |
| c = a, h = l, a = e[m + 4], l = e[m + 5], i.bezierCurveTo(e[m], e[m + 1], e[m + 2], e[m + 3], a, l), r.updateCurvePathMinMax(u, c, h, e[m], e[m + 1], e[m + 2], e[m + 3], a, l, f), m += 6; | |
| break; | |
| case Ss.curveTo2: | |
| c = a, h = l, i.bezierCurveTo(a, l, e[m], e[m + 1], e[m + 2], e[m + 3]), r.updateCurvePathMinMax(u, c, h, a, l, e[m], e[m + 1], e[m + 2], e[m + 3], f), a = e[m + 2], l = e[m + 3], m += 4; | |
| break; | |
| case Ss.curveTo3: | |
| c = a, h = l, a = e[m + 2], l = e[m + 3], i.bezierCurveTo(e[m], e[m + 1], a, l, a, l), r.updateCurvePathMinMax(u, c, h, e[m], e[m + 1], a, l, a, l, f), m += 4; | |
| break; | |
| case Ss.closePath: | |
| i.closePath(); | |
| break; | |
| } | |
| d && r.updateScalingPathMinMax(u, f), r.setCurrentPoint(a, l); | |
| } | |
| closePath() { | |
| this.ctx.closePath(); | |
| } | |
| stroke(t = !0) { | |
| const e = this.ctx, s = this.current.strokeColor; | |
| e.globalAlpha = this.current.strokeAlpha, this.contentVisible && (typeof s == "object" && (s != null && s.getPattern) ? (e.save(), e.strokeStyle = s.getPattern(e, this, Vs(e), we.STROKE), this.rescaleAndStroke(!1), e.restore()) : this.rescaleAndStroke(!0)), t && this.consumePath(this.current.getClippedPathBoundingBox()), e.globalAlpha = this.current.fillAlpha; | |
| } | |
| closeStroke() { | |
| this.closePath(), this.stroke(); | |
| } | |
| fill(t = !0) { | |
| const e = this.ctx, s = this.current.fillColor, i = this.current.patternFill; | |
| let r = !1; | |
| i && (e.save(), e.fillStyle = s.getPattern(e, this, Vs(e), we.FILL), r = !0); | |
| const a = this.current.getClippedPathBoundingBox(); | |
| this.contentVisible && a !== null && (this.pendingEOFill ? (e.fill("evenodd"), this.pendingEOFill = !1) : e.fill()), r && e.restore(), t && this.consumePath(a); | |
| } | |
| eoFill() { | |
| this.pendingEOFill = !0, this.fill(); | |
| } | |
| fillStroke() { | |
| this.fill(!1), this.stroke(!1), this.consumePath(); | |
| } | |
| eoFillStroke() { | |
| this.pendingEOFill = !0, this.fillStroke(); | |
| } | |
| closeFillStroke() { | |
| this.closePath(), this.fillStroke(); | |
| } | |
| closeEOFillStroke() { | |
| this.pendingEOFill = !0, this.closePath(), this.fillStroke(); | |
| } | |
| endPath() { | |
| this.consumePath(); | |
| } | |
| clip() { | |
| this.pendingClip = dx; | |
| } | |
| eoClip() { | |
| this.pendingClip = Zg; | |
| } | |
| beginText() { | |
| this.current.textMatrix = $y, this.current.textMatrixScale = 1, this.current.x = this.current.lineX = 0, this.current.y = this.current.lineY = 0; | |
| } | |
| endText() { | |
| const t = this.pendingTextPaths, e = this.ctx; | |
| if (t === void 0) { | |
| e.beginPath(); | |
| return; | |
| } | |
| const s = new Path2D(), i = e.getTransform().invertSelf(); | |
| for (const { | |
| transform: r, | |
| x: a, | |
| y: l, | |
| fontSize: c, | |
| path: h | |
| } of t) | |
| s.addPath(h, new DOMMatrix(r).preMultiplySelf(i).translate(a, l).scale(c, -c)); | |
| e.clip(s), e.beginPath(), delete this.pendingTextPaths; | |
| } | |
| setCharSpacing(t) { | |
| this.current.charSpacing = t; | |
| } | |
| setWordSpacing(t) { | |
| this.current.wordSpacing = t; | |
| } | |
| setHScale(t) { | |
| this.current.textHScale = t / 100; | |
| } | |
| setLeading(t) { | |
| this.current.leading = -t; | |
| } | |
| setFont(t, e) { | |
| var u; | |
| const s = this.commonObjs.get(t), i = this.current; | |
| if (!s) | |
| throw new Error(`Can't find font for ${t}`); | |
| if (i.fontMatrix = s.fontMatrix || hf, (i.fontMatrix[0] === 0 || i.fontMatrix[3] === 0) && st("Invalid font matrix for font " + t), e < 0 ? (e = -e, i.fontDirection = -1) : i.fontDirection = 1, this.current.font = s, this.current.fontSize = e, s.isType3Font) | |
| return; | |
| const r = s.loadedName || "sans-serif", a = ((u = s.systemFontInfo) == null ? void 0 : u.css) || `"${r}", ${s.fallbackName}`; | |
| let l = "normal"; | |
| s.black ? l = "900" : s.bold && (l = "bold"); | |
| const c = s.italic ? "italic" : "normal"; | |
| let h = e; | |
| e < Hg ? h = Hg : e > Ug && (h = Ug), this.current.fontSizeScale = e / h, this.ctx.font = `${c} ${l} ${h}px ${a}`; | |
| } | |
| setTextRenderingMode(t) { | |
| this.current.textRenderingMode = t; | |
| } | |
| setTextRise(t) { | |
| this.current.textRise = t; | |
| } | |
| moveText(t, e) { | |
| this.current.x = this.current.lineX += t, this.current.y = this.current.lineY += e; | |
| } | |
| setLeadingMoveText(t, e) { | |
| this.setLeading(-e), this.moveText(t, e); | |
| } | |
| setTextMatrix(t, e, s, i, r, a) { | |
| this.current.textMatrix = [t, e, s, i, r, a], this.current.textMatrixScale = Math.hypot(t, e), this.current.x = this.current.lineX = 0, this.current.y = this.current.lineY = 0; | |
| } | |
| nextLine() { | |
| this.moveText(0, this.current.leading); | |
| } | |
| paintChar(t, e, s, i, r) { | |
| const a = this.ctx, l = this.current, c = l.font, h = l.textRenderingMode, u = l.fontSize / l.fontSizeScale, d = h & ge.FILL_STROKE_MASK, f = !!(h & ge.ADD_TO_PATH_FLAG), g = l.patternFill && !c.missingFile, m = l.patternStroke && !c.missingFile; | |
| let y; | |
| if ((c.disableFontFace || f || g || m) && (y = c.getPathGenerator(this.commonObjs, t)), c.disableFontFace || g || m) { | |
| if (a.save(), a.translate(e, s), a.scale(u, -u), d === ge.FILL || d === ge.FILL_STROKE) | |
| if (i) { | |
| const _ = a.getTransform(); | |
| a.setTransform(...i), a.fill(v(this, Us, jf).call(this, y, _, i)); | |
| } else | |
| a.fill(y); | |
| if (d === ge.STROKE || d === ge.FILL_STROKE) | |
| if (r) { | |
| const _ = a.getTransform(); | |
| a.setTransform(...r), a.stroke(v(this, Us, jf).call(this, y, _, r)); | |
| } else | |
| a.lineWidth /= u, a.stroke(y); | |
| a.restore(); | |
| } else | |
| (d === ge.FILL || d === ge.FILL_STROKE) && a.fillText(t, e, s), (d === ge.STROKE || d === ge.FILL_STROKE) && a.strokeText(t, e, s); | |
| f && (this.pendingTextPaths || (this.pendingTextPaths = [])).push({ | |
| transform: Mt(a), | |
| x: e, | |
| y: s, | |
| fontSize: u, | |
| path: y | |
| }); | |
| } | |
| get isFontSubpixelAAEnabled() { | |
| const { | |
| context: t | |
| } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10); | |
| t.scale(1.5, 1), t.fillText("I", 0, 10); | |
| const e = t.getImageData(0, 0, 10, 10).data; | |
| let s = !1; | |
| for (let i = 3; i < e.length; i += 4) | |
| if (e[i] > 0 && e[i] < 255) { | |
| s = !0; | |
| break; | |
| } | |
| return at(this, "isFontSubpixelAAEnabled", s); | |
| } | |
| showText(t) { | |
| const e = this.current, s = e.font; | |
| if (s.isType3Font) | |
| return this.showType3Text(t); | |
| const i = e.fontSize; | |
| if (i === 0) | |
| return; | |
| const r = this.ctx, a = e.fontSizeScale, l = e.charSpacing, c = e.wordSpacing, h = e.fontDirection, u = e.textHScale * h, d = t.length, f = s.vertical, g = f ? 1 : -1, m = s.defaultVMetrics, y = i * e.fontMatrix[0], _ = e.textRenderingMode === ge.FILL && !s.disableFontFace && !e.patternFill; | |
| r.save(), r.transform(...e.textMatrix), r.translate(e.x, e.y + e.textRise), h > 0 ? r.scale(u, -1) : r.scale(u, 1); | |
| let A, S; | |
| if (e.patternFill) { | |
| r.save(); | |
| const C = e.fillColor.getPattern(r, this, Vs(r), we.FILL); | |
| A = Mt(r), r.restore(), r.fillStyle = C; | |
| } | |
| if (e.patternStroke) { | |
| r.save(); | |
| const C = e.strokeColor.getPattern(r, this, Vs(r), we.STROKE); | |
| S = Mt(r), r.restore(), r.strokeStyle = C; | |
| } | |
| let E = e.lineWidth; | |
| const x = e.textMatrixScale; | |
| if (x === 0 || E === 0) { | |
| const C = e.textRenderingMode & ge.FILL_STROKE_MASK; | |
| (C === ge.STROKE || C === ge.FILL_STROKE) && (E = this.getSinglePixelWidth()); | |
| } else | |
| E /= x; | |
| if (a !== 1 && (r.scale(a, a), E /= a), r.lineWidth = E, s.isInvalidPDFjsFont) { | |
| const C = []; | |
| let P = 0; | |
| for (const j of t) | |
| C.push(j.unicode), P += j.width; | |
| r.fillText(C.join(""), 0, 0), e.x += P * y * u, r.restore(), this.compose(); | |
| return; | |
| } | |
| let T = 0, k; | |
| for (k = 0; k < d; ++k) { | |
| const C = t[k]; | |
| if (typeof C == "number") { | |
| T += g * C * i / 1e3; | |
| continue; | |
| } | |
| let P = !1; | |
| const j = (C.isSpace ? c : 0) + l, Z = C.fontChar, V = C.accent; | |
| let dt, gt, Y = C.width; | |
| if (f) { | |
| const M = C.vmetric || m, z = -(C.vmetric ? M[1] : Y * 0.5) * y, ot = M[2] * y; | |
| Y = M ? -M[0] : Y, dt = z / a, gt = (T + ot) / a; | |
| } else | |
| dt = T / a, gt = 0; | |
| if (s.remeasure && Y > 0) { | |
| const M = r.measureText(Z).width * 1e3 / i * a; | |
| if (Y < M && this.isFontSubpixelAAEnabled) { | |
| const z = Y / M; | |
| P = !0, r.save(), r.scale(z, 1), dt /= z; | |
| } else Y !== M && (dt += (Y - M) / 2e3 * i / a); | |
| } | |
| if (this.contentVisible && (C.isInFont || s.missingFile)) { | |
| if (_ && !V) | |
| r.fillText(Z, dt, gt); | |
| else if (this.paintChar(Z, dt, gt, A, S), V) { | |
| const M = dt + i * V.offset.x / a, z = gt - i * V.offset.y / a; | |
| this.paintChar(V.fontChar, M, z, A, S); | |
| } | |
| } | |
| const xt = f ? Y * y - j * h : Y * y + j * h; | |
| T += xt, P && r.restore(); | |
| } | |
| f ? e.y -= T : e.x += T * u, r.restore(), this.compose(); | |
| } | |
| showType3Text(t) { | |
| const e = this.ctx, s = this.current, i = s.font, r = s.fontSize, a = s.fontDirection, l = i.vertical ? 1 : -1, c = s.charSpacing, h = s.wordSpacing, u = s.textHScale * a, d = s.fontMatrix || hf, f = t.length, g = s.textRenderingMode === ge.INVISIBLE; | |
| let m, y, _, A; | |
| if (!(g || r === 0)) { | |
| for (this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null, e.save(), e.transform(...s.textMatrix), e.translate(s.x, s.y), e.scale(u, a), m = 0; m < f; ++m) { | |
| if (y = t[m], typeof y == "number") { | |
| A = l * y * r / 1e3, this.ctx.translate(A, 0), s.x += A * u; | |
| continue; | |
| } | |
| const S = (y.isSpace ? h : 0) + c, E = i.charProcOperatorList[y.operatorListId]; | |
| if (!E) { | |
| st(`Type3 character "${y.operatorListId}" is not available.`); | |
| continue; | |
| } | |
| this.contentVisible && (this.processingType3 = y, this.save(), e.scale(r, r), e.transform(...d), this.executeOperatorList(E), this.restore()), _ = U.applyTransform([y.width, 0], d)[0] * r + S, e.translate(_, 0), s.x += _ * u; | |
| } | |
| e.restore(), this.processingType3 = null; | |
| } | |
| } | |
| setCharWidth(t, e) { | |
| } | |
| setCharWidthAndBounds(t, e, s, i, r, a) { | |
| this.ctx.rect(s, i, r - s, a - i), this.ctx.clip(), this.endPath(); | |
| } | |
| getColorN_Pattern(t) { | |
| let e; | |
| if (t[0] === "TilingPattern") { | |
| const s = t[1], i = this.baseTransform || Mt(this.ctx), r = { | |
| createCanvasGraphics: (a) => new Jp(a, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, { | |
| optionalContentConfig: this.optionalContentConfig, | |
| markedContentStack: this.markedContentStack | |
| }) | |
| }; | |
| e = new Df(t, s, this.ctx, r, i); | |
| } else | |
| e = this._getPattern(t[1], t[2]); | |
| return e; | |
| } | |
| setStrokeColorN() { | |
| this.current.strokeColor = this.getColorN_Pattern(arguments), this.current.patternStroke = !0; | |
| } | |
| setFillColorN() { | |
| this.current.fillColor = this.getColorN_Pattern(arguments), this.current.patternFill = !0; | |
| } | |
| setStrokeRGBColor(t, e, s) { | |
| this.ctx.strokeStyle = this.current.strokeColor = U.makeHexColor(t, e, s), this.current.patternStroke = !1; | |
| } | |
| setStrokeTransparent() { | |
| this.ctx.strokeStyle = this.current.strokeColor = "transparent", this.current.patternStroke = !1; | |
| } | |
| setFillRGBColor(t, e, s) { | |
| this.ctx.fillStyle = this.current.fillColor = U.makeHexColor(t, e, s), this.current.patternFill = !1; | |
| } | |
| setFillTransparent() { | |
| this.ctx.fillStyle = this.current.fillColor = "transparent", this.current.patternFill = !1; | |
| } | |
| _getPattern(t, e = null) { | |
| let s; | |
| return this.cachedPatterns.has(t) ? s = this.cachedPatterns.get(t) : (s = nx(this.getObject(t)), this.cachedPatterns.set(t, s)), e && (s.matrix = e), s; | |
| } | |
| shadingFill(t) { | |
| if (!this.contentVisible) | |
| return; | |
| const e = this.ctx; | |
| this.save(); | |
| const s = this._getPattern(t); | |
| e.fillStyle = s.getPattern(e, this, Vs(e), we.SHADING); | |
| const i = Vs(e); | |
| if (i) { | |
| const { | |
| width: r, | |
| height: a | |
| } = e.canvas, [l, c, h, u] = U.getAxialAlignedBoundingBox([0, 0, r, a], i); | |
| this.ctx.fillRect(l, c, h - l, u - c); | |
| } else | |
| this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10); | |
| this.compose(this.current.getClippedPathBoundingBox()), this.restore(); | |
| } | |
| beginInlineImage() { | |
| Et("Should not call beginInlineImage"); | |
| } | |
| beginImageData() { | |
| Et("Should not call beginImageData"); | |
| } | |
| paintFormXObjectBegin(t, e) { | |
| if (this.contentVisible && (this.save(), this.baseTransformStack.push(this.baseTransform), t && this.transform(...t), this.baseTransform = Mt(this.ctx), e)) { | |
| const s = e[2] - e[0], i = e[3] - e[1]; | |
| this.ctx.rect(e[0], e[1], s, i), this.current.updateRectMinMax(Mt(this.ctx), e), this.clip(), this.endPath(); | |
| } | |
| } | |
| paintFormXObjectEnd() { | |
| this.contentVisible && (this.restore(), this.baseTransform = this.baseTransformStack.pop()); | |
| } | |
| beginGroup(t) { | |
| if (!this.contentVisible) | |
| return; | |
| this.save(), this.inSMaskMode && (this.endSMaskMode(), this.current.activeSMask = null); | |
| const e = this.ctx; | |
| t.isolated || vd("TODO: Support non-isolated groups."), t.knockout && st("Knockout groups not supported."); | |
| const s = Mt(e); | |
| if (t.matrix && e.transform(...t.matrix), !t.bbox) | |
| throw new Error("Bounding box is required."); | |
| let i = U.getAxialAlignedBoundingBox(t.bbox, Mt(e)); | |
| const r = [0, 0, e.canvas.width, e.canvas.height]; | |
| i = U.intersect(i, r) || [0, 0, 0, 0]; | |
| const a = Math.floor(i[0]), l = Math.floor(i[1]), c = Math.max(Math.ceil(i[2]) - a, 1), h = Math.max(Math.ceil(i[3]) - l, 1); | |
| this.current.startNewPathAndClipBox([0, 0, c, h]); | |
| let u = "groupAt" + this.groupLevel; | |
| t.smask && (u += "_smask_" + this.smaskCounter++ % 2); | |
| const d = this.cachedCanvases.getCanvas(u, c, h), f = d.context; | |
| f.translate(-a, -l), f.transform(...s), t.smask ? this.smaskStack.push({ | |
| canvas: d.canvas, | |
| context: f, | |
| offsetX: a, | |
| offsetY: l, | |
| subtype: t.smask.subtype, | |
| backdrop: t.smask.backdrop, | |
| transferMap: t.smask.transferMap || null, | |
| startTransformInverse: null | |
| }) : (e.setTransform(1, 0, 0, 1, 0, 0), e.translate(a, l), e.save()), rl(e, f), this.ctx = f, this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]), this.groupStack.push(e), this.groupLevel++; | |
| } | |
| endGroup(t) { | |
| if (!this.contentVisible) | |
| return; | |
| this.groupLevel--; | |
| const e = this.ctx, s = this.groupStack.pop(); | |
| if (this.ctx = s, this.ctx.imageSmoothingEnabled = !1, t.smask) | |
| this.tempSMask = this.smaskStack.pop(), this.restore(); | |
| else { | |
| this.ctx.restore(); | |
| const i = Mt(this.ctx); | |
| this.restore(), this.ctx.save(), this.ctx.setTransform(...i); | |
| const r = U.getAxialAlignedBoundingBox([0, 0, e.canvas.width, e.canvas.height], i); | |
| this.ctx.drawImage(e.canvas, 0, 0), this.ctx.restore(), this.compose(r); | |
| } | |
| } | |
| beginAnnotation(t, e, s, i, r) { | |
| if (v(this, Us, Ff).call(this), Hh(this.ctx), this.ctx.save(), this.save(), this.baseTransform && this.ctx.setTransform(...this.baseTransform), e) { | |
| const a = e[2] - e[0], l = e[3] - e[1]; | |
| if (r && this.annotationCanvasMap) { | |
| s = s.slice(), s[4] -= e[0], s[5] -= e[1], e = e.slice(), e[0] = e[1] = 0, e[2] = a, e[3] = l; | |
| const [c, h] = U.singularValueDecompose2dScale(Mt(this.ctx)), { | |
| viewportScale: u | |
| } = this, d = Math.ceil(a * this.outputScaleX * u), f = Math.ceil(l * this.outputScaleY * u); | |
| this.annotationCanvas = this.canvasFactory.create(d, f); | |
| const { | |
| canvas: g, | |
| context: m | |
| } = this.annotationCanvas; | |
| this.annotationCanvasMap.set(t, g), this.annotationCanvas.savedCtx = this.ctx, this.ctx = m, this.ctx.save(), this.ctx.setTransform(c, 0, 0, -h, 0, l * h), Hh(this.ctx); | |
| } else | |
| Hh(this.ctx), this.endPath(), this.ctx.rect(e[0], e[1], a, l), this.ctx.clip(), this.ctx.beginPath(); | |
| } | |
| this.current = new Gg(this.ctx.canvas.width, this.ctx.canvas.height), this.transform(...s), this.transform(...i); | |
| } | |
| endAnnotation() { | |
| this.annotationCanvas && (this.ctx.restore(), v(this, Us, $f).call(this), this.ctx = this.annotationCanvas.savedCtx, delete this.annotationCanvas.savedCtx, delete this.annotationCanvas); | |
| } | |
| paintImageMaskXObject(t) { | |
| if (!this.contentVisible) | |
| return; | |
| const e = t.count; | |
| t = this.getObject(t.data, t), t.count = e; | |
| const s = this.ctx, i = this.processingType3; | |
| if (i && (i.compiled === void 0 && (i.compiled = cx(t)), i.compiled)) { | |
| i.compiled(s); | |
| return; | |
| } | |
| const r = this._createMaskCanvas(t), a = r.canvas; | |
| s.save(), s.setTransform(1, 0, 0, 1, 0, 0), s.drawImage(a, r.offsetX, r.offsetY), s.restore(), this.compose(); | |
| } | |
| paintImageMaskXObjectRepeat(t, e, s = 0, i = 0, r, a) { | |
| if (!this.contentVisible) | |
| return; | |
| t = this.getObject(t.data, t); | |
| const l = this.ctx; | |
| l.save(); | |
| const c = Mt(l); | |
| l.transform(e, s, i, r, 0, 0); | |
| const h = this._createMaskCanvas(t); | |
| l.setTransform(1, 0, 0, 1, h.offsetX - c[4], h.offsetY - c[5]); | |
| for (let u = 0, d = a.length; u < d; u += 2) { | |
| const f = U.transform(c, [e, s, i, r, a[u], a[u + 1]]), [g, m] = U.applyTransform([0, 0], f); | |
| l.drawImage(h.canvas, g, m); | |
| } | |
| l.restore(), this.compose(); | |
| } | |
| paintImageMaskXObjectGroup(t) { | |
| if (!this.contentVisible) | |
| return; | |
| const e = this.ctx, s = this.current.fillColor, i = this.current.patternFill; | |
| for (const r of t) { | |
| const { | |
| data: a, | |
| width: l, | |
| height: c, | |
| transform: h | |
| } = r, u = this.cachedCanvases.getCanvas("maskCanvas", l, c), d = u.context; | |
| d.save(); | |
| const f = this.getObject(a, r); | |
| Wg(d, f), d.globalCompositeOperation = "source-in", d.fillStyle = i ? s.getPattern(d, this, Vs(e), we.FILL) : s, d.fillRect(0, 0, l, c), d.restore(), e.save(), e.transform(...h), e.scale(1, -1), Bh(e, u.canvas, 0, 0, l, c, 0, -1, 1, 1), e.restore(); | |
| } | |
| this.compose(); | |
| } | |
| paintImageXObject(t) { | |
| if (!this.contentVisible) | |
| return; | |
| const e = this.getObject(t); | |
| if (!e) { | |
| st("Dependent image isn't ready yet"); | |
| return; | |
| } | |
| this.paintInlineImageXObject(e); | |
| } | |
| paintImageXObjectRepeat(t, e, s, i) { | |
| if (!this.contentVisible) | |
| return; | |
| const r = this.getObject(t); | |
| if (!r) { | |
| st("Dependent image isn't ready yet"); | |
| return; | |
| } | |
| const a = r.width, l = r.height, c = []; | |
| for (let h = 0, u = i.length; h < u; h += 2) | |
| c.push({ | |
| transform: [e, 0, 0, s, i[h], i[h + 1]], | |
| x: 0, | |
| y: 0, | |
| w: a, | |
| h: l | |
| }); | |
| this.paintInlineImageXObjectGroup(r, c); | |
| } | |
| applyTransferMapsToCanvas(t) { | |
| return this.current.transferMaps !== "none" && (t.filter = this.current.transferMaps, t.drawImage(t.canvas, 0, 0), t.filter = "none"), t.canvas; | |
| } | |
| applyTransferMapsToBitmap(t) { | |
| if (this.current.transferMaps === "none") | |
| return t.bitmap; | |
| const { | |
| bitmap: e, | |
| width: s, | |
| height: i | |
| } = t, r = this.cachedCanvases.getCanvas("inlineImage", s, i), a = r.context; | |
| return a.filter = this.current.transferMaps, a.drawImage(e, 0, 0), a.filter = "none", r.canvas; | |
| } | |
| paintInlineImageXObject(t) { | |
| if (!this.contentVisible) | |
| return; | |
| const e = t.width, s = t.height, i = this.ctx; | |
| if (this.save(), !Se) { | |
| const { | |
| filter: l | |
| } = i; | |
| l !== "none" && l !== "" && (i.filter = "none"); | |
| } | |
| i.scale(1 / e, -1 / s); | |
| let r; | |
| if (t.bitmap) | |
| r = this.applyTransferMapsToBitmap(t); | |
| else if (typeof HTMLElement == "function" && t instanceof HTMLElement || !t.data) | |
| r = t; | |
| else { | |
| const c = this.cachedCanvases.getCanvas("inlineImage", e, s).context; | |
| qg(c, t), r = this.applyTransferMapsToCanvas(c); | |
| } | |
| const a = this._scaleImage(r, Vs(i)); | |
| i.imageSmoothingEnabled = Xg(Mt(i), t.interpolate), Bh(i, a.img, 0, 0, a.paintWidth, a.paintHeight, 0, -s, e, s), this.compose(), this.restore(); | |
| } | |
| paintInlineImageXObjectGroup(t, e) { | |
| if (!this.contentVisible) | |
| return; | |
| const s = this.ctx; | |
| let i; | |
| if (t.bitmap) | |
| i = t.bitmap; | |
| else { | |
| const r = t.width, a = t.height, c = this.cachedCanvases.getCanvas("inlineImage", r, a).context; | |
| qg(c, t), i = this.applyTransferMapsToCanvas(c); | |
| } | |
| for (const r of e) | |
| s.save(), s.transform(...r.transform), s.scale(1, -1), Bh(s, i, r.x, r.y, r.w, r.h, 0, -1, 1, 1), s.restore(); | |
| this.compose(); | |
| } | |
| paintSolidColorImageMask() { | |
| this.contentVisible && (this.ctx.fillRect(0, 0, 1, 1), this.compose()); | |
| } | |
| markPoint(t) { | |
| } | |
| markPointProps(t, e) { | |
| } | |
| beginMarkedContent(t) { | |
| this.markedContentStack.push({ | |
| visible: !0 | |
| }); | |
| } | |
| beginMarkedContentProps(t, e) { | |
| t === "OC" ? this.markedContentStack.push({ | |
| visible: this.optionalContentConfig.isVisible(e) | |
| }) : this.markedContentStack.push({ | |
| visible: !0 | |
| }), this.contentVisible = this.isContentVisible(); | |
| } | |
| endMarkedContent() { | |
| this.markedContentStack.pop(), this.contentVisible = this.isContentVisible(); | |
| } | |
| beginCompat() { | |
| } | |
| endCompat() { | |
| } | |
| consumePath(t) { | |
| const e = this.current.isEmptyClip(); | |
| this.pendingClip && this.current.updateClipFromPath(), this.pendingClip || this.compose(t); | |
| const s = this.ctx; | |
| this.pendingClip && (e || (this.pendingClip === Zg ? s.clip("evenodd") : s.clip()), this.pendingClip = null), this.current.startNewPathAndClipBox(this.current.clipBox), s.beginPath(); | |
| } | |
| getSinglePixelWidth() { | |
| if (!this._cachedGetSinglePixelWidth) { | |
| const t = Mt(this.ctx); | |
| if (t[1] === 0 && t[2] === 0) | |
| this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(t[0]), Math.abs(t[3])); | |
| else { | |
| const e = Math.abs(t[0] * t[3] - t[2] * t[1]), s = Math.hypot(t[0], t[2]), i = Math.hypot(t[1], t[3]); | |
| this._cachedGetSinglePixelWidth = Math.max(s, i) / e; | |
| } | |
| } | |
| return this._cachedGetSinglePixelWidth; | |
| } | |
| getScaleForStroking() { | |
| if (this._cachedScaleForStroking[0] === -1) { | |
| const { | |
| lineWidth: t | |
| } = this.current, { | |
| a: e, | |
| b: s, | |
| c: i, | |
| d: r | |
| } = this.ctx.getTransform(); | |
| let a, l; | |
| if (s === 0 && i === 0) { | |
| const c = Math.abs(e), h = Math.abs(r); | |
| if (c === h) | |
| if (t === 0) | |
| a = l = 1 / c; | |
| else { | |
| const u = c * t; | |
| a = l = u < 1 ? 1 / u : 1; | |
| } | |
| else if (t === 0) | |
| a = 1 / c, l = 1 / h; | |
| else { | |
| const u = c * t, d = h * t; | |
| a = u < 1 ? 1 / u : 1, l = d < 1 ? 1 / d : 1; | |
| } | |
| } else { | |
| const c = Math.abs(e * r - s * i), h = Math.hypot(e, s), u = Math.hypot(i, r); | |
| if (t === 0) | |
| a = u / c, l = h / c; | |
| else { | |
| const d = t * c; | |
| a = u > d ? u / d : 1, l = h > d ? h / d : 1; | |
| } | |
| } | |
| this._cachedScaleForStroking[0] = a, this._cachedScaleForStroking[1] = l; | |
| } | |
| return this._cachedScaleForStroking; | |
| } | |
| rescaleAndStroke(t) { | |
| const { | |
| ctx: e | |
| } = this, { | |
| lineWidth: s | |
| } = this.current, [i, r] = this.getScaleForStroking(); | |
| if (e.lineWidth = s || 1, i === 1 && r === 1) { | |
| e.stroke(); | |
| return; | |
| } | |
| const a = e.getLineDash(); | |
| if (t && e.save(), e.scale(i, r), a.length > 0) { | |
| const l = Math.max(i, r); | |
| e.setLineDash(a.map((c) => c / l)), e.lineDashOffset /= l; | |
| } | |
| e.stroke(), t && e.restore(); | |
| } | |
| isContentVisible() { | |
| for (let t = this.markedContentStack.length - 1; t >= 0; t--) | |
| if (!this.markedContentStack[t].visible) | |
| return !1; | |
| return !0; | |
| } | |
| }; | |
| Us = new WeakSet(), Ff = function() { | |
| for (; this.stateStack.length || this.inSMaskMode; ) | |
| this.restore(); | |
| this.current.activeSMask = null, this.ctx.restore(), this.transparentCanvas && (this.ctx = this.compositeCtx, this.ctx.save(), this.ctx.setTransform(1, 0, 0, 1, 0, 0), this.ctx.drawImage(this.transparentCanvas, 0, 0), this.ctx.restore(), this.transparentCanvas = null); | |
| }, $f = function() { | |
| if (this.pageColors) { | |
| const t = this.filterFactory.addHCMFilter(this.pageColors.foreground, this.pageColors.background); | |
| if (t !== "none") { | |
| const e = this.ctx.filter; | |
| this.ctx.filter = t, this.ctx.drawImage(this.ctx.canvas, 0, 0), this.ctx.filter = e; | |
| } | |
| } | |
| }, jf = function(t, e, s) { | |
| const i = new Path2D(); | |
| return i.addPath(t, new DOMMatrix(s).invertSelf().multiplySelf(e)), i; | |
| }; | |
| let Oa = Jp; | |
| for (const n in Ss) | |
| Oa.prototype[n] !== void 0 && (Oa.prototype[Ss[n]] = Oa.prototype[n]); | |
| var Oc, Lc; | |
| class qi { | |
| static get workerPort() { | |
| return o(this, Oc); | |
| } | |
| static set workerPort(t) { | |
| if (!(typeof Worker < "u" && t instanceof Worker) && t !== null) | |
| throw new Error("Invalid `workerPort` type."); | |
| p(this, Oc, t); | |
| } | |
| static get workerSrc() { | |
| return o(this, Lc); | |
| } | |
| static set workerSrc(t) { | |
| if (typeof t != "string") | |
| throw new Error("Invalid `workerSrc` type."); | |
| p(this, Lc, t); | |
| } | |
| } | |
| Oc = new WeakMap(), Lc = new WeakMap(), b(qi, Oc, null), b(qi, Lc, ""); | |
| var Tr, Dc; | |
| class fx { | |
| constructor({ | |
| parsedData: t, | |
| rawData: e | |
| }) { | |
| b(this, Tr); | |
| b(this, Dc); | |
| p(this, Tr, t), p(this, Dc, e); | |
| } | |
| getRaw() { | |
| return o(this, Dc); | |
| } | |
| get(t) { | |
| return o(this, Tr).get(t) ?? null; | |
| } | |
| getAll() { | |
| return Bp(o(this, Tr)); | |
| } | |
| has(t) { | |
| return o(this, Tr).has(t); | |
| } | |
| } | |
| Tr = new WeakMap(), Dc = new WeakMap(); | |
| const Ta = Symbol("INTERNAL"); | |
| var Fc, $c, jc, Qa; | |
| class px { | |
| constructor(t, { | |
| name: e, | |
| intent: s, | |
| usage: i, | |
| rbGroups: r | |
| }) { | |
| b(this, Fc, !1); | |
| b(this, $c, !1); | |
| b(this, jc, !1); | |
| b(this, Qa, !0); | |
| p(this, Fc, !!(t & ss.DISPLAY)), p(this, $c, !!(t & ss.PRINT)), this.name = e, this.intent = s, this.usage = i, this.rbGroups = r; | |
| } | |
| get visible() { | |
| if (o(this, jc)) | |
| return o(this, Qa); | |
| if (!o(this, Qa)) | |
| return !1; | |
| const { | |
| print: t, | |
| view: e | |
| } = this.usage; | |
| return o(this, Fc) ? (e == null ? void 0 : e.viewState) !== "OFF" : o(this, $c) ? (t == null ? void 0 : t.printState) !== "OFF" : !0; | |
| } | |
| _setVisible(t, e, s = !1) { | |
| t !== Ta && Et("Internal method `_setVisible` called."), p(this, jc, s), p(this, Qa, e); | |
| } | |
| } | |
| Fc = new WeakMap(), $c = new WeakMap(), jc = new WeakMap(), Qa = new WeakMap(); | |
| var mn, vt, to, eo, Bc, Bf; | |
| class gx { | |
| constructor(t, e = ss.DISPLAY) { | |
| b(this, Bc); | |
| b(this, mn, null); | |
| b(this, vt, /* @__PURE__ */ new Map()); | |
| b(this, to, null); | |
| b(this, eo, null); | |
| if (this.renderingIntent = e, this.name = null, this.creator = null, t !== null) { | |
| this.name = t.name, this.creator = t.creator, p(this, eo, t.order); | |
| for (const s of t.groups) | |
| o(this, vt).set(s.id, new px(e, s)); | |
| if (t.baseState === "OFF") | |
| for (const s of o(this, vt).values()) | |
| s._setVisible(Ta, !1); | |
| for (const s of t.on) | |
| o(this, vt).get(s)._setVisible(Ta, !0); | |
| for (const s of t.off) | |
| o(this, vt).get(s)._setVisible(Ta, !1); | |
| p(this, to, this.getHash()); | |
| } | |
| } | |
| isVisible(t) { | |
| if (o(this, vt).size === 0) | |
| return !0; | |
| if (!t) | |
| return vd("Optional content group not defined."), !0; | |
| if (t.type === "OCG") | |
| return o(this, vt).has(t.id) ? o(this, vt).get(t.id).visible : (st(`Optional content group not found: ${t.id}`), !0); | |
| if (t.type === "OCMD") { | |
| if (t.expression) | |
| return v(this, Bc, Bf).call(this, t.expression); | |
| if (!t.policy || t.policy === "AnyOn") { | |
| for (const e of t.ids) { | |
| if (!o(this, vt).has(e)) | |
| return st(`Optional content group not found: ${e}`), !0; | |
| if (o(this, vt).get(e).visible) | |
| return !0; | |
| } | |
| return !1; | |
| } else if (t.policy === "AllOn") { | |
| for (const e of t.ids) { | |
| if (!o(this, vt).has(e)) | |
| return st(`Optional content group not found: ${e}`), !0; | |
| if (!o(this, vt).get(e).visible) | |
| return !1; | |
| } | |
| return !0; | |
| } else if (t.policy === "AnyOff") { | |
| for (const e of t.ids) { | |
| if (!o(this, vt).has(e)) | |
| return st(`Optional content group not found: ${e}`), !0; | |
| if (!o(this, vt).get(e).visible) | |
| return !0; | |
| } | |
| return !1; | |
| } else if (t.policy === "AllOff") { | |
| for (const e of t.ids) { | |
| if (!o(this, vt).has(e)) | |
| return st(`Optional content group not found: ${e}`), !0; | |
| if (o(this, vt).get(e).visible) | |
| return !1; | |
| } | |
| return !0; | |
| } | |
| return st(`Unknown optional content policy ${t.policy}.`), !0; | |
| } | |
| return st(`Unknown group type ${t.type}.`), !0; | |
| } | |
| setVisibility(t, e = !0, s = !0) { | |
| var r; | |
| const i = o(this, vt).get(t); | |
| if (!i) { | |
| st(`Optional content group not found: ${t}`); | |
| return; | |
| } | |
| if (s && e && i.rbGroups.length) | |
| for (const a of i.rbGroups) | |
| for (const l of a) | |
| l !== t && ((r = o(this, vt).get(l)) == null || r._setVisible(Ta, !1, !0)); | |
| i._setVisible(Ta, !!e, !0), p(this, mn, null); | |
| } | |
| setOCGState({ | |
| state: t, | |
| preserveRB: e | |
| }) { | |
| let s; | |
| for (const i of t) { | |
| switch (i) { | |
| case "ON": | |
| case "OFF": | |
| case "Toggle": | |
| s = i; | |
| continue; | |
| } | |
| const r = o(this, vt).get(i); | |
| if (r) | |
| switch (s) { | |
| case "ON": | |
| this.setVisibility(i, !0, e); | |
| break; | |
| case "OFF": | |
| this.setVisibility(i, !1, e); | |
| break; | |
| case "Toggle": | |
| this.setVisibility(i, !r.visible, e); | |
| break; | |
| } | |
| } | |
| p(this, mn, null); | |
| } | |
| get hasInitialVisibility() { | |
| return o(this, to) === null || this.getHash() === o(this, to); | |
| } | |
| getOrder() { | |
| return o(this, vt).size ? o(this, eo) ? o(this, eo).slice() : [...o(this, vt).keys()] : null; | |
| } | |
| getGroups() { | |
| return o(this, vt).size > 0 ? Bp(o(this, vt)) : null; | |
| } | |
| getGroup(t) { | |
| return o(this, vt).get(t) || null; | |
| } | |
| getHash() { | |
| if (o(this, mn) !== null) | |
| return o(this, mn); | |
| const t = new gb(); | |
| for (const [e, s] of o(this, vt)) | |
| t.update(`${e}:${s.visible}`); | |
| return p(this, mn, t.hexdigest()); | |
| } | |
| } | |
| mn = new WeakMap(), vt = new WeakMap(), to = new WeakMap(), eo = new WeakMap(), Bc = new WeakSet(), Bf = function(t) { | |
| const e = t.length; | |
| if (e < 2) | |
| return !0; | |
| const s = t[0]; | |
| for (let i = 1; i < e; i++) { | |
| const r = t[i]; | |
| let a; | |
| if (Array.isArray(r)) | |
| a = v(this, Bc, Bf).call(this, r); | |
| else if (o(this, vt).has(r)) | |
| a = o(this, vt).get(r).visible; | |
| else | |
| return st(`Optional content group not found: ${r}`), !0; | |
| switch (s) { | |
| case "And": | |
| if (!a) | |
| return !1; | |
| break; | |
| case "Or": | |
| if (a) | |
| return !0; | |
| break; | |
| case "Not": | |
| return !a; | |
| default: | |
| return !0; | |
| } | |
| } | |
| return s === "And"; | |
| }; | |
| class mx { | |
| constructor(t, { | |
| disableRange: e = !1, | |
| disableStream: s = !1 | |
| }) { | |
| qt(t, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'); | |
| const { | |
| length: i, | |
| initialData: r, | |
| progressiveDone: a, | |
| contentDispositionFilename: l | |
| } = t; | |
| if (this._queuedChunks = [], this._progressiveDone = a, this._contentDispositionFilename = l, (r == null ? void 0 : r.length) > 0) { | |
| const c = r instanceof Uint8Array && r.byteLength === r.buffer.byteLength ? r.buffer : new Uint8Array(r).buffer; | |
| this._queuedChunks.push(c); | |
| } | |
| this._pdfDataRangeTransport = t, this._isStreamingSupported = !s, this._isRangeSupported = !e, this._contentLength = i, this._fullRequestReader = null, this._rangeReaders = [], t.addRangeListener((c, h) => { | |
| this._onReceiveData({ | |
| begin: c, | |
| chunk: h | |
| }); | |
| }), t.addProgressListener((c, h) => { | |
| this._onProgress({ | |
| loaded: c, | |
| total: h | |
| }); | |
| }), t.addProgressiveReadListener((c) => { | |
| this._onReceiveData({ | |
| chunk: c | |
| }); | |
| }), t.addProgressiveDoneListener(() => { | |
| this._onProgressiveDone(); | |
| }), t.transportReady(); | |
| } | |
| _onReceiveData({ | |
| begin: t, | |
| chunk: e | |
| }) { | |
| const s = e instanceof Uint8Array && e.byteLength === e.buffer.byteLength ? e.buffer : new Uint8Array(e).buffer; | |
| if (t === void 0) | |
| this._fullRequestReader ? this._fullRequestReader._enqueue(s) : this._queuedChunks.push(s); | |
| else { | |
| const i = this._rangeReaders.some(function(r) { | |
| return r._begin !== t ? !1 : (r._enqueue(s), !0); | |
| }); | |
| qt(i, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."); | |
| } | |
| } | |
| get _progressiveDataLength() { | |
| var t; | |
| return ((t = this._fullRequestReader) == null ? void 0 : t._loaded) ?? 0; | |
| } | |
| _onProgress(t) { | |
| var e, s, i, r; | |
| t.total === void 0 ? (s = (e = this._rangeReaders[0]) == null ? void 0 : e.onProgress) == null || s.call(e, { | |
| loaded: t.loaded | |
| }) : (r = (i = this._fullRequestReader) == null ? void 0 : i.onProgress) == null || r.call(i, { | |
| loaded: t.loaded, | |
| total: t.total | |
| }); | |
| } | |
| _onProgressiveDone() { | |
| var t; | |
| (t = this._fullRequestReader) == null || t.progressiveDone(), this._progressiveDone = !0; | |
| } | |
| _removeRangeReader(t) { | |
| const e = this._rangeReaders.indexOf(t); | |
| e >= 0 && this._rangeReaders.splice(e, 1); | |
| } | |
| getFullReader() { | |
| qt(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once."); | |
| const t = this._queuedChunks; | |
| return this._queuedChunks = null, new yx(this, t, this._progressiveDone, this._contentDispositionFilename); | |
| } | |
| getRangeReader(t, e) { | |
| if (e <= this._progressiveDataLength) | |
| return null; | |
| const s = new bx(this, t, e); | |
| return this._pdfDataRangeTransport.requestDataRange(t, e), this._rangeReaders.push(s), s; | |
| } | |
| cancelAllRequests(t) { | |
| var e; | |
| (e = this._fullRequestReader) == null || e.cancel(t); | |
| for (const s of this._rangeReaders.slice(0)) | |
| s.cancel(t); | |
| this._pdfDataRangeTransport.abort(); | |
| } | |
| } | |
| class yx { | |
| constructor(t, e, s = !1, i = null) { | |
| this._stream = t, this._done = s || !1, this._filename = zp(i) ? i : null, this._queuedChunks = e || [], this._loaded = 0; | |
| for (const r of this._queuedChunks) | |
| this._loaded += r.byteLength; | |
| this._requests = [], this._headersReady = Promise.resolve(), t._fullRequestReader = this, this.onProgress = null; | |
| } | |
| _enqueue(t) { | |
| this._done || (this._requests.length > 0 ? this._requests.shift().resolve({ | |
| value: t, | |
| done: !1 | |
| }) : this._queuedChunks.push(t), this._loaded += t.byteLength); | |
| } | |
| get headersReady() { | |
| return this._headersReady; | |
| } | |
| get filename() { | |
| return this._filename; | |
| } | |
| get isRangeSupported() { | |
| return this._stream._isRangeSupported; | |
| } | |
| get isStreamingSupported() { | |
| return this._stream._isStreamingSupported; | |
| } | |
| get contentLength() { | |
| return this._stream._contentLength; | |
| } | |
| async read() { | |
| if (this._queuedChunks.length > 0) | |
| return { | |
| value: this._queuedChunks.shift(), | |
| done: !1 | |
| }; | |
| if (this._done) | |
| return { | |
| value: void 0, | |
| done: !0 | |
| }; | |
| const t = Promise.withResolvers(); | |
| return this._requests.push(t), t.promise; | |
| } | |
| cancel(t) { | |
| this._done = !0; | |
| for (const e of this._requests) | |
| e.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0; | |
| } | |
| progressiveDone() { | |
| this._done || (this._done = !0); | |
| } | |
| } | |
| class bx { | |
| constructor(t, e, s) { | |
| this._stream = t, this._begin = e, this._end = s, this._queuedChunk = null, this._requests = [], this._done = !1, this.onProgress = null; | |
| } | |
| _enqueue(t) { | |
| if (!this._done) { | |
| if (this._requests.length === 0) | |
| this._queuedChunk = t; | |
| else { | |
| this._requests.shift().resolve({ | |
| value: t, | |
| done: !1 | |
| }); | |
| for (const s of this._requests) | |
| s.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0; | |
| } | |
| this._done = !0, this._stream._removeRangeReader(this); | |
| } | |
| } | |
| get isStreamingSupported() { | |
| return !1; | |
| } | |
| async read() { | |
| if (this._queuedChunk) { | |
| const e = this._queuedChunk; | |
| return this._queuedChunk = null, { | |
| value: e, | |
| done: !1 | |
| }; | |
| } | |
| if (this._done) | |
| return { | |
| value: void 0, | |
| done: !0 | |
| }; | |
| const t = Promise.withResolvers(); | |
| return this._requests.push(t), t.promise; | |
| } | |
| cancel(t) { | |
| this._done = !0; | |
| for (const e of this._requests) | |
| e.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0, this._stream._removeRangeReader(this); | |
| } | |
| } | |
| function vx(n) { | |
| let t = !0, e = s("filename\\*", "i").exec(n); | |
| if (e) { | |
| e = e[1]; | |
| let u = l(e); | |
| return u = unescape(u), u = c(u), u = h(u), r(u); | |
| } | |
| if (e = a(n), e) { | |
| const u = h(e); | |
| return r(u); | |
| } | |
| if (e = s("filename", "i").exec(n), e) { | |
| e = e[1]; | |
| let u = l(e); | |
| return u = h(u), r(u); | |
| } | |
| function s(u, d) { | |
| return new RegExp("(?:^|;)\\s*" + u + '\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)', d); | |
| } | |
| function i(u, d) { | |
| if (u) { | |
| if (!/^[\x00-\xFF]+$/.test(d)) | |
| return d; | |
| try { | |
| const f = new TextDecoder(u, { | |
| fatal: !0 | |
| }), g = _d(d); | |
| d = f.decode(g), t = !1; | |
| } catch { | |
| } | |
| } | |
| return d; | |
| } | |
| function r(u) { | |
| return t && /[\x80-\xff]/.test(u) && (u = i("utf-8", u), t && (u = i("iso-8859-1", u))), u; | |
| } | |
| function a(u) { | |
| const d = []; | |
| let f; | |
| const g = s("filename\\*((?!0\\d)\\d+)(\\*?)", "ig"); | |
| for (; (f = g.exec(u)) !== null; ) { | |
| let [, y, _, A] = f; | |
| if (y = parseInt(y, 10), y in d) { | |
| if (y === 0) | |
| break; | |
| continue; | |
| } | |
| d[y] = [_, A]; | |
| } | |
| const m = []; | |
| for (let y = 0; y < d.length && y in d; ++y) { | |
| let [_, A] = d[y]; | |
| A = l(A), _ && (A = unescape(A), y === 0 && (A = c(A))), m.push(A); | |
| } | |
| return m.join(""); | |
| } | |
| function l(u) { | |
| if (u.startsWith('"')) { | |
| const d = u.slice(1).split('\\"'); | |
| for (let f = 0; f < d.length; ++f) { | |
| const g = d[f].indexOf('"'); | |
| g !== -1 && (d[f] = d[f].slice(0, g), d.length = f + 1), d[f] = d[f].replaceAll(/\\(.)/g, "$1"); | |
| } | |
| u = d.join('"'); | |
| } | |
| return u; | |
| } | |
| function c(u) { | |
| const d = u.indexOf("'"); | |
| if (d === -1) | |
| return u; | |
| const f = u.slice(0, d), m = u.slice(d + 1).replace(/^[^']*'/, ""); | |
| return i(f, m); | |
| } | |
| function h(u) { | |
| return !u.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(u) ? u : u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function(d, f, g, m) { | |
| if (g === "q" || g === "Q") | |
| return m = m.replaceAll("_", " "), m = m.replaceAll(/=([0-9a-fA-F]{2})/g, function(y, _) { | |
| return String.fromCharCode(parseInt(_, 16)); | |
| }), i(f, m); | |
| try { | |
| m = atob(m); | |
| } catch { | |
| } | |
| return i(f, m); | |
| }); | |
| } | |
| return ""; | |
| } | |
| function Ib(n, t) { | |
| const e = new Headers(); | |
| if (!n || !t || typeof t != "object") | |
| return e; | |
| for (const s in t) { | |
| const i = t[s]; | |
| i !== void 0 && e.append(s, i); | |
| } | |
| return e; | |
| } | |
| function Sd(n) { | |
| try { | |
| return new URL(n).origin; | |
| } catch { | |
| } | |
| return null; | |
| } | |
| function Rb({ | |
| responseHeaders: n, | |
| isHttp: t, | |
| rangeChunkSize: e, | |
| disableRange: s | |
| }) { | |
| const i = { | |
| allowRangeRequests: !1, | |
| suggestedLength: void 0 | |
| }, r = parseInt(n.get("Content-Length"), 10); | |
| return !Number.isInteger(r) || (i.suggestedLength = r, r <= 2 * e) || s || !t || n.get("Accept-Ranges") !== "bytes" || (n.get("Content-Encoding") || "identity") !== "identity" || (i.allowRangeRequests = !0), i; | |
| } | |
| function Pb(n) { | |
| const t = n.get("Content-Disposition"); | |
| if (t) { | |
| let e = vx(t); | |
| if (e.includes("%")) | |
| try { | |
| e = decodeURIComponent(e); | |
| } catch { | |
| } | |
| if (zp(e)) | |
| return e; | |
| } | |
| return null; | |
| } | |
| function Ed(n, t) { | |
| return n === 404 || n === 0 && t.startsWith("file:") ? new ic('Missing PDF "' + t + '".') : new $u(`Unexpected server response (${n}) while retrieving PDF "${t}".`, n); | |
| } | |
| function Mb(n) { | |
| return n === 200 || n === 206; | |
| } | |
| function Nb(n, t, e) { | |
| return { | |
| method: "GET", | |
| headers: n, | |
| signal: e.signal, | |
| mode: "cors", | |
| credentials: t ? "include" : "same-origin", | |
| redirect: "follow" | |
| }; | |
| } | |
| function Ob(n) { | |
| return n instanceof Uint8Array ? n.buffer : n instanceof ArrayBuffer ? n : (st(`getArrayBuffer - unexpected data format: ${n}`), new Uint8Array(n).buffer); | |
| } | |
| class Yg { | |
| constructor(t) { | |
| G(this, "_responseOrigin", null); | |
| this.source = t, this.isHttp = /^https?:/i.test(t.url), this.headers = Ib(this.isHttp, t.httpHeaders), this._fullRequestReader = null, this._rangeRequestReaders = []; | |
| } | |
| get _progressiveDataLength() { | |
| var t; | |
| return ((t = this._fullRequestReader) == null ? void 0 : t._loaded) ?? 0; | |
| } | |
| getFullReader() { | |
| return qt(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once."), this._fullRequestReader = new _x(this), this._fullRequestReader; | |
| } | |
| getRangeReader(t, e) { | |
| if (e <= this._progressiveDataLength) | |
| return null; | |
| const s = new Ax(this, t, e); | |
| return this._rangeRequestReaders.push(s), s; | |
| } | |
| cancelAllRequests(t) { | |
| var e; | |
| (e = this._fullRequestReader) == null || e.cancel(t); | |
| for (const s of this._rangeRequestReaders.slice(0)) | |
| s.cancel(t); | |
| } | |
| } | |
| class _x { | |
| constructor(t) { | |
| this._stream = t, this._reader = null, this._loaded = 0, this._filename = null; | |
| const e = t.source; | |
| this._withCredentials = e.withCredentials || !1, this._contentLength = e.length, this._headersCapability = Promise.withResolvers(), this._disableRange = e.disableRange || !1, this._rangeChunkSize = e.rangeChunkSize, !this._rangeChunkSize && !this._disableRange && (this._disableRange = !0), this._abortController = new AbortController(), this._isStreamingSupported = !e.disableStream, this._isRangeSupported = !e.disableRange; | |
| const s = new Headers(t.headers), i = e.url; | |
| fetch(i, Nb(s, this._withCredentials, this._abortController)).then((r) => { | |
| if (t._responseOrigin = Sd(r.url), !Mb(r.status)) | |
| throw Ed(r.status, i); | |
| this._reader = r.body.getReader(), this._headersCapability.resolve(); | |
| const a = r.headers, { | |
| allowRangeRequests: l, | |
| suggestedLength: c | |
| } = Rb({ | |
| responseHeaders: a, | |
| isHttp: t.isHttp, | |
| rangeChunkSize: this._rangeChunkSize, | |
| disableRange: this._disableRange | |
| }); | |
| this._isRangeSupported = l, this._contentLength = c || this._contentLength, this._filename = Pb(a), !this._isStreamingSupported && this._isRangeSupported && this.cancel(new Bn("Streaming is disabled.")); | |
| }).catch(this._headersCapability.reject), this.onProgress = null; | |
| } | |
| get headersReady() { | |
| return this._headersCapability.promise; | |
| } | |
| get filename() { | |
| return this._filename; | |
| } | |
| get contentLength() { | |
| return this._contentLength; | |
| } | |
| get isRangeSupported() { | |
| return this._isRangeSupported; | |
| } | |
| get isStreamingSupported() { | |
| return this._isStreamingSupported; | |
| } | |
| async read() { | |
| var s; | |
| await this._headersCapability.promise; | |
| const { | |
| value: t, | |
| done: e | |
| } = await this._reader.read(); | |
| return e ? { | |
| value: t, | |
| done: e | |
| } : (this._loaded += t.byteLength, (s = this.onProgress) == null || s.call(this, { | |
| loaded: this._loaded, | |
| total: this._contentLength | |
| }), { | |
| value: Ob(t), | |
| done: !1 | |
| }); | |
| } | |
| cancel(t) { | |
| var e; | |
| (e = this._reader) == null || e.cancel(t), this._abortController.abort(); | |
| } | |
| } | |
| class Ax { | |
| constructor(t, e, s) { | |
| this._stream = t, this._reader = null, this._loaded = 0; | |
| const i = t.source; | |
| this._withCredentials = i.withCredentials || !1, this._readCapability = Promise.withResolvers(), this._isStreamingSupported = !i.disableStream, this._abortController = new AbortController(); | |
| const r = new Headers(t.headers); | |
| r.append("Range", `bytes=${e}-${s - 1}`); | |
| const a = i.url; | |
| fetch(a, Nb(r, this._withCredentials, this._abortController)).then((l) => { | |
| const c = Sd(l.url); | |
| if (c !== t._responseOrigin) | |
| throw new Error(`Expected range response-origin "${c}" to match "${t._responseOrigin}".`); | |
| if (!Mb(l.status)) | |
| throw Ed(l.status, a); | |
| this._readCapability.resolve(), this._reader = l.body.getReader(); | |
| }).catch(this._readCapability.reject), this.onProgress = null; | |
| } | |
| get isStreamingSupported() { | |
| return this._isStreamingSupported; | |
| } | |
| async read() { | |
| var s; | |
| await this._readCapability.promise; | |
| const { | |
| value: t, | |
| done: e | |
| } = await this._reader.read(); | |
| return e ? { | |
| value: t, | |
| done: e | |
| } : (this._loaded += t.byteLength, (s = this.onProgress) == null || s.call(this, { | |
| loaded: this._loaded | |
| }), { | |
| value: Ob(t), | |
| done: !1 | |
| }); | |
| } | |
| cancel(t) { | |
| var e; | |
| (e = this._reader) == null || e.cancel(t), this._abortController.abort(); | |
| } | |
| } | |
| const Xd = 200, Zd = 206; | |
| function wx(n) { | |
| const t = n.response; | |
| return typeof t != "string" ? t : _d(t).buffer; | |
| } | |
| class Sx { | |
| constructor({ | |
| url: t, | |
| httpHeaders: e, | |
| withCredentials: s | |
| }) { | |
| G(this, "_responseOrigin", null); | |
| this.url = t, this.isHttp = /^https?:/i.test(t), this.headers = Ib(this.isHttp, e), this.withCredentials = s || !1, this.currXhrId = 0, this.pendingRequests = /* @__PURE__ */ Object.create(null); | |
| } | |
| request(t) { | |
| const e = new XMLHttpRequest(), s = this.currXhrId++, i = this.pendingRequests[s] = { | |
| xhr: e | |
| }; | |
| e.open("GET", this.url), e.withCredentials = this.withCredentials; | |
| for (const [r, a] of this.headers) | |
| e.setRequestHeader(r, a); | |
| return this.isHttp && "begin" in t && "end" in t ? (e.setRequestHeader("Range", `bytes=${t.begin}-${t.end - 1}`), i.expectedStatus = Zd) : i.expectedStatus = Xd, e.responseType = "arraybuffer", qt(t.onError, "Expected `onError` callback to be provided."), e.onerror = () => { | |
| t.onError(e.status); | |
| }, e.onreadystatechange = this.onStateChange.bind(this, s), e.onprogress = this.onProgress.bind(this, s), i.onHeadersReceived = t.onHeadersReceived, i.onDone = t.onDone, i.onError = t.onError, i.onProgress = t.onProgress, e.send(null), s; | |
| } | |
| onProgress(t, e) { | |
| var i; | |
| const s = this.pendingRequests[t]; | |
| s && ((i = s.onProgress) == null || i.call(s, e)); | |
| } | |
| onStateChange(t, e) { | |
| const s = this.pendingRequests[t]; | |
| if (!s) | |
| return; | |
| const i = s.xhr; | |
| if (i.readyState >= 2 && s.onHeadersReceived && (s.onHeadersReceived(), delete s.onHeadersReceived), i.readyState !== 4 || !(t in this.pendingRequests)) | |
| return; | |
| if (delete this.pendingRequests[t], i.status === 0 && this.isHttp) { | |
| s.onError(i.status); | |
| return; | |
| } | |
| const r = i.status || Xd; | |
| if (!(r === Xd && s.expectedStatus === Zd) && r !== s.expectedStatus) { | |
| s.onError(i.status); | |
| return; | |
| } | |
| const l = wx(i); | |
| if (r === Zd) { | |
| const c = i.getResponseHeader("Content-Range"), h = /bytes (\d+)-(\d+)\/(\d+)/.exec(c); | |
| h ? s.onDone({ | |
| begin: parseInt(h[1], 10), | |
| chunk: l | |
| }) : (st('Missing or invalid "Content-Range" header.'), s.onError(0)); | |
| } else l ? s.onDone({ | |
| begin: 0, | |
| chunk: l | |
| }) : s.onError(i.status); | |
| } | |
| getRequestXhr(t) { | |
| return this.pendingRequests[t].xhr; | |
| } | |
| isPendingRequest(t) { | |
| return t in this.pendingRequests; | |
| } | |
| abortRequest(t) { | |
| const e = this.pendingRequests[t].xhr; | |
| delete this.pendingRequests[t], e.abort(); | |
| } | |
| } | |
| class Ex { | |
| constructor(t) { | |
| this._source = t, this._manager = new Sx(t), this._rangeChunkSize = t.rangeChunkSize, this._fullRequestReader = null, this._rangeRequestReaders = []; | |
| } | |
| _onRangeRequestReaderClosed(t) { | |
| const e = this._rangeRequestReaders.indexOf(t); | |
| e >= 0 && this._rangeRequestReaders.splice(e, 1); | |
| } | |
| getFullReader() { | |
| return qt(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once."), this._fullRequestReader = new xx(this._manager, this._source), this._fullRequestReader; | |
| } | |
| getRangeReader(t, e) { | |
| const s = new Tx(this._manager, t, e); | |
| return s.onClosed = this._onRangeRequestReaderClosed.bind(this), this._rangeRequestReaders.push(s), s; | |
| } | |
| cancelAllRequests(t) { | |
| var e; | |
| (e = this._fullRequestReader) == null || e.cancel(t); | |
| for (const s of this._rangeRequestReaders.slice(0)) | |
| s.cancel(t); | |
| } | |
| } | |
| class xx { | |
| constructor(t, e) { | |
| this._manager = t, this._url = e.url, this._fullRequestId = t.request({ | |
| onHeadersReceived: this._onHeadersReceived.bind(this), | |
| onDone: this._onDone.bind(this), | |
| onError: this._onError.bind(this), | |
| onProgress: this._onProgress.bind(this) | |
| }), this._headersCapability = Promise.withResolvers(), this._disableRange = e.disableRange || !1, this._contentLength = e.length, this._rangeChunkSize = e.rangeChunkSize, !this._rangeChunkSize && !this._disableRange && (this._disableRange = !0), this._isStreamingSupported = !1, this._isRangeSupported = !1, this._cachedChunks = [], this._requests = [], this._done = !1, this._storedError = void 0, this._filename = null, this.onProgress = null; | |
| } | |
| _onHeadersReceived() { | |
| const t = this._fullRequestId, e = this._manager.getRequestXhr(t); | |
| this._manager._responseOrigin = Sd(e.responseURL); | |
| const s = e.getAllResponseHeaders(), i = new Headers(s ? s.trimStart().replace(/[^\S ]+$/, "").split(/[\r\n]+/).map((l) => { | |
| const [c, ...h] = l.split(": "); | |
| return [c, h.join(": ")]; | |
| }) : []), { | |
| allowRangeRequests: r, | |
| suggestedLength: a | |
| } = Rb({ | |
| responseHeaders: i, | |
| isHttp: this._manager.isHttp, | |
| rangeChunkSize: this._rangeChunkSize, | |
| disableRange: this._disableRange | |
| }); | |
| r && (this._isRangeSupported = !0), this._contentLength = a || this._contentLength, this._filename = Pb(i), this._isRangeSupported && this._manager.abortRequest(t), this._headersCapability.resolve(); | |
| } | |
| _onDone(t) { | |
| if (t && (this._requests.length > 0 ? this._requests.shift().resolve({ | |
| value: t.chunk, | |
| done: !1 | |
| }) : this._cachedChunks.push(t.chunk)), this._done = !0, !(this._cachedChunks.length > 0)) { | |
| for (const e of this._requests) | |
| e.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0; | |
| } | |
| } | |
| _onError(t) { | |
| this._storedError = Ed(t, this._url), this._headersCapability.reject(this._storedError); | |
| for (const e of this._requests) | |
| e.reject(this._storedError); | |
| this._requests.length = 0, this._cachedChunks.length = 0; | |
| } | |
| _onProgress(t) { | |
| var e; | |
| (e = this.onProgress) == null || e.call(this, { | |
| loaded: t.loaded, | |
| total: t.lengthComputable ? t.total : this._contentLength | |
| }); | |
| } | |
| get filename() { | |
| return this._filename; | |
| } | |
| get isRangeSupported() { | |
| return this._isRangeSupported; | |
| } | |
| get isStreamingSupported() { | |
| return this._isStreamingSupported; | |
| } | |
| get contentLength() { | |
| return this._contentLength; | |
| } | |
| get headersReady() { | |
| return this._headersCapability.promise; | |
| } | |
| async read() { | |
| if (await this._headersCapability.promise, this._storedError) | |
| throw this._storedError; | |
| if (this._cachedChunks.length > 0) | |
| return { | |
| value: this._cachedChunks.shift(), | |
| done: !1 | |
| }; | |
| if (this._done) | |
| return { | |
| value: void 0, | |
| done: !0 | |
| }; | |
| const t = Promise.withResolvers(); | |
| return this._requests.push(t), t.promise; | |
| } | |
| cancel(t) { | |
| this._done = !0, this._headersCapability.reject(t); | |
| for (const e of this._requests) | |
| e.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0, this._manager.isPendingRequest(this._fullRequestId) && this._manager.abortRequest(this._fullRequestId), this._fullRequestReader = null; | |
| } | |
| } | |
| class Tx { | |
| constructor(t, e, s) { | |
| this._manager = t, this._url = t.url, this._requestId = t.request({ | |
| begin: e, | |
| end: s, | |
| onHeadersReceived: this._onHeadersReceived.bind(this), | |
| onDone: this._onDone.bind(this), | |
| onError: this._onError.bind(this), | |
| onProgress: this._onProgress.bind(this) | |
| }), this._requests = [], this._queuedChunk = null, this._done = !1, this._storedError = void 0, this.onProgress = null, this.onClosed = null; | |
| } | |
| _onHeadersReceived() { | |
| var e; | |
| const t = Sd((e = this._manager.getRequestXhr(this._requestId)) == null ? void 0 : e.responseURL); | |
| t !== this._manager._responseOrigin && (this._storedError = new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`), this._onError(0)); | |
| } | |
| _close() { | |
| var t; | |
| (t = this.onClosed) == null || t.call(this, this); | |
| } | |
| _onDone(t) { | |
| const e = t.chunk; | |
| this._requests.length > 0 ? this._requests.shift().resolve({ | |
| value: e, | |
| done: !1 | |
| }) : this._queuedChunk = e, this._done = !0; | |
| for (const s of this._requests) | |
| s.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0, this._close(); | |
| } | |
| _onError(t) { | |
| this._storedError ?? (this._storedError = Ed(t, this._url)); | |
| for (const e of this._requests) | |
| e.reject(this._storedError); | |
| this._requests.length = 0, this._queuedChunk = null; | |
| } | |
| _onProgress(t) { | |
| var e; | |
| this.isStreamingSupported || (e = this.onProgress) == null || e.call(this, { | |
| loaded: t.loaded | |
| }); | |
| } | |
| get isStreamingSupported() { | |
| return !1; | |
| } | |
| async read() { | |
| if (this._storedError) | |
| throw this._storedError; | |
| if (this._queuedChunk !== null) { | |
| const e = this._queuedChunk; | |
| return this._queuedChunk = null, { | |
| value: e, | |
| done: !1 | |
| }; | |
| } | |
| if (this._done) | |
| return { | |
| value: void 0, | |
| done: !0 | |
| }; | |
| const t = Promise.withResolvers(); | |
| return this._requests.push(t), t.promise; | |
| } | |
| cancel(t) { | |
| this._done = !0; | |
| for (const e of this._requests) | |
| e.resolve({ | |
| value: void 0, | |
| done: !0 | |
| }); | |
| this._requests.length = 0, this._manager.isPendingRequest(this._requestId) && this._manager.abortRequest(this._requestId), this._close(); | |
| } | |
| } | |
| const Cx = /^[a-z][a-z0-9\-+.]+:/i; | |
| function kx(n) { | |
| if (Cx.test(n)) | |
| return new URL(n); | |
| const t = process.getBuiltinModule("url"); | |
| return new URL(t.pathToFileURL(n)); | |
| } | |
| class Ix { | |
| constructor(t) { | |
| this.source = t, this.url = kx(t.url), qt(this.url.protocol === "file:", "PDFNodeStream only supports file:// URLs."), this._fullRequestReader = null, this._rangeRequestReaders = []; | |
| } | |
| get _progressiveDataLength() { | |
| var t; | |
| return ((t = this._fullRequestReader) == null ? void 0 : t._loaded) ?? 0; | |
| } | |
| getFullReader() { | |
| return qt(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once."), this._fullRequestReader = new Rx(this), this._fullRequestReader; | |
| } | |
| getRangeReader(t, e) { | |
| if (e <= this._progressiveDataLength) | |
| return null; | |
| const s = new Px(this, t, e); | |
| return this._rangeRequestReaders.push(s), s; | |
| } | |
| cancelAllRequests(t) { | |
| var e; | |
| (e = this._fullRequestReader) == null || e.cancel(t); | |
| for (const s of this._rangeRequestReaders.slice(0)) | |
| s.cancel(t); | |
| } | |
| } | |
| class Rx { | |
| constructor(t) { | |
| this._url = t.url, this._done = !1, this._storedError = null, this.onProgress = null; | |
| const e = t.source; | |
| this._contentLength = e.length, this._loaded = 0, this._filename = null, this._disableRange = e.disableRange || !1, this._rangeChunkSize = e.rangeChunkSize, !this._rangeChunkSize && !this._disableRange && (this._disableRange = !0), this._isStreamingSupported = !e.disableStream, this._isRangeSupported = !e.disableRange, this._readableStream = null, this._readCapability = Promise.withResolvers(), this._headersCapability = Promise.withResolvers(); | |
| const s = process.getBuiltinModule("fs"); | |
| s.promises.lstat(this._url).then((i) => { | |
| this._contentLength = i.size, this._setReadableStream(s.createReadStream(this._url)), this._headersCapability.resolve(); | |
| }, (i) => { | |
| i.code === "ENOENT" && (i = new ic(`Missing PDF "${this._url}".`)), this._storedError = i, this._headersCapability.reject(i); | |
| }); | |
| } | |
| get headersReady() { | |
| return this._headersCapability.promise; | |
| } | |
| get filename() { | |
| return this._filename; | |
| } | |
| get contentLength() { | |
| return this._contentLength; | |
| } | |
| get isRangeSupported() { | |
| return this._isRangeSupported; | |
| } | |
| get isStreamingSupported() { | |
| return this._isStreamingSupported; | |
| } | |
| async read() { | |
| var s; | |
| if (await this._readCapability.promise, this._done) | |
| return { | |
| value: void 0, | |
| done: !0 | |
| }; | |
| if (this._storedError) | |
| throw this._storedError; | |
| const t = this._readableStream.read(); | |
| return t === null ? (this._readCapability = Promise.withResolvers(), this.read()) : (this._loaded += t.length, (s = this.onProgress) == null || s.call(this, { | |
| loaded: this._loaded, | |
| total: this._contentLength | |
| }), { | |
| value: new Uint8Array(t).buffer, | |
| done: !1 | |
| }); | |
| } | |
| cancel(t) { | |
| if (!this._readableStream) { | |
| this._error(t); | |
| return; | |
| } | |
| this._readableStream.destroy(t); | |
| } | |
| _error(t) { | |
| this._storedError = t, this._readCapability.resolve(); | |
| } | |
| _setReadableStream(t) { | |
| this._readableStream = t, t.on("readable", () => { | |
| this._readCapability.resolve(); | |
| }), t.on("end", () => { | |
| t.destroy(), this._done = !0, this._readCapability.resolve(); | |
| }), t.on("error", (e) => { | |
| this._error(e); | |
| }), !this._isStreamingSupported && this._isRangeSupported && this._error(new Bn("streaming is disabled")), this._storedError && this._readableStream.destroy(this._storedError); | |
| } | |
| } | |
| class Px { | |
| constructor(t, e, s) { | |
| this._url = t.url, this._done = !1, this._storedError = null, this.onProgress = null, this._loaded = 0, this._readableStream = null, this._readCapability = Promise.withResolvers(); | |
| const i = t.source; | |
| this._isStreamingSupported = !i.disableStream; | |
| const r = process.getBuiltinModule("fs"); | |
| this._setReadableStream(r.createReadStream(this._url, { | |
| start: e, | |
| end: s - 1 | |
| })); | |
| } | |
| get isStreamingSupported() { | |
| return this._isStreamingSupported; | |
| } | |
| async read() { | |
| var s; | |
| if (await this._readCapability.promise, this._done) | |
| return { | |
| value: void 0, | |
| done: !0 | |
| }; | |
| if (this._storedError) | |
| throw this._storedError; | |
| const t = this._readableStream.read(); | |
| return t === null ? (this._readCapability = Promise.withResolvers(), this.read()) : (this._loaded += t.length, (s = this.onProgress) == null || s.call(this, { | |
| loaded: this._loaded | |
| }), { | |
| value: new Uint8Array(t).buffer, | |
| done: !1 | |
| }); | |
| } | |
| cancel(t) { | |
| if (!this._readableStream) { | |
| this._error(t); | |
| return; | |
| } | |
| this._readableStream.destroy(t); | |
| } | |
| _error(t) { | |
| this._storedError = t, this._readCapability.resolve(); | |
| } | |
| _setReadableStream(t) { | |
| this._readableStream = t, t.on("readable", () => { | |
| this._readCapability.resolve(); | |
| }), t.on("end", () => { | |
| t.destroy(), this._done = !0, this._readCapability.resolve(); | |
| }), t.on("error", (e) => { | |
| this._error(e); | |
| }), this._storedError && this._readableStream.destroy(this._storedError); | |
| } | |
| } | |
| const Mx = 1e5, De = 30, Nx = 0.8; | |
| var em, yn, Be, Hc, Uc, Cr, Ri, zc, Vc, kr, so, io, bn, no, Gc, ro, Ir, qc, Wc, Rr, Pr, Xc, vn, ao, Ji, Lb, Db, Hf, as, su, Uf, Fb, $b; | |
| const Zt = class Zt { | |
| constructor({ | |
| textContentSource: t, | |
| container: e, | |
| viewport: s | |
| }) { | |
| b(this, Ji); | |
| b(this, yn, Promise.withResolvers()); | |
| b(this, Be, null); | |
| b(this, Hc, !1); | |
| b(this, Uc, !!((em = globalThis.FontInspector) != null && em.enabled)); | |
| b(this, Cr, null); | |
| b(this, Ri, null); | |
| b(this, zc, 0); | |
| b(this, Vc, 0); | |
| b(this, kr, null); | |
| b(this, so, null); | |
| b(this, io, 0); | |
| b(this, bn, 0); | |
| b(this, no, /* @__PURE__ */ Object.create(null)); | |
| b(this, Gc, []); | |
| b(this, ro, null); | |
| b(this, Ir, []); | |
| b(this, qc, /* @__PURE__ */ new WeakMap()); | |
| b(this, Wc, null); | |
| var c; | |
| if (t instanceof ReadableStream) | |
| p(this, ro, t); | |
| else if (typeof t == "object") | |
| p(this, ro, new ReadableStream({ | |
| start(h) { | |
| h.enqueue(t), h.close(); | |
| } | |
| })); | |
| else | |
| throw new Error('No "textContentSource" parameter specified.'); | |
| p(this, Be, p(this, so, e)), p(this, bn, s.scale * (globalThis.devicePixelRatio || 1)), p(this, io, s.rotation), p(this, Ri, { | |
| div: null, | |
| properties: null, | |
| ctx: null | |
| }); | |
| const { | |
| pageWidth: i, | |
| pageHeight: r, | |
| pageX: a, | |
| pageY: l | |
| } = s.rawDims; | |
| p(this, Wc, [1, 0, 0, -1, -a, l + r]), p(this, Vc, i), p(this, zc, r), v(c = Zt, as, Fb).call(c), fa(e, s), o(this, yn).promise.finally(() => { | |
| o(Zt, ao).delete(this), p(this, Ri, null), p(this, no, null); | |
| }).catch(() => { | |
| }); | |
| } | |
| static get fontFamilyMap() { | |
| const { | |
| isWindows: t, | |
| isFirefox: e | |
| } = Me.platform; | |
| return at(this, "fontFamilyMap", /* @__PURE__ */ new Map([["sans-serif", `${t && e ? "Calibri, " : ""}sans-serif`], ["monospace", `${t && e ? "Lucida Console, " : ""}monospace`]])); | |
| } | |
| render() { | |
| const t = () => { | |
| o(this, kr).read().then(({ | |
| value: e, | |
| done: s | |
| }) => { | |
| if (s) { | |
| o(this, yn).resolve(); | |
| return; | |
| } | |
| o(this, Cr) ?? p(this, Cr, e.lang), Object.assign(o(this, no), e.styles), v(this, Ji, Lb).call(this, e.items), t(); | |
| }, o(this, yn).reject); | |
| }; | |
| return p(this, kr, o(this, ro).getReader()), o(Zt, ao).add(this), t(), o(this, yn).promise; | |
| } | |
| update({ | |
| viewport: t, | |
| onBefore: e = null | |
| }) { | |
| var r; | |
| const s = t.scale * (globalThis.devicePixelRatio || 1), i = t.rotation; | |
| if (i !== o(this, io) && (e == null || e(), p(this, io, i), fa(o(this, so), { | |
| rotation: i | |
| })), s !== o(this, bn)) { | |
| e == null || e(), p(this, bn, s); | |
| const a = { | |
| div: null, | |
| properties: null, | |
| ctx: v(r = Zt, as, su).call(r, o(this, Cr)) | |
| }; | |
| for (const l of o(this, Ir)) | |
| a.properties = o(this, qc).get(l), a.div = l, v(this, Ji, Hf).call(this, a); | |
| } | |
| } | |
| cancel() { | |
| var e; | |
| const t = new Bn("TextLayer task cancelled."); | |
| (e = o(this, kr)) == null || e.cancel(t).catch(() => { | |
| }), p(this, kr, null), o(this, yn).reject(t); | |
| } | |
| get textDivs() { | |
| return o(this, Ir); | |
| } | |
| get textContentItemsStr() { | |
| return o(this, Gc); | |
| } | |
| static cleanup() { | |
| if (!(o(this, ao).size > 0)) { | |
| o(this, Rr).clear(); | |
| for (const { | |
| canvas: t | |
| } of o(this, Pr).values()) | |
| t.remove(); | |
| o(this, Pr).clear(); | |
| } | |
| } | |
| }; | |
| yn = new WeakMap(), Be = new WeakMap(), Hc = new WeakMap(), Uc = new WeakMap(), Cr = new WeakMap(), Ri = new WeakMap(), zc = new WeakMap(), Vc = new WeakMap(), kr = new WeakMap(), so = new WeakMap(), io = new WeakMap(), bn = new WeakMap(), no = new WeakMap(), Gc = new WeakMap(), ro = new WeakMap(), Ir = new WeakMap(), qc = new WeakMap(), Wc = new WeakMap(), Rr = new WeakMap(), Pr = new WeakMap(), Xc = new WeakMap(), vn = new WeakMap(), ao = new WeakMap(), Ji = new WeakSet(), Lb = function(t) { | |
| var i, r; | |
| if (o(this, Hc)) | |
| return; | |
| (r = o(this, Ri)).ctx ?? (r.ctx = v(i = Zt, as, su).call(i, o(this, Cr))); | |
| const e = o(this, Ir), s = o(this, Gc); | |
| for (const a of t) { | |
| if (e.length > Mx) { | |
| st("Ignoring additional textDivs for performance reasons."), p(this, Hc, !0); | |
| return; | |
| } | |
| if (a.str === void 0) { | |
| if (a.type === "beginMarkedContentProps" || a.type === "beginMarkedContent") { | |
| const l = o(this, Be); | |
| p(this, Be, document.createElement("span")), o(this, Be).classList.add("markedContent"), a.id !== null && o(this, Be).setAttribute("id", `${a.id}`), l.append(o(this, Be)); | |
| } else a.type === "endMarkedContent" && p(this, Be, o(this, Be).parentNode); | |
| continue; | |
| } | |
| s.push(a.str), v(this, Ji, Db).call(this, a); | |
| } | |
| }, Db = function(t) { | |
| var y; | |
| const e = document.createElement("span"), s = { | |
| angle: 0, | |
| canvasWidth: 0, | |
| hasText: t.str !== "", | |
| hasEOL: t.hasEOL, | |
| fontSize: 0 | |
| }; | |
| o(this, Ir).push(e); | |
| const i = U.transform(o(this, Wc), t.transform); | |
| let r = Math.atan2(i[1], i[0]); | |
| const a = o(this, no)[t.fontName]; | |
| a.vertical && (r += Math.PI / 2); | |
| let l = o(this, Uc) && a.fontSubstitution || a.fontFamily; | |
| l = Zt.fontFamilyMap.get(l) || l; | |
| const c = Math.hypot(i[2], i[3]), h = c * v(y = Zt, as, $b).call(y, l, o(this, Cr)); | |
| let u, d; | |
| r === 0 ? (u = i[4], d = i[5] - h) : (u = i[4] + h * Math.sin(r), d = i[5] - h * Math.cos(r)); | |
| const f = "calc(var(--scale-factor)*", g = e.style; | |
| o(this, Be) === o(this, so) ? (g.left = `${(100 * u / o(this, Vc)).toFixed(2)}%`, g.top = `${(100 * d / o(this, zc)).toFixed(2)}%`) : (g.left = `${f}${u.toFixed(2)}px)`, g.top = `${f}${d.toFixed(2)}px)`), g.fontSize = `${f}${(o(Zt, vn) * c).toFixed(2)}px)`, g.fontFamily = l, s.fontSize = c, e.setAttribute("role", "presentation"), e.textContent = t.str, e.dir = t.dir, o(this, Uc) && (e.dataset.fontName = a.fontSubstitutionLoadedName || t.fontName), r !== 0 && (s.angle = r * (180 / Math.PI)); | |
| let m = !1; | |
| if (t.str.length > 1) | |
| m = !0; | |
| else if (t.str !== " " && t.transform[0] !== t.transform[3]) { | |
| const _ = Math.abs(t.transform[0]), A = Math.abs(t.transform[3]); | |
| _ !== A && Math.max(_, A) / Math.min(_, A) > 1.5 && (m = !0); | |
| } | |
| if (m && (s.canvasWidth = a.vertical ? t.height : t.width), o(this, qc).set(e, s), o(this, Ri).div = e, o(this, Ri).properties = s, v(this, Ji, Hf).call(this, o(this, Ri)), s.hasText && o(this, Be).append(e), s.hasEOL) { | |
| const _ = document.createElement("br"); | |
| _.setAttribute("role", "presentation"), o(this, Be).append(_); | |
| } | |
| }, Hf = function(t) { | |
| var l; | |
| const { | |
| div: e, | |
| properties: s, | |
| ctx: i | |
| } = t, { | |
| style: r | |
| } = e; | |
| let a = ""; | |
| if (o(Zt, vn) > 1 && (a = `scale(${1 / o(Zt, vn)})`), s.canvasWidth !== 0 && s.hasText) { | |
| const { | |
| fontFamily: c | |
| } = r, { | |
| canvasWidth: h, | |
| fontSize: u | |
| } = s; | |
| v(l = Zt, as, Uf).call(l, i, u * o(this, bn), c); | |
| const { | |
| width: d | |
| } = i.measureText(e.textContent); | |
| d > 0 && (a = `scaleX(${h * o(this, bn) / d}) ${a}`); | |
| } | |
| s.angle !== 0 && (a = `rotate(${s.angle}deg) ${a}`), a.length > 0 && (r.transform = a); | |
| }, as = new WeakSet(), su = function(t = null) { | |
| let e = o(this, Pr).get(t || (t = "")); | |
| if (!e) { | |
| const s = document.createElement("canvas"); | |
| s.className = "hiddenCanvasElement", s.lang = t, document.body.append(s), e = s.getContext("2d", { | |
| alpha: !1, | |
| willReadFrequently: !0 | |
| }), o(this, Pr).set(t, e), o(this, Xc).set(e, { | |
| size: 0, | |
| family: "" | |
| }); | |
| } | |
| return e; | |
| }, Uf = function(t, e, s) { | |
| const i = o(this, Xc).get(t); | |
| e === i.size && s === i.family || (t.font = `${e}px ${s}`, i.size = e, i.family = s); | |
| }, Fb = function() { | |
| if (o(this, vn) !== null) | |
| return; | |
| const t = document.createElement("div"); | |
| t.style.opacity = 0, t.style.lineHeight = 1, t.style.fontSize = "1px", t.style.position = "absolute", t.textContent = "X", document.body.append(t), p(this, vn, t.getBoundingClientRect().height), t.remove(); | |
| }, $b = function(t, e) { | |
| const s = o(this, Rr).get(t); | |
| if (s) | |
| return s; | |
| const i = v(this, as, su).call(this, e); | |
| i.canvas.width = i.canvas.height = De, v(this, as, Uf).call(this, i, De, t); | |
| const r = i.measureText(""); | |
| let a = r.fontBoundingBoxAscent, l = Math.abs(r.fontBoundingBoxDescent); | |
| if (a) { | |
| const u = a / (a + l); | |
| return o(this, Rr).set(t, u), i.canvas.width = i.canvas.height = 0, u; | |
| } | |
| i.strokeStyle = "red", i.clearRect(0, 0, De, De), i.strokeText("g", 0, 0); | |
| let c = i.getImageData(0, 0, De, De).data; | |
| l = 0; | |
| for (let u = c.length - 1 - 3; u >= 0; u -= 4) | |
| if (c[u] > 0) { | |
| l = Math.ceil(u / 4 / De); | |
| break; | |
| } | |
| i.clearRect(0, 0, De, De), i.strokeText("A", 0, De), c = i.getImageData(0, 0, De, De).data, a = 0; | |
| for (let u = 0, d = c.length; u < d; u += 4) | |
| if (c[u] > 0) { | |
| a = De - Math.floor(u / 4 / De); | |
| break; | |
| } | |
| i.canvas.width = i.canvas.height = 0; | |
| const h = a ? a / (a + l) : Nx; | |
| return o(this, Rr).set(t, h), h; | |
| }, b(Zt, as), b(Zt, Rr, /* @__PURE__ */ new Map()), b(Zt, Pr, /* @__PURE__ */ new Map()), b(Zt, Xc, /* @__PURE__ */ new WeakMap()), b(Zt, vn, null), b(Zt, ao, /* @__PURE__ */ new Set()); | |
| let nc = Zt; | |
| class rc { | |
| static textContent(t) { | |
| const e = [], s = { | |
| items: e, | |
| styles: /* @__PURE__ */ Object.create(null) | |
| }; | |
| function i(r) { | |
| var c; | |
| if (!r) | |
| return; | |
| let a = null; | |
| const l = r.name; | |
| if (l === "#text") | |
| a = r.value; | |
| else if (rc.shouldBuildText(l)) | |
| (c = r == null ? void 0 : r.attributes) != null && c.textContent ? a = r.attributes.textContent : r.value && (a = r.value); | |
| else return; | |
| if (a !== null && e.push({ | |
| str: a | |
| }), !!r.children) | |
| for (const h of r.children) | |
| i(h); | |
| } | |
| return i(t), s; | |
| } | |
| static shouldBuildText(t) { | |
| return !(t === "textarea" || t === "input" || t === "option" || t === "select"); | |
| } | |
| } | |
| const Ox = 65536, Lx = 100, Dx = 5e3, Fx = Se ? KE : XE, $x = Se ? JE : Sb, jx = Se ? YE : ZE, Bx = Se ? QE : Cb; | |
| function Hx(n = {}) { | |
| typeof n == "string" || n instanceof URL ? n = { | |
| url: n | |
| } : (n instanceof ArrayBuffer || ArrayBuffer.isView(n)) && (n = { | |
| data: n | |
| }); | |
| const t = new zf(), { | |
| docId: e | |
| } = t, s = n.url ? Ux(n.url) : null, i = n.data ? zx(n.data) : null, r = n.httpHeaders || null, a = n.withCredentials === !0, l = n.password ?? null, c = n.range instanceof jb ? n.range : null, h = Number.isInteger(n.rangeChunkSize) && n.rangeChunkSize > 0 ? n.rangeChunkSize : Ox; | |
| let u = n.worker instanceof La ? n.worker : null; | |
| const d = n.verbosity, f = typeof n.docBaseUrl == "string" && !wd(n.docBaseUrl) ? n.docBaseUrl : null, g = typeof n.cMapUrl == "string" ? n.cMapUrl : null, m = n.cMapPacked !== !1, y = n.CMapReaderFactory || $x, _ = typeof n.standardFontDataUrl == "string" ? n.standardFontDataUrl : null, A = n.StandardFontDataFactory || Bx, S = n.stopAtErrors !== !0, E = Number.isInteger(n.maxImageSize) && n.maxImageSize > -1 ? n.maxImageSize : -1, x = n.isEvalSupported !== !1, T = typeof n.isOffscreenCanvasSupported == "boolean" ? n.isOffscreenCanvasSupported : !Se, k = typeof n.isImageDecoderSupported == "boolean" ? n.isImageDecoderSupported : !Se && (Me.platform.isFirefox || !globalThis.chrome), C = Number.isInteger(n.canvasMaxAreaInBytes) ? n.canvasMaxAreaInBytes : -1, P = typeof n.disableFontFace == "boolean" ? n.disableFontFace : Se, j = n.fontExtraProperties === !0, Z = n.enableXfa === !0, V = n.ownerDocument || globalThis.document, dt = n.disableRange === !0, gt = n.disableStream === !0, Y = n.disableAutoFetch === !0, xt = n.pdfBug === !0, M = n.CanvasFactory || Fx, z = n.FilterFactory || jx, ot = n.enableHWA === !0, kt = c ? c.length : n.length ?? NaN, yt = typeof n.useSystemFonts == "boolean" ? n.useSystemFonts : !Se && !P, Q = typeof n.useWorkerFetch == "boolean" ? n.useWorkerFetch : y === Sb && A === Cb && g && _ && hl(g, document.baseURI) && hl(_, document.baseURI), Vt = null; | |
| TE(d); | |
| const $t = { | |
| canvasFactory: new M({ | |
| ownerDocument: V, | |
| enableHWA: ot | |
| }), | |
| filterFactory: new z({ | |
| docId: e, | |
| ownerDocument: V | |
| }), | |
| cMapReaderFactory: Q ? null : new y({ | |
| baseUrl: g, | |
| isCompressed: m | |
| }), | |
| standardFontDataFactory: Q ? null : new A({ | |
| baseUrl: _ | |
| }) | |
| }; | |
| if (!u) { | |
| const St = { | |
| verbosity: d, | |
| port: qi.workerPort | |
| }; | |
| u = St.port ? La.fromPort(St) : new La(St), t._worker = u; | |
| } | |
| const vs = { | |
| docId: e, | |
| apiVersion: "4.10.38", | |
| data: i, | |
| password: l, | |
| disableAutoFetch: Y, | |
| rangeChunkSize: h, | |
| length: kt, | |
| docBaseUrl: f, | |
| enableXfa: Z, | |
| evaluatorOptions: { | |
| maxImageSize: E, | |
| disableFontFace: P, | |
| ignoreErrors: S, | |
| isEvalSupported: x, | |
| isOffscreenCanvasSupported: T, | |
| isImageDecoderSupported: k, | |
| canvasMaxAreaInBytes: C, | |
| fontExtraProperties: j, | |
| useSystemFonts: yt, | |
| cMapUrl: Q ? g : null, | |
| standardFontDataUrl: Q ? _ : null | |
| } | |
| }, Tt = { | |
| disableFontFace: P, | |
| fontExtraProperties: j, | |
| ownerDocument: V, | |
| pdfBug: xt, | |
| styleElement: Vt, | |
| loadingParams: { | |
| disableAutoFetch: Y, | |
| enableXfa: Z | |
| } | |
| }; | |
| return u.promise.then(function() { | |
| if (t.destroyed) | |
| throw new Error("Loading aborted"); | |
| if (u.destroyed) | |
| throw new Error("Worker was destroyed"); | |
| const St = u.messageHandler.sendWithPromise("GetDocRequest", vs, i ? [i.buffer] : null); | |
| let tt; | |
| if (c) | |
| tt = new mx(c, { | |
| disableRange: dt, | |
| disableStream: gt | |
| }); | |
| else if (!i) { | |
| if (!s) | |
| throw new Error("getDocument - no `url` parameter provided."); | |
| let Qt; | |
| if (Se) | |
| if (hl(s)) { | |
| if (typeof fetch > "u" || typeof Response > "u" || !("body" in Response.prototype)) | |
| throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`."); | |
| Qt = Yg; | |
| } else | |
| Qt = Ix; | |
| else | |
| Qt = hl(s) ? Yg : Ex; | |
| tt = new Qt({ | |
| url: s, | |
| length: kt, | |
| httpHeaders: r, | |
| withCredentials: a, | |
| rangeChunkSize: h, | |
| disableRange: dt, | |
| disableStream: gt | |
| }); | |
| } | |
| return St.then((Qt) => { | |
| if (t.destroyed) | |
| throw new Error("Loading aborted"); | |
| if (u.destroyed) | |
| throw new Error("Worker was destroyed"); | |
| const Vn = new pl(e, Qt, u.port), Gn = new Wx(Vn, t, tt, Tt, $t); | |
| t._transport = Gn, Vn.send("Ready", null); | |
| }); | |
| }).catch(t._capability.reject), t; | |
| } | |
| function Ux(n) { | |
| if (n instanceof URL) | |
| return n.href; | |
| try { | |
| return new URL(n, window.location).href; | |
| } catch { | |
| if (Se && typeof n == "string") | |
| return n; | |
| } | |
| throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property."); | |
| } | |
| function zx(n) { | |
| if (Se && typeof Buffer < "u" && n instanceof Buffer) | |
| throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`."); | |
| if (n instanceof Uint8Array && n.byteLength === n.buffer.byteLength) | |
| return n; | |
| if (typeof n == "string") | |
| return _d(n); | |
| if (n instanceof ArrayBuffer || ArrayBuffer.isView(n) || typeof n == "object" && !isNaN(n == null ? void 0 : n.length)) | |
| return new Uint8Array(n); | |
| throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property."); | |
| } | |
| function Kg(n) { | |
| return typeof n == "object" && Number.isInteger(n == null ? void 0 : n.num) && n.num >= 0 && Number.isInteger(n == null ? void 0 : n.gen) && n.gen >= 0; | |
| } | |
| var ed; | |
| const sd = class sd { | |
| constructor() { | |
| this._capability = Promise.withResolvers(), this._transport = null, this._worker = null, this.docId = `d${xe(sd, ed)._++}`, this.destroyed = !1, this.onPassword = null, this.onProgress = null; | |
| } | |
| get promise() { | |
| return this._capability.promise; | |
| } | |
| async destroy() { | |
| var t, e, s, i; | |
| this.destroyed = !0; | |
| try { | |
| (t = this._worker) != null && t.port && (this._worker._pendingDestroy = !0), await ((e = this._transport) == null ? void 0 : e.destroy()); | |
| } catch (r) { | |
| throw (s = this._worker) != null && s.port && delete this._worker._pendingDestroy, r; | |
| } | |
| this._transport = null, (i = this._worker) == null || i.destroy(), this._worker = null; | |
| } | |
| }; | |
| ed = new WeakMap(), b(sd, ed, 0); | |
| let zf = sd; | |
| class jb { | |
| constructor(t, e, s = !1, i = null) { | |
| this.length = t, this.initialData = e, this.progressiveDone = s, this.contentDispositionFilename = i, this._rangeListeners = [], this._progressListeners = [], this._progressiveReadListeners = [], this._progressiveDoneListeners = [], this._readyCapability = Promise.withResolvers(); | |
| } | |
| addRangeListener(t) { | |
| this._rangeListeners.push(t); | |
| } | |
| addProgressListener(t) { | |
| this._progressListeners.push(t); | |
| } | |
| addProgressiveReadListener(t) { | |
| this._progressiveReadListeners.push(t); | |
| } | |
| addProgressiveDoneListener(t) { | |
| this._progressiveDoneListeners.push(t); | |
| } | |
| onDataRange(t, e) { | |
| for (const s of this._rangeListeners) | |
| s(t, e); | |
| } | |
| onDataProgress(t, e) { | |
| this._readyCapability.promise.then(() => { | |
| for (const s of this._progressListeners) | |
| s(t, e); | |
| }); | |
| } | |
| onDataProgressiveRead(t) { | |
| this._readyCapability.promise.then(() => { | |
| for (const e of this._progressiveReadListeners) | |
| e(t); | |
| }); | |
| } | |
| onDataProgressiveDone() { | |
| this._readyCapability.promise.then(() => { | |
| for (const t of this._progressiveDoneListeners) | |
| t(); | |
| }); | |
| } | |
| transportReady() { | |
| this._readyCapability.resolve(); | |
| } | |
| requestDataRange(t, e) { | |
| Et("Abstract method PDFDataRangeTransport.requestDataRange"); | |
| } | |
| abort() { | |
| } | |
| } | |
| class Vx { | |
| constructor(t, e) { | |
| this._pdfInfo = t, this._transport = e; | |
| } | |
| get annotationStorage() { | |
| return this._transport.annotationStorage; | |
| } | |
| get canvasFactory() { | |
| return this._transport.canvasFactory; | |
| } | |
| get filterFactory() { | |
| return this._transport.filterFactory; | |
| } | |
| get numPages() { | |
| return this._pdfInfo.numPages; | |
| } | |
| get fingerprints() { | |
| return this._pdfInfo.fingerprints; | |
| } | |
| get isPureXfa() { | |
| return at(this, "isPureXfa", !!this._transport._htmlForXfa); | |
| } | |
| get allXfaHtml() { | |
| return this._transport._htmlForXfa; | |
| } | |
| getPage(t) { | |
| return this._transport.getPage(t); | |
| } | |
| getPageIndex(t) { | |
| return this._transport.getPageIndex(t); | |
| } | |
| getDestinations() { | |
| return this._transport.getDestinations(); | |
| } | |
| getDestination(t) { | |
| return this._transport.getDestination(t); | |
| } | |
| getPageLabels() { | |
| return this._transport.getPageLabels(); | |
| } | |
| getPageLayout() { | |
| return this._transport.getPageLayout(); | |
| } | |
| getPageMode() { | |
| return this._transport.getPageMode(); | |
| } | |
| getViewerPreferences() { | |
| return this._transport.getViewerPreferences(); | |
| } | |
| getOpenAction() { | |
| return this._transport.getOpenAction(); | |
| } | |
| getAttachments() { | |
| return this._transport.getAttachments(); | |
| } | |
| getJSActions() { | |
| return this._transport.getDocJSActions(); | |
| } | |
| getOutline() { | |
| return this._transport.getOutline(); | |
| } | |
| getOptionalContentConfig({ | |
| intent: t = "display" | |
| } = {}) { | |
| const { | |
| renderingIntent: e | |
| } = this._transport.getRenderingIntent(t); | |
| return this._transport.getOptionalContentConfig(e); | |
| } | |
| getPermissions() { | |
| return this._transport.getPermissions(); | |
| } | |
| getMetadata() { | |
| return this._transport.getMetadata(); | |
| } | |
| getMarkInfo() { | |
| return this._transport.getMarkInfo(); | |
| } | |
| getData() { | |
| return this._transport.getData(); | |
| } | |
| saveDocument() { | |
| return this._transport.saveDocument(); | |
| } | |
| getDownloadInfo() { | |
| return this._transport.downloadInfoCapability.promise; | |
| } | |
| cleanup(t = !1) { | |
| return this._transport.startCleanup(t || this.isPureXfa); | |
| } | |
| destroy() { | |
| return this.loadingTask.destroy(); | |
| } | |
| cachedPageNumber(t) { | |
| return this._transport.cachedPageNumber(t); | |
| } | |
| get loadingParams() { | |
| return this._transport.loadingParams; | |
| } | |
| get loadingTask() { | |
| return this._transport.loadingTask; | |
| } | |
| getFieldObjects() { | |
| return this._transport.getFieldObjects(); | |
| } | |
| hasJSActions() { | |
| return this._transport.hasJSActions(); | |
| } | |
| getCalculationOrderIds() { | |
| return this._transport.getCalculationOrderIds(); | |
| } | |
| } | |
| var _n, Pi, ms, Ca, iu; | |
| class Gx { | |
| constructor(t, e, s, i = !1) { | |
| b(this, ms); | |
| b(this, _n, null); | |
| b(this, Pi, !1); | |
| this._pageIndex = t, this._pageInfo = e, this._transport = s, this._stats = i ? new Fg() : null, this._pdfBug = i, this.commonObjs = s.commonObjs, this.objs = new Bb(), this._maybeCleanupAfterRender = !1, this._intentStates = /* @__PURE__ */ new Map(), this.destroyed = !1; | |
| } | |
| get pageNumber() { | |
| return this._pageIndex + 1; | |
| } | |
| get rotate() { | |
| return this._pageInfo.rotate; | |
| } | |
| get ref() { | |
| return this._pageInfo.ref; | |
| } | |
| get userUnit() { | |
| return this._pageInfo.userUnit; | |
| } | |
| get view() { | |
| return this._pageInfo.view; | |
| } | |
| getViewport({ | |
| scale: t, | |
| rotation: e = this.rotate, | |
| offsetX: s = 0, | |
| offsetY: i = 0, | |
| dontFlip: r = !1 | |
| } = {}) { | |
| return new Nh({ | |
| viewBox: this.view, | |
| userUnit: this.userUnit, | |
| scale: t, | |
| rotation: e, | |
| offsetX: s, | |
| offsetY: i, | |
| dontFlip: r | |
| }); | |
| } | |
| getAnnotations({ | |
| intent: t = "display" | |
| } = {}) { | |
| const { | |
| renderingIntent: e | |
| } = this._transport.getRenderingIntent(t); | |
| return this._transport.getAnnotations(this._pageIndex, e); | |
| } | |
| getJSActions() { | |
| return this._transport.getPageJSActions(this._pageIndex); | |
| } | |
| get filterFactory() { | |
| return this._transport.filterFactory; | |
| } | |
| get isPureXfa() { | |
| return at(this, "isPureXfa", !!this._transport._htmlForXfa); | |
| } | |
| async getXfa() { | |
| var t; | |
| return ((t = this._transport._htmlForXfa) == null ? void 0 : t.children[this._pageIndex]) || null; | |
| } | |
| render({ | |
| canvasContext: t, | |
| viewport: e, | |
| intent: s = "display", | |
| annotationMode: i = sn.ENABLE, | |
| transform: r = null, | |
| background: a = null, | |
| optionalContentConfigPromise: l = null, | |
| annotationCanvasMap: c = null, | |
| pageColors: h = null, | |
| printAnnotationStorage: u = null, | |
| isEditing: d = !1 | |
| }) { | |
| var x, T; | |
| (x = this._stats) == null || x.time("Overall"); | |
| const f = this._transport.getRenderingIntent(s, i, u, d), { | |
| renderingIntent: g, | |
| cacheKey: m | |
| } = f; | |
| p(this, Pi, !1), v(this, ms, iu).call(this), l || (l = this._transport.getOptionalContentConfig(g)); | |
| let y = this._intentStates.get(m); | |
| y || (y = /* @__PURE__ */ Object.create(null), this._intentStates.set(m, y)), y.streamReaderCancelTimeout && (clearTimeout(y.streamReaderCancelTimeout), y.streamReaderCancelTimeout = null); | |
| const _ = !!(g & ss.PRINT); | |
| y.displayReadyCapability || (y.displayReadyCapability = Promise.withResolvers(), y.operatorList = { | |
| fnArray: [], | |
| argsArray: [], | |
| lastChunk: !1, | |
| separateAnnots: null | |
| }, (T = this._stats) == null || T.time("Page Request"), this._pumpOperatorList(f)); | |
| const A = (k) => { | |
| var C; | |
| y.renderTasks.delete(S), (this._maybeCleanupAfterRender || _) && p(this, Pi, !0), v(this, ms, Ca).call(this, !_), k ? (S.capability.reject(k), this._abortOperatorList({ | |
| intentState: y, | |
| reason: k instanceof Error ? k : new Error(k) | |
| })) : S.capability.resolve(), this._stats && (this._stats.timeEnd("Rendering"), this._stats.timeEnd("Overall"), (C = globalThis.Stats) != null && C.enabled && globalThis.Stats.add(this.pageNumber, this._stats)); | |
| }, S = new Gf({ | |
| callback: A, | |
| params: { | |
| canvasContext: t, | |
| viewport: e, | |
| transform: r, | |
| background: a | |
| }, | |
| objs: this.objs, | |
| commonObjs: this.commonObjs, | |
| annotationCanvasMap: c, | |
| operatorList: y.operatorList, | |
| pageIndex: this._pageIndex, | |
| canvasFactory: this._transport.canvasFactory, | |
| filterFactory: this._transport.filterFactory, | |
| useRequestAnimationFrame: !_, | |
| pdfBug: this._pdfBug, | |
| pageColors: h | |
| }); | |
| (y.renderTasks || (y.renderTasks = /* @__PURE__ */ new Set())).add(S); | |
| const E = S.task; | |
| return Promise.all([y.displayReadyCapability.promise, l]).then(([k, C]) => { | |
| var P; | |
| if (this.destroyed) { | |
| A(); | |
| return; | |
| } | |
| if ((P = this._stats) == null || P.time("Rendering"), !(C.renderingIntent & g)) | |
| throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods."); | |
| S.initializeGraphics({ | |
| transparency: k, | |
| optionalContentConfig: C | |
| }), S.operatorListChanged(); | |
| }).catch(A), E; | |
| } | |
| getOperatorList({ | |
| intent: t = "display", | |
| annotationMode: e = sn.ENABLE, | |
| printAnnotationStorage: s = null, | |
| isEditing: i = !1 | |
| } = {}) { | |
| var h; | |
| function r() { | |
| l.operatorList.lastChunk && (l.opListReadCapability.resolve(l.operatorList), l.renderTasks.delete(c)); | |
| } | |
| const a = this._transport.getRenderingIntent(t, e, s, i, !0); | |
| let l = this._intentStates.get(a.cacheKey); | |
| l || (l = /* @__PURE__ */ Object.create(null), this._intentStates.set(a.cacheKey, l)); | |
| let c; | |
| return l.opListReadCapability || (c = /* @__PURE__ */ Object.create(null), c.operatorListChanged = r, l.opListReadCapability = Promise.withResolvers(), (l.renderTasks || (l.renderTasks = /* @__PURE__ */ new Set())).add(c), l.operatorList = { | |
| fnArray: [], | |
| argsArray: [], | |
| lastChunk: !1, | |
| separateAnnots: null | |
| }, (h = this._stats) == null || h.time("Page Request"), this._pumpOperatorList(a)), l.opListReadCapability.promise; | |
| } | |
| streamTextContent({ | |
| includeMarkedContent: t = !1, | |
| disableNormalization: e = !1 | |
| } = {}) { | |
| return this._transport.messageHandler.sendWithStream("GetTextContent", { | |
| pageIndex: this._pageIndex, | |
| includeMarkedContent: t === !0, | |
| disableNormalization: e === !0 | |
| }, { | |
| highWaterMark: 100, | |
| size(i) { | |
| return i.items.length; | |
| } | |
| }); | |
| } | |
| getTextContent(t = {}) { | |
| if (this._transport._htmlForXfa) | |
| return this.getXfa().then((s) => rc.textContent(s)); | |
| const e = this.streamTextContent(t); | |
| return new Promise(function(s, i) { | |
| function r() { | |
| a.read().then(function({ | |
| value: c, | |
| done: h | |
| }) { | |
| if (h) { | |
| s(l); | |
| return; | |
| } | |
| l.lang ?? (l.lang = c.lang), Object.assign(l.styles, c.styles), l.items.push(...c.items), r(); | |
| }, i); | |
| } | |
| const a = e.getReader(), l = { | |
| items: [], | |
| styles: /* @__PURE__ */ Object.create(null), | |
| lang: null | |
| }; | |
| r(); | |
| }); | |
| } | |
| getStructTree() { | |
| return this._transport.getStructTree(this._pageIndex); | |
| } | |
| _destroy() { | |
| this.destroyed = !0; | |
| const t = []; | |
| for (const e of this._intentStates.values()) | |
| if (this._abortOperatorList({ | |
| intentState: e, | |
| reason: new Error("Page was destroyed."), | |
| force: !0 | |
| }), !e.opListReadCapability) | |
| for (const s of e.renderTasks) | |
| t.push(s.completed), s.cancel(); | |
| return this.objs.clear(), p(this, Pi, !1), v(this, ms, iu).call(this), Promise.all(t); | |
| } | |
| cleanup(t = !1) { | |
| p(this, Pi, !0); | |
| const e = v(this, ms, Ca).call(this, !1); | |
| return t && e && this._stats && (this._stats = new Fg()), e; | |
| } | |
| _startRenderPage(t, e) { | |
| var i, r; | |
| const s = this._intentStates.get(e); | |
| s && ((i = this._stats) == null || i.timeEnd("Page Request"), (r = s.displayReadyCapability) == null || r.resolve(t)); | |
| } | |
| _renderPageChunk(t, e) { | |
| for (let s = 0, i = t.length; s < i; s++) | |
| e.operatorList.fnArray.push(t.fnArray[s]), e.operatorList.argsArray.push(t.argsArray[s]); | |
| e.operatorList.lastChunk = t.lastChunk, e.operatorList.separateAnnots = t.separateAnnots; | |
| for (const s of e.renderTasks) | |
| s.operatorListChanged(); | |
| t.lastChunk && v(this, ms, Ca).call(this, !0); | |
| } | |
| _pumpOperatorList({ | |
| renderingIntent: t, | |
| cacheKey: e, | |
| annotationStorageSerializable: s, | |
| modifiedIds: i | |
| }) { | |
| const { | |
| map: r, | |
| transfer: a | |
| } = s, c = this._transport.messageHandler.sendWithStream("GetOperatorList", { | |
| pageIndex: this._pageIndex, | |
| intent: t, | |
| cacheKey: e, | |
| annotationStorage: r, | |
| modifiedIds: i | |
| }, a).getReader(), h = this._intentStates.get(e); | |
| h.streamReader = c; | |
| const u = () => { | |
| c.read().then(({ | |
| value: d, | |
| done: f | |
| }) => { | |
| if (f) { | |
| h.streamReader = null; | |
| return; | |
| } | |
| this._transport.destroyed || (this._renderPageChunk(d, h), u()); | |
| }, (d) => { | |
| if (h.streamReader = null, !this._transport.destroyed) { | |
| if (h.operatorList) { | |
| h.operatorList.lastChunk = !0; | |
| for (const f of h.renderTasks) | |
| f.operatorListChanged(); | |
| v(this, ms, Ca).call(this, !0); | |
| } | |
| if (h.displayReadyCapability) | |
| h.displayReadyCapability.reject(d); | |
| else if (h.opListReadCapability) | |
| h.opListReadCapability.reject(d); | |
| else | |
| throw d; | |
| } | |
| }); | |
| }; | |
| u(); | |
| } | |
| _abortOperatorList({ | |
| intentState: t, | |
| reason: e, | |
| force: s = !1 | |
| }) { | |
| if (t.streamReader) { | |
| if (t.streamReaderCancelTimeout && (clearTimeout(t.streamReaderCancelTimeout), t.streamReaderCancelTimeout = null), !s) { | |
| if (t.renderTasks.size > 0) | |
| return; | |
| if (e instanceof Up) { | |
| let i = Lx; | |
| e.extraDelay > 0 && e.extraDelay < 1e3 && (i += e.extraDelay), t.streamReaderCancelTimeout = setTimeout(() => { | |
| t.streamReaderCancelTimeout = null, this._abortOperatorList({ | |
| intentState: t, | |
| reason: e, | |
| force: !0 | |
| }); | |
| }, i); | |
| return; | |
| } | |
| } | |
| if (t.streamReader.cancel(new Bn(e.message)).catch(() => { | |
| }), t.streamReader = null, !this._transport.destroyed) { | |
| for (const [i, r] of this._intentStates) | |
| if (r === t) { | |
| this._intentStates.delete(i); | |
| break; | |
| } | |
| this.cleanup(); | |
| } | |
| } | |
| } | |
| get stats() { | |
| return this._stats; | |
| } | |
| } | |
| _n = new WeakMap(), Pi = new WeakMap(), ms = new WeakSet(), Ca = function(t = !1) { | |
| if (v(this, ms, iu).call(this), !o(this, Pi) || this.destroyed) | |
| return !1; | |
| if (t) | |
| return p(this, _n, setTimeout(() => { | |
| p(this, _n, null), v(this, ms, Ca).call(this, !1); | |
| }, Dx)), !1; | |
| for (const { | |
| renderTasks: e, | |
| operatorList: s | |
| } of this._intentStates.values()) | |
| if (e.size > 0 || !s.lastChunk) | |
| return !1; | |
| return this._intentStates.clear(), this.objs.clear(), p(this, Pi, !1), !0; | |
| }, iu = function() { | |
| o(this, _n) && (clearTimeout(o(this, _n)), p(this, _n, null)); | |
| }; | |
| var Mi, id; | |
| class qx { | |
| constructor() { | |
| b(this, Mi, /* @__PURE__ */ new Map()); | |
| b(this, id, Promise.resolve()); | |
| } | |
| postMessage(t, e) { | |
| const s = { | |
| data: structuredClone(t, e ? { | |
| transfer: e | |
| } : null) | |
| }; | |
| o(this, id).then(() => { | |
| for (const [i] of o(this, Mi)) | |
| i.call(this, s); | |
| }); | |
| } | |
| addEventListener(t, e, s = null) { | |
| let i = null; | |
| if ((s == null ? void 0 : s.signal) instanceof AbortSignal) { | |
| const { | |
| signal: r | |
| } = s; | |
| if (r.aborted) { | |
| st("LoopbackPort - cannot use an `aborted` signal."); | |
| return; | |
| } | |
| const a = () => this.removeEventListener(t, e); | |
| i = () => r.removeEventListener("abort", a), r.addEventListener("abort", a); | |
| } | |
| o(this, Mi).set(e, i); | |
| } | |
| removeEventListener(t, e) { | |
| const s = o(this, Mi).get(e); | |
| s == null || s(), o(this, Mi).delete(e); | |
| } | |
| terminate() { | |
| for (const [, t] of o(this, Mi)) | |
| t == null || t(); | |
| o(this, Mi).clear(); | |
| } | |
| } | |
| Mi = new WeakMap(), id = new WeakMap(); | |
| var nd, Mr, Nr, oo, nu, lo, ru; | |
| const Pt = class Pt { | |
| constructor({ | |
| name: t = null, | |
| port: e = null, | |
| verbosity: s = CE() | |
| } = {}) { | |
| b(this, oo); | |
| var i; | |
| if (this.name = t, this.destroyed = !1, this.verbosity = s, this._readyCapability = Promise.withResolvers(), this._port = null, this._webWorker = null, this._messageHandler = null, e) { | |
| if ((i = o(Pt, Nr)) != null && i.has(e)) | |
| throw new Error("Cannot use more than one PDFWorker per port."); | |
| (o(Pt, Nr) || p(Pt, Nr, /* @__PURE__ */ new WeakMap())).set(e, this), this._initializeFromPort(e); | |
| return; | |
| } | |
| this._initialize(); | |
| } | |
| get promise() { | |
| return this._readyCapability.promise; | |
| } | |
| get port() { | |
| return this._port; | |
| } | |
| get messageHandler() { | |
| return this._messageHandler; | |
| } | |
| _initializeFromPort(t) { | |
| this._port = t, this._messageHandler = new pl("main", "worker", t), this._messageHandler.on("ready", function() { | |
| }), v(this, oo, nu).call(this); | |
| } | |
| _initialize() { | |
| if (o(Pt, Mr) || o(Pt, lo, ru)) { | |
| this._setupFakeWorker(); | |
| return; | |
| } | |
| let { | |
| workerSrc: t | |
| } = Pt; | |
| try { | |
| Pt._isSameOrigin(window.location.href, t) || (t = Pt._createCDNWrapper(new URL(t, window.location).href)); | |
| const e = new Worker(t, { | |
| type: "module" | |
| }), s = new pl("main", "worker", e), i = () => { | |
| r.abort(), s.destroy(), e.terminate(), this.destroyed ? this._readyCapability.reject(new Error("Worker was destroyed")) : this._setupFakeWorker(); | |
| }, r = new AbortController(); | |
| e.addEventListener("error", () => { | |
| this._webWorker || i(); | |
| }, { | |
| signal: r.signal | |
| }), s.on("test", (l) => { | |
| if (r.abort(), this.destroyed || !l) { | |
| i(); | |
| return; | |
| } | |
| this._messageHandler = s, this._port = e, this._webWorker = e, v(this, oo, nu).call(this); | |
| }), s.on("ready", (l) => { | |
| if (r.abort(), this.destroyed) { | |
| i(); | |
| return; | |
| } | |
| try { | |
| a(); | |
| } catch { | |
| this._setupFakeWorker(); | |
| } | |
| }); | |
| const a = () => { | |
| const l = new Uint8Array(); | |
| s.send("test", l, [l.buffer]); | |
| }; | |
| a(); | |
| return; | |
| } catch { | |
| vd("The worker has been disabled."); | |
| } | |
| this._setupFakeWorker(); | |
| } | |
| _setupFakeWorker() { | |
| o(Pt, Mr) || (st("Setting up fake worker."), p(Pt, Mr, !0)), Pt._setupFakeWorkerGlobal.then((t) => { | |
| if (this.destroyed) { | |
| this._readyCapability.reject(new Error("Worker was destroyed")); | |
| return; | |
| } | |
| const e = new qx(); | |
| this._port = e; | |
| const s = `fake${xe(Pt, nd)._++}`, i = new pl(s + "_worker", s, e); | |
| t.setup(i, e), this._messageHandler = new pl(s, s + "_worker", e), v(this, oo, nu).call(this); | |
| }).catch((t) => { | |
| this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`)); | |
| }); | |
| } | |
| destroy() { | |
| var t, e, s; | |
| this.destroyed = !0, (t = this._webWorker) == null || t.terminate(), this._webWorker = null, (e = o(Pt, Nr)) == null || e.delete(this._port), this._port = null, (s = this._messageHandler) == null || s.destroy(), this._messageHandler = null; | |
| } | |
| static fromPort(t) { | |
| var s; | |
| if (!(t != null && t.port)) | |
| throw new Error("PDFWorker.fromPort - invalid method signature."); | |
| const e = (s = o(this, Nr)) == null ? void 0 : s.get(t.port); | |
| if (e) { | |
| if (e._pendingDestroy) | |
| throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls."); | |
| return e; | |
| } | |
| return new Pt(t); | |
| } | |
| static get workerSrc() { | |
| if (qi.workerSrc) | |
| return qi.workerSrc; | |
| throw new Error('No "GlobalWorkerOptions.workerSrc" specified.'); | |
| } | |
| static get _setupFakeWorkerGlobal() { | |
| return at(this, "_setupFakeWorkerGlobal", (async () => o(this, lo, ru) ? o(this, lo, ru) : (await import( | |
| /*webpackIgnore: true*/ | |
| this.workerSrc | |
| )).WorkerMessageHandler)()); | |
| } | |
| }; | |
| nd = new WeakMap(), Mr = new WeakMap(), Nr = new WeakMap(), oo = new WeakSet(), nu = function() { | |
| this._readyCapability.resolve(), this._messageHandler.send("configure", { | |
| verbosity: this.verbosity | |
| }); | |
| }, lo = new WeakSet(), ru = function() { | |
| var t; | |
| try { | |
| return ((t = globalThis.pdfjsWorker) == null ? void 0 : t.WorkerMessageHandler) || null; | |
| } catch { | |
| return null; | |
| } | |
| }, b(Pt, lo), b(Pt, nd, 0), b(Pt, Mr, !1), b(Pt, Nr), Se && (p(Pt, Mr, !0), qi.workerSrc || (qi.workerSrc = "./pdf.worker.mjs")), Pt._isSameOrigin = (t, e) => { | |
| let s; | |
| try { | |
| if (s = new URL(t), !s.origin || s.origin === "null") | |
| return !1; | |
| } catch { | |
| return !1; | |
| } | |
| const i = new URL(e, s); | |
| return s.origin === i.origin; | |
| }, Pt._createCDNWrapper = (t) => { | |
| const e = `await import("${t}");`; | |
| return URL.createObjectURL(new Blob([e], { | |
| type: "text/javascript" | |
| })); | |
| }; | |
| let La = Pt; | |
| var Ni, si, co, ho, Oi, Or, vl; | |
| class Wx { | |
| constructor(t, e, s, i, r) { | |
| b(this, Or); | |
| b(this, Ni, /* @__PURE__ */ new Map()); | |
| b(this, si, /* @__PURE__ */ new Map()); | |
| b(this, co, /* @__PURE__ */ new Map()); | |
| b(this, ho, /* @__PURE__ */ new Map()); | |
| b(this, Oi, null); | |
| this.messageHandler = t, this.loadingTask = e, this.commonObjs = new Bb(), this.fontLoader = new qE({ | |
| ownerDocument: i.ownerDocument, | |
| styleElement: i.styleElement | |
| }), this.loadingParams = i.loadingParams, this._params = i, this.canvasFactory = r.canvasFactory, this.filterFactory = r.filterFactory, this.cMapReaderFactory = r.cMapReaderFactory, this.standardFontDataFactory = r.standardFontDataFactory, this.destroyed = !1, this.destroyCapability = null, this._networkStream = s, this._fullReader = null, this._lastProgress = null, this.downloadInfoCapability = Promise.withResolvers(), this.setupMessageHandler(); | |
| } | |
| get annotationStorage() { | |
| return at(this, "annotationStorage", new qp()); | |
| } | |
| getRenderingIntent(t, e = sn.ENABLE, s = null, i = !1, r = !1) { | |
| let a = ss.DISPLAY, l = Mf; | |
| switch (t) { | |
| case "any": | |
| a = ss.ANY; | |
| break; | |
| case "display": | |
| break; | |
| case "print": | |
| a = ss.PRINT; | |
| break; | |
| default: | |
| st(`getRenderingIntent - invalid intent: ${t}`); | |
| } | |
| const c = a & ss.PRINT && s instanceof yb ? s : this.annotationStorage; | |
| switch (e) { | |
| case sn.DISABLE: | |
| a += ss.ANNOTATIONS_DISABLE; | |
| break; | |
| case sn.ENABLE: | |
| break; | |
| case sn.ENABLE_FORMS: | |
| a += ss.ANNOTATIONS_FORMS; | |
| break; | |
| case sn.ENABLE_STORAGE: | |
| a += ss.ANNOTATIONS_STORAGE, l = c.serializable; | |
| break; | |
| default: | |
| st(`getRenderingIntent - invalid annotationMode: ${e}`); | |
| } | |
| i && (a += ss.IS_EDITING), r && (a += ss.OPLIST); | |
| const { | |
| ids: h, | |
| hash: u | |
| } = c.modifiedIds, d = [a, l.hash, u]; | |
| return { | |
| renderingIntent: a, | |
| cacheKey: d.join("_"), | |
| annotationStorageSerializable: l, | |
| modifiedIds: h | |
| }; | |
| } | |
| destroy() { | |
| var s; | |
| if (this.destroyCapability) | |
| return this.destroyCapability.promise; | |
| this.destroyed = !0, this.destroyCapability = Promise.withResolvers(), (s = o(this, Oi)) == null || s.reject(new Error("Worker was destroyed during onPassword callback")); | |
| const t = []; | |
| for (const i of o(this, si).values()) | |
| t.push(i._destroy()); | |
| o(this, si).clear(), o(this, co).clear(), o(this, ho).clear(), this.hasOwnProperty("annotationStorage") && this.annotationStorage.resetModified(); | |
| const e = this.messageHandler.sendWithPromise("Terminate", null); | |
| return t.push(e), Promise.all(t).then(() => { | |
| var i, r; | |
| this.commonObjs.clear(), this.fontLoader.clear(), o(this, Ni).clear(), this.filterFactory.destroy(), nc.cleanup(), (i = this._networkStream) == null || i.cancelAllRequests(new Bn("Worker was terminated.")), (r = this.messageHandler) == null || r.destroy(), this.messageHandler = null, this.destroyCapability.resolve(); | |
| }, this.destroyCapability.reject), this.destroyCapability.promise; | |
| } | |
| setupMessageHandler() { | |
| const { | |
| messageHandler: t, | |
| loadingTask: e | |
| } = this; | |
| t.on("GetReader", (s, i) => { | |
| qt(this._networkStream, "GetReader - no `IPDFStream` instance available."), this._fullReader = this._networkStream.getFullReader(), this._fullReader.onProgress = (r) => { | |
| this._lastProgress = { | |
| loaded: r.loaded, | |
| total: r.total | |
| }; | |
| }, i.onPull = () => { | |
| this._fullReader.read().then(function({ | |
| value: r, | |
| done: a | |
| }) { | |
| if (a) { | |
| i.close(); | |
| return; | |
| } | |
| qt(r instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer."), i.enqueue(new Uint8Array(r), 1, [r]); | |
| }).catch((r) => { | |
| i.error(r); | |
| }); | |
| }, i.onCancel = (r) => { | |
| this._fullReader.cancel(r), i.ready.catch((a) => { | |
| if (!this.destroyed) | |
| throw a; | |
| }); | |
| }; | |
| }), t.on("ReaderHeadersReady", async (s) => { | |
| var l; | |
| await this._fullReader.headersReady; | |
| const { | |
| isStreamingSupported: i, | |
| isRangeSupported: r, | |
| contentLength: a | |
| } = this._fullReader; | |
| return (!i || !r) && (this._lastProgress && ((l = e.onProgress) == null || l.call(e, this._lastProgress)), this._fullReader.onProgress = (c) => { | |
| var h; | |
| (h = e.onProgress) == null || h.call(e, { | |
| loaded: c.loaded, | |
| total: c.total | |
| }); | |
| }), { | |
| isStreamingSupported: i, | |
| isRangeSupported: r, | |
| contentLength: a | |
| }; | |
| }), t.on("GetRangeReader", (s, i) => { | |
| qt(this._networkStream, "GetRangeReader - no `IPDFStream` instance available."); | |
| const r = this._networkStream.getRangeReader(s.begin, s.end); | |
| if (!r) { | |
| i.close(); | |
| return; | |
| } | |
| i.onPull = () => { | |
| r.read().then(function({ | |
| value: a, | |
| done: l | |
| }) { | |
| if (l) { | |
| i.close(); | |
| return; | |
| } | |
| qt(a instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer."), i.enqueue(new Uint8Array(a), 1, [a]); | |
| }).catch((a) => { | |
| i.error(a); | |
| }); | |
| }, i.onCancel = (a) => { | |
| r.cancel(a), i.ready.catch((l) => { | |
| if (!this.destroyed) | |
| throw l; | |
| }); | |
| }; | |
| }), t.on("GetDoc", ({ | |
| pdfInfo: s | |
| }) => { | |
| this._numPages = s.numPages, this._htmlForXfa = s.htmlForXfa, delete s.htmlForXfa, e._capability.resolve(new Vx(s, this)); | |
| }), t.on("DocException", (s) => { | |
| e._capability.reject(Fe(s)); | |
| }), t.on("PasswordRequest", (s) => { | |
| p(this, Oi, Promise.withResolvers()); | |
| try { | |
| if (!e.onPassword) | |
| throw Fe(s); | |
| const i = (r) => { | |
| r instanceof Error ? o(this, Oi).reject(r) : o(this, Oi).resolve({ | |
| password: r | |
| }); | |
| }; | |
| e.onPassword(i, s.code); | |
| } catch (i) { | |
| o(this, Oi).reject(i); | |
| } | |
| return o(this, Oi).promise; | |
| }), t.on("DataLoaded", (s) => { | |
| var i; | |
| (i = e.onProgress) == null || i.call(e, { | |
| loaded: s.length, | |
| total: s.length | |
| }), this.downloadInfoCapability.resolve(s); | |
| }), t.on("StartRenderPage", (s) => { | |
| if (this.destroyed) | |
| return; | |
| o(this, si).get(s.pageIndex)._startRenderPage(s.transparency, s.cacheKey); | |
| }), t.on("commonobj", ([s, i, r]) => { | |
| var a; | |
| if (this.destroyed || this.commonObjs.has(s)) | |
| return null; | |
| switch (i) { | |
| case "Font": | |
| const { | |
| disableFontFace: l, | |
| fontExtraProperties: c, | |
| pdfBug: h | |
| } = this._params; | |
| if ("error" in r) { | |
| const g = r.error; | |
| st(`Error during font loading: ${g}`), this.commonObjs.resolve(s, g); | |
| break; | |
| } | |
| const u = h && ((a = globalThis.FontInspector) != null && a.enabled) ? (g, m) => globalThis.FontInspector.fontAdded(g, m) : null, d = new WE(r, { | |
| disableFontFace: l, | |
| fontExtraProperties: c, | |
| inspectFont: u | |
| }); | |
| this.fontLoader.bind(d).catch(() => t.sendWithPromise("FontFallback", { | |
| id: s | |
| })).finally(() => { | |
| !c && d.data && (d.data = null), this.commonObjs.resolve(s, d); | |
| }); | |
| break; | |
| case "CopyLocalImage": | |
| const { | |
| imageRef: f | |
| } = r; | |
| qt(f, "The imageRef must be defined."); | |
| for (const g of o(this, si).values()) | |
| for (const [, m] of g.objs) | |
| if ((m == null ? void 0 : m.ref) === f) | |
| return m.dataLen ? (this.commonObjs.resolve(s, structuredClone(m)), m.dataLen) : null; | |
| break; | |
| case "FontPath": | |
| case "Image": | |
| case "Pattern": | |
| this.commonObjs.resolve(s, r); | |
| break; | |
| default: | |
| throw new Error(`Got unknown common object type ${i}`); | |
| } | |
| return null; | |
| }), t.on("obj", ([s, i, r, a]) => { | |
| var c; | |
| if (this.destroyed) | |
| return; | |
| const l = o(this, si).get(i); | |
| if (!l.objs.has(s)) { | |
| if (l._intentStates.size === 0) { | |
| (c = a == null ? void 0 : a.bitmap) == null || c.close(); | |
| return; | |
| } | |
| switch (r) { | |
| case "Image": | |
| l.objs.resolve(s, a), (a == null ? void 0 : a.dataLen) > wE && (l._maybeCleanupAfterRender = !0); | |
| break; | |
| case "Pattern": | |
| l.objs.resolve(s, a); | |
| break; | |
| default: | |
| throw new Error(`Got unknown object type ${r}`); | |
| } | |
| } | |
| }), t.on("DocProgress", (s) => { | |
| var i; | |
| this.destroyed || (i = e.onProgress) == null || i.call(e, { | |
| loaded: s.loaded, | |
| total: s.total | |
| }); | |
| }), t.on("FetchBuiltInCMap", async (s) => { | |
| if (this.destroyed) | |
| throw new Error("Worker was destroyed."); | |
| if (!this.cMapReaderFactory) | |
| throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."); | |
| return this.cMapReaderFactory.fetch(s); | |
| }), t.on("FetchStandardFontData", async (s) => { | |
| if (this.destroyed) | |
| throw new Error("Worker was destroyed."); | |
| if (!this.standardFontDataFactory) | |
| throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."); | |
| return this.standardFontDataFactory.fetch(s); | |
| }); | |
| } | |
| getData() { | |
| return this.messageHandler.sendWithPromise("GetData", null); | |
| } | |
| saveDocument() { | |
| var s; | |
| this.annotationStorage.size <= 0 && st("saveDocument called while `annotationStorage` is empty, please use the getData-method instead."); | |
| const { | |
| map: t, | |
| transfer: e | |
| } = this.annotationStorage.serializable; | |
| return this.messageHandler.sendWithPromise("SaveDocument", { | |
| isPureXfa: !!this._htmlForXfa, | |
| numPages: this._numPages, | |
| annotationStorage: t, | |
| filename: ((s = this._fullReader) == null ? void 0 : s.filename) ?? null | |
| }, e).finally(() => { | |
| this.annotationStorage.resetModified(); | |
| }); | |
| } | |
| getPage(t) { | |
| if (!Number.isInteger(t) || t <= 0 || t > this._numPages) | |
| return Promise.reject(new Error("Invalid page request.")); | |
| const e = t - 1, s = o(this, co).get(e); | |
| if (s) | |
| return s; | |
| const i = this.messageHandler.sendWithPromise("GetPage", { | |
| pageIndex: e | |
| }).then((r) => { | |
| if (this.destroyed) | |
| throw new Error("Transport destroyed"); | |
| r.refStr && o(this, ho).set(r.refStr, t); | |
| const a = new Gx(e, r, this, this._params.pdfBug); | |
| return o(this, si).set(e, a), a; | |
| }); | |
| return o(this, co).set(e, i), i; | |
| } | |
| getPageIndex(t) { | |
| return Kg(t) ? this.messageHandler.sendWithPromise("GetPageIndex", { | |
| num: t.num, | |
| gen: t.gen | |
| }) : Promise.reject(new Error("Invalid pageIndex request.")); | |
| } | |
| getAnnotations(t, e) { | |
| return this.messageHandler.sendWithPromise("GetAnnotations", { | |
| pageIndex: t, | |
| intent: e | |
| }); | |
| } | |
| getFieldObjects() { | |
| return v(this, Or, vl).call(this, "GetFieldObjects"); | |
| } | |
| hasJSActions() { | |
| return v(this, Or, vl).call(this, "HasJSActions"); | |
| } | |
| getCalculationOrderIds() { | |
| return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null); | |
| } | |
| getDestinations() { | |
| return this.messageHandler.sendWithPromise("GetDestinations", null); | |
| } | |
| getDestination(t) { | |
| return typeof t != "string" ? Promise.reject(new Error("Invalid destination request.")) : this.messageHandler.sendWithPromise("GetDestination", { | |
| id: t | |
| }); | |
| } | |
| getPageLabels() { | |
| return this.messageHandler.sendWithPromise("GetPageLabels", null); | |
| } | |
| getPageLayout() { | |
| return this.messageHandler.sendWithPromise("GetPageLayout", null); | |
| } | |
| getPageMode() { | |
| return this.messageHandler.sendWithPromise("GetPageMode", null); | |
| } | |
| getViewerPreferences() { | |
| return this.messageHandler.sendWithPromise("GetViewerPreferences", null); | |
| } | |
| getOpenAction() { | |
| return this.messageHandler.sendWithPromise("GetOpenAction", null); | |
| } | |
| getAttachments() { | |
| return this.messageHandler.sendWithPromise("GetAttachments", null); | |
| } | |
| getDocJSActions() { | |
| return v(this, Or, vl).call(this, "GetDocJSActions"); | |
| } | |
| getPageJSActions(t) { | |
| return this.messageHandler.sendWithPromise("GetPageJSActions", { | |
| pageIndex: t | |
| }); | |
| } | |
| getStructTree(t) { | |
| return this.messageHandler.sendWithPromise("GetStructTree", { | |
| pageIndex: t | |
| }); | |
| } | |
| getOutline() { | |
| return this.messageHandler.sendWithPromise("GetOutline", null); | |
| } | |
| getOptionalContentConfig(t) { | |
| return v(this, Or, vl).call(this, "GetOptionalContentConfig").then((e) => new gx(e, t)); | |
| } | |
| getPermissions() { | |
| return this.messageHandler.sendWithPromise("GetPermissions", null); | |
| } | |
| getMetadata() { | |
| const t = "GetMetadata", e = o(this, Ni).get(t); | |
| if (e) | |
| return e; | |
| const s = this.messageHandler.sendWithPromise(t, null).then((i) => { | |
| var r, a; | |
| return { | |
| info: i[0], | |
| metadata: i[1] ? new fx(i[1]) : null, | |
| contentDispositionFilename: ((r = this._fullReader) == null ? void 0 : r.filename) ?? null, | |
| contentLength: ((a = this._fullReader) == null ? void 0 : a.contentLength) ?? null | |
| }; | |
| }); | |
| return o(this, Ni).set(t, s), s; | |
| } | |
| getMarkInfo() { | |
| return this.messageHandler.sendWithPromise("GetMarkInfo", null); | |
| } | |
| async startCleanup(t = !1) { | |
| if (!this.destroyed) { | |
| await this.messageHandler.sendWithPromise("Cleanup", null); | |
| for (const e of o(this, si).values()) | |
| if (!e.cleanup()) | |
| throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`); | |
| this.commonObjs.clear(), t || this.fontLoader.clear(), o(this, Ni).clear(), this.filterFactory.destroy(!0), nc.cleanup(); | |
| } | |
| } | |
| cachedPageNumber(t) { | |
| if (!Kg(t)) | |
| return null; | |
| const e = t.gen === 0 ? `${t.num}R` : `${t.num}R${t.gen}`; | |
| return o(this, ho).get(e) ?? null; | |
| } | |
| } | |
| Ni = new WeakMap(), si = new WeakMap(), co = new WeakMap(), ho = new WeakMap(), Oi = new WeakMap(), Or = new WeakSet(), vl = function(t, e = null) { | |
| const s = o(this, Ni).get(t); | |
| if (s) | |
| return s; | |
| const i = this.messageHandler.sendWithPromise(t, e); | |
| return o(this, Ni).set(t, i), i; | |
| }; | |
| const al = Symbol("INITIAL_DATA"); | |
| var qe, Zc, Vf; | |
| class Bb { | |
| constructor() { | |
| b(this, Zc); | |
| b(this, qe, /* @__PURE__ */ Object.create(null)); | |
| } | |
| get(t, e = null) { | |
| if (e) { | |
| const i = v(this, Zc, Vf).call(this, t); | |
| return i.promise.then(() => e(i.data)), null; | |
| } | |
| const s = o(this, qe)[t]; | |
| if (!s || s.data === al) | |
| throw new Error(`Requesting object that isn't resolved yet ${t}.`); | |
| return s.data; | |
| } | |
| has(t) { | |
| const e = o(this, qe)[t]; | |
| return !!e && e.data !== al; | |
| } | |
| delete(t) { | |
| const e = o(this, qe)[t]; | |
| return !e || e.data === al ? !1 : (delete o(this, qe)[t], !0); | |
| } | |
| resolve(t, e = null) { | |
| const s = v(this, Zc, Vf).call(this, t); | |
| s.data = e, s.resolve(); | |
| } | |
| clear() { | |
| var t; | |
| for (const e in o(this, qe)) { | |
| const { | |
| data: s | |
| } = o(this, qe)[e]; | |
| (t = s == null ? void 0 : s.bitmap) == null || t.close(); | |
| } | |
| p(this, qe, /* @__PURE__ */ Object.create(null)); | |
| } | |
| *[Symbol.iterator]() { | |
| for (const t in o(this, qe)) { | |
| const { | |
| data: e | |
| } = o(this, qe)[t]; | |
| e !== al && (yield [t, e]); | |
| } | |
| } | |
| } | |
| qe = new WeakMap(), Zc = new WeakSet(), Vf = function(t) { | |
| var e; | |
| return (e = o(this, qe))[t] || (e[t] = { | |
| ...Promise.withResolvers(), | |
| data: al | |
| }); | |
| }; | |
| var An; | |
| class Xx { | |
| constructor(t) { | |
| b(this, An, null); | |
| p(this, An, t), this.onContinue = null; | |
| } | |
| get promise() { | |
| return o(this, An).capability.promise; | |
| } | |
| cancel(t = 0) { | |
| o(this, An).cancel(null, t); | |
| } | |
| get separateAnnots() { | |
| const { | |
| separateAnnots: t | |
| } = o(this, An).operatorList; | |
| if (!t) | |
| return !1; | |
| const { | |
| annotationCanvasMap: e | |
| } = o(this, An); | |
| return t.form || t.canvas && (e == null ? void 0 : e.size) > 0; | |
| } | |
| } | |
| An = new WeakMap(); | |
| var wn, Lr; | |
| const tr = class tr { | |
| constructor({ | |
| callback: t, | |
| params: e, | |
| objs: s, | |
| commonObjs: i, | |
| annotationCanvasMap: r, | |
| operatorList: a, | |
| pageIndex: l, | |
| canvasFactory: c, | |
| filterFactory: h, | |
| useRequestAnimationFrame: u = !1, | |
| pdfBug: d = !1, | |
| pageColors: f = null | |
| }) { | |
| b(this, wn, null); | |
| this.callback = t, this.params = e, this.objs = s, this.commonObjs = i, this.annotationCanvasMap = r, this.operatorListIdx = null, this.operatorList = a, this._pageIndex = l, this.canvasFactory = c, this.filterFactory = h, this._pdfBug = d, this.pageColors = f, this.running = !1, this.graphicsReadyCallback = null, this.graphicsReady = !1, this._useRequestAnimationFrame = u === !0 && typeof window < "u", this.cancelled = !1, this.capability = Promise.withResolvers(), this.task = new Xx(this), this._cancelBound = this.cancel.bind(this), this._continueBound = this._continue.bind(this), this._scheduleNextBound = this._scheduleNext.bind(this), this._nextBound = this._next.bind(this), this._canvas = e.canvasContext.canvas; | |
| } | |
| get completed() { | |
| return this.capability.promise.catch(function() { | |
| }); | |
| } | |
| initializeGraphics({ | |
| transparency: t = !1, | |
| optionalContentConfig: e | |
| }) { | |
| var l, c; | |
| if (this.cancelled) | |
| return; | |
| if (this._canvas) { | |
| if (o(tr, Lr).has(this._canvas)) | |
| throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed."); | |
| o(tr, Lr).add(this._canvas); | |
| } | |
| this._pdfBug && ((l = globalThis.StepperManager) != null && l.enabled) && (this.stepper = globalThis.StepperManager.create(this._pageIndex), this.stepper.init(this.operatorList), this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint()); | |
| const { | |
| canvasContext: s, | |
| viewport: i, | |
| transform: r, | |
| background: a | |
| } = this.params; | |
| this.gfx = new Oa(s, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, { | |
| optionalContentConfig: e | |
| }, this.annotationCanvasMap, this.pageColors), this.gfx.beginDrawing({ | |
| transform: r, | |
| viewport: i, | |
| transparency: t, | |
| background: a | |
| }), this.operatorListIdx = 0, this.graphicsReady = !0, (c = this.graphicsReadyCallback) == null || c.call(this); | |
| } | |
| cancel(t = null, e = 0) { | |
| var s; | |
| this.running = !1, this.cancelled = !0, (s = this.gfx) == null || s.endDrawing(), o(this, wn) && (window.cancelAnimationFrame(o(this, wn)), p(this, wn, null)), o(tr, Lr).delete(this._canvas), this.callback(t || new Up(`Rendering cancelled, page ${this._pageIndex + 1}`, e)); | |
| } | |
| operatorListChanged() { | |
| var t; | |
| if (!this.graphicsReady) { | |
| this.graphicsReadyCallback || (this.graphicsReadyCallback = this._continueBound); | |
| return; | |
| } | |
| (t = this.stepper) == null || t.updateOperatorList(this.operatorList), !this.running && this._continue(); | |
| } | |
| _continue() { | |
| this.running = !0, !this.cancelled && (this.task.onContinue ? this.task.onContinue(this._scheduleNextBound) : this._scheduleNext()); | |
| } | |
| _scheduleNext() { | |
| this._useRequestAnimationFrame ? p(this, wn, window.requestAnimationFrame(() => { | |
| p(this, wn, null), this._nextBound().catch(this._cancelBound); | |
| })) : Promise.resolve().then(this._nextBound).catch(this._cancelBound); | |
| } | |
| async _next() { | |
| this.cancelled || (this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper), this.operatorListIdx === this.operatorList.argsArray.length && (this.running = !1, this.operatorList.lastChunk && (this.gfx.endDrawing(), o(tr, Lr).delete(this._canvas), this.callback()))); | |
| } | |
| }; | |
| wn = new WeakMap(), Lr = new WeakMap(), b(tr, Lr, /* @__PURE__ */ new WeakSet()); | |
| let Gf = tr; | |
| const Zx = "4.10.38", Yx = "f9bea397f"; | |
| function Jg(n) { | |
| return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0"); | |
| } | |
| function ol(n) { | |
| return Math.max(0, Math.min(255, 255 * n)); | |
| } | |
| class Qg { | |
| static CMYK_G([t, e, s, i]) { | |
| return ["G", 1 - Math.min(1, 0.3 * t + 0.59 * s + 0.11 * e + i)]; | |
| } | |
| static G_CMYK([t]) { | |
| return ["CMYK", 0, 0, 0, 1 - t]; | |
| } | |
| static G_RGB([t]) { | |
| return ["RGB", t, t, t]; | |
| } | |
| static G_rgb([t]) { | |
| return t = ol(t), [t, t, t]; | |
| } | |
| static G_HTML([t]) { | |
| const e = Jg(t); | |
| return `#${e}${e}${e}`; | |
| } | |
| static RGB_G([t, e, s]) { | |
| return ["G", 0.3 * t + 0.59 * e + 0.11 * s]; | |
| } | |
| static RGB_rgb(t) { | |
| return t.map(ol); | |
| } | |
| static RGB_HTML(t) { | |
| return `#${t.map(Jg).join("")}`; | |
| } | |
| static T_HTML() { | |
| return "#00000000"; | |
| } | |
| static T_rgb() { | |
| return [null]; | |
| } | |
| static CMYK_RGB([t, e, s, i]) { | |
| return ["RGB", 1 - Math.min(1, t + i), 1 - Math.min(1, s + i), 1 - Math.min(1, e + i)]; | |
| } | |
| static CMYK_rgb([t, e, s, i]) { | |
| return [ol(1 - Math.min(1, t + i)), ol(1 - Math.min(1, s + i)), ol(1 - Math.min(1, e + i))]; | |
| } | |
| static CMYK_HTML(t) { | |
| const e = this.CMYK_RGB(t).slice(1); | |
| return this.RGB_HTML(e); | |
| } | |
| static RGB_CMYK([t, e, s]) { | |
| const i = 1 - t, r = 1 - e, a = 1 - s, l = Math.min(i, r, a); | |
| return ["CMYK", i, r, a, l]; | |
| } | |
| } | |
| class Kx { | |
| create(t, e, s = !1) { | |
| if (t <= 0 || e <= 0) | |
| throw new Error("Invalid SVG dimensions"); | |
| const i = this._createSVG("svg:svg"); | |
| return i.setAttribute("version", "1.1"), s || (i.setAttribute("width", `${t}px`), i.setAttribute("height", `${e}px`)), i.setAttribute("preserveAspectRatio", "none"), i.setAttribute("viewBox", `0 0 ${t} ${e}`), i; | |
| } | |
| createElement(t) { | |
| if (typeof t != "string") | |
| throw new Error("Invalid SVG element type"); | |
| return this._createSVG(t); | |
| } | |
| _createSVG(t) { | |
| Et("Abstract method `_createSVG` called."); | |
| } | |
| } | |
| class Xp extends Kx { | |
| _createSVG(t) { | |
| return document.createElementNS(gi, t); | |
| } | |
| } | |
| class Hb { | |
| static setupStorage(t, e, s, i, r) { | |
| const a = i.getValue(e, { | |
| value: null | |
| }); | |
| switch (s.name) { | |
| case "textarea": | |
| if (a.value !== null && (t.textContent = a.value), r === "print") | |
| break; | |
| t.addEventListener("input", (l) => { | |
| i.setValue(e, { | |
| value: l.target.value | |
| }); | |
| }); | |
| break; | |
| case "input": | |
| if (s.attributes.type === "radio" || s.attributes.type === "checkbox") { | |
| if (a.value === s.attributes.xfaOn ? t.setAttribute("checked", !0) : a.value === s.attributes.xfaOff && t.removeAttribute("checked"), r === "print") | |
| break; | |
| t.addEventListener("change", (l) => { | |
| i.setValue(e, { | |
| value: l.target.checked ? l.target.getAttribute("xfaOn") : l.target.getAttribute("xfaOff") | |
| }); | |
| }); | |
| } else { | |
| if (a.value !== null && t.setAttribute("value", a.value), r === "print") | |
| break; | |
| t.addEventListener("input", (l) => { | |
| i.setValue(e, { | |
| value: l.target.value | |
| }); | |
| }); | |
| } | |
| break; | |
| case "select": | |
| if (a.value !== null) { | |
| t.setAttribute("value", a.value); | |
| for (const l of s.children) | |
| l.attributes.value === a.value ? l.attributes.selected = !0 : l.attributes.hasOwnProperty("selected") && delete l.attributes.selected; | |
| } | |
| t.addEventListener("input", (l) => { | |
| const c = l.target.options, h = c.selectedIndex === -1 ? "" : c[c.selectedIndex].value; | |
| i.setValue(e, { | |
| value: h | |
| }); | |
| }); | |
| break; | |
| } | |
| } | |
| static setAttributes({ | |
| html: t, | |
| element: e, | |
| storage: s = null, | |
| intent: i, | |
| linkService: r | |
| }) { | |
| const { | |
| attributes: a | |
| } = e, l = t instanceof HTMLAnchorElement; | |
| a.type === "radio" && (a.name = `${a.name}-${i}`); | |
| for (const [c, h] of Object.entries(a)) | |
| if (h != null) | |
| switch (c) { | |
| case "class": | |
| h.length && t.setAttribute(c, h.join(" ")); | |
| break; | |
| case "dataId": | |
| break; | |
| case "id": | |
| t.setAttribute("data-element-id", h); | |
| break; | |
| case "style": | |
| Object.assign(t.style, h); | |
| break; | |
| case "textContent": | |
| t.textContent = h; | |
| break; | |
| default: | |
| (!l || c !== "href" && c !== "newWindow") && t.setAttribute(c, h); | |
| } | |
| l && r.addLinkAttributes(t, a.href, a.newWindow), s && a.dataId && this.setupStorage(t, a.dataId, e, s); | |
| } | |
| static render(t) { | |
| var d, f; | |
| const e = t.annotationStorage, s = t.linkService, i = t.xfaHtml, r = t.intent || "display", a = document.createElement(i.name); | |
| i.attributes && this.setAttributes({ | |
| html: a, | |
| element: i, | |
| intent: r, | |
| linkService: s | |
| }); | |
| const l = r !== "richText", c = t.div; | |
| if (c.append(a), t.viewport) { | |
| const g = `matrix(${t.viewport.transform.join(",")})`; | |
| c.style.transform = g; | |
| } | |
| l && c.setAttribute("class", "xfaLayer xfaFont"); | |
| const h = []; | |
| if (i.children.length === 0) { | |
| if (i.value) { | |
| const g = document.createTextNode(i.value); | |
| a.append(g), l && rc.shouldBuildText(i.name) && h.push(g); | |
| } | |
| return { | |
| textDivs: h | |
| }; | |
| } | |
| const u = [[i, -1, a]]; | |
| for (; u.length > 0; ) { | |
| const [g, m, y] = u.at(-1); | |
| if (m + 1 === g.children.length) { | |
| u.pop(); | |
| continue; | |
| } | |
| const _ = g.children[++u.at(-1)[1]]; | |
| if (_ === null) | |
| continue; | |
| const { | |
| name: A | |
| } = _; | |
| if (A === "#text") { | |
| const E = document.createTextNode(_.value); | |
| h.push(E), y.append(E); | |
| continue; | |
| } | |
| const S = (d = _ == null ? void 0 : _.attributes) != null && d.xmlns ? document.createElementNS(_.attributes.xmlns, A) : document.createElement(A); | |
| if (y.append(S), _.attributes && this.setAttributes({ | |
| html: S, | |
| element: _, | |
| storage: e, | |
| intent: r, | |
| linkService: s | |
| }), ((f = _.children) == null ? void 0 : f.length) > 0) | |
| u.push([_, -1, S]); | |
| else if (_.value) { | |
| const E = document.createTextNode(_.value); | |
| l && rc.shouldBuildText(A) && h.push(E), S.append(E); | |
| } | |
| } | |
| for (const g of c.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea")) | |
| g.setAttribute("readOnly", !0); | |
| return { | |
| textDivs: h | |
| }; | |
| } | |
| static update(t) { | |
| const e = `matrix(${t.viewport.transform.join(",")})`; | |
| t.div.style.transform = e, t.div.hidden = !1; | |
| } | |
| } | |
| const Lh = 1e3, Jx = 9, ga = /* @__PURE__ */ new WeakSet(); | |
| function Ln(n) { | |
| return { | |
| width: n[2] - n[0], | |
| height: n[3] - n[1] | |
| }; | |
| } | |
| class Qx { | |
| static create(t) { | |
| switch (t.data.annotationType) { | |
| case Xt.LINK: | |
| return new Ub(t); | |
| case Xt.TEXT: | |
| return new tT(t); | |
| case Xt.WIDGET: | |
| switch (t.data.fieldType) { | |
| case "Tx": | |
| return new eT(t); | |
| case "Btn": | |
| return t.data.radioButton ? new Gb(t) : t.data.checkBox ? new iT(t) : new nT(t); | |
| case "Ch": | |
| return new rT(t); | |
| case "Sig": | |
| return new sT(t); | |
| } | |
| return new ba(t); | |
| case Xt.POPUP: | |
| return new Wf(t); | |
| case Xt.FREETEXT: | |
| return new Yb(t); | |
| case Xt.LINE: | |
| return new oT(t); | |
| case Xt.SQUARE: | |
| return new lT(t); | |
| case Xt.CIRCLE: | |
| return new cT(t); | |
| case Xt.POLYLINE: | |
| return new Kb(t); | |
| case Xt.CARET: | |
| return new uT(t); | |
| case Xt.INK: | |
| return new Zp(t); | |
| case Xt.POLYGON: | |
| return new hT(t); | |
| case Xt.HIGHLIGHT: | |
| return new Jb(t); | |
| case Xt.UNDERLINE: | |
| return new dT(t); | |
| case Xt.SQUIGGLY: | |
| return new fT(t); | |
| case Xt.STRIKEOUT: | |
| return new pT(t); | |
| case Xt.STAMP: | |
| return new Qb(t); | |
| case Xt.FILEATTACHMENT: | |
| return new gT(t); | |
| default: | |
| return new zt(t); | |
| } | |
| } | |
| } | |
| var Dr, uo, fo, Yc, qf; | |
| const Qp = class Qp { | |
| constructor(t, { | |
| isRenderable: e = !1, | |
| ignoreBorder: s = !1, | |
| createQuadrilaterals: i = !1 | |
| } = {}) { | |
| b(this, Yc); | |
| b(this, Dr, null); | |
| b(this, uo, !1); | |
| b(this, fo, null); | |
| this.isRenderable = e, this.data = t.data, this.layer = t.layer, this.linkService = t.linkService, this.downloadManager = t.downloadManager, this.imageResourcesPath = t.imageResourcesPath, this.renderForms = t.renderForms, this.svgFactory = t.svgFactory, this.annotationStorage = t.annotationStorage, this.enableScripting = t.enableScripting, this.hasJSActions = t.hasJSActions, this._fieldObjects = t.fieldObjects, this.parent = t.parent, e && (this.container = this._createContainer(s)), i && this._createQuadrilaterals(); | |
| } | |
| static _hasPopupData({ | |
| titleObj: t, | |
| contentsObj: e, | |
| richText: s | |
| }) { | |
| return !!(t != null && t.str || e != null && e.str || s != null && s.str); | |
| } | |
| get _isEditable() { | |
| return this.data.isEditable; | |
| } | |
| get hasPopupData() { | |
| return Qp._hasPopupData(this.data); | |
| } | |
| updateEdited(t) { | |
| var s; | |
| if (!this.container) | |
| return; | |
| o(this, Dr) || p(this, Dr, { | |
| rect: this.data.rect.slice(0) | |
| }); | |
| const { | |
| rect: e | |
| } = t; | |
| e && v(this, Yc, qf).call(this, e), (s = o(this, fo)) == null || s.popup.updateEdited(t); | |
| } | |
| resetEdited() { | |
| var t; | |
| o(this, Dr) && (v(this, Yc, qf).call(this, o(this, Dr).rect), (t = o(this, fo)) == null || t.popup.resetEdited(), p(this, Dr, null)); | |
| } | |
| _createContainer(t) { | |
| const { | |
| data: e, | |
| parent: { | |
| page: s, | |
| viewport: i | |
| } | |
| } = this, r = document.createElement("section"); | |
| r.setAttribute("data-annotation-id", e.id), this instanceof ba || (r.tabIndex = Lh); | |
| const { | |
| style: a | |
| } = r; | |
| if (a.zIndex = this.parent.zIndex++, e.alternativeText && (r.title = e.alternativeText), e.noRotate && r.classList.add("norotate"), !e.rect || this instanceof Wf) { | |
| const { | |
| rotation: y | |
| } = e; | |
| return !e.hasOwnCanvas && y !== 0 && this.setRotation(y, r), r; | |
| } | |
| const { | |
| width: l, | |
| height: c | |
| } = Ln(e.rect); | |
| if (!t && e.borderStyle.width > 0) { | |
| a.borderWidth = `${e.borderStyle.width}px`; | |
| const y = e.borderStyle.horizontalCornerRadius, _ = e.borderStyle.verticalCornerRadius; | |
| if (y > 0 || _ > 0) { | |
| const S = `calc(${y}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`; | |
| a.borderRadius = S; | |
| } else if (this instanceof Gb) { | |
| const S = `calc(${l}px * var(--scale-factor)) / calc(${c}px * var(--scale-factor))`; | |
| a.borderRadius = S; | |
| } | |
| switch (e.borderStyle.style) { | |
| case nl.SOLID: | |
| a.borderStyle = "solid"; | |
| break; | |
| case nl.DASHED: | |
| a.borderStyle = "dashed"; | |
| break; | |
| case nl.BEVELED: | |
| st("Unimplemented border style: beveled"); | |
| break; | |
| case nl.INSET: | |
| st("Unimplemented border style: inset"); | |
| break; | |
| case nl.UNDERLINE: | |
| a.borderBottomStyle = "solid"; | |
| break; | |
| } | |
| const A = e.borderColor || null; | |
| A ? (p(this, uo, !0), a.borderColor = U.makeHexColor(A[0] | 0, A[1] | 0, A[2] | 0)) : a.borderWidth = 0; | |
| } | |
| const h = U.normalizeRect([e.rect[0], s.view[3] - e.rect[1] + s.view[1], e.rect[2], s.view[3] - e.rect[3] + s.view[1]]), { | |
| pageWidth: u, | |
| pageHeight: d, | |
| pageX: f, | |
| pageY: g | |
| } = i.rawDims; | |
| a.left = `${100 * (h[0] - f) / u}%`, a.top = `${100 * (h[1] - g) / d}%`; | |
| const { | |
| rotation: m | |
| } = e; | |
| return e.hasOwnCanvas || m === 0 ? (a.width = `${100 * l / u}%`, a.height = `${100 * c / d}%`) : this.setRotation(m, r), r; | |
| } | |
| setRotation(t, e = this.container) { | |
| if (!this.data.rect) | |
| return; | |
| const { | |
| pageWidth: s, | |
| pageHeight: i | |
| } = this.parent.viewport.rawDims, { | |
| width: r, | |
| height: a | |
| } = Ln(this.data.rect); | |
| let l, c; | |
| t % 180 === 0 ? (l = 100 * r / s, c = 100 * a / i) : (l = 100 * a / s, c = 100 * r / i), e.style.width = `${l}%`, e.style.height = `${c}%`, e.setAttribute("data-main-rotation", (360 - t) % 360); | |
| } | |
| get _commonActions() { | |
| const t = (e, s, i) => { | |
| const r = i.detail[e], a = r[0], l = r.slice(1); | |
| i.target.style[s] = Qg[`${a}_HTML`](l), this.annotationStorage.setValue(this.data.id, { | |
| [s]: Qg[`${a}_rgb`](l) | |
| }); | |
| }; | |
| return at(this, "_commonActions", { | |
| display: (e) => { | |
| const { | |
| display: s | |
| } = e.detail, i = s % 2 === 1; | |
| this.container.style.visibility = i ? "hidden" : "visible", this.annotationStorage.setValue(this.data.id, { | |
| noView: i, | |
| noPrint: s === 1 || s === 2 | |
| }); | |
| }, | |
| print: (e) => { | |
| this.annotationStorage.setValue(this.data.id, { | |
| noPrint: !e.detail.print | |
| }); | |
| }, | |
| hidden: (e) => { | |
| const { | |
| hidden: s | |
| } = e.detail; | |
| this.container.style.visibility = s ? "hidden" : "visible", this.annotationStorage.setValue(this.data.id, { | |
| noPrint: s, | |
| noView: s | |
| }); | |
| }, | |
| focus: (e) => { | |
| setTimeout(() => e.target.focus({ | |
| preventScroll: !1 | |
| }), 0); | |
| }, | |
| userName: (e) => { | |
| e.target.title = e.detail.userName; | |
| }, | |
| readonly: (e) => { | |
| e.target.disabled = e.detail.readonly; | |
| }, | |
| required: (e) => { | |
| this._setRequired(e.target, e.detail.required); | |
| }, | |
| bgColor: (e) => { | |
| t("bgColor", "backgroundColor", e); | |
| }, | |
| fillColor: (e) => { | |
| t("fillColor", "backgroundColor", e); | |
| }, | |
| fgColor: (e) => { | |
| t("fgColor", "color", e); | |
| }, | |
| textColor: (e) => { | |
| t("textColor", "color", e); | |
| }, | |
| borderColor: (e) => { | |
| t("borderColor", "borderColor", e); | |
| }, | |
| strokeColor: (e) => { | |
| t("strokeColor", "borderColor", e); | |
| }, | |
| rotation: (e) => { | |
| const s = e.detail.rotation; | |
| this.setRotation(s), this.annotationStorage.setValue(this.data.id, { | |
| rotation: s | |
| }); | |
| } | |
| }); | |
| } | |
| _dispatchEventFromSandbox(t, e) { | |
| const s = this._commonActions; | |
| for (const i of Object.keys(e.detail)) { | |
| const r = t[i] || s[i]; | |
| r == null || r(e); | |
| } | |
| } | |
| _setDefaultPropertiesFromJS(t) { | |
| if (!this.enableScripting) | |
| return; | |
| const e = this.annotationStorage.getRawValue(this.data.id); | |
| if (!e) | |
| return; | |
| const s = this._commonActions; | |
| for (const [i, r] of Object.entries(e)) { | |
| const a = s[i]; | |
| if (a) { | |
| const l = { | |
| detail: { | |
| [i]: r | |
| }, | |
| target: t | |
| }; | |
| a(l), delete e[i]; | |
| } | |
| } | |
| } | |
| _createQuadrilaterals() { | |
| if (!this.container) | |
| return; | |
| const { | |
| quadPoints: t | |
| } = this.data; | |
| if (!t) | |
| return; | |
| const [e, s, i, r] = this.data.rect.map((y) => Math.fround(y)); | |
| if (t.length === 8) { | |
| const [y, _, A, S] = t.subarray(2, 6); | |
| if (i === y && r === _ && e === A && s === S) | |
| return; | |
| } | |
| const { | |
| style: a | |
| } = this.container; | |
| let l; | |
| if (o(this, uo)) { | |
| const { | |
| borderColor: y, | |
| borderWidth: _ | |
| } = a; | |
| a.borderWidth = 0, l = ["url('data:image/svg+xml;utf8,", '<svg xmlns="http://www.w3.org/2000/svg"', ' preserveAspectRatio="none" viewBox="0 0 1 1">', `<g fill="transparent" stroke="${y}" stroke-width="${_}">`], this.container.classList.add("hasBorder"); | |
| } | |
| const c = i - e, h = r - s, { | |
| svgFactory: u | |
| } = this, d = u.createElement("svg"); | |
| d.classList.add("quadrilateralsContainer"), d.setAttribute("width", 0), d.setAttribute("height", 0); | |
| const f = u.createElement("defs"); | |
| d.append(f); | |
| const g = u.createElement("clipPath"), m = `clippath_${this.data.id}`; | |
| g.setAttribute("id", m), g.setAttribute("clipPathUnits", "objectBoundingBox"), f.append(g); | |
| for (let y = 2, _ = t.length; y < _; y += 8) { | |
| const A = t[y], S = t[y + 1], E = t[y + 2], x = t[y + 3], T = u.createElement("rect"), k = (E - e) / c, C = (r - S) / h, P = (A - E) / c, j = (S - x) / h; | |
| T.setAttribute("x", k), T.setAttribute("y", C), T.setAttribute("width", P), T.setAttribute("height", j), g.append(T), l == null || l.push(`<rect vector-effect="non-scaling-stroke" x="${k}" y="${C}" width="${P}" height="${j}"/>`); | |
| } | |
| o(this, uo) && (l.push("</g></svg>')"), a.backgroundImage = l.join("")), this.container.append(d), this.container.style.clipPath = `url(#${m})`; | |
| } | |
| _createPopup() { | |
| const { | |
| data: t | |
| } = this, e = p(this, fo, new Wf({ | |
| data: { | |
| color: t.color, | |
| titleObj: t.titleObj, | |
| modificationDate: t.modificationDate, | |
| contentsObj: t.contentsObj, | |
| richText: t.richText, | |
| parentRect: t.rect, | |
| borderStyle: 0, | |
| id: `popup_${t.id}`, | |
| rotation: t.rotation | |
| }, | |
| parent: this.parent, | |
| elements: [this] | |
| })); | |
| this.parent.div.append(e.render()); | |
| } | |
| render() { | |
| Et("Abstract method `AnnotationElement.render` called"); | |
| } | |
| _getElementsByName(t, e = null) { | |
| const s = []; | |
| if (this._fieldObjects) { | |
| const i = this._fieldObjects[t]; | |
| if (i) | |
| for (const { | |
| page: r, | |
| id: a, | |
| exportValues: l | |
| } of i) { | |
| if (r === -1 || a === e) | |
| continue; | |
| const c = typeof l == "string" ? l : null, h = document.querySelector(`[data-element-id="${a}"]`); | |
| if (h && !ga.has(h)) { | |
| st(`_getElementsByName - element not allowed: ${a}`); | |
| continue; | |
| } | |
| s.push({ | |
| id: a, | |
| exportValue: c, | |
| domElement: h | |
| }); | |
| } | |
| return s; | |
| } | |
| for (const i of document.getElementsByName(t)) { | |
| const { | |
| exportValue: r | |
| } = i, a = i.getAttribute("data-element-id"); | |
| a !== e && ga.has(i) && s.push({ | |
| id: a, | |
| exportValue: r, | |
| domElement: i | |
| }); | |
| } | |
| return s; | |
| } | |
| show() { | |
| var t; | |
| this.container && (this.container.hidden = !1), (t = this.popup) == null || t.maybeShow(); | |
| } | |
| hide() { | |
| var t; | |
| this.container && (this.container.hidden = !0), (t = this.popup) == null || t.forceHide(); | |
| } | |
| getElementsToTriggerPopup() { | |
| return this.container; | |
| } | |
| addHighlightArea() { | |
| const t = this.getElementsToTriggerPopup(); | |
| if (Array.isArray(t)) | |
| for (const e of t) | |
| e.classList.add("highlightArea"); | |
| else | |
| t.classList.add("highlightArea"); | |
| } | |
| _editOnDoubleClick() { | |
| if (!this._isEditable) | |
| return; | |
| const { | |
| annotationEditorType: t, | |
| data: { | |
| id: e | |
| } | |
| } = this; | |
| this.container.addEventListener("dblclick", () => { | |
| var s; | |
| (s = this.linkService.eventBus) == null || s.dispatch("switchannotationeditormode", { | |
| source: this, | |
| mode: t, | |
| editId: e | |
| }); | |
| }); | |
| } | |
| }; | |
| Dr = new WeakMap(), uo = new WeakMap(), fo = new WeakMap(), Yc = new WeakSet(), qf = function(t) { | |
| const { | |
| container: { | |
| style: e | |
| }, | |
| data: { | |
| rect: s, | |
| rotation: i | |
| }, | |
| parent: { | |
| viewport: { | |
| rawDims: { | |
| pageWidth: r, | |
| pageHeight: a, | |
| pageX: l, | |
| pageY: c | |
| } | |
| } | |
| } | |
| } = this; | |
| s == null || s.splice(0, 4, ...t); | |
| const { | |
| width: h, | |
| height: u | |
| } = Ln(t); | |
| e.left = `${100 * (t[0] - l) / r}%`, e.top = `${100 * (a - t[3] + c) / a}%`, i === 0 ? (e.width = `${100 * h / r}%`, e.height = `${100 * u / a}%`) : this.setRotation(i); | |
| }; | |
| let zt = Qp; | |
| var is, Yn, zb, Vb; | |
| class Ub extends zt { | |
| constructor(e, s = null) { | |
| super(e, { | |
| isRenderable: !0, | |
| ignoreBorder: !!(s != null && s.ignoreBorder), | |
| createQuadrilaterals: !0 | |
| }); | |
| b(this, is); | |
| this.isTooltipOnly = e.data.isTooltipOnly; | |
| } | |
| render() { | |
| const { | |
| data: e, | |
| linkService: s | |
| } = this, i = document.createElement("a"); | |
| i.setAttribute("data-element-id", e.id); | |
| let r = !1; | |
| return e.url ? (s.addLinkAttributes(i, e.url, e.newWindow), r = !0) : e.action ? (this._bindNamedAction(i, e.action), r = !0) : e.attachment ? (v(this, is, zb).call(this, i, e.attachment, e.attachmentDest), r = !0) : e.setOCGState ? (v(this, is, Vb).call(this, i, e.setOCGState), r = !0) : e.dest ? (this._bindLink(i, e.dest), r = !0) : (e.actions && (e.actions.Action || e.actions["Mouse Up"] || e.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions && (this._bindJSAction(i, e), r = !0), e.resetForm ? (this._bindResetFormAction(i, e.resetForm), r = !0) : this.isTooltipOnly && !r && (this._bindLink(i, ""), r = !0)), this.container.classList.add("linkAnnotation"), r && this.container.append(i), this.container; | |
| } | |
| _bindLink(e, s) { | |
| e.href = this.linkService.getDestinationHash(s), e.onclick = () => (s && this.linkService.goToDestination(s), !1), (s || s === "") && v(this, is, Yn).call(this); | |
| } | |
| _bindNamedAction(e, s) { | |
| e.href = this.linkService.getAnchorUrl(""), e.onclick = () => (this.linkService.executeNamedAction(s), !1), v(this, is, Yn).call(this); | |
| } | |
| _bindJSAction(e, s) { | |
| e.href = this.linkService.getAnchorUrl(""); | |
| const i = /* @__PURE__ */ new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]); | |
| for (const r of Object.keys(s.actions)) { | |
| const a = i.get(r); | |
| a && (e[a] = () => { | |
| var l; | |
| return (l = this.linkService.eventBus) == null || l.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: s.id, | |
| name: r | |
| } | |
| }), !1; | |
| }); | |
| } | |
| e.onclick || (e.onclick = () => !1), v(this, is, Yn).call(this); | |
| } | |
| _bindResetFormAction(e, s) { | |
| const i = e.onclick; | |
| if (i || (e.href = this.linkService.getAnchorUrl("")), v(this, is, Yn).call(this), !this._fieldObjects) { | |
| st('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'), i || (e.onclick = () => !1); | |
| return; | |
| } | |
| e.onclick = () => { | |
| var d; | |
| i == null || i(); | |
| const { | |
| fields: r, | |
| refs: a, | |
| include: l | |
| } = s, c = []; | |
| if (r.length !== 0 || a.length !== 0) { | |
| const f = new Set(a); | |
| for (const g of r) { | |
| const m = this._fieldObjects[g] || []; | |
| for (const { | |
| id: y | |
| } of m) | |
| f.add(y); | |
| } | |
| for (const g of Object.values(this._fieldObjects)) | |
| for (const m of g) | |
| f.has(m.id) === l && c.push(m); | |
| } else | |
| for (const f of Object.values(this._fieldObjects)) | |
| c.push(...f); | |
| const h = this.annotationStorage, u = []; | |
| for (const f of c) { | |
| const { | |
| id: g | |
| } = f; | |
| switch (u.push(g), f.type) { | |
| case "text": { | |
| const y = f.defaultValue || ""; | |
| h.setValue(g, { | |
| value: y | |
| }); | |
| break; | |
| } | |
| case "checkbox": | |
| case "radiobutton": { | |
| const y = f.defaultValue === f.exportValues; | |
| h.setValue(g, { | |
| value: y | |
| }); | |
| break; | |
| } | |
| case "combobox": | |
| case "listbox": { | |
| const y = f.defaultValue || ""; | |
| h.setValue(g, { | |
| value: y | |
| }); | |
| break; | |
| } | |
| default: | |
| continue; | |
| } | |
| const m = document.querySelector(`[data-element-id="${g}"]`); | |
| if (m) { | |
| if (!ga.has(m)) { | |
| st(`_bindResetFormAction - element not allowed: ${g}`); | |
| continue; | |
| } | |
| } else continue; | |
| m.dispatchEvent(new Event("resetform")); | |
| } | |
| return this.enableScripting && ((d = this.linkService.eventBus) == null || d.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: "app", | |
| ids: u, | |
| name: "ResetForm" | |
| } | |
| })), !1; | |
| }; | |
| } | |
| } | |
| is = new WeakSet(), Yn = function() { | |
| this.container.setAttribute("data-internal-link", ""); | |
| }, zb = function(e, s, i = null) { | |
| e.href = this.linkService.getAnchorUrl(""), s.description && (e.title = s.description), e.onclick = () => { | |
| var r; | |
| return (r = this.downloadManager) == null || r.openOrDownloadData(s.content, s.filename, i), !1; | |
| }, v(this, is, Yn).call(this); | |
| }, Vb = function(e, s) { | |
| e.href = this.linkService.getAnchorUrl(""), e.onclick = () => (this.linkService.executeSetOCGState(s), !1), v(this, is, Yn).call(this); | |
| }; | |
| class tT extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0 | |
| }); | |
| } | |
| render() { | |
| this.container.classList.add("textAnnotation"); | |
| const t = document.createElement("img"); | |
| return t.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg", t.setAttribute("data-l10n-id", "pdfjs-text-annotation-type"), t.setAttribute("data-l10n-args", JSON.stringify({ | |
| type: this.data.name | |
| })), !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.append(t), this.container; | |
| } | |
| } | |
| class ba extends zt { | |
| render() { | |
| return this.container; | |
| } | |
| showElementAndHideCanvas(t) { | |
| var e; | |
| this.data.hasOwnCanvas && (((e = t.previousSibling) == null ? void 0 : e.nodeName) === "CANVAS" && (t.previousSibling.hidden = !0), t.hidden = !1); | |
| } | |
| _getKeyModifier(t) { | |
| return Me.platform.isMac ? t.metaKey : t.ctrlKey; | |
| } | |
| _setEventListener(t, e, s, i, r) { | |
| s.includes("mouse") ? t.addEventListener(s, (a) => { | |
| var l; | |
| (l = this.linkService.eventBus) == null || l.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: this.data.id, | |
| name: i, | |
| value: r(a), | |
| shift: a.shiftKey, | |
| modifier: this._getKeyModifier(a) | |
| } | |
| }); | |
| }) : t.addEventListener(s, (a) => { | |
| var l; | |
| if (s === "blur") { | |
| if (!e.focused || !a.relatedTarget) | |
| return; | |
| e.focused = !1; | |
| } else if (s === "focus") { | |
| if (e.focused) | |
| return; | |
| e.focused = !0; | |
| } | |
| r && ((l = this.linkService.eventBus) == null || l.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: this.data.id, | |
| name: i, | |
| value: r(a) | |
| } | |
| })); | |
| }); | |
| } | |
| _setEventListeners(t, e, s, i) { | |
| var r, a, l; | |
| for (const [c, h] of s) | |
| (h === "Action" || (r = this.data.actions) != null && r[h]) && ((h === "Focus" || h === "Blur") && (e || (e = { | |
| focused: !1 | |
| })), this._setEventListener(t, e, c, h, i), h === "Focus" && !((a = this.data.actions) != null && a.Blur) ? this._setEventListener(t, e, "blur", "Blur", null) : h === "Blur" && !((l = this.data.actions) != null && l.Focus) && this._setEventListener(t, e, "focus", "Focus", null)); | |
| } | |
| _setBackgroundColor(t) { | |
| const e = this.data.backgroundColor || null; | |
| t.style.backgroundColor = e === null ? "transparent" : U.makeHexColor(e[0], e[1], e[2]); | |
| } | |
| _setTextStyle(t) { | |
| const e = ["left", "center", "right"], { | |
| fontColor: s | |
| } = this.data.defaultAppearanceData, i = this.data.defaultAppearanceData.fontSize || Jx, r = t.style; | |
| let a; | |
| const l = 2, c = (h) => Math.round(10 * h) / 10; | |
| if (this.data.multiLine) { | |
| const h = Math.abs(this.data.rect[3] - this.data.rect[1] - l), u = Math.round(h / (zd * i)) || 1, d = h / u; | |
| a = Math.min(i, c(d / zd)); | |
| } else { | |
| const h = Math.abs(this.data.rect[3] - this.data.rect[1] - l); | |
| a = Math.min(i, c(h / zd)); | |
| } | |
| r.fontSize = `calc(${a}px * var(--scale-factor))`, r.color = U.makeHexColor(s[0], s[1], s[2]), this.data.textAlignment !== null && (r.textAlign = e[this.data.textAlignment]); | |
| } | |
| _setRequired(t, e) { | |
| e ? t.setAttribute("required", !0) : t.removeAttribute("required"), t.setAttribute("aria-required", e); | |
| } | |
| } | |
| class eT extends ba { | |
| constructor(t) { | |
| const e = t.renderForms || t.data.hasOwnCanvas || !t.data.hasAppearance && !!t.data.fieldValue; | |
| super(t, { | |
| isRenderable: e | |
| }); | |
| } | |
| setPropertyOnSiblings(t, e, s, i) { | |
| const r = this.annotationStorage; | |
| for (const a of this._getElementsByName(t.name, t.id)) | |
| a.domElement && (a.domElement[e] = s), r.setValue(a.id, { | |
| [i]: s | |
| }); | |
| } | |
| render() { | |
| var i, r; | |
| const t = this.annotationStorage, e = this.data.id; | |
| this.container.classList.add("textWidgetAnnotation"); | |
| let s = null; | |
| if (this.renderForms) { | |
| const a = t.getValue(e, { | |
| value: this.data.fieldValue | |
| }); | |
| let l = a.value || ""; | |
| const c = t.getValue(e, { | |
| charLimit: this.data.maxLen | |
| }).charLimit; | |
| c && l.length > c && (l = l.slice(0, c)); | |
| let h = a.formattedValue || ((i = this.data.textContent) == null ? void 0 : i.join(` | |
| `)) || null; | |
| h && this.data.comb && (h = h.replaceAll(/\s+/g, "")); | |
| const u = { | |
| userValue: l, | |
| formattedValue: h, | |
| lastCommittedValue: null, | |
| commitKey: 1, | |
| focused: !1 | |
| }; | |
| this.data.multiLine ? (s = document.createElement("textarea"), s.textContent = h ?? l, this.data.doNotScroll && (s.style.overflowY = "hidden")) : (s = document.createElement("input"), s.type = "text", s.setAttribute("value", h ?? l), this.data.doNotScroll && (s.style.overflowX = "hidden")), this.data.hasOwnCanvas && (s.hidden = !0), ga.add(s), s.setAttribute("data-element-id", e), s.disabled = this.data.readOnly, s.name = this.data.fieldName, s.tabIndex = Lh, this._setRequired(s, this.data.required), c && (s.maxLength = c), s.addEventListener("input", (f) => { | |
| t.setValue(e, { | |
| value: f.target.value | |
| }), this.setPropertyOnSiblings(s, "value", f.target.value, "value"), u.formattedValue = null; | |
| }), s.addEventListener("resetform", (f) => { | |
| const g = this.data.defaultFieldValue ?? ""; | |
| s.value = u.userValue = g, u.formattedValue = null; | |
| }); | |
| let d = (f) => { | |
| const { | |
| formattedValue: g | |
| } = u; | |
| g != null && (f.target.value = g), f.target.scrollLeft = 0; | |
| }; | |
| if (this.enableScripting && this.hasJSActions) { | |
| s.addEventListener("focus", (g) => { | |
| var y; | |
| if (u.focused) | |
| return; | |
| const { | |
| target: m | |
| } = g; | |
| u.userValue && (m.value = u.userValue), u.lastCommittedValue = m.value, u.commitKey = 1, (y = this.data.actions) != null && y.Focus || (u.focused = !0); | |
| }), s.addEventListener("updatefromsandbox", (g) => { | |
| this.showElementAndHideCanvas(g.target); | |
| const m = { | |
| value(y) { | |
| u.userValue = y.detail.value ?? "", t.setValue(e, { | |
| value: u.userValue.toString() | |
| }), y.target.value = u.userValue; | |
| }, | |
| formattedValue(y) { | |
| const { | |
| formattedValue: _ | |
| } = y.detail; | |
| u.formattedValue = _, _ != null && y.target !== document.activeElement && (y.target.value = _), t.setValue(e, { | |
| formattedValue: _ | |
| }); | |
| }, | |
| selRange(y) { | |
| y.target.setSelectionRange(...y.detail.selRange); | |
| }, | |
| charLimit: (y) => { | |
| var E; | |
| const { | |
| charLimit: _ | |
| } = y.detail, { | |
| target: A | |
| } = y; | |
| if (_ === 0) { | |
| A.removeAttribute("maxLength"); | |
| return; | |
| } | |
| A.setAttribute("maxLength", _); | |
| let S = u.userValue; | |
| !S || S.length <= _ || (S = S.slice(0, _), A.value = u.userValue = S, t.setValue(e, { | |
| value: S | |
| }), (E = this.linkService.eventBus) == null || E.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: e, | |
| name: "Keystroke", | |
| value: S, | |
| willCommit: !0, | |
| commitKey: 1, | |
| selStart: A.selectionStart, | |
| selEnd: A.selectionEnd | |
| } | |
| })); | |
| } | |
| }; | |
| this._dispatchEventFromSandbox(m, g); | |
| }), s.addEventListener("keydown", (g) => { | |
| var _; | |
| u.commitKey = 1; | |
| let m = -1; | |
| if (g.key === "Escape" ? m = 0 : g.key === "Enter" && !this.data.multiLine ? m = 2 : g.key === "Tab" && (u.commitKey = 3), m === -1) | |
| return; | |
| const { | |
| value: y | |
| } = g.target; | |
| u.lastCommittedValue !== y && (u.lastCommittedValue = y, u.userValue = y, (_ = this.linkService.eventBus) == null || _.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: e, | |
| name: "Keystroke", | |
| value: y, | |
| willCommit: !0, | |
| commitKey: m, | |
| selStart: g.target.selectionStart, | |
| selEnd: g.target.selectionEnd | |
| } | |
| })); | |
| }); | |
| const f = d; | |
| d = null, s.addEventListener("blur", (g) => { | |
| var y, _; | |
| if (!u.focused || !g.relatedTarget) | |
| return; | |
| (y = this.data.actions) != null && y.Blur || (u.focused = !1); | |
| const { | |
| value: m | |
| } = g.target; | |
| u.userValue = m, u.lastCommittedValue !== m && ((_ = this.linkService.eventBus) == null || _.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: e, | |
| name: "Keystroke", | |
| value: m, | |
| willCommit: !0, | |
| commitKey: u.commitKey, | |
| selStart: g.target.selectionStart, | |
| selEnd: g.target.selectionEnd | |
| } | |
| })), f(g); | |
| }), (r = this.data.actions) != null && r.Keystroke && s.addEventListener("beforeinput", (g) => { | |
| var T; | |
| u.lastCommittedValue = null; | |
| const { | |
| data: m, | |
| target: y | |
| } = g, { | |
| value: _, | |
| selectionStart: A, | |
| selectionEnd: S | |
| } = y; | |
| let E = A, x = S; | |
| switch (g.inputType) { | |
| case "deleteWordBackward": { | |
| const k = _.substring(0, A).match(/\w*[^\w]*$/); | |
| k && (E -= k[0].length); | |
| break; | |
| } | |
| case "deleteWordForward": { | |
| const k = _.substring(A).match(/^[^\w]*\w*/); | |
| k && (x += k[0].length); | |
| break; | |
| } | |
| case "deleteContentBackward": | |
| A === S && (E -= 1); | |
| break; | |
| case "deleteContentForward": | |
| A === S && (x += 1); | |
| break; | |
| } | |
| g.preventDefault(), (T = this.linkService.eventBus) == null || T.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: e, | |
| name: "Keystroke", | |
| value: _, | |
| change: m || "", | |
| willCommit: !1, | |
| selStart: E, | |
| selEnd: x | |
| } | |
| }); | |
| }), this._setEventListeners(s, u, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], (g) => g.target.value); | |
| } | |
| if (d && s.addEventListener("blur", d), this.data.comb) { | |
| const g = (this.data.rect[2] - this.data.rect[0]) / c; | |
| s.classList.add("comb"), s.style.letterSpacing = `calc(${g}px * var(--scale-factor) - 1ch)`; | |
| } | |
| } else | |
| s = document.createElement("div"), s.textContent = this.data.fieldValue, s.style.verticalAlign = "middle", s.style.display = "table-cell", this.data.hasOwnCanvas && (s.hidden = !0); | |
| return this._setTextStyle(s), this._setBackgroundColor(s), this._setDefaultPropertiesFromJS(s), this.container.append(s), this.container; | |
| } | |
| } | |
| class sT extends ba { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !!t.data.hasOwnCanvas | |
| }); | |
| } | |
| } | |
| class iT extends ba { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: t.renderForms | |
| }); | |
| } | |
| render() { | |
| const t = this.annotationStorage, e = this.data, s = e.id; | |
| let i = t.getValue(s, { | |
| value: e.exportValue === e.fieldValue | |
| }).value; | |
| typeof i == "string" && (i = i !== "Off", t.setValue(s, { | |
| value: i | |
| })), this.container.classList.add("buttonWidgetAnnotation", "checkBox"); | |
| const r = document.createElement("input"); | |
| return ga.add(r), r.setAttribute("data-element-id", s), r.disabled = e.readOnly, this._setRequired(r, this.data.required), r.type = "checkbox", r.name = e.fieldName, i && r.setAttribute("checked", !0), r.setAttribute("exportValue", e.exportValue), r.tabIndex = Lh, r.addEventListener("change", (a) => { | |
| const { | |
| name: l, | |
| checked: c | |
| } = a.target; | |
| for (const h of this._getElementsByName(l, s)) { | |
| const u = c && h.exportValue === e.exportValue; | |
| h.domElement && (h.domElement.checked = u), t.setValue(h.id, { | |
| value: u | |
| }); | |
| } | |
| t.setValue(s, { | |
| value: c | |
| }); | |
| }), r.addEventListener("resetform", (a) => { | |
| const l = e.defaultFieldValue || "Off"; | |
| a.target.checked = l === e.exportValue; | |
| }), this.enableScripting && this.hasJSActions && (r.addEventListener("updatefromsandbox", (a) => { | |
| const l = { | |
| value(c) { | |
| c.target.checked = c.detail.value !== "Off", t.setValue(s, { | |
| value: c.target.checked | |
| }); | |
| } | |
| }; | |
| this._dispatchEventFromSandbox(l, a); | |
| }), this._setEventListeners(r, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], (a) => a.target.checked)), this._setBackgroundColor(r), this._setDefaultPropertiesFromJS(r), this.container.append(r), this.container; | |
| } | |
| } | |
| class Gb extends ba { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: t.renderForms | |
| }); | |
| } | |
| render() { | |
| this.container.classList.add("buttonWidgetAnnotation", "radioButton"); | |
| const t = this.annotationStorage, e = this.data, s = e.id; | |
| let i = t.getValue(s, { | |
| value: e.fieldValue === e.buttonValue | |
| }).value; | |
| if (typeof i == "string" && (i = i !== e.buttonValue, t.setValue(s, { | |
| value: i | |
| })), i) | |
| for (const a of this._getElementsByName(e.fieldName, s)) | |
| t.setValue(a.id, { | |
| value: !1 | |
| }); | |
| const r = document.createElement("input"); | |
| if (ga.add(r), r.setAttribute("data-element-id", s), r.disabled = e.readOnly, this._setRequired(r, this.data.required), r.type = "radio", r.name = e.fieldName, i && r.setAttribute("checked", !0), r.tabIndex = Lh, r.addEventListener("change", (a) => { | |
| const { | |
| name: l, | |
| checked: c | |
| } = a.target; | |
| for (const h of this._getElementsByName(l, s)) | |
| t.setValue(h.id, { | |
| value: !1 | |
| }); | |
| t.setValue(s, { | |
| value: c | |
| }); | |
| }), r.addEventListener("resetform", (a) => { | |
| const l = e.defaultFieldValue; | |
| a.target.checked = l != null && l === e.buttonValue; | |
| }), this.enableScripting && this.hasJSActions) { | |
| const a = e.buttonValue; | |
| r.addEventListener("updatefromsandbox", (l) => { | |
| const c = { | |
| value: (h) => { | |
| const u = a === h.detail.value; | |
| for (const d of this._getElementsByName(h.target.name)) { | |
| const f = u && d.id === s; | |
| d.domElement && (d.domElement.checked = f), t.setValue(d.id, { | |
| value: f | |
| }); | |
| } | |
| } | |
| }; | |
| this._dispatchEventFromSandbox(c, l); | |
| }), this._setEventListeners(r, null, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], (l) => l.target.checked); | |
| } | |
| return this._setBackgroundColor(r), this._setDefaultPropertiesFromJS(r), this.container.append(r), this.container; | |
| } | |
| } | |
| class nT extends Ub { | |
| constructor(t) { | |
| super(t, { | |
| ignoreBorder: t.data.hasAppearance | |
| }); | |
| } | |
| render() { | |
| const t = super.render(); | |
| t.classList.add("buttonWidgetAnnotation", "pushButton"); | |
| const e = t.lastChild; | |
| return this.enableScripting && this.hasJSActions && e && (this._setDefaultPropertiesFromJS(e), e.addEventListener("updatefromsandbox", (s) => { | |
| this._dispatchEventFromSandbox({}, s); | |
| })), t; | |
| } | |
| } | |
| class rT extends ba { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: t.renderForms | |
| }); | |
| } | |
| render() { | |
| this.container.classList.add("choiceWidgetAnnotation"); | |
| const t = this.annotationStorage, e = this.data.id, s = t.getValue(e, { | |
| value: this.data.fieldValue | |
| }), i = document.createElement("select"); | |
| ga.add(i), i.setAttribute("data-element-id", e), i.disabled = this.data.readOnly, this._setRequired(i, this.data.required), i.name = this.data.fieldName, i.tabIndex = Lh; | |
| let r = this.data.combo && this.data.options.length > 0; | |
| this.data.combo || (i.size = this.data.options.length, this.data.multiSelect && (i.multiple = !0)), i.addEventListener("resetform", (u) => { | |
| const d = this.data.defaultFieldValue; | |
| for (const f of i.options) | |
| f.selected = f.value === d; | |
| }); | |
| for (const u of this.data.options) { | |
| const d = document.createElement("option"); | |
| d.textContent = u.displayValue, d.value = u.exportValue, s.value.includes(u.exportValue) && (d.setAttribute("selected", !0), r = !1), i.append(d); | |
| } | |
| let a = null; | |
| if (r) { | |
| const u = document.createElement("option"); | |
| u.value = " ", u.setAttribute("hidden", !0), u.setAttribute("selected", !0), i.prepend(u), a = () => { | |
| u.remove(), i.removeEventListener("input", a), a = null; | |
| }, i.addEventListener("input", a); | |
| } | |
| const l = (u) => { | |
| const d = u ? "value" : "textContent", { | |
| options: f, | |
| multiple: g | |
| } = i; | |
| return g ? Array.prototype.filter.call(f, (m) => m.selected).map((m) => m[d]) : f.selectedIndex === -1 ? null : f[f.selectedIndex][d]; | |
| }; | |
| let c = l(!1); | |
| const h = (u) => { | |
| const d = u.target.options; | |
| return Array.prototype.map.call(d, (f) => ({ | |
| displayValue: f.textContent, | |
| exportValue: f.value | |
| })); | |
| }; | |
| return this.enableScripting && this.hasJSActions ? (i.addEventListener("updatefromsandbox", (u) => { | |
| const d = { | |
| value(f) { | |
| a == null || a(); | |
| const g = f.detail.value, m = new Set(Array.isArray(g) ? g : [g]); | |
| for (const y of i.options) | |
| y.selected = m.has(y.value); | |
| t.setValue(e, { | |
| value: l(!0) | |
| }), c = l(!1); | |
| }, | |
| multipleSelection(f) { | |
| i.multiple = !0; | |
| }, | |
| remove(f) { | |
| const g = i.options, m = f.detail.remove; | |
| g[m].selected = !1, i.remove(m), g.length > 0 && Array.prototype.findIndex.call(g, (_) => _.selected) === -1 && (g[0].selected = !0), t.setValue(e, { | |
| value: l(!0), | |
| items: h(f) | |
| }), c = l(!1); | |
| }, | |
| clear(f) { | |
| for (; i.length !== 0; ) | |
| i.remove(0); | |
| t.setValue(e, { | |
| value: null, | |
| items: [] | |
| }), c = l(!1); | |
| }, | |
| insert(f) { | |
| const { | |
| index: g, | |
| displayValue: m, | |
| exportValue: y | |
| } = f.detail.insert, _ = i.children[g], A = document.createElement("option"); | |
| A.textContent = m, A.value = y, _ ? _.before(A) : i.append(A), t.setValue(e, { | |
| value: l(!0), | |
| items: h(f) | |
| }), c = l(!1); | |
| }, | |
| items(f) { | |
| const { | |
| items: g | |
| } = f.detail; | |
| for (; i.length !== 0; ) | |
| i.remove(0); | |
| for (const m of g) { | |
| const { | |
| displayValue: y, | |
| exportValue: _ | |
| } = m, A = document.createElement("option"); | |
| A.textContent = y, A.value = _, i.append(A); | |
| } | |
| i.options.length > 0 && (i.options[0].selected = !0), t.setValue(e, { | |
| value: l(!0), | |
| items: h(f) | |
| }), c = l(!1); | |
| }, | |
| indices(f) { | |
| const g = new Set(f.detail.indices); | |
| for (const m of f.target.options) | |
| m.selected = g.has(m.index); | |
| t.setValue(e, { | |
| value: l(!0) | |
| }), c = l(!1); | |
| }, | |
| editable(f) { | |
| f.target.disabled = !f.detail.editable; | |
| } | |
| }; | |
| this._dispatchEventFromSandbox(d, u); | |
| }), i.addEventListener("input", (u) => { | |
| var g; | |
| const d = l(!0), f = l(!1); | |
| t.setValue(e, { | |
| value: d | |
| }), u.preventDefault(), (g = this.linkService.eventBus) == null || g.dispatch("dispatcheventinsandbox", { | |
| source: this, | |
| detail: { | |
| id: e, | |
| name: "Keystroke", | |
| value: c, | |
| change: f, | |
| changeEx: d, | |
| willCommit: !1, | |
| commitKey: 1, | |
| keyDown: !1 | |
| } | |
| }); | |
| }), this._setEventListeners(i, null, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"], ["input", "Validate"]], (u) => u.target.value)) : i.addEventListener("input", function(u) { | |
| t.setValue(e, { | |
| value: l(!0) | |
| }); | |
| }), this.data.combo && this._setTextStyle(i), this._setBackgroundColor(i), this._setDefaultPropertiesFromJS(i), this.container.append(i), this.container; | |
| } | |
| } | |
| class Wf extends zt { | |
| constructor(t) { | |
| const { | |
| data: e, | |
| elements: s | |
| } = t; | |
| super(t, { | |
| isRenderable: zt._hasPopupData(e) | |
| }), this.elements = s, this.popup = null; | |
| } | |
| render() { | |
| this.container.classList.add("popupAnnotation"); | |
| const t = this.popup = new aT({ | |
| container: this.container, | |
| color: this.data.color, | |
| titleObj: this.data.titleObj, | |
| modificationDate: this.data.modificationDate, | |
| contentsObj: this.data.contentsObj, | |
| richText: this.data.richText, | |
| rect: this.data.rect, | |
| parentRect: this.data.parentRect || null, | |
| parent: this.parent, | |
| elements: this.elements, | |
| open: this.data.open | |
| }), e = []; | |
| for (const s of this.elements) | |
| s.popup = t, s.container.ariaHasPopup = "dialog", e.push(s.data.id), s.addHighlightArea(); | |
| return this.container.setAttribute("aria-controls", e.map((s) => `${Hp}${s}`).join(",")), this.container; | |
| } | |
| } | |
| var po, rd, ad, go, Fr, jt, Li, mo, Kc, Jc, yo, Di, ks, Fi, Qc, $i, th, $r, jr, wt, au, Xf, qb, Wb, Xb, Zb, ou, lu, Zf; | |
| class aT { | |
| constructor({ | |
| container: t, | |
| color: e, | |
| elements: s, | |
| titleObj: i, | |
| modificationDate: r, | |
| contentsObj: a, | |
| richText: l, | |
| parent: c, | |
| rect: h, | |
| parentRect: u, | |
| open: d | |
| }) { | |
| b(this, wt); | |
| b(this, po, v(this, wt, Xb).bind(this)); | |
| b(this, rd, v(this, wt, Zf).bind(this)); | |
| b(this, ad, v(this, wt, lu).bind(this)); | |
| b(this, go, v(this, wt, ou).bind(this)); | |
| b(this, Fr, null); | |
| b(this, jt, null); | |
| b(this, Li, null); | |
| b(this, mo, null); | |
| b(this, Kc, null); | |
| b(this, Jc, null); | |
| b(this, yo, null); | |
| b(this, Di, !1); | |
| b(this, ks, null); | |
| b(this, Fi, null); | |
| b(this, Qc, null); | |
| b(this, $i, null); | |
| b(this, th, null); | |
| b(this, $r, null); | |
| b(this, jr, !1); | |
| var f; | |
| p(this, jt, t), p(this, th, i), p(this, Li, a), p(this, $i, l), p(this, Jc, c), p(this, Fr, e), p(this, Qc, h), p(this, yo, u), p(this, Kc, s), p(this, mo, Vp.toDateObject(r)), this.trigger = s.flatMap((g) => g.getElementsToTriggerPopup()); | |
| for (const g of this.trigger) | |
| g.addEventListener("click", o(this, go)), g.addEventListener("mouseenter", o(this, ad)), g.addEventListener("mouseleave", o(this, rd)), g.classList.add("popupTriggerArea"); | |
| for (const g of s) | |
| (f = g.container) == null || f.addEventListener("keydown", o(this, po)); | |
| o(this, jt).hidden = !0, d && v(this, wt, ou).call(this); | |
| } | |
| render() { | |
| if (o(this, ks)) | |
| return; | |
| const t = p(this, ks, document.createElement("div")); | |
| if (t.className = "popup", o(this, Fr)) { | |
| const r = t.style.outlineColor = U.makeHexColor(...o(this, Fr)); | |
| CSS.supports("background-color", "color-mix(in srgb, red 30%, white)") ? t.style.backgroundColor = `color-mix(in srgb, ${r} 30%, white)` : t.style.backgroundColor = U.makeHexColor(...o(this, Fr).map((l) => Math.floor(0.7 * (255 - l) + l))); | |
| } | |
| const e = document.createElement("span"); | |
| e.className = "header"; | |
| const s = document.createElement("h1"); | |
| if (e.append(s), { | |
| dir: s.dir, | |
| str: s.textContent | |
| } = o(this, th), t.append(e), o(this, mo)) { | |
| const r = document.createElement("span"); | |
| r.classList.add("popupDate"), r.setAttribute("data-l10n-id", "pdfjs-annotation-date-time-string"), r.setAttribute("data-l10n-args", JSON.stringify({ | |
| dateObj: o(this, mo).valueOf() | |
| })), e.append(r); | |
| } | |
| const i = o(this, wt, au); | |
| if (i) | |
| Hb.render({ | |
| xfaHtml: i, | |
| intent: "richText", | |
| div: t | |
| }), t.lastChild.classList.add("richText", "popupContent"); | |
| else { | |
| const r = this._formatContents(o(this, Li)); | |
| t.append(r); | |
| } | |
| o(this, jt).append(t); | |
| } | |
| _formatContents({ | |
| str: t, | |
| dir: e | |
| }) { | |
| const s = document.createElement("p"); | |
| s.classList.add("popupContent"), s.dir = e; | |
| const i = t.split(/(?:\r\n?|\n)/); | |
| for (let r = 0, a = i.length; r < a; ++r) { | |
| const l = i[r]; | |
| s.append(document.createTextNode(l)), r < a - 1 && s.append(document.createElement("br")); | |
| } | |
| return s; | |
| } | |
| updateEdited({ | |
| rect: t, | |
| popupContent: e | |
| }) { | |
| var s; | |
| o(this, $r) || p(this, $r, { | |
| contentsObj: o(this, Li), | |
| richText: o(this, $i) | |
| }), t && p(this, Fi, null), e && (p(this, $i, v(this, wt, Wb).call(this, e)), p(this, Li, null)), (s = o(this, ks)) == null || s.remove(), p(this, ks, null); | |
| } | |
| resetEdited() { | |
| var t; | |
| o(this, $r) && ({ | |
| contentsObj: xe(this, Li)._, | |
| richText: xe(this, $i)._ | |
| } = o(this, $r), p(this, $r, null), (t = o(this, ks)) == null || t.remove(), p(this, ks, null), p(this, Fi, null)); | |
| } | |
| forceHide() { | |
| p(this, jr, this.isVisible), o(this, jr) && (o(this, jt).hidden = !0); | |
| } | |
| maybeShow() { | |
| o(this, jr) && (o(this, ks) || v(this, wt, lu).call(this), p(this, jr, !1), o(this, jt).hidden = !1); | |
| } | |
| get isVisible() { | |
| return o(this, jt).hidden === !1; | |
| } | |
| } | |
| po = new WeakMap(), rd = new WeakMap(), ad = new WeakMap(), go = new WeakMap(), Fr = new WeakMap(), jt = new WeakMap(), Li = new WeakMap(), mo = new WeakMap(), Kc = new WeakMap(), Jc = new WeakMap(), yo = new WeakMap(), Di = new WeakMap(), ks = new WeakMap(), Fi = new WeakMap(), Qc = new WeakMap(), $i = new WeakMap(), th = new WeakMap(), $r = new WeakMap(), jr = new WeakMap(), wt = new WeakSet(), au = function() { | |
| const t = o(this, $i), e = o(this, Li); | |
| return t != null && t.str && (!(e != null && e.str) || e.str === t.str) && o(this, $i).html || null; | |
| }, Xf = function() { | |
| var t, e, s; | |
| return ((s = (e = (t = o(this, wt, au)) == null ? void 0 : t.attributes) == null ? void 0 : e.style) == null ? void 0 : s.fontSize) || 0; | |
| }, qb = function() { | |
| var t, e, s; | |
| return ((s = (e = (t = o(this, wt, au)) == null ? void 0 : t.attributes) == null ? void 0 : e.style) == null ? void 0 : s.color) || null; | |
| }, Wb = function(t) { | |
| const e = [], s = { | |
| str: t, | |
| html: { | |
| name: "div", | |
| attributes: { | |
| dir: "auto" | |
| }, | |
| children: [{ | |
| name: "p", | |
| children: e | |
| }] | |
| } | |
| }, i = { | |
| style: { | |
| color: o(this, wt, qb), | |
| fontSize: o(this, wt, Xf) ? `calc(${o(this, wt, Xf)}px * var(--scale-factor))` : "" | |
| } | |
| }; | |
| for (const r of t.split(` | |
| `)) | |
| e.push({ | |
| name: "span", | |
| value: r, | |
| attributes: i | |
| }); | |
| return s; | |
| }, Xb = function(t) { | |
| t.altKey || t.shiftKey || t.ctrlKey || t.metaKey || (t.key === "Enter" || t.key === "Escape" && o(this, Di)) && v(this, wt, ou).call(this); | |
| }, Zb = function() { | |
| if (o(this, Fi) !== null) | |
| return; | |
| const { | |
| page: { | |
| view: t | |
| }, | |
| viewport: { | |
| rawDims: { | |
| pageWidth: e, | |
| pageHeight: s, | |
| pageX: i, | |
| pageY: r | |
| } | |
| } | |
| } = o(this, Jc); | |
| let a = !!o(this, yo), l = a ? o(this, yo) : o(this, Qc); | |
| for (const m of o(this, Kc)) | |
| if (!l || U.intersect(m.data.rect, l) !== null) { | |
| l = m.data.rect, a = !0; | |
| break; | |
| } | |
| const c = U.normalizeRect([l[0], t[3] - l[1] + t[1], l[2], t[3] - l[3] + t[1]]), u = a ? l[2] - l[0] + 5 : 0, d = c[0] + u, f = c[1]; | |
| p(this, Fi, [100 * (d - i) / e, 100 * (f - r) / s]); | |
| const { | |
| style: g | |
| } = o(this, jt); | |
| g.left = `${o(this, Fi)[0]}%`, g.top = `${o(this, Fi)[1]}%`; | |
| }, ou = function() { | |
| p(this, Di, !o(this, Di)), o(this, Di) ? (v(this, wt, lu).call(this), o(this, jt).addEventListener("click", o(this, go)), o(this, jt).addEventListener("keydown", o(this, po))) : (v(this, wt, Zf).call(this), o(this, jt).removeEventListener("click", o(this, go)), o(this, jt).removeEventListener("keydown", o(this, po))); | |
| }, lu = function() { | |
| o(this, ks) || this.render(), this.isVisible ? o(this, Di) && o(this, jt).classList.add("focused") : (v(this, wt, Zb).call(this), o(this, jt).hidden = !1, o(this, jt).style.zIndex = parseInt(o(this, jt).style.zIndex) + 1e3); | |
| }, Zf = function() { | |
| o(this, jt).classList.remove("focused"), !(o(this, Di) || !this.isVisible) && (o(this, jt).hidden = !0, o(this, jt).style.zIndex = parseInt(o(this, jt).style.zIndex) - 1e3); | |
| }; | |
| class Yb extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }), this.textContent = t.data.textContent, this.textPosition = t.data.textPosition, this.annotationEditorType = et.FREETEXT; | |
| } | |
| render() { | |
| if (this.container.classList.add("freeTextAnnotation"), this.textContent) { | |
| const t = document.createElement("div"); | |
| t.classList.add("annotationTextContent"), t.setAttribute("role", "comment"); | |
| for (const e of this.textContent) { | |
| const s = document.createElement("span"); | |
| s.textContent = e, t.append(s); | |
| } | |
| this.container.append(t); | |
| } | |
| return !this.data.popupRef && this.hasPopupData && this._createPopup(), this._editOnDoubleClick(), this.container; | |
| } | |
| } | |
| var eh; | |
| class oT extends zt { | |
| constructor(e) { | |
| super(e, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }); | |
| b(this, eh, null); | |
| } | |
| render() { | |
| this.container.classList.add("lineAnnotation"); | |
| const e = this.data, { | |
| width: s, | |
| height: i | |
| } = Ln(e.rect), r = this.svgFactory.create(s, i, !0), a = p(this, eh, this.svgFactory.createElement("svg:line")); | |
| return a.setAttribute("x1", e.rect[2] - e.lineCoordinates[0]), a.setAttribute("y1", e.rect[3] - e.lineCoordinates[1]), a.setAttribute("x2", e.rect[2] - e.lineCoordinates[2]), a.setAttribute("y2", e.rect[3] - e.lineCoordinates[3]), a.setAttribute("stroke-width", e.borderStyle.width || 1), a.setAttribute("stroke", "transparent"), a.setAttribute("fill", "transparent"), r.append(a), this.container.append(r), !e.popupRef && this.hasPopupData && this._createPopup(), this.container; | |
| } | |
| getElementsToTriggerPopup() { | |
| return o(this, eh); | |
| } | |
| addHighlightArea() { | |
| this.container.classList.add("highlightArea"); | |
| } | |
| } | |
| eh = new WeakMap(); | |
| var sh; | |
| class lT extends zt { | |
| constructor(e) { | |
| super(e, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }); | |
| b(this, sh, null); | |
| } | |
| render() { | |
| this.container.classList.add("squareAnnotation"); | |
| const e = this.data, { | |
| width: s, | |
| height: i | |
| } = Ln(e.rect), r = this.svgFactory.create(s, i, !0), a = e.borderStyle.width, l = p(this, sh, this.svgFactory.createElement("svg:rect")); | |
| return l.setAttribute("x", a / 2), l.setAttribute("y", a / 2), l.setAttribute("width", s - a), l.setAttribute("height", i - a), l.setAttribute("stroke-width", a || 1), l.setAttribute("stroke", "transparent"), l.setAttribute("fill", "transparent"), r.append(l), this.container.append(r), !e.popupRef && this.hasPopupData && this._createPopup(), this.container; | |
| } | |
| getElementsToTriggerPopup() { | |
| return o(this, sh); | |
| } | |
| addHighlightArea() { | |
| this.container.classList.add("highlightArea"); | |
| } | |
| } | |
| sh = new WeakMap(); | |
| var ih; | |
| class cT extends zt { | |
| constructor(e) { | |
| super(e, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }); | |
| b(this, ih, null); | |
| } | |
| render() { | |
| this.container.classList.add("circleAnnotation"); | |
| const e = this.data, { | |
| width: s, | |
| height: i | |
| } = Ln(e.rect), r = this.svgFactory.create(s, i, !0), a = e.borderStyle.width, l = p(this, ih, this.svgFactory.createElement("svg:ellipse")); | |
| return l.setAttribute("cx", s / 2), l.setAttribute("cy", i / 2), l.setAttribute("rx", s / 2 - a / 2), l.setAttribute("ry", i / 2 - a / 2), l.setAttribute("stroke-width", a || 1), l.setAttribute("stroke", "transparent"), l.setAttribute("fill", "transparent"), r.append(l), this.container.append(r), !e.popupRef && this.hasPopupData && this._createPopup(), this.container; | |
| } | |
| getElementsToTriggerPopup() { | |
| return o(this, ih); | |
| } | |
| addHighlightArea() { | |
| this.container.classList.add("highlightArea"); | |
| } | |
| } | |
| ih = new WeakMap(); | |
| var nh; | |
| class Kb extends zt { | |
| constructor(e) { | |
| super(e, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }); | |
| b(this, nh, null); | |
| this.containerClassName = "polylineAnnotation", this.svgElementName = "svg:polyline"; | |
| } | |
| render() { | |
| this.container.classList.add(this.containerClassName); | |
| const { | |
| data: { | |
| rect: e, | |
| vertices: s, | |
| borderStyle: i, | |
| popupRef: r | |
| } | |
| } = this; | |
| if (!s) | |
| return this.container; | |
| const { | |
| width: a, | |
| height: l | |
| } = Ln(e), c = this.svgFactory.create(a, l, !0); | |
| let h = []; | |
| for (let d = 0, f = s.length; d < f; d += 2) { | |
| const g = s[d] - e[0], m = e[3] - s[d + 1]; | |
| h.push(`${g},${m}`); | |
| } | |
| h = h.join(" "); | |
| const u = p(this, nh, this.svgFactory.createElement(this.svgElementName)); | |
| return u.setAttribute("points", h), u.setAttribute("stroke-width", i.width || 1), u.setAttribute("stroke", "transparent"), u.setAttribute("fill", "transparent"), c.append(u), this.container.append(c), !r && this.hasPopupData && this._createPopup(), this.container; | |
| } | |
| getElementsToTriggerPopup() { | |
| return o(this, nh); | |
| } | |
| addHighlightArea() { | |
| this.container.classList.add("highlightArea"); | |
| } | |
| } | |
| nh = new WeakMap(); | |
| class hT extends Kb { | |
| constructor(t) { | |
| super(t), this.containerClassName = "polygonAnnotation", this.svgElementName = "svg:polygon"; | |
| } | |
| } | |
| class uT extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }); | |
| } | |
| render() { | |
| return this.container.classList.add("caretAnnotation"), !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container; | |
| } | |
| } | |
| var rh, Br, ah, Yf; | |
| class Zp extends zt { | |
| constructor(e) { | |
| super(e, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }); | |
| b(this, ah); | |
| b(this, rh, null); | |
| b(this, Br, []); | |
| this.containerClassName = "inkAnnotation", this.svgElementName = "svg:polyline", this.annotationEditorType = this.data.it === "InkHighlight" ? et.HIGHLIGHT : et.INK; | |
| } | |
| render() { | |
| this.container.classList.add(this.containerClassName); | |
| const { | |
| data: { | |
| rect: e, | |
| rotation: s, | |
| inkLists: i, | |
| borderStyle: r, | |
| popupRef: a | |
| } | |
| } = this, { | |
| transform: l, | |
| width: c, | |
| height: h | |
| } = v(this, ah, Yf).call(this, s, e), u = this.svgFactory.create(c, h, !0), d = p(this, rh, this.svgFactory.createElement("svg:g")); | |
| u.append(d), d.setAttribute("stroke-width", r.width || 1), d.setAttribute("stroke-linecap", "round"), d.setAttribute("stroke-linejoin", "round"), d.setAttribute("stroke-miterlimit", 10), d.setAttribute("stroke", "transparent"), d.setAttribute("fill", "transparent"), d.setAttribute("transform", l); | |
| for (let f = 0, g = i.length; f < g; f++) { | |
| const m = this.svgFactory.createElement(this.svgElementName); | |
| o(this, Br).push(m), m.setAttribute("points", i[f].join(",")), d.append(m); | |
| } | |
| return !a && this.hasPopupData && this._createPopup(), this.container.append(u), this._editOnDoubleClick(), this.container; | |
| } | |
| updateEdited(e) { | |
| super.updateEdited(e); | |
| const { | |
| thickness: s, | |
| points: i, | |
| rect: r | |
| } = e, a = o(this, rh); | |
| if (s >= 0 && a.setAttribute("stroke-width", s || 1), i) | |
| for (let l = 0, c = o(this, Br).length; l < c; l++) | |
| o(this, Br)[l].setAttribute("points", i[l].join(",")); | |
| if (r) { | |
| const { | |
| transform: l, | |
| width: c, | |
| height: h | |
| } = v(this, ah, Yf).call(this, this.data.rotation, r); | |
| a.parentElement.setAttribute("viewBox", `0 0 ${c} ${h}`), a.setAttribute("transform", l); | |
| } | |
| } | |
| getElementsToTriggerPopup() { | |
| return o(this, Br); | |
| } | |
| addHighlightArea() { | |
| this.container.classList.add("highlightArea"); | |
| } | |
| } | |
| rh = new WeakMap(), Br = new WeakMap(), ah = new WeakSet(), Yf = function(e, s) { | |
| switch (e) { | |
| case 90: | |
| return { | |
| transform: `rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`, | |
| width: s[3] - s[1], | |
| height: s[2] - s[0] | |
| }; | |
| case 180: | |
| return { | |
| transform: `rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`, | |
| width: s[2] - s[0], | |
| height: s[3] - s[1] | |
| }; | |
| case 270: | |
| return { | |
| transform: `rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`, | |
| width: s[3] - s[1], | |
| height: s[2] - s[0] | |
| }; | |
| default: | |
| return { | |
| transform: `translate(${-s[0]},${s[3]}) scale(1,-1)`, | |
| width: s[2] - s[0], | |
| height: s[3] - s[1] | |
| }; | |
| } | |
| }; | |
| class Jb extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0, | |
| createQuadrilaterals: !0 | |
| }), this.annotationEditorType = et.HIGHLIGHT; | |
| } | |
| render() { | |
| return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("highlightAnnotation"), this._editOnDoubleClick(), this.container; | |
| } | |
| } | |
| class dT extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0, | |
| createQuadrilaterals: !0 | |
| }); | |
| } | |
| render() { | |
| return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("underlineAnnotation"), this.container; | |
| } | |
| } | |
| class fT extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0, | |
| createQuadrilaterals: !0 | |
| }); | |
| } | |
| render() { | |
| return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("squigglyAnnotation"), this.container; | |
| } | |
| } | |
| class pT extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0, | |
| createQuadrilaterals: !0 | |
| }); | |
| } | |
| render() { | |
| return !this.data.popupRef && this.hasPopupData && this._createPopup(), this.container.classList.add("strikeoutAnnotation"), this.container; | |
| } | |
| } | |
| class Qb extends zt { | |
| constructor(t) { | |
| super(t, { | |
| isRenderable: !0, | |
| ignoreBorder: !0 | |
| }), this.annotationEditorType = et.STAMP; | |
| } | |
| render() { | |
| return this.container.classList.add("stampAnnotation"), this.container.setAttribute("role", "img"), !this.data.popupRef && this.hasPopupData && this._createPopup(), this._editOnDoubleClick(), this.container; | |
| } | |
| } | |
| var oh, lh, Kf; | |
| class gT extends zt { | |
| constructor(e) { | |
| var i; | |
| super(e, { | |
| isRenderable: !0 | |
| }); | |
| b(this, lh); | |
| b(this, oh, null); | |
| const { | |
| file: s | |
| } = this.data; | |
| this.filename = s.filename, this.content = s.content, (i = this.linkService.eventBus) == null || i.dispatch("fileattachmentannotation", { | |
| source: this, | |
| ...s | |
| }); | |
| } | |
| render() { | |
| this.container.classList.add("fileAttachmentAnnotation"); | |
| const { | |
| container: e, | |
| data: s | |
| } = this; | |
| let i; | |
| s.hasAppearance || s.fillAlpha === 0 ? i = document.createElement("div") : (i = document.createElement("img"), i.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name) ? "paperclip" : "pushpin"}.svg`, s.fillAlpha && s.fillAlpha < 1 && (i.style = `filter: opacity(${Math.round(s.fillAlpha * 100)}%);`)), i.addEventListener("dblclick", v(this, lh, Kf).bind(this)), p(this, oh, i); | |
| const { | |
| isMac: r | |
| } = Me.platform; | |
| return e.addEventListener("keydown", (a) => { | |
| a.key === "Enter" && (r ? a.metaKey : a.ctrlKey) && v(this, lh, Kf).call(this); | |
| }), !s.popupRef && this.hasPopupData ? this._createPopup() : i.classList.add("popupTriggerArea"), e.append(i), e; | |
| } | |
| getElementsToTriggerPopup() { | |
| return o(this, oh); | |
| } | |
| addHighlightArea() { | |
| this.container.classList.add("highlightArea"); | |
| } | |
| } | |
| oh = new WeakMap(), lh = new WeakSet(), Kf = function() { | |
| var e; | |
| (e = this.downloadManager) == null || e.openOrDownloadData(this.content, this.filename); | |
| }; | |
| var ch, Hr, Ur, hh, ma, tv, Jf; | |
| class mT { | |
| constructor({ | |
| div: t, | |
| accessibilityManager: e, | |
| annotationCanvasMap: s, | |
| annotationEditorUIManager: i, | |
| page: r, | |
| viewport: a, | |
| structTreeLayer: l | |
| }) { | |
| b(this, ma); | |
| b(this, ch, null); | |
| b(this, Hr, null); | |
| b(this, Ur, /* @__PURE__ */ new Map()); | |
| b(this, hh, null); | |
| this.div = t, p(this, ch, e), p(this, Hr, s), p(this, hh, l || null), this.page = r, this.viewport = a, this.zIndex = 0, this._annotationEditorUIManager = i; | |
| } | |
| hasEditableAnnotations() { | |
| return o(this, Ur).size > 0; | |
| } | |
| async render(t) { | |
| var a; | |
| const { | |
| annotations: e | |
| } = t, s = this.div; | |
| fa(s, this.viewport); | |
| const i = /* @__PURE__ */ new Map(), r = { | |
| data: null, | |
| layer: s, | |
| linkService: t.linkService, | |
| downloadManager: t.downloadManager, | |
| imageResourcesPath: t.imageResourcesPath || "", | |
| renderForms: t.renderForms !== !1, | |
| svgFactory: new Xp(), | |
| annotationStorage: t.annotationStorage || new qp(), | |
| enableScripting: t.enableScripting === !0, | |
| hasJSActions: t.hasJSActions, | |
| fieldObjects: t.fieldObjects, | |
| parent: this, | |
| elements: null | |
| }; | |
| for (const l of e) { | |
| if (l.noHTML) | |
| continue; | |
| const c = l.annotationType === Xt.POPUP; | |
| if (c) { | |
| const d = i.get(l.id); | |
| if (!d) | |
| continue; | |
| r.elements = d; | |
| } else { | |
| const { | |
| width: d, | |
| height: f | |
| } = Ln(l.rect); | |
| if (d <= 0 || f <= 0) | |
| continue; | |
| } | |
| r.data = l; | |
| const h = Qx.create(r); | |
| if (!h.isRenderable) | |
| continue; | |
| if (!c && l.popupRef) { | |
| const d = i.get(l.popupRef); | |
| d ? d.push(h) : i.set(l.popupRef, [h]); | |
| } | |
| const u = h.render(); | |
| l.hidden && (u.style.visibility = "hidden"), await v(this, ma, tv).call(this, u, l.id), h._isEditable && (o(this, Ur).set(h.data.id, h), (a = this._annotationEditorUIManager) == null || a.renderAnnotationElement(h)); | |
| } | |
| v(this, ma, Jf).call(this); | |
| } | |
| update({ | |
| viewport: t | |
| }) { | |
| const e = this.div; | |
| this.viewport = t, fa(e, { | |
| rotation: t.rotation | |
| }), v(this, ma, Jf).call(this), e.hidden = !1; | |
| } | |
| getEditableAnnotations() { | |
| return Array.from(o(this, Ur).values()); | |
| } | |
| getEditableAnnotation(t) { | |
| return o(this, Ur).get(t); | |
| } | |
| } | |
| ch = new WeakMap(), Hr = new WeakMap(), Ur = new WeakMap(), hh = new WeakMap(), ma = new WeakSet(), tv = async function(t, e) { | |
| var a, l; | |
| const s = t.firstChild || t, i = s.id = `${Hp}${e}`, r = await ((a = o(this, hh)) == null ? void 0 : a.getAriaAttributes(i)); | |
| if (r) | |
| for (const [c, h] of r) | |
| s.setAttribute(c, h); | |
| this.div.append(t), (l = o(this, ch)) == null || l.moveElementInDOM(this.div, t, s, !1); | |
| }, Jf = function() { | |
| if (!o(this, Hr)) | |
| return; | |
| const t = this.div; | |
| for (const [e, s] of o(this, Hr)) { | |
| const i = t.querySelector(`[data-annotation-id="${e}"]`); | |
| if (!i) | |
| continue; | |
| s.className = "annotationContent"; | |
| const { | |
| firstChild: r | |
| } = i; | |
| r ? r.nodeName === "CANVAS" ? r.replaceWith(s) : r.classList.contains("annotationContent") ? r.after(s) : r.before(s) : i.append(s); | |
| } | |
| o(this, Hr).clear(); | |
| }; | |
| const Uh = /\r\n?|\n/g; | |
| var Is, We, uh, zr, Xe, Wt, ev, sv, iv, cu, Xi, hu, uu, nv, tp, rv; | |
| const Ct = class Ct extends Ft { | |
| constructor(e) { | |
| super({ | |
| ...e, | |
| name: "freeTextEditor" | |
| }); | |
| b(this, Wt); | |
| b(this, Is); | |
| b(this, We, ""); | |
| b(this, uh, `${this.id}-editor`); | |
| b(this, zr, null); | |
| b(this, Xe); | |
| p(this, Is, e.color || Ct._defaultColor || Ft._defaultLineColor), p(this, Xe, e.fontSize || Ct._defaultFontSize); | |
| } | |
| static get _keyboardManager() { | |
| const e = Ct.prototype, s = (a) => a.isEmpty(), i = pa.TRANSLATE_SMALL, r = pa.TRANSLATE_BIG; | |
| return at(this, "_keyboardManager", new Oh([[["ctrl+s", "mac+meta+s", "ctrl+p", "mac+meta+p"], e.commitOrRemove, { | |
| bubbles: !0 | |
| }], [["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], e.commitOrRemove], [["ArrowLeft", "mac+ArrowLeft"], e._translateEmpty, { | |
| args: [-i, 0], | |
| checker: s | |
| }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], e._translateEmpty, { | |
| args: [-r, 0], | |
| checker: s | |
| }], [["ArrowRight", "mac+ArrowRight"], e._translateEmpty, { | |
| args: [i, 0], | |
| checker: s | |
| }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], e._translateEmpty, { | |
| args: [r, 0], | |
| checker: s | |
| }], [["ArrowUp", "mac+ArrowUp"], e._translateEmpty, { | |
| args: [0, -i], | |
| checker: s | |
| }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], e._translateEmpty, { | |
| args: [0, -r], | |
| checker: s | |
| }], [["ArrowDown", "mac+ArrowDown"], e._translateEmpty, { | |
| args: [0, i], | |
| checker: s | |
| }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], e._translateEmpty, { | |
| args: [0, r], | |
| checker: s | |
| }]])); | |
| } | |
| static initialize(e, s) { | |
| Ft.initialize(e, s); | |
| const i = getComputedStyle(document.documentElement); | |
| this._internalPadding = parseFloat(i.getPropertyValue("--freetext-padding")); | |
| } | |
| static updateDefaultParams(e, s) { | |
| switch (e) { | |
| case lt.FREETEXT_SIZE: | |
| Ct._defaultFontSize = s; | |
| break; | |
| case lt.FREETEXT_COLOR: | |
| Ct._defaultColor = s; | |
| break; | |
| } | |
| } | |
| updateParams(e, s) { | |
| switch (e) { | |
| case lt.FREETEXT_SIZE: | |
| v(this, Wt, ev).call(this, s); | |
| break; | |
| case lt.FREETEXT_COLOR: | |
| v(this, Wt, sv).call(this, s); | |
| break; | |
| } | |
| } | |
| static get defaultPropertiesToUpdate() { | |
| return [[lt.FREETEXT_SIZE, Ct._defaultFontSize], [lt.FREETEXT_COLOR, Ct._defaultColor || Ft._defaultLineColor]]; | |
| } | |
| get propertiesToUpdate() { | |
| return [[lt.FREETEXT_SIZE, o(this, Xe)], [lt.FREETEXT_COLOR, o(this, Is)]]; | |
| } | |
| _translateEmpty(e, s) { | |
| this._uiManager.translateSelectedEditors(e, s, !0); | |
| } | |
| getInitialTranslation() { | |
| const e = this.parentScale; | |
| return [-Ct._internalPadding * e, -(Ct._internalPadding + o(this, Xe)) * e]; | |
| } | |
| rebuild() { | |
| this.parent && (super.rebuild(), this.div !== null && (this.isAttachedToDOM || this.parent.add(this))); | |
| } | |
| enableEditMode() { | |
| if (this.isInEditMode()) | |
| return; | |
| this.parent.setEditingState(!1), this.parent.updateToolbar(et.FREETEXT), super.enableEditMode(), this.overlayDiv.classList.remove("enabled"), this.editorDiv.contentEditable = !0, this._isDraggable = !1, this.div.removeAttribute("aria-activedescendant"), p(this, zr, new AbortController()); | |
| const e = this._uiManager.combinedSignal(o(this, zr)); | |
| this.editorDiv.addEventListener("keydown", this.editorDivKeydown.bind(this), { | |
| signal: e | |
| }), this.editorDiv.addEventListener("focus", this.editorDivFocus.bind(this), { | |
| signal: e | |
| }), this.editorDiv.addEventListener("blur", this.editorDivBlur.bind(this), { | |
| signal: e | |
| }), this.editorDiv.addEventListener("input", this.editorDivInput.bind(this), { | |
| signal: e | |
| }), this.editorDiv.addEventListener("paste", this.editorDivPaste.bind(this), { | |
| signal: e | |
| }); | |
| } | |
| disableEditMode() { | |
| var e; | |
| this.isInEditMode() && (this.parent.setEditingState(!0), super.disableEditMode(), this.overlayDiv.classList.add("enabled"), this.editorDiv.contentEditable = !1, this.div.setAttribute("aria-activedescendant", o(this, uh)), this._isDraggable = !0, (e = o(this, zr)) == null || e.abort(), p(this, zr, null), this.div.focus({ | |
| preventScroll: !0 | |
| }), this.isEditing = !1, this.parent.div.classList.add("freetextEditing")); | |
| } | |
| focusin(e) { | |
| this._focusEventsAllowed && (super.focusin(e), e.target !== this.editorDiv && this.editorDiv.focus()); | |
| } | |
| onceAdded(e) { | |
| var s; | |
| this.width || (this.enableEditMode(), e && this.editorDiv.focus(), (s = this._initialOptions) != null && s.isCentered && this.center(), this._initialOptions = null); | |
| } | |
| isEmpty() { | |
| return !this.editorDiv || this.editorDiv.innerText.trim() === ""; | |
| } | |
| remove() { | |
| this.isEditing = !1, this.parent && (this.parent.setEditingState(!0), this.parent.div.classList.add("freetextEditing")), super.remove(); | |
| } | |
| commit() { | |
| if (!this.isInEditMode()) | |
| return; | |
| super.commit(), this.disableEditMode(); | |
| const e = o(this, We), s = p(this, We, v(this, Wt, iv).call(this).trimEnd()); | |
| if (e === s) | |
| return; | |
| const i = (r) => { | |
| if (p(this, We, r), !r) { | |
| this.remove(); | |
| return; | |
| } | |
| v(this, Wt, uu).call(this), this._uiManager.rebuild(this), v(this, Wt, cu).call(this); | |
| }; | |
| this.addCommands({ | |
| cmd: () => { | |
| i(s); | |
| }, | |
| undo: () => { | |
| i(e); | |
| }, | |
| mustExec: !1 | |
| }), v(this, Wt, cu).call(this); | |
| } | |
| shouldGetKeyboardEvents() { | |
| return this.isInEditMode(); | |
| } | |
| enterInEditMode() { | |
| this.enableEditMode(), this.editorDiv.focus(); | |
| } | |
| dblclick(e) { | |
| this.enterInEditMode(); | |
| } | |
| keydown(e) { | |
| e.target === this.div && e.key === "Enter" && (this.enterInEditMode(), e.preventDefault()); | |
| } | |
| editorDivKeydown(e) { | |
| Ct._keyboardManager.exec(this, e); | |
| } | |
| editorDivFocus(e) { | |
| this.isEditing = !0; | |
| } | |
| editorDivBlur(e) { | |
| this.isEditing = !1; | |
| } | |
| editorDivInput(e) { | |
| this.parent.div.classList.toggle("freetextEditing", this.isEmpty()); | |
| } | |
| disableEditing() { | |
| this.editorDiv.setAttribute("role", "comment"), this.editorDiv.removeAttribute("aria-multiline"); | |
| } | |
| enableEditing() { | |
| this.editorDiv.setAttribute("role", "textbox"), this.editorDiv.setAttribute("aria-multiline", !0); | |
| } | |
| render() { | |
| if (this.div) | |
| return this.div; | |
| let e, s; | |
| this.width && (e = this.x, s = this.y), super.render(), this.editorDiv = document.createElement("div"), this.editorDiv.className = "internal", this.editorDiv.setAttribute("id", o(this, uh)), this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text2"), this.editorDiv.setAttribute("data-l10n-attrs", "default-content"), this.enableEditing(), this.editorDiv.contentEditable = !0; | |
| const { | |
| style: i | |
| } = this.editorDiv; | |
| if (i.fontSize = `calc(${o(this, Xe)}px * var(--scale-factor))`, i.color = o(this, Is), this.div.append(this.editorDiv), this.overlayDiv = document.createElement("div"), this.overlayDiv.classList.add("overlay", "enabled"), this.div.append(this.overlayDiv), ju(this, this.div, ["dblclick", "keydown"]), this.width) { | |
| const [r, a] = this.parentDimensions; | |
| if (this.annotationElementId) { | |
| const { | |
| position: l | |
| } = this._initialData; | |
| let [c, h] = this.getInitialTranslation(); | |
| [c, h] = this.pageTranslationToScreen(c, h); | |
| const [u, d] = this.pageDimensions, [f, g] = this.pageTranslation; | |
| let m, y; | |
| switch (this.rotation) { | |
| case 0: | |
| m = e + (l[0] - f) / u, y = s + this.height - (l[1] - g) / d; | |
| break; | |
| case 90: | |
| m = e + (l[0] - f) / u, y = s - (l[1] - g) / d, [c, h] = [h, -c]; | |
| break; | |
| case 180: | |
| m = e - this.width + (l[0] - f) / u, y = s - (l[1] - g) / d, [c, h] = [-c, -h]; | |
| break; | |
| case 270: | |
| m = e + (l[0] - f - this.height * d) / u, y = s + (l[1] - g - this.width * u) / d, [c, h] = [-h, c]; | |
| break; | |
| } | |
| this.setAt(m * r, y * a, c, h); | |
| } else | |
| this.setAt(e * r, s * a, this.width * r, this.height * a); | |
| v(this, Wt, uu).call(this), this._isDraggable = !0, this.editorDiv.contentEditable = !1; | |
| } else | |
| this._isDraggable = !1, this.editorDiv.contentEditable = !0; | |
| return this.div; | |
| } | |
| editorDivPaste(e) { | |
| var m, y, _; | |
| const s = e.clipboardData || window.clipboardData, { | |
| types: i | |
| } = s; | |
| if (i.length === 1 && i[0] === "text/plain") | |
| return; | |
| e.preventDefault(); | |
| const r = v(m = Ct, Xi, tp).call(m, s.getData("text") || "").replaceAll(Uh, ` | |
| `); | |
| if (!r) | |
| return; | |
| const a = window.getSelection(); | |
| if (!a.rangeCount) | |
| return; | |
| this.editorDiv.normalize(), a.deleteFromDocument(); | |
| const l = a.getRangeAt(0); | |
| if (!r.includes(` | |
| `)) { | |
| l.insertNode(document.createTextNode(r)), this.editorDiv.normalize(), a.collapseToStart(); | |
| return; | |
| } | |
| const { | |
| startContainer: c, | |
| startOffset: h | |
| } = l, u = [], d = []; | |
| if (c.nodeType === Node.TEXT_NODE) { | |
| const A = c.parentElement; | |
| if (d.push(c.nodeValue.slice(h).replaceAll(Uh, "")), A !== this.editorDiv) { | |
| let S = u; | |
| for (const E of this.editorDiv.childNodes) { | |
| if (E === A) { | |
| S = d; | |
| continue; | |
| } | |
| S.push(v(y = Ct, Xi, hu).call(y, E)); | |
| } | |
| } | |
| u.push(c.nodeValue.slice(0, h).replaceAll(Uh, "")); | |
| } else if (c === this.editorDiv) { | |
| let A = u, S = 0; | |
| for (const E of this.editorDiv.childNodes) | |
| S++ === h && (A = d), A.push(v(_ = Ct, Xi, hu).call(_, E)); | |
| } | |
| p(this, We, `${u.join(` | |
| `)}${r}${d.join(` | |
| `)}`), v(this, Wt, uu).call(this); | |
| const f = new Range(); | |
| let g = u.reduce((A, S) => A + S.length, 0); | |
| for (const { | |
| firstChild: A | |
| } of this.editorDiv.childNodes) | |
| if (A.nodeType === Node.TEXT_NODE) { | |
| const S = A.nodeValue.length; | |
| if (g <= S) { | |
| f.setStart(A, g), f.setEnd(A, g); | |
| break; | |
| } | |
| g -= S; | |
| } | |
| a.removeAllRanges(), a.addRange(f); | |
| } | |
| get contentDiv() { | |
| return this.editorDiv; | |
| } | |
| static async deserialize(e, s, i) { | |
| var l; | |
| let r = null; | |
| if (e instanceof Yb) { | |
| const { | |
| data: { | |
| defaultAppearanceData: { | |
| fontSize: c, | |
| fontColor: h | |
| }, | |
| rect: u, | |
| rotation: d, | |
| id: f, | |
| popupRef: g | |
| }, | |
| textContent: m, | |
| textPosition: y, | |
| parent: { | |
| page: { | |
| pageNumber: _ | |
| } | |
| } | |
| } = e; | |
| if (!m || m.length === 0) | |
| return null; | |
| r = e = { | |
| annotationType: et.FREETEXT, | |
| color: Array.from(h), | |
| fontSize: c, | |
| value: m.join(` | |
| `), | |
| position: y, | |
| pageIndex: _ - 1, | |
| rect: u.slice(0), | |
| rotation: d, | |
| id: f, | |
| deleted: !1, | |
| popupRef: g | |
| }; | |
| } | |
| const a = await super.deserialize(e, s, i); | |
| return p(a, Xe, e.fontSize), p(a, Is, U.makeHexColor(...e.color)), p(a, We, v(l = Ct, Xi, tp).call(l, e.value)), a.annotationElementId = e.id || null, a._initialData = r, a; | |
| } | |
| serialize(e = !1) { | |
| if (this.isEmpty()) | |
| return null; | |
| if (this.deleted) | |
| return this.serializeDeleted(); | |
| const s = Ct._internalPadding * this.parentScale, i = this.getRect(s, s), r = Ft._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : o(this, Is)), a = { | |
| annotationType: et.FREETEXT, | |
| color: r, | |
| fontSize: o(this, Xe), | |
| value: v(this, Wt, nv).call(this), | |
| pageIndex: this.pageIndex, | |
| rect: i, | |
| rotation: this.rotation, | |
| structTreeParentId: this._structTreeParentId | |
| }; | |
| return e ? a : this.annotationElementId && !v(this, Wt, rv).call(this, a) ? null : (a.id = this.annotationElementId, a); | |
| } | |
| renderAnnotationElement(e) { | |
| const s = super.renderAnnotationElement(e); | |
| if (this.deleted) | |
| return s; | |
| const { | |
| style: i | |
| } = s; | |
| i.fontSize = `calc(${o(this, Xe)}px * var(--scale-factor))`, i.color = o(this, Is), s.replaceChildren(); | |
| for (const a of o(this, We).split(` | |
| `)) { | |
| const l = document.createElement("div"); | |
| l.append(a ? document.createTextNode(a) : document.createElement("br")), s.append(l); | |
| } | |
| const r = Ct._internalPadding * this.parentScale; | |
| return e.updateEdited({ | |
| rect: this.getRect(r, r), | |
| popupContent: o(this, We) | |
| }), s; | |
| } | |
| resetAnnotationElement(e) { | |
| super.resetAnnotationElement(e), e.resetEdited(); | |
| } | |
| }; | |
| Is = new WeakMap(), We = new WeakMap(), uh = new WeakMap(), zr = new WeakMap(), Xe = new WeakMap(), Wt = new WeakSet(), ev = function(e) { | |
| const s = (r) => { | |
| this.editorDiv.style.fontSize = `calc(${r}px * var(--scale-factor))`, this.translate(0, -(r - o(this, Xe)) * this.parentScale), p(this, Xe, r), v(this, Wt, cu).call(this); | |
| }, i = o(this, Xe); | |
| this.addCommands({ | |
| cmd: s.bind(this, e), | |
| undo: s.bind(this, i), | |
| post: this._uiManager.updateUI.bind(this._uiManager, this), | |
| mustExec: !0, | |
| type: lt.FREETEXT_SIZE, | |
| overwriteIfSameType: !0, | |
| keepUndo: !0 | |
| }); | |
| }, sv = function(e) { | |
| const s = (r) => { | |
| p(this, Is, this.editorDiv.style.color = r); | |
| }, i = o(this, Is); | |
| this.addCommands({ | |
| cmd: s.bind(this, e), | |
| undo: s.bind(this, i), | |
| post: this._uiManager.updateUI.bind(this._uiManager, this), | |
| mustExec: !0, | |
| type: lt.FREETEXT_COLOR, | |
| overwriteIfSameType: !0, | |
| keepUndo: !0 | |
| }); | |
| }, iv = function() { | |
| var i; | |
| const e = []; | |
| this.editorDiv.normalize(); | |
| let s = null; | |
| for (const r of this.editorDiv.childNodes) | |
| (s == null ? void 0 : s.nodeType) === Node.TEXT_NODE && r.nodeName === "BR" || (e.push(v(i = Ct, Xi, hu).call(i, r)), s = r); | |
| return e.join(` | |
| `); | |
| }, cu = function() { | |
| const [e, s] = this.parentDimensions; | |
| let i; | |
| if (this.isAttachedToDOM) | |
| i = this.div.getBoundingClientRect(); | |
| else { | |
| const { | |
| currentLayer: r, | |
| div: a | |
| } = this, l = a.style.display, c = a.classList.contains("hidden"); | |
| a.classList.remove("hidden"), a.style.display = "hidden", r.div.append(this.div), i = a.getBoundingClientRect(), a.remove(), a.style.display = l, a.classList.toggle("hidden", c); | |
| } | |
| this.rotation % 180 === this.parentRotation % 180 ? (this.width = i.width / e, this.height = i.height / s) : (this.width = i.height / e, this.height = i.width / s), this.fixAndSetPosition(); | |
| }, Xi = new WeakSet(), hu = function(e) { | |
| return (e.nodeType === Node.TEXT_NODE ? e.nodeValue : e.innerText).replaceAll(Uh, ""); | |
| }, uu = function() { | |
| if (this.editorDiv.replaceChildren(), !!o(this, We)) | |
| for (const e of o(this, We).split(` | |
| `)) { | |
| const s = document.createElement("div"); | |
| s.append(e ? document.createTextNode(e) : document.createElement("br")), this.editorDiv.append(s); | |
| } | |
| }, nv = function() { | |
| return o(this, We).replaceAll(" ", " "); | |
| }, tp = function(e) { | |
| return e.replaceAll(" ", " "); | |
| }, rv = function(e) { | |
| const { | |
| value: s, | |
| fontSize: i, | |
| color: r, | |
| pageIndex: a | |
| } = this._initialData; | |
| return this._hasBeenMoved || e.value !== s || e.fontSize !== i || e.color.some((l, c) => l !== r[c]) || e.pageIndex !== a; | |
| }, b(Ct, Xi), G(Ct, "_freeTextDefaultContent", ""), G(Ct, "_internalPadding", 0), G(Ct, "_defaultColor", null), G(Ct, "_defaultFontSize", 10), G(Ct, "_type", "freetext"), G(Ct, "_editorType", et.FREETEXT); | |
| let Qf = Ct; | |
| class F { | |
| toSVGPath() { | |
| Et("Abstract method `toSVGPath` must be implemented."); | |
| } | |
| get box() { | |
| Et("Abstract getter `box` must be implemented."); | |
| } | |
| serialize(t, e) { | |
| Et("Abstract method `serialize` must be implemented."); | |
| } | |
| static _rescale(t, e, s, i, r, a) { | |
| a || (a = new Float32Array(t.length)); | |
| for (let l = 0, c = t.length; l < c; l += 2) | |
| a[l] = e + t[l] * i, a[l + 1] = s + t[l + 1] * r; | |
| return a; | |
| } | |
| static _rescaleAndSwap(t, e, s, i, r, a) { | |
| a || (a = new Float32Array(t.length)); | |
| for (let l = 0, c = t.length; l < c; l += 2) | |
| a[l] = e + t[l + 1] * i, a[l + 1] = s + t[l] * r; | |
| return a; | |
| } | |
| static _translate(t, e, s, i) { | |
| i || (i = new Float32Array(t.length)); | |
| for (let r = 0, a = t.length; r < a; r += 2) | |
| i[r] = e + t[r], i[r + 1] = s + t[r + 1]; | |
| return i; | |
| } | |
| static svgRound(t) { | |
| return Math.round(t * 1e4); | |
| } | |
| static _normalizePoint(t, e, s, i, r) { | |
| switch (r) { | |
| case 90: | |
| return [1 - e / s, t / i]; | |
| case 180: | |
| return [1 - t / s, 1 - e / i]; | |
| case 270: | |
| return [e / s, 1 - t / i]; | |
| default: | |
| return [t / s, e / i]; | |
| } | |
| } | |
| static _normalizePagePoint(t, e, s) { | |
| switch (s) { | |
| case 90: | |
| return [1 - e, t]; | |
| case 180: | |
| return [1 - t, 1 - e]; | |
| case 270: | |
| return [e, 1 - t]; | |
| default: | |
| return [t, e]; | |
| } | |
| } | |
| static createBezierPoints(t, e, s, i, r, a) { | |
| return [(t + 5 * s) / 6, (e + 5 * i) / 6, (5 * s + r) / 6, (5 * i + a) / 6, (s + r) / 2, (i + a) / 2]; | |
| } | |
| } | |
| G(F, "PRECISION", 1e-4); | |
| var Ze, Rs, bo, vo, ii, rt, Vr, Gr, dh, fh, _o, Ao, Sn, ph, od, ld, Jt, _l, av, ov, lv, cv, hv, uv; | |
| const vi = class vi { | |
| constructor({ | |
| x: t, | |
| y: e | |
| }, s, i, r, a, l = 0) { | |
| b(this, Jt); | |
| b(this, Ze); | |
| b(this, Rs, []); | |
| b(this, bo); | |
| b(this, vo); | |
| b(this, ii, []); | |
| b(this, rt, new Float32Array(18)); | |
| b(this, Vr); | |
| b(this, Gr); | |
| b(this, dh); | |
| b(this, fh); | |
| b(this, _o); | |
| b(this, Ao); | |
| b(this, Sn, []); | |
| p(this, Ze, s), p(this, Ao, r * i), p(this, vo, a), o(this, rt).set([NaN, NaN, NaN, NaN, t, e], 6), p(this, bo, l), p(this, fh, o(vi, ph) * i), p(this, dh, o(vi, ld) * i), p(this, _o, i), o(this, Sn).push(t, e); | |
| } | |
| isEmpty() { | |
| return isNaN(o(this, rt)[8]); | |
| } | |
| add({ | |
| x: t, | |
| y: e | |
| }) { | |
| var j; | |
| p(this, Vr, t), p(this, Gr, e); | |
| const [s, i, r, a] = o(this, Ze); | |
| let [l, c, h, u] = o(this, rt).subarray(8, 12); | |
| const d = t - h, f = e - u, g = Math.hypot(d, f); | |
| if (g < o(this, dh)) | |
| return !1; | |
| const m = g - o(this, fh), y = m / g, _ = y * d, A = y * f; | |
| let S = l, E = c; | |
| l = h, c = u, h += _, u += A, (j = o(this, Sn)) == null || j.push(t, e); | |
| const x = -A / m, T = _ / m, k = x * o(this, Ao), C = T * o(this, Ao); | |
| return o(this, rt).set(o(this, rt).subarray(2, 8), 0), o(this, rt).set([h + k, u + C], 4), o(this, rt).set(o(this, rt).subarray(14, 18), 12), o(this, rt).set([h - k, u - C], 16), isNaN(o(this, rt)[6]) ? (o(this, ii).length === 0 && (o(this, rt).set([l + k, c + C], 2), o(this, ii).push(NaN, NaN, NaN, NaN, (l + k - s) / r, (c + C - i) / a), o(this, rt).set([l - k, c - C], 14), o(this, Rs).push(NaN, NaN, NaN, NaN, (l - k - s) / r, (c - C - i) / a)), o(this, rt).set([S, E, l, c, h, u], 6), !this.isEmpty()) : (o(this, rt).set([S, E, l, c, h, u], 6), Math.abs(Math.atan2(E - c, S - l) - Math.atan2(A, _)) < Math.PI / 2 ? ([l, c, h, u] = o(this, rt).subarray(2, 6), o(this, ii).push(NaN, NaN, NaN, NaN, ((l + h) / 2 - s) / r, ((c + u) / 2 - i) / a), [l, c, S, E] = o(this, rt).subarray(14, 18), o(this, Rs).push(NaN, NaN, NaN, NaN, ((S + l) / 2 - s) / r, ((E + c) / 2 - i) / a), !0) : ([S, E, l, c, h, u] = o(this, rt).subarray(0, 6), o(this, ii).push(((S + 5 * l) / 6 - s) / r, ((E + 5 * c) / 6 - i) / a, ((5 * l + h) / 6 - s) / r, ((5 * c + u) / 6 - i) / a, ((l + h) / 2 - s) / r, ((c + u) / 2 - i) / a), [h, u, l, c, S, E] = o(this, rt).subarray(12, 18), o(this, Rs).push(((S + 5 * l) / 6 - s) / r, ((E + 5 * c) / 6 - i) / a, ((5 * l + h) / 6 - s) / r, ((5 * c + u) / 6 - i) / a, ((l + h) / 2 - s) / r, ((c + u) / 2 - i) / a), !0)); | |
| } | |
| toSVGPath() { | |
| if (this.isEmpty()) | |
| return ""; | |
| const t = o(this, ii), e = o(this, Rs); | |
| if (isNaN(o(this, rt)[6]) && !this.isEmpty()) | |
| return v(this, Jt, av).call(this); | |
| const s = []; | |
| s.push(`M${t[4]} ${t[5]}`); | |
| for (let i = 6; i < t.length; i += 6) | |
| isNaN(t[i]) ? s.push(`L${t[i + 4]} ${t[i + 5]}`) : s.push(`C${t[i]} ${t[i + 1]} ${t[i + 2]} ${t[i + 3]} ${t[i + 4]} ${t[i + 5]}`); | |
| v(this, Jt, lv).call(this, s); | |
| for (let i = e.length - 6; i >= 6; i -= 6) | |
| isNaN(e[i]) ? s.push(`L${e[i + 4]} ${e[i + 5]}`) : s.push(`C${e[i]} ${e[i + 1]} ${e[i + 2]} ${e[i + 3]} ${e[i + 4]} ${e[i + 5]}`); | |
| return v(this, Jt, ov).call(this, s), s.join(" "); | |
| } | |
| newFreeDrawOutline(t, e, s, i, r, a) { | |
| return new dv(t, e, s, i, r, a); | |
| } | |
| getOutlines() { | |
| var d; | |
| const t = o(this, ii), e = o(this, Rs), s = o(this, rt), [i, r, a, l] = o(this, Ze), c = new Float32Array((((d = o(this, Sn)) == null ? void 0 : d.length) ?? 0) + 2); | |
| for (let f = 0, g = c.length - 2; f < g; f += 2) | |
| c[f] = (o(this, Sn)[f] - i) / a, c[f + 1] = (o(this, Sn)[f + 1] - r) / l; | |
| if (c[c.length - 2] = (o(this, Vr) - i) / a, c[c.length - 1] = (o(this, Gr) - r) / l, isNaN(s[6]) && !this.isEmpty()) | |
| return v(this, Jt, cv).call(this, c); | |
| const h = new Float32Array(o(this, ii).length + 24 + o(this, Rs).length); | |
| let u = t.length; | |
| for (let f = 0; f < u; f += 2) { | |
| if (isNaN(t[f])) { | |
| h[f] = h[f + 1] = NaN; | |
| continue; | |
| } | |
| h[f] = t[f], h[f + 1] = t[f + 1]; | |
| } | |
| u = v(this, Jt, uv).call(this, h, u); | |
| for (let f = e.length - 6; f >= 6; f -= 6) | |
| for (let g = 0; g < 6; g += 2) { | |
| if (isNaN(e[f + g])) { | |
| h[u] = h[u + 1] = NaN, u += 2; | |
| continue; | |
| } | |
| h[u] = e[f + g], h[u + 1] = e[f + g + 1], u += 2; | |
| } | |
| return v(this, Jt, hv).call(this, h, u), this.newFreeDrawOutline(h, c, o(this, Ze), o(this, _o), o(this, bo), o(this, vo)); | |
| } | |
| }; | |
| Ze = new WeakMap(), Rs = new WeakMap(), bo = new WeakMap(), vo = new WeakMap(), ii = new WeakMap(), rt = new WeakMap(), Vr = new WeakMap(), Gr = new WeakMap(), dh = new WeakMap(), fh = new WeakMap(), _o = new WeakMap(), Ao = new WeakMap(), Sn = new WeakMap(), ph = new WeakMap(), od = new WeakMap(), ld = new WeakMap(), Jt = new WeakSet(), _l = function() { | |
| const t = o(this, rt).subarray(4, 6), e = o(this, rt).subarray(16, 18), [s, i, r, a] = o(this, Ze); | |
| return [(o(this, Vr) + (t[0] - e[0]) / 2 - s) / r, (o(this, Gr) + (t[1] - e[1]) / 2 - i) / a, (o(this, Vr) + (e[0] - t[0]) / 2 - s) / r, (o(this, Gr) + (e[1] - t[1]) / 2 - i) / a]; | |
| }, av = function() { | |
| const [t, e, s, i] = o(this, Ze), [r, a, l, c] = v(this, Jt, _l).call(this); | |
| return `M${(o(this, rt)[2] - t) / s} ${(o(this, rt)[3] - e) / i} L${(o(this, rt)[4] - t) / s} ${(o(this, rt)[5] - e) / i} L${r} ${a} L${l} ${c} L${(o(this, rt)[16] - t) / s} ${(o(this, rt)[17] - e) / i} L${(o(this, rt)[14] - t) / s} ${(o(this, rt)[15] - e) / i} Z`; | |
| }, ov = function(t) { | |
| const e = o(this, Rs); | |
| t.push(`L${e[4]} ${e[5]} Z`); | |
| }, lv = function(t) { | |
| const [e, s, i, r] = o(this, Ze), a = o(this, rt).subarray(4, 6), l = o(this, rt).subarray(16, 18), [c, h, u, d] = v(this, Jt, _l).call(this); | |
| t.push(`L${(a[0] - e) / i} ${(a[1] - s) / r} L${c} ${h} L${u} ${d} L${(l[0] - e) / i} ${(l[1] - s) / r}`); | |
| }, cv = function(t) { | |
| const e = o(this, rt), [s, i, r, a] = o(this, Ze), [l, c, h, u] = v(this, Jt, _l).call(this), d = new Float32Array(36); | |
| return d.set([NaN, NaN, NaN, NaN, (e[2] - s) / r, (e[3] - i) / a, NaN, NaN, NaN, NaN, (e[4] - s) / r, (e[5] - i) / a, NaN, NaN, NaN, NaN, l, c, NaN, NaN, NaN, NaN, h, u, NaN, NaN, NaN, NaN, (e[16] - s) / r, (e[17] - i) / a, NaN, NaN, NaN, NaN, (e[14] - s) / r, (e[15] - i) / a], 0), this.newFreeDrawOutline(d, t, o(this, Ze), o(this, _o), o(this, bo), o(this, vo)); | |
| }, hv = function(t, e) { | |
| const s = o(this, Rs); | |
| return t.set([NaN, NaN, NaN, NaN, s[4], s[5]], e), e += 6; | |
| }, uv = function(t, e) { | |
| const s = o(this, rt).subarray(4, 6), i = o(this, rt).subarray(16, 18), [r, a, l, c] = o(this, Ze), [h, u, d, f] = v(this, Jt, _l).call(this); | |
| return t.set([NaN, NaN, NaN, NaN, (s[0] - r) / l, (s[1] - a) / c, NaN, NaN, NaN, NaN, h, u, NaN, NaN, NaN, NaN, d, f, NaN, NaN, NaN, NaN, (i[0] - r) / l, (i[1] - a) / c], e), e += 24; | |
| }, b(vi, ph, 8), b(vi, od, 2), b(vi, ld, o(vi, ph) + o(vi, od)); | |
| let Uu = vi; | |
| var wo, qr, ji, gh, Ye, mh, Ut, cd, fv; | |
| class dv extends F { | |
| constructor(e, s, i, r, a, l) { | |
| super(); | |
| b(this, cd); | |
| b(this, wo); | |
| b(this, qr, new Float32Array(4)); | |
| b(this, ji); | |
| b(this, gh); | |
| b(this, Ye); | |
| b(this, mh); | |
| b(this, Ut); | |
| p(this, Ut, e), p(this, Ye, s), p(this, wo, i), p(this, mh, r), p(this, ji, a), p(this, gh, l), this.lastPoint = [NaN, NaN], v(this, cd, fv).call(this, l); | |
| const [c, h, u, d] = o(this, qr); | |
| for (let f = 0, g = e.length; f < g; f += 2) | |
| e[f] = (e[f] - c) / u, e[f + 1] = (e[f + 1] - h) / d; | |
| for (let f = 0, g = s.length; f < g; f += 2) | |
| s[f] = (s[f] - c) / u, s[f + 1] = (s[f + 1] - h) / d; | |
| } | |
| toSVGPath() { | |
| const e = [`M${o(this, Ut)[4]} ${o(this, Ut)[5]}`]; | |
| for (let s = 6, i = o(this, Ut).length; s < i; s += 6) { | |
| if (isNaN(o(this, Ut)[s])) { | |
| e.push(`L${o(this, Ut)[s + 4]} ${o(this, Ut)[s + 5]}`); | |
| continue; | |
| } | |
| e.push(`C${o(this, Ut)[s]} ${o(this, Ut)[s + 1]} ${o(this, Ut)[s + 2]} ${o(this, Ut)[s + 3]} ${o(this, Ut)[s + 4]} ${o(this, Ut)[s + 5]}`); | |
| } | |
| return e.push("Z"), e.join(" "); | |
| } | |
| serialize([e, s, i, r], a) { | |
| const l = i - e, c = r - s; | |
| let h, u; | |
| switch (a) { | |
| case 0: | |
| h = F._rescale(o(this, Ut), e, r, l, -c), u = F._rescale(o(this, Ye), e, r, l, -c); | |
| break; | |
| case 90: | |
| h = F._rescaleAndSwap(o(this, Ut), e, s, l, c), u = F._rescaleAndSwap(o(this, Ye), e, s, l, c); | |
| break; | |
| case 180: | |
| h = F._rescale(o(this, Ut), i, s, -l, c), u = F._rescale(o(this, Ye), i, s, -l, c); | |
| break; | |
| case 270: | |
| h = F._rescaleAndSwap(o(this, Ut), i, r, -l, -c), u = F._rescaleAndSwap(o(this, Ye), i, r, -l, -c); | |
| break; | |
| } | |
| return { | |
| outline: Array.from(h), | |
| points: [Array.from(u)] | |
| }; | |
| } | |
| get box() { | |
| return o(this, qr); | |
| } | |
| newOutliner(e, s, i, r, a, l = 0) { | |
| return new Uu(e, s, i, r, a, l); | |
| } | |
| getNewOutline(e, s) { | |
| const [i, r, a, l] = o(this, qr), [c, h, u, d] = o(this, wo), f = a * u, g = l * d, m = i * u + c, y = r * d + h, _ = this.newOutliner({ | |
| x: o(this, Ye)[0] * f + m, | |
| y: o(this, Ye)[1] * g + y | |
| }, o(this, wo), o(this, mh), e, o(this, gh), s ?? o(this, ji)); | |
| for (let A = 2; A < o(this, Ye).length; A += 2) | |
| _.add({ | |
| x: o(this, Ye)[A] * f + m, | |
| y: o(this, Ye)[A + 1] * g + y | |
| }); | |
| return _.getOutlines(); | |
| } | |
| } | |
| wo = new WeakMap(), qr = new WeakMap(), ji = new WeakMap(), gh = new WeakMap(), Ye = new WeakMap(), mh = new WeakMap(), Ut = new WeakMap(), cd = new WeakSet(), fv = function(e) { | |
| const s = o(this, Ut); | |
| let i = s[4], r = s[5], a = i, l = r, c = i, h = r, u = i, d = r; | |
| const f = e ? Math.max : Math.min; | |
| for (let m = 6, y = s.length; m < y; m += 6) { | |
| if (isNaN(s[m])) | |
| a = Math.min(a, s[m + 4]), l = Math.min(l, s[m + 5]), c = Math.max(c, s[m + 4]), h = Math.max(h, s[m + 5]), d < s[m + 5] ? (u = s[m + 4], d = s[m + 5]) : d === s[m + 5] && (u = f(u, s[m + 4])); | |
| else { | |
| const _ = U.bezierBoundingBox(i, r, ...s.slice(m, m + 6)); | |
| a = Math.min(a, _[0]), l = Math.min(l, _[1]), c = Math.max(c, _[2]), h = Math.max(h, _[3]), d < _[3] ? (u = _[2], d = _[3]) : d === _[3] && (u = f(u, _[2])); | |
| } | |
| i = s[m + 4], r = s[m + 5]; | |
| } | |
| const g = o(this, qr); | |
| g[0] = a - o(this, ji), g[1] = l - o(this, ji), g[2] = c - a + 2 * o(this, ji), g[3] = h - l + 2 * o(this, ji), this.lastPoint = [u, d]; | |
| }; | |
| var yh, bh, En, Ps, Oe, pv, du, gv, mv, sp; | |
| class ep { | |
| constructor(t, e = 0, s = 0, i = !0) { | |
| b(this, Oe); | |
| b(this, yh); | |
| b(this, bh); | |
| b(this, En, []); | |
| b(this, Ps, []); | |
| let r = 1 / 0, a = -1 / 0, l = 1 / 0, c = -1 / 0; | |
| const h = 10 ** -4; | |
| for (const { | |
| x: _, | |
| y: A, | |
| width: S, | |
| height: E | |
| } of t) { | |
| const x = Math.floor((_ - e) / h) * h, T = Math.ceil((_ + S + e) / h) * h, k = Math.floor((A - e) / h) * h, C = Math.ceil((A + E + e) / h) * h, P = [x, k, C, !0], j = [T, k, C, !1]; | |
| o(this, En).push(P, j), r = Math.min(r, x), a = Math.max(a, T), l = Math.min(l, k), c = Math.max(c, C); | |
| } | |
| const u = a - r + 2 * s, d = c - l + 2 * s, f = r - s, g = l - s, m = o(this, En).at(i ? -1 : -2), y = [m[0], m[2]]; | |
| for (const _ of o(this, En)) { | |
| const [A, S, E] = _; | |
| _[0] = (A - f) / u, _[1] = (S - g) / d, _[2] = (E - g) / d; | |
| } | |
| p(this, yh, new Float32Array([f, g, u, d])), p(this, bh, y); | |
| } | |
| getOutlines() { | |
| o(this, En).sort((e, s) => e[0] - s[0] || e[1] - s[1] || e[2] - s[2]); | |
| const t = []; | |
| for (const e of o(this, En)) | |
| e[3] ? (t.push(...v(this, Oe, sp).call(this, e)), v(this, Oe, gv).call(this, e)) : (v(this, Oe, mv).call(this, e), t.push(...v(this, Oe, sp).call(this, e))); | |
| return v(this, Oe, pv).call(this, t); | |
| } | |
| } | |
| yh = new WeakMap(), bh = new WeakMap(), En = new WeakMap(), Ps = new WeakMap(), Oe = new WeakSet(), pv = function(t) { | |
| const e = [], s = /* @__PURE__ */ new Set(); | |
| for (const a of t) { | |
| const [l, c, h] = a; | |
| e.push([l, c, a], [l, h, a]); | |
| } | |
| e.sort((a, l) => a[1] - l[1] || a[0] - l[0]); | |
| for (let a = 0, l = e.length; a < l; a += 2) { | |
| const c = e[a][2], h = e[a + 1][2]; | |
| c.push(h), h.push(c), s.add(c), s.add(h); | |
| } | |
| const i = []; | |
| let r; | |
| for (; s.size > 0; ) { | |
| const a = s.values().next().value; | |
| let [l, c, h, u, d] = a; | |
| s.delete(a); | |
| let f = l, g = c; | |
| for (r = [l, h], i.push(r); ; ) { | |
| let m; | |
| if (s.has(u)) | |
| m = u; | |
| else if (s.has(d)) | |
| m = d; | |
| else | |
| break; | |
| s.delete(m), [l, c, h, u, d] = m, f !== l && (r.push(f, g, l, g === c ? c : h), f = l), g = g === c ? h : c; | |
| } | |
| r.push(f, g); | |
| } | |
| return new yT(i, o(this, yh), o(this, bh)); | |
| }, du = function(t) { | |
| const e = o(this, Ps); | |
| let s = 0, i = e.length - 1; | |
| for (; s <= i; ) { | |
| const r = s + i >> 1, a = e[r][0]; | |
| if (a === t) | |
| return r; | |
| a < t ? s = r + 1 : i = r - 1; | |
| } | |
| return i + 1; | |
| }, gv = function([, t, e]) { | |
| const s = v(this, Oe, du).call(this, t); | |
| o(this, Ps).splice(s, 0, [t, e]); | |
| }, mv = function([, t, e]) { | |
| const s = v(this, Oe, du).call(this, t); | |
| for (let i = s; i < o(this, Ps).length; i++) { | |
| const [r, a] = o(this, Ps)[i]; | |
| if (r !== t) | |
| break; | |
| if (r === t && a === e) { | |
| o(this, Ps).splice(i, 1); | |
| return; | |
| } | |
| } | |
| for (let i = s - 1; i >= 0; i--) { | |
| const [r, a] = o(this, Ps)[i]; | |
| if (r !== t) | |
| break; | |
| if (r === t && a === e) { | |
| o(this, Ps).splice(i, 1); | |
| return; | |
| } | |
| } | |
| }, sp = function(t) { | |
| const [e, s, i] = t, r = [[e, s, i]], a = v(this, Oe, du).call(this, i); | |
| for (let l = 0; l < a; l++) { | |
| const [c, h] = o(this, Ps)[l]; | |
| for (let u = 0, d = r.length; u < d; u++) { | |
| const [, f, g] = r[u]; | |
| if (!(h <= f || g <= c)) { | |
| if (f >= c) { | |
| if (g > h) | |
| r[u][1] = h; | |
| else { | |
| if (d === 1) | |
| return []; | |
| r.splice(u, 1), u--, d--; | |
| } | |
| continue; | |
| } | |
| r[u][2] = c, g > h && r.push([e, h, g]); | |
| } | |
| } | |
| } | |
| return r; | |
| }; | |
| var vh, So; | |
| class yT extends F { | |
| constructor(e, s, i) { | |
| super(); | |
| b(this, vh); | |
| b(this, So); | |
| p(this, So, e), p(this, vh, s), this.lastPoint = i; | |
| } | |
| toSVGPath() { | |
| const e = []; | |
| for (const s of o(this, So)) { | |
| let [i, r] = s; | |
| e.push(`M${i} ${r}`); | |
| for (let a = 2; a < s.length; a += 2) { | |
| const l = s[a], c = s[a + 1]; | |
| l === i ? (e.push(`V${c}`), r = c) : c === r && (e.push(`H${l}`), i = l); | |
| } | |
| e.push("Z"); | |
| } | |
| return e.join(" "); | |
| } | |
| serialize([e, s, i, r], a) { | |
| const l = [], c = i - e, h = r - s; | |
| for (const u of o(this, So)) { | |
| const d = new Array(u.length); | |
| for (let f = 0; f < u.length; f += 2) | |
| d[f] = e + u[f] * c, d[f + 1] = r - u[f + 1] * h; | |
| l.push(d); | |
| } | |
| return l; | |
| } | |
| get box() { | |
| return o(this, vh); | |
| } | |
| get classNamesForOutlining() { | |
| return ["highlightOutline"]; | |
| } | |
| } | |
| vh = new WeakMap(), So = new WeakMap(); | |
| class ip extends Uu { | |
| newFreeDrawOutline(t, e, s, i, r, a) { | |
| return new bT(t, e, s, i, r, a); | |
| } | |
| } | |
| class bT extends dv { | |
| newOutliner(t, e, s, i, r, a = 0) { | |
| return new ip(t, e, s, i, r, a); | |
| } | |
| } | |
| var Ms, Wr, Eo, Kt, _h, xo, Ah, wh, xn, Ns, To, Sh, At, np, rp, ap, Kn, yv, Qi; | |
| const $e = class $e { | |
| constructor({ | |
| editor: t = null, | |
| uiManager: e = null | |
| }) { | |
| b(this, At); | |
| b(this, Ms, null); | |
| b(this, Wr, null); | |
| b(this, Eo); | |
| b(this, Kt, null); | |
| b(this, _h, !1); | |
| b(this, xo, !1); | |
| b(this, Ah, null); | |
| b(this, wh); | |
| b(this, xn, null); | |
| b(this, Ns, null); | |
| b(this, To); | |
| var s; | |
| t ? (p(this, xo, !1), p(this, To, lt.HIGHLIGHT_COLOR), p(this, Ah, t)) : (p(this, xo, !0), p(this, To, lt.HIGHLIGHT_DEFAULT_COLOR)), p(this, Ns, (t == null ? void 0 : t._uiManager) || e), p(this, wh, o(this, Ns)._eventBus), p(this, Eo, (t == null ? void 0 : t.color) || ((s = o(this, Ns)) == null ? void 0 : s.highlightColors.values().next().value) || "#FFFF98"), o($e, Sh) || p($e, Sh, Object.freeze({ | |
| blue: "pdfjs-editor-colorpicker-blue", | |
| green: "pdfjs-editor-colorpicker-green", | |
| pink: "pdfjs-editor-colorpicker-pink", | |
| red: "pdfjs-editor-colorpicker-red", | |
| yellow: "pdfjs-editor-colorpicker-yellow" | |
| })); | |
| } | |
| static get _keyboardManager() { | |
| return at(this, "_keyboardManager", new Oh([[["Escape", "mac+Escape"], $e.prototype._hideDropdownFromKeyboard], [[" ", "mac+ "], $e.prototype._colorSelectFromKeyboard], [["ArrowDown", "ArrowRight", "mac+ArrowDown", "mac+ArrowRight"], $e.prototype._moveToNext], [["ArrowUp", "ArrowLeft", "mac+ArrowUp", "mac+ArrowLeft"], $e.prototype._moveToPrevious], [["Home", "mac+Home"], $e.prototype._moveToBeginning], [["End", "mac+End"], $e.prototype._moveToEnd]])); | |
| } | |
| renderButton() { | |
| const t = p(this, Ms, document.createElement("button")); | |
| t.className = "colorPicker", t.tabIndex = "0", t.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-button"), t.setAttribute("aria-haspopup", !0); | |
| const e = o(this, Ns)._signal; | |
| t.addEventListener("click", v(this, At, Kn).bind(this), { | |
| signal: e | |
| }), t.addEventListener("keydown", v(this, At, ap).bind(this), { | |
| signal: e | |
| }); | |
| const s = p(this, Wr, document.createElement("span")); | |
| return s.className = "swatch", s.setAttribute("aria-hidden", !0), s.style.backgroundColor = o(this, Eo), t.append(s), t; | |
| } | |
| renderMainDropdown() { | |
| const t = p(this, Kt, v(this, At, np).call(this)); | |
| return t.setAttribute("aria-orientation", "horizontal"), t.setAttribute("aria-labelledby", "highlightColorPickerLabel"), t; | |
| } | |
| _colorSelectFromKeyboard(t) { | |
| if (t.target === o(this, Ms)) { | |
| v(this, At, Kn).call(this, t); | |
| return; | |
| } | |
| const e = t.target.getAttribute("data-color"); | |
| e && v(this, At, rp).call(this, e, t); | |
| } | |
| _moveToNext(t) { | |
| var e, s; | |
| if (!o(this, At, Qi)) { | |
| v(this, At, Kn).call(this, t); | |
| return; | |
| } | |
| if (t.target === o(this, Ms)) { | |
| (e = o(this, Kt).firstChild) == null || e.focus(); | |
| return; | |
| } | |
| (s = t.target.nextSibling) == null || s.focus(); | |
| } | |
| _moveToPrevious(t) { | |
| var e, s; | |
| if (t.target === ((e = o(this, Kt)) == null ? void 0 : e.firstChild) || t.target === o(this, Ms)) { | |
| o(this, At, Qi) && this._hideDropdownFromKeyboard(); | |
| return; | |
| } | |
| o(this, At, Qi) || v(this, At, Kn).call(this, t), (s = t.target.previousSibling) == null || s.focus(); | |
| } | |
| _moveToBeginning(t) { | |
| var e; | |
| if (!o(this, At, Qi)) { | |
| v(this, At, Kn).call(this, t); | |
| return; | |
| } | |
| (e = o(this, Kt).firstChild) == null || e.focus(); | |
| } | |
| _moveToEnd(t) { | |
| var e; | |
| if (!o(this, At, Qi)) { | |
| v(this, At, Kn).call(this, t); | |
| return; | |
| } | |
| (e = o(this, Kt).lastChild) == null || e.focus(); | |
| } | |
| hideDropdown() { | |
| var t, e; | |
| (t = o(this, Kt)) == null || t.classList.add("hidden"), (e = o(this, xn)) == null || e.abort(), p(this, xn, null); | |
| } | |
| _hideDropdownFromKeyboard() { | |
| var t; | |
| if (!o(this, xo)) { | |
| if (!o(this, At, Qi)) { | |
| (t = o(this, Ah)) == null || t.unselect(); | |
| return; | |
| } | |
| this.hideDropdown(), o(this, Ms).focus({ | |
| preventScroll: !0, | |
| focusVisible: o(this, _h) | |
| }); | |
| } | |
| } | |
| updateColor(t) { | |
| if (o(this, Wr) && (o(this, Wr).style.backgroundColor = t), !o(this, Kt)) | |
| return; | |
| const e = o(this, Ns).highlightColors.values(); | |
| for (const s of o(this, Kt).children) | |
| s.setAttribute("aria-selected", e.next().value === t); | |
| } | |
| destroy() { | |
| var t, e; | |
| (t = o(this, Ms)) == null || t.remove(), p(this, Ms, null), p(this, Wr, null), (e = o(this, Kt)) == null || e.remove(), p(this, Kt, null); | |
| } | |
| }; | |
| Ms = new WeakMap(), Wr = new WeakMap(), Eo = new WeakMap(), Kt = new WeakMap(), _h = new WeakMap(), xo = new WeakMap(), Ah = new WeakMap(), wh = new WeakMap(), xn = new WeakMap(), Ns = new WeakMap(), To = new WeakMap(), Sh = new WeakMap(), At = new WeakSet(), np = function() { | |
| const t = document.createElement("div"), e = o(this, Ns)._signal; | |
| t.addEventListener("contextmenu", Hs, { | |
| signal: e | |
| }), t.className = "dropdown", t.role = "listbox", t.setAttribute("aria-multiselectable", !1), t.setAttribute("aria-orientation", "vertical"), t.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-dropdown"); | |
| for (const [s, i] of o(this, Ns).highlightColors) { | |
| const r = document.createElement("button"); | |
| r.tabIndex = "0", r.role = "option", r.setAttribute("data-color", i), r.title = s, r.setAttribute("data-l10n-id", o($e, Sh)[s]); | |
| const a = document.createElement("span"); | |
| r.append(a), a.className = "swatch", a.style.backgroundColor = i, r.setAttribute("aria-selected", i === o(this, Eo)), r.addEventListener("click", v(this, At, rp).bind(this, i), { | |
| signal: e | |
| }), t.append(r); | |
| } | |
| return t.addEventListener("keydown", v(this, At, ap).bind(this), { | |
| signal: e | |
| }), t; | |
| }, rp = function(t, e) { | |
| e.stopPropagation(), o(this, wh).dispatch("switchannotationeditorparams", { | |
| source: this, | |
| type: o(this, To), | |
| value: t | |
| }); | |
| }, ap = function(t) { | |
| $e._keyboardManager.exec(this, t); | |
| }, Kn = function(t) { | |
| if (o(this, At, Qi)) { | |
| this.hideDropdown(); | |
| return; | |
| } | |
| if (p(this, _h, t.detail === 0), o(this, xn) || (p(this, xn, new AbortController()), window.addEventListener("pointerdown", v(this, At, yv).bind(this), { | |
| signal: o(this, Ns).combinedSignal(o(this, xn)) | |
| })), o(this, Kt)) { | |
| o(this, Kt).classList.remove("hidden"); | |
| return; | |
| } | |
| const e = p(this, Kt, v(this, At, np).call(this)); | |
| o(this, Ms).append(e); | |
| }, yv = function(t) { | |
| var e; | |
| (e = o(this, Kt)) != null && e.contains(t.target) || this.hideDropdown(); | |
| }, Qi = function() { | |
| return o(this, Kt) && !o(this, Kt).classList.contains("hidden"); | |
| }, b($e, Sh, null); | |
| let zu = $e; | |
| var Co, Eh, Bi, Xr, ko, He, xh, Th, Zr, ds, Ke, ue, Io, Hi, _e, Ro, fs, Ch, K, op, fu, bv, vv, _v, lp, Jn, ys, ka, Av, pu, Al, wv, Sv, Ev, xv, Tv; | |
| const mt = class mt extends Ft { | |
| constructor(e) { | |
| super({ | |
| ...e, | |
| name: "highlightEditor" | |
| }); | |
| b(this, K); | |
| b(this, Co, null); | |
| b(this, Eh, 0); | |
| b(this, Bi); | |
| b(this, Xr, null); | |
| b(this, ko, null); | |
| b(this, He, null); | |
| b(this, xh, null); | |
| b(this, Th, 0); | |
| b(this, Zr, null); | |
| b(this, ds, null); | |
| b(this, Ke, null); | |
| b(this, ue, !1); | |
| b(this, Io, null); | |
| b(this, Hi); | |
| b(this, _e, null); | |
| b(this, Ro, ""); | |
| b(this, fs); | |
| b(this, Ch, ""); | |
| this.color = e.color || mt._defaultColor, p(this, fs, e.thickness || mt._defaultThickness), p(this, Hi, e.opacity || mt._defaultOpacity), p(this, Bi, e.boxes || null), p(this, Ch, e.methodOfCreation || ""), p(this, Ro, e.text || ""), this._isDraggable = !1, e.highlightId > -1 ? (p(this, ue, !0), v(this, K, fu).call(this, e), v(this, K, Jn).call(this)) : o(this, Bi) && (p(this, Co, e.anchorNode), p(this, Eh, e.anchorOffset), p(this, xh, e.focusNode), p(this, Th, e.focusOffset), v(this, K, op).call(this), v(this, K, Jn).call(this), this.rotate(this.rotation)); | |
| } | |
| static get _keyboardManager() { | |
| const e = mt.prototype; | |
| return at(this, "_keyboardManager", new Oh([[["ArrowLeft", "mac+ArrowLeft"], e._moveCaret, { | |
| args: [0] | |
| }], [["ArrowRight", "mac+ArrowRight"], e._moveCaret, { | |
| args: [1] | |
| }], [["ArrowUp", "mac+ArrowUp"], e._moveCaret, { | |
| args: [2] | |
| }], [["ArrowDown", "mac+ArrowDown"], e._moveCaret, { | |
| args: [3] | |
| }]])); | |
| } | |
| get telemetryInitialData() { | |
| return { | |
| action: "added", | |
| type: o(this, ue) ? "free_highlight" : "highlight", | |
| color: this._uiManager.highlightColorNames.get(this.color), | |
| thickness: o(this, fs), | |
| methodOfCreation: o(this, Ch) | |
| }; | |
| } | |
| get telemetryFinalData() { | |
| return { | |
| type: "highlight", | |
| color: this._uiManager.highlightColorNames.get(this.color) | |
| }; | |
| } | |
| static computeTelemetryFinalData(e) { | |
| return { | |
| numberOfColors: e.get("color").size | |
| }; | |
| } | |
| static initialize(e, s) { | |
| var i; | |
| Ft.initialize(e, s), mt._defaultColor || (mt._defaultColor = ((i = s.highlightColors) == null ? void 0 : i.values().next().value) || "#fff066"); | |
| } | |
| static updateDefaultParams(e, s) { | |
| switch (e) { | |
| case lt.HIGHLIGHT_DEFAULT_COLOR: | |
| mt._defaultColor = s; | |
| break; | |
| case lt.HIGHLIGHT_THICKNESS: | |
| mt._defaultThickness = s; | |
| break; | |
| } | |
| } | |
| translateInPage(e, s) { | |
| } | |
| get toolbarPosition() { | |
| return o(this, Io); | |
| } | |
| updateParams(e, s) { | |
| switch (e) { | |
| case lt.HIGHLIGHT_COLOR: | |
| v(this, K, bv).call(this, s); | |
| break; | |
| case lt.HIGHLIGHT_THICKNESS: | |
| v(this, K, vv).call(this, s); | |
| break; | |
| } | |
| } | |
| static get defaultPropertiesToUpdate() { | |
| return [[lt.HIGHLIGHT_DEFAULT_COLOR, mt._defaultColor], [lt.HIGHLIGHT_THICKNESS, mt._defaultThickness]]; | |
| } | |
| get propertiesToUpdate() { | |
| return [[lt.HIGHLIGHT_COLOR, this.color || mt._defaultColor], [lt.HIGHLIGHT_THICKNESS, o(this, fs) || mt._defaultThickness], [lt.HIGHLIGHT_FREE, o(this, ue)]]; | |
| } | |
| async addEditToolbar() { | |
| const e = await super.addEditToolbar(); | |
| return e ? (this._uiManager.highlightColors && (p(this, ko, new zu({ | |
| editor: this | |
| })), e.addColorPicker(o(this, ko))), e) : null; | |
| } | |
| disableEditing() { | |
| super.disableEditing(), this.div.classList.toggle("disabled", !0); | |
| } | |
| enableEditing() { | |
| super.enableEditing(), this.div.classList.toggle("disabled", !1); | |
| } | |
| fixAndSetPosition() { | |
| return super.fixAndSetPosition(v(this, K, Al).call(this)); | |
| } | |
| getBaseTranslation() { | |
| return [0, 0]; | |
| } | |
| getRect(e, s) { | |
| return super.getRect(e, s, v(this, K, Al).call(this)); | |
| } | |
| onceAdded(e) { | |
| this.annotationElementId || this.parent.addUndoableEditor(this), e && this.div.focus(); | |
| } | |
| remove() { | |
| v(this, K, lp).call(this), this._reportTelemetry({ | |
| action: "deleted" | |
| }), super.remove(); | |
| } | |
| rebuild() { | |
| this.parent && (super.rebuild(), this.div !== null && (v(this, K, Jn).call(this), this.isAttachedToDOM || this.parent.add(this))); | |
| } | |
| setParent(e) { | |
| var i; | |
| let s = !1; | |
| this.parent && !e ? v(this, K, lp).call(this) : e && (v(this, K, Jn).call(this, e), s = !this.parent && ((i = this.div) == null ? void 0 : i.classList.contains("selectedEditor"))), super.setParent(e), this.show(this._isVisible), s && this.select(); | |
| } | |
| rotate(e) { | |
| var r, a, l; | |
| const { | |
| drawLayer: s | |
| } = this.parent; | |
| let i; | |
| o(this, ue) ? (e = (e - this.rotation + 360) % 360, i = v(r = mt, ys, ka).call(r, o(this, ds).box, e)) : i = v(a = mt, ys, ka).call(a, [this.x, this.y, this.width, this.height], e), s.updateProperties(o(this, Ke), { | |
| bbox: i, | |
| root: { | |
| "data-main-rotation": e | |
| } | |
| }), s.updateProperties(o(this, _e), { | |
| bbox: v(l = mt, ys, ka).call(l, o(this, He).box, e), | |
| root: { | |
| "data-main-rotation": e | |
| } | |
| }); | |
| } | |
| render() { | |
| if (this.div) | |
| return this.div; | |
| const e = super.render(); | |
| o(this, Ro) && (e.setAttribute("aria-label", o(this, Ro)), e.setAttribute("role", "mark")), o(this, ue) ? e.classList.add("free") : this.div.addEventListener("keydown", v(this, K, Av).bind(this), { | |
| signal: this._uiManager._signal | |
| }); | |
| const s = p(this, Zr, document.createElement("div")); | |
| e.append(s), s.setAttribute("aria-hidden", "true"), s.className = "internal", s.style.clipPath = o(this, Xr); | |
| const [i, r] = this.parentDimensions; | |
| return this.setDims(this.width * i, this.height * r), ju(this, o(this, Zr), ["pointerover", "pointerleave"]), this.enableEditing(), e; | |
| } | |
| pointerover() { | |
| var e; | |
| this.isSelected || (e = this.parent) == null || e.drawLayer.updateProperties(o(this, _e), { | |
| rootClass: { | |
| hovered: !0 | |
| } | |
| }); | |
| } | |
| pointerleave() { | |
| var e; | |
| this.isSelected || (e = this.parent) == null || e.drawLayer.updateProperties(o(this, _e), { | |
| rootClass: { | |
| hovered: !1 | |
| } | |
| }); | |
| } | |
| _moveCaret(e) { | |
| switch (this.parent.unselect(this), e) { | |
| case 0: | |
| case 2: | |
| v(this, K, pu).call(this, !0); | |
| break; | |
| case 1: | |
| case 3: | |
| v(this, K, pu).call(this, !1); | |
| break; | |
| } | |
| } | |
| select() { | |
| var e; | |
| super.select(), o(this, _e) && ((e = this.parent) == null || e.drawLayer.updateProperties(o(this, _e), { | |
| rootClass: { | |
| hovered: !1, | |
| selected: !0 | |
| } | |
| })); | |
| } | |
| unselect() { | |
| var e; | |
| super.unselect(), o(this, _e) && ((e = this.parent) == null || e.drawLayer.updateProperties(o(this, _e), { | |
| rootClass: { | |
| selected: !1 | |
| } | |
| }), o(this, ue) || v(this, K, pu).call(this, !1)); | |
| } | |
| get _mustFixPosition() { | |
| return !o(this, ue); | |
| } | |
| show(e = this._isVisible) { | |
| super.show(e), this.parent && (this.parent.drawLayer.updateProperties(o(this, Ke), { | |
| rootClass: { | |
| hidden: !e | |
| } | |
| }), this.parent.drawLayer.updateProperties(o(this, _e), { | |
| rootClass: { | |
| hidden: !e | |
| } | |
| })); | |
| } | |
| static startHighlighting(e, s, { | |
| target: i, | |
| x: r, | |
| y: a | |
| }) { | |
| const { | |
| x: l, | |
| y: c, | |
| width: h, | |
| height: u | |
| } = i.getBoundingClientRect(), d = new AbortController(), f = e.combinedSignal(d), g = (m) => { | |
| d.abort(), v(this, ys, xv).call(this, e, m); | |
| }; | |
| window.addEventListener("blur", g, { | |
| signal: f | |
| }), window.addEventListener("pointerup", g, { | |
| signal: f | |
| }), window.addEventListener("pointerdown", ns, { | |
| capture: !0, | |
| passive: !1, | |
| signal: f | |
| }), window.addEventListener("contextmenu", Hs, { | |
| signal: f | |
| }), i.addEventListener("pointermove", v(this, ys, Ev).bind(this, e), { | |
| signal: f | |
| }), this._freeHighlight = new ip({ | |
| x: r, | |
| y: a | |
| }, [l, c, h, u], e.scale, this._defaultThickness / 2, s, 1e-3), { | |
| id: this._freeHighlightId, | |
| clipPathId: this._freeHighlightClipId | |
| } = e.drawLayer.draw({ | |
| bbox: [0, 0, 1, 1], | |
| root: { | |
| viewBox: "0 0 1 1", | |
| fill: this._defaultColor, | |
| "fill-opacity": this._defaultOpacity | |
| }, | |
| rootClass: { | |
| highlight: !0, | |
| free: !0 | |
| }, | |
| path: { | |
| d: this._freeHighlight.toSVGPath() | |
| } | |
| }, !0, !0); | |
| } | |
| static async deserialize(e, s, i) { | |
| var y, _, A, S; | |
| let r = null; | |
| if (e instanceof Jb) { | |
| const { | |
| data: { | |
| quadPoints: E, | |
| rect: x, | |
| rotation: T, | |
| id: k, | |
| color: C, | |
| opacity: P, | |
| popupRef: j | |
| }, | |
| parent: { | |
| page: { | |
| pageNumber: Z | |
| } | |
| } | |
| } = e; | |
| r = e = { | |
| annotationType: et.HIGHLIGHT, | |
| color: Array.from(C), | |
| opacity: P, | |
| quadPoints: E, | |
| boxes: null, | |
| pageIndex: Z - 1, | |
| rect: x.slice(0), | |
| rotation: T, | |
| id: k, | |
| deleted: !1, | |
| popupRef: j | |
| }; | |
| } else if (e instanceof Zp) { | |
| const { | |
| data: { | |
| inkLists: E, | |
| rect: x, | |
| rotation: T, | |
| id: k, | |
| color: C, | |
| borderStyle: { | |
| rawWidth: P | |
| }, | |
| popupRef: j | |
| }, | |
| parent: { | |
| page: { | |
| pageNumber: Z | |
| } | |
| } | |
| } = e; | |
| r = e = { | |
| annotationType: et.HIGHLIGHT, | |
| color: Array.from(C), | |
| thickness: P, | |
| inkLists: E, | |
| boxes: null, | |
| pageIndex: Z - 1, | |
| rect: x.slice(0), | |
| rotation: T, | |
| id: k, | |
| deleted: !1, | |
| popupRef: j | |
| }; | |
| } | |
| const { | |
| color: a, | |
| quadPoints: l, | |
| inkLists: c, | |
| opacity: h | |
| } = e, u = await super.deserialize(e, s, i); | |
| u.color = U.makeHexColor(...a), p(u, Hi, h || 1), c && p(u, fs, e.thickness), u.annotationElementId = e.id || null, u._initialData = r; | |
| const [d, f] = u.pageDimensions, [g, m] = u.pageTranslation; | |
| if (l) { | |
| const E = p(u, Bi, []); | |
| for (let x = 0; x < l.length; x += 8) | |
| E.push({ | |
| x: (l[x] - g) / d, | |
| y: 1 - (l[x + 1] - m) / f, | |
| width: (l[x + 2] - l[x]) / d, | |
| height: (l[x + 1] - l[x + 5]) / f | |
| }); | |
| v(y = u, K, op).call(y), v(_ = u, K, Jn).call(_), u.rotate(u.rotation); | |
| } else if (c) { | |
| p(u, ue, !0); | |
| const E = c[0], x = { | |
| x: E[0] - g, | |
| y: f - (E[1] - m) | |
| }, T = new ip(x, [0, 0, d, f], 1, o(u, fs) / 2, !0, 1e-3); | |
| for (let P = 0, j = E.length; P < j; P += 2) | |
| x.x = E[P] - g, x.y = f - (E[P + 1] - m), T.add(x); | |
| const { | |
| id: k, | |
| clipPathId: C | |
| } = s.drawLayer.draw({ | |
| bbox: [0, 0, 1, 1], | |
| root: { | |
| viewBox: "0 0 1 1", | |
| fill: u.color, | |
| "fill-opacity": u._defaultOpacity | |
| }, | |
| rootClass: { | |
| highlight: !0, | |
| free: !0 | |
| }, | |
| path: { | |
| d: T.toSVGPath() | |
| } | |
| }, !0, !0); | |
| v(A = u, K, fu).call(A, { | |
| highlightOutlines: T.getOutlines(), | |
| highlightId: k, | |
| clipPathId: C | |
| }), v(S = u, K, Jn).call(S); | |
| } | |
| return u; | |
| } | |
| serialize(e = !1) { | |
| if (this.isEmpty() || e) | |
| return null; | |
| if (this.deleted) | |
| return this.serializeDeleted(); | |
| const s = this.getRect(0, 0), i = Ft._colorManager.convert(this.color), r = { | |
| annotationType: et.HIGHLIGHT, | |
| color: i, | |
| opacity: o(this, Hi), | |
| thickness: o(this, fs), | |
| quadPoints: v(this, K, wv).call(this), | |
| outlines: v(this, K, Sv).call(this, s), | |
| pageIndex: this.pageIndex, | |
| rect: s, | |
| rotation: v(this, K, Al).call(this), | |
| structTreeParentId: this._structTreeParentId | |
| }; | |
| return this.annotationElementId && !v(this, K, Tv).call(this, r) ? null : (r.id = this.annotationElementId, r); | |
| } | |
| renderAnnotationElement(e) { | |
| return e.updateEdited({ | |
| rect: this.getRect(0, 0) | |
| }), null; | |
| } | |
| static canCreateNewEmptyEditor() { | |
| return !1; | |
| } | |
| }; | |
| Co = new WeakMap(), Eh = new WeakMap(), Bi = new WeakMap(), Xr = new WeakMap(), ko = new WeakMap(), He = new WeakMap(), xh = new WeakMap(), Th = new WeakMap(), Zr = new WeakMap(), ds = new WeakMap(), Ke = new WeakMap(), ue = new WeakMap(), Io = new WeakMap(), Hi = new WeakMap(), _e = new WeakMap(), Ro = new WeakMap(), fs = new WeakMap(), Ch = new WeakMap(), K = new WeakSet(), op = function() { | |
| const e = new ep(o(this, Bi), 1e-3); | |
| p(this, ds, e.getOutlines()), [this.x, this.y, this.width, this.height] = o(this, ds).box; | |
| const s = new ep(o(this, Bi), 25e-4, 1e-3, this._uiManager.direction === "ltr"); | |
| p(this, He, s.getOutlines()); | |
| const { | |
| lastPoint: i | |
| } = o(this, He); | |
| p(this, Io, [(i[0] - this.x) / this.width, (i[1] - this.y) / this.height]); | |
| }, fu = function({ | |
| highlightOutlines: e, | |
| highlightId: s, | |
| clipPathId: i | |
| }) { | |
| var d, f; | |
| if (p(this, ds, e), p(this, He, e.getNewOutline(o(this, fs) / 2 + 1.5, 25e-4)), s >= 0) | |
| p(this, Ke, s), p(this, Xr, i), this.parent.drawLayer.finalizeDraw(s, { | |
| bbox: e.box, | |
| path: { | |
| d: e.toSVGPath() | |
| } | |
| }), p(this, _e, this.parent.drawLayer.drawOutline({ | |
| rootClass: { | |
| highlightOutline: !0, | |
| free: !0 | |
| }, | |
| bbox: o(this, He).box, | |
| path: { | |
| d: o(this, He).toSVGPath() | |
| } | |
| }, !0)); | |
| else if (this.parent) { | |
| const g = this.parent.viewport.rotation; | |
| this.parent.drawLayer.updateProperties(o(this, Ke), { | |
| bbox: v(d = mt, ys, ka).call(d, o(this, ds).box, (g - this.rotation + 360) % 360), | |
| path: { | |
| d: e.toSVGPath() | |
| } | |
| }), this.parent.drawLayer.updateProperties(o(this, _e), { | |
| bbox: v(f = mt, ys, ka).call(f, o(this, He).box, g), | |
| path: { | |
| d: o(this, He).toSVGPath() | |
| } | |
| }); | |
| } | |
| const [a, l, c, h] = e.box; | |
| switch (this.rotation) { | |
| case 0: | |
| this.x = a, this.y = l, this.width = c, this.height = h; | |
| break; | |
| case 90: { | |
| const [g, m] = this.parentDimensions; | |
| this.x = l, this.y = 1 - a, this.width = c * m / g, this.height = h * g / m; | |
| break; | |
| } | |
| case 180: | |
| this.x = 1 - a, this.y = 1 - l, this.width = c, this.height = h; | |
| break; | |
| case 270: { | |
| const [g, m] = this.parentDimensions; | |
| this.x = 1 - l, this.y = a, this.width = c * m / g, this.height = h * g / m; | |
| break; | |
| } | |
| } | |
| const { | |
| lastPoint: u | |
| } = o(this, He); | |
| p(this, Io, [(u[0] - a) / c, (u[1] - l) / h]); | |
| }, bv = function(e) { | |
| const s = (a, l) => { | |
| var c, h; | |
| this.color = a, p(this, Hi, l), (c = this.parent) == null || c.drawLayer.updateProperties(o(this, Ke), { | |
| root: { | |
| fill: a, | |
| "fill-opacity": l | |
| } | |
| }), (h = o(this, ko)) == null || h.updateColor(a); | |
| }, i = this.color, r = o(this, Hi); | |
| this.addCommands({ | |
| cmd: s.bind(this, e, mt._defaultOpacity), | |
| undo: s.bind(this, i, r), | |
| post: this._uiManager.updateUI.bind(this._uiManager, this), | |
| mustExec: !0, | |
| type: lt.HIGHLIGHT_COLOR, | |
| overwriteIfSameType: !0, | |
| keepUndo: !0 | |
| }), this._reportTelemetry({ | |
| action: "color_changed", | |
| color: this._uiManager.highlightColorNames.get(e) | |
| }, !0); | |
| }, vv = function(e) { | |
| const s = o(this, fs), i = (r) => { | |
| p(this, fs, r), v(this, K, _v).call(this, r); | |
| }; | |
| this.addCommands({ | |
| cmd: i.bind(this, e), | |
| undo: i.bind(this, s), | |
| post: this._uiManager.updateUI.bind(this._uiManager, this), | |
| mustExec: !0, | |
| type: lt.INK_THICKNESS, | |
| overwriteIfSameType: !0, | |
| keepUndo: !0 | |
| }), this._reportTelemetry({ | |
| action: "thickness_changed", | |
| thickness: e | |
| }, !0); | |
| }, _v = function(e) { | |
| if (!o(this, ue)) | |
| return; | |
| v(this, K, fu).call(this, { | |
| highlightOutlines: o(this, ds).getNewOutline(e / 2) | |
| }), this.fixAndSetPosition(); | |
| const [s, i] = this.parentDimensions; | |
| this.setDims(this.width * s, this.height * i); | |
| }, lp = function() { | |
| o(this, Ke) === null || !this.parent || (this.parent.drawLayer.remove(o(this, Ke)), p(this, Ke, null), this.parent.drawLayer.remove(o(this, _e)), p(this, _e, null)); | |
| }, Jn = function(e = this.parent) { | |
| o(this, Ke) === null && ({ | |
| id: xe(this, Ke)._, | |
| clipPathId: xe(this, Xr)._ | |
| } = e.drawLayer.draw({ | |
| bbox: o(this, ds).box, | |
| root: { | |
| viewBox: "0 0 1 1", | |
| fill: this.color, | |
| "fill-opacity": o(this, Hi) | |
| }, | |
| rootClass: { | |
| highlight: !0, | |
| free: o(this, ue) | |
| }, | |
| path: { | |
| d: o(this, ds).toSVGPath() | |
| } | |
| }, !1, !0), p(this, _e, e.drawLayer.drawOutline({ | |
| rootClass: { | |
| highlightOutline: !0, | |
| free: o(this, ue) | |
| }, | |
| bbox: o(this, He).box, | |
| path: { | |
| d: o(this, He).toSVGPath() | |
| } | |
| }, o(this, ue))), o(this, Zr) && (o(this, Zr).style.clipPath = o(this, Xr))); | |
| }, ys = new WeakSet(), ka = function([e, s, i, r], a) { | |
| switch (a) { | |
| case 90: | |
| return [1 - s - r, e, r, i]; | |
| case 180: | |
| return [1 - e - i, 1 - s - r, i, r]; | |
| case 270: | |
| return [s, 1 - e - i, r, i]; | |
| } | |
| return [e, s, i, r]; | |
| }, Av = function(e) { | |
| mt._keyboardManager.exec(this, e); | |
| }, pu = function(e) { | |
| if (!o(this, Co)) | |
| return; | |
| const s = window.getSelection(); | |
| e ? s.setPosition(o(this, Co), o(this, Eh)) : s.setPosition(o(this, xh), o(this, Th)); | |
| }, Al = function() { | |
| return o(this, ue) ? this.rotation : 0; | |
| }, wv = function() { | |
| if (o(this, ue)) | |
| return null; | |
| const [e, s] = this.pageDimensions, [i, r] = this.pageTranslation, a = o(this, Bi), l = new Float32Array(a.length * 8); | |
| let c = 0; | |
| for (const { | |
| x: h, | |
| y: u, | |
| width: d, | |
| height: f | |
| } of a) { | |
| const g = h * e + i, m = (1 - u) * s + r; | |
| l[c] = l[c + 4] = g, l[c + 1] = l[c + 3] = m, l[c + 2] = l[c + 6] = g + d * e, l[c + 5] = l[c + 7] = m - f * s, c += 8; | |
| } | |
| return l; | |
| }, Sv = function(e) { | |
| return o(this, ds).serialize(e, v(this, K, Al).call(this)); | |
| }, Ev = function(e, s) { | |
| this._freeHighlight.add(s) && e.drawLayer.updateProperties(this._freeHighlightId, { | |
| path: { | |
| d: this._freeHighlight.toSVGPath() | |
| } | |
| }); | |
| }, xv = function(e, s) { | |
| this._freeHighlight.isEmpty() ? e.drawLayer.remove(this._freeHighlightId) : e.createAndAddNewEditor(s, !1, { | |
| highlightId: this._freeHighlightId, | |
| highlightOutlines: this._freeHighlight.getOutlines(), | |
| clipPathId: this._freeHighlightClipId, | |
| methodOfCreation: "main_toolbar" | |
| }), this._freeHighlightId = -1, this._freeHighlight = null, this._freeHighlightClipId = ""; | |
| }, Tv = function(e) { | |
| const { | |
| color: s | |
| } = this._initialData; | |
| return e.color.some((i, r) => i !== s[r]); | |
| }, b(mt, ys), G(mt, "_defaultColor", null), G(mt, "_defaultOpacity", 1), G(mt, "_defaultThickness", 12), G(mt, "_type", "highlight"), G(mt, "_editorType", et.HIGHLIGHT), G(mt, "_freeHighlightId", -1), G(mt, "_freeHighlight", null), G(mt, "_freeHighlightClipId", ""); | |
| let Vu = mt; | |
| var Yr; | |
| class vT { | |
| constructor() { | |
| b(this, Yr, /* @__PURE__ */ Object.create(null)); | |
| } | |
| updateProperty(t, e) { | |
| this[t] = e, this.updateSVGProperty(t, e); | |
| } | |
| updateProperties(t) { | |
| if (t) | |
| for (const [e, s] of Object.entries(t)) | |
| this.updateProperty(e, s); | |
| } | |
| updateSVGProperty(t, e) { | |
| o(this, Yr)[t] = e; | |
| } | |
| toSVGProperties() { | |
| const t = o(this, Yr); | |
| return p(this, Yr, /* @__PURE__ */ Object.create(null)), { | |
| root: t | |
| }; | |
| } | |
| reset() { | |
| p(this, Yr, /* @__PURE__ */ Object.create(null)); | |
| } | |
| updateAll(t = this) { | |
| this.updateProperties(t); | |
| } | |
| clone() { | |
| Et("Not implemented"); | |
| } | |
| } | |
| Yr = new WeakMap(); | |
| var Je, Po, ie, Kr, Jr, Tn, Cn, kn, Qr, ut, hp, up, dp, wl, Cv, gu, Sl, Ia; | |
| const $ = class $ extends Ft { | |
| constructor(e) { | |
| super(e); | |
| b(this, ut); | |
| b(this, Je, null); | |
| b(this, Po); | |
| G(this, "_drawId", null); | |
| p(this, Po, e.mustBeCommitted || !1), e.drawOutlines && (v(this, ut, hp).call(this, e), v(this, ut, wl).call(this)); | |
| } | |
| static _mergeSVGProperties(e, s) { | |
| const i = new Set(Object.keys(e)); | |
| for (const [r, a] of Object.entries(s)) | |
| i.has(r) ? Object.assign(e[r], a) : e[r] = a; | |
| return e; | |
| } | |
| static getDefaultDrawingOptions(e) { | |
| Et("Not implemented"); | |
| } | |
| static get typesMap() { | |
| Et("Not implemented"); | |
| } | |
| static get isDrawer() { | |
| return !0; | |
| } | |
| static get supportMultipleDrawings() { | |
| return !1; | |
| } | |
| static updateDefaultParams(e, s) { | |
| const i = this.typesMap.get(e); | |
| i && this._defaultDrawingOptions.updateProperty(i, s), this._currentParent && (o($, ie).updateProperty(i, s), this._currentParent.drawLayer.updateProperties(this._currentDrawId, this._defaultDrawingOptions.toSVGProperties())); | |
| } | |
| updateParams(e, s) { | |
| const i = this.constructor.typesMap.get(e); | |
| i && this._updateProperty(e, i, s); | |
| } | |
| static get defaultPropertiesToUpdate() { | |
| const e = [], s = this._defaultDrawingOptions; | |
| for (const [i, r] of this.typesMap) | |
| e.push([i, s[r]]); | |
| return e; | |
| } | |
| get propertiesToUpdate() { | |
| const e = [], { | |
| _drawingOptions: s | |
| } = this; | |
| for (const [i, r] of this.constructor.typesMap) | |
| e.push([i, s[r]]); | |
| return e; | |
| } | |
| _updateProperty(e, s, i) { | |
| const r = this._drawingOptions, a = r[s], l = (c) => { | |
| var u; | |
| r.updateProperty(s, c); | |
| const h = o(this, Je).updateProperty(s, c); | |
| h && v(this, ut, Sl).call(this, h), (u = this.parent) == null || u.drawLayer.updateProperties(this._drawId, r.toSVGProperties()); | |
| }; | |
| this.addCommands({ | |
| cmd: l.bind(this, i), | |
| undo: l.bind(this, a), | |
| post: this._uiManager.updateUI.bind(this._uiManager, this), | |
| mustExec: !0, | |
| type: e, | |
| overwriteIfSameType: !0, | |
| keepUndo: !0 | |
| }); | |
| } | |
| _onResizing() { | |
| var e; | |
| (e = this.parent) == null || e.drawLayer.updateProperties(this._drawId, $._mergeSVGProperties(o(this, Je).getPathResizingSVGProperties(v(this, ut, gu).call(this)), { | |
| bbox: v(this, ut, Ia).call(this) | |
| })); | |
| } | |
| _onResized() { | |
| var e; | |
| (e = this.parent) == null || e.drawLayer.updateProperties(this._drawId, $._mergeSVGProperties(o(this, Je).getPathResizedSVGProperties(v(this, ut, gu).call(this)), { | |
| bbox: v(this, ut, Ia).call(this) | |
| })); | |
| } | |
| _onTranslating(e, s) { | |
| var i; | |
| (i = this.parent) == null || i.drawLayer.updateProperties(this._drawId, { | |
| bbox: v(this, ut, Ia).call(this, e, s) | |
| }); | |
| } | |
| _onTranslated() { | |
| var e; | |
| (e = this.parent) == null || e.drawLayer.updateProperties(this._drawId, $._mergeSVGProperties(o(this, Je).getPathTranslatedSVGProperties(v(this, ut, gu).call(this), this.parentDimensions), { | |
| bbox: v(this, ut, Ia).call(this) | |
| })); | |
| } | |
| _onStartDragging() { | |
| var e; | |
| (e = this.parent) == null || e.drawLayer.updateProperties(this._drawId, { | |
| rootClass: { | |
| moving: !0 | |
| } | |
| }); | |
| } | |
| _onStopDragging() { | |
| var e; | |
| (e = this.parent) == null || e.drawLayer.updateProperties(this._drawId, { | |
| rootClass: { | |
| moving: !1 | |
| } | |
| }); | |
| } | |
| commit() { | |
| super.commit(), this.disableEditMode(), this.disableEditing(); | |
| } | |
| disableEditing() { | |
| super.disableEditing(), this.div.classList.toggle("disabled", !0); | |
| } | |
| enableEditing() { | |
| super.enableEditing(), this.div.classList.toggle("disabled", !1); | |
| } | |
| getBaseTranslation() { | |
| return [0, 0]; | |
| } | |
| get isResizable() { | |
| return !0; | |
| } | |
| onceAdded(e) { | |
| this.annotationElementId || this.parent.addUndoableEditor(this), this._isDraggable = !0, o(this, Po) && (p(this, Po, !1), this.commit(), this.parent.setSelected(this), e && this.isOnScreen && this.div.focus()); | |
| } | |
| remove() { | |
| v(this, ut, dp).call(this), super.remove(); | |
| } | |
| rebuild() { | |
| this.parent && (super.rebuild(), this.div !== null && (v(this, ut, wl).call(this), v(this, ut, Sl).call(this, o(this, Je).box), this.isAttachedToDOM || this.parent.add(this))); | |
| } | |
| setParent(e) { | |
| var i; | |
| let s = !1; | |
| this.parent && !e ? (this._uiManager.removeShouldRescale(this), v(this, ut, dp).call(this)) : e && (this._uiManager.addShouldRescale(this), v(this, ut, wl).call(this, e), s = !this.parent && ((i = this.div) == null ? void 0 : i.classList.contains("selectedEditor"))), super.setParent(e), s && this.select(); | |
| } | |
| rotate() { | |
| this.parent && this.parent.drawLayer.updateProperties(this._drawId, $._mergeSVGProperties({ | |
| bbox: v(this, ut, Ia).call(this) | |
| }, o(this, Je).updateRotation((this.parentRotation - this.rotation + 360) % 360))); | |
| } | |
| onScaleChanging() { | |
| this.parent && v(this, ut, Sl).call(this, o(this, Je).updateParentDimensions(this.parentDimensions, this.parent.scale)); | |
| } | |
| static onScaleChangingWhenDrawing() { | |
| } | |
| render() { | |
| if (this.div) | |
| return this.div; | |
| const e = super.render(); | |
| e.classList.add("draw"); | |
| const s = document.createElement("div"); | |
| e.append(s), s.setAttribute("aria-hidden", "true"), s.className = "internal"; | |
| const [i, r] = this.parentDimensions; | |
| return this.setDims(this.width * i, this.height * r), this._uiManager.addShouldRescale(this), this.disableEditing(), e; | |
| } | |
| static createDrawerInstance(e, s, i, r, a) { | |
| Et("Not implemented"); | |
| } | |
| static startDrawing(e, s, i, r) { | |
| var _; | |
| const { | |
| target: a, | |
| offsetX: l, | |
| offsetY: c, | |
| pointerId: h, | |
| pointerType: u | |
| } = r; | |
| if (o($, Cn) && o($, Cn) !== u) | |
| return; | |
| const { | |
| viewport: { | |
| rotation: d | |
| } | |
| } = e, { | |
| width: f, | |
| height: g | |
| } = a.getBoundingClientRect(), m = p($, Kr, new AbortController()), y = e.combinedSignal(m); | |
| if (o($, Tn) || p($, Tn, h), o($, Cn) ?? p($, Cn, u), window.addEventListener("pointerup", (A) => { | |
| var S; | |
| o($, Tn) === A.pointerId ? this._endDraw(A) : (S = o($, kn)) == null || S.delete(A.pointerId); | |
| }, { | |
| signal: y | |
| }), window.addEventListener("pointercancel", (A) => { | |
| var S; | |
| o($, Tn) === A.pointerId ? this._currentParent.endDrawingSession() : (S = o($, kn)) == null || S.delete(A.pointerId); | |
| }, { | |
| signal: y | |
| }), window.addEventListener("pointerdown", (A) => { | |
| o($, Cn) === A.pointerType && ((o($, kn) || p($, kn, /* @__PURE__ */ new Set())).add(A.pointerId), o($, ie).isCancellable() && (o($, ie).removeLastElement(), o($, ie).isEmpty() ? this._currentParent.endDrawingSession(!0) : this._endDraw(null))); | |
| }, { | |
| capture: !0, | |
| passive: !1, | |
| signal: y | |
| }), window.addEventListener("contextmenu", Hs, { | |
| signal: y | |
| }), a.addEventListener("pointermove", this._drawMove.bind(this), { | |
| signal: y | |
| }), a.addEventListener("touchmove", (A) => { | |
| A.timeStamp === o($, Qr) && ns(A); | |
| }, { | |
| signal: y | |
| }), e.toggleDrawing(), (_ = s._editorUndoBar) == null || _.hide(), o($, ie)) { | |
| e.drawLayer.updateProperties(this._currentDrawId, o($, ie).startNew(l, c, f, g, d)); | |
| return; | |
| } | |
| s.updateUIForDefaultProperties(this), p($, ie, this.createDrawerInstance(l, c, f, g, d)), p($, Jr, this.getDefaultDrawingOptions()), this._currentParent = e, { | |
| id: this._currentDrawId | |
| } = e.drawLayer.draw(this._mergeSVGProperties(o($, Jr).toSVGProperties(), o($, ie).defaultSVGProperties), !0, !1); | |
| } | |
| static _drawMove(e) { | |
| var a; | |
| if (p($, Qr, -1), !o($, ie)) | |
| return; | |
| const { | |
| offsetX: s, | |
| offsetY: i, | |
| pointerId: r | |
| } = e; | |
| if (o($, Tn) === r) { | |
| if (((a = o($, kn)) == null ? void 0 : a.size) >= 1) { | |
| this._endDraw(e); | |
| return; | |
| } | |
| this._currentParent.drawLayer.updateProperties(this._currentDrawId, o($, ie).add(s, i)), p($, Qr, e.timeStamp), ns(e); | |
| } | |
| } | |
| static _cleanup(e) { | |
| e && (this._currentDrawId = -1, this._currentParent = null, p($, ie, null), p($, Jr, null), p($, Cn, null), p($, Qr, NaN)), o($, Kr) && (o($, Kr).abort(), p($, Kr, null), p($, Tn, NaN), p($, kn, null)); | |
| } | |
| static _endDraw(e) { | |
| const s = this._currentParent; | |
| if (s) { | |
| if (s.toggleDrawing(!0), this._cleanup(!1), e && s.drawLayer.updateProperties(this._currentDrawId, o($, ie).end(e.offsetX, e.offsetY)), this.supportMultipleDrawings) { | |
| const i = o($, ie), r = this._currentDrawId, a = i.getLastElement(); | |
| s.addCommands({ | |
| cmd: () => { | |
| s.drawLayer.updateProperties(r, i.setLastElement(a)); | |
| }, | |
| undo: () => { | |
| s.drawLayer.updateProperties(r, i.removeLastElement()); | |
| }, | |
| mustExec: !1, | |
| type: lt.DRAW_STEP | |
| }); | |
| return; | |
| } | |
| this.endDrawing(!1); | |
| } | |
| } | |
| static endDrawing(e) { | |
| const s = this._currentParent; | |
| if (!s) | |
| return null; | |
| if (s.toggleDrawing(!0), s.cleanUndoStack(lt.DRAW_STEP), !o($, ie).isEmpty()) { | |
| const { | |
| pageDimensions: [i, r], | |
| scale: a | |
| } = s, l = s.createAndAddNewEditor({ | |
| offsetX: 0, | |
| offsetY: 0 | |
| }, !1, { | |
| drawId: this._currentDrawId, | |
| drawOutlines: o($, ie).getOutlines(i * a, r * a, a, this._INNER_MARGIN), | |
| drawingOptions: o($, Jr), | |
| mustBeCommitted: !e | |
| }); | |
| return this._cleanup(!0), l; | |
| } | |
| return s.drawLayer.remove(this._currentDrawId), this._cleanup(!0), null; | |
| } | |
| createDrawingOptions(e) { | |
| } | |
| static deserializeDraw(e, s, i, r, a, l) { | |
| Et("Not implemented"); | |
| } | |
| static async deserialize(e, s, i) { | |
| var d, f; | |
| const { | |
| rawDims: { | |
| pageWidth: r, | |
| pageHeight: a, | |
| pageX: l, | |
| pageY: c | |
| } | |
| } = s.viewport, h = this.deserializeDraw(l, c, r, a, this._INNER_MARGIN, e), u = await super.deserialize(e, s, i); | |
| return u.createDrawingOptions(e), v(d = u, ut, hp).call(d, { | |
| drawOutlines: h | |
| }), v(f = u, ut, wl).call(f), u.onScaleChanging(), u.rotate(), u; | |
| } | |
| serializeDraw(e) { | |
| const [s, i] = this.pageTranslation, [r, a] = this.pageDimensions; | |
| return o(this, Je).serialize([s, i, r, a], e); | |
| } | |
| renderAnnotationElement(e) { | |
| return e.updateEdited({ | |
| rect: this.getRect(0, 0) | |
| }), null; | |
| } | |
| static canCreateNewEmptyEditor() { | |
| return !1; | |
| } | |
| }; | |
| Je = new WeakMap(), Po = new WeakMap(), ie = new WeakMap(), Kr = new WeakMap(), Jr = new WeakMap(), Tn = new WeakMap(), Cn = new WeakMap(), kn = new WeakMap(), Qr = new WeakMap(), ut = new WeakSet(), hp = function({ | |
| drawOutlines: e, | |
| drawId: s, | |
| drawingOptions: i | |
| }) { | |
| p(this, Je, e), this._drawingOptions || (this._drawingOptions = i), s >= 0 ? (this._drawId = s, this.parent.drawLayer.finalizeDraw(s, e.defaultProperties)) : this._drawId = v(this, ut, up).call(this, e, this.parent), v(this, ut, Sl).call(this, e.box); | |
| }, up = function(e, s) { | |
| const { | |
| id: i | |
| } = s.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(), e.defaultSVGProperties), !1, !1); | |
| return i; | |
| }, dp = function() { | |
| this._drawId === null || !this.parent || (this.parent.drawLayer.remove(this._drawId), this._drawId = null, this._drawingOptions.reset()); | |
| }, wl = function(e = this.parent) { | |
| if (!(this._drawId !== null && this.parent === e)) { | |
| if (this._drawId !== null) { | |
| this.parent.drawLayer.updateParent(this._drawId, e.drawLayer); | |
| return; | |
| } | |
| this._drawingOptions.updateAll(), this._drawId = v(this, ut, up).call(this, o(this, Je), e); | |
| } | |
| }, Cv = function([e, s, i, r]) { | |
| const { | |
| parentDimensions: [a, l], | |
| rotation: c | |
| } = this; | |
| switch (c) { | |
| case 90: | |
| return [s, 1 - e, i * (l / a), r * (a / l)]; | |
| case 180: | |
| return [1 - e, 1 - s, i, r]; | |
| case 270: | |
| return [1 - s, e, i * (l / a), r * (a / l)]; | |
| default: | |
| return [e, s, i, r]; | |
| } | |
| }, gu = function() { | |
| const { | |
| x: e, | |
| y: s, | |
| width: i, | |
| height: r, | |
| parentDimensions: [a, l], | |
| rotation: c | |
| } = this; | |
| switch (c) { | |
| case 90: | |
| return [1 - s, e, i * (a / l), r * (l / a)]; | |
| case 180: | |
| return [1 - e, 1 - s, i, r]; | |
| case 270: | |
| return [s, 1 - e, i * (a / l), r * (l / a)]; | |
| default: | |
| return [e, s, i, r]; | |
| } | |
| }, Sl = function(e) { | |
| if ([this.x, this.y, this.width, this.height] = v(this, ut, Cv).call(this, e), this.div) { | |
| this.fixAndSetPosition(); | |
| const [s, i] = this.parentDimensions; | |
| this.setDims(this.width * s, this.height * i); | |
| } | |
| this._onResized(); | |
| }, Ia = function() { | |
| const { | |
| x: e, | |
| y: s, | |
| width: i, | |
| height: r, | |
| rotation: a, | |
| parentRotation: l, | |
| parentDimensions: [c, h] | |
| } = this; | |
| switch ((a * 4 + l) / 90) { | |
| case 1: | |
| return [1 - s - r, e, r, i]; | |
| case 2: | |
| return [1 - e - i, 1 - s - r, i, r]; | |
| case 3: | |
| return [s, 1 - e - i, r, i]; | |
| case 4: | |
| return [e, s - i * (c / h), r * (h / c), i * (c / h)]; | |
| case 5: | |
| return [1 - s, e, i * (c / h), r * (h / c)]; | |
| case 6: | |
| return [1 - e - r * (h / c), 1 - s, r * (h / c), i * (c / h)]; | |
| case 7: | |
| return [s - i * (c / h), 1 - e - r * (h / c), i * (c / h), r * (h / c)]; | |
| case 8: | |
| return [e - i, s - r, i, r]; | |
| case 9: | |
| return [1 - s, e - i, r, i]; | |
| case 10: | |
| return [1 - e, 1 - s, i, r]; | |
| case 11: | |
| return [s - r, 1 - e, r, i]; | |
| case 12: | |
| return [e - r * (h / c), s, r * (h / c), i * (c / h)]; | |
| case 13: | |
| return [1 - s - i * (c / h), e - r * (h / c), i * (c / h), r * (h / c)]; | |
| case 14: | |
| return [1 - e, 1 - s - i * (c / h), r * (h / c), i * (c / h)]; | |
| case 15: | |
| return [s, 1 - e, i * (c / h), r * (h / c)]; | |
| default: | |
| return [e, s, i, r]; | |
| } | |
| }, G($, "_currentDrawId", -1), G($, "_currentParent", null), b($, ie, null), b($, Kr, null), b($, Jr, null), b($, Tn, NaN), b($, Cn, null), b($, kn, null), b($, Qr, NaN), G($, "_INNER_MARGIN", 3); | |
| let cp = $; | |
| var ni, ne, re, ta, Mo, Ie, de, ps, ea, sa, ia, No, mu; | |
| class _T { | |
| constructor(t, e, s, i, r, a) { | |
| b(this, No); | |
| b(this, ni, new Float64Array(6)); | |
| b(this, ne); | |
| b(this, re); | |
| b(this, ta); | |
| b(this, Mo); | |
| b(this, Ie); | |
| b(this, de, ""); | |
| b(this, ps, 0); | |
| b(this, ea, new Gu()); | |
| b(this, sa); | |
| b(this, ia); | |
| p(this, sa, s), p(this, ia, i), p(this, ta, r), p(this, Mo, a), [t, e] = v(this, No, mu).call(this, t, e); | |
| const l = p(this, ne, [NaN, NaN, NaN, NaN, t, e]); | |
| p(this, Ie, [t, e]), p(this, re, [{ | |
| line: l, | |
| points: o(this, Ie) | |
| }]), o(this, ni).set(l, 0); | |
| } | |
| updateProperty(t, e) { | |
| t === "stroke-width" && p(this, Mo, e); | |
| } | |
| isEmpty() { | |
| return !o(this, re) || o(this, re).length === 0; | |
| } | |
| isCancellable() { | |
| return o(this, Ie).length <= 10; | |
| } | |
| add(t, e) { | |
| [t, e] = v(this, No, mu).call(this, t, e); | |
| const [s, i, r, a] = o(this, ni).subarray(2, 6), l = t - r, c = e - a; | |
| return Math.hypot(o(this, sa) * l, o(this, ia) * c) <= 2 ? null : (o(this, Ie).push(t, e), isNaN(s) ? (o(this, ni).set([r, a, t, e], 2), o(this, ne).push(NaN, NaN, NaN, NaN, t, e), { | |
| path: { | |
| d: this.toSVGPath() | |
| } | |
| }) : (isNaN(o(this, ni)[0]) && o(this, ne).splice(6, 6), o(this, ni).set([s, i, r, a, t, e], 0), o(this, ne).push(...F.createBezierPoints(s, i, r, a, t, e)), { | |
| path: { | |
| d: this.toSVGPath() | |
| } | |
| })); | |
| } | |
| end(t, e) { | |
| const s = this.add(t, e); | |
| return s || (o(this, Ie).length === 2 ? { | |
| path: { | |
| d: this.toSVGPath() | |
| } | |
| } : null); | |
| } | |
| startNew(t, e, s, i, r) { | |
| p(this, sa, s), p(this, ia, i), p(this, ta, r), [t, e] = v(this, No, mu).call(this, t, e); | |
| const a = p(this, ne, [NaN, NaN, NaN, NaN, t, e]); | |
| p(this, Ie, [t, e]); | |
| const l = o(this, re).at(-1); | |
| return l && (l.line = new Float32Array(l.line), l.points = new Float32Array(l.points)), o(this, re).push({ | |
| line: a, | |
| points: o(this, Ie) | |
| }), o(this, ni).set(a, 0), p(this, ps, 0), this.toSVGPath(), null; | |
| } | |
| getLastElement() { | |
| return o(this, re).at(-1); | |
| } | |
| setLastElement(t) { | |
| return o(this, re) ? (o(this, re).push(t), p(this, ne, t.line), p(this, Ie, t.points), p(this, ps, 0), { | |
| path: { | |
| d: this.toSVGPath() | |
| } | |
| }) : o(this, ea).setLastElement(t); | |
| } | |
| removeLastElement() { | |
| if (!o(this, re)) | |
| return o(this, ea).removeLastElement(); | |
| o(this, re).pop(), p(this, de, ""); | |
| for (let t = 0, e = o(this, re).length; t < e; t++) { | |
| const { | |
| line: s, | |
| points: i | |
| } = o(this, re)[t]; | |
| p(this, ne, s), p(this, Ie, i), p(this, ps, 0), this.toSVGPath(); | |
| } | |
| return { | |
| path: { | |
| d: o(this, de) | |
| } | |
| }; | |
| } | |
| toSVGPath() { | |
| const t = F.svgRound(o(this, ne)[4]), e = F.svgRound(o(this, ne)[5]); | |
| if (o(this, Ie).length === 2) | |
| return p(this, de, `${o(this, de)} M ${t} ${e} Z`), o(this, de); | |
| if (o(this, Ie).length <= 6) { | |
| const i = o(this, de).lastIndexOf("M"); | |
| p(this, de, `${o(this, de).slice(0, i)} M ${t} ${e}`), p(this, ps, 6); | |
| } | |
| if (o(this, Ie).length === 4) { | |
| const i = F.svgRound(o(this, ne)[10]), r = F.svgRound(o(this, ne)[11]); | |
| return p(this, de, `${o(this, de)} L ${i} ${r}`), p(this, ps, 12), o(this, de); | |
| } | |
| const s = []; | |
| o(this, ps) === 0 && (s.push(`M ${t} ${e}`), p(this, ps, 6)); | |
| for (let i = o(this, ps), r = o(this, ne).length; i < r; i += 6) { | |
| const [a, l, c, h, u, d] = o(this, ne).slice(i, i + 6).map(F.svgRound); | |
| s.push(`C${a} ${l} ${c} ${h} ${u} ${d}`); | |
| } | |
| return p(this, de, o(this, de) + s.join(" ")), p(this, ps, o(this, ne).length), o(this, de); | |
| } | |
| getOutlines(t, e, s, i) { | |
| const r = o(this, re).at(-1); | |
| return r.line = new Float32Array(r.line), r.points = new Float32Array(r.points), o(this, ea).build(o(this, re), t, e, s, o(this, ta), o(this, Mo), i), p(this, ni, null), p(this, ne, null), p(this, re, null), p(this, de, null), o(this, ea); | |
| } | |
| get defaultSVGProperties() { | |
| return { | |
| root: { | |
| viewBox: "0 0 10000 10000" | |
| }, | |
| rootClass: { | |
| draw: !0 | |
| }, | |
| bbox: [0, 0, 1, 1] | |
| }; | |
| } | |
| } | |
| ni = new WeakMap(), ne = new WeakMap(), re = new WeakMap(), ta = new WeakMap(), Mo = new WeakMap(), Ie = new WeakMap(), de = new WeakMap(), ps = new WeakMap(), ea = new WeakMap(), sa = new WeakMap(), ia = new WeakMap(), No = new WeakSet(), mu = function(t, e) { | |
| return F._normalizePoint(t, e, o(this, sa), o(this, ia), o(this, ta)); | |
| }; | |
| var Re, kh, Ih, Qe, ri, ai, Oo, Lo, Do, pe, yi, kv, Iv, Rv; | |
| const tg = class tg extends F { | |
| constructor() { | |
| super(...arguments); | |
| b(this, pe); | |
| b(this, Re); | |
| b(this, kh, 0); | |
| b(this, Ih); | |
| b(this, Qe); | |
| b(this, ri); | |
| b(this, ai); | |
| b(this, Oo); | |
| b(this, Lo); | |
| b(this, Do); | |
| } | |
| build(e, s, i, r, a, l, c) { | |
| p(this, ri, s), p(this, ai, i), p(this, Oo, r), p(this, Lo, a), p(this, Do, l), p(this, Ih, c ?? 0), p(this, Qe, e), v(this, pe, Iv).call(this); | |
| } | |
| setLastElement(e) { | |
| return o(this, Qe).push(e), { | |
| path: { | |
| d: this.toSVGPath() | |
| } | |
| }; | |
| } | |
| removeLastElement() { | |
| return o(this, Qe).pop(), { | |
| path: { | |
| d: this.toSVGPath() | |
| } | |
| }; | |
| } | |
| toSVGPath() { | |
| const e = []; | |
| for (const { | |
| line: s | |
| } of o(this, Qe)) { | |
| if (e.push(`M${F.svgRound(s[4])} ${F.svgRound(s[5])}`), s.length === 6) { | |
| e.push("Z"); | |
| continue; | |
| } | |
| if (s.length === 12) { | |
| e.push(`L${F.svgRound(s[10])} ${F.svgRound(s[11])}`); | |
| continue; | |
| } | |
| for (let i = 6, r = s.length; i < r; i += 6) { | |
| const [a, l, c, h, u, d] = s.subarray(i, i + 6).map(F.svgRound); | |
| e.push(`C${a} ${l} ${c} ${h} ${u} ${d}`); | |
| } | |
| } | |
| return e.join(""); | |
| } | |
| serialize([e, s, i, r], a) { | |
| const l = [], c = [], [h, u, d, f] = v(this, pe, kv).call(this); | |
| let g, m, y, _, A, S, E, x, T; | |
| switch (o(this, Lo)) { | |
| case 0: | |
| T = F._rescale, g = e, m = s + r, y = i, _ = -r, A = e + h * i, S = s + (1 - u - f) * r, E = e + (h + d) * i, x = s + (1 - u) * r; | |
| break; | |
| case 90: | |
| T = F._rescaleAndSwap, g = e, m = s, y = i, _ = r, A = e + u * i, S = s + h * r, E = e + (u + f) * i, x = s + (h + d) * r; | |
| break; | |
| case 180: | |
| T = F._rescale, g = e + i, m = s, y = -i, _ = r, A = e + (1 - h - d) * i, S = s + u * r, E = e + (1 - h) * i, x = s + (u + f) * r; | |
| break; | |
| case 270: | |
| T = F._rescaleAndSwap, g = e + i, m = s + r, y = -i, _ = -r, A = e + (1 - u - f) * i, S = s + (1 - h - d) * r, E = e + (1 - u) * i, x = s + (1 - h) * r; | |
| break; | |
| } | |
| for (const { | |
| line: k, | |
| points: C | |
| } of o(this, Qe)) | |
| l.push(T(k, g, m, y, _, a ? new Array(k.length) : null)), c.push(T(C, g, m, y, _, a ? new Array(C.length) : null)); | |
| return { | |
| lines: l, | |
| points: c, | |
| rect: [A, S, E, x] | |
| }; | |
| } | |
| static deserialize(e, s, i, r, a, { | |
| paths: { | |
| lines: l, | |
| points: c | |
| }, | |
| rotation: h, | |
| thickness: u | |
| }) { | |
| const d = []; | |
| let f, g, m, y, _; | |
| switch (h) { | |
| case 0: | |
| _ = F._rescale, f = -e / i, g = s / r + 1, m = 1 / i, y = -1 / r; | |
| break; | |
| case 90: | |
| _ = F._rescaleAndSwap, f = -s / r, g = -e / i, m = 1 / r, y = 1 / i; | |
| break; | |
| case 180: | |
| _ = F._rescale, f = e / i + 1, g = -s / r, m = -1 / i, y = 1 / r; | |
| break; | |
| case 270: | |
| _ = F._rescaleAndSwap, f = s / r + 1, g = e / i + 1, m = -1 / r, y = -1 / i; | |
| break; | |
| } | |
| if (!l) { | |
| l = []; | |
| for (const S of c) { | |
| const E = S.length; | |
| if (E === 2) { | |
| l.push(new Float32Array([NaN, NaN, NaN, NaN, S[0], S[1]])); | |
| continue; | |
| } | |
| if (E === 4) { | |
| l.push(new Float32Array([NaN, NaN, NaN, NaN, S[0], S[1], NaN, NaN, NaN, NaN, S[2], S[3]])); | |
| continue; | |
| } | |
| const x = new Float32Array(3 * (E - 2)); | |
| l.push(x); | |
| let [T, k, C, P] = S.subarray(0, 4); | |
| x.set([NaN, NaN, NaN, NaN, T, k], 0); | |
| for (let j = 4; j < E; j += 2) { | |
| const Z = S[j], V = S[j + 1]; | |
| x.set(F.createBezierPoints(T, k, C, P, Z, V), (j - 2) * 3), [T, k, C, P] = [C, P, Z, V]; | |
| } | |
| } | |
| } | |
| for (let S = 0, E = l.length; S < E; S++) | |
| d.push({ | |
| line: _(l[S].map((x) => x ?? NaN), f, g, m, y), | |
| points: _(c[S].map((x) => x ?? NaN), f, g, m, y) | |
| }); | |
| const A = new tg(); | |
| return A.build(d, i, r, 1, h, u, a), A; | |
| } | |
| get box() { | |
| return o(this, Re); | |
| } | |
| updateProperty(e, s) { | |
| return e === "stroke-width" ? v(this, pe, Rv).call(this, s) : null; | |
| } | |
| updateParentDimensions([e, s], i) { | |
| const [r, a] = v(this, pe, yi).call(this); | |
| p(this, ri, e), p(this, ai, s), p(this, Oo, i); | |
| const [l, c] = v(this, pe, yi).call(this), h = l - r, u = c - a, d = o(this, Re); | |
| return d[0] -= h, d[1] -= u, d[2] += 2 * h, d[3] += 2 * u, d; | |
| } | |
| updateRotation(e) { | |
| return p(this, kh, e), { | |
| path: { | |
| transform: this.rotationTransform | |
| } | |
| }; | |
| } | |
| get viewBox() { | |
| return o(this, Re).map(F.svgRound).join(" "); | |
| } | |
| get defaultProperties() { | |
| const [e, s] = o(this, Re); | |
| return { | |
| root: { | |
| viewBox: this.viewBox | |
| }, | |
| path: { | |
| "transform-origin": `${F.svgRound(e)} ${F.svgRound(s)}` | |
| } | |
| }; | |
| } | |
| get rotationTransform() { | |
| const [, , e, s] = o(this, Re); | |
| let i = 0, r = 0, a = 0, l = 0, c = 0, h = 0; | |
| switch (o(this, kh)) { | |
| case 90: | |
| r = s / e, a = -e / s, c = e; | |
| break; | |
| case 180: | |
| i = -1, l = -1, c = e, h = s; | |
| break; | |
| case 270: | |
| r = -s / e, a = e / s, h = s; | |
| break; | |
| default: | |
| return ""; | |
| } | |
| return `matrix(${i} ${r} ${a} ${l} ${F.svgRound(c)} ${F.svgRound(h)})`; | |
| } | |
| getPathResizingSVGProperties([e, s, i, r]) { | |
| const [a, l] = v(this, pe, yi).call(this), [c, h, u, d] = o(this, Re); | |
| if (Math.abs(u - a) <= F.PRECISION || Math.abs(d - l) <= F.PRECISION) { | |
| const _ = e + i / 2 - (c + u / 2), A = s + r / 2 - (h + d / 2); | |
| return { | |
| path: { | |
| "transform-origin": `${F.svgRound(e)} ${F.svgRound(s)}`, | |
| transform: `${this.rotationTransform} translate(${_} ${A})` | |
| } | |
| }; | |
| } | |
| const f = (i - 2 * a) / (u - 2 * a), g = (r - 2 * l) / (d - 2 * l), m = u / i, y = d / r; | |
| return { | |
| path: { | |
| "transform-origin": `${F.svgRound(c)} ${F.svgRound(h)}`, | |
| transform: `${this.rotationTransform} scale(${m} ${y}) translate(${F.svgRound(a)} ${F.svgRound(l)}) scale(${f} ${g}) translate(${F.svgRound(-a)} ${F.svgRound(-l)})` | |
| } | |
| }; | |
| } | |
| getPathResizedSVGProperties([e, s, i, r]) { | |
| const [a, l] = v(this, pe, yi).call(this), c = o(this, Re), [h, u, d, f] = c; | |
| if (c[0] = e, c[1] = s, c[2] = i, c[3] = r, Math.abs(d - a) <= F.PRECISION || Math.abs(f - l) <= F.PRECISION) { | |
| const A = e + i / 2 - (h + d / 2), S = s + r / 2 - (u + f / 2); | |
| for (const { | |
| line: E, | |
| points: x | |
| } of o(this, Qe)) | |
| F._translate(E, A, S, E), F._translate(x, A, S, x); | |
| return { | |
| root: { | |
| viewBox: this.viewBox | |
| }, | |
| path: { | |
| "transform-origin": `${F.svgRound(e)} ${F.svgRound(s)}`, | |
| transform: this.rotationTransform || null, | |
| d: this.toSVGPath() | |
| } | |
| }; | |
| } | |
| const g = (i - 2 * a) / (d - 2 * a), m = (r - 2 * l) / (f - 2 * l), y = -g * (h + a) + e + a, _ = -m * (u + l) + s + l; | |
| if (g !== 1 || m !== 1 || y !== 0 || _ !== 0) | |
| for (const { | |
| line: A, | |
| points: S | |
| } of o(this, Qe)) | |
| F._rescale(A, y, _, g, m, A), F._rescale(S, y, _, g, m, S); | |
| return { | |
| root: { | |
| viewBox: this.viewBox | |
| }, | |
| path: { | |
| "transform-origin": `${F.svgRound(e)} ${F.svgRound(s)}`, | |
| transform: this.rotationTransform || null, | |
| d: this.toSVGPath() | |
| } | |
| }; | |
| } | |
| getPathTranslatedSVGProperties([e, s], i) { | |
| const [r, a] = i, l = o(this, Re), c = e - l[0], h = s - l[1]; | |
| if (o(this, ri) === r && o(this, ai) === a) | |
| for (const { | |
| line: u, | |
| points: d | |
| } of o(this, Qe)) | |
| F._translate(u, c, h, u), F._translate(d, c, h, d); | |
| else { | |
| const u = o(this, ri) / r, d = o(this, ai) / a; | |
| p(this, ri, r), p(this, ai, a); | |
| for (const { | |
| line: f, | |
| points: g | |
| } of o(this, Qe)) | |
| F._rescale(f, c, h, u, d, f), F._rescale(g, c, h, u, d, g); | |
| l[2] *= u, l[3] *= d; | |
| } | |
| return l[0] = e, l[1] = s, { | |
| root: { | |
| viewBox: this.viewBox | |
| }, | |
| path: { | |
| d: this.toSVGPath(), | |
| "transform-origin": `${F.svgRound(e)} ${F.svgRound(s)}` | |
| } | |
| }; | |
| } | |
| get defaultSVGProperties() { | |
| const e = o(this, Re); | |
| return { | |
| root: { | |
| viewBox: this.viewBox | |
| }, | |
| rootClass: { | |
| draw: !0 | |
| }, | |
| path: { | |
| d: this.toSVGPath(), | |
| "transform-origin": `${F.svgRound(e[0])} ${F.svgRound(e[1])}`, | |
| transform: this.rotationTransform || null | |
| }, | |
| bbox: e | |
| }; | |
| } | |
| }; | |
| Re = new WeakMap(), kh = new WeakMap(), Ih = new WeakMap(), Qe = new WeakMap(), ri = new WeakMap(), ai = new WeakMap(), Oo = new WeakMap(), Lo = new WeakMap(), Do = new WeakMap(), pe = new WeakSet(), yi = function(e = o(this, Do)) { | |
| const s = o(this, Ih) + e / 2 * o(this, Oo); | |
| return o(this, Lo) % 180 === 0 ? [s / o(this, ri), s / o(this, ai)] : [s / o(this, ai), s / o(this, ri)]; | |
| }, kv = function() { | |
| const [e, s, i, r] = o(this, Re), [a, l] = v(this, pe, yi).call(this, 0); | |
| return [e + a, s + l, i - 2 * a, r - 2 * l]; | |
| }, Iv = function() { | |
| const e = p(this, Re, new Float32Array([1 / 0, 1 / 0, -1 / 0, -1 / 0])); | |
| for (const { | |
| line: r | |
| } of o(this, Qe)) { | |
| if (r.length <= 12) { | |
| for (let c = 4, h = r.length; c < h; c += 6) { | |
| const [u, d] = r.subarray(c, c + 2); | |
| e[0] = Math.min(e[0], u), e[1] = Math.min(e[1], d), e[2] = Math.max(e[2], u), e[3] = Math.max(e[3], d); | |
| } | |
| continue; | |
| } | |
| let a = r[4], l = r[5]; | |
| for (let c = 6, h = r.length; c < h; c += 6) { | |
| const [u, d, f, g, m, y] = r.subarray(c, c + 6); | |
| U.bezierBoundingBox(a, l, u, d, f, g, m, y, e), a = m, l = y; | |
| } | |
| } | |
| const [s, i] = v(this, pe, yi).call(this); | |
| e[0] = Math.min(1, Math.max(0, e[0] - s)), e[1] = Math.min(1, Math.max(0, e[1] - i)), e[2] = Math.min(1, Math.max(0, e[2] + s)), e[3] = Math.min(1, Math.max(0, e[3] + i)), e[2] -= e[0], e[3] -= e[1]; | |
| }, Rv = function(e) { | |
| const [s, i] = v(this, pe, yi).call(this); | |
| p(this, Do, e); | |
| const [r, a] = v(this, pe, yi).call(this), [l, c] = [r - s, a - i], h = o(this, Re); | |
| return h[0] -= l, h[1] -= c, h[2] += 2 * l, h[3] += 2 * c, h; | |
| }; | |
| let Gu = tg; | |
| var Fo; | |
| const eg = class eg extends vT { | |
| constructor(e) { | |
| super(); | |
| b(this, Fo); | |
| p(this, Fo, e), super.updateProperties({ | |
| fill: "none", | |
| stroke: Ft._defaultLineColor, | |
| "stroke-opacity": 1, | |
| "stroke-width": 1, | |
| "stroke-linecap": "round", | |
| "stroke-linejoin": "round", | |
| "stroke-miterlimit": 10 | |
| }); | |
| } | |
| updateSVGProperty(e, s) { | |
| e === "stroke-width" && (s ?? (s = this["stroke-width"]), s *= o(this, Fo).realScale), super.updateSVGProperty(e, s); | |
| } | |
| clone() { | |
| const e = new eg(o(this, Fo)); | |
| return e.updateAll(this), e; | |
| } | |
| }; | |
| Fo = new WeakMap(); | |
| let fp = eg; | |
| var hd, Pv; | |
| const Ma = class Ma extends cp { | |
| constructor(e) { | |
| super({ | |
| ...e, | |
| name: "inkEditor" | |
| }); | |
| b(this, hd); | |
| this._willKeepAspectRatio = !0; | |
| } | |
| static initialize(e, s) { | |
| Ft.initialize(e, s), this._defaultDrawingOptions = new fp(s.viewParameters); | |
| } | |
| static getDefaultDrawingOptions(e) { | |
| const s = this._defaultDrawingOptions.clone(); | |
| return s.updateProperties(e), s; | |
| } | |
| static get supportMultipleDrawings() { | |
| return !0; | |
| } | |
| static get typesMap() { | |
| return at(this, "typesMap", /* @__PURE__ */ new Map([[lt.INK_THICKNESS, "stroke-width"], [lt.INK_COLOR, "stroke"], [lt.INK_OPACITY, "stroke-opacity"]])); | |
| } | |
| static createDrawerInstance(e, s, i, r, a) { | |
| return new _T(e, s, i, r, a, this._defaultDrawingOptions["stroke-width"]); | |
| } | |
| static deserializeDraw(e, s, i, r, a, l) { | |
| return Gu.deserialize(e, s, i, r, a, l); | |
| } | |
| static async deserialize(e, s, i) { | |
| let r = null; | |
| if (e instanceof Zp) { | |
| const { | |
| data: { | |
| inkLists: l, | |
| rect: c, | |
| rotation: h, | |
| id: u, | |
| color: d, | |
| opacity: f, | |
| borderStyle: { | |
| rawWidth: g | |
| }, | |
| popupRef: m | |
| }, | |
| parent: { | |
| page: { | |
| pageNumber: y | |
| } | |
| } | |
| } = e; | |
| r = e = { | |
| annotationType: et.INK, | |
| color: Array.from(d), | |
| thickness: g, | |
| opacity: f, | |
| paths: { | |
| points: l | |
| }, | |
| boxes: null, | |
| pageIndex: y - 1, | |
| rect: c.slice(0), | |
| rotation: h, | |
| id: u, | |
| deleted: !1, | |
| popupRef: m | |
| }; | |
| } | |
| const a = await super.deserialize(e, s, i); | |
| return a.annotationElementId = e.id || null, a._initialData = r, a; | |
| } | |
| onScaleChanging() { | |
| if (!this.parent) | |
| return; | |
| super.onScaleChanging(); | |
| const { | |
| _drawId: e, | |
| _drawingOptions: s, | |
| parent: i | |
| } = this; | |
| s.updateSVGProperty("stroke-width"), i.drawLayer.updateProperties(e, s.toSVGProperties()); | |
| } | |
| static onScaleChangingWhenDrawing() { | |
| const e = this._currentParent; | |
| e && (super.onScaleChangingWhenDrawing(), this._defaultDrawingOptions.updateSVGProperty("stroke-width"), e.drawLayer.updateProperties(this._currentDrawId, this._defaultDrawingOptions.toSVGProperties())); | |
| } | |
| createDrawingOptions({ | |
| color: e, | |
| thickness: s, | |
| opacity: i | |
| }) { | |
| this._drawingOptions = Ma.getDefaultDrawingOptions({ | |
| stroke: U.makeHexColor(...e), | |
| "stroke-width": s, | |
| "stroke-opacity": i | |
| }); | |
| } | |
| serialize(e = !1) { | |
| if (this.isEmpty()) | |
| return null; | |
| if (this.deleted) | |
| return this.serializeDeleted(); | |
| const { | |
| lines: s, | |
| points: i, | |
| rect: r | |
| } = this.serializeDraw(e), { | |
| _drawingOptions: { | |
| stroke: a, | |
| "stroke-opacity": l, | |
| "stroke-width": c | |
| } | |
| } = this, h = { | |
| annotationType: et.INK, | |
| color: Ft._colorManager.convert(a), | |
| opacity: l, | |
| thickness: c, | |
| paths: { | |
| lines: s, | |
| points: i | |
| }, | |
| pageIndex: this.pageIndex, | |
| rect: r, | |
| rotation: this.rotation, | |
| structTreeParentId: this._structTreeParentId | |
| }; | |
| return e ? h : this.annotationElementId && !v(this, hd, Pv).call(this, h) ? null : (h.id = this.annotationElementId, h); | |
| } | |
| renderAnnotationElement(e) { | |
| const { | |
| points: s, | |
| rect: i | |
| } = this.serializeDraw(!1); | |
| return e.updateEdited({ | |
| rect: i, | |
| thickness: this._drawingOptions["stroke-width"], | |
| points: s | |
| }), null; | |
| } | |
| }; | |
| hd = new WeakSet(), Pv = function(e) { | |
| const { | |
| color: s, | |
| thickness: i, | |
| opacity: r, | |
| pageIndex: a | |
| } = this._initialData; | |
| return this._hasBeenMoved || this._hasBeenResized || e.color.some((l, c) => l !== s[c]) || e.thickness !== i || e.opacity !== r || e.pageIndex !== a; | |
| }, G(Ma, "_type", "ink"), G(Ma, "_editorType", et.INK), G(Ma, "_defaultDrawingOptions", null); | |
| let pp = Ma; | |
| var Lt, fe, In, Ui, Rn, $o, oi, li, ts, jo, pt, El, xl, yu, mp, bu, yp, vu, Mv; | |
| const Pl = class Pl extends Ft { | |
| constructor(e) { | |
| super({ | |
| ...e, | |
| name: "stampEditor" | |
| }); | |
| b(this, pt); | |
| b(this, Lt, null); | |
| b(this, fe, null); | |
| b(this, In, null); | |
| b(this, Ui, null); | |
| b(this, Rn, null); | |
| b(this, $o, ""); | |
| b(this, oi, null); | |
| b(this, li, null); | |
| b(this, ts, !1); | |
| b(this, jo, !1); | |
| p(this, Ui, e.bitmapUrl), p(this, Rn, e.bitmapFile); | |
| } | |
| static initialize(e, s) { | |
| Ft.initialize(e, s); | |
| } | |
| static get supportedTypes() { | |
| return at(this, "supportedTypes", ["apng", "avif", "bmp", "gif", "jpeg", "png", "svg+xml", "webp", "x-icon"].map((s) => `image/${s}`)); | |
| } | |
| static get supportedTypesStr() { | |
| return at(this, "supportedTypesStr", this.supportedTypes.join(",")); | |
| } | |
| static isHandlingMimeForPasting(e) { | |
| return this.supportedTypes.includes(e); | |
| } | |
| static paste(e, s) { | |
| s.pasteEditor(et.STAMP, { | |
| bitmapFile: e.getAsFile() | |
| }); | |
| } | |
| altTextFinish() { | |
| this._uiManager.useNewAltTextFlow && (this.div.hidden = !1), super.altTextFinish(); | |
| } | |
| get telemetryFinalData() { | |
| var e; | |
| return { | |
| type: "stamp", | |
| hasAltText: !!((e = this.altTextData) != null && e.altText) | |
| }; | |
| } | |
| static computeTelemetryFinalData(e) { | |
| const s = e.get("hasAltText"); | |
| return { | |
| hasAltText: s.get(!0) ?? 0, | |
| hasNoAltText: s.get(!1) ?? 0 | |
| }; | |
| } | |
| async mlGuessAltText(e = null, s = !0) { | |
| if (this.hasAltTextData()) | |
| return null; | |
| const { | |
| mlManager: i | |
| } = this._uiManager; | |
| if (!i) | |
| throw new Error("No ML."); | |
| if (!await i.isEnabledFor("altText")) | |
| throw new Error("ML isn't enabled for alt text."); | |
| const { | |
| data: r, | |
| width: a, | |
| height: l | |
| } = e || this.copyCanvas(null, null, !0).imageData, c = await i.guess({ | |
| name: "altText", | |
| request: { | |
| data: r, | |
| width: a, | |
| height: l, | |
| channels: r.length / (a * l) | |
| } | |
| }); | |
| if (!c) | |
| throw new Error("No response from the AI service."); | |
| if (c.error) | |
| throw new Error("Error from the AI service."); | |
| if (c.cancel) | |
| return null; | |
| if (!c.output) | |
| throw new Error("No valid response from the AI service."); | |
| const h = c.output; | |
| return await this.setGuessedAltText(h), s && !this.hasAltTextData() && (this.altTextData = { | |
| alt: h, | |
| decorative: !1 | |
| }), h; | |
| } | |
| remove() { | |
| var e; | |
| o(this, fe) && (p(this, Lt, null), this._uiManager.imageManager.deleteId(o(this, fe)), (e = o(this, oi)) == null || e.remove(), p(this, oi, null), o(this, li) && (clearTimeout(o(this, li)), p(this, li, null))), super.remove(); | |
| } | |
| rebuild() { | |
| if (!this.parent) { | |
| o(this, fe) && v(this, pt, yu).call(this); | |
| return; | |
| } | |
| super.rebuild(), this.div !== null && (o(this, fe) && o(this, oi) === null && v(this, pt, yu).call(this), this.isAttachedToDOM || this.parent.add(this)); | |
| } | |
| onceAdded(e) { | |
| this._isDraggable = !0, e && this.div.focus(); | |
| } | |
| isEmpty() { | |
| return !(o(this, In) || o(this, Lt) || o(this, Ui) || o(this, Rn) || o(this, fe)); | |
| } | |
| get isResizable() { | |
| return !0; | |
| } | |
| render() { | |
| if (this.div) | |
| return this.div; | |
| let e, s; | |
| if (this.width && (e = this.x, s = this.y), super.render(), this.div.hidden = !0, this.div.setAttribute("role", "figure"), this.addAltTextButton(), o(this, Lt) ? v(this, pt, mp).call(this) : v(this, pt, yu).call(this), this.width && !this.annotationElementId) { | |
| const [i, r] = this.parentDimensions; | |
| this.setAt(e * i, s * r, this.width * i, this.height * r); | |
| } | |
| return this._uiManager.addShouldRescale(this), this.div; | |
| } | |
| _onResized() { | |
| this.onScaleChanging(); | |
| } | |
| onScaleChanging() { | |
| if (!this.parent) | |
| return; | |
| o(this, li) !== null && clearTimeout(o(this, li)), p(this, li, setTimeout(() => { | |
| p(this, li, null), v(this, pt, yp).call(this); | |
| }, 200)); | |
| } | |
| copyCanvas(e, s, i = !1) { | |
| var g; | |
| e || (e = 224); | |
| const { | |
| width: r, | |
| height: a | |
| } = o(this, Lt), l = new ff(); | |
| let c = o(this, Lt), h = r, u = a, d = null; | |
| if (s) { | |
| if (r > s || a > s) { | |
| const P = Math.min(s / r, s / a); | |
| h = Math.floor(r * P), u = Math.floor(a * P); | |
| } | |
| d = document.createElement("canvas"); | |
| const m = d.width = Math.ceil(h * l.sx), y = d.height = Math.ceil(u * l.sy); | |
| o(this, ts) || (c = v(this, pt, bu).call(this, m, y)); | |
| const _ = d.getContext("2d"); | |
| _.filter = this._uiManager.hcmFilter; | |
| let A = "white", S = "#cfcfd8"; | |
| this._uiManager.hcmFilter !== "none" ? S = "black" : (g = window.matchMedia) != null && g.call(window, "(prefers-color-scheme: dark)").matches && (A = "#8f8f9d", S = "#42414d"); | |
| const E = 15, x = E * l.sx, T = E * l.sy, k = new OffscreenCanvas(x * 2, T * 2), C = k.getContext("2d"); | |
| C.fillStyle = A, C.fillRect(0, 0, x * 2, T * 2), C.fillStyle = S, C.fillRect(0, 0, x, T), C.fillRect(x, T, x, T), _.fillStyle = _.createPattern(k, "repeat"), _.fillRect(0, 0, m, y), _.drawImage(c, 0, 0, c.width, c.height, 0, 0, m, y); | |
| } | |
| let f = null; | |
| if (i) { | |
| let m, y; | |
| if (l.symmetric && c.width < e && c.height < e) | |
| m = c.width, y = c.height; | |
| else if (c = o(this, Lt), r > e || a > e) { | |
| const S = Math.min(e / r, e / a); | |
| m = Math.floor(r * S), y = Math.floor(a * S), o(this, ts) || (c = v(this, pt, bu).call(this, m, y)); | |
| } | |
| const A = new OffscreenCanvas(m, y).getContext("2d", { | |
| willReadFrequently: !0 | |
| }); | |
| A.drawImage(c, 0, 0, c.width, c.height, 0, 0, m, y), f = { | |
| width: m, | |
| height: y, | |
| data: A.getImageData(0, 0, m, y).data | |
| }; | |
| } | |
| return { | |
| canvas: d, | |
| width: h, | |
| height: u, | |
| imageData: f | |
| }; | |
| } | |
| getImageForAltText() { | |
| return o(this, oi); | |
| } | |
| static async deserialize(e, s, i) { | |
| var y; | |
| let r = null; | |
| if (e instanceof Qb) { | |
| const { | |
| data: { | |
| rect: _, | |
| rotation: A, | |
| id: S, | |
| structParent: E, | |
| popupRef: x | |
| }, | |
| container: T, | |
| parent: { | |
| page: { | |
| pageNumber: k | |
| } | |
| } | |
| } = e, C = T.querySelector("canvas"), P = i.imageManager.getFromCanvas(T.id, C); | |
| C.remove(); | |
| const j = ((y = await s._structTree.getAriaAttributes(`${Hp}${S}`)) == null ? void 0 : y.get("aria-label")) || ""; | |
| r = e = { | |
| annotationType: et.STAMP, | |
| bitmapId: P.id, | |
| bitmap: P.bitmap, | |
| pageIndex: k - 1, | |
| rect: _.slice(0), | |
| rotation: A, | |
| id: S, | |
| deleted: !1, | |
| accessibilityData: { | |
| decorative: !1, | |
| altText: j | |
| }, | |
| isSvg: !1, | |
| structParent: E, | |
| popupRef: x | |
| }; | |
| } | |
| const a = await super.deserialize(e, s, i), { | |
| rect: l, | |
| bitmap: c, | |
| bitmapUrl: h, | |
| bitmapId: u, | |
| isSvg: d, | |
| accessibilityData: f | |
| } = e; | |
| u && i.imageManager.isValidId(u) ? (p(a, fe, u), c && p(a, Lt, c)) : p(a, Ui, h), p(a, ts, d); | |
| const [g, m] = a.pageDimensions; | |
| return a.width = (l[2] - l[0]) / g, a.height = (l[3] - l[1]) / m, a.annotationElementId = e.id || null, f && (a.altTextData = f), a._initialData = r, p(a, jo, !!r), a; | |
| } | |
| serialize(e = !1, s = null) { | |
| if (this.isEmpty()) | |
| return null; | |
| if (this.deleted) | |
| return this.serializeDeleted(); | |
| const i = { | |
| annotationType: et.STAMP, | |
| bitmapId: o(this, fe), | |
| pageIndex: this.pageIndex, | |
| rect: this.getRect(0, 0), | |
| rotation: this.rotation, | |
| isSvg: o(this, ts), | |
| structTreeParentId: this._structTreeParentId | |
| }; | |
| if (e) | |
| return i.bitmapUrl = v(this, pt, vu).call(this, !0), i.accessibilityData = this.serializeAltText(!0), i; | |
| const { | |
| decorative: r, | |
| altText: a | |
| } = this.serializeAltText(!1); | |
| if (!r && a && (i.accessibilityData = { | |
| type: "Figure", | |
| alt: a | |
| }), this.annotationElementId) { | |
| const c = v(this, pt, Mv).call(this, i); | |
| if (c.isSame) | |
| return null; | |
| c.isSameAltText ? delete i.accessibilityData : i.accessibilityData.structParent = this._initialData.structParent ?? -1; | |
| } | |
| if (i.id = this.annotationElementId, s === null) | |
| return i; | |
| s.stamps || (s.stamps = /* @__PURE__ */ new Map()); | |
| const l = o(this, ts) ? (i.rect[2] - i.rect[0]) * (i.rect[3] - i.rect[1]) : null; | |
| if (!s.stamps.has(o(this, fe))) | |
| s.stamps.set(o(this, fe), { | |
| area: l, | |
| serialized: i | |
| }), i.bitmap = v(this, pt, vu).call(this, !1); | |
| else if (o(this, ts)) { | |
| const c = s.stamps.get(o(this, fe)); | |
| l > c.area && (c.area = l, c.serialized.bitmap.close(), c.serialized.bitmap = v(this, pt, vu).call(this, !1)); | |
| } | |
| return i; | |
| } | |
| renderAnnotationElement(e) { | |
| return e.updateEdited({ | |
| rect: this.getRect(0, 0) | |
| }), null; | |
| } | |
| }; | |
| Lt = new WeakMap(), fe = new WeakMap(), In = new WeakMap(), Ui = new WeakMap(), Rn = new WeakMap(), $o = new WeakMap(), oi = new WeakMap(), li = new WeakMap(), ts = new WeakMap(), jo = new WeakMap(), pt = new WeakSet(), El = function(e, s = !1) { | |
| if (!e) { | |
| this.remove(); | |
| return; | |
| } | |
| p(this, Lt, e.bitmap), s || (p(this, fe, e.id), p(this, ts, e.isSvg)), e.file && p(this, $o, e.file.name), v(this, pt, mp).call(this); | |
| }, xl = function() { | |
| if (p(this, In, null), this._uiManager.enableWaiting(!1), !!o(this, oi)) { | |
| if (this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && o(this, Lt)) { | |
| this._editToolbar.hide(), this._uiManager.editAltText(this, !0); | |
| return; | |
| } | |
| if (!this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && o(this, Lt)) { | |
| this._reportTelemetry({ | |
| action: "pdfjs.image.image_added", | |
| data: { | |
| alt_text_modal: !1, | |
| alt_text_type: "empty" | |
| } | |
| }); | |
| try { | |
| this.mlGuessAltText(); | |
| } catch { | |
| } | |
| } | |
| this.div.focus(); | |
| } | |
| }, yu = function() { | |
| if (o(this, fe)) { | |
| this._uiManager.enableWaiting(!0), this._uiManager.imageManager.getFromId(o(this, fe)).then((i) => v(this, pt, El).call(this, i, !0)).finally(() => v(this, pt, xl).call(this)); | |
| return; | |
| } | |
| if (o(this, Ui)) { | |
| const i = o(this, Ui); | |
| p(this, Ui, null), this._uiManager.enableWaiting(!0), p(this, In, this._uiManager.imageManager.getFromUrl(i).then((r) => v(this, pt, El).call(this, r)).finally(() => v(this, pt, xl).call(this))); | |
| return; | |
| } | |
| if (o(this, Rn)) { | |
| const i = o(this, Rn); | |
| p(this, Rn, null), this._uiManager.enableWaiting(!0), p(this, In, this._uiManager.imageManager.getFromFile(i).then((r) => v(this, pt, El).call(this, r)).finally(() => v(this, pt, xl).call(this))); | |
| return; | |
| } | |
| const e = document.createElement("input"); | |
| e.type = "file", e.accept = Pl.supportedTypesStr; | |
| const s = this._uiManager._signal; | |
| p(this, In, new Promise((i) => { | |
| e.addEventListener("change", async () => { | |
| if (!e.files || e.files.length === 0) | |
| this.remove(); | |
| else { | |
| this._uiManager.enableWaiting(!0); | |
| const r = await this._uiManager.imageManager.getFromFile(e.files[0]); | |
| this._reportTelemetry({ | |
| action: "pdfjs.image.image_selected", | |
| data: { | |
| alt_text_modal: this._uiManager.useNewAltTextFlow | |
| } | |
| }), v(this, pt, El).call(this, r); | |
| } | |
| i(); | |
| }, { | |
| signal: s | |
| }), e.addEventListener("cancel", () => { | |
| this.remove(), i(); | |
| }, { | |
| signal: s | |
| }); | |
| }).finally(() => v(this, pt, xl).call(this))), e.click(); | |
| }, mp = function() { | |
| var d; | |
| const { | |
| div: e | |
| } = this; | |
| let { | |
| width: s, | |
| height: i | |
| } = o(this, Lt); | |
| const [r, a] = this.pageDimensions, l = 0.75; | |
| if (this.width) | |
| s = this.width * r, i = this.height * a; | |
| else if (s > l * r || i > l * a) { | |
| const f = Math.min(l * r / s, l * a / i); | |
| s *= f, i *= f; | |
| } | |
| const [c, h] = this.parentDimensions; | |
| this.setDims(s * c / r, i * h / a), this._uiManager.enableWaiting(!1); | |
| const u = p(this, oi, document.createElement("canvas")); | |
| u.setAttribute("role", "img"), this.addContainer(u), this.width = s / r, this.height = i / a, (d = this._initialOptions) != null && d.isCentered ? this.center() : this.fixAndSetPosition(), this._initialOptions = null, (!this._uiManager.useNewAltTextWhenAddingImage || !this._uiManager.useNewAltTextFlow || this.annotationElementId) && (e.hidden = !1), v(this, pt, yp).call(this), o(this, jo) || (this.parent.addUndoableEditor(this), p(this, jo, !0)), this._reportTelemetry({ | |
| action: "inserted_image" | |
| }), o(this, $o) && u.setAttribute("aria-label", o(this, $o)); | |
| }, bu = function(e, s) { | |
| const { | |
| width: i, | |
| height: r | |
| } = o(this, Lt); | |
| let a = i, l = r, c = o(this, Lt); | |
| for (; a > 2 * e || l > 2 * s; ) { | |
| const h = a, u = l; | |
| a > 2 * e && (a = a >= 16384 ? Math.floor(a / 2) - 1 : Math.ceil(a / 2)), l > 2 * s && (l = l >= 16384 ? Math.floor(l / 2) - 1 : Math.ceil(l / 2)); | |
| const d = new OffscreenCanvas(a, l); | |
| d.getContext("2d").drawImage(c, 0, 0, h, u, 0, 0, a, l), c = d.transferToImageBitmap(); | |
| } | |
| return c; | |
| }, yp = function() { | |
| const [e, s] = this.parentDimensions, { | |
| width: i, | |
| height: r | |
| } = this, a = new ff(), l = Math.ceil(i * e * a.sx), c = Math.ceil(r * s * a.sy), h = o(this, oi); | |
| if (!h || h.width === l && h.height === c) | |
| return; | |
| h.width = l, h.height = c; | |
| const u = o(this, ts) ? o(this, Lt) : v(this, pt, bu).call(this, l, c), d = h.getContext("2d"); | |
| d.filter = this._uiManager.hcmFilter, d.drawImage(u, 0, 0, u.width, u.height, 0, 0, l, c); | |
| }, vu = function(e) { | |
| if (e) { | |
| if (o(this, ts)) { | |
| const r = this._uiManager.imageManager.getSvgUrl(o(this, fe)); | |
| if (r) | |
| return r; | |
| } | |
| const s = document.createElement("canvas"); | |
| return { | |
| width: s.width, | |
| height: s.height | |
| } = o(this, Lt), s.getContext("2d").drawImage(o(this, Lt), 0, 0), s.toDataURL(); | |
| } | |
| if (o(this, ts)) { | |
| const [s, i] = this.pageDimensions, r = Math.round(this.width * s * Hn.PDF_TO_CSS_UNITS), a = Math.round(this.height * i * Hn.PDF_TO_CSS_UNITS), l = new OffscreenCanvas(r, a); | |
| return l.getContext("2d").drawImage(o(this, Lt), 0, 0, o(this, Lt).width, o(this, Lt).height, 0, 0, r, a), l.transferToImageBitmap(); | |
| } | |
| return structuredClone(o(this, Lt)); | |
| }, Mv = function(e) { | |
| var l; | |
| const { | |
| pageIndex: s, | |
| accessibilityData: { | |
| altText: i | |
| } | |
| } = this._initialData, r = e.pageIndex === s, a = (((l = e.accessibilityData) == null ? void 0 : l.alt) || "") === i; | |
| return { | |
| isSame: !this._hasBeenMoved && !this._hasBeenResized && r && a, | |
| isSameAltText: a | |
| }; | |
| }, G(Pl, "_type", "stamp"), G(Pl, "_editorType", et.STAMP); | |
| let gp = Pl; | |
| var na, Bo, ci, Pn, zi, gs, Mn, Ho, ra, Os, Vi, Ae, Gi, H, Nn, Nt, Nv, qs, vp, _p, _u; | |
| const ws = class ws { | |
| constructor({ | |
| uiManager: t, | |
| pageIndex: e, | |
| div: s, | |
| structTreeLayer: i, | |
| accessibilityManager: r, | |
| annotationLayer: a, | |
| drawLayer: l, | |
| textLayer: c, | |
| viewport: h, | |
| l10n: u | |
| }) { | |
| b(this, Nt); | |
| b(this, na); | |
| b(this, Bo, !1); | |
| b(this, ci, null); | |
| b(this, Pn, null); | |
| b(this, zi, null); | |
| b(this, gs, /* @__PURE__ */ new Map()); | |
| b(this, Mn, !1); | |
| b(this, Ho, !1); | |
| b(this, ra, !1); | |
| b(this, Os, null); | |
| b(this, Vi, null); | |
| b(this, Ae, null); | |
| b(this, Gi, null); | |
| b(this, H); | |
| const d = [...o(ws, Nn).values()]; | |
| if (!ws._initialized) { | |
| ws._initialized = !0; | |
| for (const f of d) | |
| f.initialize(u, t); | |
| } | |
| t.registerEditorTypes(d), p(this, H, t), this.pageIndex = e, this.div = s, p(this, na, r), p(this, ci, a), this.viewport = h, p(this, Ae, c), this.drawLayer = l, this._structTree = i, o(this, H).addLayer(this); | |
| } | |
| get isEmpty() { | |
| return o(this, gs).size === 0; | |
| } | |
| get isInvisible() { | |
| return this.isEmpty && o(this, H).getMode() === et.NONE; | |
| } | |
| updateToolbar(t) { | |
| o(this, H).updateToolbar(t); | |
| } | |
| updateMode(t = o(this, H).getMode()) { | |
| switch (v(this, Nt, _u).call(this), t) { | |
| case et.NONE: | |
| this.disableTextSelection(), this.togglePointerEvents(!1), this.toggleAnnotationLayerPointerEvents(!0), this.disableClick(); | |
| return; | |
| case et.INK: | |
| this.disableTextSelection(), this.togglePointerEvents(!0), this.enableClick(); | |
| break; | |
| case et.HIGHLIGHT: | |
| this.enableTextSelection(), this.togglePointerEvents(!1), this.disableClick(); | |
| break; | |
| default: | |
| this.disableTextSelection(), this.togglePointerEvents(!0), this.enableClick(); | |
| } | |
| this.toggleAnnotationLayerPointerEvents(!1); | |
| const { | |
| classList: e | |
| } = this.div; | |
| for (const s of o(ws, Nn).values()) | |
| e.toggle(`${s._type}Editing`, t === s._editorType); | |
| this.div.hidden = !1; | |
| } | |
| hasTextLayer(t) { | |
| var e; | |
| return t === ((e = o(this, Ae)) == null ? void 0 : e.div); | |
| } | |
| setEditingState(t) { | |
| o(this, H).setEditingState(t); | |
| } | |
| addCommands(t) { | |
| o(this, H).addCommands(t); | |
| } | |
| cleanUndoStack(t) { | |
| o(this, H).cleanUndoStack(t); | |
| } | |
| toggleDrawing(t = !1) { | |
| this.div.classList.toggle("drawing", !t); | |
| } | |
| togglePointerEvents(t = !1) { | |
| this.div.classList.toggle("disabled", !t); | |
| } | |
| toggleAnnotationLayerPointerEvents(t = !1) { | |
| var e; | |
| (e = o(this, ci)) == null || e.div.classList.toggle("disabled", !t); | |
| } | |
| async enable() { | |
| p(this, ra, !0), this.div.tabIndex = 0, this.togglePointerEvents(!0); | |
| const t = /* @__PURE__ */ new Set(); | |
| for (const s of o(this, gs).values()) | |
| s.enableEditing(), s.show(!0), s.annotationElementId && (o(this, H).removeChangedExistingAnnotation(s), t.add(s.annotationElementId)); | |
| if (!o(this, ci)) { | |
| p(this, ra, !1); | |
| return; | |
| } | |
| const e = o(this, ci).getEditableAnnotations(); | |
| for (const s of e) { | |
| if (s.hide(), o(this, H).isDeletedAnnotationElement(s.data.id) || t.has(s.data.id)) | |
| continue; | |
| const i = await this.deserialize(s); | |
| i && (this.addOrRebuild(i), i.enableEditing()); | |
| } | |
| p(this, ra, !1); | |
| } | |
| disable() { | |
| var i; | |
| p(this, Ho, !0), this.div.tabIndex = -1, this.togglePointerEvents(!1); | |
| const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(); | |
| for (const r of o(this, gs).values()) | |
| if (r.disableEditing(), !!r.annotationElementId) { | |
| if (r.serialize() !== null) { | |
| t.set(r.annotationElementId, r); | |
| continue; | |
| } else | |
| e.set(r.annotationElementId, r); | |
| (i = this.getEditableAnnotation(r.annotationElementId)) == null || i.show(), r.remove(); | |
| } | |
| if (o(this, ci)) { | |
| const r = o(this, ci).getEditableAnnotations(); | |
| for (const a of r) { | |
| const { | |
| id: l | |
| } = a.data; | |
| if (o(this, H).isDeletedAnnotationElement(l)) | |
| continue; | |
| let c = e.get(l); | |
| if (c) { | |
| c.resetAnnotationElement(a), c.show(!1), a.show(); | |
| continue; | |
| } | |
| c = t.get(l), c && (o(this, H).addChangedExistingAnnotation(c), c.renderAnnotationElement(a) && c.show(!1)), a.show(); | |
| } | |
| } | |
| v(this, Nt, _u).call(this), this.isEmpty && (this.div.hidden = !0); | |
| const { | |
| classList: s | |
| } = this.div; | |
| for (const r of o(ws, Nn).values()) | |
| s.remove(`${r._type}Editing`); | |
| this.disableTextSelection(), this.toggleAnnotationLayerPointerEvents(!0), p(this, Ho, !1); | |
| } | |
| getEditableAnnotation(t) { | |
| var e; | |
| return ((e = o(this, ci)) == null ? void 0 : e.getEditableAnnotation(t)) || null; | |
| } | |
| setActiveEditor(t) { | |
| o(this, H).getActive() !== t && o(this, H).setActiveEditor(t); | |
| } | |
| enableTextSelection() { | |
| var t; | |
| if (this.div.tabIndex = -1, (t = o(this, Ae)) != null && t.div && !o(this, Gi)) { | |
| p(this, Gi, new AbortController()); | |
| const e = o(this, H).combinedSignal(o(this, Gi)); | |
| o(this, Ae).div.addEventListener("pointerdown", v(this, Nt, Nv).bind(this), { | |
| signal: e | |
| }), o(this, Ae).div.classList.add("highlighting"); | |
| } | |
| } | |
| disableTextSelection() { | |
| var t; | |
| this.div.tabIndex = 0, (t = o(this, Ae)) != null && t.div && o(this, Gi) && (o(this, Gi).abort(), p(this, Gi, null), o(this, Ae).div.classList.remove("highlighting")); | |
| } | |
| enableClick() { | |
| if (o(this, Pn)) | |
| return; | |
| p(this, Pn, new AbortController()); | |
| const t = o(this, H).combinedSignal(o(this, Pn)); | |
| this.div.addEventListener("pointerdown", this.pointerdown.bind(this), { | |
| signal: t | |
| }); | |
| const e = this.pointerup.bind(this); | |
| this.div.addEventListener("pointerup", e, { | |
| signal: t | |
| }), this.div.addEventListener("pointercancel", e, { | |
| signal: t | |
| }); | |
| } | |
| disableClick() { | |
| var t; | |
| (t = o(this, Pn)) == null || t.abort(), p(this, Pn, null); | |
| } | |
| attach(t) { | |
| o(this, gs).set(t.id, t); | |
| const { | |
| annotationElementId: e | |
| } = t; | |
| e && o(this, H).isDeletedAnnotationElement(e) && o(this, H).removeDeletedAnnotationElement(t); | |
| } | |
| detach(t) { | |
| var e; | |
| o(this, gs).delete(t.id), (e = o(this, na)) == null || e.removePointerInTextLayer(t.contentDiv), !o(this, Ho) && t.annotationElementId && o(this, H).addDeletedAnnotationElement(t); | |
| } | |
| remove(t) { | |
| this.detach(t), o(this, H).removeEditor(t), t.div.remove(), t.isAttachedToDOM = !1; | |
| } | |
| changeParent(t) { | |
| var e; | |
| t.parent !== this && (t.parent && t.annotationElementId && (o(this, H).addDeletedAnnotationElement(t.annotationElementId), Ft.deleteAnnotationElement(t), t.annotationElementId = null), this.attach(t), (e = t.parent) == null || e.detach(t), t.setParent(this), t.div && t.isAttachedToDOM && (t.div.remove(), this.div.append(t.div))); | |
| } | |
| add(t) { | |
| if (!(t.parent === this && t.isAttachedToDOM)) { | |
| if (this.changeParent(t), o(this, H).addEditor(t), this.attach(t), !t.isAttachedToDOM) { | |
| const e = t.render(); | |
| this.div.append(e), t.isAttachedToDOM = !0; | |
| } | |
| t.fixAndSetPosition(), t.onceAdded(!o(this, ra)), o(this, H).addToAnnotationStorage(t), t._reportTelemetry(t.telemetryInitialData); | |
| } | |
| } | |
| moveEditorInDOM(t) { | |
| var s; | |
| if (!t.isAttachedToDOM) | |
| return; | |
| const { | |
| activeElement: e | |
| } = document; | |
| t.div.contains(e) && !o(this, zi) && (t._focusEventsAllowed = !1, p(this, zi, setTimeout(() => { | |
| p(this, zi, null), t.div.contains(document.activeElement) ? t._focusEventsAllowed = !0 : (t.div.addEventListener("focusin", () => { | |
| t._focusEventsAllowed = !0; | |
| }, { | |
| once: !0, | |
| signal: o(this, H)._signal | |
| }), e.focus()); | |
| }, 0))), t._structTreeParentId = (s = o(this, na)) == null ? void 0 : s.moveElementInDOM(this.div, t.div, t.contentDiv, !0); | |
| } | |
| addOrRebuild(t) { | |
| t.needsToBeRebuilt() ? (t.parent || (t.parent = this), t.rebuild(), t.show()) : this.add(t); | |
| } | |
| addUndoableEditor(t) { | |
| const e = () => t._uiManager.rebuild(t), s = () => { | |
| t.remove(); | |
| }; | |
| this.addCommands({ | |
| cmd: e, | |
| undo: s, | |
| mustExec: !1 | |
| }); | |
| } | |
| getNextId() { | |
| return o(this, H).getId(); | |
| } | |
| combinedSignal(t) { | |
| return o(this, H).combinedSignal(t); | |
| } | |
| canCreateNewEmptyEditor() { | |
| var t; | |
| return (t = o(this, Nt, qs)) == null ? void 0 : t.canCreateNewEmptyEditor(); | |
| } | |
| pasteEditor(t, e) { | |
| o(this, H).updateToolbar(t), o(this, H).updateMode(t); | |
| const { | |
| offsetX: s, | |
| offsetY: i | |
| } = v(this, Nt, _p).call(this), r = this.getNextId(), a = v(this, Nt, vp).call(this, { | |
| parent: this, | |
| id: r, | |
| x: s, | |
| y: i, | |
| uiManager: o(this, H), | |
| isCentered: !0, | |
| ...e | |
| }); | |
| a && this.add(a); | |
| } | |
| async deserialize(t) { | |
| var e; | |
| return await ((e = o(ws, Nn).get(t.annotationType ?? t.annotationEditorType)) == null ? void 0 : e.deserialize(t, this, o(this, H))) || null; | |
| } | |
| createAndAddNewEditor(t, e, s = {}) { | |
| const i = this.getNextId(), r = v(this, Nt, vp).call(this, { | |
| parent: this, | |
| id: i, | |
| x: t.offsetX, | |
| y: t.offsetY, | |
| uiManager: o(this, H), | |
| isCentered: e, | |
| ...s | |
| }); | |
| return r && this.add(r), r; | |
| } | |
| addNewEditor() { | |
| this.createAndAddNewEditor(v(this, Nt, _p).call(this), !0); | |
| } | |
| setSelected(t) { | |
| o(this, H).setSelected(t); | |
| } | |
| toggleSelected(t) { | |
| o(this, H).toggleSelected(t); | |
| } | |
| unselect(t) { | |
| o(this, H).unselect(t); | |
| } | |
| pointerup(t) { | |
| var s; | |
| const { | |
| isMac: e | |
| } = Me.platform; | |
| if (!(t.button !== 0 || t.ctrlKey && e) && t.target === this.div && o(this, Mn) && (p(this, Mn, !1), !((s = o(this, Nt, qs)) != null && s.isDrawer && o(this, Nt, qs).supportMultipleDrawings))) { | |
| if (!o(this, Bo)) { | |
| p(this, Bo, !0); | |
| return; | |
| } | |
| if (o(this, H).getMode() === et.STAMP) { | |
| o(this, H).unselectAll(); | |
| return; | |
| } | |
| this.createAndAddNewEditor(t, !1); | |
| } | |
| } | |
| pointerdown(t) { | |
| var i; | |
| if (o(this, H).getMode() === et.HIGHLIGHT && this.enableTextSelection(), o(this, Mn)) { | |
| p(this, Mn, !1); | |
| return; | |
| } | |
| const { | |
| isMac: e | |
| } = Me.platform; | |
| if (t.button !== 0 || t.ctrlKey && e || t.target !== this.div) | |
| return; | |
| if (p(this, Mn, !0), (i = o(this, Nt, qs)) != null && i.isDrawer) { | |
| this.startDrawingSession(t); | |
| return; | |
| } | |
| const s = o(this, H).getActive(); | |
| p(this, Bo, !s || s.isEmpty()); | |
| } | |
| startDrawingSession(t) { | |
| if (this.div.focus(), o(this, Os)) { | |
| o(this, Nt, qs).startDrawing(this, o(this, H), !1, t); | |
| return; | |
| } | |
| o(this, H).setCurrentDrawingSession(this), p(this, Os, new AbortController()); | |
| const e = o(this, H).combinedSignal(o(this, Os)); | |
| this.div.addEventListener("blur", ({ | |
| relatedTarget: s | |
| }) => { | |
| s && !this.div.contains(s) && (p(this, Vi, null), this.commitOrRemove()); | |
| }, { | |
| signal: e | |
| }), o(this, Nt, qs).startDrawing(this, o(this, H), !1, t); | |
| } | |
| pause(t) { | |
| if (t) { | |
| const { | |
| activeElement: e | |
| } = document; | |
| this.div.contains(e) && p(this, Vi, e); | |
| return; | |
| } | |
| o(this, Vi) && setTimeout(() => { | |
| var e; | |
| (e = o(this, Vi)) == null || e.focus(), p(this, Vi, null); | |
| }, 0); | |
| } | |
| endDrawingSession(t = !1) { | |
| return o(this, Os) ? (o(this, H).setCurrentDrawingSession(null), o(this, Os).abort(), p(this, Os, null), p(this, Vi, null), o(this, Nt, qs).endDrawing(t)) : null; | |
| } | |
| findNewParent(t, e, s) { | |
| const i = o(this, H).findParent(e, s); | |
| return i === null || i === this ? !1 : (i.changeParent(t), !0); | |
| } | |
| commitOrRemove() { | |
| return o(this, Os) ? (this.endDrawingSession(), !0) : !1; | |
| } | |
| onScaleChanging() { | |
| o(this, Os) && o(this, Nt, qs).onScaleChangingWhenDrawing(this); | |
| } | |
| destroy() { | |
| var t, e; | |
| this.commitOrRemove(), ((t = o(this, H).getActive()) == null ? void 0 : t.parent) === this && (o(this, H).commitOrRemove(), o(this, H).setActiveEditor(null)), o(this, zi) && (clearTimeout(o(this, zi)), p(this, zi, null)); | |
| for (const s of o(this, gs).values()) | |
| (e = o(this, na)) == null || e.removePointerInTextLayer(s.contentDiv), s.setParent(null), s.isAttachedToDOM = !1, s.div.remove(); | |
| this.div = null, o(this, gs).clear(), o(this, H).removeLayer(this); | |
| } | |
| render({ | |
| viewport: t | |
| }) { | |
| this.viewport = t, fa(this.div, t); | |
| for (const e of o(this, H).getEditors(this.pageIndex)) | |
| this.add(e), e.rebuild(); | |
| this.updateMode(); | |
| } | |
| update({ | |
| viewport: t | |
| }) { | |
| o(this, H).commitOrRemove(), v(this, Nt, _u).call(this); | |
| const e = this.viewport.rotation, s = t.rotation; | |
| if (this.viewport = t, fa(this.div, { | |
| rotation: s | |
| }), e !== s) | |
| for (const i of o(this, gs).values()) | |
| i.rotate(s); | |
| } | |
| get pageDimensions() { | |
| const { | |
| pageWidth: t, | |
| pageHeight: e | |
| } = this.viewport.rawDims; | |
| return [t, e]; | |
| } | |
| get scale() { | |
| return o(this, H).viewParameters.realScale; | |
| } | |
| }; | |
| na = new WeakMap(), Bo = new WeakMap(), ci = new WeakMap(), Pn = new WeakMap(), zi = new WeakMap(), gs = new WeakMap(), Mn = new WeakMap(), Ho = new WeakMap(), ra = new WeakMap(), Os = new WeakMap(), Vi = new WeakMap(), Ae = new WeakMap(), Gi = new WeakMap(), H = new WeakMap(), Nn = new WeakMap(), Nt = new WeakSet(), Nv = function(t) { | |
| o(this, H).unselectAll(); | |
| const { | |
| target: e | |
| } = t; | |
| if (e === o(this, Ae).div || (e.getAttribute("role") === "img" || e.classList.contains("endOfContent")) && o(this, Ae).div.contains(e)) { | |
| const { | |
| isMac: s | |
| } = Me.platform; | |
| if (t.button !== 0 || t.ctrlKey && s) | |
| return; | |
| o(this, H).showAllEditors("highlight", !0, !0), o(this, Ae).div.classList.add("free"), this.toggleDrawing(), Vu.startHighlighting(this, o(this, H).direction === "ltr", { | |
| target: o(this, Ae).div, | |
| x: t.x, | |
| y: t.y | |
| }), o(this, Ae).div.addEventListener("pointerup", () => { | |
| o(this, Ae).div.classList.remove("free"), this.toggleDrawing(!0); | |
| }, { | |
| once: !0, | |
| signal: o(this, H)._signal | |
| }), t.preventDefault(); | |
| } | |
| }, qs = function() { | |
| return o(ws, Nn).get(o(this, H).getMode()); | |
| }, vp = function(t) { | |
| const e = o(this, Nt, qs); | |
| return e ? new e.prototype.constructor(t) : null; | |
| }, _p = function() { | |
| const { | |
| x: t, | |
| y: e, | |
| width: s, | |
| height: i | |
| } = this.div.getBoundingClientRect(), r = Math.max(0, t), a = Math.max(0, e), l = Math.min(window.innerWidth, t + s), c = Math.min(window.innerHeight, e + i), h = (r + l) / 2 - t, u = (a + c) / 2 - e, [d, f] = this.viewport.rotation % 180 === 0 ? [h, u] : [u, h]; | |
| return { | |
| offsetX: d, | |
| offsetY: f | |
| }; | |
| }, _u = function() { | |
| for (const t of o(this, gs).values()) | |
| t.isEmpty() && t.remove(); | |
| }, G(ws, "_initialized", !1), b(ws, Nn, new Map([Qf, pp, gp, Vu].map((t) => [t._editorType, t]))); | |
| let bp = ws; | |
| var Ls, Rh, Pe, aa, ud, Ov, fi, wp, Lv, Sp; | |
| const ye = class ye { | |
| constructor({ | |
| pageIndex: t | |
| }) { | |
| b(this, fi); | |
| b(this, Ls, null); | |
| b(this, Rh, 0); | |
| b(this, Pe, /* @__PURE__ */ new Map()); | |
| b(this, aa, /* @__PURE__ */ new Map()); | |
| this.pageIndex = t; | |
| } | |
| setParent(t) { | |
| if (!o(this, Ls)) { | |
| p(this, Ls, t); | |
| return; | |
| } | |
| if (o(this, Ls) !== t) { | |
| if (o(this, Pe).size > 0) | |
| for (const e of o(this, Pe).values()) | |
| e.remove(), t.append(e); | |
| p(this, Ls, t); | |
| } | |
| } | |
| static get _svgFactory() { | |
| return at(this, "_svgFactory", new Xp()); | |
| } | |
| draw(t, e = !1, s = !1) { | |
| const i = xe(this, Rh)._++, r = v(this, fi, wp).call(this), a = ye._svgFactory.createElement("defs"); | |
| r.append(a); | |
| const l = ye._svgFactory.createElement("path"); | |
| a.append(l); | |
| const c = `path_p${this.pageIndex}_${i}`; | |
| l.setAttribute("id", c), l.setAttribute("vector-effect", "non-scaling-stroke"), e && o(this, aa).set(i, l); | |
| const h = s ? v(this, fi, Lv).call(this, a, c) : null, u = ye._svgFactory.createElement("use"); | |
| return r.append(u), u.setAttribute("href", `#${c}`), this.updateProperties(r, t), o(this, Pe).set(i, r), { | |
| id: i, | |
| clipPathId: `url(#${h})` | |
| }; | |
| } | |
| drawOutline(t, e) { | |
| const s = xe(this, Rh)._++, i = v(this, fi, wp).call(this), r = ye._svgFactory.createElement("defs"); | |
| i.append(r); | |
| const a = ye._svgFactory.createElement("path"); | |
| r.append(a); | |
| const l = `path_p${this.pageIndex}_${s}`; | |
| a.setAttribute("id", l), a.setAttribute("vector-effect", "non-scaling-stroke"); | |
| let c; | |
| if (e) { | |
| const d = ye._svgFactory.createElement("mask"); | |
| r.append(d), c = `mask_p${this.pageIndex}_${s}`, d.setAttribute("id", c), d.setAttribute("maskUnits", "objectBoundingBox"); | |
| const f = ye._svgFactory.createElement("rect"); | |
| d.append(f), f.setAttribute("width", "1"), f.setAttribute("height", "1"), f.setAttribute("fill", "white"); | |
| const g = ye._svgFactory.createElement("use"); | |
| d.append(g), g.setAttribute("href", `#${l}`), g.setAttribute("stroke", "none"), g.setAttribute("fill", "black"), g.setAttribute("fill-rule", "nonzero"), g.classList.add("mask"); | |
| } | |
| const h = ye._svgFactory.createElement("use"); | |
| i.append(h), h.setAttribute("href", `#${l}`), c && h.setAttribute("mask", `url(#${c})`); | |
| const u = h.cloneNode(); | |
| return i.append(u), h.classList.add("mainOutline"), u.classList.add("secondaryOutline"), this.updateProperties(i, t), o(this, Pe).set(s, i), s; | |
| } | |
| finalizeDraw(t, e) { | |
| o(this, aa).delete(t), this.updateProperties(t, e); | |
| } | |
| updateProperties(t, e) { | |
| var c; | |
| if (!e) | |
| return; | |
| const { | |
| root: s, | |
| bbox: i, | |
| rootClass: r, | |
| path: a | |
| } = e, l = typeof t == "number" ? o(this, Pe).get(t) : t; | |
| if (l) { | |
| if (s && v(this, fi, Sp).call(this, l, s), i && v(c = ye, ud, Ov).call(c, l, i), r) { | |
| const { | |
| classList: h | |
| } = l; | |
| for (const [u, d] of Object.entries(r)) | |
| h.toggle(u, d); | |
| } | |
| if (a) { | |
| const u = l.firstChild.firstChild; | |
| v(this, fi, Sp).call(this, u, a); | |
| } | |
| } | |
| } | |
| updateParent(t, e) { | |
| if (e === this) | |
| return; | |
| const s = o(this, Pe).get(t); | |
| s && (o(e, Ls).append(s), o(this, Pe).delete(t), o(e, Pe).set(t, s)); | |
| } | |
| remove(t) { | |
| o(this, aa).delete(t), o(this, Ls) !== null && (o(this, Pe).get(t).remove(), o(this, Pe).delete(t)); | |
| } | |
| destroy() { | |
| p(this, Ls, null); | |
| for (const t of o(this, Pe).values()) | |
| t.remove(); | |
| o(this, Pe).clear(), o(this, aa).clear(); | |
| } | |
| }; | |
| Ls = new WeakMap(), Rh = new WeakMap(), Pe = new WeakMap(), aa = new WeakMap(), ud = new WeakSet(), Ov = function(t, [e, s, i, r]) { | |
| const { | |
| style: a | |
| } = t; | |
| a.top = `${100 * s}%`, a.left = `${100 * e}%`, a.width = `${100 * i}%`, a.height = `${100 * r}%`; | |
| }, fi = new WeakSet(), wp = function() { | |
| const t = ye._svgFactory.create(1, 1, !0); | |
| return o(this, Ls).append(t), t.setAttribute("aria-hidden", !0), t; | |
| }, Lv = function(t, e) { | |
| const s = ye._svgFactory.createElement("clipPath"); | |
| t.append(s); | |
| const i = `clip_${e}`; | |
| s.setAttribute("id", i), s.setAttribute("clipPathUnits", "objectBoundingBox"); | |
| const r = ye._svgFactory.createElement("use"); | |
| return s.append(r), r.setAttribute("href", `#${e}`), r.classList.add("clip"), i; | |
| }, Sp = function(t, e) { | |
| for (const [s, i] of Object.entries(e)) | |
| i === null ? t.removeAttribute(s) : t.setAttribute(s, i); | |
| }, b(ye, ud); | |
| let Ap = ye; | |
| globalThis.pdfjsTestingUtils = { | |
| HighlightOutliner: ep | |
| }; | |
| X.AbortException; | |
| X.AnnotationEditorLayer; | |
| X.AnnotationEditorParamsType; | |
| X.AnnotationEditorType; | |
| X.AnnotationEditorUIManager; | |
| X.AnnotationLayer; | |
| X.AnnotationMode; | |
| X.ColorPicker; | |
| X.DOMSVGFactory; | |
| X.DrawLayer; | |
| X.FeatureTest; | |
| var AT = X.GlobalWorkerOptions; | |
| X.ImageKind; | |
| X.InvalidPDFException; | |
| X.MissingPDFException; | |
| X.OPS; | |
| X.OutputScale; | |
| X.PDFDataRangeTransport; | |
| X.PDFDateString; | |
| X.PDFWorker; | |
| X.PasswordResponses; | |
| X.PermissionFlag; | |
| X.PixelsPerInch; | |
| X.RenderingCancelledException; | |
| X.TextLayer; | |
| X.TouchManager; | |
| X.UnexpectedResponseException; | |
| X.Util; | |
| X.VerbosityLevel; | |
| X.XfaLayer; | |
| X.build; | |
| X.createValidAbsoluteUrl; | |
| X.fetchData; | |
| var wT = X.getDocument; | |
| X.getFilenameFromUrl; | |
| X.getPdfFilenameFromUrl; | |
| X.getXfaPageViewport; | |
| X.isDataScheme; | |
| X.isPdfFile; | |
| X.noContextMenu; | |
| X.normalizeUnicode; | |
| X.setLayerDimensions; | |
| X.shadow; | |
| X.stopEvent; | |
| X.version; | |
| function ST(n) { | |
| return new Worker( | |
| "/assets/pdf.worker-BcRfCWcj.js", | |
| { | |
| name: n == null ? void 0 : n.name | |
| } | |
| ); | |
| } | |
| const ET = w.object({ | |
| fullName: w.string(), | |
| email: w.string().email(), | |
| phone: w.string(), | |
| location: w.object({ | |
| city: w.string(), | |
| country: w.string(), | |
| postalCode: w.string().optional() | |
| }), | |
| socialProfiles: w.object({ | |
| linkedin: w.string().url().optional(), | |
| github: w.string().url().optional(), | |
| personalWebsite: w.string().url().optional() | |
| }).optional() | |
| }), xT = w.object({ | |
| institution: w.string(), | |
| degree: w.string(), | |
| fieldOfStudy: w.string(), | |
| startDate: w.string(), | |
| endDate: w.string().optional(), | |
| gpa: w.any().optional(), | |
| honors: w.array(w.string()).optional() | |
| }), TT = w.object({ | |
| company: w.string(), | |
| position: w.string(), | |
| startDate: w.string(), | |
| endDate: w.string().optional(), | |
| isCurrentRole: w.boolean(), | |
| responsibilities: w.array(w.string()), | |
| achievements: w.array(w.string()).optional(), | |
| technologies: w.array(w.string()).optional() | |
| }), CT = w.object({ | |
| category: w.string(), | |
| skills: w.array(w.string()) | |
| }), kT = w.object({ | |
| contactInfo: ET, | |
| summary: w.string(), | |
| education: w.array(xT), | |
| workExperience: w.array(TT), | |
| skills: w.array(CT), | |
| languages: w.array( | |
| w.object({ | |
| language: w.string(), | |
| proficiency: w.enum(["Native", "Fluent", "Intermediate", "Basic"]) | |
| }) | |
| ).optional(), | |
| certifications: w.array( | |
| w.object({ | |
| name: w.string(), | |
| issuingOrganization: w.string(), | |
| date: w.string() | |
| }) | |
| ).optional(), | |
| projects: w.array( | |
| w.object({ | |
| name: w.string(), | |
| description: w.string(), | |
| technologies: w.array(w.string()), | |
| link: w.string().url().optional() | |
| }) | |
| ).optional() | |
| }); | |
| var IT = Object.defineProperty, RT = Object.getOwnPropertyDescriptor, Dv = (n, t, e, s) => { | |
| for (var i = s > 1 ? void 0 : s ? RT(t, e) : t, r = n.length - 1, a; r >= 0; r--) | |
| (a = n[r]) && (i = (s ? a(t, e, i) : a(i)) || i); | |
| return s && i && IT(t, e, i), i; | |
| }; | |
| AT.workerPort = new ST(); | |
| let qu = class extends kl { | |
| constructor() { | |
| super(...arguments), this.label = "Upload your CV"; | |
| } | |
| render() { | |
| return Jv` <button @click="${this._onClick}">${this.label}</button> `; | |
| } | |
| _onClick() { | |
| const n = document.createElement("input"); | |
| n.type = "file", n.accept = "application/pdf", n.multiple = !0, n.style.display = "none", n.addEventListener("change", async () => { | |
| const t = await new Promise((s) => { | |
| const i = Array.from(n.files || []).filter( | |
| (r) => r.type === "application/pdf" | |
| ); | |
| s(i); | |
| }), e = []; | |
| for (const s of t) { | |
| const i = [], r = await s.arrayBuffer(), a = await wT(r).promise, l = a.numPages; | |
| for (let c = 1; c <= l; c++) { | |
| const d = (await (await a.getPage(c)).getTextContent()).items.map((f) => f.hasEOL ? ` | |
| ` : f.str).join(""); | |
| i.push(d); | |
| } | |
| e.push({ | |
| filename: s.name, | |
| content: i.join(` | |
| `), | |
| parsed: await PT(i.join(` | |
| `)) | |
| }); | |
| } | |
| this.dispatchEvent( | |
| new CustomEvent("cv-parsed", { | |
| detail: e | |
| }) | |
| ); | |
| }), n.click(); | |
| } | |
| }; | |
| qu.styles = Bv``; | |
| Dv([ | |
| c_() | |
| ], qu.prototype, "label", 2); | |
| qu = Dv([ | |
| a_("succefy-cv-button") | |
| ], qu); | |
| async function PT(n) { | |
| const t = Fy({ | |
| baseURL: "https://text.pollinations.ai/openai", | |
| apiKey: "pollinations" | |
| }); | |
| return await qS({ | |
| model: t("gpt-4o-mini"), | |
| prompt: `Using this CV information of the candidate give me a JSON object of the candidate's CV. | |
| ${n}`, | |
| schema: kT | |
| }); | |
| } | |
| export { | |
| qu as MyElement | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment