@veltdev/slate-velt-comments-staging 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/types/adapters/host/doc.d.ts +86 -0
- package/cjs/types/adapters/host/marks.d.ts +51 -0
- package/cjs/types/adapters/host/storage.d.ts +38 -0
- package/cjs/types/adapters/velt.d.ts +50 -0
- package/cjs/types/constants/common.d.ts +58 -0
- package/cjs/types/core/ExtensionComponent.d.ts +13 -0
- package/cjs/types/core/extension.d.ts +54 -0
- package/cjs/types/core/registry.d.ts +52 -0
- package/cjs/types/core/state.d.ts +80 -0
- package/cjs/types/features/addComment.d.ts +63 -0
- package/cjs/types/features/commentRenderer.d.ts +46 -0
- package/cjs/types/features/renderComments.d.ts +73 -0
- package/cjs/types/features/updateContent.d.ts +25 -0
- package/cjs/types/index.d.ts +14 -34
- package/cjs/types/types/common.d.ts +54 -0
- package/cjs/types/types/host.d.ts +65 -0
- package/cjs/types/types/state.d.ts +28 -0
- package/cjs/types/types/velt.d.ts +23 -0
- package/cjs/types/utils/common.d.ts +80 -0
- package/cjs/types/utils/console.d.ts +25 -0
- package/cjs/types/utils/serializer.d.ts +20 -0
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/types/adapters/host/doc.d.ts +86 -0
- package/esm/types/adapters/host/marks.d.ts +51 -0
- package/esm/types/adapters/host/storage.d.ts +38 -0
- package/esm/types/adapters/velt.d.ts +50 -0
- package/esm/types/constants/common.d.ts +58 -0
- package/esm/types/core/ExtensionComponent.d.ts +13 -0
- package/esm/types/core/extension.d.ts +54 -0
- package/esm/types/core/registry.d.ts +52 -0
- package/esm/types/core/state.d.ts +80 -0
- package/esm/types/features/addComment.d.ts +63 -0
- package/esm/types/features/commentRenderer.d.ts +46 -0
- package/esm/types/features/renderComments.d.ts +73 -0
- package/esm/types/features/updateContent.d.ts +25 -0
- package/esm/types/index.d.ts +14 -34
- package/esm/types/types/common.d.ts +54 -0
- package/esm/types/types/host.d.ts +65 -0
- package/esm/types/types/state.d.ts +28 -0
- package/esm/types/types/velt.d.ts +23 -0
- package/esm/types/utils/common.d.ts +80 -0
- package/esm/types/utils/console.d.ts +25 -0
- package/esm/types/utils/serializer.d.ts +20 -0
- package/index.d.ts +268 -34
- package/package.json +1 -1
- package/cjs/types/SlateVeltComment.d.ts +0 -6
- package/cjs/types/constants.d.ts +0 -9
- package/cjs/types/editor.d.ts +0 -72
- package/cjs/types/plugin.d.ts +0 -17
- package/cjs/types/store.d.ts +0 -36
- package/cjs/types/types.d.ts +0 -14
- package/cjs/types/velt.d.ts +0 -21
- package/esm/types/SlateVeltComment.d.ts +0 -6
- package/esm/types/constants.d.ts +0 -9
- package/esm/types/editor.d.ts +0 -72
- package/esm/types/plugin.d.ts +0 -17
- package/esm/types/store.d.ts +0 -36
- package/esm/types/types.d.ts +0 -14
- package/esm/types/velt.d.ts +0 -21
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../node_modules/tslib/tslib.es6.js","../../src/constants.ts","../../src/velt.ts","../../src/editor.ts","../../src/store.ts","../../src/plugin.ts","../../src/SlateVeltComment.tsx","../../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","export const Constants = {\n ATTRIBUTES: {\n EDITOR_ID: 'data-editor-id',\n LOCATION_ID: 'data-velt-location-id',\n },\n ELEMENT_TYPE: {\n VELT_COMMENT: 'veltComment',\n },\n};\n","var _a;\nexport class VeltService {\n}\n_a = VeltService;\nVeltService.selectedCommentsMap = new Map();\nVeltService.subscribers = new Map();\nVeltService.isSubscribed = false;\n/* eslint-disable @typescript-eslint/no-explicit-any */\nVeltService.getCommentElement = () => {\n try {\n const velt = window.Velt;\n if (velt === null || velt === void 0 ? void 0 : velt.getCommentElement) {\n return velt.getCommentElement();\n }\n return null;\n }\n catch (error) {\n _a.catchError('Error getting comment element:', error);\n return null;\n }\n};\nVeltService.addManualComment = ({ context, location, }) => {\n try {\n const commentElement = _a.getCommentElement();\n if (!commentElement)\n return Promise.resolve(null);\n return commentElement.addManualComment({ context, location });\n }\n catch (error) {\n _a.catchError('Error adding manual comment:', error);\n return Promise.resolve(null);\n }\n};\nVeltService.updateContext = ({ annotationId, context, }) => {\n try {\n const commentElement = _a.getCommentElement();\n if (!commentElement)\n return Promise.resolve(null);\n return commentElement.updateContext(annotationId, context);\n }\n catch (error) {\n _a.catchError('Error updating context:', error);\n }\n};\nVeltService.subscribeToSelectedCommentsMap = (id, subscriber) => {\n try {\n _a.subscribeToSelectedAnnotationsMapSingleton();\n _a.subscribers.set(id, subscriber);\n }\n catch (error) {\n _a.catchError('Error subscribing to selected comments map:', error);\n }\n};\nVeltService.unsubscribeFromSelectedCommentsMap = (id) => {\n try {\n _a.subscribers.delete(id);\n }\n catch (error) {\n _a.catchError('Error unsubscribing from selected comments map:', error);\n }\n};\nVeltService.catchError = (message, otherProperties) => {\n var _b;\n try {\n const url = 'https://api.velt.dev/sa';\n let properties = {};\n if (otherProperties && typeof otherProperties === 'object') {\n properties = Object.assign(Object.assign({}, properties), otherProperties);\n }\n if (message) {\n properties.message = message;\n }\n properties.sdkVersion = (_b = window.Velt) === null || _b === void 0 ? void 0 : _b.version;\n const body = {\n type: 'track',\n data: {\n event: 'tiptapVeltCommentsError',\n properties: properties,\n },\n };\n // fetch(url, {\n // method: 'POST',\n // headers: {\n // 'Content-Type': 'application/json',\n // },\n // body: JSON.stringify(body),\n // });\n }\n catch (error) {\n // handle error here\n }\n};\nVeltService.subscribeToSelectedAnnotationsMapSingleton = () => {\n var _b;\n try {\n if (_a.isSubscribed) {\n return;\n }\n const commentElement = _a.getCommentElement();\n if (commentElement && typeof (commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments) === 'function') {\n (_b = commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments()) === null || _b === void 0 ? void 0 : _b.subscribe((comments) => {\n const selectedCommentsMap = new Map();\n comments === null || comments === void 0 ? void 0 : comments.forEach((comment) => {\n if (comment === null || comment === void 0 ? void 0 : comment.annotationId) {\n selectedCommentsMap.set(comment === null || comment === void 0 ? void 0 : comment.annotationId, true);\n }\n });\n // Check if the maps are different\n const areMapsEqual = (map1, map2) => {\n if (map1.size !== map2.size)\n return false;\n for (const [key, value] of map1) {\n if (map2.get(key) !== value)\n return false;\n }\n return true;\n };\n // Skip update if maps are equal\n if (areMapsEqual(selectedCommentsMap, _a.selectedCommentsMap || new Map())) {\n return;\n }\n _a.updateSelectedCommentsMap(selectedCommentsMap);\n });\n _a.isSubscribed = true;\n }\n }\n catch (error) {\n return new Map();\n }\n};\nVeltService.updateSelectedCommentsMap = (selectedCommentsMap) => {\n try {\n _a.selectedCommentsMap = selectedCommentsMap;\n _a.subscribers.forEach((subscriber) => {\n if (typeof subscriber === 'function') {\n subscriber(_a.selectedCommentsMap);\n }\n });\n }\n catch (error) {\n _a.catchError('Error updating selected comments map:', error);\n }\n};\n","import { Editor, Node, Path, Element as SlateElement, Text, Transforms } from 'slate';\nimport { ReactEditor } from 'slate-react';\nimport { Constants } from './constants';\nimport { VeltService } from './velt';\nexport class EditorService {\n constructor(plugin) {\n this.getSelectedText = (editor) => {\n try {\n // Ensure there's a selection\n if (!editor.selection)\n return null;\n // Extract and return the selected text\n return Editor.string(editor, editor.selection);\n }\n catch (err) {\n VeltService.catchError('Error getting selected text:', err);\n return null;\n }\n };\n /**\n * Finds occurrences of a given text within a specified element or text\n * @param {Object} options - Configuration options for occurrence search\n * @param {string} options.searchText - The text to search for\n * @param {SlateElement|string} [options.scopeElement] - DOM element or text to search within\n * @param {number} [options.startOffset] - Optional starting offset for the search\n * @param {boolean} [options.caseSensitive] - Whether the search should be case-sensitive\n * @returns {Object} Occurrence details\n */\n this.findOccurrenceOfText = (options) => {\n try {\n const { searchText, scopeElement, startOffset = 0, caseSensitive = true } = options;\n // Validate input\n if (!searchText)\n return { total: 0, position: 0 };\n // Determine the text to search in\n const fullText = typeof scopeElement === 'string' ? scopeElement : (scopeElement === null || scopeElement === void 0 ? void 0 : scopeElement.textContent) || '';\n // Adjust search based on case sensitivity\n const searchMethod = caseSensitive\n ? (text) => text\n : (text) => text.toLowerCase();\n const processedFullText = searchMethod(fullText);\n const processedSearchText = searchMethod(searchText);\n // Find all occurrences\n const occurrences = [];\n let lastIndex = 0;\n while (true) {\n const matchIndex = processedFullText.indexOf(processedSearchText, lastIndex);\n if (matchIndex === -1)\n break;\n occurrences.push(matchIndex);\n lastIndex = matchIndex + processedSearchText.length;\n }\n // Calculate position\n const positionBeforeSelected = occurrences.filter((index) => index < startOffset).length + 1;\n return {\n total: occurrences.length,\n position: positionBeforeSelected,\n };\n }\n catch (error) {\n VeltService.catchError('Error finding occurrence of text:', error);\n return null;\n }\n };\n this.findOccurrenceOfSelectedText = (editor, scopeElement) => {\n var _a;\n try {\n // Get selected text\n const selectedText = this.getSelectedText(editor);\n // If no text selected, return 0\n if (!selectedText)\n return 0;\n if (!scopeElement) {\n // Determine which occurrence of the text this is within the document\n // This helps with maintaining comment positions during text edits\n let occurrence = 0;\n const allMatches = this.findAllMatches(editor, selectedText);\n const selection = editor.selection;\n if (selection) {\n const matchIndex = allMatches.findIndex((match) => {\n return (match.anchor.path.toString() === selection.anchor.path.toString() &&\n match.focus.path.toString() === selection.focus.path.toString() &&\n match.anchor.offset === selection.anchor.offset &&\n match.focus.offset === selection.focus.offset);\n });\n if (matchIndex !== -1) {\n occurrence = matchIndex + 1;\n }\n }\n return occurrence;\n }\n // Find the DOM node of the selection\n const domSelection = ReactEditor.toDOMNode(editor, editor);\n const startOffset = (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.offset;\n // Find occurrence\n const result = this.findOccurrenceOfText({\n searchText: selectedText,\n scopeElement: scopeElement || domSelection,\n startOffset,\n });\n return result === null || result === void 0 ? void 0 : result.position;\n }\n catch (error) {\n VeltService.catchError('Error finding occurrence of selected text:', error);\n return null;\n }\n };\n this.findAllMatches = (editor, textToSearch, options = { caseSensitive: true }) => {\n try {\n const { caseSensitive = true } = options;\n const matches = [];\n // If no text to search, return empty array\n if (!textToSearch)\n return matches;\n // Safely get text from a node\n const getText = (node) => {\n return typeof node === 'object' && node !== null && 'text' in node ? node.text : '';\n };\n // Check if a node is a text node\n const isTextNode = (node) => {\n return (typeof node === 'object' &&\n node !== null &&\n 'text' in node &&\n typeof node.text === 'string');\n };\n // Iterate through all text nodes in the document\n const searchInNode = (node, path) => {\n // Handle text nodes\n if (isTextNode(node)) {\n const text = getText(node);\n // Apply case sensitivity\n const searchText = caseSensitive ? textToSearch : textToSearch.toLowerCase();\n const nodeText = caseSensitive ? text : text.toLowerCase();\n // Find all matches in the current text node\n let lastIndex = 0;\n while (true) {\n const index = nodeText.indexOf(searchText, lastIndex);\n if (index === -1)\n break;\n // Create a range for this match\n const range = {\n anchor: { path, offset: index },\n focus: { path, offset: index + textToSearch.length },\n };\n matches.push(range);\n // Move the search forward\n lastIndex = index + 1;\n }\n }\n // Recursively search child nodes\n if ('children' in node && Array.isArray(node.children)) {\n node.children.forEach((child, index) => {\n searchInNode(child, [...path, index]);\n });\n }\n };\n // Start the search from the root of the document\n try {\n const [initialNode] = Editor.nodes(editor, {\n at: [],\n mode: 'highest',\n });\n if (initialNode) {\n searchInNode(initialNode[0], initialNode[1]);\n }\n }\n catch (error) {\n VeltService.catchError('Error searching in document:', error);\n }\n return matches;\n }\n catch (error) {\n VeltService.catchError('Error finding all matches:', error);\n return [];\n }\n };\n this.findParentNodeWithIdForSelection = (editor) => {\n try {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n const { anchor } = selection;\n const node = Node.get(editor, anchor.path);\n return this.findParentNodeWithId(editor, { node, path: anchor.path });\n }\n catch (error) {\n VeltService.catchError('Error finding parent node with ID for selection:', error);\n return null;\n }\n };\n this.findParentNodeWithId = (editor, options) => {\n var _a;\n try {\n let { node, path } = options || {};\n if (!node) {\n return null;\n }\n if (path) {\n node = Editor.node(editor, path)[0];\n }\n let domNode = null;\n let editorDOM = null;\n try {\n // Convert Slate path to DOM node\n domNode = ReactEditor.toDOMNode(editor, node);\n }\n catch (err) {\n // handle error here\n return null;\n }\n try {\n // Get the editor's DOM element\n editorDOM = ReactEditor.toDOMNode(editor, editor);\n }\n catch (err) {\n // handle error here\n return null;\n }\n // Default options\n const maxIterations = (_a = options === null || options === void 0 ? void 0 : options.maxIterations) !== null && _a !== void 0 ? _a : 100;\n const idPattern = options === null || options === void 0 ? void 0 : options.idPattern;\n let currentNode = domNode;\n let iterationCount = 0;\n while (currentNode && currentNode !== document.body && iterationCount < maxIterations) {\n // Check if we're still within the editor's DOM\n if (!editorDOM.contains(currentNode)) {\n return null;\n }\n // Check ID based on optional pattern or just presence of ID\n if (currentNode.id) {\n if (!idPattern || idPattern.test(currentNode.id)) {\n return currentNode;\n }\n }\n currentNode = currentNode.parentElement;\n iterationCount++;\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error finding parent node with ID:', error);\n return null;\n }\n };\n this.removeVeltCommentFromEditor = (editor, annotationId) => {\n try {\n // Validate input\n if (!editor || !annotationId) {\n throw new Error('Invalid input: editor and annotationId are required');\n }\n // Create an array to store paths of elements to remove\n const elementsToUnwrap = [];\n // Iterate through all nodes in the editor\n for (const [node, path] of Node.descendants(editor)) {\n // Check if the node is an element using the type\n if (EditorService.isVeltCommentText(node) &&\n node.annotationId === annotationId) {\n // Store the path of the element to be removed\n elementsToUnwrap.push(path);\n }\n }\n try {\n // Unwrap elements in reverse order to avoid path shifting issues\n elementsToUnwrap.reverse().forEach((path) => {\n const nodeAtPath = Editor.node(editor, path)[0];\n const elementAtNode = ReactEditor.toDOMNode(editor, nodeAtPath);\n if (elementAtNode === null || elementAtNode === void 0 ? void 0 : elementAtNode.isConnected) {\n const unwrapNodes = () => {\n Transforms.unwrapNodes(editor, {\n at: path,\n // This ensures only the wrapper is removed, keeping its children\n mode: 'lowest',\n });\n };\n const HistoryEditor = EditorService.getHistoryEditor();\n if (HistoryEditor && typeof HistoryEditor.withoutSaving === 'function') {\n HistoryEditor.withoutSaving(editor, () => {\n unwrapNodes();\n });\n }\n else {\n unwrapNodes();\n }\n }\n });\n }\n catch (err) {\n VeltService.catchError('Error unwrapping elements:', err);\n }\n return true;\n }\n catch (error) {\n VeltService.catchError('Error removing Velt comment:', error);\n return false;\n }\n };\n // Helper function to highlight text with velt comment\n this.highlightTextWithVeltComment = (editor, annotation) => {\n var _a;\n try {\n const { text, targetTextNodeId, occurrence } = ((_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) || {};\n if (!text || !occurrence) {\n return;\n }\n const isWrapped = this.injectTag(editor, text, occurrence, annotation.annotationId, targetTextNodeId);\n if (isWrapped) {\n // Store the annotation data\n if (annotation.annotationId) {\n this.plugin.storeService.annotationStore.set(annotation.annotationId, {\n annotation,\n });\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error highlighting text with velt comment:', error);\n }\n };\n this.getEditorTextContent = (editor) => {\n try {\n return editor.children.map((node) => Node.string(node)).join('');\n }\n catch (error) {\n VeltService.catchError('Error getting editor text content:', error);\n return '';\n }\n };\n this.onSlateValueChange = ({ editor }) => {\n try {\n // Phase 1: Collect all annotations in the document\n const annotationsToCheck = this.collectDocumentAnnotations({ editor });\n // Early return if no annotations to process\n if (annotationsToCheck.size === 0)\n return;\n // Phase 2: Process each annotation to check for changes\n const changedAnnotations = new Map();\n for (const [annotationId] of annotationsToCheck) {\n // Get the stored annotation data\n const storedData = this.plugin.storeService.annotationStore.get(annotationId);\n if (!storedData)\n continue;\n // Find all nodes with this annotation ID\n const nodes = Array.from(Editor.nodes(editor, { at: [] }))\n .filter(([node]) => EditorService.isVeltCommentText(node))\n .filter(([node]) => node.annotationId === annotationId)\n .map(([node, path]) => ({\n node: node,\n pos: Editor.start(editor, path).offset,\n }));\n // Skip if no nodes found for this annotation\n if (!nodes.length)\n continue;\n const changes = this.processAnnotationChanges({ editor, annotationId });\n // Store changes if any detected\n if (changes) {\n changedAnnotations.set(annotationId, changes);\n }\n }\n // Phase 3: Apply updates for any annotations that changed\n if (changedAnnotations.size > 0) {\n this.updateVeltComments({ changes: changedAnnotations, editor });\n }\n }\n catch (error) {\n VeltService.catchError('Error in processVeltCommentChanges:', error);\n }\n };\n this.injectTag = (editor, textToSearch, occurrence, annotationId, targetElementId) => {\n try {\n // If target element ID is provided, find the DOM element\n let targetElement = null;\n if (targetElementId) {\n targetElement = document.getElementById(targetElementId);\n // Validate target element\n if (!targetElement) {\n return false;\n }\n // Ensure the element is part of the editor\n if (!this.isElementInEditor(editor, targetElement)) {\n return false;\n }\n }\n else {\n targetElement = ReactEditor.toDOMNode(editor, editor);\n }\n // If no target element is specified, fall back to editor-wide search\n if (!targetElement) {\n return false;\n }\n // Find the range for the specific text occurrence\n const range = this.findTextOccurrence(editor, textToSearch, occurrence, targetElement);\n if (!range) {\n return false;\n }\n // Check if the range is already wrapped with a velt-comment-text element\n const isAlreadyWrapped = Array.from(Editor.nodes(editor, {\n at: range,\n match: (node) => EditorService.isVeltCommentText(node),\n })).length > 0;\n if (isAlreadyWrapped)\n return false;\n const wrapNodes = () => {\n editor.wrapNodes({\n type: Constants.ELEMENT_TYPE.VELT_COMMENT,\n children: [],\n annotationId: annotationId,\n }, { at: range, split: true });\n };\n const HistoryEditor = EditorService.getHistoryEditor();\n // If history editor is available, use it to wrap nodes without saving\n if (HistoryEditor && typeof HistoryEditor.withoutSaving === 'function') {\n HistoryEditor.withoutSaving(editor, () => {\n wrapNodes();\n });\n }\n else {\n // Fallback if withoutSaving isn't available\n // Just perform the operation directly\n wrapNodes();\n }\n return true;\n }\n catch (error) {\n VeltService.catchError('Error injecting tag:', error);\n return false;\n }\n };\n this.plugin = plugin;\n }\n // Phase 1: Collect all annotations in the document\n collectDocumentAnnotations({ editor, }) {\n try {\n const annotationsToCheck = new Map();\n // Traverse all nodes in the document\n Array.from(Editor.nodes(editor, { at: [] }))\n .filter(([node]) => EditorService.isVeltCommentText(node))\n .forEach(([node]) => {\n const veltNode = node;\n const annotationId = veltNode.annotationId;\n if (annotationId) {\n const storedData = this.plugin.storeService.annotationStore.get(annotationId);\n if (storedData === null || storedData === void 0 ? void 0 : storedData.annotation) {\n annotationsToCheck.set(annotationId, storedData.annotation);\n }\n }\n });\n return annotationsToCheck;\n }\n catch (error) {\n VeltService.catchError('Error collecting document annotations:', error);\n return new Map();\n }\n }\n processAnnotationChanges({ editor, annotationId, }) {\n var _a, _b, _c, _d;\n try {\n let targetNode = null;\n let targetElement = null;\n let targetPath = null;\n const annotation = (_a = this.plugin.storeService.annotationStore.get(annotationId)) === null || _a === void 0 ? void 0 : _a.annotation;\n if (!((_b = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _b === void 0 ? void 0 : _b.textEditorConfig)) {\n return null;\n }\n const { text, targetTextNodeId, occurrence } = ((_c = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _c === void 0 ? void 0 : _c.textEditorConfig) || {};\n const annotatedNodes = Array.from(Editor.nodes(editor, {\n at: [],\n match: (node) => EditorService.isVeltCommentText(node) &&\n node.annotationId === annotationId,\n mode: 'lowest',\n }));\n for (const [node, path] of annotatedNodes) {\n targetNode = node;\n targetPath = path;\n }\n if (!targetNode) {\n return null;\n }\n try {\n targetElement = ReactEditor.toDOMNode(editor, targetNode);\n if (!targetElement) {\n return null;\n }\n }\n catch (error) {\n return null;\n }\n // Extract and concatenate text from matched nodes\n const currentText = annotatedNodes\n .map(([node]) => Node.string(node))\n .join('');\n if (!currentText) {\n return null;\n }\n const currentTargetNode = this.findParentNodeWithId(editor, {\n node: targetNode,\n path: targetPath !== null && targetPath !== void 0 ? targetPath : undefined,\n });\n let currentTargetNodeId;\n if (currentTargetNode) {\n currentTargetNodeId = currentTargetNode.id;\n }\n let containerNode;\n let containerPath;\n if (currentTargetNode) {\n containerNode = ReactEditor.toSlateNode(editor, currentTargetNode);\n containerPath = ReactEditor.findPath(editor, containerNode);\n }\n const currentOccurrence = (_d = this.findTextOccurrenceOfNode(editor, targetNode, targetPath !== null && targetPath !== void 0 ? targetPath : undefined, containerNode, containerPath)) === null || _d === void 0 ? void 0 : _d.nodeOccurrencePosition;\n if (!currentOccurrence) {\n return null;\n }\n const textChanged = currentText !== text;\n const occurrenceChanged = currentOccurrence !== occurrence;\n const targetTextNodeIdChanged = targetTextNodeId !== currentTargetNodeId;\n if (textChanged || occurrenceChanged || targetTextNodeIdChanged) {\n return {\n contentChanged: textChanged,\n currentText,\n occurrenceChanged,\n currentOccurrence: currentOccurrence !== null && currentOccurrence !== void 0 ? currentOccurrence : 0,\n originalOccurrence: occurrence,\n annotationId,\n originalText: text,\n originalTargetTextNodeId: targetTextNodeId,\n newTargetTextNodeId: currentTargetNodeId,\n annotation,\n multiThreadAnnotationId: annotation === null || annotation === void 0 ? void 0 : annotation.multiThreadAnnotationId,\n targetTextNodeIdChanged,\n };\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error processing annotation changes:', error);\n return null;\n }\n }\n // Phase 3: Apply updates for any annotations that changed\n /**\n * Updates the Velt comment element with new annotation data\n */\n updateVeltComments({ changes, editor, }) {\n var _a;\n try {\n for (const [annotationId, changeData] of Array.from(changes.entries())) {\n try {\n if (!((_a = changeData.annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig))\n continue;\n const textEditorConfig = JSON.parse(JSON.stringify(changeData.annotation.context.textEditorConfig));\n if (changeData.contentChanged) {\n textEditorConfig.text = changeData.currentText;\n }\n if (changeData.occurrenceChanged) {\n textEditorConfig.occurrence = changeData.currentOccurrence;\n }\n if (changeData.targetTextNodeIdChanged) {\n textEditorConfig.targetTextNodeId = changeData.newTargetTextNodeId;\n }\n const context = Object.assign(Object.assign({}, changeData.annotation.context), { textEditorConfig });\n // Remove data from store\n this.plugin.storeService.annotationStore.remove(annotationId);\n this.removeVeltCommentFromEditor(editor, annotationId);\n VeltService.updateContext({ annotationId, context });\n }\n catch (error) {\n VeltService.catchError('Error updating Velt comments', error);\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error updating Velt comments', error);\n }\n }\n isElementInEditor(editor, element) {\n try {\n // Convert Slate editor to its DOM representation\n const editorElement = ReactEditor.toDOMNode(editor, editor);\n // Check if the target element is a descendant of the editor\n return editorElement.contains(element);\n }\n catch (error) {\n VeltService.catchError('Error checking element in editor:', error);\n return false;\n }\n }\n // Helper method to extract the traversal logic\n traverseNodesForText(currentNode, currentPath, textNodePositions, fullText) {\n try {\n if (Text.isText(currentNode)) {\n const start = fullText.length;\n fullText += currentNode.text;\n const end = fullText.length;\n textNodePositions.push({\n node: currentNode,\n path: currentPath,\n start,\n end,\n });\n }\n else if (SlateElement.isElement(currentNode)) {\n // Traverse child nodes\n for (let i = 0; i < currentNode.children.length; i++) {\n const childPath = [...currentPath, i];\n fullText = this.traverseNodesForText(currentNode.children[i], childPath, textNodePositions, fullText);\n }\n }\n return fullText;\n }\n catch (error) {\n VeltService.catchError('Error traversing nodes for text:', error);\n return '';\n }\n }\n collectSubtreeText(editor, node, path) {\n try {\n const textNodePositions = [];\n let fullText = '';\n // Special case for the root node (editor itself)\n if (path.length === 0) {\n // When path is [], we're at the editor root, so traverse all children\n for (let i = 0; i < editor.children.length; i++) {\n const childPath = [i];\n fullText = this.traverseNodesForText(editor.children[i], childPath, textNodePositions, fullText);\n }\n }\n else {\n // Normal case for non-root nodes\n fullText = this.traverseNodesForText(node, path, textNodePositions, fullText);\n }\n return { fullText, textNodePositions };\n }\n catch (error) {\n VeltService.catchError('Error collecting subtree text:', error);\n return { fullText: '', textNodePositions: [] };\n }\n }\n findTextOccurrence(editor, textToSearch, occurrence, targetElement) {\n try {\n // Convert target element to Slate node\n const targetNode = ReactEditor.toSlateNode(editor, targetElement);\n const targetPath = ReactEditor.findPath(editor, targetNode);\n // Collect all text from the subtree\n const { fullText, textNodePositions } = this.collectSubtreeText(editor, targetNode, targetPath);\n // Find all matches in the full text\n const matches = [];\n let match;\n const regex = new RegExp(textToSearch.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g');\n while ((match = regex.exec(fullText)) !== null) {\n matches.push({ index: match.index });\n }\n // If we don't have enough occurrences, return null\n if (matches.length < occurrence) {\n return null;\n }\n // Get the specific match\n const targetMatch = matches[occurrence - 1];\n // Find which text nodes the match spans\n const matchStart = targetMatch.index;\n const matchEnd = matchStart + textToSearch.length;\n // Find the range that covers this match\n let anchorNodeInfo;\n let focusNodeInfo;\n for (const nodePosition of textNodePositions) {\n // Check for anchor (start of match)\n if (matchStart >= nodePosition.start && matchStart < nodePosition.end) {\n anchorNodeInfo = nodePosition;\n }\n // Check for focus (end of match)\n if (matchEnd > nodePosition.start && matchEnd <= nodePosition.end) {\n focusNodeInfo = nodePosition;\n }\n // If we have both anchor and focus, we can create the range\n if (anchorNodeInfo && focusNodeInfo) {\n return {\n anchor: {\n path: anchorNodeInfo.path,\n offset: matchStart - anchorNodeInfo.start,\n },\n focus: {\n path: focusNodeInfo.path,\n offset: matchEnd - focusNodeInfo.start,\n },\n };\n }\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error in findTextOccurrence:', error);\n return null;\n }\n }\n // for dynamic update\n /**\n * Find all occurrences of a specific text in the editor\n * @param {Editor} editor - The Slate.js editor instance\n * @param {string} searchText - The text to search for\n * @param {boolean} [caseSensitive=true] - Whether the search should be case-sensitive\n * @param {Node} [containerNode] - Optional container node to limit the search scope (if provided, only searches within this node)\n * @param {Path} [containerPath] - Optional path of the container node (will be calculated if not provided)\n * @returns {Array} Array of occurrence details\n */\n findAllTextOccurrences(editor, searchText, caseSensitive = true, containerNode, containerPath) {\n try {\n if (!searchText)\n return [];\n const occurrences = [];\n // Process search based on case sensitivity\n const processText = caseSensitive\n ? (text) => text\n : (text) => text.toLowerCase();\n const processedSearchText = processText(searchText);\n // Find container path if container node is provided but path isn't\n if (containerNode && !containerPath) {\n try {\n for (const [n, p] of Editor.nodes(editor)) {\n if (n === containerNode) {\n containerPath = p;\n break;\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error finding container path:', error);\n }\n }\n // Determine search scope\n const searchAt = containerPath || [];\n // Iterate through all text nodes in the scope\n for (const [node, path] of Editor.nodes(editor, {\n at: searchAt,\n match: (n) => Text.isText(n),\n })) {\n // Skip nodes that aren't within the container if container is specified\n if (containerPath &&\n !Path.isDescendant(path, containerPath) &&\n !Path.equals(path, containerPath)) {\n continue;\n }\n const nodeText = Node.string(node);\n const processedNodeText = processText(nodeText);\n let lastIndex = 0;\n let matchIndex;\n // Find all occurrences within this text node\n while ((matchIndex = processedNodeText.indexOf(processedSearchText, lastIndex)) !== -1) {\n // Create a point at the start of the match\n const start = { path, offset: matchIndex };\n // Create a point at the end of the match\n const end = { path, offset: matchIndex + searchText.length };\n // Create a range from start to end points\n const range = { anchor: start, focus: end };\n occurrences.push({\n node,\n path,\n range,\n startPoint: start,\n endPoint: end,\n text: nodeText.substring(matchIndex, matchIndex + searchText.length),\n });\n lastIndex = matchIndex + processedSearchText.length;\n }\n }\n return occurrences;\n }\n catch (error) {\n VeltService.catchError('Error finding all text occurrences:', error);\n return [];\n }\n }\n findTextOccurrenceOfNode(editor, node, nodePath, containerNode, containerPath) {\n try {\n // Get the text of the provided node\n const nodeText = Node.string(node);\n if (!nodeText.trim()) {\n // Return empty result for empty nodes\n return {\n node,\n nodePath,\n text: nodeText,\n totalOccurrences: 0,\n nodeOccurrencePosition: 0,\n textOccurrences: [],\n containerNode,\n containerPath,\n };\n }\n // Find the node's path if not provided\n if (!nodePath) {\n try {\n // Try to find the path using ReactEditor if applicable\n if ('findPath' in ReactEditor) {\n try {\n nodePath = ReactEditor.findPath(editor, node);\n }\n catch (reactError) {\n VeltService.catchError('Error finding path with ReactEditor:', reactError);\n }\n }\n // Fall back to manual search if needed\n if (!nodePath) {\n for (const [n, p] of Editor.nodes(editor)) {\n if (n === node) {\n nodePath = p;\n break;\n }\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error finding node path:', error);\n }\n }\n // Use findAllTextOccurrences to find all occurrences of this node's text\n // If containerNode is provided, search will be limited to that container\n const textOccurrences = this.findAllTextOccurrences(editor, nodeText, true, containerNode, containerPath);\n // Calculate occurrence position (1-based)\n let nodeOccurrencePosition = 0;\n if (nodePath) {\n // Find matching occurrence with the same path or where the node path is an ancestor\n for (let i = 0; i < textOccurrences.length; i++) {\n const occurrence = textOccurrences[i];\n // Check path relationships\n const isEqual = Path.equals(occurrence.path, nodePath);\n const isDescendant = Path.isAncestor(nodePath, occurrence.path);\n if (isEqual || isDescendant) {\n // Found the matching occurrence, using 1-based position index\n nodeOccurrencePosition = i + 1;\n break;\n }\n }\n }\n // Create detailed occurrence info\n const occurrenceInfo = {\n node,\n nodePath,\n text: nodeText,\n totalOccurrences: textOccurrences.length,\n nodeOccurrencePosition,\n textOccurrences,\n containerNode,\n containerPath,\n };\n return occurrenceInfo;\n }\n catch (error) {\n VeltService.catchError('Error finding text occurrence of node:', error);\n return null;\n }\n }\n}\nEditorService.setHistoryEditor = (historyEditor) => {\n EditorService.HistoryEditor = historyEditor;\n};\nEditorService.getHistoryEditor = () => {\n return EditorService.HistoryEditor;\n};\nEditorService.getEditorId = (editor) => {\n var _a, _b;\n try {\n // Get the DOM node representing the editor\n const domNode = ReactEditor.toDOMNode(editor, editor);\n if (domNode) {\n return ((_b = (_a = domNode === null || domNode === void 0 ? void 0 : domNode.closest(`[${Constants.ATTRIBUTES.EDITOR_ID}]`)) === null || _a === void 0 ? void 0 : _a.getAttribute(Constants.ATTRIBUTES.EDITOR_ID)) !== null && _b !== void 0 ? _b : null);\n }\n // No parent with data-editor-id found\n return null;\n }\n catch (error) {\n // Handle cases where the editor might not be connected to the DOM\n VeltService.catchError('Error finding editor ID:', error);\n return null;\n }\n};\nEditorService.isVeltCommentText = (element) => {\n return element.type === Constants.ELEMENT_TYPE.VELT_COMMENT;\n};\n","import { VeltService } from './velt';\nexport class StoreService {\n constructor(plugin) {\n this.isSubscribed = false;\n this.globalStore = {\n editor: null,\n comments: [],\n filteredComments: [],\n selectedCommentsMap: new Map(),\n };\n // Global annotation storage\n this.globalAnnotationStore = new Map();\n /**\n * Helper to get and set annotations with debug messages\n */\n this.annotationStore = {\n get: (id) => {\n return this.globalAnnotationStore.get(id);\n },\n set: (id, data) => {\n this.globalAnnotationStore.set(id, data);\n },\n getAll: () => {\n return new Map(this.globalAnnotationStore);\n },\n clear: () => {\n this.globalAnnotationStore.clear();\n },\n remove: (id) => {\n this.globalAnnotationStore.delete(id);\n },\n };\n this.updateGlobalStore = (store) => {\n var _a, _b, _c;\n try {\n const comments = (store === null || store === void 0 ? void 0 : store.comments) || ((_a = this.globalStore) === null || _a === void 0 ? void 0 : _a.comments) || [];\n const newSelectedCommentsMap = (store === null || store === void 0 ? void 0 : store.selectedCommentsMap) || ((_b = this.globalStore) === null || _b === void 0 ? void 0 : _b.selectedCommentsMap) || new Map();\n const oldFilteredComments = ((_c = this.globalStore) === null || _c === void 0 ? void 0 : _c.filteredComments) || [];\n const filteredComments = comments.filter((annotation) => {\n var _a;\n return (((_a = annotation === null || annotation === void 0 ? void 0 : annotation.status) === null || _a === void 0 ? void 0 : _a.type) !== 'terminal' ||\n (newSelectedCommentsMap === null || newSelectedCommentsMap === void 0 ? void 0 : newSelectedCommentsMap.get(annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)));\n });\n // Create a Set of new annotation IDs for O(1) lookup\n const newAnnotationIds = new Set(filteredComments.map((annotation) => annotation === null || annotation === void 0 ? void 0 : annotation.annotationId));\n // Get IDs of removed comments\n const removedAnnotationIds = oldFilteredComments\n .map((annotation) => annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)\n .filter((id) => id && !newAnnotationIds.has(id));\n // Remove comments from editor using just IDs\n removedAnnotationIds.forEach((annotationId) => {\n var _a, _b;\n if (((_a = this.globalStore) === null || _a === void 0 ? void 0 : _a.editor) && annotationId) {\n this.plugin.editorService.removeVeltCommentFromEditor((_b = this.globalStore) === null || _b === void 0 ? void 0 : _b.editor, annotationId);\n }\n });\n this.globalStore = Object.assign(Object.assign(Object.assign({}, this.globalStore), store), { filteredComments });\n this.highlightCommentsFromGlobalStore();\n }\n catch (error) {\n // handle error\n VeltService.catchError('Error updating global store:', error);\n }\n };\n this.highlightCommentsFromGlobalStore = () => {\n var _a, _b;\n try {\n const { editor, filteredComments } = this.globalStore;\n if (!editor || !filteredComments)\n return;\n for (const annotation of filteredComments) {\n const textToFind = (_b = (_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) === null || _b === void 0 ? void 0 : _b.text;\n if (textToFind) {\n this.plugin.editorService.highlightTextWithVeltComment(editor, annotation);\n }\n }\n }\n catch (error) {\n // handle error\n VeltService.catchError('Error highlighting comments from global store:', error);\n }\n };\n this.plugin = plugin;\n try {\n VeltService.subscribeToSelectedCommentsMap(this.plugin.editorId, (selectedCommentsMap) => {\n try {\n this.updateGlobalStore({ selectedCommentsMap });\n }\n catch (error) {\n VeltService.catchError('Error updating global store:', error);\n }\n });\n }\n catch (error) {\n VeltService.catchError('Error subscribing to selected comments map:', error);\n }\n }\n}\nStoreService.storeInstanceMap = new Map();\n","import { EditorService } from './editor';\nimport { StoreService } from './store';\nconst instanceMap = new Map();\nexport class Plugin {\n constructor(editorId, editor) {\n this.previousEditorTextContent = '';\n this.editorId = editorId;\n this.editor = editor;\n this.editorService = new EditorService(this);\n this.storeService = new StoreService(this);\n if (editor) {\n this.setPreviousEditorTextContent(this.editorService.getEditorTextContent(editor));\n }\n }\n static getInstance(config) {\n let { editorId, editor } = config || {};\n if (!editorId) {\n editorId = 'default';\n }\n if (!instanceMap.has(editorId)) {\n instanceMap.set(editorId, new Plugin(editorId, editor));\n }\n return instanceMap.get(editorId);\n }\n getPreviousEditorTextContent() {\n return this.previousEditorTextContent;\n }\n setPreviousEditorTextContent(textContent) {\n this.previousEditorTextContent = textContent;\n }\n}\n","import React from 'react';\nexport const SlateVeltComment = (props) => {\n const { attributes, children, element } = props;\n const annotationId = element === null || element === void 0 ? void 0 : element.annotationId;\n return (React.createElement(\"velt-comment-text\", Object.assign({ \"annotation-id\": annotationId }, attributes), children));\n};\n","import { __awaiter } from \"tslib\";\nimport { Operation } from 'slate';\nimport { EditorService } from './editor';\nimport { Plugin } from './plugin';\nimport { VeltService } from './velt';\nexport { SlateVeltComment } from './SlateVeltComment';\nexport * from './types';\n// Plugin configuration\nexport const withVeltComments = (editor, options) => {\n const { isInline, isVoid, onChange } = editor;\n if (options === null || options === void 0 ? void 0 : options.HistoryEditor) {\n EditorService.setHistoryEditor(options.HistoryEditor);\n }\n // Override isInline to treat Velt comment text elements as inline elements\n // This ensures comment text flows naturally within the document\n editor.isInline = (element) => {\n return EditorService.isVeltCommentText(element) ? true : isInline(element);\n };\n // Override isVoid to ensure Velt comment text elements are not void elements\n // This allows comment text to contain and display content\n editor.isVoid = (element) => {\n return EditorService.isVeltCommentText(element) ? false : isVoid(element);\n };\n // Add observer for value changes to track and update comments when text changes\n editor.onChange = () => {\n // Call the original onChange if it exists to preserve existing behavior\n if (onChange) {\n onChange();\n }\n // Only process text-related operations to avoid unnecessary updates\n const isTextChange = editor.operations.some((operation) => Operation.isTextOperation(operation));\n if (isTextChange) {\n // Update comment positions and states when text content changes\n onSlateValueChange({ editor });\n }\n };\n // Return the enhanced editor with Velt comments functionality\n return editor;\n};\nexport const triggerAddComment = (editor, config) => __awaiter(void 0, void 0, void 0, function* () {\n try {\n return addComment({ editor, context: config === null || config === void 0 ? void 0 : config.context });\n }\n catch (error) {\n VeltService.catchError('Error triggering add comment', error);\n }\n});\n/**\n * Creates a comment annotation for the currently selected text in the editor\n * This function handles the entire flow from getting the selected text to creating\n * the actual comment through the Velt service\n */\nexport const addComment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ editorId, editor, context: clientContext, }) {\n var _b, _c;\n try {\n // get comment element from Velt sdk\n const commentElement = VeltService.getCommentElement();\n if (!commentElement)\n return;\n // Ensure we have an editor ID for proper tracking\n if (!editorId) {\n editorId = (_b = EditorService.getEditorId(editor)) !== null && _b !== void 0 ? _b : undefined;\n }\n // Initialize plugin instance with editor context\n const plugin = Plugin.getInstance({ editorId, editor });\n // Get text currently selected by the user\n const selectedText = plugin.editorService.getSelectedText(editor);\n // Exit if no text is selected - nothing to comment on\n if (!selectedText) {\n return;\n }\n // Find the parent node containing the selection to establish position context\n const targetTextNode = plugin.editorService.findParentNodeWithIdForSelection(editor);\n // Extract node ID and location information for proper positioning\n let targetTextNodeId = undefined;\n let locationId = null;\n if (targetTextNode) {\n targetTextNodeId = targetTextNode.id;\n // Find the closest parent with a location ID to properly anchor the comment\n locationId = (_c = targetTextNode\n .closest('[data-velt-location-id]')) === null || _c === void 0 ? void 0 : _c.getAttribute('data-velt-location-id');\n }\n const occurrence = plugin.editorService.findOccurrenceOfSelectedText(editor, targetTextNode !== null && targetTextNode !== void 0 ? targetTextNode : undefined);\n // Exit if we can't determine occurrence information\n if (!occurrence) {\n return;\n }\n // Initialize context object for the comment\n let context = {};\n if (clientContext && typeof clientContext === 'object') {\n context = Object.assign(Object.assign({}, context), clientContext);\n }\n // Add text editor specific configuration to context\n // This helps position and track the comment as document changes\n context.textEditorConfig = {\n text: selectedText,\n occurrence: occurrence,\n targetTextNodeId: targetTextNodeId,\n };\n if (editorId) {\n context.textEditorConfig.editorId = editorId;\n }\n // Short delay to prevent comment dialog from closing immediately\n // This improves user experience when interacting with comments\n yield new Promise((resolve) => setTimeout(resolve, 200));\n // Create location reference if we have a location ID\n let location;\n if (locationId) {\n location = { id: locationId };\n }\n try {\n // Create the actual comment through Velt service\n VeltService.addManualComment({ context, location });\n }\n catch (error) {\n VeltService.catchError('Error creating comment', error);\n }\n }\n catch (error) {\n VeltService.catchError('Error adding comment', error);\n }\n});\nexport function highlightComments(editor, commentAnnotations, editorId) {\n try {\n renderComments({ editor, editorId, commentAnnotations });\n }\n catch (error) {\n VeltService.catchError('Error highlighting tiptap-velt-comments', error);\n }\n}\nexport const renderComments = ({ editor, editorId, commentAnnotations }) => {\n var _a;\n try {\n if (editor) {\n if (!editorId) {\n editorId = (_a = EditorService.getEditorId(editor)) !== null && _a !== void 0 ? _a : undefined;\n }\n commentAnnotations = commentAnnotations === null || commentAnnotations === void 0 ? void 0 : commentAnnotations.filter((annotation) => {\n var _a, _b, _c;\n return !!((_a = annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) &&\n ((_c = (_b = annotation.context) === null || _b === void 0 ? void 0 : _b.textEditorConfig) === null || _c === void 0 ? void 0 : _c.editorId) === editorId;\n });\n const plugin = Plugin.getInstance({ editorId, editor });\n plugin.storeService.updateGlobalStore({ editor, comments: commentAnnotations });\n VeltService.subscribeToSelectedAnnotationsMapSingleton();\n }\n }\n catch (error) {\n VeltService.catchError('Error highlighting tiptap-velt-comments', error);\n }\n};\nexport const onSlateValueChange = ({ editor, editorId, }) => {\n var _a;\n try {\n if (!editorId) {\n editorId = (_a = EditorService.getEditorId(editor)) !== null && _a !== void 0 ? _a : undefined;\n }\n const plugin = Plugin.getInstance({ editorId, editor });\n // Get the current editor text content\n const currentEditorTextContent = plugin.editorService.getEditorTextContent(editor);\n const previousEditorTextContent = plugin.getPreviousEditorTextContent();\n // Prevent unnecessary processing if content hasn't changed\n if (currentEditorTextContent === previousEditorTextContent)\n return;\n // Update the previous content for next comparison\n plugin.setPreviousEditorTextContent(currentEditorTextContent);\n plugin.editorService.onSlateValueChange({ editor });\n }\n catch (error) {\n VeltService.catchError('Error in processVeltCommentChanges:', error);\n }\n};\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","Constants","EDITOR_ID","LOCATION_ID","VELT_COMMENT","_a","VeltService","selectedCommentsMap","Map","subscribers","isSubscribed","getCommentElement","velt","window","Velt","error","catchError","addManualComment","context","location","commentElement","updateContext","annotationId","subscribeToSelectedCommentsMap","id","subscriber","subscribeToSelectedAnnotationsMapSingleton","set","unsubscribeFromSelectedCommentsMap","delete","message","otherProperties","_b","properties","Object","assign","sdkVersion","version","getSelectedComments","subscribe","comments","forEach","comment","map1","map2","size","key","get","areMapsEqual","updateSelectedCommentsMap","EditorService","constructor","plugin","this","getSelectedText","editor","selection","Editor","string","err","findOccurrenceOfText","options","searchText","scopeElement","startOffset","caseSensitive","total","position","fullText","textContent","searchMethod","text","toLowerCase","processedFullText","processedSearchText","occurrences","lastIndex","matchIndex","indexOf","push","length","positionBeforeSelected","filter","index","findOccurrenceOfSelectedText","selectedText","occurrence","allMatches","findAllMatches","findIndex","match","anchor","path","toString","focus","offset","domSelection","ReactEditor","toDOMNode","textToSearch","matches","getText","node","isTextNode","searchInNode","nodeText","range","Array","isArray","children","child","initialNode","nodes","at","mode","findParentNodeWithIdForSelection","Node","findParentNodeWithId","domNode","editorDOM","maxIterations","idPattern","currentNode","iterationCount","document","body","contains","test","parentElement","removeVeltCommentFromEditor","Error","elementsToUnwrap","descendants","isVeltCommentText","reverse","nodeAtPath","elementAtNode","isConnected","unwrapNodes","Transforms","HistoryEditor","getHistoryEditor","withoutSaving","highlightTextWithVeltComment","annotation","targetTextNodeId","textEditorConfig","injectTag","storeService","annotationStore","getEditorTextContent","map","join","onSlateValueChange","annotationsToCheck","collectDocumentAnnotations","changedAnnotations","from","pos","start","changes","processAnnotationChanges","updateVeltComments","targetElementId","targetElement","getElementById","isElementInEditor","findTextOccurrence","wrapNodes","type","split","storedData","_c","_d","targetNode","targetPath","annotatedNodes","currentText","currentTargetNode","undefined","currentTargetNodeId","containerNode","containerPath","toSlateNode","findPath","currentOccurrence","findTextOccurrenceOfNode","nodeOccurrencePosition","textChanged","occurrenceChanged","targetTextNodeIdChanged","contentChanged","originalOccurrence","originalText","originalTargetTextNodeId","newTargetTextNodeId","multiThreadAnnotationId","changeData","entries","JSON","parse","stringify","remove","element","traverseNodesForText","currentPath","textNodePositions","Text","isText","end","SlateElement","Element","isElement","i","childPath","collectSubtreeText","regex","RegExp","replace","exec","matchStart","matchEnd","anchorNodeInfo","focusNodeInfo","nodePosition","findAllTextOccurrences","processText","n","p","searchAt","Path","isDescendant","equals","processedNodeText","startPoint","endPoint","substring","nodePath","trim","totalOccurrences","textOccurrences","reactError","isEqual","isAncestor","setHistoryEditor","historyEditor","getEditorId","closest","getAttribute","StoreService","globalStore","filteredComments","globalAnnotationStore","data","getAll","clear","updateGlobalStore","store","newSelectedCommentsMap","oldFilteredComments","status","newAnnotationIds","Set","has","editorService","highlightCommentsFromGlobalStore","editorId","storeInstanceMap","instanceMap","Plugin","previousEditorTextContent","setPreviousEditorTextContent","getInstance","config","getPreviousEditorTextContent","addComment","clientContext","targetTextNode","locationId","setTimeout","renderComments","commentAnnotations","currentEditorTextContent","props","attributes","React","createElement","isInline","isVoid","onChange","operations","some","operation","Operation","isTextOperation"],"mappings":"gFAkHO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,KAAKR,EAAWK,EAAY,CAC9GH,GAAMN,EAAYA,EAAUa,MAAMhB,EAASC,GAAc,KAAKS,OACtE,GACA,CA8MkD,mBAApBO,iBAAiCA,gBCxUxD,MAAMC,EACG,CACRC,UAAW,iBACXC,YAAa,yBAHRF,EAKK,CACVG,aAAc,eCNtB,IAAIC,EACG,MAAMC,GAEbD,EAAKC,EACLA,EAAYC,oBAAsB,IAAIC,IACtCF,EAAYG,YAAc,IAAID,IAC9BF,EAAYI,cAAe,EAE3BJ,EAAYK,kBAAoB,KAC5B,IACI,MAAMC,EAAOC,OAAOC,KACpB,OAAIF,aAAmC,EAASA,EAAKD,mBAC1CC,EAAKD,oBAET,IACV,CACD,MAA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AGEA,CAAM","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/constants/common.ts","../../src/utils/common.ts","../../src/utils/console.ts","../../src/adapters/host/doc.ts","../../src/adapters/host/marks.ts","../../src/core/state.ts","../../src/core/registry.ts","../../node_modules/tslib/tslib.es6.js","../../src/adapters/velt.ts","../../src/features/updateContent.ts","../../src/core/extension.ts","../../src/adapters/host/storage.ts","../../src/features/commentRenderer.ts","../../src/features/renderComments.ts","../../src/utils/serializer.ts","../../src/core/ExtensionComponent.tsx","../../src/features/addComment.ts"],"sourcesContent":["/**\n * Shared constants for Slate-Velt Comments integration\n *\n * This module contains all magic strings and configuration constants\n * used across the application.\n */\nexport const Constants = {\n /**\n * DOM attribute names used for editor identification and location tracking.\n */\n ATTRIBUTES: {\n EDITOR_ID: 'data-editor-id',\n LOCATION_ID: 'data-velt-location-id',\n ANNOTATION_ID: 'annotation-id',\n MULTI_THREAD_ANNOTATION_ID: 'multi-thread-annotation-id',\n },\n /**\n * Element types used in the editor's document model.\n */\n ELEMENT_TYPE: {\n VELT_COMMENT: 'veltComment',\n },\n /**\n * Mark/extension name constant.\n * Generic constant name, value is Slate-specific for this package.\n */\n MARK_NAME: 'veltComment',\n /**\n * Storage key constant.\n * Generic constant name, value is Slate-specific for this package.\n */\n STORAGE_KEY: 'slateVeltComments',\n /**\n * Default extension name for error messages.\n */\n DEFAULT_EXTENSION_NAME: 'VeltComments',\n /**\n * Default editor ID used when no editor ID is provided.\n * Uses '__default__' to avoid collision with user-provided values.\n */\n DEFAULT_EDITOR_ID: '__default__',\n /**\n * Terminal status type for resolved/closed comments.\n */\n STATUS_TERMINAL: 'terminal',\n /**\n * Log prefix for console messages.\n */\n LOG_PREFIX: 'SlateVeltComments: ',\n /**\n * Session storage key for debug mode.\n */\n DEBUG_MODE_KEY: 'debugMode',\n /**\n * Session storage key for forced debug mode.\n */\n FORCE_DEBUG_MODE_KEY: 'forceDebugMode',\n};\n","/**\n * Pure utility functions with zero side effects.\n * These functions contain algorithmic logic extracted from legacy code.\n *\n * IMPORTANT: This module MUST NOT import any external SDKs or have side effects.\n * All functions must be pure: input → output, deterministic, no mutations.\n */\n/**\n * Computes the KMP (Knuth-Morris-Pratt) failure function (LPS array).\n * This is used for efficient pattern matching in text search.\n *\n * @param pattern The pattern string to compute the failure function for\n * @returns Longest proper prefix array (LPS array)\n *\n * @example\n * ```typescript\n * const lps = computeKMPTable(\"abcabc\");\n * // Returns: [0, 0, 0, 1, 2, 3]\n * ```\n */\nexport const computeKMPTable = (pattern) => {\n if (!pattern || pattern.length === 0) {\n return [];\n }\n const lps = new Array(pattern.length).fill(0);\n let len = 0;\n let i = 1;\n while (i < pattern.length) {\n if (pattern[i] === pattern[len]) {\n len++;\n lps[i] = len;\n i++;\n }\n else {\n if (len !== 0) {\n len = lps[len - 1];\n }\n else {\n lps[i] = 0;\n i++;\n }\n }\n }\n return lps;\n};\n/**\n * Finds all occurrences of a pattern in text using the KMP algorithm.\n *\n * @param text The text to search in\n * @param pattern The pattern to search for\n * @param startPos Starting position offset (default: 0)\n * @param maxOccurrences Maximum number of occurrences to find (optional)\n * @returns Array of start positions (0-based indices in the text)\n *\n * @example\n * ```typescript\n * const positions = kmpSearch(\"abcabcabc\", \"abc\", 0, 2);\n * // Returns: [0, 3] (first 2 occurrences)\n * ```\n */\nexport const kmpSearch = (text, pattern, startPos = 0, maxOccurrences) => {\n const positions = [];\n if (!pattern || !text || pattern.length > text.length) {\n return positions;\n }\n const lps = computeKMPTable(pattern);\n let i = 0;\n let j = 0;\n while (i < text.length) {\n if (pattern[j] === text[i]) {\n i++;\n j++;\n }\n if (j === pattern.length) {\n positions.push(startPos + i - j);\n j = lps[j - 1];\n if (maxOccurrences && positions.length >= maxOccurrences) {\n break;\n }\n }\n else if (i < text.length && pattern[j] !== text[i]) {\n if (j !== 0) {\n j = lps[j - 1];\n }\n else {\n i++;\n }\n }\n }\n return positions;\n};\n/**\n * Maps text positions in a combined string back to document positions.\n * Used when searching across multiple text nodes that have been concatenated.\n *\n * @param textNodes Array of text nodes with their document positions\n * @param textPositions Positions in the combined text (from kmpSearch)\n * @param patternLength Length of the pattern being searched for\n * @returns Array of { from, to } ranges in document coordinates\n *\n * @example\n * ```typescript\n * const textNodes = [\n * { text: \"Hello \", pos: 0 },\n * { text: \"World\", pos: 6 }\n * ];\n * const positions = [0]; // Found at start of combined text\n * const ranges = mapTextPositionsToDocument(textNodes, positions, 5);\n * // Returns: [{ from: 0, to: 5 }]\n * ```\n */\nexport const mapTextPositionsToDocument = (textNodes, textPositions, patternLength) => {\n const ranges = [];\n for (const textPos of textPositions) {\n let currentPos = 0;\n let startNodeIndex = -1;\n let startOffset = 0;\n let endNodeIndex = -1;\n let endOffset = 0;\n // Find the start and end nodes for this match\n for (let i = 0; i < textNodes.length; i++) {\n const node = textNodes[i];\n const nodeLength = node.text.length;\n // Check if this node contains the start of the match\n if (startNodeIndex === -1 && textPos < currentPos + nodeLength) {\n startNodeIndex = i;\n startOffset = textPos - currentPos;\n }\n // Check if this node contains the end of the match\n if (endNodeIndex === -1 && textPos + patternLength <= currentPos + nodeLength) {\n endNodeIndex = i;\n endOffset = textPos + patternLength - currentPos;\n break;\n }\n currentPos += nodeLength;\n }\n // If we found both start and end nodes, create the range\n if (startNodeIndex !== -1 && endNodeIndex !== -1) {\n const startPos = textNodes[startNodeIndex].pos + startOffset;\n const endPos = textNodes[endNodeIndex].pos + endOffset;\n ranges.push({ from: startPos, to: endPos });\n }\n }\n return ranges;\n};\n/**\n * Compares two maps for equality.\n * Checks if both maps have the same size and identical key-value pairs.\n *\n * @param map1 First map to compare\n * @param map2 Second map to compare\n * @returns True if maps are equal, false otherwise\n *\n * @example\n * ```typescript\n * const map1 = new Map([['a', true], ['b', false]]);\n * const map2 = new Map([['a', true], ['b', false]]);\n * areMapsEqual(map1, map2); // Returns: true\n * ```\n */\nexport const areMapsEqual = (map1, map2) => {\n if (map1.size !== map2.size)\n return false;\n for (const [key, value] of Array.from(map1)) {\n if (map2.get(key) !== value)\n return false;\n }\n return true;\n};\n","import { Constants } from '@/constants/common';\nexport class Console {\n static showLogs() {\n try {\n return !!sessionStorage.getItem(Constants.DEBUG_MODE_KEY) || !!sessionStorage.getItem(Constants.FORCE_DEBUG_MODE_KEY);\n }\n catch (err) {\n Console.catch('Error in showLogs: ', err);\n return false;\n }\n }\n}\nConsole.log = Console.showLogs() ? console.log : () => { };\nConsole.warn = Console.showLogs() ? console.warn : () => { };\nConsole.error = Console.showLogs() ? console.error : () => { };\nConsole.debug = Console.showLogs() ? console.debug : () => { };\nConsole.info = Console.showLogs() ? console.info : () => { };\nConsole.logsEnabled = true;\n// to show error catched in try catch\nConsole.catch = (message, error) => {\n try {\n if (Console.logsEnabled) {\n if (error !== undefined) {\n console.warn(Constants.LOG_PREFIX, message, error);\n }\n else {\n console.warn(Constants.LOG_PREFIX, message);\n }\n }\n }\n catch (err) {\n // do nothing\n }\n};\n","/**\n * Host editor document operations adapter.\n * This is the ONLY place where editor-specific types may be imported.\n *\n * Responsibilities:\n * - Extract selection context from editor\n * - Find text occurrences in document\n * - Detect document changes for annotations\n * - Get editor ID from DOM\n *\n * Architectural Rules:\n * - MAY import editor-specific types (Editor, Node, Range, etc.)\n * - MUST NOT import Velt SDK types\n * - Uses pure utilities from utils/common.ts where possible\n */\nimport { Editor, Element as SlateElement, Node, Path } from 'slate';\nimport { ReactEditor as ReactEditorImpl } from 'slate-react';\nimport { Constants } from '@/constants/common';\nimport { kmpSearch } from '@/utils/common';\nimport { Console } from '@/utils/console';\n/**\n * Gets editor ID from editor instance by traversing DOM.\n * Returns null if editor ID attribute not found.\n */\nexport const getEditorId = (editor) => {\n var _a, _b;\n try {\n // Get the DOM node representing the editor\n // This will fail if editor is not mounted yet (expected during initial creation)\n const domNode = ReactEditorImpl.toDOMNode(editor, editor);\n if (domNode) {\n return ((_b = (_a = domNode === null || domNode === void 0 ? void 0 : domNode.closest(`[${Constants.ATTRIBUTES.EDITOR_ID}]`)) === null || _a === void 0 ? void 0 : _a.getAttribute(Constants.ATTRIBUTES.EDITOR_ID)) !== null && _b !== void 0 ? _b : null);\n }\n // No parent with data-editor-id found\n return null;\n }\n catch (error) {\n // Editor not mounted yet - this is expected during initial editor creation\n // Return null silently, the editorId will be resolved when editor is mounted\n // or a default will be used by the extension\n return null;\n }\n};\n/**\n * Gets current selection context from editor with full details.\n * Returns null if no selection or selection is collapsed.\n */\nexport const getCurrentSelectionContext = (editor) => {\n var _a;\n try {\n // Ensure there's a selection\n if (!editor.selection) {\n return null;\n }\n // Get selected text\n const text = Editor.string(editor, editor.selection);\n if (!text) {\n return null;\n }\n // Calculate start and end positions\n const from = Editor.start(editor, editor.selection).offset;\n const to = Editor.end(editor, editor.selection).offset;\n // Find parent node with ID for targetTextNodeId\n const targetTextNode = findParentNodeWithId(editor);\n const targetTextNodeId = targetTextNode === null || targetTextNode === void 0 ? void 0 : targetTextNode.id;\n // Find location ID from DOM\n let locationId;\n if (targetTextNode) {\n locationId =\n ((_a = targetTextNode\n .closest(`[${Constants.ATTRIBUTES.LOCATION_ID}]`)) === null || _a === void 0 ? void 0 : _a.getAttribute(Constants.ATTRIBUTES.LOCATION_ID)) || undefined;\n }\n // Find occurrence index\n const occurrence = findOccurrenceIndex(editor, text, targetTextNodeId);\n return {\n text,\n from,\n to,\n occurrence,\n targetTextNodeId,\n locationId,\n };\n }\n catch (error) {\n Console.catch('[HostAdapter] Error getting selection context:', error);\n return null;\n }\n};\n/**\n * Finds occurrence index of selected text in the document.\n * Returns 1-based occurrence index, or 0 if not found.\n */\nexport const findOccurrenceIndex = (editor, text, targetTextNodeId) => {\n try {\n if (!text || !editor.selection) {\n return 0;\n }\n // If targetTextNodeId is provided, find occurrences within that node\n if (targetTextNodeId) {\n const targetElement = document.getElementById(targetTextNodeId);\n if (targetElement) {\n // Use DOM-based occurrence finding for scoped search\n const startOffset = editor.selection.anchor.offset;\n return findOccurrenceInDOM(targetElement, text, startOffset);\n }\n }\n // Find all matches in the document\n const allMatches = findAllMatches(editor, text);\n const selection = editor.selection;\n if (!selection || allMatches.length === 0) {\n return 0;\n }\n // Check if selection is forward or backward\n const isBackward = Path.compare(selection.anchor.path, selection.focus.path) > 0 ||\n (Path.equals(selection.anchor.path, selection.focus.path) &&\n selection.anchor.offset > selection.focus.offset);\n // Find matching occurrence\n const matchIndex = allMatches.findIndex((match) => {\n if (isBackward) {\n return (Path.equals(match.anchor.path, selection.focus.path) &&\n Path.equals(match.focus.path, selection.anchor.path) &&\n match.anchor.offset === selection.focus.offset &&\n match.focus.offset === selection.anchor.offset);\n }\n else {\n return (Path.equals(match.anchor.path, selection.anchor.path) &&\n Path.equals(match.focus.path, selection.focus.path) &&\n match.anchor.offset === selection.anchor.offset &&\n match.focus.offset === selection.focus.offset);\n }\n });\n return matchIndex !== -1 ? matchIndex + 1 : 0;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding occurrence index:', error);\n return 0;\n }\n};\n/**\n * Finds all text occurrences in the document.\n * Returns array of ranges matching the search text.\n */\nexport const findTextOccurrences = (editor, text, targetTextNodeId, occurrence) => {\n try {\n if (!text) {\n return [];\n }\n // Find all matches using editor traversal\n const ranges = findAllMatches(editor, text);\n // Convert ranges to OccurrenceMatch format\n const matches = ranges.map((range, index) => {\n const start = Editor.start(editor, range).offset;\n const end = Editor.end(editor, range).offset;\n return {\n index: index + 1, // 1-based\n start,\n end,\n text,\n };\n });\n // Filter by occurrence if specified\n if (occurrence !== undefined && occurrence > 0) {\n const match = matches[occurrence - 1];\n return match ? [match] : [];\n }\n return matches;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding text occurrences:', error);\n return [];\n }\n};\n/**\n * Finds parent node with ID attribute for current selection.\n * Returns HTMLElement with ID, or null if not found.\n */\nexport const findParentNodeWithId = (editor) => {\n try {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n const { anchor } = selection;\n const node = Node.get(editor, anchor.path);\n return findParentNodeWithIdFromNode(editor, node, anchor.path);\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding parent node with ID:', error);\n return null;\n }\n};\n/**\n * Helper: Finds parent node with ID from a given node.\n */\nconst findParentNodeWithIdFromNode = (editor, node, path, maxIterations = 100) => {\n try {\n let domNode = null;\n let editorDOM = null;\n try {\n // Convert Slate node to DOM node\n domNode = ReactEditorImpl.toDOMNode(editor, node);\n }\n catch (err) {\n return null;\n }\n try {\n // Get the editor's DOM element\n editorDOM = ReactEditorImpl.toDOMNode(editor, editor);\n }\n catch (err) {\n return null;\n }\n let currentNode = domNode;\n let iterationCount = 0;\n while (currentNode && currentNode !== document.body && iterationCount < maxIterations) {\n // Check if we're still within the editor's DOM\n if (!editorDOM.contains(currentNode)) {\n return null;\n }\n // Check if current node has an ID\n if (currentNode.id) {\n return currentNode;\n }\n currentNode = currentNode.parentElement;\n iterationCount++;\n }\n return null;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding parent node:', error);\n return null;\n }\n};\n/**\n * Helper: Finds occurrence index for a given node and text.\n * This matches the legacy findTextOccurrenceOfNode approach exactly:\n * 1. Find all occurrences of the text in the document (or container)\n * 2. Match the node's path against occurrence paths using Path.equals or Path.isAncestor\n * 3. Return the matching occurrence index (1-based)\n *\n * This is simpler and more reliable than range-based comparison.\n */\nconst findOccurrenceForNode = (editor, text, node, path, targetTextNodeId) => {\n try {\n if (!text) {\n return 0;\n }\n const nodeText = Node.string(node);\n if (!nodeText || !nodeText.trim()) {\n return 0;\n }\n // Find container node if targetTextNodeId is provided (matching legacy logic)\n let containerNode;\n let containerPath;\n if (targetTextNodeId) {\n const targetElement = document.getElementById(targetTextNodeId);\n if (targetElement) {\n try {\n containerNode = ReactEditorImpl.toSlateNode(editor, targetElement);\n containerPath = ReactEditorImpl.findPath(editor, containerNode);\n }\n catch (error) {\n Console.warn('[findOccurrenceForNode] Could not find container node:', error);\n }\n }\n }\n // Find all occurrences of the text in the document\n // Use findAllMatches which returns ranges with paths\n const allMatches = findAllMatches(editor, text);\n if (allMatches.length === 0) {\n return 0;\n }\n // Filter matches by container if provided (matching legacy findAllTextOccurrences logic)\n let matchesToCheck = allMatches;\n if (containerPath) {\n matchesToCheck = allMatches.filter((match) => {\n const matchStart = Editor.start(editor, match);\n // Check if match is within container by checking if container path is ancestor\n return Path.isAncestor(containerPath, matchStart.path) || Path.equals(containerPath, matchStart.path);\n });\n }\n if (matchesToCheck.length === 0) {\n return 0;\n }\n // Find which occurrence matches the node's path\n // Match using Path.equals or Path.isAncestor (matching legacy logic exactly)\n // Legacy code: const isEqual = Path.equals(occurrence.path, nodePath);\n // const isDescendant = Path.isAncestor(nodePath, occurrence.path);\n for (let i = 0; i < matchesToCheck.length; i++) {\n const match = matchesToCheck[i];\n const matchStart = Editor.start(editor, match);\n const matchPath = matchStart.path;\n // Check path relationships (matching legacy logic)\n const isEqual = Path.equals(matchPath, path);\n const isDescendant = Path.isAncestor(path, matchPath);\n if (isEqual || isDescendant) {\n // Found the matching occurrence, return 1-based index\n // Need to map back to original allMatches index to get correct occurrence number\n const originalIndex = allMatches.indexOf(match);\n return originalIndex !== -1 ? originalIndex + 1 : i + 1;\n }\n }\n // If no match found, return 0 (matching legacy behavior)\n Console.warn('[findOccurrenceForNode] No matching occurrence found for text:', text, 'node path:', path);\n return 0;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding occurrence for node:', error);\n return 0;\n }\n};\n/**\n * Helper: Finds all matches of text in the document using KMP algorithm.\n */\nconst findAllMatches = (editor, textToSearch, caseSensitive = true) => {\n try {\n const matches = [];\n if (!textToSearch) {\n return matches;\n }\n // Safely get text from a node\n const getText = (node) => {\n return typeof node === 'object' && node !== null && 'text' in node ? node.text : '';\n };\n // Check if a node is a text node\n const isTextNode = (node) => {\n return (typeof node === 'object' &&\n node !== null &&\n 'text' in node &&\n typeof node.text === 'string');\n };\n // Iterate through all text nodes in the document\n const searchInNode = (node, path) => {\n // Handle text nodes\n if (isTextNode(node)) {\n const text = getText(node);\n // Apply case sensitivity\n const searchText = caseSensitive ? textToSearch : textToSearch.toLowerCase();\n const nodeText = caseSensitive ? text : text.toLowerCase();\n // Use KMP algorithm to find all matches in the current text node\n const positions = kmpSearch(nodeText, searchText);\n // Create ranges for each match\n for (const index of positions) {\n const range = {\n anchor: { path, offset: index },\n focus: { path, offset: index + textToSearch.length },\n };\n matches.push(range);\n }\n }\n // Recursively search child nodes\n if ('children' in node && Array.isArray(node.children)) {\n node.children.forEach((child, index) => {\n searchInNode(child, [...path, index]);\n });\n }\n };\n // Start the search from the root of the document\n try {\n const [initialNode] = Editor.nodes(editor, {\n at: [],\n mode: 'highest',\n });\n if (initialNode) {\n searchInNode(initialNode[0], initialNode[1]);\n }\n }\n catch (error) {\n Console.catch('[HostAdapter] Error searching in document:', error);\n }\n return matches;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding all matches:', error);\n return [];\n }\n};\n/**\n * Helper: Finds occurrence in DOM element using KMP algorithm (for scoped searches).\n */\nconst findOccurrenceInDOM = (element, searchText, startOffset, caseSensitive = true) => {\n try {\n if (!searchText) {\n return 0;\n }\n const fullText = element.textContent || '';\n const processedFullText = caseSensitive ? fullText : fullText.toLowerCase();\n const processedSearchText = caseSensitive ? searchText : searchText.toLowerCase();\n // Use KMP algorithm to find all occurrences\n const occurrences = kmpSearch(processedFullText, processedSearchText);\n if (occurrences.length === 0) {\n return 0;\n }\n // Calculate position (1-based)\n if (startOffset !== undefined) {\n const positionBeforeSelected = occurrences.filter((index) => index < startOffset).length + 1;\n return positionBeforeSelected;\n }\n return 1; // Default to first occurrence\n }\n catch (error) {\n Console.catch('[HostAdapter] Error finding occurrence in DOM:', error);\n return 0;\n }\n};\n/**\n * Detects document changes for annotations.\n * Compares current document state with stored annotation data.\n */\nexport const detectDocumentChanges = (editor, transaction, markType = Constants.MARK_NAME, getAnnotationData) => {\n const logPrefix = '[detectDocumentChanges]';\n const changes = new Map();\n try {\n // Collect all annotation nodes in the document\n const annotationNodes = Array.from(Editor.nodes(editor, {\n at: [],\n match: (node) => {\n return (SlateElement.isElement(node) &&\n node.type === Constants.ELEMENT_TYPE.VELT_COMMENT &&\n 'annotationId' in node);\n },\n mode: 'lowest',\n }));\n for (const [node, path] of annotationNodes) {\n const veltNode = node;\n const annotationId = veltNode.annotationId;\n if (!annotationId) {\n Console.warn(`${logPrefix} Node missing annotationId, skipping`);\n continue;\n }\n // Get stored annotation data\n const storedData = getAnnotationData(annotationId);\n if (!storedData) {\n Console.warn(`${logPrefix} No stored data found for annotationId: ${annotationId}, skipping`);\n continue;\n }\n const originalText = storedData.originalText;\n const originalOccurrence = storedData.originalOccurrence;\n const originalTargetTextNodeId = storedData.targetTextNodeId || '';\n // Extract current text from node\n const currentText = Node.string(node);\n if (!currentText) {\n Console.warn(`${logPrefix} Node has no text content, skipping`);\n continue;\n }\n // Find parent node with ID\n const currentTargetNode = findParentNodeWithIdFromNode(editor, node, path);\n const currentTargetNodeId = (currentTargetNode === null || currentTargetNode === void 0 ? void 0 : currentTargetNode.id) || '';\n // Calculate current occurrence\n // We need to find which occurrence this text represents in the document\n // Since we don't have a selection, we'll use a helper function\n const currentOccurrence = findOccurrenceForNode(editor, currentText, node, path, currentTargetNodeId);\n // Detect changes\n const textChanged = currentText !== originalText;\n const occurrenceChanged = currentOccurrence !== originalOccurrence;\n const targetTextNodeIdChanged = originalTargetTextNodeId !== currentTargetNodeId;\n if (textChanged || occurrenceChanged || targetTextNodeIdChanged) {\n const annotation = storedData.annotation;\n changes.set(annotationId, {\n annotationId,\n multiThreadAnnotationId: annotation.multiThreadAnnotationId,\n originalText,\n currentText,\n originalOccurrence,\n currentOccurrence,\n originalTargetTextNodeId,\n newTargetTextNodeId: currentTargetNodeId,\n annotation,\n contentChanged: textChanged,\n occurrenceChanged,\n targetTextNodeIdChanged,\n });\n }\n }\n }\n catch (error) {\n Console.catch('[HostAdapter] Error detecting document changes:', error);\n }\n return changes;\n};\n/**\n * Ensures editor is set up (registered and document listeners configured).\n * This is a unified adapter function that handles both registration and setup.\n *\n * @param editorId Optional editor ID (will be resolved from editor if not provided)\n * @param editor The editor instance (typed as unknown to avoid importing editor types in feature modules)\n * @returns Object with editorId string\n *\n * @remarks\n * - This function abstracts editor-specific setup logic\n * - For Slate, just resolves editor ID (document listeners are handled by extension)\n * - Fails silently if setup fails\n */\nexport const ensureEditorSetup = (editorId, editor) => {\n const logPrefix = '[ensureEditorSetup]';\n try {\n // Resolve editor ID if not provided\n let finalEditorId = editorId;\n if (!finalEditorId) {\n finalEditorId = getEditorId(editor) || 'default';\n }\n // Note: For Slate, document change listeners are handled by the extension\n // No additional setup needed here\n return { editorId: finalEditorId };\n }\n catch (error) {\n Console.warn(`${logPrefix} Error setting up editor:`, error);\n return { editorId: editorId || 'default' };\n }\n};\n/**\n * Resets the editor selection by focusing the editor.\n * Uses Slate's selection API to reset selection/focus after comment operations.\n *\n * @param editor The editor instance (typed as unknown to avoid importing editor types in feature modules)\n * @returns void\n *\n * @remarks\n * - This function abstracts editor-specific selection reset logic\n * - For Slate, selection reset is handled by the editor itself\n * - Fails silently if reset fails\n */\nexport const resetEditorSelection = (editor) => {\n const logPrefix = '[resetEditorSelection]';\n try {\n // For Slate, selection reset is typically handled by the editor itself\n // after comment creation, so we don't need to do anything here\n // This matches the comment in the original Slate addComment.ts:\n // \"Note: Editor selection reset is handled by the editor itself after comment creation\"\n }\n catch (error) {\n Console.warn(`${logPrefix} Error resetting selection:`, error);\n }\n};\n","/**\n * Host editor marks/nodes operations adapter.\n * This is the ONLY place where editor-specific mark/node operations may be implemented.\n *\n * Responsibilities:\n * - Apply comment marks/nodes to editor\n * - Remove comment marks/nodes from editor\n * - Update marks/nodes when document changes\n *\n * Architectural Rules:\n * - MAY import editor-specific types (Editor, Element, Transforms, etc.)\n * - MUST NOT import Velt SDK types\n * - Handles editor-specific mark/node application logic\n */\nimport { Editor, Element, Node, Text, Transforms } from 'slate';\nimport { ReactEditor as ReactEditorImpl } from 'slate-react';\nimport { Constants } from '@/constants/common';\nimport { Console } from '@/utils/console';\n/**\n * History editor type (if available from extension config).\n * Used to wrap operations without saving to history.\n * This is editor-specific and may vary, so we use unknown.\n */\nlet HistoryEditor = null;\n/**\n * Sets the history editor instance (called from extension).\n */\nexport const setHistoryEditor = (historyEditor) => {\n HistoryEditor = historyEditor;\n};\n/**\n * Gets the history editor instance.\n */\nexport const getHistoryEditor = () => {\n return HistoryEditor;\n};\n/**\n * Checks if a node is a Velt comment element.\n */\nconst isVeltCommentText = (element) => {\n return Element.isElement(element) && element.type === Constants.ELEMENT_TYPE.VELT_COMMENT;\n};\n/**\n * Internal function that applies annotation mark/node to editor at specified range.\n * Wraps text range with comment element/node.\n */\nconst applyAnnotationMarkWithRange = (editor, annotationId, multiThreadAnnotationId, range) => {\n try {\n if (!range) {\n return false;\n }\n // Check if the range is already wrapped with a velt-comment-text element\n const isAlreadyWrapped = Array.from(Editor.nodes(editor, {\n at: range,\n match: (node) => {\n if (!Element.isElement(node)) {\n return false;\n }\n return isVeltCommentText(node);\n },\n })).length > 0;\n if (isAlreadyWrapped) {\n return false;\n }\n // Wrap nodes with comment element\n const wrapNodes = () => {\n Transforms.wrapNodes(editor, {\n type: Constants.ELEMENT_TYPE.VELT_COMMENT,\n children: [],\n annotationId: annotationId,\n multiThreadAnnotationId: multiThreadAnnotationId,\n }, { at: range, split: true });\n };\n // Use history editor if available to wrap without saving to history\n if (HistoryEditor && typeof HistoryEditor.withoutSaving === 'function') {\n HistoryEditor.withoutSaving(editor, () => {\n wrapNodes();\n });\n }\n else {\n wrapNodes();\n }\n return true;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error applying annotation mark:', error);\n return false;\n }\n};\n/**\n * Applies annotation mark/node by finding text occurrence and wrapping it.\n * This is the main entry point for applying marks.\n *\n * @param editor The editor instance (typed as unknown to avoid importing editor types in feature modules)\n * @param textToSearch The text to search for\n * @param occurrence The occurrence number (1-based)\n * @param annotationId The annotation ID to mark\n * @param multiThreadAnnotationId Optional multi-thread annotation ID\n * @param targetElementId Optional target element ID to scope the search\n * @returns True if mark was successfully applied, false otherwise\n */\nexport const applyAnnotationMarkByText = (editor, textToSearch, occurrence, annotationId, multiThreadAnnotationId, targetElementId) => {\n const logPrefix = '[applyAnnotationMarkByText]';\n try {\n if (!editor || !annotationId) {\n return false;\n }\n const slateEditor = editor;\n // Find target element\n let targetElement = null;\n if (targetElementId) {\n targetElement = document.getElementById(targetElementId);\n // Validate target element\n if (!targetElement) {\n Console.warn(`${logPrefix} Target element not found: ${targetElementId}`);\n return false;\n }\n // Ensure the element is part of the editor\n if (!isElementInEditor(slateEditor, targetElement)) {\n Console.warn(`${logPrefix} Target element not in editor: ${targetElementId}`);\n return false;\n }\n }\n else {\n targetElement = ReactEditorImpl.toDOMNode(slateEditor, slateEditor);\n }\n if (!targetElement) {\n Console.warn(`${logPrefix} No target element found`);\n return false;\n }\n // Find the range for the specific text occurrence\n const range = findTextOccurrenceRange(slateEditor, textToSearch, occurrence, targetElement);\n if (!range) {\n Console.warn(`${logPrefix} Could not find text occurrence range for \"${textToSearch}\" occurrence ${occurrence}`);\n return false;\n }\n // Apply mark directly with range instead of converting to from/to\n return applyAnnotationMarkWithRange(slateEditor, annotationId, multiThreadAnnotationId, range);\n }\n catch (error) {\n Console.catch(`${logPrefix} Error applying annotation mark by text:`, error);\n return false;\n }\n};\n/**\n * Removes annotation mark/node from editor by annotation ID.\n * Finds all nodes with matching annotationId and unwraps them.\n */\nexport const removeAnnotationMark = (editor, annotationId) => {\n try {\n if (!editor || !annotationId) {\n return false;\n }\n // Create an array to store paths of elements to remove\n const elementsToUnwrap = [];\n // Iterate through all nodes in the editor\n for (const [node, path] of Node.descendants(editor)) {\n // Check if the node is a Velt comment element with matching annotationId\n if (Element.isElement(node) &&\n isVeltCommentText(node) &&\n node.annotationId === annotationId) {\n elementsToUnwrap.push(path);\n }\n }\n // Unwrap elements in reverse order to avoid path shifting issues\n try {\n elementsToUnwrap.reverse().forEach((path) => {\n const nodeAtPath = Node.get(editor, path);\n const elementAtNode = ReactEditorImpl.toDOMNode(editor, nodeAtPath);\n if (elementAtNode === null || elementAtNode === void 0 ? void 0 : elementAtNode.isConnected) {\n const unwrapNodes = () => {\n Transforms.unwrapNodes(editor, {\n at: path,\n mode: 'lowest',\n });\n };\n // Use history editor if available\n if (HistoryEditor && typeof HistoryEditor.withoutSaving === 'function') {\n HistoryEditor.withoutSaving(editor, () => {\n unwrapNodes();\n });\n }\n else {\n unwrapNodes();\n }\n }\n });\n }\n catch (err) {\n Console.catch('[HostAdapter] Error unwrapping elements:', err);\n }\n return true;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error removing annotation mark:', error);\n return false;\n }\n};\n/**\n * Updates marks/nodes based on document changes.\n * Removes old marks and applies new ones at updated positions.\n */\nexport const updateMarks = (editor, changes) => {\n try {\n for (const [annotationId, change] of changes) {\n // Remove old mark\n removeAnnotationMark(editor, annotationId);\n // TODO: Re-apply mark at new position if needed\n // This requires the full annotation data to rebuild the mark\n // For now, just remove - re-application will happen via renderComments\n }\n }\n catch (error) {\n Console.catch('[HostAdapter] Error updating marks:', error);\n }\n};\n/**\n * Helper: Checks if element is within editor DOM.\n */\nconst isElementInEditor = (editor, element) => {\n try {\n const editorElement = ReactEditorImpl.toDOMNode(editor, editor);\n return editorElement.contains(element);\n }\n catch (error) {\n Console.catch('[HostAdapter] Error checking element in editor:', error);\n return false;\n }\n};\n/**\n * Helper: Finds text occurrence range in editor.\n * Converts DOM element to Slate range for the specified occurrence.\n */\nconst findTextOccurrenceRange = (editor, textToSearch, occurrence, targetElement) => {\n const logPrefix = '[findTextOccurrenceRange]';\n try {\n // Convert target element to Slate node\n const targetNode = ReactEditorImpl.toSlateNode(editor, targetElement);\n if (!targetNode) {\n Console.warn(`${logPrefix} Could not convert target element to Slate node`);\n return null;\n }\n const targetPath = ReactEditorImpl.findPath(editor, targetNode);\n // Collect all text from the subtree\n const { fullText, textNodePositions } = collectSubtreeText(editor, targetNode, targetPath);\n // Find all matches in the full text\n const matches = [];\n let match;\n const regex = new RegExp(textToSearch.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g');\n while ((match = regex.exec(fullText)) !== null) {\n matches.push({ index: match.index });\n }\n // If we don't have enough occurrences, return null\n if (matches.length < occurrence) {\n Console.warn(`${logPrefix} Not enough occurrences: found ${matches.length}, need ${occurrence}`);\n return null;\n }\n // Get the specific match\n const targetMatch = matches[occurrence - 1];\n // Find which text nodes the match spans\n const matchStart = targetMatch.index;\n const matchEnd = matchStart + textToSearch.length;\n // Find the range that covers this match\n let anchorNodeInfo;\n let focusNodeInfo;\n for (const nodePosition of textNodePositions) {\n // Check for anchor (start of match)\n if (matchStart >= nodePosition.start && matchStart < nodePosition.end && !anchorNodeInfo) {\n anchorNodeInfo = nodePosition;\n }\n // Check for focus (end of match)\n if (matchEnd > nodePosition.start && matchEnd <= nodePosition.end && !focusNodeInfo) {\n focusNodeInfo = nodePosition;\n }\n // If we have both anchor and focus, we can create the range\n if (anchorNodeInfo && focusNodeInfo) {\n const range = {\n anchor: {\n path: anchorNodeInfo.path,\n offset: matchStart - anchorNodeInfo.start,\n },\n focus: {\n path: focusNodeInfo.path,\n offset: matchEnd - focusNodeInfo.start,\n },\n };\n return range;\n }\n }\n Console.warn(`${logPrefix} Could not find anchor/focus nodes for match`);\n return null;\n }\n catch (error) {\n Console.catch(`${logPrefix} Error finding text occurrence range:`, error);\n return null;\n }\n};\n/**\n * Helper: Collects subtree text and maps text node positions.\n */\nconst collectSubtreeText = (editor, node, path) => {\n const textNodePositions = [];\n let fullText = '';\n // Traverse nodes for text\n const traverseNodesForText = (currentNode, currentPath, textNodePositions, fullText) => {\n try {\n if (Text.isText(currentNode)) {\n const start = fullText.length;\n fullText += currentNode.text;\n const end = fullText.length;\n textNodePositions.push({\n node: currentNode,\n path: currentPath,\n start,\n end,\n });\n }\n else if (Element.isElement(currentNode)) {\n // Traverse child nodes\n for (let i = 0; i < currentNode.children.length; i++) {\n const childPath = [...currentPath, i];\n fullText = traverseNodesForText(currentNode.children[i], childPath, textNodePositions, fullText);\n }\n }\n return fullText;\n }\n catch (error) {\n Console.catch('[HostAdapter] Error traversing nodes for text:', error);\n return fullText;\n }\n };\n // Special case for the root node (editor itself)\n if (path.length === 0) {\n // When path is [], we're at the editor root, so traverse all children\n for (let i = 0; i < editor.children.length; i++) {\n const childPath = [i];\n fullText = traverseNodesForText(editor.children[i], childPath, textNodePositions, fullText);\n }\n }\n else {\n // Normal case for non-root nodes\n fullText = traverseNodesForText(node, path, textNodePositions, fullText);\n }\n return { fullText, textNodePositions };\n};\n","/**\n * Core state management module.\n *\n * Purpose: Single source of truth for annotation state per editor.\n * This module manages annotation data and selected annotations for each editor instance.\n *\n * Key responsibilities:\n * - Create and manage per-editor annotation state\n * - CRUD operations for annotations\n * - Track selected annotations\n * - Ensure state isolation between editor instances\n *\n * Dependencies: types/state.ts, types/common.ts\n */\nimport { Console } from '@/utils/console';\n/**\n * Per-editor state storage\n * Maps editorId -> AnnotationState\n */\nconst stateMap = new Map();\n/**\n * Creates a new annotation state for an editor instance.\n *\n * @param editorId Unique identifier for the editor\n * @returns New AnnotationState instance\n */\nexport const createAnnotationState = (editorId) => {\n const state = {\n annotations: new Map(),\n commentAnnotations: [], // Full CommentAnnotation[] with status for rendering\n selectedAnnotations: new Set(),\n editorId,\n };\n stateMap.set(editorId, state);\n return state;\n};\n/**\n * Gets the annotation state for an editor, creating it if it doesn't exist.\n *\n * @param editorId Unique identifier for the editor\n * @returns AnnotationState instance\n */\nconst getOrCreateState = (editorId) => {\n let state = stateMap.get(editorId);\n if (!state) {\n state = createAnnotationState(editorId);\n }\n return state;\n};\n/**\n * Updates annotations in state from Velt SDK data.\n * Converts CommentAnnotation[] to AnnotationData[] and stores them.\n *\n * @param editorId Unique identifier for the editor\n * @param annotations Array of CommentAnnotation from Velt SDK\n */\nexport const updateAnnotations = (editorId, annotations) => {\n try {\n const state = getOrCreateState(editorId);\n // Store full CommentAnnotation[] with status for rendering\n state.commentAnnotations = annotations;\n // Convert CommentAnnotation[] to AnnotationData[] for core logic\n const annotationDataMap = new Map();\n for (const annotation of annotations) {\n if (!(annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)) {\n continue;\n }\n const annotationData = {\n annotationId: annotation.annotationId,\n multiThreadAnnotationId: annotation.multiThreadAnnotationId,\n context: annotation.context,\n // Position will be set when marks are applied\n };\n annotationDataMap.set(annotation.annotationId, annotationData);\n }\n // Update state\n state.annotations = annotationDataMap;\n }\n catch (error) {\n Console.catch('Error updating annotations:', error);\n }\n};\n/**\n * Retrieves a single annotation by ID.\n *\n * @param editorId Unique identifier for the editor\n * @param annotationId The annotation ID to retrieve\n * @returns AnnotationData or null if not found\n */\nexport const getAnnotation = (editorId, annotationId) => {\n try {\n const state = stateMap.get(editorId);\n if (!state) {\n return null;\n }\n return state.annotations.get(annotationId) || null;\n }\n catch (error) {\n Console.catch('Error getting annotation:', error);\n return null;\n }\n};\n/**\n * Removes an annotation from state.\n *\n * @param editorId Unique identifier for the editor\n * @param annotationId The annotation ID to remove\n */\nexport const removeAnnotation = (editorId, annotationId) => {\n try {\n const state = stateMap.get(editorId);\n if (!state) {\n return;\n }\n state.annotations.delete(annotationId);\n state.selectedAnnotations.delete(annotationId);\n }\n catch (error) {\n Console.catch('Error removing annotation:', error);\n }\n};\n/**\n * Gets the set of selected annotation IDs for an editor.\n *\n * @param editorId Unique identifier for the editor\n * @returns Set of selected annotation IDs\n */\nexport const getSelectedAnnotations = (editorId) => {\n try {\n const state = stateMap.get(editorId);\n if (!state) {\n return new Set();\n }\n return new Set(state.selectedAnnotations);\n }\n catch (error) {\n Console.catch('Error getting selected annotations:', error);\n return new Set();\n }\n};\n/**\n * Updates the set of selected annotation IDs for an editor.\n *\n * @param editorId Unique identifier for the editor\n * @param selectedIds Set of selected annotation IDs\n */\nexport const setSelectedAnnotations = (editorId, selectedIds) => {\n try {\n const state = getOrCreateState(editorId);\n state.selectedAnnotations = new Set(selectedIds);\n }\n catch (error) {\n Console.catch('Error setting selected annotations:', error);\n }\n};\n/**\n * Gets all annotations for an editor.\n *\n * @param editorId Unique identifier for the editor\n * @returns Map of annotation ID to AnnotationData\n */\nexport const getAllAnnotations = (editorId) => {\n try {\n const state = stateMap.get(editorId);\n if (!state) {\n return new Map();\n }\n return new Map(state.annotations);\n }\n catch (error) {\n Console.catch('Error getting all annotations:', error);\n return new Map();\n }\n};\n/**\n * Gets all comment annotations for an editor (with status field).\n *\n * @param editorId Unique identifier for the editor\n * @returns Array of CommentAnnotation with status field\n */\nexport const getCommentAnnotations = (editorId) => {\n try {\n const state = stateMap.get(editorId);\n if (!state) {\n return [];\n }\n return [...state.commentAnnotations];\n }\n catch (error) {\n Console.catch('Error getting comment annotations:', error);\n return [];\n }\n};\n/**\n * Clears all state for an editor (used during cleanup).\n *\n * @param editorId Unique identifier for the editor\n */\nexport const clearState = (editorId) => {\n stateMap.delete(editorId);\n};\n","/**\n * Core registry module.\n *\n * Purpose: Maintains a registry mapping editorId → editor context.\n * Replaces the singleton pattern from legacy Plugin class with a proper registry.\n *\n * Key responsibilities:\n * - Register editor instances with their configuration\n * - Retrieve editor contexts by ID\n * - Unregister editors when they're destroyed\n * - Extract editor IDs from editor instances\n *\n * Dependencies: types/common.ts, core/state.ts, adapters/host/doc.ts\n */\nimport { getEditorId } from '@/adapters/host/doc';\nimport { clearState, createAnnotationState } from '@/core/state';\nimport { Console } from '@/utils/console';\n/**\n * Registry mapping editorId -> EditorContext\n */\nconst registry = new Map();\n/**\n * Registers an editor instance in the registry.\n * Creates initial state for the editor.\n *\n * @param editorId Unique identifier for the editor\n * @param editor The editor instance\n * @param config Extension configuration options\n * @returns EditorContext for the registered editor\n */\nexport const registerEditor = (editorId, editor, config) => {\n // Ensure editorId is set\n const finalEditorId = editorId || 'default';\n // Create initial state for this editor\n createAnnotationState(finalEditorId);\n const context = {\n editorId: finalEditorId,\n editor,\n config: config || {},\n };\n registry.set(finalEditorId, context);\n return context;\n};\n/**\n * Retrieves the editor context for a given editor ID.\n *\n * @param editorId Unique identifier for the editor\n * @returns EditorContext or null if not found\n */\nexport const getEditorContext = (editorId) => {\n const context = registry.get(editorId);\n return context || null;\n};\n/**\n * Unregisters an editor from the registry and cleans up its state.\n *\n * @param editorId Unique identifier for the editor\n */\nexport const unregisterEditor = (editorId) => {\n registry.delete(editorId);\n clearState(editorId);\n};\n/**\n * Extracts the editor ID from an editor instance.\n * Checks editor storage first, then DOM attributes.\n *\n * @param editor The editor instance\n * @returns Editor ID or null if not found\n */\nexport const getEditorIdFromEditor = (editor) => {\n try {\n // Use the host adapter to extract editor ID\n // This avoids importing editor types here\n return getEditorId(editor);\n }\n catch (error) {\n Console.catch('Error extracting editor ID:', error);\n return null;\n }\n};\n/**\n * Gets all registered editor IDs.\n *\n * @returns Array of editor IDs\n */\nexport const getAllEditorIds = () => {\n return Array.from(registry.keys());\n};\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","/**\n * Velt SDK adapter.\n * This is the ONLY place where @veltdev/types may be imported or window.Velt accessed.\n *\n * Responsibilities:\n * - Wrap all Velt SDK calls with error handling\n * - Provide high-level async functions for SDK operations\n * - Manage singleton subscription pattern\n *\n * Architectural Rules:\n * - MAY import @veltdev/types\n * - MAY access window.Velt\n * - MUST wrap all SDK calls in try-catch\n * - MUST NOT import editor types\n */\nimport { __awaiter } from \"tslib\";\nimport { areMapsEqual } from '@/utils/common';\nimport { Console } from '@/utils/console';\n/**\n * Global state for singleton subscription pattern.\n */\nlet isSubscribed = false;\nlet selectedCommentsMap = new Map();\nconst subscribers = new Map();\n/**\n * Gets Velt comment element from SDK.\n * Returns null if SDK is not available.\n */\nexport const getCommentElement = () => {\n try {\n // Access window.Velt safely\n const velt = window.Velt;\n if (velt === null || velt === void 0 ? void 0 : velt.getCommentElement) {\n return velt.getCommentElement();\n }\n return null;\n }\n catch (error) {\n Console.catch('[VeltAdapter] Error getting comment element:', error);\n return null;\n }\n};\n/**\n * Adds a comment via Velt SDK.\n * Returns the created annotation, or null on failure.\n */\nexport const addVeltComment = (params) => __awaiter(void 0, void 0, void 0, function* () {\n try {\n const commentElement = getCommentElement();\n if (!commentElement) {\n return null;\n }\n const result = yield commentElement.addManualComment({\n context: params.context,\n location: params.location,\n });\n if (!result) {\n return null;\n }\n // Result should contain the annotation\n return {\n annotation: result,\n };\n }\n catch (error) {\n Console.catch('[VeltAdapter] Error adding comment:', error);\n return null;\n }\n});\n/**\n * Updates annotation context in Velt SDK.\n */\nexport const updateAnnotationContext = (annotationId, context) => {\n try {\n const commentElement = getCommentElement();\n if (!commentElement) {\n return;\n }\n commentElement.updateContext(annotationId, context);\n }\n catch (error) {\n Console.catch('[VeltAdapter] Error updating context:', error);\n }\n};\n/**\n * Sets up the singleton subscription to getSelectedComments.\n * This is separated out so it can be retried when commentElement becomes available.\n */\nconst setupSelectedCommentsSubscription = () => {\n const commentElement = getCommentElement();\n if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments)) {\n return false;\n }\n try {\n const observable = commentElement.getSelectedComments();\n if (!(observable === null || observable === void 0 ? void 0 : observable.subscribe)) {\n return false;\n }\n // Subscribe returns an RxJS Subscription object with an unsubscribe method\n const subscription = observable.subscribe((comments) => {\n const selectedMap = new Map();\n comments === null || comments === void 0 ? void 0 : comments.forEach((comment) => {\n if (comment === null || comment === void 0 ? void 0 : comment.annotationId) {\n selectedMap.set(comment.annotationId, true);\n }\n });\n // Skip update if maps are equal\n if (!areMapsEqual(selectedMap, selectedCommentsMap)) {\n selectedCommentsMap = selectedMap;\n // Convert Map to Set<string> for callback (matching Tiptap's signature)\n const selectedIds = new Set();\n for (const [annotationId] of selectedMap) {\n selectedIds.add(annotationId);\n }\n // Notify all subscribers with Set<string>\n subscribers.forEach((subscriber) => {\n if (typeof subscriber === 'function') {\n try {\n subscriber(selectedIds);\n }\n catch (error) {\n Console.catch('[VeltAdapter] Error in subscriber callback:', error);\n }\n }\n });\n }\n });\n // Check if subscription was successful by verifying the subscription object\n // has an unsubscribe method (RxJS Subscription pattern)\n if (subscription && typeof subscription.unsubscribe === 'function') {\n isSubscribed = true;\n return true;\n }\n }\n catch (error) {\n Console.catch('[VeltAdapter] Error setting up getSelectedComments subscription:', error);\n }\n return false;\n};\n/**\n * Subscribes to selected annotations from Velt SDK.\n * Uses singleton pattern to avoid multiple subscriptions.\n * Returns unsubscribe function.\n *\n * Matches Tiptap's signature: callback receives Set<string> of selected annotation IDs.\n */\nexport const subscribeToSelectedAnnotations = (callback, editorId) => {\n try {\n // Register this editor's callback first\n subscribers.set(editorId, callback);\n // Try to set up singleton subscription if not already subscribed\n if (!isSubscribed) {\n setupSelectedCommentsSubscription();\n }\n // Return unsubscribe function\n return () => {\n subscribers.delete(editorId);\n };\n }\n catch (error) {\n Console.catch('[VeltAdapter] Error subscribing to selected annotations:', error);\n return () => {\n // No-op unsubscribe on error\n };\n }\n};\n/**\n * Attempts to set up the selected comments subscription if not already done.\n * This should be called when we know the Velt SDK is ready.\n * Returns true if subscription is now active.\n */\nexport const ensureSelectedCommentsSubscription = () => {\n if (isSubscribed) {\n return true;\n }\n return setupSelectedCommentsSubscription();\n};\n","/**\n * Update Content feature module.\n * Handles document changes and annotation context updates.\n *\n * Responsibilities:\n * - Detect document changes via doc adapter\n * - Process each change: contentChanged, occurrenceChanged, targetTextNodeIdChanged\n * - Update annotation contexts in Velt SDK\n * - Update marks/nodes via marks adapter\n *\n * Architectural Rules:\n * - NO direct editor or Velt imports (uses adapters)\n * - Orchestrates: doc adapter → velt adapter → marks adapter\n * - All functions use ES6 arrow functions\n * - All imports use path aliases (@/)\n */\nimport { detectDocumentChanges } from '@/adapters/host/doc';\nimport { updateMarks } from '@/adapters/host/marks';\nimport { updateAnnotationContext } from '@/adapters/velt';\nimport { Constants } from '@/constants/common';\nimport { getAnnotation } from '@/core/state';\nimport { Console } from '@/utils/console';\n/**\n * Handles content updates when document changes occur.\n * Detects annotation changes and updates Velt contexts accordingly.\n *\n * @param editorId Unique identifier for the editor\n * @param editor The editor instance\n * @param transaction The transaction object\n */\nexport const handleContentUpdate = (editorId, editor, transaction) => {\n var _a;\n const logPrefix = '[handleContentUpdate]';\n try {\n // Step 1: Detect document changes using host adapter\n // This requires a function to get annotation data from state\n const getAnnotationData = (annotationId) => {\n var _a, _b, _c, _d, _e, _f;\n const annotation = getAnnotation(editorId, annotationId);\n if (!annotation) {\n Console.warn(`${logPrefix} Annotation not found in state: ${annotationId}`);\n return null;\n }\n const originalText = ((_b = (_a = annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) === null || _b === void 0 ? void 0 : _b.text) || '';\n const originalOccurrence = ((_d = (_c = annotation.context) === null || _c === void 0 ? void 0 : _c.textEditorConfig) === null || _d === void 0 ? void 0 : _d.occurrence) || 1;\n const targetTextNodeId = ((_f = (_e = annotation.context) === null || _e === void 0 ? void 0 : _e.textEditorConfig) === null || _f === void 0 ? void 0 : _f.targetTextNodeId) || '';\n return {\n annotation: annotation,\n originalText,\n originalOccurrence,\n targetTextNodeId,\n };\n };\n const changes = detectDocumentChanges(editor, transaction, Constants.MARK_NAME, getAnnotationData);\n if (changes.size === 0) {\n return;\n }\n // Step 2: Process each change (matching legacy updateVeltComments logic)\n for (const [annotationId, change] of Array.from(changes.entries())) {\n const changeLogPrefix = `${logPrefix}[${annotationId}]`;\n const annotation = getAnnotation(editorId, annotationId);\n if (!annotation) {\n Console.warn(`${changeLogPrefix} Annotation not found in state, skipping`);\n continue;\n }\n // Step 3: Build updated context (matching legacy updateVeltComments logic)\n if (!((_a = annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig)) {\n Console.warn(`${changeLogPrefix} No textEditorConfig, skipping`);\n continue;\n }\n const textEditorConfig = JSON.parse(JSON.stringify(annotation.context.textEditorConfig));\n if (change.contentChanged) {\n textEditorConfig.text = change.currentText;\n }\n if (change.occurrenceChanged) {\n textEditorConfig.occurrence = change.currentOccurrence;\n }\n if (change.targetTextNodeIdChanged) {\n textEditorConfig.targetTextNodeId = change.newTargetTextNodeId;\n }\n const updatedContext = Object.assign(Object.assign({}, annotation.context), { textEditorConfig });\n // Step 4: Update Velt context\n updateAnnotationContext(annotationId, updatedContext);\n // Step 5: Update state with new context\n // Note: State update should happen here, but for now we rely on renderComments\n // TODO: Add state update method if needed\n }\n // Step 6: Update marks if needed\n updateMarks(editor, changes);\n }\n catch (error) {\n Console.catch('Error handling content update:', error);\n }\n};\n","/**\n * Core extension module.\n * This module creates the editor extension that wires everything together.\n *\n * Responsibilities:\n * - Create extension factory function\n * - Wire features into editor lifecycle hooks\n * - Register editor in registry\n * - Handle cleanup on editor destruction\n *\n * Architectural Rules:\n * - This module MAY import editor types (it's the extension entry point)\n * - It delegates to features and adapters for actual work\n */\nimport { Element, Operation } from 'slate';\nimport { getEditorId } from '@/adapters/host/doc';\nimport { setHistoryEditor } from '@/adapters/host/marks';\nimport { Constants } from '@/constants/common';\nimport { registerEditor } from '@/core/registry';\nimport { handleContentUpdate } from '@/features/updateContent';\n/**\n * Checks if an element is a Velt comment element.\n */\nconst isVeltCommentText = (element) => {\n return Element.isElement(element) && element.type === Constants.ELEMENT_TYPE.VELT_COMMENT;\n};\n/**\n * Wraps the editor with Velt Comments functionality.\n *\n * This is the main entry point that enhances the editor with comment functionality.\n * It enhances the editor by:\n * - Overriding isInline and isVoid methods to handle comment elements\n * - Setting up onChange handler to detect and process document changes\n * - Registering the editor in the registry for state management\n *\n * @param editor - The Slate editor instance to enhance\n * @param config - Optional extension configuration including HistoryEditor and editorId\n * @returns Enhanced editor with Velt comments functionality\n *\n * @example\n * ```typescript\n * // Standard Slate plugin pattern\n * const editor = withVeltComments(withReact(createEditor()));\n *\n * // With configuration\n * const editor = withVeltComments(withReact(createEditor()), {\n * HistoryEditor: myHistoryEditor,\n * editorId: 'my-editor'\n * });\n * ```\n *\n * @remarks\n * - Follows standard Slate plugin pattern (like withReact, withHistory)\n * - Only processes text-related operations to avoid unnecessary updates\n * - Registers editor with default editorId if not provided\n */\nexport const withVeltComments = (editor, config) => {\n var _a;\n const { isInline, isVoid, onChange } = editor;\n // Set history editor if provided\n if (config === null || config === void 0 ? void 0 : config.HistoryEditor) {\n setHistoryEditor(config.HistoryEditor);\n }\n // 1. Get or create editorId\n // Try to get editorId from config first, then from DOM, fallback to 'default'\n // Note: getEditorId may return null if editor is not mounted yet, which is fine\n const editorId = (config === null || config === void 0 ? void 0 : config.editorId) || getEditorId(editor) || 'default';\n // 2. Register editor in registry\n registerEditor(editorId, editor, {\n persistVeltMarks: (_a = config === null || config === void 0 ? void 0 : config.persistVeltMarks) !== null && _a !== void 0 ? _a : true,\n editorId,\n HistoryEditor: config === null || config === void 0 ? void 0 : config.HistoryEditor,\n });\n // 3. Override editor methods\n // Override isInline to treat Velt comment text elements as inline elements\n // This ensures comment text flows naturally within the document\n editor.isInline = (element) => {\n return isVeltCommentText(element) ? true : isInline(element);\n };\n // Override isVoid to ensure Velt comment text elements are not void elements\n // This allows comment text to contain and display content\n editor.isVoid = (element) => {\n return isVeltCommentText(element) ? false : isVoid(element);\n };\n // 4. Set up onChange handler\n editor.onChange = () => {\n // Call the original onChange if it exists to preserve existing behavior\n if (onChange) {\n onChange();\n }\n // Only process text-related operations to avoid unnecessary updates\n const isTextChange = editor.operations.some((operation) => Operation.isTextOperation(operation));\n if (isTextChange) {\n // Update comment positions and states when text content changes\n handleContentUpdate(editorId, editor, undefined);\n }\n };\n // 5. Return enhanced editor\n return editor;\n};\n","/**\n * Storage adapter for editor-specific storage access.\n *\n * Purpose: Abstracts away editor-specific storage patterns.\n * This allows the codebase to be more generic and reusable across different editor implementations.\n *\n * Key responsibilities:\n * - Get persistVeltMarks setting (for Slate, checks extension config)\n * - Determine if marks should be applied\n *\n * Dependencies:\n * - slate (ONLY place allowed to import Editor types for storage access)\n */\nimport { getEditorId } from '@/adapters/host/doc';\nimport { Constants } from '@/constants/common';\nimport { getEditorContext } from '@/core/registry';\nimport { Console } from '@/utils/console';\n/**\n * Gets persistVeltMarks setting from storage.\n * For Slate, checks the extension config from registry.\n *\n * @param editor The editor instance\n * @param storageKey The storage key (unused for Slate, kept for API compatibility)\n * @returns persistVeltMarks boolean value (defaults to true)\n */\nexport const getPersistVeltMarks = (editor, storageKey = Constants.STORAGE_KEY) => {\n var _a;\n try {\n // Get editor ID first\n const editorId = getEditorId(editor);\n if (!editorId) {\n return true; // Default to true if editorId not found\n }\n // Get editor context from registry\n const context = getEditorContext(editorId);\n if (((_a = context === null || context === void 0 ? void 0 : context.config) === null || _a === void 0 ? void 0 : _a.persistVeltMarks) !== undefined) {\n return context.config.persistVeltMarks;\n }\n // Default to true if not configured\n return true;\n }\n catch (error) {\n Console.warn('[getPersistVeltMarks] Error checking persistVeltMarks, defaulting to true:', error);\n return true;\n }\n};\n/**\n * Determines if marks should be applied based on persistVeltMarks setting.\n * This is a unified adapter function that abstracts the mark application logic.\n *\n * @param editor The editor instance (typed as unknown to avoid importing editor types in feature modules)\n * @param storageKey The storage key (default: 'slateVeltComments')\n * @returns boolean indicating if marks should be applied\n *\n * @remarks\n * - For TipTap: checks persistVeltMarks setting (apply if FALSE)\n * - For Lexical: always returns true (always apply marks)\n * - For Slate: checks persistVeltMarks setting (apply if FALSE)\n * - Defaults to true if storage is unavailable\n */\nexport const shouldApplyMark = (editor, storageKey = Constants.STORAGE_KEY) => {\n try {\n const persistVeltMarks = getPersistVeltMarks(editor, storageKey);\n // Apply mark if persistVeltMarks is FALSE (matching legacy behavior)\n return persistVeltMarks === false;\n }\n catch (error) {\n Console.warn('[shouldApplyMark] Error checking persistVeltMarks, defaulting to true:', error);\n return true;\n }\n};\n","/**\n * Comment renderer module.\n *\n * Purpose: Handle filtering, comparison, and mark updates for comment annotations.\n * This module manages the rendering state and applies marks based on resolved/selected status.\n *\n * Key responsibilities:\n * - Filter annotations based on status (terminal/resolved) and selected state\n * - Compare previous vs current filtered annotations to detect removals\n * - Remove marks for annotations that should no longer be shown\n * - Re-apply marks for all filtered annotations\n *\n * Dependencies:\n * - core/state.ts (for reading annotations and selected state)\n * - adapters/host/doc.ts (for finding text occurrences)\n * - adapters/host/marks.ts (for applying/removing marks)\n * - types/velt.ts (for CommentAnnotation)\n *\n * IMPORTANT: This module MUST NOT import editor or Velt types directly.\n * All SDK access goes through adapters.\n */\nimport { applyAnnotationMarkByText, removeAnnotationMark } from '@/adapters/host/marks';\nimport { Constants } from '@/constants/common';\nimport { getCommentAnnotations, getSelectedAnnotations } from '@/core/state';\nimport { Console } from '@/utils/console';\nconst rendererStore = new Map();\n/**\n * Filters annotations based on status and selected state.\n * Excludes terminal/resolved comments unless they're selected.\n *\n * @param annotations Array of CommentAnnotation to filter\n * @param selectedIds Set of selected annotation IDs\n * @returns Filtered array of CommentAnnotation\n */\nconst filterAnnotations = (annotations, selectedIds) => {\n return annotations.filter((annotation) => {\n var _a;\n // Include if not terminal/resolved\n if (((_a = annotation === null || annotation === void 0 ? void 0 : annotation.status) === null || _a === void 0 ? void 0 : _a.type) !== Constants.STATUS_TERMINAL) {\n return true;\n }\n // Include terminal/resolved only if selected\n return selectedIds.has(annotation.annotationId);\n });\n};\n/**\n * Applies marks for filtered annotations.\n * Finds text occurrences and applies marks to the editor.\n *\n * @param editor The editor instance\n * @param filteredAnnotations Array of filtered CommentAnnotation to render\n */\nconst applyMarksForAnnotations = (editor, filteredAnnotations) => {\n var _a;\n for (const annotation of filteredAnnotations) {\n const textEditorConfig = (_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig;\n if (!(textEditorConfig === null || textEditorConfig === void 0 ? void 0 : textEditorConfig.text) || !annotation.annotationId) {\n continue;\n }\n const textToFind = textEditorConfig.text;\n const occurrence = textEditorConfig.occurrence || 1;\n const targetTextNodeId = textEditorConfig.targetTextNodeId;\n // Use applyAnnotationMarkByText which takes text and occurrence directly\n // This function handles finding the text and applying the mark internally\n applyAnnotationMarkByText(editor, textToFind, occurrence, annotation.annotationId, annotation.multiThreadAnnotationId, targetTextNodeId);\n }\n};\n/**\n * Updates comments for an editor by filtering, comparing, removing, and re-applying marks.\n * This is the core rendering logic that handles resolved comment filtering.\n *\n * @param editorId Unique identifier for the editor\n * @param editor The editor instance\n * @param annotations All CommentAnnotation from Velt SDK (with status)\n */\nexport const updateComments = (editorId, editor, annotations) => {\n var _a;\n const logPrefix = '[commentRenderer:updateComments]';\n try {\n // Store editor instance in renderer store\n const storeEntry = rendererStore.get(editorId);\n if (storeEntry) {\n storeEntry.editor = editor;\n }\n else {\n rendererStore.set(editorId, {\n editor,\n previousFilteredAnnotations: [],\n });\n }\n // Get selected annotations from state\n const selectedIds = getSelectedAnnotations(editorId);\n // Filter annotations based on status and selected state\n const filteredAnnotations = filterAnnotations(annotations, selectedIds);\n // Get previous filtered annotations for comparison\n const previousFilteredAnnotations = ((_a = rendererStore.get(editorId)) === null || _a === void 0 ? void 0 : _a.previousFilteredAnnotations) || [];\n // Create sets of annotation IDs for comparison\n const newAnnotationIds = new Set(filteredAnnotations.map((ann) => ann.annotationId).filter(Boolean));\n const previousAnnotationIds = new Set(previousFilteredAnnotations.map((ann) => ann.annotationId).filter(Boolean));\n // Find annotations that should be removed (were in previous, not in new)\n const removedAnnotationIds = Array.from(previousAnnotationIds).filter((id) => !newAnnotationIds.has(id));\n // Remove marks for removed annotations\n for (const annotationId of removedAnnotationIds) {\n if (annotationId) {\n removeAnnotationMark(editor, annotationId);\n }\n }\n // Update previous filtered annotations in renderer store\n const currentStoreEntry = rendererStore.get(editorId);\n if (currentStoreEntry) {\n currentStoreEntry.previousFilteredAnnotations = filteredAnnotations;\n }\n // Re-apply marks for all filtered annotations\n // This ensures newly selected resolved comments are highlighted\n applyMarksForAnnotations(editor, filteredAnnotations);\n }\n catch (error) {\n Console.catch(`${logPrefix} Error updating comments:`, error);\n }\n};\n/**\n * Updates comments when selected annotations change.\n * Re-reads annotations from state and triggers re-rendering.\n *\n * @param editorId Unique identifier for the editor\n * @param selectedIds Set of selected annotation IDs (already updated in state)\n */\nexport const updateSelection = (editorId, selectedIds) => {\n const logPrefix = '[commentRenderer:updateSelection]';\n try {\n // Get editor instance from renderer store\n const storeEntry = rendererStore.get(editorId);\n if (!storeEntry || !storeEntry.editor) {\n Console.warn(`${logPrefix} No editor found for editorId: ${editorId}`);\n return;\n }\n // Get all comment annotations from state (with status)\n const annotations = getCommentAnnotations(editorId);\n // Re-run updateComments with current annotations and new selection\n // This will filter, compare, remove, and re-apply marks\n updateComments(editorId, storeEntry.editor, annotations);\n }\n catch (error) {\n Console.catch(`${logPrefix} Error updating selection:`, error);\n }\n};\n/**\n * Cleans up renderer store for an editor.\n * Should be called when editor is destroyed.\n *\n * @param editorId Unique identifier for the editor\n */\nexport const cleanupRenderer = (editorId) => {\n rendererStore.delete(editorId);\n};\n","/**\n * Render comments feature module.\n *\n * Purpose: Public API entry point for rendering comment annotations.\n * Orchestrates state updates, subscriptions, and delegates to commentRenderer.\n *\n * Key responsibilities:\n * - Update state with new annotations\n * - Subscribe to selected annotations from Velt\n * - Delegate rendering logic to commentRenderer\n *\n * Dependencies:\n * - adapters/velt.ts (for Velt SDK subscription)\n * - adapters/host/doc.ts (for editor setup)\n * - core/state.ts (for state management)\n * - core/registry.ts (for editor ID extraction)\n * - features/commentRenderer.ts (for rendering logic)\n * - types/velt.ts (for CommentAnnotation)\n *\n * IMPORTANT: This module MUST NOT import editor or Velt types directly.\n * All SDK access goes through adapters.\n */\nimport { ensureEditorSetup } from '@/adapters/host/doc';\nimport { ensureSelectedCommentsSubscription, subscribeToSelectedAnnotations } from '@/adapters/velt';\nimport { Constants } from '@/constants/common';\nimport { setSelectedAnnotations, updateAnnotations } from '@/core/state';\nimport { cleanupRenderer, updateComments, updateSelection } from '@/features/commentRenderer';\nimport { Console } from '@/utils/console';\n/**\n * Subscription map to track subscriptions per editor\n */\nconst subscriptionMap = new Map();\n/**\n * Renders comment annotations as marks in the editor.\n *\n * This function renders comment annotations as visual marks in the editor.\n * It filters annotations for the specific editor and applies marks accordingly.\n *\n * @param request - Object containing editor, editorId (optional), and commentAnnotations (optional)\n *\n * @example\n * ```typescript\n * // Simple usage\n * renderComments({ editor });\n *\n * // With editor ID\n * renderComments({ editorId: 'my-editor', editor });\n *\n * // With annotations\n * renderComments({\n * editorId: 'my-editor',\n * editor,\n * commentAnnotations: [\n * {\n * annotationId: 'ann-123',\n * context: {\n * textEditorConfig: {\n * text: 'Hello world',\n * occurrence: 1,\n * editorId: 'my-editor'\n * }\n * }\n * }\n * ]\n * });\n * ```\n *\n * @remarks\n * - Only annotations with matching editorId are rendered\n * - Automatically subscribes to selected annotations changes\n * - Filters out terminal/resolved comments unless they're selected\n * - Removes marks when comments become resolved\n * - Re-applies marks when resolved comments are selected\n */\nexport const renderComments = ({ editor, editorId, commentAnnotations, }) => {\n const logPrefix = '[renderComments]';\n try {\n if (!editor) {\n Console.warn(`${logPrefix} No editor provided`);\n return;\n }\n // Validate commentAnnotations silently - skip if not available or not an array\n if (!commentAnnotations || !Array.isArray(commentAnnotations)) {\n commentAnnotations = [];\n }\n // Step 0: Ensure editor is set up (registered and document listeners configured)\n const { editorId: finalEditorId } = ensureEditorSetup(editorId, editor);\n // Deep clone annotations to avoid mutations\n const clonedAnnotations = JSON.parse(JSON.stringify(commentAnnotations));\n // Filter annotations for this specific editor\n // - If finalEditorId is DEFAULT_EDITOR_ID, match annotations without editorId OR with editorId === DEFAULT_EDITOR_ID\n // - Otherwise, match annotations with exact editorId match\n const editorAnnotations = clonedAnnotations.filter((annotation) => {\n var _a;\n if (!((_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig)) {\n return false;\n }\n const annotationEditorId = annotation.context.textEditorConfig.editorId;\n // Default editor matches: no editorId OR explicit DEFAULT_EDITOR_ID\n if (finalEditorId === Constants.DEFAULT_EDITOR_ID) {\n return annotationEditorId === undefined || annotationEditorId === Constants.DEFAULT_EDITOR_ID;\n }\n // For user-provided editorIds, require exact match\n return annotationEditorId === finalEditorId;\n });\n // Step 1: Update state with filtered annotations (stores both AnnotationData and CommentAnnotation[])\n updateAnnotations(finalEditorId, editorAnnotations);\n // Step 2: Set up subscription to selected annotations (singleton pattern)\n if (!subscriptionMap.has(finalEditorId)) {\n // Capture finalEditorId in const to ensure type safety in closure\n const editorIdForSubscription = finalEditorId;\n const unsubscribe = subscribeToSelectedAnnotations((selectedIds) => {\n // Update selected annotations in state\n setSelectedAnnotations(editorIdForSubscription, selectedIds);\n // Trigger re-rendering with new selection\n updateSelection(editorIdForSubscription, selectedIds);\n }, editorIdForSubscription);\n subscriptionMap.set(finalEditorId, unsubscribe);\n }\n // Step 2.5: Ensure the selected comments subscription is active\n // This retries the subscription if it failed earlier (e.g., commentElement wasn't ready)\n ensureSelectedCommentsSubscription();\n // Step 3: Delegate to commentRenderer to handle filtering, comparison, removal, and re-application\n updateComments(finalEditorId, editor, editorAnnotations);\n }\n catch (error) {\n Console.catch(`${logPrefix} Error rendering comments:`, error);\n }\n};\n/**\n * Cleans up subscriptions and renderer state for an editor.\n * Should be called when editor is destroyed.\n *\n * @param editorId Unique identifier for the editor\n */\nexport const cleanupRenderComments = (editorId) => {\n // Clean up subscription\n const unsubscribe = subscriptionMap.get(editorId);\n if (unsubscribe) {\n unsubscribe();\n subscriptionMap.delete(editorId);\n }\n // Clean up renderer store\n cleanupRenderer(editorId);\n};\n","/**\n * Serializer utilities for Slate editor content\n *\n * This module provides utilities for serializing Slate editor content,\n * particularly for removing comment nodes from serialized JSON.\n *\n * Use this when persisting editor content to remove Velt comment elements\n * while preserving the original text content.\n */\nimport { Constants } from '@/constants/common';\n/** Use the element's canonical type string */\nconst COMMENT_TYPE = Constants.ELEMENT_TYPE.VELT_COMMENT;\n/**\n * Export JSON without comment nodes.\n *\n * This function takes Slate editor content and removes all comment nodes,\n * unwrapping their children and merging adjacent text nodes with same formatting.\n *\n * @param content - Slate editor content (Descendant[])\n * @returns Serialized content without comment nodes\n */\nexport const exportJSONWithoutComments = (content) => {\n // 1) Strip comment nodes from the content\n const strippedContent = stripCommentsFromContent(content);\n // 2) Normalize adjacent text nodes created by unwrapping\n const normalizedContent = normalizeTextNodesInContent(strippedContent);\n return normalizedContent;\n};\n/* -------------------- internals (strictly typed) -------------------- */\nconst stripCommentsFromContent = (content) => {\n return stripFromChildrenArray(content);\n};\n/**\n * Flattens comment nodes inside a children array and recurses.\n */\nconst stripFromChildrenArray = (children) => {\n const out = [];\n for (const child of children) {\n if (isElementNode(child) && child.type === COMMENT_TYPE) {\n // Unwrap: push processed grandchildren directly\n const flattened = stripFromChildrenArray(child.children);\n out.push(...flattened);\n continue;\n }\n out.push(stripCommentsFromNode(child));\n }\n return out;\n};\nconst stripCommentsFromNode = (node) => {\n if (isElementNode(node)) {\n const nextChildren = stripFromChildrenArray(node.children);\n return Object.assign(Object.assign({}, node), { children: nextChildren });\n }\n return node;\n};\n/* -------------------- normalization (strictly typed) -------------------- */\nconst normalizeTextNodesInContent = (content) => {\n const normalizedKids = content.map(normalizeTextNodesInNode);\n return mergeAdjacentTextNodes(normalizedKids);\n};\nconst normalizeTextNodesInNode = (node) => {\n if (isElementNode(node)) {\n const normalizedKids = node.children.map(normalizeTextNodesInNode);\n return Object.assign(Object.assign({}, node), { children: mergeAdjacentTextNodes(normalizedKids) });\n }\n return node;\n};\nconst mergeAdjacentTextNodes = (children) => {\n var _a, _b;\n if (children.length < 2)\n return children;\n const merged = [];\n let i = 0;\n while (i < children.length) {\n const cur = children[i];\n if (isTextNode(cur)) {\n // Skip empty text nodes (artifacts from Slate's split operation)\n if (cur.text === '') {\n i++;\n continue;\n }\n let text = (_a = cur.text) !== null && _a !== void 0 ? _a : '';\n let j = i + 1;\n while (j < children.length) {\n const nxt = children[j];\n // Skip empty text nodes\n if (isTextNode(nxt) && nxt.text === '') {\n j++;\n continue;\n }\n if (isTextNode(nxt) && haveSameTextFormat(cur, nxt)) {\n text += (_b = nxt.text) !== null && _b !== void 0 ? _b : '';\n j++;\n }\n else {\n break;\n }\n }\n merged.push(Object.assign(Object.assign({}, cur), { text }));\n i = j;\n }\n else {\n merged.push(cur);\n i++;\n }\n }\n // Ensure at least one child for element nodes\n return merged.length > 0 ? merged : [{ text: '' }];\n};\n/* -------------------- type guards & equality -------------------- */\nconst isElementNode = (node) => {\n // Slate Element nodes always have a 'children' array and 'type' property\n return (Object.prototype.hasOwnProperty.call(node, 'children') &&\n Object.prototype.hasOwnProperty.call(node, 'type'));\n};\nconst isTextNode = (node) => {\n return Object.prototype.hasOwnProperty.call(node, 'text');\n};\nconst haveSameTextFormat = (a, b) => {\n return (a.bold === b.bold &&\n a.italic === b.italic &&\n a.underline === b.underline);\n};\n","/**\n * React component for rendering Velt comment elements in Slate editor.\n * This component renders the <velt-comment-text> custom element.\n *\n * Note: velt-comment-text is an inline element, so it should only contain text nodes\n * or other inline elements, never block elements like <p>.\n */\nimport React from 'react';\nimport { Constants } from '@/constants/common';\nexport const SlateVeltComment = (props) => {\n const { attributes, children, element } = props;\n const annotationId = element === null || element === void 0 ? void 0 : element.annotationId;\n // Use React.createElement to avoid TypeScript JSX type checking for custom web component\n // velt-comment-text is an inline element, so children should be inline content only\n return React.createElement('velt-comment-text', Object.assign({ [Constants.ATTRIBUTES.ANNOTATION_ID]: annotationId }, attributes), children);\n};\n","/**\n * Add comment feature module.\n *\n * Purpose: End-to-end add comment orchestration.\n * Orchestrates adapters and core to implement the add comment flow.\n *\n * Key responsibilities:\n * - Get Velt comment element\n * - Extract selection context from editor\n * - Create comment via Velt SDK\n * - Apply mark to editor document\n * - Update state with annotation data\n *\n * Dependencies:\n * - adapters/velt.ts (for Velt SDK calls)\n * - adapters/host/doc.ts (for selection extraction, editor setup, and selection reset)\n * - adapters/host/marks.ts (for mark application)\n * - adapters/host/storage.ts (for mark application configuration)\n * - core/state.ts (for state updates)\n * - types/common.ts (for CommentAnnotationContext)\n *\n * IMPORTANT: This module MUST NOT import editor or Velt types directly.\n * All SDK access goes through adapters.\n */\nimport { __awaiter } from \"tslib\";\nimport { applyAnnotationMarkByText } from '@/adapters/host/marks';\nimport { ensureEditorSetup, getCurrentSelectionContext, resetEditorSelection } from '@/adapters/host/doc';\nimport { shouldApplyMark } from '@/adapters/host/storage';\nimport { addVeltComment, getCommentElement } from '@/adapters/velt';\nimport { Constants } from '@/constants/common';\nimport { updateAnnotations } from '@/core/state';\nimport { Console } from '@/utils/console';\n/**\n * Adds a comment to the currently selected text in the editor.\n *\n * This is the main entry point for adding comments. It handles:\n * - Extracting selection context from the editor\n * - Creating the comment via Velt SDK\n * - Applying marks to the editor if configured\n * - Updating state with annotation data\n *\n * @param request - Object containing editorId (optional), editor, and context (optional)\n * @returns Promise that resolves when the comment is added (or fails silently)\n *\n * @example\n * ```typescript\n * // Simple usage\n * await addComment({ editor });\n *\n * // With editor ID\n * await addComment({ editorId: 'my-editor', editor });\n *\n * // With custom context\n * await addComment({\n * editorId: 'my-editor',\n * editor,\n * context: {\n * userId: 'user123',\n * metadata: { source: 'web-app' }\n * }\n * });\n * ```\n *\n * @remarks\n * - Requires text to be selected in the editor\n * - Requires Velt SDK to be available (window.Velt)\n * - Marks are only applied if persistVeltMarks is FALSE in extension config (matching legacy behavior)\n * - Fails silently if Velt SDK is unavailable or selection is invalid\n */\nexport function addComment(_a) {\n return __awaiter(this, arguments, void 0, function* ({ editorId, editor, context: clientContext, }) {\n const logPrefix = '[addComment]';\n // Validate editor parameter\n if (!editor) {\n Console.catch(`${logPrefix} ERROR: No editor provided`);\n return;\n }\n try {\n // Step 1: Get Velt comment element\n const commentElement = getCommentElement();\n if (!commentElement) {\n Console.warn(`${logPrefix} Velt SDK not available, cannot add comment`);\n return;\n }\n // Step 2: Extract selection context from editor\n // Type assertion needed because editor type is generic (unknown) to avoid importing editor types\n const selectionContext = getCurrentSelectionContext(editor);\n if (!selectionContext) {\n Console.warn(`${logPrefix} No valid selection found, exiting`);\n return;\n }\n // Step 3: Ensure editor is set up (registered and document listeners configured)\n const { editorId: finalEditorId } = ensureEditorSetup(editorId, editor);\n // Step 4: Build context object for Velt SDK\n // Only include editorId in textEditorConfig if user explicitly provided it\n // (either directly or via editor storage/DOM). DEFAULT_EDITOR_ID means it was auto-generated,\n // so we omit it for backward compatibility with old data that has no editorId.\n const userProvidedEditorId = editorId !== undefined || finalEditorId !== Constants.DEFAULT_EDITOR_ID;\n const context = Object.assign(Object.assign({}, (clientContext && typeof clientContext === 'object' ? clientContext : {})), { textEditorConfig: Object.assign(Object.assign({ text: selectionContext.text, occurrence: selectionContext.occurrence }, (userProvidedEditorId && { editorId: finalEditorId })), { targetTextNodeId: selectionContext.targetTextNodeId }) });\n // Step 5: Build location object if locationId is available\n let location;\n if (selectionContext.locationId) {\n location = { id: selectionContext.locationId };\n }\n // 5.1 Short delay to prevent comment dialog from closing immediately\n // This improves user experience when interacting with comments\n yield new Promise((resolve) => setTimeout(resolve, 200));\n // Step 6: Add comment via Velt SDK (matching legacy behavior - mark applied in callback)\n const veltResult = yield addVeltComment({ context, location });\n if (!veltResult || !veltResult.annotation) {\n Console.warn(`${logPrefix} Failed to create comment via Velt SDK`);\n return;\n }\n const annotation = veltResult.annotation;\n // Step 7: Check if marks should be applied (matching legacy behavior)\n // This means: if persistVeltMarks is FALSE, apply the mark\n const shouldApplyMarkValue = shouldApplyMark(editor, Constants.STORAGE_KEY);\n // Step 8: Apply mark to editor if needed (matching legacy behavior)\n // Legacy applies mark in the .then() callback, but we've already awaited, so apply now\n // Use text + occurrence approach for correct mark positioning across all document structures\n if (shouldApplyMarkValue && annotation.annotationId) {\n applyAnnotationMarkByText(editor, selectionContext.text, selectionContext.occurrence, annotation.annotationId, annotation.multiThreadAnnotationId, selectionContext.targetTextNodeId);\n }\n // Step 9: Update state with new annotation\n if (annotation.annotationId) {\n updateAnnotations(finalEditorId, [annotation]);\n }\n else {\n Console.warn(`${logPrefix} No annotationId, skipping state update`);\n }\n // Step 10: Reset editor selection (matching legacy behavior)\n resetEditorSelection(editor);\n }\n catch (error) {\n Console.catch(`${logPrefix} Error adding comment:`, error);\n }\n });\n}\n"],"names":["Constants","EDITOR_ID","LOCATION_ID","ANNOTATION_ID","MULTI_THREAD_ANNOTATION_ID","VELT_COMMENT","kmpSearch","text","pattern","startPos","maxOccurrences","positions","length","lps","Array","fill","len","i","computeKMPTable","j","push","Console","showLogs","sessionStorage","getItem","err","catch","log","console","warn","error","debug","info","logsEnabled","message","undefined","getEditorId","editor","_a","_b","domNode","ReactEditorImpl","ReactEditor","toDOMNode","closest","getAttribute","findOccurrenceIndex","targetTextNodeId","selection","targetElement","document","getElementById","startOffset","anchor","offset","findOccurrenceInDOM","allMatches","findAllMatches","isBackward","Path","compare","path","focus","equals","matchIndex","findIndex","match","findParentNodeWithId","node","Node","get","findParentNodeWithIdFromNode","maxIterations","editorDOM","currentNode","iterationCount","body","contains","id","parentElement","findOccurrenceForNode","nodeText","string","trim","containerNode","containerPath","toSlateNode","findPath","matchesToCheck","filter","matchStart","Editor","start","isAncestor","matchPath","isEqual","isDescendant","originalIndex","indexOf","textToSearch","caseSensitive","matches","getText","isTextNode","searchInNode","searchText","toLowerCase","index","range","isArray","children","forEach","child","initialNode","nodes","at","mode","element","fullText","textContent","processedFullText","processedSearchText","occurrences","ensureEditorSetup","editorId","finalEditorId","HistoryEditor","isVeltCommentText","Element","isElement","type","applyAnnotationMarkByText","occurrence","annotationId","multiThreadAnnotationId","targetElementId","logPrefix","slateEditor","isElementInEditor","findTextOccurrenceRange","from","wrapNodes","Transforms","split","withoutSaving","applyAnnotationMarkWithRange","removeAnnotationMark","elementsToUnwrap","descendants","reverse","nodeAtPath","elementAtNode","isConnected","unwrapNodes","targetNode","targetPath","textNodePositions","collectSubtreeText","regex","RegExp","replace","exec","matchEnd","anchorNodeInfo","focusNodeInfo","nodePosition","end","traverseNodesForText","currentPath","Text","isText","childPath","stateMap","Map","createAnnotationState","state","annotations","commentAnnotations","selectedAnnotations","Set","set","getOrCreateState","updateAnnotations","annotationDataMap","annotation","annotationData","context","getAnnotation","registry","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","isSubscribed","selectedCommentsMap","subscribers","getCommentElement","velt","window","Velt","updateAnnotationContext","commentElement","updateContext","setupSelectedCommentsSubscription","getSelectedComments","observable","subscribe","subscription","comments","selectedMap","comment","map1","map2","size","key","areMapsEqual","selectedIds","add","subscriber","unsubscribe","handleContentUpdate","transaction","getAnnotationData","_c","_d","_e","_f","originalText","textEditorConfig","originalOccurrence","changes","markType","annotationNodes","SlateElement","storedData","originalTargetTextNodeId","currentText","currentTargetNode","currentTargetNodeId","currentOccurrence","textChanged","occurrenceChanged","targetTextNodeIdChanged","newTargetTextNodeId","contentChanged","detectDocumentChanges","change","entries","changeLogPrefix","JSON","parse","stringify","updatedContext","Object","assign","updateMarks","getPersistVeltMarks","storageKey","getEditorContext","config","persistVeltMarks","rendererStore","updateComments","storeEntry","previousFilteredAnnotations","getSelectedAnnotations","filteredAnnotations","status","has","filterAnnotations","newAnnotationIds","map","ann","Boolean","previousAnnotationIds","removedAnnotationIds","currentStoreEntry","textToFind","applyMarksForAnnotations","updateSelection","getCommentAnnotations","subscriptionMap","COMMENT_TYPE","stripCommentsFromContent","content","stripFromChildrenArray","out","isElementNode","flattened","stripCommentsFromNode","nextChildren","normalizeTextNodesInContent","normalizedKids","normalizeTextNodesInNode","mergeAdjacentTextNodes","merged","cur","nxt","haveSameTextFormat","prototype","hasOwnProperty","call","a","b","bold","italic","underline","props","attributes","React","createElement","this","arguments","clientContext","params","selectionContext","to","targetTextNode","locationId","getCurrentSelectionContext","userProvidedEditorId","location","setTimeout","veltResult","addManualComment","shouldApplyMarkValue","shouldApplyMark","strippedContent","editorAnnotations","annotationEditorId","editorIdForSubscription","callback","delete","subscribeToSelectedAnnotations","setSelectedAnnotations","isInline","isVoid","onChange","historyEditor","registerEditor","operations","some","operation","Operation","isTextOperation"],"mappings":"gFAMO,MAAMA,EAIG,CACRC,UAAW,iBACXC,YAAa,wBACbC,cAAe,gBACfC,2BAA4B,8BARvBJ,EAaK,CACVK,aAAc,eAdTL,EAoBE,cApBFA,EAyBI,oBAzBJA,EAkCU,cAlCVA,EAsCQ,WAtCRA,EA0CG,sBA1CHA,EA8CO,YA9CPA,EAkDa,iBCIbM,EAAY,CAACC,EAAMC,EAASC,EAAW,EAAGC,KACnD,MAAMC,EAAY,GAClB,IAAKH,IAAYD,GAAQC,EAAQI,OAASL,EAAKK,OAC3C,OA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