var Nt = Object.defineProperty; var Rt = (a, e, n) => e in a ? Nt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n; var F = (a, e, n) => Rt(a, typeof e != "symbol" ? e + "" : e, n); import { sortRules as xt, sortRulesByDesc as Bt, createIdentifier as Wt, CommandType as Gt, ImageSourceType as at, ImageUploadStatusType as Qe, Tools as Lt, Inject as qt, Injector as Kt, Plugin as Ft, merge as Vt, mergeOverrideWithDependencies as Ht, IConfigService as zt, ICommandService as Xt, IImageIoService as Jt } from "@univerjs/core"; import { IImageIoService as En, ImageSourceType as Dn, ImageUploadStatusType as Pn } from "@univerjs/core"; import { Subject as ve } from "rxjs"; const mn = 500, On = 500, wn = 10, Yt = 5 * 1024 * 1024, Zt = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"]; var Ye = {}, et = {}, tt = {}, mt; function Qt() { if (mt) return tt; mt = 1, Object.defineProperty(tt, "__esModule", { value: !0 }); function a(t, r) { if (Array.isArray(r)) return !1; for (let u in t) if (!n(t[u], r[u])) return !1; for (let u in r) if (t[u] === void 0) return !1; return !0; } function e(t, r) { if (!Array.isArray(r) || t.length !== r.length) return !1; for (let u = 0; u < t.length; u++) if (!n(t[u], r[u])) return !1; return !0; } function n(t, r) { return t === r ? !0 : t === null || r === null || typeof t != "object" || typeof r != "object" ? !1 : Array.isArray(t) ? e(t, r) : a(t, r); } return tt.default = n, tt; } var nt = {}, Ot; function en() { if (Ot) return nt; Ot = 1, Object.defineProperty(nt, "__esModule", { value: !0 }); function a(e) { if (e === null) return null; if (Array.isArray(e)) return e.map(a); if (typeof e == "object") { const n = {}; for (let t in e) n[t] = a(e[t]); return n; } else return e; } return nt.default = a, nt; } var lt = {}, wt; function Mt() { return wt || (wt = 1, function(a) { Object.defineProperty(a, "__esModule", { value: !0 }), a.eachChildOf = a.advancer = a.readCursor = a.writeCursor = a.WriteCursor = a.ReadCursor = a.isValidPathItem = void 0; function e(_, s) { if (!_) throw new Error(s); } const n = (_) => _ != null && typeof _ == "object" && !Array.isArray(_), t = (_, s) => ( // All the numbers, then all the letters. Just as the gods of ascii intended. typeof _ == typeof s ? _ > s : typeof _ == "string" && typeof s == "number" ); function r(_, s) { for (let d in _) { const h = d; s.write(h, _[h]); } } a.isValidPathItem = (_) => typeof _ == "number" || typeof _ == "string" && _ !== "__proto__"; class u { constructor(s = null) { this.parents = [], this.indexes = [], this.lcIdx = -1, this.idx = -1, this.container = s; } ascend() { e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--, n(this.container[this.idx]) && this.idx--); } getPath() { const s = []; let d = this.container, h = this.parents.length - 1, k = this.idx; for (; k >= 0; ) s.unshift(d[k]), k === 0 ? (k = this.indexes[h * 2], d = this.parents[h--]) : k -= n(d[k - 1]) ? 2 : 1; return s; } } class o extends u { get() { return this.container ? this.container.slice(this.idx + 1) : null; } // Its only valid to call this after descending into a child. getKey() { return e(this.container != null, "Invalid call to getKey before cursor descended"), this.container[this.idx]; } getComponent() { let s; return this.container && this.container.length > this.idx + 1 && n(s = this.container[this.idx + 1]) ? s : null; } descendFirst() { let s = this.idx + 1; if (!this.container || s >= this.container.length || n(this.container[s]) && s + 1 >= this.container.length) return !1; n(this.container[s]) && s++; const d = this.container[s]; return Array.isArray(d) ? (this.indexes.push(this.idx), this.parents.push(this.container), this.indexes.push(s), this.idx = 0, this.container = d) : this.idx = s, !0; } nextSibling() { if (e(this.parents.length === this.indexes.length / 2), this.idx > 0 || this.parents.length === 0) return !1; const s = this.indexes[this.indexes.length - 1] + 1, d = this.parents[this.parents.length - 1]; return s >= d.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = d[s], !0); } _init(s, d, h, k) { this.container = s, this.idx = d, this.parents = h.slice(), this.indexes = k.slice(); } clone() { const s = new o(); return s._init(this.container, this.idx, this.parents, this.indexes), s; } *[Symbol.iterator]() { if (this.descendFirst()) { do yield this.getKey(); while (this.nextSibling()); this.ascend(); } } // TODO(cleanup): Consider moving these functions out of cursor, since // they're really just helper methods. // It'd be really nice to do this using generators. traverse(s, d) { const h = this.getComponent(); h && d(h, s); for (const k of this) s && s.descend(k), this.traverse(s, d), s && s.ascend(); } eachPick(s, d) { this.traverse(s, (h, k) => { h.p != null && d(h.p, k); }); } eachDrop(s, d) { this.traverse(s, (h, k) => { h.d != null && d(h.d, k); }); } } a.ReadCursor = o; class l extends u { constructor(s = null) { super(s), this.pendingDescent = [], this._op = s; } flushDescent() { e(this.parents.length === this.indexes.length / 2), this.container === null && (this._op = this.container = []); for (let s = 0; s < this.pendingDescent.length; s++) { const d = this.pendingDescent[s]; let h = this.idx + 1; if (h < this.container.length && n(this.container[h]) && h++, e(h === this.container.length || !n(this.container[h])), h === this.container.length) this.container.push(d), this.idx = h; else if (this.container[h] === d) this.idx = h; else { if (!Array.isArray(this.container[h])) { const k = this.container.splice(h, this.container.length - h); this.container.push(k), this.lcIdx > -1 && (this.lcIdx = h); } for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(t(d, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && t(d, this.container[h][0]); ) h++; if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === d) this.container = this.container[h]; else { const k = [d]; this.container.splice(h, 0, k), this.container = k; } } } this.pendingDescent.length = 0; } reset() { this.lcIdx = -1; } // Creates and returns a component, creating one if need be. You should // probably write to it immediately - ops are not valid with empty // components. getComponent() { this.flushDescent(); const s = this.idx + 1; if (s < this.container.length && n(this.container[s])) return this.container[s]; { const d = {}; return this.container.splice(s, 0, d), d; } } write(s, d) { const h = this.getComponent(); e(h[s] == null || h[s] === d, "Internal consistency error: Overwritten component. File a bug"), h[s] = d; } get() { return this._op; } descend(s) { if (!a.isValidPathItem(s)) throw Error("Invalid JSON key"); this.pendingDescent.push(s); } descendPath(s) { return this.pendingDescent.push(...s), this; } ascend() { this.pendingDescent.length ? this.pendingDescent.pop() : super.ascend(); } mergeTree(s, d = r) { if (s === null) return; if (e(Array.isArray(s)), s === this._op) throw Error("Cannot merge into my own tree"); const h = this.lcIdx, k = this.parents.length; let Y = 0; for (let pe = 0; pe < s.length; pe++) { const Z = s[pe]; typeof Z == "string" || typeof Z == "number" ? (Y++, this.descend(Z)) : Array.isArray(Z) ? this.mergeTree(Z, d) : typeof Z == "object" && d(Z, this); } for (; Y--; ) this.ascend(); this.lcIdx = this.parents.length === k ? h : -1; } at(s, d) { this.descendPath(s), d(this); for (let h = 0; h < s.length; h++) this.ascend(); return this; } // This is used by helpers, so the strict ordering guarantees are // relaxed. writeAtPath(s, d, h) { return this.at(s, () => this.write(d, h)), this.reset(), this; } writeMove(s, d, h = 0) { return this.writeAtPath(s, "p", h).writeAtPath(d, "d", h); } getPath() { const s = super.getPath(); return s.push(...this.pendingDescent), s; } } a.WriteCursor = l, a.writeCursor = () => new l(), a.readCursor = (_) => new o(_); function E(_, s, d) { let h, k; k = h = _ ? _.descendFirst() : !1; function Y(pe) { let Z; for (; k; ) { const Ce = Z = _.getKey(); if (pe != null) { let Ge = !1; if (s && typeof Ce == "number" && (Z = s(Ce, _.getComponent()), Z < 0 && (Z = ~Z, Ge = !0)), t(Z, pe)) return null; if (Z === pe && !Ge) return _; } d && typeof Z == "number" && d(Z, _.getComponent()), k = _.nextSibling(); } return null; } return Y.end = () => { h && _.ascend(); }, Y; } a.advancer = E; function x(_, s, d) { let h, k, Y, pe; for (h = k = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) { let Z = h ? _.getKey() : null, Ce = Y ? s.getKey() : null; Z !== null && Ce !== null && (t(Ce, Z) ? Ce = null : Z !== Ce && (Z = null)), d(Z == null ? Ce : Z, Z != null ? _ : null, Ce != null ? s : null), Z != null && h && (h = _.nextSibling()), Ce != null && Y && (Y = s.nextSibling()); } k && _.ascend(), pe && s.ascend(); } a.eachChildOf = x; }(lt)), lt; } var ut = {}, bt; function St() { return bt || (bt = 1, function(a) { Object.defineProperty(a, "__esModule", { value: !0 }), a.ConflictType = void 0, function(e) { e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE"; }(a.ConflictType || (a.ConflictType = {})); }(ut)), ut; } var Fe = {}, Ve = {}, vt; function pt() { return vt || (vt = 1, Object.defineProperty(Ve, "__esModule", { value: !0 }), Ve.uniToStrPos = Ve.strPosToUni = void 0, Ve.strPosToUni = (a, e = a.length) => { let n = 0, t = 0; for (; t < e; t++) { const r = a.charCodeAt(t); r >= 55296 && r <= 57343 && (n++, t++); } if (t !== e) throw Error("Invalid offset - splits unicode bytes"); return t - n; }, Ve.uniToStrPos = (a, e) => { let n = 0; for (; e > 0; e--) { const t = a.charCodeAt(n); n += t >= 55296 && t <= 57343 ? 2 : 1; } return n; }), Ve; } var dt = {}, Ct; function ht() { return Ct || (Ct = 1, function(a) { Object.defineProperty(a, "__esModule", { value: !0 }), a.uniSlice = a.dlen = a.eachOp = void 0; const e = pt(), n = (f) => { if (!Array.isArray(f)) throw Error("Op must be an array of components"); let y = null; for (let v = 0; v < f.length; v++) { const L = f[v]; switch (typeof L) { case "object": if (typeof L.d != "number" && typeof L.d != "string") throw Error("Delete must be number or string"); if (a.dlen(L.d) <= 0) throw Error("Deletes must not be empty"); break; case "string": if (!(L.length > 0)) throw Error("Inserts cannot be empty"); break; case "number": if (!(L > 0)) throw Error("Skip components must be >0"); if (typeof y == "number") throw Error("Adjacent skip components should be combined"); break; } y = L; } if (typeof y == "number") throw Error("Op has a trailing skip"); }; function t(f, y) { let v = 0, L = 0; for (let z = 0; z < f.length; z++) { const q = f[z]; switch (y(q, v, L), typeof q) { case "object": v += a.dlen(q.d); break; case "string": L += e.strPosToUni(q); break; case "number": v += q, L += q; break; } } } a.eachOp = t; function r(f, y) { const v = [], L = l(v); return t(f, (z, q, Ee) => { L(y(z, q, Ee)); }), s(v); } const u = (f) => f, o = (f) => r(f, u); a.dlen = (f) => typeof f == "number" ? f : e.strPosToUni(f); const l = (f) => (y) => { if (!(!y || y.d === 0 || y.d === "")) if (f.length === 0) f.push(y); else if (typeof y == typeof f[f.length - 1]) if (typeof y == "object") { const v = f[f.length - 1]; v.d = typeof v.d == "string" && typeof y.d == "string" ? v.d + y.d : a.dlen(v.d) + a.dlen(y.d); } else f[f.length - 1] += y; else f.push(y); }, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d); a.uniSlice = (f, y, v) => { const L = e.uniToStrPos(f, y), z = v == null ? 1 / 0 : e.uniToStrPos(f, v); return f.slice(L, z); }; const x = (f, y, v) => typeof f == "number" ? v == null ? f - y : Math.min(f, v) - y : a.uniSlice(f, y, v), _ = (f) => { let y = 0, v = 0; return { take: (q, Ee) => { if (y === f.length) return q === -1 ? null : q; const de = f[y]; let ne; if (typeof de == "number") return q === -1 || de - v <= q ? (ne = de - v, ++y, v = 0, ne) : (v += q, q); if (typeof de == "string") { if (q === -1 || Ee === "i" || e.strPosToUni(de.slice(v)) <= q) return ne = de.slice(v), ++y, v = 0, ne; { const le = v + e.uniToStrPos(de.slice(v), q); return ne = de.slice(v, le), v = le, ne; } } else { if (q === -1 || Ee === "d" || a.dlen(de.d) - v <= q) return ne = { d: x(de.d, v) }, ++y, v = 0, ne; { let le = x(de.d, v, v + q); return v += q, { d: le }; } } }, peek: () => f[y] }; }, s = (f) => (f.length > 0 && typeof f[f.length - 1] == "number" && f.pop(), f); function d(f, y, v) { if (v !== "left" && v !== "right") throw Error("side (" + v + ") must be 'left' or 'right'"); n(f), n(y); const L = [], z = l(L), { take: q, peek: Ee } = _(f); for (let ne = 0; ne < y.length; ne++) { const le = y[ne]; let ge, De; switch (typeof le) { case "number": for (ge = le; ge > 0; ) De = q(ge, "i"), z(De), typeof De != "string" && (ge -= E(De)); break; case "string": v === "left" && typeof Ee() == "string" && z(q(-1)), z(e.strPosToUni(le)); break; case "object": for (ge = a.dlen(le.d); ge > 0; ) switch (De = q(ge, "i"), typeof De) { case "number": ge -= De; break; case "string": z(De); break; case "object": ge -= a.dlen(De.d); } break; } } let de; for (; de = q(-1); ) z(de); return s(L); } function h(f, y) { n(f), n(y); const v = [], L = l(v), { take: z } = _(f); for (let Ee = 0; Ee < y.length; Ee++) { const de = y[Ee]; let ne, le; switch (typeof de) { case "number": for (ne = de; ne > 0; ) le = z(ne, "d"), L(le), typeof le != "object" && (ne -= E(le)); break; case "string": L(de); break; case "object": ne = a.dlen(de.d); let ge = 0; for (; ge < ne; ) switch (le = z(ne - ge, "d"), typeof le) { case "number": L({ d: x(de.d, ge, ge + le) }), ge += le; break; case "string": ge += e.strPosToUni(le); break; case "object": L(le); } break; } } let q; for (; q = z(-1); ) L(q); return s(v); } const k = (f, y) => { let v = 0; for (let L = 0; L < y.length && f > v; L++) { const z = y[L]; switch (typeof z) { case "number": { v += z; break; } case "string": const q = e.strPosToUni(z); v += q, f += q; break; case "object": f -= Math.min(a.dlen(z.d), f - v); break; } } return f; }, Y = (f, y) => typeof f == "number" ? k(f, y) : f.map((v) => k(v, y)); function pe(f, y, v) { return r(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: v.slice(y, z, z + L.d) } : L); } function Z(f) { return r(f, (y) => { switch (typeof y) { case "object": if (typeof y.d == "number") throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first."); return y.d; // delete -> insert case "string": return { d: y }; // Insert -> delete case "number": return y; } }); } function Ce(f) { return r(f, (y) => typeof y == "object" && typeof y.d == "string" ? { d: e.strPosToUni(y.d) } : y); } function Ge(f) { let y = !0; return t(f, (v) => { typeof v == "object" && typeof v.d == "number" && (y = !1); }), y; } function me(f) { return { name: "text-unicode", uri: "http://sharejs.org/types/text-unicode", trim: s, normalize: o, checkOp: n, /** Create a new text snapshot. * * @param {string} initial - initial snapshot data. Optional. Defaults to ''. * @returns {Snap} Initial document snapshot object */ create(y = "") { if (typeof y != "string") throw Error("Initial data must be a string"); return f.create(y); }, /** Apply an operation to a document snapshot */ apply(y, v) { n(v); const L = f.builder(y); for (let z = 0; z < v.length; z++) { const q = v[z]; switch (typeof q) { case "number": L.skip(q); break; case "string": L.append(q); break; case "object": L.del(a.dlen(q.d)); break; } } return L.build(); }, transform: d, compose: h, transformPosition: k, transformSelection: Y, isInvertible: Ge, makeInvertible(y, v) { return pe(y, v, f); }, stripInvertible: Ce, invert: Z, invertWithDoc(y, v) { return Z(pe(y, v, f)); }, isNoop: (y) => y.length === 0 }; } a.default = me; }(dt)), dt; } var rt = {}, It; function tn() { if (It) return rt; It = 1, Object.defineProperty(rt, "__esModule", { value: !0 }); const a = ht(), e = pt(); function n(t, r) { return { // Returns the text content of the document get: t, // Returns the number of characters in the string getLength() { return t().length; }, // Insert the specified text at the given position in the document insert(u, o, l) { const E = e.strPosToUni(t(), u); return r([E, o], l); }, remove(u, o, l) { const E = e.strPosToUni(t(), u); return r([E, { d: o }], l); }, // When you use this API, you should implement these two methods // in your editing context. //onInsert: function(pos, text) {}, //onRemove: function(pos, removedLength) {}, _onOp(u) { a.eachOp(u, (o, l, E) => { switch (typeof o) { case "string": this.onInsert && this.onInsert(E, o); break; case "object": const x = a.dlen(o.d); this.onRemove && this.onRemove(E, x); } }); }, onInsert: null, onRemove: null }; } return rt.default = n, n.provides = { text: !0 }, rt; } var Et; function nn() { return Et || (Et = 1, function(a) { var e = Fe.__createBinding || (Object.create ? function(d, h, k, Y) { Y === void 0 && (Y = k), Object.defineProperty(d, Y, { enumerable: !0, get: function() { return h[k]; } }); } : function(d, h, k, Y) { Y === void 0 && (Y = k), d[Y] = h[k]; }), n = Fe.__setModuleDefault || (Object.create ? function(d, h) { Object.defineProperty(d, "default", { enumerable: !0, value: h }); } : function(d, h) { d.default = h; }), t = Fe.__importStar || function(d) { if (d && d.__esModule) return d; var h = {}; if (d != null) for (var k in d) Object.hasOwnProperty.call(d, k) && e(h, d, k); return n(h, d), h; }, r = Fe.__importDefault || function(d) { return d && d.__esModule ? d : { default: d }; }; Object.defineProperty(a, "__esModule", { value: !0 }), a.type = a.remove = a.insert = void 0; const u = pt(), o = t(ht()), l = r(tn()), E = { create(d) { return d; }, toString(d) { return d; }, builder(d) { if (typeof d != "string") throw Error("Invalid document snapshot: " + d); const h = []; return { skip(k) { let Y = u.uniToStrPos(d, k); if (Y > d.length) throw Error("The op is too long for this document"); h.push(d.slice(0, Y)), d = d.slice(Y); }, append(k) { h.push(k); }, del(k) { d = d.slice(u.uniToStrPos(d, k)); }, build() { return h.join("") + d; } }; }, slice: o.uniSlice }, x = o.default(E), _ = Object.assign(Object.assign({}, x), { api: l.default }); a.type = _, a.insert = (d, h) => h.length === 0 ? [] : d === 0 ? [h] : [d, h], a.remove = (d, h) => o.dlen(h) === 0 ? [] : d === 0 ? [{ d: h }] : [d, { d: h }]; var s = ht(); Object.defineProperty(a, "makeType", { enumerable: !0, get: function() { return s.default; } }); }(Fe)), Fe; } var Dt; function rn() { return Dt || (Dt = 1, function(a) { var e = et.__importDefault || function(i) { return i && i.__esModule ? i : { default: i }; }; Object.defineProperty(a, "__esModule", { value: !0 }), a.editOp = a.replaceOp = a.insertOp = a.moveOp = a.removeOp = a.type = void 0; const n = e(Qt()), t = e(en()), r = Mt(), u = St(); function o(i, c) { if (!i) throw new Error(c); } a.type = { name: "json1", uri: "http://sharejs.org/types/JSONv1", readCursor: r.readCursor, writeCursor: r.writeCursor, create: (i) => i, isNoop: (i) => i == null, setDebug(i) { }, registerSubtype: Z, checkValidOp: z, normalize: q, apply: Ee, transformPosition: de, compose: ne, tryTransform: st, transform: jt, makeInvertible: De, invert: le, invertWithDoc: kt, RM_UNEXPECTED_CONTENT: u.ConflictType.RM_UNEXPECTED_CONTENT, DROP_COLLISION: u.ConflictType.DROP_COLLISION, BLACKHOLE: u.ConflictType.BLACKHOLE, transformNoConflict: (i, c, O) => yt(() => !0, i, c, O), typeAllowingConflictsPred: (i) => Object.assign(Object.assign({}, a.type), { transform: (c, O, D) => yt(i, c, O, D) }) }; const l = (i) => i ? i.getComponent() : null; function E(i) { return i && typeof i == "object" && !Array.isArray(i); } const x = (i) => Array.isArray(i) ? i.slice() : i !== null && typeof i == "object" ? Object.assign({}, i) : i, _ = (i) => i && (i.p != null || i.r !== void 0), s = (i) => i && (i.d != null || i.i !== void 0); function d(i, c) { return o(i != null), typeof c == "number" ? (o(Array.isArray(i), "Invalid key - child is not an array"), (i = i.slice()).splice(c, 1)) : (o(E(i), "Invalid key - child is not an object"), delete (i = Object.assign({}, i))[c]), i; } function h(i, c, O) { return typeof c == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= c, "Cannot insert into out of bounds index"), i.splice(c, 0, O)) : (o(E(i), "Cannot insert into missing item"), o(i[c] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), i[c] = O), O; } a.removeOp = (i, c = !0) => r.writeCursor().writeAtPath(i, "r", c).get(), a.moveOp = (i, c) => r.writeCursor().writeMove(i, c).get(), a.insertOp = (i, c) => r.writeCursor().writeAtPath(i, "i", c).get(), a.replaceOp = (i, c, O) => r.writeCursor().at(i, (D) => { D.write("r", c), D.write("i", O); }).get(), a.editOp = (i, c, O, D = !1) => r.writeCursor().at(i, (w) => y(w, c, O, D)).get(); const k = (i, c) => i != null && (typeof c == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, c) => k(i, c) ? i[c] : void 0, pe = {}; function Z(i) { let c = i.type ? i.type : i; c.name && (pe[c.name] = c), c.uri && (pe[c.uri] = c); } const Ce = (i) => { const c = pe[i]; if (c) return c; throw Error("Missing type: " + i); }; Z(nn()); const Ge = (i, c) => i + c; Z({ name: "number", apply: Ge, compose: Ge, invert: (i) => -i, transform: (i) => i }); const me = (i) => i == null ? null : i.et ? Ce(i.et) : i.es ? pe["text-unicode"] : i.ena != null ? pe.number : null, f = (i) => i.es ? i.es : i.ena != null ? i.ena : i.e, y = (i, c, O, D = !1) => { const [w, I] = typeof c == "string" ? [Ce(c), c] : [c, c.name]; !D && w.isNoop && w.isNoop(O) || (I === "number" ? i.write("ena", O) : I === "text-unicode" ? i.write("es", O) : (i.write("et", I), i.write("e", O))); }; function v(i) { o(typeof i == "number"), o(i >= 0), o(i === (0 | i)); } function L(i) { typeof i == "number" ? v(i) : o(typeof i == "string"); } function z(i) { if (i === null) return; const c = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), D = (I) => { let R = !0, $ = !1; for (let p in I) { const m = I[p]; if (R = !1, o(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") v(m), o(!c.has(m)), c.add(m), o(I.r === void 0); else if (p === "d") v(m), o(!O.has(m)), O.add(m), o(I.i === void 0); else if (p === "e" || p === "es" || p === "ena") { o(!$), $ = !0; const b = me(I); o(b, "Missing type in edit"), b.checkValidOp && b.checkValidOp(f(I)); } } o(!R); }, w = (I, R, $) => { if (!Array.isArray(I)) throw Error("Op must be null or a list"); if (I.length === 0) throw Error("Empty descent"); R || L(I[0]); let p = 1, m = 0, b = 0; for (let C = 0; C < I.length; C++) { const N = I[C]; if (o(N != null), Array.isArray(N)) { const B = w(N, !1); if (m) { const g = typeof b, S = typeof B; g === S ? o(b < B, "descent keys are not in order") : o(g === "number" && S === "string"); } b = B, m++, p = 3; } else typeof N == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(N), p = 2) : (o(p !== 3), L(N), o(r.isValidPathItem(N), "Invalid path key"), p = 1); } return o(m !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), I[0]; }; w(i, !0), o(c.size === O.size, "Mismatched picks and drops in op"); for (let I = 0; I < c.size; I++) o(c.has(I)), o(O.has(I)); } function q(i) { let c = 0, O = []; const D = r.writeCursor(); return D.mergeTree(i, (w, I) => { const R = me(w); if (R) { const p = f(w); y(I, R, R.normalize ? R.normalize(p) : p); } for (const p of ["r", "p", "i", "d"]) if (w[p] !== void 0) { const m = p === "p" || p === "d" ? ($ = w[p], O[$] == null && (O[$] = c++), O[$]) : w[p]; I.write(p, m); } var $; }), D.get(); } function Ee(i, c) { if (z(c), c === null) return i; const O = []; return function D(w, I) { let R = w, $ = 0, p = { root: w }, m = 0, b = p, C = "root"; function N() { for (; m < $; m++) { let B = I[m]; typeof B != "object" && (o(k(b, C)), b = b[C] = x(b[C]), C = B); } } for (; $ < I.length; $++) { const B = I[$]; if (Array.isArray(B)) { const g = D(R, B); g !== R && g !== void 0 && (N(), R = b[C] = g); } else if (typeof B == "object") { B.d != null ? (N(), R = h(b, C, O[B.d])) : B.i !== void 0 && (N(), R = h(b, C, B.i)); const g = me(B); if (g) N(), R = b[C] = g.apply(R, f(B)); else if (B.e !== void 0) throw Error("Subtype " + B.et + " undefined"); } else R = Y(R, B); } return p.root; }(i = function D(w, I) { const R = []; let $ = 0; for (; $ < I.length; $++) { const C = I[$]; if (Array.isArray(C)) break; typeof C != "object" && (R.push(w), w = Y(w, C)); } for (let C = I.length - 1; C >= $; C--) w = D(w, I[C]); for (--$; $ >= 0; $--) { const C = I[$]; if (typeof C != "object") { const N = R.pop(); w = w === Y(N, C) ? N : w === void 0 ? d(N, C) : (m = C, b = w, (p = x(p = N))[m] = b, p); } else _(C) && (o(w !== void 0, "Cannot pick up or remove undefined"), C.p != null && (O[C.p] = w), w = void 0); } var p, m, b; return w; }(i, c), c); } function de(i, c) { i = i.slice(), z(c); const O = r.readCursor(c); let D, w, I = !1; const R = []; for (let p = 0; ; p++) { const m = i[p], b = O.getComponent(); if (b && (b.r !== void 0 ? I = !0 : b.p != null && (I = !1, D = b.p, w = p)), p >= i.length) break; let C = 0; const N = r.advancer(O, void 0, (g, S) => { _(S) && C++; }); R.unshift(N); const B = N(m); if (typeof m == "number" && (i[p] -= C), !B) break; } if (R.forEach((p) => p.end()), I) return null; const $ = () => { let p = 0; if (D != null) { const m = O.getPath(); p = m.length, i = m.concat(i.slice(w)); } for (; p < i.length; p++) { const m = i[p], b = l(O), C = me(b); if (C) { const g = f(b); C.transformPosition && (i[p] = C.transformPosition(i[p], g)); break; } let N = 0; const B = r.advancer(O, (g, S) => s(S) ? ~(g - N) : g - N, (g, S) => { s(S) && N++; })(m); if (typeof m == "number" && (i[p] += N), !B) break; } }; return D != null ? O.eachDrop(null, (p) => { p === D && $(); }) : $(), i; } function ne(i, c) { if (z(i), z(c), i == null) return c; if (c == null) return i; let O = 0; const D = r.readCursor(i), w = r.readCursor(c), I = r.writeCursor(), R = [], $ = [], p = [], m = [], b = [], C = [], N = /* @__PURE__ */ new Set(); D.traverse(null, (g) => { g.p != null && (p[g.p] = D.clone()); }), w.traverse(null, (g) => { g.d != null && (m[g.d] = w.clone()); }); const B = r.writeCursor(); return function g(S, re, te, K, se, $e, we, ye) { o(re || te); const oe = l(re), Pe = l(te), Ae = !!Pe && Pe.r !== void 0, Le = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ie = Pe ? Pe.p : null, Ne = ($e || Ae) && Ie == null; if (Ie != null) K = m[Ie], we = $[Ie] = new r.WriteCursor(); else if (Pe && Pe.r !== void 0) K = null; else { const T = l(K); T && T.d != null && (K = null); } const Q = l(K); if (Te != null) if (S = p[Te], ye = R[Te] = new r.WriteCursor(), Ne) $e && !Ae && ye.write("r", !0); else { const T = b[Te] = O++; we.write("d", T); } else if (oe && oe.i !== void 0) S = null; else { const T = l(S); T && T.p != null && (S = null); } let A; Le ? (o(se === void 0), A = oe.i) : A = se; const W = (Ie == null ? !Le || $e || Ae : A === void 0) ? null : we.getComponent(); if (Ie != null) { if (!(se !== void 0 || Le)) { const T = Te != null ? b[Te] : O++; C[Ie] = T, ye.write("p", T); } } else Ae && (Le || se !== void 0 || (Pe.r, ye.write("r", Pe.r))); const M = Ne ? null : me(oe), P = me(Q); if ((M || P) && (M && M.name, P && P.name), M && P) { o(M === P); const T = f(oe), G = f(Q), he = M.compose(T, G); y(we, M, he), N.add(Q); } else M ? y(we, M, f(oe)) : P && (y(we, P, f(Q)), N.add(Q)); const U = typeof A == "object" && A != null; let J = !1, X = 0, ee = 0, fe = 0, ce = 0, ae = 0; const Oe = r.advancer(K, (T, G) => s(G) ? ce - T - 1 : T - ce, (T, G) => { s(G) && ce++; }), H = r.advancer(S, (T, G) => _(G) ? X - T - 1 : T - X, (T, G) => { _(G) && X++; }); if (r.eachChildOf(re, te, (T, G, he) => { let be, Re, qe = T, Me = T, Je = T; if (typeof T == "number") { let _e = T + fe; Re = Oe(_e), Me = _e + ce; let ue = T + ee; be = H(ue), s(l(Re)) && (be = null), qe = ue + X, Je = T + ae, o(qe >= 0, "p1PickKey is negative"), o(Me >= 0, "p2DropKey is negative"); const Se = s(l(G)), xe = _(l(he)); (Se || xe && !Ne) && ae--, Se && ee--, xe && fe--; } else be = H(T), Re = Oe(T); ye.descend(qe), we.descend(Me); const ze = U && !s(l(G)) ? A[Je] : void 0, ke = g(be, G, he, Re, ze, Ne, we, ye); var je, j, ie; U && !Ne ? ze !== ke && (J || (A = Array.isArray(A) ? A.slice() : Object.assign({}, A), J = !0), je = A, ie = ke, typeof (j = Je) == "number" ? (o(Array.isArray(je)), o(j < je.length)) : (o(!Array.isArray(je)), o(je[j] !== void 0)), ie === void 0 ? typeof j == "number" ? je.splice(j, 1) : delete je[j] : je[j] = ie) : o(ke === void 0), we.ascend(), ye.ascend(); }), H.end(), Oe.end(), W != null) W.i = A; else if (!$e && !Ae && Ie == null) return A; }(D, D.clone(), w, w.clone(), void 0, !1, I, B), I.reset(), I.mergeTree(B.get()), I.reset(), I.get(), R.map((g) => g.get()), $.map((g) => g.get()), D.traverse(I, (g, S) => { const re = g.p; if (re != null) { const te = b[re]; te != null && S.write("p", te); const K = R[re]; K && K.get(), K && S.mergeTree(K.get()); } else g.r !== void 0 && S.write("r", g.r); }), I.reset(), I.get(), w.traverse(I, (g, S) => { const re = g.d; if (re != null) { const K = C[re]; K != null && S.write("d", K); const se = $[re]; se && S.mergeTree(se.get()); } else g.i !== void 0 && S.write("i", g.i); const te = me(g); te && !N.has(g) && y(S, te, f(g)); }), I.get(); } function le(i) { if (i == null) return null; const c = new r.ReadCursor(i), O = new r.WriteCursor(); let D; const w = [], I = []; return function R($, p, m) { const b = $.getComponent(); let C, N = !1; if (b) { b.p != null && (p.write("d", b.p), w[b.p] = $.clone()), b.r !== void 0 && p.write("i", b.r), b.d != null && (p.write("p", b.d), m = void 0), b.i !== void 0 && (m = C = b.i); const g = me(b); g && (m === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(b)) : (f(b), m = g.apply(m, f(b)), N = !0)); } let B = 0; for (const g of $) { p.descend(g); const S = typeof g == "number" ? g - B : g, re = Y(m, S); s($.getComponent()) && B++; const te = R($, p, re); if (m !== void 0 && te !== void 0) { if (N || (N = !0, m = x(m)), !k(m, S)) throw Error("Cannot modify child - invalid operation"); m[S] = te; } p.ascend(); } if (C === void 0) return N ? m : void 0; p.write("r", m); }(c, O, void 0), D && (O.reset(), function R($, p, m) { const b = p.getComponent(); if (b) { const g = b.d; if (g != null && ($ = w[g], m = I[g] = r.writeCursor()), D.has(b)) { const S = me(b); if (!S.invert) throw Error(`Cannot invert subtype ${S.name}`); y(m, S, S.invert(f(b))); } } let C = 0, N = 0; const B = r.advancer($, (g, S) => _(S) ? C - g - 1 : g - C, (g, S) => { _(S) && C++; }); for (const g of p) if (typeof g == "number") { const S = g - N, re = B(S), te = S + C; m.descend(te), R(re, p, m), s(p.getComponent()) && N++, m.ascend(); } else m.descend(g), R(B(g), p, m), m.ascend(); B.end(); }(c.clone(), c, O), I.length && (O.reset(), c.traverse(O, (R, $) => { const p = R.p; if (p != null) { const m = I[p]; m && m.get(), m && $.mergeTree(m.get()); } }))), O.get(); } const ge = (i, c) => i.some((O) => typeof O == "object" && (Array.isArray(O) ? ge(O, c) : c(O))); function De(i, c) { if (i == null || !ge(i, (p) => { var m; return p.r !== void 0 || ((m = me(p)) === null || m === void 0 ? void 0 : m.makeInvertible) != null; })) return i; const O = new r.ReadCursor(i), D = new r.WriteCursor(); let w = !1; const I = [], R = [], $ = (p, m, b) => { const C = p.getComponent(); let N = !1; if (C) { C.d != null && m.write("d", C.d), C.i !== void 0 && m.write("i", C.i); const g = C.p; if (g != null && (I[g] = p.clone(), o(b !== void 0, "Operation picks up at an invalid key"), R[g] = b, m.write("p", C.p)), C.r !== void 0 && b === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc"); const S = me(C); S && (S.makeInvertible ? w = !0 : y(m, S, f(C), !0)); } let B = 0; for (const g of p) { m.descend(g); const S = typeof g == "number" ? g - B : g, re = Y(b, S), te = $(p, m, re); re !== te && (N || (N = !0, b = x(b)), te === void 0 ? (b = d(b, S), typeof g == "number" && B++) : b[S] = te), m.ascend(); } return C && (C.r !== void 0 ? (m.write("r", t.default(b)), b = void 0) : C.p != null && (b = void 0)), b; }; return $(O, D, c), D.get(), w && (D.reset(), function p(m, b, C, N, B) { const g = b.getComponent(); if (g) { g.i !== void 0 ? (N = g.i, B = !0) : g.d != null && (N = R[g.d], m = I[g.d], B = !1, g.d); let K = me(g); if (K && K.makeInvertible) { const se = f(g); y(C, K, K.makeInvertible(se, N), !0); } } let S = 0, re = 0; const te = r.advancer(m, (K, se) => _(se) ? S - K - 1 : K - S, (K, se) => { _(se) && S++; }); for (const K of b) if (typeof K == "number") { const se = K - re, $e = te(se), we = se + S, ye = Y(N, B ? se : we); C.descend(K), p($e, b, C, ye, B), s(b.getComponent()) && re++, C.ascend(); } else { const se = Y(N, K); C.descend(K), p(te(K), b, C, se, B), C.ascend(); } te.end(); }(O.clone(), O, D, c, !1)), D.get(); } function kt(i, c) { return le(De(i, c)); } const it = (i) => { if (i == null) return null; const c = i.slice(); for (let O = 0; O < i.length; O++) { const D = c[O]; Array.isArray(D) && (c[O] = it(D)); } return c; }; function st(i, c, O) { o(O === "left" || O === "right", "Direction must be left or right"); const D = O === "left" ? 0 : 1; if (c == null) return { ok: !0, result: i }; z(i), z(c); let w = null; const I = [], R = [], $ = [], p = [], m = [], b = [], C = [], N = [], B = [], g = [], S = [], re = [], te = [], K = [], se = []; let $e = 0; const we = r.readCursor(i), ye = r.readCursor(c), oe = r.writeCursor(); if (function Q(A, W = null, M) { const P = l(W); P && (P.r !== void 0 ? M = W.clone() : P.p != null && (M = null, b[P.p] = A.clone())); const U = A.getComponent(); let J; U && (J = U.p) != null && (m[J] = W ? W.clone() : null, $[J] = A.clone(), M && (g[J] = !0, B[J] = M), P && P.p != null && (K[J] = P.p)); const X = r.advancer(W); for (const ee of A) Q(A, X(ee), M); X.end(); }(ye, we, null), function Q(A, W, M, P, U) { const J = M.getComponent(); let X, ee = !1; J && ((X = J.d) != null ? (p[X] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(X)), g[X], A = m[X] || null, W = $[X] || null, g[X] ? (U && (S[X] = !0), U = B[X] || null) : !U || D !== 1 && K[X] != null || w == null && (w = { type: u.ConflictType.RM_UNEXPECTED_CONTENT, op1: a.removeOp(U.getPath()), op2: a.moveOp(W.getPath(), M.getPath()) }), ee = !0) : J.i !== void 0 && (A = W = null, ee = !0, U && w == null && (w = { type: u.ConflictType.RM_UNEXPECTED_CONTENT, op1: a.removeOp(U.getPath()), op2: a.insertOp(M.getPath(), J.i) }))); const fe = l(A); fe && (fe.r !== void 0 ? U = A.clone() : fe.p != null && (fe.p, P = fe.p, U = null)); const ce = me(J); ce && U && w == null && (w = { type: u.ConflictType.RM_UNEXPECTED_CONTENT, op1: a.removeOp(U.getPath()), op2: a.editOp(M.getPath(), ce, f(J), !0) }); let ae = 0, Oe = 0; const H = r.advancer(W, (G, he) => _(he) ? ae - G - 1 : G - ae, (G, he) => { _(he) && ae++; }), T = r.advancer(A); for (const G of M) if (typeof G == "number") { const he = G - Oe, be = H(he); Oe += +Q(T(he + ae), be, M, P, U); } else { const he = H(G); Q(T(G), he, M, P, U); } return H.end(), T.end(), ee; }(we, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), w) return { ok: !1, conflict: w }; S.map((Q) => !!Q); const Pe = []; let Ae = null; (function Q(A, W, M, P, U) { let J = !1; const X = l(W); if (_(X)) { const H = X.p; H != null ? (M = p[H], P = re[H] = r.writeCursor(), J = !0, U = null) : (M = null, U = W.clone()); } else s(l(M)) && (M = null); const ee = A.getComponent(); if (ee) { const H = ee.p; H != null ? (U && (N[H] = U), Pe[H] = U || D === 1 && J ? null : P.getComponent(), I[H] = A.clone(), M && (C[H] = M.clone())) : ee.r !== void 0 && (U || P.write("r", !0), (U || J) && (Ae == null && (Ae = /* @__PURE__ */ new Set()), Ae.add(ee))); } let fe = 0, ce = 0; const ae = r.advancer(W, void 0, (H, T) => { _(T) && fe++; }), Oe = r.advancer(M, (H, T) => s(T) ? ~(H - ce) : H - ce, (H, T) => { s(T) && ce++; }); if (A) for (const H of A) if (typeof H == "string") { const T = ae(H), G = Oe(H); P.descend(H), Q(A, T, G, P, U), P.ascend(); } else { const T = ae(H), G = H - fe, he = _(l(T)) ? null : Oe(G), be = G + ce; o(be >= 0), P.descend(be), Q(A, T, he, P, U), P.ascend(); } ae.end(), Oe.end(); })(we, ye, ye.clone(), oe, null), oe.reset(); let Le = []; if (function Q(A, W, M, P, U, J) { o(W); const X = W.getComponent(); let ee = l(P), fe = !1; const ce = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i); if (s(X)) { const j = X.d; j != null && (R[j] = W.clone()); const ie = j != null ? Pe[j] : null; let _e = !1; if (X.i !== void 0 || j != null && ie) { let ue; ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : n.default(ee.i, X.i), _e || ue != null && D !== 1 && K[ue] != null || w == null && (w = { type: u.ConflictType.DROP_COLLISION, op1: ce(j != null ? I[j] : null, W, X), op2: ce(ue != null ? $[ue] : null, P, ee) })), _e || (J ? w == null && (w = { type: u.ConflictType.RM_UNEXPECTED_CONTENT, op1: ce(j != null ? I[j] : null, W, X), op2: a.removeOp(J.getPath()) }) : (j != null ? (Le[$e] = j, U.write("d", ie.p = $e++)) : U.write("i", t.default(X.i)), fe = !0)); } else if (j != null && !ie) { const ue = N[j]; ue && (J = ue.clone()); } j != null ? (A = I[j], M = b[j], P = C[j]) : X.i !== void 0 && (A = M = null, _e || (P = null)); } else _(l(A)) && (A = M = P = null); const ae = l(A), Oe = l(M); if (_(Oe)) { const j = Oe.p; Oe.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, J = M.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((U = te[j]) || (U = te[j] = r.writeCursor()), U.reset(), J = null)); } else !s(X) && s(ee) && (P = null); ee = P != null ? P.getComponent() : null; const H = me(X); if (H) { const j = f(X); if (J) w == null && (w = { type: u.ConflictType.RM_UNEXPECTED_CONTENT, op1: a.editOp(W.getPath(), H, j, !0), op2: a.removeOp(J.getPath()) }); else { const ie = me(ee); let _e; if (ie) { if (H !== ie) throw Error("Transforming incompatible types"); const ue = f(ee); _e = H.transform(j, ue, O); } else _e = t.default(j); y(U, H, _e); } } let T = 0, G = 0, he = 0, be = 0, Re = 0, qe = 0, Me = A != null && A.descendFirst(), Je = Me; const ze = r.advancer(M, void 0, (j, ie) => { _(ie) && he++; }); let ke = P != null && P.descendFirst(), je = ke; for (const j of W) if (typeof j == "number") { let ie; const _e = s(W.getComponent()), ue = j - G; { let Be; for (; Me && typeof (Be = A.getKey()) == "number"; ) { Be += T; const Ue = A.getComponent(), Xe = _(Ue); if (Be > ue || Be === ue && (!Xe || D === 0 && _e)) break; if (Xe) { T--; const Ke = Ue.p; K.includes(Ke), Ue.d, l(te[Ue.d]), _(l(te[Ue.d])), (Ue.r === void 0 || Ae && Ae.has(Ue)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || Re--; } Me = A.nextSibling(); } ie = Me && Be === ue ? A : null; } const Se = ue - T; let xe = ze(Se); const ot = Se - he; let Ze = null; { let Be, Ue; for (; ke && typeof (Be = P.getKey()) == "number"; ) { Ue = Be - be; const Xe = P.getComponent(), Ke = s(Xe); if (Ue > ot) break; if (Ue === ot) { if (!Ke) { Ze = P; break; } { if (D === 0 && _e) { Ze = P; break; } const We = xe && _(xe.getComponent()); if (D === 0 && We) break; } } if (Ke) { const We = Xe.d; g[We], K[We], Xe.i === void 0 && (g[We] || K[We] != null && D !== 1) ? (g[We] || K[We] != null && D === 0) && (be++, qe--) : be++; } ke = P.nextSibling(); } } const _t = ot + be + Re + qe; o(_t >= 0, "trying to descend to a negative index"), U.descend(_t), _e && (ie = xe = Ze = null, G++), Q(ie, W, xe, Ze, U, J) && qe++, U.ascend(); } else { let ie; for (; Me && (ie = A.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) Me = A.nextSibling(); const _e = Me && ie === j ? A : null, ue = ze(j); let Se; for (; ke && (Se = P.getKey(), typeof Se != "string" || !(Se > j || Se === j)); ) ke = P.nextSibling(); const xe = ke && Se === j ? P : null; U.descend(j), Q(_e, W, ue, xe, U, J), U.ascend(); } return ze.end(), Je && A.ascend(), je && P.ascend(), fe; }(we, we.clone(), ye, ye.clone(), oe, null), w) return { ok: !1, conflict: w }; oe.reset(); const Te = (Q, A, W) => Q.traverse(A, (M, P) => { M.d != null && W(M.d, Q, P); }); (g.length || re.length) && (Te(ye, oe, (Q, A, W) => { g[Q] && !S[Q] && W.write("r", !0), re[Q] && W.mergeTree(re[Q].get()); }), oe.reset()); const Ie = [], Ne = []; if ((te.length || g.length) && !w) { const Q = r.readCursor(it(oe.get())); if (Te(Q, null, (A, W) => { Ie[A] = W.clone(); }), te.forEach((A) => { A && Te(r.readCursor(A.get()), null, (W, M) => { Ie[W] = M.clone(); }); }), function A(W, M, P, U, J, X) { const ee = l(M); if (ee && _(ee)) if (ee.p != null) { const T = ee.p; Ie[T].getPath(), P = Ie[T], U = Ne[T] = r.writeCursor(); } else ee.r !== void 0 && (P = null); else s(l(P)) && (P = null); const fe = W.getComponent(); if (fe) { let T; if ((T = fe.d) != null) { const G = te[T]; G && (G.get(), U.mergeTree(G.get()), P = r.readCursor(G.get())); } } let ce = 0, ae = 0; const Oe = r.advancer(M, void 0, (T, G) => { _(G) && ce--; }), H = r.advancer(P, (T, G) => s(G) ? -(T - ae) - 1 : T - ae, (T, G) => { s(G) && ae++; }); for (const T of W) if (typeof T == "number") { const G = Oe(T), he = T + ce, be = H(he), Re = he + ae; U.descend(Re), A(W, G, be, U), U.ascend(); } else U.descend(T), A(W, Oe(T), H(T), U), U.ascend(); Oe.end(), H.end(); }(ye, Q, Q.clone(), oe), oe.reset(), w) return { ok: !1, conflict: w }; if (oe.get(), Ne.length) { const A = Ne.map((M) => M ? M.get() : null), W = r.readCursor(it(oe.get())); if (Te(W, oe, (M, P, U) => { const J = A[M]; J && (U.mergeTree(J), A[M] = null); }), A.find((M) => M)) { const M = r.writeCursor(), P = r.writeCursor(); let U = 0, J = 0; A.forEach((X) => { X != null && Te(r.readCursor(X), null, (ee) => { const fe = Le[ee]; M.writeMove(I[fe].getPath(), R[fe].getPath(), U++); const ce = se[fe]; ce && ce.forEach((ae) => { g[ae] || D !== 1 && K[ae] != null || P.writeMove($[ae].getPath(), p[ae].getPath(), J++); }); }); }), w = { type: u.ConflictType.BLACKHOLE, op1: M.get(), op2: P.get() }; } } } return w ? { ok: !1, conflict: w } : { ok: !0, result: oe.get() }; } const gt = (i) => { const c = new Error("Transform detected write conflict"); throw c.conflict = i, c.type = c.name = "writeConflict", c; }; function jt(i, c, O) { const D = st(i, c, O); if (D.ok) return D.result; gt(D.conflict); } const He = (i) => { const c = r.writeCursor(); return r.readCursor(i).traverse(c, (O, D) => { (s(O) || me(O)) && D.write("r", !0); }), c.get(); }, $t = (i, c) => { const { type: O, op1: D, op2: w } = i; switch (O) { case u.ConflictType.DROP_COLLISION: return c === "left" ? [null, He(w)] : [He(D), null]; case u.ConflictType.RM_UNEXPECTED_CONTENT: let I = !1; return r.readCursor(D).traverse(null, (R) => { R.r !== void 0 && (I = !0); }), I ? [null, He(w)] : [He(D), null]; case u.ConflictType.BLACKHOLE: return [He(D), He(w)]; default: throw Error("Unrecognised conflict: " + O); } }; function yt(i, c, O, D) { let w = null; for (; ; ) { const I = st(c, O, D); if (I.ok) return ne(w, I.result); { const { conflict: R } = I; i(R) || gt(R); const [$, p] = $t(R, D); c = ne(q(c), $), O = ne(q(O), p), w = ne(w, p); } } } }(et)), et; } var Pt; function sn() { return Pt || (Pt = 1, function(a) { var e = Ye.__createBinding || (Object.create ? function(u, o, l, E) { E === void 0 && (E = l), Object.defineProperty(u, E, { enumerable: !0, get: function() { return o[l]; } }); } : function(u, o, l, E) { E === void 0 && (E = l), u[E] = o[l]; }), n = Ye.__exportStar || function(u, o) { for (var l in u) l !== "default" && !o.hasOwnProperty(l) && e(o, u, l); }; Object.defineProperty(a, "__esModule", { value: !0 }), n(rn(), a); var t = Mt(); Object.defineProperty(a, "ReadCursor", { enumerable: !0, get: function() { return t.ReadCursor; } }), Object.defineProperty(a, "WriteCursor", { enumerable: !0, get: function() { return t.WriteCursor; } }); var r = St(); Object.defineProperty(a, "ConflictType", { enumerable: !0, get: function() { return r.ConflictType; } }); }(Ye)), Ye; } var V = sn(); class on { constructor() { F(this, "drawingManagerData", {}); F(this, "_oldDrawingManagerData", {}); F(this, "_focusDrawings", []); F(this, "_remove$", new ve()); F(this, "remove$", this._remove$.asObservable()); F(this, "_add$", new ve()); F(this, "add$", this._add$.asObservable()); F(this, "_update$", new ve()); F(this, "update$", this._update$.asObservable()); F(this, "_order$", new ve()); F(this, "order$", this._order$.asObservable()); F(this, "_group$", new ve()); F(this, "group$", this._group$.asObservable()); F(this, "_ungroup$", new ve()); F(this, "ungroup$", this._ungroup$.asObservable()); F(this, "_refreshTransform$", new ve()); F(this, "refreshTransform$", this._refreshTransform$.asObservable()); F(this, "_visible$", new ve()); F(this, "visible$", this._visible$.asObservable()); // private readonly _externalUpdate$ = new Subject(); // readonly externalUpdate$ = this._externalUpdate$.asObservable(); F(this, "_focus$", new ve()); F(this, "focus$", this._focus$.asObservable()); F(this, "_featurePluginUpdate$", new ve()); F(this, "featurePluginUpdate$", this._featurePluginUpdate$.asObservable()); F(this, "_featurePluginAdd$", new ve()); F(this, "featurePluginAdd$", this._featurePluginAdd$.asObservable()); F(this, "_featurePluginRemove$", new ve()); F(this, "featurePluginRemove$", this._featurePluginRemove$.asObservable()); F(this, "_featurePluginOrderUpdate$", new ve()); F(this, "featurePluginOrderUpdate$", this._featurePluginOrderUpdate$.asObservable()); F(this, "_featurePluginGroupUpdate$", new ve()); F(this, "featurePluginGroupUpdate$", this._featurePluginGroupUpdate$.asObservable()); F(this, "_featurePluginUngroupUpdate$", new ve()); F(this, "featurePluginUngroupUpdate$", this._featurePluginUngroupUpdate$.asObservable()); F(this, "_visible", !0); F(this, "_editable", !0); } dispose() { this._remove$.complete(), this._add$.complete(), this._update$.complete(), this._order$.complete(), this._focus$.complete(), this._featurePluginUpdate$.complete(), this._featurePluginAdd$.complete(), this._featurePluginRemove$.complete(), this._featurePluginOrderUpdate$.complete(), this.drawingManagerData = {}, this._oldDrawingManagerData = {}; } visibleNotification(e) { this._visible$.next(e); } refreshTransform(e) { e.forEach((n) => { const t = this._getCurrentBySearch(n); t != null && (t.transform = n.transform, t.transforms = n.transforms, t.isMultiTransform = n.isMultiTransform); }), this.refreshTransformNotification(e); } getDrawingDataForUnit(e) { return this.drawingManagerData[e] || {}; } removeDrawingDataForUnit(e) { const n = this.drawingManagerData[e]; if (n == null) return; delete this.drawingManagerData[e]; const t = []; Object.keys(n).forEach((r) => { const u = n[r]; (u == null ? void 0 : u.data) != null && Object.keys(u.data).forEach((o) => { t.push({ unitId: e, subUnitId: r, drawingId: o }); }); }), t.length > 0 && this.removeNotification(t); } registerDrawingData(e, n) { this.drawingManagerData[e] = n; } initializeNotification(e) { const n = [], t = this.drawingManagerData[e]; t != null && (Object.keys(t).forEach((r) => { this._establishDrawingMap(e, r); const u = t[r]; Object.keys(u.data).forEach((o) => { const l = u.data[o]; l.unitId = e, l.subUnitId = r, n.push(l); }); }), n.length > 0 && this.addNotification(n)); } getDrawingData(e, n) { return this._getDrawingData(e, n); } // Use in doc only. setDrawingData(e, n, t) { this.drawingManagerData[e][n].data = t; } getBatchAddOp(e) { const n = [], t = [], r = []; e.forEach((x) => { const { op: _, invertOp: s } = this._addByParam(x); n.push({ unitId: x.unitId, subUnitId: x.subUnitId, drawingId: x.drawingId }), t.push(_), r.push(s); }); const u = t.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0]; return { undo: o, redo: u, unitId: l, subUnitId: E, objects: n }; } getBatchRemoveOp(e) { const n = [], t = []; e.forEach((E) => { const { op: x, invertOp: _ } = this._removeByParam(E); n.unshift(x), t.push(_); }); const r = n.reduce(V.type.compose, null), u = t.reduce(V.type.compose, null), { unitId: o, subUnitId: l } = e[0]; return { undo: u, redo: r, unitId: o, subUnitId: l, objects: e }; } getBatchUpdateOp(e) { const n = [], t = [], r = []; e.forEach((x) => { const { op: _, invertOp: s } = this._updateByParam(x); n.push({ unitId: x.unitId, subUnitId: x.subUnitId, drawingId: x.drawingId }), t.push(_), r.push(s); }); const u = t.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0]; return { undo: o, redo: u, unitId: l, subUnitId: E, objects: n }; } removeNotification(e) { this._remove$.next(e); } addNotification(e) { this._add$.next(e); } updateNotification(e) { this._update$.next(e); } orderNotification(e) { this._order$.next(e); } groupUpdateNotification(e) { this._group$.next(e); } ungroupUpdateNotification(e) { this._ungroup$.next(e); } refreshTransformNotification(e) { this._refreshTransform$.next(e); } getGroupDrawingOp(e) { const n = [], { unitId: t, subUnitId: r } = e[0].parent; e.forEach((l) => { n.push(this._getGroupDrawingOp(l)); }); const u = n.reduce(V.type.compose, null); return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: t, subUnitId: r, objects: e }; } getUngroupDrawingOp(e) { const n = [], { unitId: t, subUnitId: r } = e[0].parent; e.forEach((l) => { n.push(this._getUngroupDrawingOp(l)); }); const u = n.reduce(V.type.compose, null); return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: t, subUnitId: r, objects: e }; } getDrawingsByGroup(e) { const { unitId: n, subUnitId: t, drawingId: r } = e; if (this.getDrawingByParam({ unitId: n, subUnitId: t, drawingId: r }) == null) return []; const o = this._getDrawingData(n, t), l = []; return Object.keys(o).forEach((E) => { const x = o[E]; x.groupId === r && l.push(x); }), l; } _getGroupDrawingOp(e) { const { parent: n, children: t } = e, { unitId: r, subUnitId: u, drawingId: o } = n, l = []; l.push( V.insertOp([r, u, "data", o], n) ); let E = Number.NEGATIVE_INFINITY; return t.forEach((x) => { const { unitId: _, subUnitId: s, drawingId: d } = x, h = this._hasDrawingOrder({ unitId: _, subUnitId: s, drawingId: d }); E = Math.max(E, h), l.push( ...this._getUpdateParamCompareOp(x, this.getDrawingByParam({ unitId: _, subUnitId: s, drawingId: d })) ); }), E === Number.NEGATIVE_INFINITY && (E = this._getDrawingOrder(r, u).length), l.push( V.insertOp([r, u, "order", E], o) ), l.reduce(V.type.compose, null); } _getUngroupDrawingOp(e) { const { parent: n, children: t } = e, { unitId: r, subUnitId: u, drawingId: o } = n, l = []; return t.forEach((E) => { const { unitId: x, subUnitId: _, drawingId: s } = E; l.push( ...this._getUpdateParamCompareOp(E, this.getDrawingByParam({ unitId: x, subUnitId: _, drawingId: s })) ); }), l.push( V.removeOp([r, u, "data", o], !0) ), l.push( V.removeOp([r, u, "order", this._getDrawingOrder(r, u).indexOf(o)], !0) ), l.reduce(V.type.compose, null); } applyJson1(e, n, t) { this._establishDrawingMap(e, n), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = V.type.apply(this.drawingManagerData, t); } // private _fillMissingFields(jsonOp: JSONOp) { // if (jsonOp == null) { // return; // } // let object: { [key: string]: {} } = this.drawingManagerData; // for (let i = 0; i < jsonOp.length; i++) { // const op = jsonOp[i]; // if (Array.isArray(op)) { // const opKey = op[0] as string; // if (!(opKey in object)) { // object[opKey] = null as unknown as never; // } // } else if (typeof op === 'string') { // object = object[op]; // if (object == null) { // break; // } // } // } // } featurePluginUpdateNotification(e) { this._featurePluginUpdate$.next(e); } featurePluginOrderUpdateNotification(e) { this._featurePluginOrderUpdate$.next(e); } featurePluginAddNotification(e) { this._featurePluginAdd$.next(e); } featurePluginRemoveNotification(e) { this._featurePluginRemove$.next(e); } featurePluginGroupUpdateNotification(e) { this._featurePluginGroupUpdate$.next(e); } featurePluginUngroupUpdateNotification(e) { this._featurePluginUngroupUpdate$.next(e); } getDrawingByParam(e) { return this._getCurrentBySearch(e); } getOldDrawingByParam(e) { return this._getOldBySearch(e); } getDrawingOKey(e) { const [n, t, r] = e.split("#-#"); return this._getCurrentBySearch({ unitId: n, subUnitId: t, drawingId: r }); } focusDrawing(e) { if (e == null || e.length === 0) { this._focusDrawings = [], this._focus$.next([]); return; } const n = []; e.forEach((t) => { var E; const { unitId: r, subUnitId: u, drawingId: o } = t, l = (E = this._getDrawingData(r, u)) == null ? void 0 : E[o]; l != null && n.push(l); }), n.length > 0 && (this._focusDrawings = n, this._focus$.next(n)); } getFocusDrawings() { const e = []; return this._focusDrawings.forEach((n) => { var l; const { unitId: t, subUnitId: r, drawingId: u } = n, o = (l = this._getDrawingData(t, r)) == null ? void 0 : l[u]; o != null && e.push(o); }), e; } getDrawingOrder(e, n) { return this._getDrawingOrder(e, n); } // Use in doc only. setDrawingOrder(e, n, t) { this.drawingManagerData[e][n].order = t; } orderUpdateNotification(e) { this._order$.next(e); } getForwardDrawingsOp(e) { const { unitId: n, subUnitId: t, drawingIds: r } = e, u = [], o = this.getDrawingOrder(n, t), l = [...r]; r.forEach((_) => { const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ }); if (s === -1 || s === o.length - 1) return; const d = V.moveOp([n, t, "order", s], [n, t, "order", s + 1]); u.push(d), l.includes(o[s + 1]) || l.push(o[s + 1]); }); const E = u.reduce(V.type.compose, null); return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } }; } getBackwardDrawingOp(e) { const { unitId: n, subUnitId: t, drawingIds: r } = e, u = [], o = this.getDrawingOrder(n, t), l = [...r]; r.forEach((_) => { const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ }); if (s === -1 || s === 0) return; const d = V.moveOp([n, t, "order", s], [n, t, "order", s - 1]); u.push(d), l.includes(o[s - 1]) || l.push(o[s - 1]); }); const E = u.reduce(V.type.compose, null); return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } }; } getFrontDrawingsOp(e) { const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r), o = [...r], l = this.getDrawingOrder(n, t), E = []; u.forEach((s) => { const { drawingId: d } = s, h = this._getDrawingCount(n, t) - 1, k = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(d)], [n, t, "order", h]); E.push(k), o.includes(l[h]) || o.push(l[h]); }); const x = E.reduce(V.type.compose, null); return { undo: V.type.invertWithDoc(x, this.drawingManagerData), redo: x, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } }; } getBackDrawingsOp(e) { const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r, !0), o = [...r], l = this.getDrawingOrder(n, t), E = []; u.forEach((s) => { const { drawingId: d } = s, h = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(d)], [n, t, "order", 0]); E.push(h), o.includes(l[0]) || o.push(l[0]); }); const x = E.reduce(V.type.compose, null); return { undo: V.type.invertWithDoc(x, this.drawingManagerData), redo: x, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } }; } _getDrawingCount(e, n) { return this.getDrawingOrder(e, n).length || 0; } _getOrderFromSearchParams(e, n, t, r = !1) { return t.map((u) => { const o = this._hasDrawingOrder({ unitId: e, subUnitId: n, drawingId: u }); return { drawingId: u, zIndex: o }; }).sort(r === !1 ? xt : Bt); } _hasDrawingOrder(e) { if (e == null) return -1; const { unitId: n, subUnitId: t, drawingId: r } = e; return this._establishDrawingMap(n, t), this._getDrawingOrder(n, t).indexOf(r); } _getCurrentBySearch(e) { var u, o, l; if (e == null) return; const { unitId: n, subUnitId: t, drawingId: r } = e; return (l = (o = (u = this.drawingManagerData[n]) == null ? void 0 : u[t]) == null ? void 0 : o.data) == null ? void 0 : l[r]; } _getOldBySearch(e) { var u, o, l; if (e == null) return; const { unitId: n, subUnitId: t, drawingId: r } = e; return (l = (o = (u = this._oldDrawingManagerData[n]) == null ? void 0 : u[t]) == null ? void 0 : o.data) == null ? void 0 : l[r]; } _establishDrawingMap(e, n, t) { var r; return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][n] || (this.drawingManagerData[e][n] = { data: {}, order: [] }), t == null ? null : (r = this.drawingManagerData[e][n].data) == null ? void 0 : r[t]; } _addByParam(e) { const { unitId: n, subUnitId: t, drawingId: r } = e; this._establishDrawingMap(n, t, r); const u = V.insertOp([n, t, "data", r], e), o = V.insertOp([n, t, "order", this._getDrawingOrder(n, t).length], r), l = [u, o].reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData); return { op: l, invertOp: E }; } _removeByParam(e) { if (e == null) return { op: [], invertOp: [] }; const { unitId: n, subUnitId: t, drawingId: r } = e; if (this._establishDrawingMap(n, t, r) == null) return { op: [], invertOp: [] }; const o = V.removeOp([n, t, "data", r], !0), l = V.removeOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(r)], !0), E = [o, l].reduce(V.type.compose, null), x = V.type.invertWithDoc(E, this.drawingManagerData); return { op: E, invertOp: x }; } _updateByParam(e) { const { unitId: n, subUnitId: t, drawingId: r } = e, u = this._establishDrawingMap(n, t, r); if (u == null) return { op: [], invertOp: [] }; const l = this._getUpdateParamCompareOp(e, u).reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData); return { op: l, invertOp: E }; } // private _initializeDrawingData(updateParam: T, oldParam: T) { // Object.keys(updateParam).forEach((key) => { // if (!(key in oldParam)) { // oldParam[key as keyof IDrawingParam] = null as unknown as never; // } // }); // } _getUpdateParamCompareOp(e, n) { const { unitId: t, subUnitId: r, drawingId: u } = e, o = []; return Object.keys(e).forEach((l) => { const E = e[l], x = n[l]; x !== E && o.push( V.replaceOp([t, r, "data", u, l], x, E) ); }), o; } _getDrawingData(e, n) { var t, r; return ((r = (t = this.drawingManagerData[e]) == null ? void 0 : t[n]) == null ? void 0 : r.data) || {}; } _getDrawingOrder(e, n) { var t, r; return ((r = (t = this.drawingManagerData[e]) == null ? void 0 : t[n]) == null ? void 0 : r.order) || []; } getDrawingVisible() { return this._visible; } getDrawingEditable() { return this._editable; } setDrawingVisible(e) { this._visible = e; } setDrawingEditable(e) { this._editable = e; } } class an extends on { } function bn({ unitId: a, subUnitId: e, drawingId: n }, t) { return typeof t == "number" ? `${a}#-#${e}#-#${n}#-#${t}` : `${a}#-#${e}#-#${n}`; } const vn = async (a) => new Promise((e, n) => { const t = new Image(); t.src = a, t.onload = () => { e({ width: t.width, height: t.height, image: t }); }, t.onerror = (r) => { n(r); }; }), Ut = Wt("univer.drawing-manager.service"), ln = { id: "drawing.operation.set-drawing-selected", type: Gt.OPERATION, handler: (a, e) => { const n = a.get(Ut); return e == null ? !1 : (n.focusDrawing(e), !0); } }, un = "drawing.config", Tt = {}; class dn { constructor() { F(this, "_waitCount", 0); F(this, "_change$", new ve()); F(this, "change$", this._change$); F(this, "_imageSourceCache", /* @__PURE__ */ new Map()); } setWaitCount(e) { this._waitCount = e, this._change$.next(e); } getImageSourceCache(e, n) { if (n === at.BASE64) { const t = new Image(); return t.src = e, t; } return this._imageSourceCache.get(e); } addImageSourceCache(e, n, t) { n === at.BASE64 || t == null || this._imageSourceCache.set(e, t); } async getImage(e) { return Promise.resolve(e); } async saveImage(e) { return new Promise((n, t) => { if (!Zt.includes(e.type)) { t(new Error(Qe.ERROR_IMAGE_TYPE)), this._decreaseWaiting(); return; } if (e.size > Yt) { t(new Error(Qe.ERROR_EXCEED_SIZE)), this._decreaseWaiting(); return; } const r = new FileReader(); r.readAsDataURL(e), r.onload = (u) => { var E; const o = (E = u.target) == null ? void 0 : E.result; if (o == null) { t(new Error(Qe.ERROR_IMAGE)), this._decreaseWaiting(); return; } const l = Lt.generateRandomId(6); n({ imageId: l, imageSourceType: at.BASE64, source: o, base64Cache: o, status: Qe.SUCCUSS }), this._decreaseWaiting(); }; }); } _decreaseWaiting() { this._waitCount -= 1, this._change$.next(this._waitCount); } } var cn = Object.defineProperty, fn = Object.getOwnPropertyDescriptor, hn = (a, e, n, t) => { for (var r = t > 1 ? void 0 : t ? fn(e, n) : e, u = a.length - 1, o; u >= 0; u--) (o = a[u]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && cn(e, n, r), r; }, ct = (a, e) => (n, t) => e(n, t, a); const pn = "UNIVER_DRAWING_PLUGIN"; var ft; let At = (ft = class extends Ft { constructor(a = Tt, e, n, t) { super(), this._config = a, this._injector = e, this._configService = n, this._commandService = t; const { ...r } = Vt( {}, Tt, this._config ); this._configService.setConfig(un, r); } onStarting() { this._initCommands(), this._initDependencies(); } _initDependencies() { var n; Ht([ [Jt, { useClass: dn }], [Ut, { useClass: an }] ], (n = this._config) == null ? void 0 : n.override).forEach((t) => this._injector.add(t)); } _initCommands() { [ ln ].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a))); } }, F(ft, "pluginName", pn), ft); At = hn([ ct(1, qt(Kt)), ct(2, zt), ct(3, Xt) ], At); export { Zt as DRAWING_IMAGE_ALLOW_IMAGE_LIST, Yt as DRAWING_IMAGE_ALLOW_SIZE, wn as DRAWING_IMAGE_COUNT_LIMIT, On as DRAWING_IMAGE_HEIGHT_LIMIT, mn as DRAWING_IMAGE_WIDTH_LIMIT, an as DrawingManagerService, Ut as IDrawingManagerService, En as IImageIoService, dn as ImageIoService, Dn as ImageSourceType, Pn as ImageUploadStatusType, ln as SetDrawingSelectedOperation, on as UnitDrawingService, At as UniverDrawingPlugin, bn as getDrawingShapeKeyByDrawingSearch, vn as getImageSize };