@case-framework/survey-core 0.5.0 → 0.6.0
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/build/editor.d.mts +5 -1
- package/build/editor.d.mts.map +1 -1
- package/build/editor.mjs +14 -1
- package/build/editor.mjs.map +1 -1
- package/build/index.d.mts +1 -1
- package/build/index.mjs +1 -1
- package/build/package.json +1 -1
- package/build/{survey-Dxt6iolo.mjs → survey-BKblV5rN.mjs} +11 -1
- package/build/survey-BKblV5rN.mjs.map +1 -0
- package/build/{survey-DZ3RHkd2.d.mts → survey-CwWxsuRb.d.mts} +6 -1
- package/build/{survey-DZ3RHkd2.d.mts.map → survey-CwWxsuRb.d.mts.map} +1 -1
- package/package.json +1 -1
- package/build/survey-Dxt6iolo.mjs.map +0 -1
package/build/editor.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as SurveyCardContent, E as NavigationContent, Gt as SurveyItemCore, Jt as RawSurveyItem, M as Content, S as RawSurveyAsset, k as SurveyItemTranslations, m as ItemTypeRegistry, t as Survey, vt as TemplateValueDefinition, w as JsonComponentContent, x as RawSurvey } from "./survey-
|
|
1
|
+
import { D as SurveyCardContent, E as NavigationContent, Gt as SurveyItemCore, Jt as RawSurveyItem, M as Content, S as RawSurveyAsset, k as SurveyItemTranslations, m as ItemTypeRegistry, t as Survey, vt as TemplateValueDefinition, w as JsonComponentContent, x as RawSurvey } from "./survey-CwWxsuRb.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/editor/types.d.ts
|
|
4
4
|
interface Target {
|
|
@@ -316,6 +316,10 @@ declare class SurveyEditor {
|
|
|
316
316
|
};
|
|
317
317
|
};
|
|
318
318
|
}): void;
|
|
319
|
+
/** Add an empty survey locale so it can be authored before translated content exists. */
|
|
320
|
+
addLocale(locale: string): boolean;
|
|
321
|
+
/** Remove a locale and every survey- and item-level translation stored for it. */
|
|
322
|
+
removeLocale(locale: string): boolean;
|
|
319
323
|
/**
|
|
320
324
|
* Get maxItemsPerPage immutably (returns a copy).
|
|
321
325
|
*/
|
package/build/editor.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.mts","names":[],"sources":["../src/editor/types.ts","../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"mappings":";;;UAAiB,MAAA;EACf,QAAA;EACA,KAAA;AAAA;;;KCQU,sBAAA;EAAA,CACT,MAAA,WAAiB,oBAAA;AAAA;AAAA,UAIH,uBAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA,EAAO,KAAA;IACL,MAAA;IACA,QAAA,EAAU,aAAA;EAAA;EAEZ,YAAA;IAAA,CAAiB,MAAA,WAAiB,sBAAA;EAAA;EAClC,UAAA;EACA,SAAA;AAAA;AAAA,cAGW,aAAA;EAAA,QACH,MAAA;cAEI,MAAA,EAAQ,MAAA;EARoC;;;;;;EAkBxD,QAAA,CAAS,MAAA,WAAiB,uBAAA;EApBd;;;;;EAAA,QA4EJ,mBAAA;EAxEC;;AAGX;;;;EAHW,QAoGD,oBAAA;EAiDiB;;;;;;;EAAzB,SAAA,CAAU,aAAA,EAAe,uBAAA,EAAyB,MAAA,EAAQ,MAAA;EA/I9C;;;EAAA,QA8LJ,mBAAA;EA5HA;;;EAAA,QAgJA,2BAAA;EAnEE;;;EAAA,QAoHF,0BAAA;EAjDA;;;EAAA,QAoFA,kBAAA;EAuBoB;;;EAAA,OAArB,oBAAA,CAAqB,IAAA,YAAgB,IAAA,IAAQ,uBAAA;AAAA;;;UCxVrC,cAAA;EACf,gBAAA;EACA,cAAA;EACA,cAAA;AAAA;AAAA,cAGW,YAAA;EAAA;;;;KAKD,YAAA,WAAuB,YAAA,eAA2B,YAAA;AAAA,UAE7C,UAAA;EACf,KAAA;EACA,MAAA,GAAS,YAAA;AAAA;AAAA,UAGM,UAAA;EACf,OAAA;EACA,IAAA,GAAO,cAAA;EACP,IAAA,GAAO,cAAA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+
{"version":3,"file":"editor.d.mts","names":[],"sources":["../src/editor/types.ts","../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"mappings":";;;UAAiB,MAAA;EACf,QAAA;EACA,KAAA;AAAA;;;KCQU,sBAAA;EAAA,CACT,MAAA,WAAiB,oBAAA;AAAA;AAAA,UAIH,uBAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA,EAAO,KAAA;IACL,MAAA;IACA,QAAA,EAAU,aAAA;EAAA;EAEZ,YAAA;IAAA,CAAiB,MAAA,WAAiB,sBAAA;EAAA;EAClC,UAAA;EACA,SAAA;AAAA;AAAA,cAGW,aAAA;EAAA,QACH,MAAA;cAEI,MAAA,EAAQ,MAAA;EARoC;;;;;;EAkBxD,QAAA,CAAS,MAAA,WAAiB,uBAAA;EApBd;;;;;EAAA,QA4EJ,mBAAA;EAxEC;;AAGX;;;;EAHW,QAoGD,oBAAA;EAiDiB;;;;;;;EAAzB,SAAA,CAAU,aAAA,EAAe,uBAAA,EAAyB,MAAA,EAAQ,MAAA;EA/I9C;;;EAAA,QA8LJ,mBAAA;EA5HA;;;EAAA,QAgJA,2BAAA;EAnEE;;;EAAA,QAoHF,0BAAA;EAjDA;;;EAAA,QAoFA,kBAAA;EAuBoB;;;EAAA,OAArB,oBAAA,CAAqB,IAAA,YAAgB,IAAA,IAAQ,uBAAA;AAAA;;;UCxVrC,cAAA;EACf,gBAAA;EACA,cAAA;EACA,cAAA;AAAA;AAAA,cAGW,YAAA;EAAA;;;;KAKD,YAAA,WAAuB,YAAA,eAA2B,YAAA;AAAA,UAE7C,UAAA;EACf,KAAA;EACA,MAAA,GAAS,YAAA;AAAA;AAAA,UAGM,UAAA;EACf,OAAA;EACA,IAAA,GAAO,cAAA;EACP,IAAA,GAAO,cAAA;AAAA;AAAA,UAGC,gBAAA;EACR,SAAA;EACA,IAAA,EAAM,UAAA;EACN,UAAA;AAAA;AAAA,UAGQ,0BAAA,SAAmC,gBAAA;EAC3C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A;EDtlBjC;;;EC8lBN,qBAAA,CAAsB,KAAA;IAAS,KAAA;IAAe,KAAA;EAAA;ED1lBa;;;ECkmB3D,WAAA,CAAA;IAAA,CAAkB,GAAA;EAAA;EDhmBD;AAAA;;ECwmBjB,cAAA,CAAe,QAAA;IAAA,CAAa,GAAA;EAAA;EDpmB5B;;;EC4mBA,gBAAA,CAAiB,GAAA,WAAc,uBAAA;ED3mBZ;AAAA;;ECmnBnB,iBAAA,CAAA,GAAqB,GAAA,SAAY,uBAAA;EDhnBf;;AAKpB;EC0nBE,gBAAA,CAAiB,GAAA,UAAa,aAAA,EAAe,uBAAA;;;;EAQ7C,mBAAA,CAAoB,GAAA;EDhoBd;;;ECwoBN,QAAA,CAAS,OAAA,WAAkB,cAAA;EDroB3B;;;EC6oBA,SAAA,CAAA,GAAa,GAAA,SAAY,cAAA;EDzoBtB;;;ECgpBH,QAAA,CAAS,OAAA,UAAiB,KAAA,EAAO,cAAA;ED9oB/B;;;ECmqBF,WAAA,CAAY,OAAA;EDlqB6B;;;;;EC2rBzC,QAAA,CAAS,MAAA,WAAiB,uBAAA;ED3rBe;;AAgE3C;;;;ECsoBE,SAAA,CAAU,aAAA,EAAe,uBAAA,EAAyB,MAAA,EAAQ,MAAA;AAAA"}
|
package/build/editor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as generateId, nt as structuredCloneMethod, t as Survey, u as SurveyItemTranslations, v as GroupItemCore } from "./survey-
|
|
1
|
+
import { $ as generateId, nt as structuredCloneMethod, t as Survey, u as SurveyItemTranslations, v as GroupItemCore } from "./survey-BKblV5rN.mjs";
|
|
2
2
|
//#region src/editor/item-copy-paste.ts
|
|
3
3
|
var ItemCopyPaste = class ItemCopyPaste {
|
|
4
4
|
survey;
|
|
@@ -839,6 +839,19 @@ var SurveyEditor = class SurveyEditor {
|
|
|
839
839
|
if (updates.navigation) this._survey.translations.setNavigationContent(updates.navigation.locale, updates.navigation.content);
|
|
840
840
|
if (updates.validationMessages) this._survey.translations.setValidationMessages(updates.validationMessages.locale, updates.validationMessages.content);
|
|
841
841
|
}
|
|
842
|
+
/** Add an empty survey locale so it can be authored before translated content exists. */
|
|
843
|
+
addLocale(locale) {
|
|
844
|
+
const added = this._survey.translations.addLocale(locale);
|
|
845
|
+
if (added) this.markAsModified();
|
|
846
|
+
return added;
|
|
847
|
+
}
|
|
848
|
+
/** Remove a locale and every survey- and item-level translation stored for it. */
|
|
849
|
+
removeLocale(locale) {
|
|
850
|
+
if (!this._survey.locales.includes(locale)) return false;
|
|
851
|
+
this._survey.translations.removeLocale(locale);
|
|
852
|
+
this.markAsModified();
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
842
855
|
/**
|
|
843
856
|
* Get maxItemsPerPage immutably (returns a copy).
|
|
844
857
|
*/
|
package/build/editor.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.mjs","names":[],"sources":["../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"sourcesContent":["import { Survey } from \"../survey/survey\";\nimport { SurveyItemCore } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport { ReservedSurveyItemTypes } from \"../survey/items/types\";\nimport { SurveyItemTranslations, JsonComponentContent } from \"../survey/utils\";\nimport { RawSurveyItem } from \"../survey/items/survey-item-json\";\nimport { Target } from \"./types\";\nimport { generateId } from \"../utils\";\n\n// Serialized translation data format for clipboard\nexport type SerializedTranslations = {\n [locale: string]: JsonComponentContent;\n};\n\n// Clipboard data structure for copy-paste functionality\nexport interface SurveyItemClipboardData {\n type: \"survey-item\";\n version: string;\n items: Array<{\n itemId: string;\n itemData: RawSurveyItem;\n }>;\n translations: { [itemId: string]: SerializedTranslations };\n rootItemId: string; // The id of the main item being copied\n timestamp: number;\n}\n\nexport class ItemCopyPaste {\n private survey: Survey;\n\n constructor(survey: Survey) {\n this.survey = survey;\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * When copying a group, automatically includes all items in the subtree\n * @param itemId - The id of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const item = this.survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Collect all items to copy (including subtree for groups)\n const itemsToCopy = this.collectItemsForCopy(itemId);\n\n // Create items array with their data\n const items = itemsToCopy.map((id) => {\n const item = this.survey.surveyItems.get(id);\n if (!item) throw new Error(`Item with id '${id}' not found during copy`);\n return { itemId: id, itemData: item.rawItem };\n });\n\n // Collect translations for all items\n const translations: { [itemId: string]: SerializedTranslations } = {};\n itemsToCopy.forEach((id) => {\n try {\n const itemTranslations = this.survey.getItemTranslations(id);\n if (itemTranslations?.locales?.length) {\n const serializedTranslations: SerializedTranslations = {};\n itemTranslations.locales.forEach((locale) => {\n const localeContent = itemTranslations.getAllForLocale(locale);\n if (localeContent) {\n serializedTranslations[locale] = localeContent;\n }\n });\n translations[id] = serializedTranslations;\n } else {\n translations[id] = {};\n }\n } catch {\n translations[id] = {};\n }\n });\n\n // Create clipboard data\n const clipboardData: SurveyItemClipboardData = {\n type: \"survey-item\",\n version: \"1.0.0\",\n items: items,\n translations: translations,\n rootItemId: itemId,\n timestamp: Date.now(),\n };\n\n return clipboardData;\n }\n\n /**\n * Collect all items that should be copied, including subtree for groups\n * @param itemId - The root item id\n * @returns Array of item keys to copy\n */\n private collectItemsForCopy(itemId: string): string[] {\n const itemsToCopy: string[] = [itemId];\n const item = this.survey.surveyItems.get(itemId);\n\n if (!item) {\n return [];\n }\n\n // If this is a group item, collect all child items recursively\n if (item instanceof GroupItemCore) {\n const childIds = item.items;\n if (childIds.length > 0) {\n childIds.forEach((childId) => {\n const childItems = this.collectItemsForCopy(childId);\n itemsToCopy.push(...childItems);\n });\n }\n }\n\n return itemsToCopy;\n }\n\n /**\n * Add an item to its parent group.\n * Ensures key uniqueness among siblings.\n * @param target - Target location information\n * @param item - The item to add (may have key adjusted for uniqueness)\n */\n private addItemToParentGroup(target: Target, item: SurveyItemCore): void {\n const parentGroup = this.survey.surveyItems.get(target.parentId);\n\n if (!parentGroup) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(parentGroup instanceof GroupItemCore)) {\n throw new Error(`Parent item '${target.parentId}' is not a group item`);\n }\n\n const siblingIds = parentGroup.items;\n const siblings = siblingIds\n .map((id) => this.survey.surveyItems.get(id))\n .filter((s): s is SurveyItemCore => s !== undefined);\n const siblingKeys = new Set(siblings.map((s) => s.key));\n\n let uniqueKey = item.key;\n if (siblingKeys.has(uniqueKey)) {\n let counter = 1;\n const originalKey = item.key;\n while (siblingKeys.has(uniqueKey)) {\n uniqueKey = originalKey + `_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n const updatedRawItem = { ...item.rawItem, key: uniqueKey };\n const newItem = this.survey.createItemFromRaw(updatedRawItem);\n this.survey.surveyItems.delete(item.id);\n this.survey.surveyItems.set(newItem.id, newItem);\n item = newItem;\n }\n }\n\n const insertIndex =\n target.index !== undefined\n ? Math.min(target.index, parentGroup.items.length)\n : parentGroup.items.length;\n\n parentGroup.addChild(item.id, insertIndex);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * Handles multiple items and subtrees from the clipboard data\n * @param clipboardData - The clipboard data containing the item(s) to paste\n * @param target - Target location where to paste the item\n * @returns The id of the pasted root item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n // Validate clipboard data\n if (!ItemCopyPaste.isValidClipboardData(clipboardData)) {\n throw new Error(\"Invalid clipboard data format\");\n }\n\n // Create id mapping for all items in the subtree\n const idMapping: { [oldId: string]: string } = {};\n clipboardData.items.forEach(({ itemId }) => {\n idMapping[itemId] = generateId();\n });\n\n // Create all items with updated ids\n clipboardData.items.forEach(({ itemId, itemData }) => {\n const newId = idMapping[itemId];\n if (newId) {\n const updatedItemData = this.updateItemIdsInData(itemData, idMapping);\n updatedItemData.id = newId;\n\n const newItem = this.survey.createItemFromRaw(updatedItemData);\n this.survey.surveyItems.set(newItem.id, newItem);\n\n if (itemId === clipboardData.rootItemId) {\n this.addItemToParentGroup(target, newItem);\n }\n }\n });\n\n // Update translations with new IDs\n const updatedTranslations = this.updateTranslations(clipboardData.translations, idMapping);\n Object.keys(updatedTranslations).forEach((itemId) => {\n // Convert serialized translations back to SurveyItemTranslations instance\n const itemTranslations = new SurveyItemTranslations();\n const serializedData = updatedTranslations[itemId];\n Object.keys(serializedData).forEach((locale) => {\n itemTranslations.setAllForLocale(locale, serializedData[locale]);\n });\n this.survey.translations.setItemTranslations(itemId, itemTranslations);\n });\n\n return idMapping[clipboardData.rootItemId];\n }\n\n // PRIVATE HELPER METHODS\n /**\n * Update all item ids in the raw item data recursively\n */\n private updateItemIdsInData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): RawSurveyItem {\n const updatedData = JSON.parse(JSON.stringify(itemData));\n\n if (updatedData.itemType === ReservedSurveyItemTypes.Group && updatedData.config) {\n const config = updatedData.config as { items?: string[] };\n if (config.items) {\n config.items = config.items.map((childId: string) => idMapping[childId] ?? childId);\n }\n }\n\n this.updateExpressionsInItemData(updatedData, idMapping);\n return updatedData;\n }\n\n /**\n * Update expressions in item data that reference the old ids\n */\n private updateExpressionsInItemData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): void {\n // Update display conditions\n if (itemData.displayConditions?.root) {\n this.updateExpressionReferences(itemData.displayConditions.root, idMapping);\n }\n if (itemData.displayConditions?.components) {\n Object.values(itemData.displayConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update disabled conditions\n if (itemData.disabledConditions?.components) {\n Object.values(itemData.disabledConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update validations\n if (itemData.validations) {\n Object.values(itemData.validations).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n if (itemData.prefills) {\n itemData.prefills.forEach((prefill) => {\n if (prefill.when) {\n this.updateExpressionReferences(prefill.when, idMapping);\n }\n\n if (prefill.source.type === \"expression\") {\n this.updateExpressionReferences(prefill.source.expression, idMapping);\n }\n\n if (prefill.source.type === \"previousResponse\") {\n prefill.source.ref.itemId =\n idMapping[prefill.source.ref.itemId] ?? prefill.source.ref.itemId;\n }\n });\n }\n }\n\n /**\n * Update references in a single expression (recursive)\n */\n private updateExpressionReferences(\n expression: unknown,\n idMapping: { [oldId: string]: string },\n ): void {\n if (!expression || typeof expression !== \"object\") {\n return;\n }\n\n const expr = expression as Record<string, unknown>;\n if (Array.isArray(expr.data)) {\n expr.data.forEach((arg: unknown) => {\n if (arg && typeof arg === \"object\" && arg !== null && \"str\" in arg) {\n const argObj = arg as { str?: string };\n if (\n typeof argObj.str === \"string\" &&\n Object.prototype.hasOwnProperty.call(idMapping, argObj.str)\n ) {\n argObj.str = idMapping[argObj.str];\n }\n this.updateExpressionReferences(arg, idMapping);\n }\n });\n }\n\n Object.keys(expr).forEach((key) => {\n const val = expr[key];\n if (val && typeof val === \"object\") {\n this.updateExpressionReferences(val, idMapping);\n }\n });\n }\n\n /**\n * Update translation keys for the pasted item\n */\n private updateTranslations(\n translations: { [itemId: string]: SerializedTranslations },\n idMapping: { [oldId: string]: string },\n ): { [itemId: string]: SerializedTranslations } {\n const newTranslations: { [itemId: string]: SerializedTranslations } = {};\n\n // Update ids for all items in the translation data\n Object.keys(translations).forEach((itemId) => {\n const itemTranslations = translations[itemId];\n\n // Determine the new key for this item (update the key mapping)\n const newItemId = idMapping[itemId];\n\n // Copy the serialized translations as-is (content is preserved, only keys change)\n newTranslations[newItemId] = itemTranslations;\n });\n\n return newTranslations;\n }\n\n /**\n * Validate clipboard data format\n */\n static isValidClipboardData(data: unknown): data is SurveyItemClipboardData {\n if (typeof data !== \"object\" || data === null || data === undefined) return false;\n const clipboardData = data as SurveyItemClipboardData;\n\n if (\n clipboardData.rootItemId === undefined ||\n typeof clipboardData.rootItemId !== \"string\" ||\n !Array.isArray(clipboardData.items) ||\n clipboardData.items.length === 0 ||\n typeof clipboardData.translations !== \"object\" ||\n clipboardData.translations === null ||\n Array.isArray(clipboardData.translations)\n ) {\n return false;\n }\n\n return (\n clipboardData.type === \"survey-item\" &&\n clipboardData.version === \"1.0.0\" &&\n clipboardData.items.every(\n (item) =>\n typeof item === \"object\" &&\n item !== null &&\n typeof item.itemId === \"string\" &&\n item.itemId.length > 0 &&\n typeof item.itemData === \"object\" &&\n item.itemData !== null &&\n !Array.isArray(item.itemData) &&\n typeof item.itemData.itemType === \"string\",\n ) &&\n clipboardData.items.some((item) => item.itemId === clipboardData.rootItemId)\n );\n }\n}\n","import { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { structuredCloneMethod } from \"../utils\";\n\nexport interface UndoRedoConfig {\n maxTotalMemoryMB: number;\n minHistorySize: number;\n maxHistorySize: number;\n}\n\nexport const CommitSource = {\n USER: \"user\",\n SYSTEM: \"system\",\n ASSISTANT: \"assistant\",\n} as const;\nexport type CommitSource = (typeof CommitSource)[keyof typeof CommitSource];\n\nexport interface CommitMeta {\n label: string;\n source?: CommitSource;\n}\n\nexport interface AssetPatch {\n assetId: string;\n prev?: RawSurveyAsset;\n next?: RawSurveyAsset;\n}\n\ninterface BaseHistoryEntry {\n timestamp: number;\n meta: CommitMeta;\n memorySize: number;\n}\n\ninterface SurveySnapshotHistoryEntry extends BaseHistoryEntry {\n kind: \"survey-snapshot\";\n survey: RawSurvey;\n}\n\ninterface AssetChangeHistoryEntry extends BaseHistoryEntry {\n kind: \"asset-change\";\n changes: AssetPatch[];\n}\n\ntype HistoryEntry = SurveySnapshotHistoryEntry | AssetChangeHistoryEntry;\ntype PendingHistoryEntry =\n | Omit<SurveySnapshotHistoryEntry, \"timestamp\" | \"memorySize\">\n | Omit<AssetChangeHistoryEntry, \"timestamp\" | \"memorySize\">;\n\nexport interface SurveyEditorHistoryCommit {\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n}\n\ntype SerializedHistoryEntry =\n | SurveySnapshotHistoryEntry\n | AssetChangeHistoryEntry\n | (BaseHistoryEntry & { survey: RawSurvey });\n\n// Memory calculation utilities\nclass MemoryCalculator {\n private static encoder = new TextEncoder();\n\n static calculateSize(obj: object): number {\n const jsonString = JSON.stringify(obj);\n return this.encoder.encode(jsonString).length;\n }\n\n static formatBytes(bytes: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\n let size = bytes;\n let unitIndex = 0;\n\n while (size >= 1024 && unitIndex < units.length - 1) {\n size /= 1024;\n unitIndex++;\n }\n\n return `${size.toFixed(1)} ${units[unitIndex]}`;\n }\n}\n\nfunction cloneAssets(\n assets?: Record<string, RawSurveyAsset>,\n): Record<string, RawSurveyAsset> | undefined {\n if (!assets || Object.keys(assets).length === 0) {\n return undefined;\n }\n return structuredCloneMethod(assets);\n}\n\nfunction normalizeHistoryEntry(entry: SerializedHistoryEntry): HistoryEntry {\n if (\"kind\" in entry) {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: structuredCloneMethod(entry.changes),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n}\n\nexport class SurveyEditorUndoRedo {\n private history: HistoryEntry[] = [];\n private currentIndex: number = -1;\n private _config: UndoRedoConfig;\n private _initialAssets?: Record<string, RawSurveyAsset>;\n\n constructor(\n initialSurvey: RawSurvey,\n config: Partial<UndoRedoConfig> = {},\n meta: CommitMeta = { label: \"Initial state\", source: CommitSource.SYSTEM },\n initialAssets?: Record<string, RawSurveyAsset>,\n ) {\n this._config = {\n maxTotalMemoryMB: 50,\n minHistorySize: 10,\n maxHistorySize: 200,\n ...config,\n };\n this._initialAssets = cloneAssets(initialAssets);\n\n this.saveSnapshot(initialSurvey, meta);\n }\n\n private saveEntry(entry: PendingHistoryEntry): void {\n const payload =\n entry.kind === \"survey-snapshot\"\n ? { kind: entry.kind, survey: entry.survey }\n : { kind: entry.kind, changes: entry.changes };\n\n const memorySize = MemoryCalculator.calculateSize(payload);\n\n // Remove any history after current index\n this.history = this.history.slice(0, this.currentIndex + 1);\n\n this.history.push({\n ...structuredCloneMethod(entry),\n timestamp: Date.now(),\n memorySize,\n } as HistoryEntry);\n\n this.currentIndex++;\n\n // Clean up history based on memory usage\n this.cleanupHistory();\n }\n\n private saveSnapshot(survey: RawSurvey, meta: CommitMeta): void {\n this.saveEntry({\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(survey),\n meta,\n });\n }\n\n private getBaseAssetsSize(): number {\n return this._initialAssets ? MemoryCalculator.calculateSize(this._initialAssets) : 0;\n }\n\n private cleanupHistory(): void {\n const maxMemoryBytes = this._config.maxTotalMemoryMB * 1024 * 1024;\n\n // Remove oldest states while preserving minimum.\n while (\n this.history.length > this._config.minHistorySize &&\n (this.getTotalMemoryUsage() > maxMemoryBytes ||\n this.history.length > this._config.maxHistorySize)\n ) {\n if (this.dropOldestState() <= 0) {\n break;\n }\n }\n }\n\n private dropOldestState(): number {\n if (this.history.length <= 1) {\n return 0;\n }\n\n const nextStateIndex = 1;\n const nextStateSurvey = this.getStateAtIndex(nextStateIndex);\n const nextStateAssets = this.getAssetsAtIndex(nextStateIndex);\n const nextEntry = this.history[nextStateIndex];\n\n const newFirstEntry: SurveySnapshotHistoryEntry = {\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n meta: nextEntry.meta,\n timestamp: nextEntry.timestamp,\n memorySize: MemoryCalculator.calculateSize({\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n }),\n };\n\n const removedBytes = this.history[0].memorySize;\n\n this._initialAssets = cloneAssets(nextStateAssets);\n this.history = [newFirstEntry, ...this.history.slice(nextStateIndex + 1)];\n this.currentIndex--;\n\n return removedBytes;\n }\n\n private getTotalMemoryUsage(): number {\n return (\n this.getBaseAssetsSize() + this.history.reduce((total, entry) => total + entry.memorySize, 0)\n );\n }\n\n private getStateAtIndex(index: number): RawSurvey {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n for (let i = index; i >= 0; i--) {\n const entry = this.history[i];\n if (entry.kind === \"survey-snapshot\") {\n return structuredCloneMethod(entry.survey);\n }\n }\n\n throw new Error(\"Invalid history state\");\n }\n\n private applyAssetPatch(\n assets: Record<string, RawSurveyAsset>,\n patch: AssetPatch,\n ): Record<string, RawSurveyAsset> {\n const nextAssets = structuredCloneMethod(assets);\n if (patch.next) {\n nextAssets[patch.assetId] = structuredCloneMethod(patch.next);\n } else {\n delete nextAssets[patch.assetId];\n }\n return nextAssets;\n }\n\n private getAssetsAtIndex(index: number): Record<string, RawSurveyAsset> | undefined {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n let assets = cloneAssets(this._initialAssets) ?? {};\n\n for (let i = 1; i <= index; i++) {\n const entry = this.history[i];\n if (entry.kind !== \"asset-change\") {\n continue;\n }\n\n for (const patch of entry.changes) {\n assets = this.applyAssetPatch(assets, patch);\n }\n }\n\n return Object.keys(assets).length > 0 ? assets : undefined;\n }\n\n // Commit a change to history\n commit(survey: RawSurvey, meta: CommitMeta): void {\n this.saveSnapshot(survey, meta);\n }\n\n commitAssetChange(changes: AssetPatch[], meta: CommitMeta): void {\n if (changes.length === 0) {\n return;\n }\n\n this.saveEntry({\n kind: \"asset-change\",\n changes: structuredCloneMethod(changes),\n meta,\n });\n }\n\n // Get current committed state\n getCurrentState(): RawSurvey {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getStateAtIndex(this.currentIndex);\n }\n\n getCurrentAssets(): Record<string, RawSurveyAsset> | undefined {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getAssetsAtIndex(this.currentIndex);\n }\n\n undo(): RawSurvey | null {\n if (!this.canUndo()) return null;\n\n this.currentIndex--;\n return this.getCurrentState();\n }\n\n redo(): RawSurvey | null {\n if (!this.canRedo()) return null;\n\n this.currentIndex++;\n return this.getCurrentState();\n }\n\n canUndo(): boolean {\n return this.currentIndex > 0;\n }\n\n canRedo(): boolean {\n return this.currentIndex < this.history.length - 1;\n }\n\n getUndoMeta(): CommitMeta | null {\n if (!this.canUndo()) return null;\n return this.history[this.currentIndex].meta;\n }\n\n getRedoMeta(): CommitMeta | null {\n if (!this.canRedo()) return null;\n return this.history[this.currentIndex + 1].meta;\n }\n\n getMemoryUsage(): { totalMB: number; entries: number } {\n return {\n totalMB: this.getTotalMemoryUsage() / (1024 * 1024),\n entries: this.history.length,\n };\n }\n\n getConfig(): UndoRedoConfig {\n return { ...this._config };\n }\n\n /**\n * Get the full history list with metadata\n */\n getHistory(): Array<{\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n }> {\n return this.history.map((entry, index) => ({\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n }));\n }\n\n /**\n * Get committed history entries after the initial state up to the current index.\n *\n * Redo-only future entries are intentionally omitted so the returned list describes the active\n * change chain from the initial state to the current editor state.\n */\n getCommitsSinceInitial(): SurveyEditorHistoryCommit[] {\n return this.history.slice(1, this.currentIndex + 1).map((entry, offset) => {\n const index = offset + 1;\n return {\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n };\n });\n }\n\n /**\n * Get the current index in the history\n */\n getCurrentIndex(): number {\n return this.currentIndex;\n }\n\n /**\n * Get the total number of history entries\n */\n getHistoryLength(): number {\n return this.history.length;\n }\n\n /**\n * Jump to a specific index in the history (can go forward or backward)\n * @param targetIndex The index to jump to\n * @returns The survey state at the target index, or null if invalid\n */\n jumpToIndex(targetIndex: number): RawSurvey | null {\n if (\n targetIndex < 0 ||\n targetIndex >= this.history.length ||\n targetIndex === this.currentIndex\n ) {\n return null;\n }\n\n this.currentIndex = targetIndex;\n return this.getCurrentState();\n }\n\n /**\n * Check if we can jump to a specific index\n */\n canJumpToIndex(targetIndex: number): boolean {\n return (\n targetIndex >= 0 && targetIndex < this.history.length && targetIndex !== this.currentIndex\n );\n }\n\n /**\n * Serialize the undo/redo state to JSON\n * @returns A JSON-serializable object containing the complete state\n */\n serialize(): {\n history: Array<HistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n } {\n return {\n history: this.history.map((entry) => {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: entry.survey,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: entry.changes,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }),\n currentIndex: this.currentIndex,\n config: { ...this._config },\n initialAssets: cloneAssets(this._initialAssets),\n };\n }\n\n /**\n * Create a new SurveyEditorUndoRedo instance from JSON data\n * @param jsonData The serialized undo/redo state\n * @returns A new SurveyEditorUndoRedo instance with the restored state\n */\n static deserialize(\n jsonData: {\n history: Array<SerializedHistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n },\n initialAssetsOverride?: Record<string, RawSurveyAsset>,\n ): SurveyEditorUndoRedo {\n if (!jsonData.history || !Array.isArray(jsonData.history) || jsonData.history.length === 0) {\n throw new Error(\"Invalid object: history must be an array and must not be empty\");\n }\n\n if (\n typeof jsonData.currentIndex !== \"number\" ||\n jsonData.currentIndex < 0 ||\n jsonData.currentIndex >= jsonData.history.length\n ) {\n throw new Error(\n \"Invalid object: currentIndex must be a valid index within the history array\",\n );\n }\n\n if (!jsonData.config) {\n throw new Error(\"Invalid object: config is required\");\n }\n\n const normalizedHistory = jsonData.history.map(normalizeHistoryEntry);\n\n // Create a new instance with the first survey and config\n const firstEntry = normalizedHistory[0];\n const firstSurvey =\n firstEntry.kind === \"survey-snapshot\"\n ? firstEntry.survey\n : (() => {\n throw new Error(\n \"Invalid object: first history entry must resolve to a survey snapshot\",\n );\n })();\n\n const instance = new SurveyEditorUndoRedo(\n firstSurvey,\n jsonData.config,\n firstEntry.meta,\n initialAssetsOverride ?? jsonData.initialAssets,\n );\n\n // Clear the default initial state and restore the full history\n instance.history = normalizedHistory;\n instance.currentIndex = jsonData.currentIndex;\n instance._initialAssets = cloneAssets(initialAssetsOverride ?? jsonData.initialAssets);\n\n return instance;\n }\n}\n","import { Survey } from \"../survey/survey\";\nimport { CommitMeta, CommitSource, SurveyEditorUndoRedo, type UndoRedoConfig } from \"./undo-redo\";\nimport {\n SurveyItemTranslations,\n SurveyCardContent,\n NavigationContent,\n Content,\n} from \"../survey/utils\";\nimport { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { ItemCopyPaste, SurveyItemClipboardData } from \"./item-copy-paste\";\nimport { Target } from \"./types\";\nimport { SurveyItemCore, RawSurveyItem } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport type { ItemTypeRegistry } from \"../survey/registry/item-registry\";\nimport type { TemplateValueDefinition } from \"../expressions/template-value\";\nimport { structuredCloneMethod } from \"../utils\";\n\n// Interface for serializing SurveyEditor state\nexport interface SerializedSurveyEditor {\n version: string;\n survey: RawSurvey;\n undoRedo: ReturnType<SurveyEditorUndoRedo[\"serialize\"]>;\n hasUncommittedChanges: boolean;\n}\n\nexport interface SurveyEditorConfig extends Partial<UndoRedoConfig> {\n /** Plugin registry for deserializing survey state during undo/redo. Required when survey contains custom item types. */\n pluginRegistry?: ItemTypeRegistry;\n}\n\nfunction stripAssetsFromSurveySnapshot(survey: RawSurvey): RawSurvey {\n const snapshot = structuredCloneMethod(survey);\n delete snapshot.assets;\n return snapshot;\n}\n\nfunction mergeSurveySnapshotWithAssets(\n snapshot: RawSurvey,\n assets?: RawSurvey[\"assets\"],\n): RawSurvey {\n const merged = structuredCloneMethod(snapshot);\n\n if (assets && Object.keys(assets).length > 0) {\n merged.assets = structuredCloneMethod(assets);\n } else {\n delete merged.assets;\n }\n\n return merged;\n}\n\nexport class SurveyEditor {\n private _survey: Survey;\n private _undoRedo: SurveyEditorUndoRedo;\n private _hasUncommittedChanges: boolean = false;\n private _pluginRegistry?: ItemTypeRegistry;\n\n constructor(survey: Survey, config: SurveyEditorConfig = {}, meta?: CommitMeta) {\n this._survey = survey;\n const { pluginRegistry, ...undoRedoConfig } = config;\n this._pluginRegistry = pluginRegistry;\n const serialized = survey.serialize();\n this._undoRedo = new SurveyEditorUndoRedo(\n stripAssetsFromSurveySnapshot(serialized),\n undoRedoConfig,\n meta,\n serialized.assets,\n );\n }\n\n /** Returns an immutable copy of the current survey state. */\n get survey(): Survey {\n const serialized = this._survey.serialize();\n const registry = this._pluginRegistry ?? this._survey.getPluginRegistry();\n return Survey.fromJson(serialized, registry);\n }\n\n get hasUncommittedChanges(): boolean {\n return this._hasUncommittedChanges;\n }\n\n // Expose the undo-redo instance directly\n get undoRedo(): SurveyEditorUndoRedo {\n return this._undoRedo;\n }\n\n // Commit current changes to undo/redo history\n commit(meta: CommitMeta): void {\n if (!this._hasUncommittedChanges) {\n return;\n }\n\n this._undoRedo.commit(stripAssetsFromSurveySnapshot(this._survey.serialize()), meta);\n this._hasUncommittedChanges = false;\n }\n\n private restoreHistoryState(snapshot: RawSurvey, assets?: RawSurvey[\"assets\"]): void {\n this._survey = Survey.fromJson(\n mergeSurveySnapshotWithAssets(snapshot, assets),\n this._pluginRegistry,\n );\n }\n\n commitIfNeeded(): void {\n if (this._hasUncommittedChanges) {\n this.commit({\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n });\n }\n }\n\n // Undo to previous state\n undo(): boolean {\n if (this._hasUncommittedChanges) {\n // If there are uncommitted changes, revert to last committed state\n this.restoreHistoryState(this._undoRedo.getCurrentState(), this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n } else {\n // Normal undo operation\n const previousState = this._undoRedo.undo();\n if (previousState) {\n this.restoreHistoryState(previousState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n }\n\n // Redo to next state\n redo(): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot redo when there are uncommitted changes\n return false;\n }\n\n const nextState = this._undoRedo.redo();\n if (nextState) {\n this.restoreHistoryState(nextState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n // Enhanced undo/redo methods that use the exposed instance\n /**\n * Jump to a specific index in the history (can go forward or backward)\n */\n jumpToIndex(targetIndex: number): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot jump to specific index with uncommitted changes\n return false;\n }\n\n const targetState = this._undoRedo.jumpToIndex(targetIndex);\n if (targetState) {\n this.restoreHistoryState(targetState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n canUndo(): boolean {\n return this._hasUncommittedChanges || this._undoRedo.canUndo();\n }\n\n canRedo(): boolean {\n return !this._hasUncommittedChanges && this._undoRedo.canRedo();\n }\n\n getUndoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return {\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n };\n }\n return this._undoRedo.getUndoMeta();\n }\n\n getRedoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return null;\n }\n return this._undoRedo.getRedoMeta();\n }\n\n // Get memory usage statistics\n getMemoryUsage(): { totalMB: number; entries: number } {\n return this._undoRedo.getMemoryUsage();\n }\n\n // Get undo/redo configuration\n getUndoRedoConfig(): UndoRedoConfig {\n return this._undoRedo.getConfig();\n }\n\n /**\n * Get committed changes after the initial editor state up to the current undo/redo position.\n */\n getCommitsSinceInitial() {\n return this._undoRedo.getCommitsSinceInitial();\n }\n\n /**\n * Serialize the SurveyEditor state to JSON\n * @returns A JSON-serializable object containing the complete editor state\n */\n toJson(): SerializedSurveyEditor {\n return {\n version: \"1.0.0\",\n survey: this._survey.serialize(),\n undoRedo: this._undoRedo.serialize(),\n hasUncommittedChanges: this._hasUncommittedChanges,\n };\n }\n\n /**\n * Create a new SurveyEditor instance from JSON data\n * @param jsonData The serialized editor state\n * @param pluginRegistry Optional plugin registry for deserializing survey state (required when survey contains custom item types)\n * @returns A new SurveyEditor instance with the restored state\n */\n static fromJson(\n jsonData: SerializedSurveyEditor,\n pluginRegistry?: ItemTypeRegistry,\n ): SurveyEditor {\n if (!jsonData.survey) {\n throw new Error(\"Invalid object: survey is required\");\n }\n\n if (!jsonData.undoRedo) {\n throw new Error(\"Invalid object: undoRedo is required\");\n }\n\n if (typeof jsonData.hasUncommittedChanges !== \"boolean\") {\n throw new Error(\"Invalid object: hasUncommittedChanges must be a boolean\");\n }\n\n // Validate version (for future compatibility)\n if (jsonData.version && !jsonData.version.startsWith(\"1.\")) {\n console.warn(\n `Warning: Loading SurveyEditor with version ${jsonData.version}, current version is 1.0.0`,\n );\n }\n\n // Create survey from JSON\n const survey = Survey.fromJson(jsonData.survey, pluginRegistry);\n\n // Create a new editor instance\n const editor = new SurveyEditor(survey, { pluginRegistry });\n\n // Restore undo/redo state\n editor._undoRedo = SurveyEditorUndoRedo.deserialize(\n {\n ...jsonData.undoRedo,\n history: jsonData.undoRedo.history.map((entry) =>\n \"survey\" in entry\n ? {\n ...entry,\n survey: stripAssetsFromSurveySnapshot(entry.survey),\n }\n : entry,\n ),\n },\n jsonData.survey.assets,\n );\n\n // Infer whether the live survey contains uncommitted survey changes by comparing\n // the current survey content to the current history entry, ignoring assets.\n editor._hasUncommittedChanges =\n JSON.stringify(stripAssetsFromSurveySnapshot(jsonData.survey)) !==\n JSON.stringify(editor._undoRedo.getCurrentState());\n\n return editor;\n }\n\n private markAsModified(): void {\n this._hasUncommittedChanges = true;\n }\n\n private createEditorTimestamp(): string {\n return new Date().toISOString();\n }\n\n private touchItemModifiedMetadata(\n itemId: string,\n timestamp = this.createEditorTimestamp(),\n ): void {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return;\n }\n\n item.setModifiedAt(timestamp);\n }\n\n addItem(target: Target, item: SurveyItemCore, content?: SurveyItemTranslations): void {\n // Mark as modified (uncommitted change)\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n\n // Find the parent group item\n let parentGroup: GroupItemCore;\n\n if (!target) {\n // If no target provided, add to root\n\n const rootItem = this._survey.rootItem;\n if (!rootItem) {\n throw new Error(\"No root group found in survey\");\n }\n if (!(rootItem instanceof GroupItemCore)) {\n throw new Error(\"Root item is not a group item\");\n }\n parentGroup = rootItem;\n } else {\n // Find the target parent group\n const targetItem = this._survey.surveyItems.get(target.parentId);\n\n if (!targetItem) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Parent item '${target.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n parentGroup = targetItem;\n }\n\n if (parentGroup.hasChild(item.id)) {\n throw new Error(`Item ${item.id} already in this group`);\n }\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n parentGroup.items?.includes(sItem.id),\n );\n let counter = 1;\n const originalKey = item.key;\n let uniqueKey = originalKey;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${originalKey}_${counter}`;\n counter++;\n }\n\n // Determine insertion index\n let insertIndex: number;\n if (target?.index !== undefined) {\n // Insert at specified index, or at end if index is larger than array length\n insertIndex = Math.min(target.index, parentGroup.items.length);\n } else {\n // Insert at the end\n insertIndex = parentGroup.items.length;\n }\n\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n\n // Add the item to the survey items collection\n this._survey.surveyItems.set(item.id, item);\n\n // Add the item to the parent group (uses addChild for proper persistence)\n parentGroup.addChild(item.id, insertIndex);\n this.touchItemModifiedMetadata(parentGroup.id, timestamp);\n\n // Update translations in the survey\n if (content) {\n this._survey.translations.setItemTranslations(item.id, content);\n }\n }\n\n // Remove an item from the survey\n removeItem(itemId: string, nested: boolean = false): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n // Find parent group and remove from its items array\n const parentItem = this._survey.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Item with id '${itemId}' is the root item`);\n }\n\n if (item instanceof GroupItemCore) {\n for (const childId of item.getChildrenIds()) {\n this.removeItem(childId, true);\n }\n }\n\n // Remove from survey items\n this._survey.surveyItems.delete(itemId);\n\n // Remove translations\n this._survey.translations?.onItemDeleted(itemId);\n\n if (!nested) {\n parentItem.removeChild(itemId);\n this.touchItemModifiedMetadata(parentItem.id, timestamp);\n }\n return true;\n }\n\n // Move an item to a different position\n moveItem(itemId: string, newTarget: Target): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n // Check if item exists\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Check if new target exists and is a group\n const targetItem = this._survey.surveyItems.get(newTarget.parentId);\n if (!targetItem) {\n throw new Error(`Target parent with id '${newTarget.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Target parent '${newTarget.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n // Check if new target is not a child of the current item (prevent circular reference)\n if (this._survey.isDescendantOf(newTarget.parentId, itemId)) {\n throw new Error(`Cannot move item '${itemId}' to its descendant '${newTarget.parentId}'`);\n }\n\n // If the item is already in the target parent\n const currentParentItem = this._survey.getParentItem(itemId);\n if (currentParentItem?.id === newTarget.parentId) {\n throw new Error(`Item '${itemId}' is already in the target parent '${newTarget.parentId}'`);\n }\n\n // Remove item from current parent's items array\n if (currentParentItem) {\n const currentParentGroup = currentParentItem as GroupItemCore;\n currentParentGroup.removeChild(itemId);\n this.touchItemModifiedMetadata(currentParentGroup.id, timestamp);\n }\n\n // Add item to new parent's items array\n const targetGroup = targetItem as GroupItemCore;\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n targetGroup.hasChild(sItem.id),\n );\n let counter = 1;\n let uniqueKey = item.key;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${item.key}_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n }\n\n const insertIndex =\n newTarget.index !== undefined\n ? Math.min(newTarget.index, targetGroup.items.length)\n : targetGroup.items.length;\n\n targetGroup.addChild(itemId, insertIndex);\n this.touchItemModifiedMetadata(targetGroup.id, timestamp);\n this.touchItemModifiedMetadata(itemId, timestamp);\n\n return true;\n }\n\n /**\n * Get a deep copy of an item's raw data.\n * The returned object is independent of the survey—mutating it will not affect the survey.\n * Use this when you need to edit an item in a form or pass it to updateItem after modifications.\n *\n * @param itemId - The ID of the item to copy\n * @returns A deep copy of the item's RawSurveyItem data\n * @throws Error if the item is not found\n */\n getItemDataCopy(itemId: string): RawSurveyItem {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n return JSON.parse(JSON.stringify(item.rawItem)) as RawSurveyItem;\n }\n\n /**\n * Update an item's data in the survey.\n * Can update common attributes (displayConditions, disabledConditions, validations, etc.)\n * as well as type-specific config.\n *\n * Use getItemDataCopy to obtain an editable copy, modify it, then pass it here.\n * Alternatively, pass a Partial to merge specific fields (top-level keys only;\n * e.g. config replaces the entire config object).\n *\n * @param itemId - The ID of the item to update (must match data.id if provided)\n * @param rawItemData - Full RawSurveyItem or Partial to merge. The id cannot be changed.\n */\n updateItem(itemId: string, rawItemData: RawSurveyItem | Partial<RawSurveyItem>): void {\n const existingItem = this._survey.surveyItems.get(itemId);\n if (!existingItem) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n if (\"id\" in rawItemData && rawItemData.id !== undefined && rawItemData.id !== itemId) {\n throw new Error(`Cannot change item id from '${itemId}' to '${rawItemData.id}'`);\n }\n\n const currentRaw = existingItem.rawItem;\n const merged: RawSurveyItem = {\n ...currentRaw,\n ...rawItemData,\n id: itemId, // Ensure id is never changed\n };\n\n // Reject key change if it would collide with a sibling\n const newKey = merged.key ?? existingItem.key;\n const parentGroup = this._survey.getParentItem(itemId);\n if (parentGroup) {\n const siblingWithSameKey = (parentGroup.items ?? [])\n .filter((id) => id !== itemId)\n .map((id) => this._survey.surveyItems.get(id))\n .find((s) => s !== undefined && s.key === newKey);\n if (siblingWithSameKey) {\n throw new Error(\n `Key '${newKey}' is already in use by sibling item '${siblingWithSameKey.id}'`,\n );\n }\n }\n\n const newItem = this._survey.createItemFromRaw({\n ...merged,\n editorMetadata: existingItem.rawItem.editorMetadata,\n });\n newItem.setModifiedAt(this.createEditorTimestamp());\n this._survey.surveyItems.set(itemId, newItem);\n this.markAsModified();\n }\n\n // TODO: add also to update component translations (updating part of the item)\n // Update item translations\n updateItemTranslations(itemId: string, updatedContent?: SurveyItemTranslations): boolean {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n this.markAsModified();\n item.setModifiedAt(this.createEditorTimestamp());\n this._survey.translations.setItemTranslations(itemId, updatedContent);\n\n return true;\n }\n\n /**\n * Update survey-level translations that are not tied to specific items.\n * Use these for survey card, navigation, validation messages, etc.\n */\n updateSurveyTranslations(updates: {\n surveyCard?: { locale: string; content?: SurveyCardContent };\n navigation?: { locale: string; content?: NavigationContent };\n validationMessages?: { locale: string; content?: { invalidResponse?: Content } };\n }): void {\n this.markAsModified();\n if (updates.surveyCard) {\n this._survey.translations.setSurveyCardContent(\n updates.surveyCard.locale,\n updates.surveyCard.content,\n );\n }\n if (updates.navigation) {\n this._survey.translations.setNavigationContent(\n updates.navigation.locale,\n updates.navigation.content,\n );\n }\n if (updates.validationMessages) {\n this._survey.translations.setValidationMessages(\n updates.validationMessages.locale,\n updates.validationMessages.content,\n );\n }\n }\n\n /**\n * Get maxItemsPerPage immutably (returns a copy).\n */\n getMaxItemsPerPage(): { large: number; small: number } | undefined {\n const val = this._survey.maxItemsPerPage;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update maxItemsPerPage.\n */\n updateMaxItemsPerPage(value: { large: number; small: number } | undefined): void {\n this.markAsModified();\n this._survey.maxItemsPerPage = value ? { ...value } : undefined;\n }\n\n /**\n * Get metadata immutably (returns a copy).\n */\n getMetadata(): { [key: string]: string } | undefined {\n const val = this._survey.metadata;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update metadata.\n */\n updateMetadata(metadata: { [key: string]: string } | undefined): void {\n this.markAsModified();\n this._survey.metadata = metadata ? { ...metadata } : undefined;\n }\n\n /**\n * Get a template value immutably (returns a deep copy).\n */\n getTemplateValue(key: string): TemplateValueDefinition | undefined {\n const val = this._survey.getTemplateValue(key);\n return val ? structuredCloneMethod(val) : undefined;\n }\n\n /**\n * Get all template values immutably (returns a new Map with deep-copied values).\n */\n getTemplateValues(): Map<string, TemplateValueDefinition> {\n const keys = this._survey.getTemplateValueKeys();\n const result = new Map<string, TemplateValueDefinition>();\n for (const key of keys) {\n const val = this._survey.getTemplateValue(key);\n if (val) {\n result.set(key, structuredCloneMethod(val));\n }\n }\n return result;\n }\n\n /**\n * Add or replace a template value.\n */\n setTemplateValue(key: string, templateValue: TemplateValueDefinition): void {\n this.markAsModified();\n this._survey.setTemplateValue(key, structuredCloneMethod(templateValue));\n }\n\n /**\n * Remove a template value.\n */\n removeTemplateValue(key: string): void {\n this.markAsModified();\n this._survey.deleteTemplateValue(key);\n }\n\n /**\n * Get a survey asset immutably.\n */\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._survey.getAsset(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n /**\n * Get all survey assets immutably.\n */\n getAssets(): Map<string, RawSurveyAsset> {\n return this._survey.getAssets();\n }\n\n /**\n * Add or replace a survey asset.\n */\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n const previousAsset = this._survey.getAsset(assetId);\n this._survey.setAsset(assetId, structuredCloneMethod(asset));\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n next: structuredCloneMethod(asset),\n },\n ],\n {\n label: `Update asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Remove a survey asset.\n */\n removeAsset(assetId: string): void {\n const previousAsset = this._survey.getAsset(assetId);\n if (!previousAsset) {\n return;\n }\n this._survey.deleteAsset(assetId);\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n },\n ],\n {\n label: `Remove asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * @param itemId - The ID of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const copyPaste = new ItemCopyPaste(this._survey);\n return copyPaste.copyItem(itemId);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * @param clipboardData - The clipboard data containing the item to paste\n * @param target - Target location where to paste the item\n * @returns The ID of the pasted item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const itemIdsBeforePaste = new Set(this._survey.surveyItems.keys());\n const copyPaste = new ItemCopyPaste(this._survey);\n const newItemId = copyPaste.pasteItem(clipboardData, target);\n const pastedItemIds = Array.from(this._survey.surveyItems.keys()).filter(\n (itemId) => !itemIdsBeforePaste.has(itemId),\n );\n\n for (const itemId of pastedItemIds) {\n const item = this._survey.surveyItems.get(itemId);\n if (item) {\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n }\n }\n this.touchItemModifiedMetadata(target.parentId, timestamp);\n\n return newItemId;\n }\n}\n"],"mappings":";;AA2BA,IAAa,gBAAb,MAAa,cAAc;CACzB;CAEA,YAAY,QAAgB;AAC1B,OAAK,SAAS;;;;;;;;CAShB,SAAS,QAAyC;AAEhD,MAAI,CADS,KAAK,OAAO,YAAY,IAAI,OAChC,CACP,OAAM,IAAI,MAAM,iBAAiB,OAAO,aAAa;EAIvD,MAAM,cAAc,KAAK,oBAAoB,OAAO;EAGpD,MAAM,QAAQ,YAAY,KAAK,OAAO;GACpC,MAAM,OAAO,KAAK,OAAO,YAAY,IAAI,GAAG;AAC5C,OAAI,CAAC,KAAM,OAAM,IAAI,MAAM,iBAAiB,GAAG,yBAAyB;AACxE,UAAO;IAAE,QAAQ;IAAI,UAAU,KAAK;IAAS;IAC7C;EAGF,MAAM,eAA6D,EAAE;AACrE,cAAY,SAAS,OAAO;AAC1B,OAAI;IACF,MAAM,mBAAmB,KAAK,OAAO,oBAAoB,GAAG;AAC5D,QAAI,kBAAkB,SAAS,QAAQ;KACrC,MAAM,yBAAiD,EAAE;AACzD,sBAAiB,QAAQ,SAAS,WAAW;MAC3C,MAAM,gBAAgB,iBAAiB,gBAAgB,OAAO;AAC9D,UAAI,cACF,wBAAuB,UAAU;OAEnC;AACF,kBAAa,MAAM;UAEnB,cAAa,MAAM,EAAE;WAEjB;AACN,iBAAa,MAAM,EAAE;;IAEvB;AAYF,SAAO;GARL,MAAM;GACN,SAAS;GACF;GACO;GACd,YAAY;GACZ,WAAW,KAAK,KAAK;GAGH;;;;;;;CAQtB,oBAA4B,QAA0B;EACpD,MAAM,cAAwB,CAAC,OAAO;E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GACtB,CACF;;;;;;;CAQH,SAAS,QAAyC;AAEhD,SAAO,IADe,cAAc,KAAK,QACzB,CAAC,SAAS,OAAO;;;;;;;;CASnC,UAAU,eAAwC,QAAwB;AACxE,OAAK,gBAAgB;EACrB,MAAM,YAAY,KAAK,uBAAuB;EAC9C,MAAM,qBAAqB,IAAI,IAAI,KAAK,QAAQ,YAAY,MAAM,CAAC;EAEnE,MAAM,YAAY,IADI,cAAc,KAAK,QACd,CAAC,UAAU,eAAe,OAAO;EAC5D,MAAM,gBAAgB,MAAM,KAAK,KAAK,QAAQ,YAAY,MAAM,CAAC,CAAC,QAC/D,WAAW,CAAC,mBAAmB,IAAI,OAAO,CAC5C;AAED,OAAK,MAAM,UAAU,eAAe;GAClC,MAAM,OAAO,KAAK,QAAQ,YAAY,IAAI,OAAO;AACjD,OAAI,MAAM;AACR,SAAK,aAAa,UAAU;AAC5B,SAAK,cAAc,UAAU;;;AAGjC,OAAK,0BAA0B,OAAO,UAAU,UAAU;AAE1D,SAAO"}
|
|
1
|
+
{"version":3,"file":"editor.mjs","names":[],"sources":["../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"sourcesContent":["import { Survey } from \"../survey/survey\";\nimport { SurveyItemCore } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport { ReservedSurveyItemTypes } from \"../survey/items/types\";\nimport { SurveyItemTranslations, JsonComponentContent } from \"../survey/utils\";\nimport { RawSurveyItem } from \"../survey/items/survey-item-json\";\nimport { Target } from \"./types\";\nimport { generateId } from \"../utils\";\n\n// Serialized translation data format for clipboard\nexport type SerializedTranslations = {\n [locale: string]: JsonComponentContent;\n};\n\n// Clipboard data structure for copy-paste functionality\nexport interface SurveyItemClipboardData {\n type: \"survey-item\";\n version: string;\n items: Array<{\n itemId: string;\n itemData: RawSurveyItem;\n }>;\n translations: { [itemId: string]: SerializedTranslations };\n rootItemId: string; // The id of the main item being copied\n timestamp: number;\n}\n\nexport class ItemCopyPaste {\n private survey: Survey;\n\n constructor(survey: Survey) {\n this.survey = survey;\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * When copying a group, automatically includes all items in the subtree\n * @param itemId - The id of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const item = this.survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Collect all items to copy (including subtree for groups)\n const itemsToCopy = this.collectItemsForCopy(itemId);\n\n // Create items array with their data\n const items = itemsToCopy.map((id) => {\n const item = this.survey.surveyItems.get(id);\n if (!item) throw new Error(`Item with id '${id}' not found during copy`);\n return { itemId: id, itemData: item.rawItem };\n });\n\n // Collect translations for all items\n const translations: { [itemId: string]: SerializedTranslations } = {};\n itemsToCopy.forEach((id) => {\n try {\n const itemTranslations = this.survey.getItemTranslations(id);\n if (itemTranslations?.locales?.length) {\n const serializedTranslations: SerializedTranslations = {};\n itemTranslations.locales.forEach((locale) => {\n const localeContent = itemTranslations.getAllForLocale(locale);\n if (localeContent) {\n serializedTranslations[locale] = localeContent;\n }\n });\n translations[id] = serializedTranslations;\n } else {\n translations[id] = {};\n }\n } catch {\n translations[id] = {};\n }\n });\n\n // Create clipboard data\n const clipboardData: SurveyItemClipboardData = {\n type: \"survey-item\",\n version: \"1.0.0\",\n items: items,\n translations: translations,\n rootItemId: itemId,\n timestamp: Date.now(),\n };\n\n return clipboardData;\n }\n\n /**\n * Collect all items that should be copied, including subtree for groups\n * @param itemId - The root item id\n * @returns Array of item keys to copy\n */\n private collectItemsForCopy(itemId: string): string[] {\n const itemsToCopy: string[] = [itemId];\n const item = this.survey.surveyItems.get(itemId);\n\n if (!item) {\n return [];\n }\n\n // If this is a group item, collect all child items recursively\n if (item instanceof GroupItemCore) {\n const childIds = item.items;\n if (childIds.length > 0) {\n childIds.forEach((childId) => {\n const childItems = this.collectItemsForCopy(childId);\n itemsToCopy.push(...childItems);\n });\n }\n }\n\n return itemsToCopy;\n }\n\n /**\n * Add an item to its parent group.\n * Ensures key uniqueness among siblings.\n * @param target - Target location information\n * @param item - The item to add (may have key adjusted for uniqueness)\n */\n private addItemToParentGroup(target: Target, item: SurveyItemCore): void {\n const parentGroup = this.survey.surveyItems.get(target.parentId);\n\n if (!parentGroup) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(parentGroup instanceof GroupItemCore)) {\n throw new Error(`Parent item '${target.parentId}' is not a group item`);\n }\n\n const siblingIds = parentGroup.items;\n const siblings = siblingIds\n .map((id) => this.survey.surveyItems.get(id))\n .filter((s): s is SurveyItemCore => s !== undefined);\n const siblingKeys = new Set(siblings.map((s) => s.key));\n\n let uniqueKey = item.key;\n if (siblingKeys.has(uniqueKey)) {\n let counter = 1;\n const originalKey = item.key;\n while (siblingKeys.has(uniqueKey)) {\n uniqueKey = originalKey + `_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n const updatedRawItem = { ...item.rawItem, key: uniqueKey };\n const newItem = this.survey.createItemFromRaw(updatedRawItem);\n this.survey.surveyItems.delete(item.id);\n this.survey.surveyItems.set(newItem.id, newItem);\n item = newItem;\n }\n }\n\n const insertIndex =\n target.index !== undefined\n ? Math.min(target.index, parentGroup.items.length)\n : parentGroup.items.length;\n\n parentGroup.addChild(item.id, insertIndex);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * Handles multiple items and subtrees from the clipboard data\n * @param clipboardData - The clipboard data containing the item(s) to paste\n * @param target - Target location where to paste the item\n * @returns The id of the pasted root item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n // Validate clipboard data\n if (!ItemCopyPaste.isValidClipboardData(clipboardData)) {\n throw new Error(\"Invalid clipboard data format\");\n }\n\n // Create id mapping for all items in the subtree\n const idMapping: { [oldId: string]: string } = {};\n clipboardData.items.forEach(({ itemId }) => {\n idMapping[itemId] = generateId();\n });\n\n // Create all items with updated ids\n clipboardData.items.forEach(({ itemId, itemData }) => {\n const newId = idMapping[itemId];\n if (newId) {\n const updatedItemData = this.updateItemIdsInData(itemData, idMapping);\n updatedItemData.id = newId;\n\n const newItem = this.survey.createItemFromRaw(updatedItemData);\n this.survey.surveyItems.set(newItem.id, newItem);\n\n if (itemId === clipboardData.rootItemId) {\n this.addItemToParentGroup(target, newItem);\n }\n }\n });\n\n // Update translations with new IDs\n const updatedTranslations = this.updateTranslations(clipboardData.translations, idMapping);\n Object.keys(updatedTranslations).forEach((itemId) => {\n // Convert serialized translations back to SurveyItemTranslations instance\n const itemTranslations = new SurveyItemTranslations();\n const serializedData = updatedTranslations[itemId];\n Object.keys(serializedData).forEach((locale) => {\n itemTranslations.setAllForLocale(locale, serializedData[locale]);\n });\n this.survey.translations.setItemTranslations(itemId, itemTranslations);\n });\n\n return idMapping[clipboardData.rootItemId];\n }\n\n // PRIVATE HELPER METHODS\n /**\n * Update all item ids in the raw item data recursively\n */\n private updateItemIdsInData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): RawSurveyItem {\n const updatedData = JSON.parse(JSON.stringify(itemData));\n\n if (updatedData.itemType === ReservedSurveyItemTypes.Group && updatedData.config) {\n const config = updatedData.config as { items?: string[] };\n if (config.items) {\n config.items = config.items.map((childId: string) => idMapping[childId] ?? childId);\n }\n }\n\n this.updateExpressionsInItemData(updatedData, idMapping);\n return updatedData;\n }\n\n /**\n * Update expressions in item data that reference the old ids\n */\n private updateExpressionsInItemData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): void {\n // Update display conditions\n if (itemData.displayConditions?.root) {\n this.updateExpressionReferences(itemData.displayConditions.root, idMapping);\n }\n if (itemData.displayConditions?.components) {\n Object.values(itemData.displayConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update disabled conditions\n if (itemData.disabledConditions?.components) {\n Object.values(itemData.disabledConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update validations\n if (itemData.validations) {\n Object.values(itemData.validations).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n if (itemData.prefills) {\n itemData.prefills.forEach((prefill) => {\n if (prefill.when) {\n this.updateExpressionReferences(prefill.when, idMapping);\n }\n\n if (prefill.source.type === \"expression\") {\n this.updateExpressionReferences(prefill.source.expression, idMapping);\n }\n\n if (prefill.source.type === \"previousResponse\") {\n prefill.source.ref.itemId =\n idMapping[prefill.source.ref.itemId] ?? prefill.source.ref.itemId;\n }\n });\n }\n }\n\n /**\n * Update references in a single expression (recursive)\n */\n private updateExpressionReferences(\n expression: unknown,\n idMapping: { [oldId: string]: string },\n ): void {\n if (!expression || typeof expression !== \"object\") {\n return;\n }\n\n const expr = expression as Record<string, unknown>;\n if (Array.isArray(expr.data)) {\n expr.data.forEach((arg: unknown) => {\n if (arg && typeof arg === \"object\" && arg !== null && \"str\" in arg) {\n const argObj = arg as { str?: string };\n if (\n typeof argObj.str === \"string\" &&\n Object.prototype.hasOwnProperty.call(idMapping, argObj.str)\n ) {\n argObj.str = idMapping[argObj.str];\n }\n this.updateExpressionReferences(arg, idMapping);\n }\n });\n }\n\n Object.keys(expr).forEach((key) => {\n const val = expr[key];\n if (val && typeof val === \"object\") {\n this.updateExpressionReferences(val, idMapping);\n }\n });\n }\n\n /**\n * Update translation keys for the pasted item\n */\n private updateTranslations(\n translations: { [itemId: string]: SerializedTranslations },\n idMapping: { [oldId: string]: string },\n ): { [itemId: string]: SerializedTranslations } {\n const newTranslations: { [itemId: string]: SerializedTranslations } = {};\n\n // Update ids for all items in the translation data\n Object.keys(translations).forEach((itemId) => {\n const itemTranslations = translations[itemId];\n\n // Determine the new key for this item (update the key mapping)\n const newItemId = idMapping[itemId];\n\n // Copy the serialized translations as-is (content is preserved, only keys change)\n newTranslations[newItemId] = itemTranslations;\n });\n\n return newTranslations;\n }\n\n /**\n * Validate clipboard data format\n */\n static isValidClipboardData(data: unknown): data is SurveyItemClipboardData {\n if (typeof data !== \"object\" || data === null || data === undefined) return false;\n const clipboardData = data as SurveyItemClipboardData;\n\n if (\n clipboardData.rootItemId === undefined ||\n typeof clipboardData.rootItemId !== \"string\" ||\n !Array.isArray(clipboardData.items) ||\n clipboardData.items.length === 0 ||\n typeof clipboardData.translations !== \"object\" ||\n clipboardData.translations === null ||\n Array.isArray(clipboardData.translations)\n ) {\n return false;\n }\n\n return (\n clipboardData.type === \"survey-item\" &&\n clipboardData.version === \"1.0.0\" &&\n clipboardData.items.every(\n (item) =>\n typeof item === \"object\" &&\n item !== null &&\n typeof item.itemId === \"string\" &&\n item.itemId.length > 0 &&\n typeof item.itemData === \"object\" &&\n item.itemData !== null &&\n !Array.isArray(item.itemData) &&\n typeof item.itemData.itemType === \"string\",\n ) &&\n clipboardData.items.some((item) => item.itemId === clipboardData.rootItemId)\n );\n }\n}\n","import { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { structuredCloneMethod } from \"../utils\";\n\nexport interface UndoRedoConfig {\n maxTotalMemoryMB: number;\n minHistorySize: number;\n maxHistorySize: number;\n}\n\nexport const CommitSource = {\n USER: \"user\",\n SYSTEM: \"system\",\n ASSISTANT: \"assistant\",\n} as const;\nexport type CommitSource = (typeof CommitSource)[keyof typeof CommitSource];\n\nexport interface CommitMeta {\n label: string;\n source?: CommitSource;\n}\n\nexport interface AssetPatch {\n assetId: string;\n prev?: RawSurveyAsset;\n next?: RawSurveyAsset;\n}\n\ninterface BaseHistoryEntry {\n timestamp: number;\n meta: CommitMeta;\n memorySize: number;\n}\n\ninterface SurveySnapshotHistoryEntry extends BaseHistoryEntry {\n kind: \"survey-snapshot\";\n survey: RawSurvey;\n}\n\ninterface AssetChangeHistoryEntry extends BaseHistoryEntry {\n kind: \"asset-change\";\n changes: AssetPatch[];\n}\n\ntype HistoryEntry = SurveySnapshotHistoryEntry | AssetChangeHistoryEntry;\ntype PendingHistoryEntry =\n | Omit<SurveySnapshotHistoryEntry, \"timestamp\" | \"memorySize\">\n | Omit<AssetChangeHistoryEntry, \"timestamp\" | \"memorySize\">;\n\nexport interface SurveyEditorHistoryCommit {\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n}\n\ntype SerializedHistoryEntry =\n | SurveySnapshotHistoryEntry\n | AssetChangeHistoryEntry\n | (BaseHistoryEntry & { survey: RawSurvey });\n\n// Memory calculation utilities\nclass MemoryCalculator {\n private static encoder = new TextEncoder();\n\n static calculateSize(obj: object): number {\n const jsonString = JSON.stringify(obj);\n return this.encoder.encode(jsonString).length;\n }\n\n static formatBytes(bytes: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\n let size = bytes;\n let unitIndex = 0;\n\n while (size >= 1024 && unitIndex < units.length - 1) {\n size /= 1024;\n unitIndex++;\n }\n\n return `${size.toFixed(1)} ${units[unitIndex]}`;\n }\n}\n\nfunction cloneAssets(\n assets?: Record<string, RawSurveyAsset>,\n): Record<string, RawSurveyAsset> | undefined {\n if (!assets || Object.keys(assets).length === 0) {\n return undefined;\n }\n return structuredCloneMethod(assets);\n}\n\nfunction normalizeHistoryEntry(entry: SerializedHistoryEntry): HistoryEntry {\n if (\"kind\" in entry) {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: structuredCloneMethod(entry.changes),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n}\n\nexport class SurveyEditorUndoRedo {\n private history: HistoryEntry[] = [];\n private currentIndex: number = -1;\n private _config: UndoRedoConfig;\n private _initialAssets?: Record<string, RawSurveyAsset>;\n\n constructor(\n initialSurvey: RawSurvey,\n config: Partial<UndoRedoConfig> = {},\n meta: CommitMeta = { label: \"Initial state\", source: CommitSource.SYSTEM },\n initialAssets?: Record<string, RawSurveyAsset>,\n ) {\n this._config = {\n maxTotalMemoryMB: 50,\n minHistorySize: 10,\n maxHistorySize: 200,\n ...config,\n };\n this._initialAssets = cloneAssets(initialAssets);\n\n this.saveSnapshot(initialSurvey, meta);\n }\n\n private saveEntry(entry: PendingHistoryEntry): void {\n const payload =\n entry.kind === \"survey-snapshot\"\n ? { kind: entry.kind, survey: entry.survey }\n : { kind: entry.kind, changes: entry.changes };\n\n const memorySize = MemoryCalculator.calculateSize(payload);\n\n // Remove any history after current index\n this.history = this.history.slice(0, this.currentIndex + 1);\n\n this.history.push({\n ...structuredCloneMethod(entry),\n timestamp: Date.now(),\n memorySize,\n } as HistoryEntry);\n\n this.currentIndex++;\n\n // Clean up history based on memory usage\n this.cleanupHistory();\n }\n\n private saveSnapshot(survey: RawSurvey, meta: CommitMeta): void {\n this.saveEntry({\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(survey),\n meta,\n });\n }\n\n private getBaseAssetsSize(): number {\n return this._initialAssets ? MemoryCalculator.calculateSize(this._initialAssets) : 0;\n }\n\n private cleanupHistory(): void {\n const maxMemoryBytes = this._config.maxTotalMemoryMB * 1024 * 1024;\n\n // Remove oldest states while preserving minimum.\n while (\n this.history.length > this._config.minHistorySize &&\n (this.getTotalMemoryUsage() > maxMemoryBytes ||\n this.history.length > this._config.maxHistorySize)\n ) {\n if (this.dropOldestState() <= 0) {\n break;\n }\n }\n }\n\n private dropOldestState(): number {\n if (this.history.length <= 1) {\n return 0;\n }\n\n const nextStateIndex = 1;\n const nextStateSurvey = this.getStateAtIndex(nextStateIndex);\n const nextStateAssets = this.getAssetsAtIndex(nextStateIndex);\n const nextEntry = this.history[nextStateIndex];\n\n const newFirstEntry: SurveySnapshotHistoryEntry = {\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n meta: nextEntry.meta,\n timestamp: nextEntry.timestamp,\n memorySize: MemoryCalculator.calculateSize({\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n }),\n };\n\n const removedBytes = this.history[0].memorySize;\n\n this._initialAssets = cloneAssets(nextStateAssets);\n this.history = [newFirstEntry, ...this.history.slice(nextStateIndex + 1)];\n this.currentIndex--;\n\n return removedBytes;\n }\n\n private getTotalMemoryUsage(): number {\n return (\n this.getBaseAssetsSize() + this.history.reduce((total, entry) => total + entry.memorySize, 0)\n );\n }\n\n private getStateAtIndex(index: number): RawSurvey {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n for (let i = index; i >= 0; i--) {\n const entry = this.history[i];\n if (entry.kind === \"survey-snapshot\") {\n return structuredCloneMethod(entry.survey);\n }\n }\n\n throw new Error(\"Invalid history state\");\n }\n\n private applyAssetPatch(\n assets: Record<string, RawSurveyAsset>,\n patch: AssetPatch,\n ): Record<string, RawSurveyAsset> {\n const nextAssets = structuredCloneMethod(assets);\n if (patch.next) {\n nextAssets[patch.assetId] = structuredCloneMethod(patch.next);\n } else {\n delete nextAssets[patch.assetId];\n }\n return nextAssets;\n }\n\n private getAssetsAtIndex(index: number): Record<string, RawSurveyAsset> | undefined {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n let assets = cloneAssets(this._initialAssets) ?? {};\n\n for (let i = 1; i <= index; i++) {\n const entry = this.history[i];\n if (entry.kind !== \"asset-change\") {\n continue;\n }\n\n for (const patch of entry.changes) {\n assets = this.applyAssetPatch(assets, patch);\n }\n }\n\n return Object.keys(assets).length > 0 ? assets : undefined;\n }\n\n // Commit a change to history\n commit(survey: RawSurvey, meta: CommitMeta): void {\n this.saveSnapshot(survey, meta);\n }\n\n commitAssetChange(changes: AssetPatch[], meta: CommitMeta): void {\n if (changes.length === 0) {\n return;\n }\n\n this.saveEntry({\n kind: \"asset-change\",\n changes: structuredCloneMethod(changes),\n meta,\n });\n }\n\n // Get current committed state\n getCurrentState(): RawSurvey {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getStateAtIndex(this.currentIndex);\n }\n\n getCurrentAssets(): Record<string, RawSurveyAsset> | undefined {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getAssetsAtIndex(this.currentIndex);\n }\n\n undo(): RawSurvey | null {\n if (!this.canUndo()) return null;\n\n this.currentIndex--;\n return this.getCurrentState();\n }\n\n redo(): RawSurvey | null {\n if (!this.canRedo()) return null;\n\n this.currentIndex++;\n return this.getCurrentState();\n }\n\n canUndo(): boolean {\n return this.currentIndex > 0;\n }\n\n canRedo(): boolean {\n return this.currentIndex < this.history.length - 1;\n }\n\n getUndoMeta(): CommitMeta | null {\n if (!this.canUndo()) return null;\n return this.history[this.currentIndex].meta;\n }\n\n getRedoMeta(): CommitMeta | null {\n if (!this.canRedo()) return null;\n return this.history[this.currentIndex + 1].meta;\n }\n\n getMemoryUsage(): { totalMB: number; entries: number } {\n return {\n totalMB: this.getTotalMemoryUsage() / (1024 * 1024),\n entries: this.history.length,\n };\n }\n\n getConfig(): UndoRedoConfig {\n return { ...this._config };\n }\n\n /**\n * Get the full history list with metadata\n */\n getHistory(): Array<{\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n }> {\n return this.history.map((entry, index) => ({\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n }));\n }\n\n /**\n * Get committed history entries after the initial state up to the current index.\n *\n * Redo-only future entries are intentionally omitted so the returned list describes the active\n * change chain from the initial state to the current editor state.\n */\n getCommitsSinceInitial(): SurveyEditorHistoryCommit[] {\n return this.history.slice(1, this.currentIndex + 1).map((entry, offset) => {\n const index = offset + 1;\n return {\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n };\n });\n }\n\n /**\n * Get the current index in the history\n */\n getCurrentIndex(): number {\n return this.currentIndex;\n }\n\n /**\n * Get the total number of history entries\n */\n getHistoryLength(): number {\n return this.history.length;\n }\n\n /**\n * Jump to a specific index in the history (can go forward or backward)\n * @param targetIndex The index to jump to\n * @returns The survey state at the target index, or null if invalid\n */\n jumpToIndex(targetIndex: number): RawSurvey | null {\n if (\n targetIndex < 0 ||\n targetIndex >= this.history.length ||\n targetIndex === this.currentIndex\n ) {\n return null;\n }\n\n this.currentIndex = targetIndex;\n return this.getCurrentState();\n }\n\n /**\n * Check if we can jump to a specific index\n */\n canJumpToIndex(targetIndex: number): boolean {\n return (\n targetIndex >= 0 && targetIndex < this.history.length && targetIndex !== this.currentIndex\n );\n }\n\n /**\n * Serialize the undo/redo state to JSON\n * @returns A JSON-serializable object containing the complete state\n */\n serialize(): {\n history: Array<HistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n } {\n return {\n history: this.history.map((entry) => {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: entry.survey,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: entry.changes,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }),\n currentIndex: this.currentIndex,\n config: { ...this._config },\n initialAssets: cloneAssets(this._initialAssets),\n };\n }\n\n /**\n * Create a new SurveyEditorUndoRedo instance from JSON data\n * @param jsonData The serialized undo/redo state\n * @returns A new SurveyEditorUndoRedo instance with the restored state\n */\n static deserialize(\n jsonData: {\n history: Array<SerializedHistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n },\n initialAssetsOverride?: Record<string, RawSurveyAsset>,\n ): SurveyEditorUndoRedo {\n if (!jsonData.history || !Array.isArray(jsonData.history) || jsonData.history.length === 0) {\n throw new Error(\"Invalid object: history must be an array and must not be empty\");\n }\n\n if (\n typeof jsonData.currentIndex !== \"number\" ||\n jsonData.currentIndex < 0 ||\n jsonData.currentIndex >= jsonData.history.length\n ) {\n throw new Error(\n \"Invalid object: currentIndex must be a valid index within the history array\",\n );\n }\n\n if (!jsonData.config) {\n throw new Error(\"Invalid object: config is required\");\n }\n\n const normalizedHistory = jsonData.history.map(normalizeHistoryEntry);\n\n // Create a new instance with the first survey and config\n const firstEntry = normalizedHistory[0];\n const firstSurvey =\n firstEntry.kind === \"survey-snapshot\"\n ? firstEntry.survey\n : (() => {\n throw new Error(\n \"Invalid object: first history entry must resolve to a survey snapshot\",\n );\n })();\n\n const instance = new SurveyEditorUndoRedo(\n firstSurvey,\n jsonData.config,\n firstEntry.meta,\n initialAssetsOverride ?? jsonData.initialAssets,\n );\n\n // Clear the default initial state and restore the full history\n instance.history = normalizedHistory;\n instance.currentIndex = jsonData.currentIndex;\n instance._initialAssets = cloneAssets(initialAssetsOverride ?? jsonData.initialAssets);\n\n return instance;\n }\n}\n","import { Survey } from \"../survey/survey\";\nimport { CommitMeta, CommitSource, SurveyEditorUndoRedo, type UndoRedoConfig } from \"./undo-redo\";\nimport {\n SurveyItemTranslations,\n SurveyCardContent,\n NavigationContent,\n Content,\n} from \"../survey/utils\";\nimport { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { ItemCopyPaste, SurveyItemClipboardData } from \"./item-copy-paste\";\nimport { Target } from \"./types\";\nimport { SurveyItemCore, RawSurveyItem } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport type { ItemTypeRegistry } from \"../survey/registry/item-registry\";\nimport type { TemplateValueDefinition } from \"../expressions/template-value\";\nimport { structuredCloneMethod } from \"../utils\";\n\n// Interface for serializing SurveyEditor state\nexport interface SerializedSurveyEditor {\n version: string;\n survey: RawSurvey;\n undoRedo: ReturnType<SurveyEditorUndoRedo[\"serialize\"]>;\n hasUncommittedChanges: boolean;\n}\n\nexport interface SurveyEditorConfig extends Partial<UndoRedoConfig> {\n /** Plugin registry for deserializing survey state during undo/redo. Required when survey contains custom item types. */\n pluginRegistry?: ItemTypeRegistry;\n}\n\nfunction stripAssetsFromSurveySnapshot(survey: RawSurvey): RawSurvey {\n const snapshot = structuredCloneMethod(survey);\n delete snapshot.assets;\n return snapshot;\n}\n\nfunction mergeSurveySnapshotWithAssets(\n snapshot: RawSurvey,\n assets?: RawSurvey[\"assets\"],\n): RawSurvey {\n const merged = structuredCloneMethod(snapshot);\n\n if (assets && Object.keys(assets).length > 0) {\n merged.assets = structuredCloneMethod(assets);\n } else {\n delete merged.assets;\n }\n\n return merged;\n}\n\nexport class SurveyEditor {\n private _survey: Survey;\n private _undoRedo: SurveyEditorUndoRedo;\n private _hasUncommittedChanges: boolean = false;\n private _pluginRegistry?: ItemTypeRegistry;\n\n constructor(survey: Survey, config: SurveyEditorConfig = {}, meta?: CommitMeta) {\n this._survey = survey;\n const { pluginRegistry, ...undoRedoConfig } = config;\n this._pluginRegistry = pluginRegistry;\n const serialized = survey.serialize();\n this._undoRedo = new SurveyEditorUndoRedo(\n stripAssetsFromSurveySnapshot(serialized),\n undoRedoConfig,\n meta,\n serialized.assets,\n );\n }\n\n /** Returns an immutable copy of the current survey state. */\n get survey(): Survey {\n const serialized = this._survey.serialize();\n const registry = this._pluginRegistry ?? this._survey.getPluginRegistry();\n return Survey.fromJson(serialized, registry);\n }\n\n get hasUncommittedChanges(): boolean {\n return this._hasUncommittedChanges;\n }\n\n // Expose the undo-redo instance directly\n get undoRedo(): SurveyEditorUndoRedo {\n return this._undoRedo;\n }\n\n // Commit current changes to undo/redo history\n commit(meta: CommitMeta): void {\n if (!this._hasUncommittedChanges) {\n return;\n }\n\n this._undoRedo.commit(stripAssetsFromSurveySnapshot(this._survey.serialize()), meta);\n this._hasUncommittedChanges = false;\n }\n\n private restoreHistoryState(snapshot: RawSurvey, assets?: RawSurvey[\"assets\"]): void {\n this._survey = Survey.fromJson(\n mergeSurveySnapshotWithAssets(snapshot, assets),\n this._pluginRegistry,\n );\n }\n\n commitIfNeeded(): void {\n if (this._hasUncommittedChanges) {\n this.commit({\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n });\n }\n }\n\n // Undo to previous state\n undo(): boolean {\n if (this._hasUncommittedChanges) {\n // If there are uncommitted changes, revert to last committed state\n this.restoreHistoryState(this._undoRedo.getCurrentState(), this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n } else {\n // Normal undo operation\n const previousState = this._undoRedo.undo();\n if (previousState) {\n this.restoreHistoryState(previousState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n }\n\n // Redo to next state\n redo(): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot redo when there are uncommitted changes\n return false;\n }\n\n const nextState = this._undoRedo.redo();\n if (nextState) {\n this.restoreHistoryState(nextState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n // Enhanced undo/redo methods that use the exposed instance\n /**\n * Jump to a specific index in the history (can go forward or backward)\n */\n jumpToIndex(targetIndex: number): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot jump to specific index with uncommitted changes\n return false;\n }\n\n const targetState = this._undoRedo.jumpToIndex(targetIndex);\n if (targetState) {\n this.restoreHistoryState(targetState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n canUndo(): boolean {\n return this._hasUncommittedChanges || this._undoRedo.canUndo();\n }\n\n canRedo(): boolean {\n return !this._hasUncommittedChanges && this._undoRedo.canRedo();\n }\n\n getUndoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return {\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n };\n }\n return this._undoRedo.getUndoMeta();\n }\n\n getRedoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return null;\n }\n return this._undoRedo.getRedoMeta();\n }\n\n // Get memory usage statistics\n getMemoryUsage(): { totalMB: number; entries: number } {\n return this._undoRedo.getMemoryUsage();\n }\n\n // Get undo/redo configuration\n getUndoRedoConfig(): UndoRedoConfig {\n return this._undoRedo.getConfig();\n }\n\n /**\n * Get committed changes after the initial editor state up to the current undo/redo position.\n */\n getCommitsSinceInitial() {\n return this._undoRedo.getCommitsSinceInitial();\n }\n\n /**\n * Serialize the SurveyEditor state to JSON\n * @returns A JSON-serializable object containing the complete editor state\n */\n toJson(): SerializedSurveyEditor {\n return {\n version: \"1.0.0\",\n survey: this._survey.serialize(),\n undoRedo: this._undoRedo.serialize(),\n hasUncommittedChanges: this._hasUncommittedChanges,\n };\n }\n\n /**\n * Create a new SurveyEditor instance from JSON data\n * @param jsonData The serialized editor state\n * @param pluginRegistry Optional plugin registry for deserializing survey state (required when survey contains custom item types)\n * @returns A new SurveyEditor instance with the restored state\n */\n static fromJson(\n jsonData: SerializedSurveyEditor,\n pluginRegistry?: ItemTypeRegistry,\n ): SurveyEditor {\n if (!jsonData.survey) {\n throw new Error(\"Invalid object: survey is required\");\n }\n\n if (!jsonData.undoRedo) {\n throw new Error(\"Invalid object: undoRedo is required\");\n }\n\n if (typeof jsonData.hasUncommittedChanges !== \"boolean\") {\n throw new Error(\"Invalid object: hasUncommittedChanges must be a boolean\");\n }\n\n // Validate version (for future compatibility)\n if (jsonData.version && !jsonData.version.startsWith(\"1.\")) {\n console.warn(\n `Warning: Loading SurveyEditor with version ${jsonData.version}, current version is 1.0.0`,\n );\n }\n\n // Create survey from JSON\n const survey = Survey.fromJson(jsonData.survey, pluginRegistry);\n\n // Create a new editor instance\n const editor = new SurveyEditor(survey, { pluginRegistry });\n\n // Restore undo/redo state\n editor._undoRedo = SurveyEditorUndoRedo.deserialize(\n {\n ...jsonData.undoRedo,\n history: jsonData.undoRedo.history.map((entry) =>\n \"survey\" in entry\n ? {\n ...entry,\n survey: stripAssetsFromSurveySnapshot(entry.survey),\n }\n : entry,\n ),\n },\n jsonData.survey.assets,\n );\n\n // Infer whether the live survey contains uncommitted survey changes by comparing\n // the current survey content to the current history entry, ignoring assets.\n editor._hasUncommittedChanges =\n JSON.stringify(stripAssetsFromSurveySnapshot(jsonData.survey)) !==\n JSON.stringify(editor._undoRedo.getCurrentState());\n\n return editor;\n }\n\n private markAsModified(): void {\n this._hasUncommittedChanges = true;\n }\n\n private createEditorTimestamp(): string {\n return new Date().toISOString();\n }\n\n private touchItemModifiedMetadata(\n itemId: string,\n timestamp = this.createEditorTimestamp(),\n ): void {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return;\n }\n\n item.setModifiedAt(timestamp);\n }\n\n addItem(target: Target, item: SurveyItemCore, content?: SurveyItemTranslations): void {\n // Mark as modified (uncommitted change)\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n\n // Find the parent group item\n let parentGroup: GroupItemCore;\n\n if (!target) {\n // If no target provided, add to root\n\n const rootItem = this._survey.rootItem;\n if (!rootItem) {\n throw new Error(\"No root group found in survey\");\n }\n if (!(rootItem instanceof GroupItemCore)) {\n throw new Error(\"Root item is not a group item\");\n }\n parentGroup = rootItem;\n } else {\n // Find the target parent group\n const targetItem = this._survey.surveyItems.get(target.parentId);\n\n if (!targetItem) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Parent item '${target.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n parentGroup = targetItem;\n }\n\n if (parentGroup.hasChild(item.id)) {\n throw new Error(`Item ${item.id} already in this group`);\n }\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n parentGroup.items?.includes(sItem.id),\n );\n let counter = 1;\n const originalKey = item.key;\n let uniqueKey = originalKey;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${originalKey}_${counter}`;\n counter++;\n }\n\n // Determine insertion index\n let insertIndex: number;\n if (target?.index !== undefined) {\n // Insert at specified index, or at end if index is larger than array length\n insertIndex = Math.min(target.index, parentGroup.items.length);\n } else {\n // Insert at the end\n insertIndex = parentGroup.items.length;\n }\n\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n\n // Add the item to the survey items collection\n this._survey.surveyItems.set(item.id, item);\n\n // Add the item to the parent group (uses addChild for proper persistence)\n parentGroup.addChild(item.id, insertIndex);\n this.touchItemModifiedMetadata(parentGroup.id, timestamp);\n\n // Update translations in the survey\n if (content) {\n this._survey.translations.setItemTranslations(item.id, content);\n }\n }\n\n // Remove an item from the survey\n removeItem(itemId: string, nested: boolean = false): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n // Find parent group and remove from its items array\n const parentItem = this._survey.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Item with id '${itemId}' is the root item`);\n }\n\n if (item instanceof GroupItemCore) {\n for (const childId of item.getChildrenIds()) {\n this.removeItem(childId, true);\n }\n }\n\n // Remove from survey items\n this._survey.surveyItems.delete(itemId);\n\n // Remove translations\n this._survey.translations?.onItemDeleted(itemId);\n\n if (!nested) {\n parentItem.removeChild(itemId);\n this.touchItemModifiedMetadata(parentItem.id, timestamp);\n }\n return true;\n }\n\n // Move an item to a different position\n moveItem(itemId: string, newTarget: Target): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n // Check if item exists\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Check if new target exists and is a group\n const targetItem = this._survey.surveyItems.get(newTarget.parentId);\n if (!targetItem) {\n throw new Error(`Target parent with id '${newTarget.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Target parent '${newTarget.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n // Check if new target is not a child of the current item (prevent circular reference)\n if (this._survey.isDescendantOf(newTarget.parentId, itemId)) {\n throw new Error(`Cannot move item '${itemId}' to its descendant '${newTarget.parentId}'`);\n }\n\n // If the item is already in the target parent\n const currentParentItem = this._survey.getParentItem(itemId);\n if (currentParentItem?.id === newTarget.parentId) {\n throw new Error(`Item '${itemId}' is already in the target parent '${newTarget.parentId}'`);\n }\n\n // Remove item from current parent's items array\n if (currentParentItem) {\n const currentParentGroup = currentParentItem as GroupItemCore;\n currentParentGroup.removeChild(itemId);\n this.touchItemModifiedMetadata(currentParentGroup.id, timestamp);\n }\n\n // Add item to new parent's items array\n const targetGroup = targetItem as GroupItemCore;\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n targetGroup.hasChild(sItem.id),\n );\n let counter = 1;\n let uniqueKey = item.key;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${item.key}_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n }\n\n const insertIndex =\n newTarget.index !== undefined\n ? Math.min(newTarget.index, targetGroup.items.length)\n : targetGroup.items.length;\n\n targetGroup.addChild(itemId, insertIndex);\n this.touchItemModifiedMetadata(targetGroup.id, timestamp);\n this.touchItemModifiedMetadata(itemId, timestamp);\n\n return true;\n }\n\n /**\n * Get a deep copy of an item's raw data.\n * The returned object is independent of the survey—mutating it will not affect the survey.\n * Use this when you need to edit an item in a form or pass it to updateItem after modifications.\n *\n * @param itemId - The ID of the item to copy\n * @returns A deep copy of the item's RawSurveyItem data\n * @throws Error if the item is not found\n */\n getItemDataCopy(itemId: string): RawSurveyItem {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n return JSON.parse(JSON.stringify(item.rawItem)) as RawSurveyItem;\n }\n\n /**\n * Update an item's data in the survey.\n * Can update common attributes (displayConditions, disabledConditions, validations, etc.)\n * as well as type-specific config.\n *\n * Use getItemDataCopy to obtain an editable copy, modify it, then pass it here.\n * Alternatively, pass a Partial to merge specific fields (top-level keys only;\n * e.g. config replaces the entire config object).\n *\n * @param itemId - The ID of the item to update (must match data.id if provided)\n * @param rawItemData - Full RawSurveyItem or Partial to merge. The id cannot be changed.\n */\n updateItem(itemId: string, rawItemData: RawSurveyItem | Partial<RawSurveyItem>): void {\n const existingItem = this._survey.surveyItems.get(itemId);\n if (!existingItem) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n if (\"id\" in rawItemData && rawItemData.id !== undefined && rawItemData.id !== itemId) {\n throw new Error(`Cannot change item id from '${itemId}' to '${rawItemData.id}'`);\n }\n\n const currentRaw = existingItem.rawItem;\n const merged: RawSurveyItem = {\n ...currentRaw,\n ...rawItemData,\n id: itemId, // Ensure id is never changed\n };\n\n // Reject key change if it would collide with a sibling\n const newKey = merged.key ?? existingItem.key;\n const parentGroup = this._survey.getParentItem(itemId);\n if (parentGroup) {\n const siblingWithSameKey = (parentGroup.items ?? [])\n .filter((id) => id !== itemId)\n .map((id) => this._survey.surveyItems.get(id))\n .find((s) => s !== undefined && s.key === newKey);\n if (siblingWithSameKey) {\n throw new Error(\n `Key '${newKey}' is already in use by sibling item '${siblingWithSameKey.id}'`,\n );\n }\n }\n\n const newItem = this._survey.createItemFromRaw({\n ...merged,\n editorMetadata: existingItem.rawItem.editorMetadata,\n });\n newItem.setModifiedAt(this.createEditorTimestamp());\n this._survey.surveyItems.set(itemId, newItem);\n this.markAsModified();\n }\n\n // TODO: add also to update component translations (updating part of the item)\n // Update item translations\n updateItemTranslations(itemId: string, updatedContent?: SurveyItemTranslations): boolean {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n this.markAsModified();\n item.setModifiedAt(this.createEditorTimestamp());\n this._survey.translations.setItemTranslations(itemId, updatedContent);\n\n return true;\n }\n\n /**\n * Update survey-level translations that are not tied to specific items.\n * Use these for survey card, navigation, validation messages, etc.\n */\n updateSurveyTranslations(updates: {\n surveyCard?: { locale: string; content?: SurveyCardContent };\n navigation?: { locale: string; content?: NavigationContent };\n validationMessages?: { locale: string; content?: { invalidResponse?: Content } };\n }): void {\n this.markAsModified();\n if (updates.surveyCard) {\n this._survey.translations.setSurveyCardContent(\n updates.surveyCard.locale,\n updates.surveyCard.content,\n );\n }\n if (updates.navigation) {\n this._survey.translations.setNavigationContent(\n updates.navigation.locale,\n updates.navigation.content,\n );\n }\n if (updates.validationMessages) {\n this._survey.translations.setValidationMessages(\n updates.validationMessages.locale,\n updates.validationMessages.content,\n );\n }\n }\n\n /** Add an empty survey locale so it can be authored before translated content exists. */\n addLocale(locale: string): boolean {\n const added = this._survey.translations.addLocale(locale);\n if (added) {\n this.markAsModified();\n }\n return added;\n }\n\n /** Remove a locale and every survey- and item-level translation stored for it. */\n removeLocale(locale: string): boolean {\n if (!this._survey.locales.includes(locale)) {\n return false;\n }\n\n this._survey.translations.removeLocale(locale);\n this.markAsModified();\n return true;\n }\n\n /**\n * Get maxItemsPerPage immutably (returns a copy).\n */\n getMaxItemsPerPage(): { large: number; small: number } | undefined {\n const val = this._survey.maxItemsPerPage;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update maxItemsPerPage.\n */\n updateMaxItemsPerPage(value: { large: number; small: number } | undefined): void {\n this.markAsModified();\n this._survey.maxItemsPerPage = value ? { ...value } : undefined;\n }\n\n /**\n * Get metadata immutably (returns a copy).\n */\n getMetadata(): { [key: string]: string } | undefined {\n const val = this._survey.metadata;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update metadata.\n */\n updateMetadata(metadata: { [key: string]: string } | undefined): void {\n this.markAsModified();\n this._survey.metadata = metadata ? { ...metadata } : undefined;\n }\n\n /**\n * Get a template value immutably (returns a deep copy).\n */\n getTemplateValue(key: string): TemplateValueDefinition | undefined {\n const val = this._survey.getTemplateValue(key);\n return val ? structuredCloneMethod(val) : undefined;\n }\n\n /**\n * Get all template values immutably (returns a new Map with deep-copied values).\n */\n getTemplateValues(): Map<string, TemplateValueDefinition> {\n const keys = this._survey.getTemplateValueKeys();\n const result = new Map<string, TemplateValueDefinition>();\n for (const key of keys) {\n const val = this._survey.getTemplateValue(key);\n if (val) {\n result.set(key, structuredCloneMethod(val));\n }\n }\n return result;\n }\n\n /**\n * Add or replace a template value.\n */\n setTemplateValue(key: string, templateValue: TemplateValueDefinition): void {\n this.markAsModified();\n this._survey.setTemplateValue(key, structuredCloneMethod(templateValue));\n }\n\n /**\n * Remove a template value.\n */\n removeTemplateValue(key: string): void {\n this.markAsModified();\n this._survey.deleteTemplateValue(key);\n }\n\n /**\n * Get a survey asset immutably.\n */\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._survey.getAsset(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n /**\n * Get all survey assets immutably.\n */\n getAssets(): Map<string, RawSurveyAsset> {\n return this._survey.getAssets();\n }\n\n /**\n * Add or replace a survey asset.\n */\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n const previousAsset = this._survey.getAsset(assetId);\n this._survey.setAsset(assetId, structuredCloneMethod(asset));\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n next: structuredCloneMethod(asset),\n },\n ],\n {\n label: `Update asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Remove a survey asset.\n */\n removeAsset(assetId: string): void {\n const previousAsset = this._survey.getAsset(assetId);\n if (!previousAsset) {\n return;\n }\n this._survey.deleteAsset(assetId);\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n },\n ],\n {\n label: `Remove asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * @param itemId - The ID of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const copyPaste = new ItemCopyPaste(this._survey);\n return copyPaste.copyItem(itemId);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * @param clipboardData - The clipboard data containing the item to paste\n * @param target - Target location where to paste the item\n * @returns The ID of the pasted item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const itemIdsBeforePaste = new Set(this._survey.surveyItems.keys());\n const copyPaste = new ItemCopyPaste(this._survey);\n const newItemId = copyPaste.pasteItem(clipboardData, target);\n const pastedItemIds = Array.from(this._survey.surveyItems.keys()).filter(\n (itemId) => !itemIdsBeforePaste.has(itemId),\n );\n\n for (const itemId of pastedItemIds) {\n const item = this._survey.surveyItems.get(itemId);\n if (item) {\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n }\n }\n this.touchItemModifiedMetadata(target.parentId, timestamp);\n\n return newItemId;\n }\n}\n"],"mappings":";;AA2BA,IAAa,gBAAb,MAAa,cAAc;CACzB;CAEA,YAAY,QAAgB;AAC1B,OAAK,SAAS;;;;;;;;CAShB,SAAS,QAAyC;AAEhD,MAAI,CADS,KAAK,OAAO,YAAY,IAAI,OAChC,CACP,OAAM,IAAI,MAAM,iBAAiB,OAAO,aAAa;EAIvD,MAAM,cAAc,KAAK,oBAAoB,OAAO;EAGpD,MAAM,QAAQ,YAAY,KAAK,OAAO;GACpC,MAAM,OAAO,KAAK,OAAO,YAAY,IAAI,GAAG;AAC5C,OAAI,CAAC,KAAM,OAAM,IAAI,MAAM,iBAAiB,GAAG,yBAAyB;AACxE,UAAO;IAAE,QAAQ;IAAI,UAAU,KAAK;IAAS;IAC7C;EAGF,MAAM,eAA6D,EAAE;AACrE,cAAY,SAAS,OAAO;AAC1B,OAAI;IACF,MAAM,mBAAmB,KAAK,OAAO,oBAAoB,GAAG;AAC5D,QAAI,kBAAkB,SAAS,QAAQ;KACrC,MAAM,yBAAiD,EAAE;AACzD,sBAAi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O"}
|
package/build/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as RichTextLinkInline, $t as ExpressionEditorConfig, A as SurveyTranslations, An as ValueType, At as SurveyItemPrefillSource, B as RichTextBulletListBlock, Bt as ItemExpressionParameterInput, C as SurveyVersion, Cn as ReferenceArrayResponse, Ct as serializeTemplateValues, D as SurveyCardContent, Dn as StringArrayResponse, Dt as JsonSurveyItemPrefillTarget, E as NavigationContent, En as SlotResponseBase, Et as JsonSurveyItemPrefillSource, F as ContentType, Ft as prefillTargetsEqual, G as RichTextImageDimension, Gt as SurveyItemCore, H as RichTextDocument, Ht as buildItemExpression, I as MDContent, It as serializeSurveyItemPrefill, J as RichTextInline, Jt as RawSurveyItem, K as RichTextImageSize, Kt as SurveyItemCoreType, L as PlainTextContent, Lt as AnyItemExpressionDefinition, M as Content, Mn as isResponseValue, Mt as SurveyItemPrefillTargetType, N as ContentAssetUsage, Nt as SurveyItemPreviousResponseRef, O as SurveyCardTranslations, On as StringResponse, Ot as SurveyItemPrefill, P as ContentAttributes, Pt as deserializeSurveyItemPrefill, Q as RichTextLinkChildInline, Qt as Expression, R as RichTextBlockExtension, Rt as ItemExpressionDefinition, S as RawSurveyAsset, Sn as NumberResponse, St as serializeTemplateValue, T as JsonSurveyTranslations, Tn as ResponseValue, Tt as JsonSurveyItemPrefill, U as RichTextHeadingBlock, Ut as getItemExpressionDefinition, V as RichTextContent, Vt as ItemExpressionParameterOption, W as RichTextImageBlock, Wt as ItemCoreConstructor, X as RichTextInlineNode, Xt as ContextVariableExpression, Y as RichTextInlineExtension, Yt as ConstExpression, Z as RichTextLineBreakInline, Zt as ContextVariableType, _ as createItemTypeDefinitionRegistry, _n as DurationResponse, _t as TemplateValueBase, a as GroupItemCore, an as JsonExpression, at as RichTextTextInline, b as CURRENT_SURVEY_SCHEMA, bn as NumberArrayResponse, bt as deserializeTemplateValue, c as builtInItemCoreRegistry, cn as ResponseVariableExpression, ct as createRichTextContent, d as ItemTypeDefinition, dn as ValueReference, dt as getPlainTextFromRichTextContent, en as ExpressionType, et as RichTextListItemBlock, f as ItemTypeDefinitionRegistry, fn as ValueReferenceMethod, ft as hasRenderableRichTextBlock, g as createItemCore, gn as DurationArrayResponse, gt as TemplateDefTypes, h as createFullRegistry, hn as DateResponse, ht as JsonTemplateValue, i as GroupConfig, in as JsonContextVariableExpression, it as RichTextTemplateInline, j as validateLocale, jn as assertResponseValue, jt as SurveyItemPrefillTarget, k as SurveyItemTranslations, kn as ValueRefTypeLookup, kt as SurveyItemPrefillApplyMode, l as isBuiltInItemType, ln as ReferenceUsage, lt as getAssetUsagesFromContent, m as ItemTypeRegistry, mn as DateArrayResponse, mt as isContentEmpty, n as SurveyAssetUsage, nn as FunctionExpressionNames, nt as RichTextSeparatorBlock, o as PageBreakConfig, on as JsonFunctionExpression, ot as SurveyContentImageSource, p as ItemTypeName, pn as BooleanResponse, pt as hasRenderableRichTextContent, q as RichTextInfoBoxBlock, qt as ReservedSurveyItemTypes, r as BuiltInItemType, rn as JsonConstExpression, rt as RichTextStyle, s as PageBreakItemCore, sn as JsonResponseVariableExpression, st as TextAlignment, t as Survey, tn as FunctionExpression, tt as RichTextParagraphBlock, u as ItemTypeCapabilities, un as ReferenceUsageType, ut as getContentPlainText, v as toItemTypeDefinitionRegistry, vn as DurationUnit, vt as TemplateValueDefinition, w as JsonComponentContent, wn as ReferenceResponse, wt as ResponseSlotDefinition, x as RawSurvey, xn as NumberPrecision, xt as deserializeTemplateValues, y as SurveyItemKey, yn as DurationUnits, yt as TemplateValueFormatDate, z as RichTextBlockNode, zt as ItemExpressionParameterDefinition } from "./survey-
|
|
1
|
+
import { $ as RichTextLinkInline, $t as ExpressionEditorConfig, A as SurveyTranslations, An as ValueType, At as SurveyItemPrefillSource, B as RichTextBulletListBlock, Bt as ItemExpressionParameterInput, C as SurveyVersion, Cn as ReferenceArrayResponse, Ct as serializeTemplateValues, D as SurveyCardContent, Dn as StringArrayResponse, Dt as JsonSurveyItemPrefillTarget, E as NavigationContent, En as SlotResponseBase, Et as JsonSurveyItemPrefillSource, F as ContentType, Ft as prefillTargetsEqual, G as RichTextImageDimension, Gt as SurveyItemCore, H as RichTextDocument, Ht as buildItemExpression, I as MDContent, It as serializeSurveyItemPrefill, J as RichTextInline, Jt as RawSurveyItem, K as RichTextImageSize, Kt as SurveyItemCoreType, L as PlainTextContent, Lt as AnyItemExpressionDefinition, M as Content, Mn as isResponseValue, Mt as SurveyItemPrefillTargetType, N as ContentAssetUsage, Nt as SurveyItemPreviousResponseRef, O as SurveyCardTranslations, On as StringResponse, Ot as SurveyItemPrefill, P as ContentAttributes, Pt as deserializeSurveyItemPrefill, Q as RichTextLinkChildInline, Qt as Expression, R as RichTextBlockExtension, Rt as ItemExpressionDefinition, S as RawSurveyAsset, Sn as NumberResponse, St as serializeTemplateValue, T as JsonSurveyTranslations, Tn as ResponseValue, Tt as JsonSurveyItemPrefill, U as RichTextHeadingBlock, Ut as getItemExpressionDefinition, V as RichTextContent, Vt as ItemExpressionParameterOption, W as RichTextImageBlock, Wt as ItemCoreConstructor, X as RichTextInlineNode, Xt as ContextVariableExpression, Y as RichTextInlineExtension, Yt as ConstExpression, Z as RichTextLineBreakInline, Zt as ContextVariableType, _ as createItemTypeDefinitionRegistry, _n as DurationResponse, _t as TemplateValueBase, a as GroupItemCore, an as JsonExpression, at as RichTextTextInline, b as CURRENT_SURVEY_SCHEMA, bn as NumberArrayResponse, bt as deserializeTemplateValue, c as builtInItemCoreRegistry, cn as ResponseVariableExpression, ct as createRichTextContent, d as ItemTypeDefinition, dn as ValueReference, dt as getPlainTextFromRichTextContent, en as ExpressionType, et as RichTextListItemBlock, f as ItemTypeDefinitionRegistry, fn as ValueReferenceMethod, ft as hasRenderableRichTextBlock, g as createItemCore, gn as DurationArrayResponse, gt as TemplateDefTypes, h as createFullRegistry, hn as DateResponse, ht as JsonTemplateValue, i as GroupConfig, in as JsonContextVariableExpression, it as RichTextTemplateInline, j as validateLocale, jn as assertResponseValue, jt as SurveyItemPrefillTarget, k as SurveyItemTranslations, kn as ValueRefTypeLookup, kt as SurveyItemPrefillApplyMode, l as isBuiltInItemType, ln as ReferenceUsage, lt as getAssetUsagesFromContent, m as ItemTypeRegistry, mn as DateArrayResponse, mt as isContentEmpty, n as SurveyAssetUsage, nn as FunctionExpressionNames, nt as RichTextSeparatorBlock, o as PageBreakConfig, on as JsonFunctionExpression, ot as SurveyContentImageSource, p as ItemTypeName, pn as BooleanResponse, pt as hasRenderableRichTextContent, q as RichTextInfoBoxBlock, qt as ReservedSurveyItemTypes, r as BuiltInItemType, rn as JsonConstExpression, rt as RichTextStyle, s as PageBreakItemCore, sn as JsonResponseVariableExpression, st as TextAlignment, t as Survey, tn as FunctionExpression, tt as RichTextParagraphBlock, u as ItemTypeCapabilities, un as ReferenceUsageType, ut as getContentPlainText, v as toItemTypeDefinitionRegistry, vn as DurationUnit, vt as TemplateValueDefinition, w as JsonComponentContent, wn as ReferenceResponse, wt as ResponseSlotDefinition, x as RawSurvey, xn as NumberPrecision, xt as deserializeTemplateValues, y as SurveyItemKey, yn as DurationUnits, yt as TemplateValueFormatDate, z as RichTextBlockNode, zt as ItemExpressionParameterDefinition } from "./survey-CwWxsuRb.mjs";
|
|
2
2
|
import { SURVEY_EDITOR_ITEM_COLORS } from "./editor/colors.mjs";
|
|
3
3
|
import { Locale } from "date-fns";
|
|
4
4
|
|
package/build/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as generateId, A as DurationUnits, B as ConstExpression, C as ReservedSurveyItemTypes, D as deserializeSurveyItemPrefill, E as SurveyItemPrefillTargetType, F as TemplateDefTypes, G as FunctionExpression, H as ContextVariableType, I as deserializeTemplateValue, J as ReferenceUsageType, K as FunctionExpressionNames, L as deserializeTemplateValues, M as ValueType, N as assertResponseValue, O as prefillTargetsEqual, P as isResponseValue, Q as generateCodingKey, R as serializeTemplateValue, S as SurveyItemKey, T as SurveyItemPrefillApplyMode, U as Expression, V as ContextVariableExpression, W as ExpressionType, X as ValueReferenceMethod, Y as ValueReference, Z as createSeededRandom, _ as toItemTypeDefinitionRegistry, a as getContentPlainText, b as builtInItemCoreRegistry, c as hasRenderableRichTextContent, d as SurveyTranslations, et as shuffleArray, f as validateLocale, g as createItemTypeDefinitionRegistry, h as createItemCore, i as getAssetUsagesFromContent, j as NumberPrecision, k as serializeSurveyItemPrefill, l as isContentEmpty, m as createFullRegistry, n as ContentType, nt as structuredCloneMethod, o as getPlainTextFromRichTextContent, p as CURRENT_SURVEY_SCHEMA, q as ResponseVariableExpression, r as createRichTextContent, s as hasRenderableRichTextBlock, t as Survey, tt as shuffleIndices, u as SurveyItemTranslations, v as GroupItemCore, w as SurveyItemCore, x as isBuiltInItemType, y as PageBreakItemCore, z as serializeTemplateValues } from "./survey-
|
|
1
|
+
import { $ as generateId, A as DurationUnits, B as ConstExpression, C as ReservedSurveyItemTypes, D as deserializeSurveyItemPrefill, E as SurveyItemPrefillTargetType, F as TemplateDefTypes, G as FunctionExpression, H as ContextVariableType, I as deserializeTemplateValue, J as ReferenceUsageType, K as FunctionExpressionNames, L as deserializeTemplateValues, M as ValueType, N as assertResponseValue, O as prefillTargetsEqual, P as isResponseValue, Q as generateCodingKey, R as serializeTemplateValue, S as SurveyItemKey, T as SurveyItemPrefillApplyMode, U as Expression, V as ContextVariableExpression, W as ExpressionType, X as ValueReferenceMethod, Y as ValueReference, Z as createSeededRandom, _ as toItemTypeDefinitionRegistry, a as getContentPlainText, b as builtInItemCoreRegistry, c as hasRenderableRichTextContent, d as SurveyTranslations, et as shuffleArray, f as validateLocale, g as createItemTypeDefinitionRegistry, h as createItemCore, i as getAssetUsagesFromContent, j as NumberPrecision, k as serializeSurveyItemPrefill, l as isContentEmpty, m as createFullRegistry, n as ContentType, nt as structuredCloneMethod, o as getPlainTextFromRichTextContent, p as CURRENT_SURVEY_SCHEMA, q as ResponseVariableExpression, r as createRichTextContent, s as hasRenderableRichTextBlock, t as Survey, tt as shuffleIndices, u as SurveyItemTranslations, v as GroupItemCore, w as SurveyItemCore, x as isBuiltInItemType, y as PageBreakItemCore, z as serializeTemplateValues } from "./survey-BKblV5rN.mjs";
|
|
2
2
|
import { SURVEY_EDITOR_ITEM_COLORS } from "./editor/colors.mjs";
|
|
3
3
|
import { format } from "date-fns";
|
|
4
4
|
import { enUS } from "date-fns/locale";
|
package/build/package.json
CHANGED
|
@@ -978,6 +978,16 @@ var SurveyTranslations = class {
|
|
|
978
978
|
get locales() {
|
|
979
979
|
return Object.keys(this._translations);
|
|
980
980
|
}
|
|
981
|
+
/**
|
|
982
|
+
* Register a locale even when it has no translated content yet.
|
|
983
|
+
* Returns false when the locale is already present.
|
|
984
|
+
*/
|
|
985
|
+
addLocale(locale) {
|
|
986
|
+
validateLocale(locale);
|
|
987
|
+
if (this._translations[locale]) return false;
|
|
988
|
+
this._translations[locale] = {};
|
|
989
|
+
return true;
|
|
990
|
+
}
|
|
981
991
|
removeLocale(locale) {
|
|
982
992
|
validateLocale(locale);
|
|
983
993
|
delete this._translations[locale];
|
|
@@ -1447,4 +1457,4 @@ var Survey = class Survey {
|
|
|
1447
1457
|
//#endregion
|
|
1448
1458
|
export { generateId as $, DurationUnits as A, ConstExpression as B, ReservedSurveyItemTypes as C, deserializeSurveyItemPrefill as D, SurveyItemPrefillTargetType as E, TemplateDefTypes as F, FunctionExpression as G, ContextVariableType as H, deserializeTemplateValue as I, ReferenceUsageType as J, FunctionExpressionNames as K, deserializeTemplateValues as L, ValueType as M, assertResponseValue as N, prefillTargetsEqual as O, isResponseValue as P, generateCodingKey as Q, serializeTemplateValue as R, SurveyItemKey as S, SurveyItemPrefillApplyMode as T, Expression as U, ContextVariableExpression as V, ExpressionType as W, ValueReferenceMethod as X, ValueReference as Y, createSeededRandom as Z, toItemTypeDefinitionRegistry as _, getContentPlainText as a, builtInItemCoreRegistry as b, hasRenderableRichTextContent as c, SurveyTranslations as d, shuffleArray as et, validateLocale as f, createItemTypeDefinitionRegistry as g, createItemCore as h, getAssetUsagesFromContent as i, NumberPrecision as j, serializeSurveyItemPrefill as k, isContentEmpty as l, createFullRegistry as m, ContentType as n, structuredCloneMethod as nt, getPlainTextFromRichTextContent as o, CURRENT_SURVEY_SCHEMA as p, ResponseVariableExpression as q, createRichTextContent as r, hasRenderableRichTextBlock as s, Survey as t, shuffleIndices as tt, SurveyItemTranslations as u, GroupItemCore as v, SurveyItemCore as w, isBuiltInItemType as x, PageBreakItemCore as y, serializeTemplateValues as z };
|
|
1449
1459
|
|
|
1450
|
-
//# sourceMappingURL=survey-
|
|
1460
|
+
//# sourceMappingURL=survey-BKblV5rN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-BKblV5rN.mjs","names":[],"sources":["../src/utils.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/expressions/template-value.ts","../src/survey/responses/value-types.ts","../src/survey/items/utils.ts","../src/survey/items/prefill.ts","../src/survey/items/survey-item.ts","../src/survey/items/types.ts","../src/survey/item-key.ts","../src/survey/utils/group-utils.ts","../src/survey/registry/built-in-items.ts","../src/survey/registry/item-registry.ts","../src/survey/survey-file-schema.ts","../src/survey/utils/translations.ts","../src/survey/utils/content.ts","../src/survey/survey.ts"],"sourcesContent":["function hashString(seed: string): number {\n let hash = 2166136261;\n\n for (let i = 0; i < seed.length; i++) {\n hash ^= seed.charCodeAt(i);\n hash = Math.imul(hash, 16777619);\n }\n\n return hash >>> 0;\n}\n\nexport function createSeededRandom(seed: string): () => number {\n let state = hashString(seed);\n\n return () => {\n state = (state + 0x6d2b79f5) >>> 0;\n let next = state;\n next = Math.imul(next ^ (next >>> 15), next | 1);\n next ^= next + Math.imul(next ^ (next >>> 7), next | 61);\n return ((next ^ (next >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport function shuffleArray<T>(values: readonly T[], random: () => number = Math.random): T[] {\n const shuffledValues = [...values];\n\n for (let i = shuffledValues.length - 1; i > 0; i--) {\n const j = Math.floor(random() * (i + 1));\n [shuffledValues[i], shuffledValues[j]] = [shuffledValues[j], shuffledValues[i]];\n }\n\n return shuffledValues;\n}\n\n/**\n * Shuffles an array of indices using the Fisher-Yates shuffle algorithm\n * @param length - The length of the array to create indices for\n * @returns A shuffled array of indices from 0 to length-1\n */\nexport function shuffleIndices(length: number, random: () => number = Math.random): number[] {\n return shuffleArray(\n Array.from({ length }, (_, i) => i),\n random,\n );\n}\n\nexport function structuredCloneMethod<T>(obj: T): T {\n if (typeof structuredClone !== \"undefined\") {\n return structuredClone(obj);\n }\n // Fallback to JSON method\n return JSON.parse(JSON.stringify(obj));\n}\n\nconst ALPHABET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n\nexport function generateId(): string {\n const length = 10;\n const timestamp = Date.now();\n let encodedTimestamp = \"\";\n let t = timestamp;\n const base = ALPHABET.length;\n\n while (t > 0) {\n encodedTimestamp = ALPHABET.charAt(t % base) + encodedTimestamp;\n t = Math.floor(t / base);\n }\n\n let randomPart = \"\";\n for (let i = 0; i < length; i++) {\n randomPart += ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return randomPart + encodedTimestamp;\n}\n\n/** Alphanumeric chars without ambiguous ones (0/O, 1/I) for human-readable coding keys. */\nconst CODING_KEY_ALPHABET = \"23456789ABCDEFGHJKLMNPQRSTUVWXYZ\";\n\n/**\n * Generates a short random coding key suitable for item keys in exports/codebooks.\n * @param length - Key length (default 4)\n * @returns A random string of the specified length.\n */\nexport function generateCodingKey(length: number = 4): string {\n const base = CODING_KEY_ALPHABET.length;\n let key = \"\";\n for (let i = 0; i < length; i++) {\n key += CODING_KEY_ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return key;\n}\n","const SEPARATOR = \"...\";\n\nexport enum ValueReferenceMethod {\n get = \"get\",\n isDefined = \"isDefined\",\n}\n\nexport class ValueReference {\n _itemId: string;\n _name: ValueReferenceMethod;\n _slotId: string;\n\n constructor(str: string) {\n const parts = str.split(SEPARATOR);\n if (parts.length !== 3) {\n throw new Error(\"Invalid value reference: \" + str);\n }\n this._itemId = parts[0];\n this._name = parts[1] as ValueReferenceMethod;\n this._slotId = parts[2];\n }\n\n get itemId(): string {\n return this._itemId;\n }\n\n get name(): ValueReferenceMethod {\n return this._name;\n }\n\n get slotId(): string {\n return this._slotId;\n }\n\n set itemId(itemId: string) {\n this._itemId = itemId;\n }\n\n toString(): string {\n return `${this._itemId}${SEPARATOR}${this._name}${this._slotId ? SEPARATOR + this._slotId : \"\"}`;\n }\n\n static fromParts(itemId: string, name: ValueReferenceMethod, slotId: string): ValueReference {\n return new ValueReference(`${itemId}${SEPARATOR}${name}${SEPARATOR}${slotId}`);\n }\n}\n\nexport enum ReferenceUsageType {\n displayConditions = \"displayConditions\",\n templateValues = \"templateValues\",\n validations = \"validations\",\n disabledConditions = \"disabledConditions\",\n prefills = \"prefills\",\n}\n\nexport interface ReferenceUsage {\n itemId: string;\n fullComponentKey?: string;\n usageType?: ReferenceUsageType;\n valueReference: ValueReference;\n}\n","import { ResponseValue, ValueType } from \"../survey/responses\";\nimport { ValueReference } from \"../survey/utils/value-reference\";\n\nexport const ExpressionType = {\n Const: \"const\",\n ResponseVariable: \"responseVariable\",\n ContextVariable: \"contextVariable\",\n Function: \"function\",\n} as const;\n\nexport type ExpressionType = (typeof ExpressionType)[keyof typeof ExpressionType];\n\nexport const ContextVariableType = {\n Locale: \"locale\",\n ParticipantFlag: \"participantFlag\",\n CustomValue: \"customValue\",\n CustomExpression: \"customExpression\",\n} as const;\n\nexport type ContextVariableType = (typeof ContextVariableType)[keyof typeof ContextVariableType];\n\nexport interface ExpressionEditorConfig {\n usedTemplate?: string;\n label?: string;\n description?: string;\n}\n\nexport interface JsonConstExpression {\n type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonResponseVariableExpression {\n type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonContextVariableExpression {\n type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: JsonExpression;\n arguments?: Array<JsonExpression | undefined>;\n asType?: ValueType;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonFunctionExpression {\n type: typeof ExpressionType.Function;\n functionName: string;\n arguments: Array<JsonExpression | undefined>;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport type JsonExpression =\n | JsonConstExpression\n | JsonResponseVariableExpression\n | JsonContextVariableExpression\n | JsonFunctionExpression;\n\n/**\n * Base class for all expressions.\n */\nexport abstract class Expression {\n type: ExpressionType;\n editorConfig?: ExpressionEditorConfig;\n\n constructor(type: ExpressionType, editorConfig?: ExpressionEditorConfig) {\n this.type = type;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression | undefined): Expression | undefined {\n if (!json) {\n return undefined;\n }\n\n switch (json.type) {\n case ExpressionType.Const:\n return ConstExpression.deserialize(json);\n case ExpressionType.ResponseVariable:\n return ResponseVariableExpression.deserialize(json);\n case ExpressionType.ContextVariable:\n return ContextVariableExpression.deserialize(json);\n case ExpressionType.Function:\n return FunctionExpression.deserialize(json);\n }\n }\n\n /**\n * Returns all unique response variable references in the expression.\n * @returns A list of ValueReference objects.\n */\n abstract get responseVariableRefs(): ValueReference[];\n abstract serialize(): JsonExpression | undefined;\n\n clone(): Expression {\n return (\n Expression.deserialize(this.serialize()) ??\n (() => {\n throw new Error(\"Failed to clone expression\");\n })()\n );\n }\n}\n\nexport class ConstExpression extends Expression {\n declare type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n constructor(value?: ResponseValue, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.Const, editorConfig);\n this.value = value;\n this.type = ExpressionType.Const;\n }\n\n static deserialize(json: JsonExpression): ConstExpression {\n if (json.type !== ExpressionType.Const) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n return new ConstExpression(json.value, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [];\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n value: this.value,\n editorConfig: this.editorConfig,\n };\n }\n\n updateItemKeyReferences(_oldItemKey: string, _newItemKey: string): boolean {\n // Const expressions don't have item references\n return false;\n }\n}\n\nexport class ResponseVariableExpression extends Expression {\n declare type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n constructor(variableRef: string, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ResponseVariable, editorConfig);\n this.variableRef = variableRef;\n this.type = ExpressionType.ResponseVariable;\n }\n\n static deserialize(json: JsonExpression): ResponseVariableExpression {\n if (json.type !== ExpressionType.ResponseVariable) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n return new ResponseVariableExpression(json.variableRef, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [new ValueReference(this.variableRef)];\n }\n\n get responseVariableRef(): ValueReference {\n return new ValueReference(this.variableRef);\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n variableRef: this.variableRef,\n editorConfig: this.editorConfig,\n };\n }\n}\n\nexport class ContextVariableExpression extends Expression {\n declare type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: Expression;\n arguments?: Array<Expression | undefined>;\n asType?: ValueType;\n\n constructor(\n contextType: ContextVariableType,\n key?: Expression,\n args?: Array<Expression | undefined>,\n asType?: ValueType,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super(ExpressionType.ContextVariable, editorConfig);\n this.type = ExpressionType.ContextVariable;\n this.contextType = contextType;\n this.key = key;\n this.arguments = args;\n this.asType = asType;\n }\n\n static deserialize(json: JsonExpression): ContextVariableExpression {\n if (json.type !== ExpressionType.ContextVariable) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n return new ContextVariableExpression(\n json.contextType,\n Expression.deserialize(json.key),\n json.arguments?.map((arg) => Expression.deserialize(arg)),\n json.asType,\n json.editorConfig,\n );\n }\n\n get responseVariableRefs(): ValueReference[] {\n return (\n this.arguments\n ?.flatMap((arg) => arg?.responseVariableRefs)\n .filter((ref) => ref !== undefined) ?? []\n );\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n contextType: this.contextType,\n key: this.key?.serialize(),\n arguments: this.arguments?.map((arg) => arg?.serialize()),\n asType: this.asType,\n editorConfig: this.editorConfig,\n };\n }\n}\n\nexport enum FunctionExpressionNames {\n and = \"and\",\n or = \"or\",\n not = \"not\",\n\n list_contains = \"list_contains\",\n\n // numeric functions\n eq = \"eq\",\n gt = \"gt\",\n gte = \"gte\",\n lt = \"lt\",\n lte = \"lte\",\n in_range = \"in_range\",\n\n sum = \"sum\",\n min = \"min\",\n max = \"max\",\n\n // string functions\n str_eq = \"str_eq\",\n\n // date functions\n date_eq = \"date_eq\",\n}\n\nexport class FunctionExpression extends Expression {\n declare type: typeof ExpressionType.Function;\n functionName: FunctionExpressionNames;\n arguments: Array<Expression | undefined>;\n\n constructor(\n functionName: FunctionExpressionNames,\n args: Array<Expression | undefined>,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super(ExpressionType.Function);\n this.type = ExpressionType.Function;\n this.functionName = functionName;\n this.arguments = args;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression): FunctionExpression {\n if (json.type !== ExpressionType.Function) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n const functionName = json.functionName as FunctionExpressionNames;\n if (!Object.values(FunctionExpressionNames).includes(functionName)) {\n throw new Error(\"Invalid function name: \" + functionName);\n }\n\n const expr = new FunctionExpression(\n functionName,\n json.arguments.map((arg) => Expression.deserialize(arg)),\n );\n expr.editorConfig = json.editorConfig;\n return expr;\n }\n\n get responseVariableRefs(): ValueReference[] {\n const refs = this.arguments\n .flatMap((arg) => arg?.responseVariableRefs)\n .filter((ref) => ref !== undefined);\n const refStrings = refs.map((ref) => ref.toString());\n return [...new Set(refStrings)].map((ref) => new ValueReference(ref));\n }\n\n serialize(): JsonExpression | undefined {\n return {\n type: this.type,\n functionName: this.functionName,\n arguments: this.arguments.map((arg) => arg?.serialize()),\n editorConfig: this.editorConfig,\n };\n }\n}\n","import { ValueType } from \"../survey/responses\";\nimport { Expression, JsonExpression } from \"./expression\";\n\nexport enum TemplateDefTypes {\n Default = \"default\",\n Date2String = \"date2string\",\n}\n\nexport type TemplateValueBase = {\n type: TemplateDefTypes;\n returnType: ValueType;\n expression?: Expression;\n};\n\nexport type TemplateValueFormatDate = TemplateValueBase & {\n type: TemplateDefTypes.Date2String;\n returnType: typeof ValueType.string;\n dateFormat: string;\n};\n\nexport type TemplateValueDefinition = TemplateValueBase | TemplateValueFormatDate;\n\nexport const serializeTemplateValue = (\n templateValue: TemplateValueDefinition,\n): JsonTemplateValue => {\n const json: JsonTemplateValue = {\n type: templateValue.type,\n returnType: templateValue.returnType,\n expression: templateValue.expression?.serialize(),\n };\n if (templateValue.type === TemplateDefTypes.Date2String) {\n json.dateFormat = (templateValue as TemplateValueFormatDate).dateFormat;\n }\n return json;\n};\n\nexport const serializeTemplateValues = (\n templateValues: Map<string, TemplateValueDefinition>,\n): { [templateValueKey: string]: JsonTemplateValue } => {\n const json: { [templateValueKey: string]: JsonTemplateValue } = {};\n for (const [key, value] of templateValues.entries()) {\n json[key] = serializeTemplateValue(value);\n }\n return json;\n};\n\nexport const deserializeTemplateValue = (json: JsonTemplateValue): TemplateValueDefinition => {\n return {\n type: json.type,\n expression: json.expression ? Expression.deserialize(json.expression) : undefined,\n returnType: json.returnType,\n dateFormat: json.dateFormat,\n };\n};\n\nexport const deserializeTemplateValues = (json: {\n [templateValueKey: string]: JsonTemplateValue;\n}): Map<string, TemplateValueDefinition> => {\n return new Map(\n Object.entries(json).map(([key, value]) => [key, deserializeTemplateValue(value)]),\n );\n};\n\nexport interface JsonTemplateValue {\n type: TemplateDefTypes;\n expression?: JsonExpression;\n returnType: ValueType;\n dateFormat?: string;\n}\n","export const ValueType = {\n string: \"string\",\n duration: \"duration\",\n reference: \"reference\",\n number: \"number\",\n boolean: \"boolean\",\n date: \"date\",\n stringArray: \"string[]\",\n durationArray: \"duration[]\",\n referenceArray: \"reference[]\",\n numberArray: \"number[]\",\n dateArray: \"date[]\",\n} as const;\n\nexport type ValueType = (typeof ValueType)[keyof typeof ValueType];\n\nexport const DurationUnits = {\n seconds: \"seconds\",\n minutes: \"minutes\",\n hours: \"hours\",\n days: \"days\",\n weeks: \"weeks\",\n months: \"months\",\n years: \"years\",\n} as const;\n\nexport type DurationUnit = (typeof DurationUnits)[keyof typeof DurationUnits];\n\nexport const NumberPrecision = {\n int: \"int\",\n float: \"float\",\n} as const;\n\nexport type NumberPrecision = (typeof NumberPrecision)[keyof typeof NumberPrecision];\n\nexport interface SlotResponseBase<TValueType extends ValueType> {\n type: TValueType;\n}\n\nexport interface StringResponse extends SlotResponseBase<typeof ValueType.string> {\n value: string;\n}\n\nexport interface DurationResponse extends SlotResponseBase<typeof ValueType.duration> {\n value: number;\n unit: DurationUnit;\n precision?: NumberPrecision;\n}\n\nexport interface NumberResponse extends SlotResponseBase<typeof ValueType.number> {\n value: number;\n precision?: NumberPrecision;\n}\n\nexport interface BooleanResponse extends SlotResponseBase<typeof ValueType.boolean> {\n value: boolean;\n}\n\nexport interface ReferenceResponse extends SlotResponseBase<typeof ValueType.reference> {\n value: string;\n}\n\nexport interface DateResponse extends SlotResponseBase<typeof ValueType.date> {\n value: number;\n}\n\nexport interface StringArrayResponse extends SlotResponseBase<typeof ValueType.stringArray> {\n value: string[];\n}\n\nexport interface DurationArrayResponse extends SlotResponseBase<typeof ValueType.durationArray> {\n value: number[];\n unit: DurationUnit;\n precision?: NumberPrecision;\n}\n\nexport interface NumberArrayResponse extends SlotResponseBase<typeof ValueType.numberArray> {\n value: number[];\n precision?: NumberPrecision;\n}\n\nexport interface DateArrayResponse extends SlotResponseBase<typeof ValueType.dateArray> {\n value: number[];\n}\n\nexport interface ReferenceArrayResponse extends SlotResponseBase<typeof ValueType.referenceArray> {\n value: string[];\n}\n\nexport type ResponseValue =\n | StringResponse\n | DurationResponse\n | ReferenceResponse\n | NumberResponse\n | BooleanResponse\n | DateResponse\n | StringArrayResponse\n | DurationArrayResponse\n | NumberArrayResponse\n | DateArrayResponse\n | ReferenceArrayResponse;\n\nexport type ValueRefTypeLookup = {\n [valueRefString: string]: ValueType;\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\nfunction isNumberArray(value: unknown): value is number[] {\n return Array.isArray(value) && value.every((item) => isFiniteNumber(item));\n}\n\nfunction isOptionalNumberPrecision(value: unknown): value is NumberPrecision | undefined {\n return value === undefined || value === NumberPrecision.int || value === NumberPrecision.float;\n}\n\nfunction isDurationUnit(value: unknown): value is DurationUnit {\n return typeof value === \"string\" && Object.values(DurationUnits).includes(value as DurationUnit);\n}\n\nexport function isResponseValue(value: unknown): value is ResponseValue {\n if (!isPlainObject(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case ValueType.string:\n case ValueType.reference:\n return typeof value.value === \"string\";\n case ValueType.number:\n return isFiniteNumber(value.value) && isOptionalNumberPrecision(value.precision);\n case ValueType.boolean:\n return typeof value.value === \"boolean\";\n case ValueType.date:\n return isFiniteNumber(value.value);\n case ValueType.duration:\n return (\n isFiniteNumber(value.value) &&\n isDurationUnit(value.unit) &&\n isOptionalNumberPrecision(value.precision)\n );\n case ValueType.stringArray:\n case ValueType.referenceArray:\n return isStringArray(value.value);\n case ValueType.numberArray:\n case ValueType.dateArray:\n return (\n isNumberArray(value.value) &&\n (value.type !== ValueType.numberArray || isOptionalNumberPrecision(value.precision))\n );\n case ValueType.durationArray:\n return (\n isNumberArray(value.value) &&\n isDurationUnit(value.unit) &&\n isOptionalNumberPrecision(value.precision)\n );\n default:\n return false;\n }\n}\n\nexport function assertResponseValue(value: unknown, path: string): asserts value is ResponseValue {\n if (!isResponseValue(value)) {\n throw new Error(`Invalid response value at '${path}'`);\n }\n}\n","import { Expression, JsonExpression } from \"../../expressions\";\n\nexport interface DisplayConditions {\n root?: Expression;\n components?: {\n [componentKey: string]: Expression | undefined;\n };\n}\n\nexport interface JsonDisplayConditions {\n root?: JsonExpression;\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n };\n}\n\nexport interface JsonDisabledConditions {\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n };\n}\n\nexport interface DisabledConditions {\n components?: {\n [componentKey: string]: Expression | undefined;\n };\n}\n\nexport const displayConditionsFromJson = (json: JsonDisplayConditions): DisplayConditions => {\n return {\n root: json.root ? Expression.deserialize(json.root) : undefined,\n components: json.components\n ? Object.fromEntries(\n Object.entries(json.components).map(([key, value]) => [\n key,\n Expression.deserialize(value),\n ]),\n )\n : undefined,\n };\n};\n\nexport const displayConditionsToJson = (\n displayConditions: DisplayConditions,\n): JsonDisplayConditions => {\n return {\n root: displayConditions.root ? displayConditions.root.serialize() : undefined,\n components: displayConditions.components\n ? Object.fromEntries(\n Object.entries(displayConditions.components).map(([key, value]) => [\n key,\n value?.serialize(),\n ]),\n )\n : undefined,\n };\n};\n\nexport const disabledConditionsFromJson = (json: JsonDisabledConditions): DisabledConditions => {\n return {\n components: json.components\n ? Object.fromEntries(\n Object.entries(json.components).map(([key, value]) => [\n key,\n Expression.deserialize(value),\n ]),\n )\n : undefined,\n };\n};\n\nexport const disabledConditionsToJson = (\n disabledConditions: DisabledConditions,\n): JsonDisabledConditions => {\n return {\n components: disabledConditions.components\n ? Object.fromEntries(\n Object.entries(disabledConditions.components).map(([key, value]) => [\n key,\n value?.serialize(),\n ]),\n )\n : undefined,\n };\n};\n","import { Expression, type JsonExpression } from \"../../expressions\";\nimport type { ResponseValue } from \"../responses\";\n\nexport const SurveyItemPrefillApplyMode = {\n ifEmpty: \"ifEmpty\",\n} as const;\n\nexport type SurveyItemPrefillApplyMode =\n (typeof SurveyItemPrefillApplyMode)[keyof typeof SurveyItemPrefillApplyMode];\n\nexport const SurveyItemPrefillTargetType = {\n itemResponse: \"itemResponse\",\n field: \"field\",\n embeddedField: \"embeddedField\",\n} as const;\n\nexport type SurveyItemPrefillTargetType =\n (typeof SurveyItemPrefillTargetType)[keyof typeof SurveyItemPrefillTargetType];\n\nexport type JsonSurveyItemPrefillTarget =\n | {\n type: typeof SurveyItemPrefillTargetType.itemResponse;\n }\n | {\n type: typeof SurveyItemPrefillTargetType.field;\n fieldId: string;\n }\n | {\n type: typeof SurveyItemPrefillTargetType.embeddedField;\n optionId: string;\n fieldId: string;\n };\n\nexport type SurveyItemPrefillTarget = JsonSurveyItemPrefillTarget;\n\nexport interface SurveyItemPreviousResponseRef {\n surveyKey?: string;\n itemId: string;\n target?: SurveyItemPrefillTarget;\n}\n\nexport type JsonSurveyItemPrefillSource =\n | {\n type: \"static\";\n value: ResponseValue;\n }\n | {\n type: \"expression\";\n expression: JsonExpression;\n }\n | {\n type: \"templateValue\";\n key: string;\n }\n | {\n type: \"previousResponse\";\n ref: SurveyItemPreviousResponseRef;\n ifUnsupported?: \"skip\";\n };\n\nexport type SurveyItemPrefillSource =\n | {\n type: \"static\";\n value: ResponseValue;\n }\n | {\n type: \"expression\";\n expression: Expression;\n }\n | {\n type: \"templateValue\";\n key: string;\n }\n | {\n type: \"previousResponse\";\n ref: SurveyItemPreviousResponseRef;\n ifUnsupported?: \"skip\";\n };\n\nexport interface JsonSurveyItemPrefill {\n id: string;\n target: JsonSurveyItemPrefillTarget;\n when?: JsonExpression;\n apply?: SurveyItemPrefillApplyMode;\n source: JsonSurveyItemPrefillSource;\n}\n\nexport interface SurveyItemPrefill {\n id: string;\n target: SurveyItemPrefillTarget;\n when?: Expression;\n apply?: SurveyItemPrefillApplyMode;\n source: SurveyItemPrefillSource;\n}\n\nexport function deserializeSurveyItemPrefill(json: JsonSurveyItemPrefill): SurveyItemPrefill {\n switch (json.source.type) {\n case \"static\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"static\",\n value: json.source.value,\n },\n };\n case \"expression\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"expression\",\n expression:\n Expression.deserialize(json.source.expression) ??\n (() => {\n throw new Error(`Prefill '${json.id}' is missing a valid expression source`);\n })(),\n },\n };\n case \"templateValue\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"templateValue\",\n key: json.source.key,\n },\n };\n case \"previousResponse\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"previousResponse\",\n ref: json.source.ref,\n ifUnsupported: json.source.ifUnsupported,\n },\n };\n default:\n throw new Error(\n `Unsupported prefill source type: ${(json.source as { type?: string }).type}`,\n );\n }\n}\n\nexport function serializeSurveyItemPrefill(prefill: SurveyItemPrefill): JsonSurveyItemPrefill {\n switch (prefill.source.type) {\n case \"static\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"static\",\n value: prefill.source.value,\n },\n };\n case \"expression\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"expression\",\n expression:\n prefill.source.expression.serialize() ??\n (() => {\n throw new Error(\n `Prefill '${prefill.id}' cannot serialize an empty expression source`,\n );\n })(),\n },\n };\n case \"templateValue\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"templateValue\",\n key: prefill.source.key,\n },\n };\n case \"previousResponse\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"previousResponse\",\n ref: prefill.source.ref,\n ifUnsupported: prefill.source.ifUnsupported,\n },\n };\n default:\n throw new Error(\n `Unsupported prefill source type: ${(prefill.source as { type?: string }).type}`,\n );\n }\n}\n\nexport function prefillTargetsEqual(\n left: SurveyItemPrefillTarget,\n right: SurveyItemPrefillTarget,\n): boolean {\n if (left.type !== right.type) {\n return false;\n }\n\n switch (left.type) {\n case SurveyItemPrefillTargetType.itemResponse:\n return true;\n case SurveyItemPrefillTargetType.field:\n return (\n left.fieldId === (right as Extract<SurveyItemPrefillTarget, { type: \"field\" }>).fieldId\n );\n case SurveyItemPrefillTargetType.embeddedField:\n return (\n left.optionId ===\n (right as Extract<SurveyItemPrefillTarget, { type: \"embeddedField\" }>).optionId &&\n left.fieldId ===\n (right as Extract<SurveyItemPrefillTarget, { type: \"embeddedField\" }>).fieldId\n );\n default:\n return false;\n }\n}\n","import { Expression } from \"../../expressions\";\nimport { RawSurveyItem } from \"../items\";\nimport { ResponseSlotDefinition } from \"../responses/slot-definition\";\nimport { ResponseValue, ValueRefTypeLookup, ValueType } from \"../responses/value-types\";\nimport { ReferenceUsage, ReferenceUsageType, ValueReferenceMethod } from \"../utils/value-reference\";\nimport {\n DisabledConditions,\n disabledConditionsFromJson,\n DisplayConditions,\n displayConditionsFromJson,\n} from \"./utils\";\nimport {\n deserializeSurveyItemPrefill,\n prefillTargetsEqual,\n SurveyItemPrefill,\n SurveyItemPrefillTarget,\n SurveyItemPrefillTargetType,\n} from \"./prefill\";\n\n/**\n * Core contract for survey item handlers.\n * Every item type (built-in and plugin) is represented by a handler class implementing this interface.\n * The core uses these methods without any casting.\n */\nexport interface SurveyItemCoreType<TConfig = unknown> {\n readonly type: string;\n readonly id: string;\n readonly key: string;\n readonly config: TConfig;\n\n isInteractive(): boolean;\n getResponseSlotDefinitions(): ResponseSlotDefinition[];\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;\n}\n\n/**\n * Base class for survey item handlers.\n * Each handler holds type, id, key, and config (properly typed) and implements core methods.\n * Subclass for each item type; the core works with SurveyItemHandler only—no casting needed.\n */\nexport abstract class SurveyItemCore<\n TType extends string = string,\n TConfig = unknown,\n> implements SurveyItemCoreType<TConfig> {\n abstract readonly type: TType;\n readonly id: string;\n key: string;\n config: TConfig;\n\n private _rawItem: RawSurveyItem;\n\n displayConditions?: DisplayConditions;\n disabledConditions?: DisabledConditions;\n validations?: {\n [validationKey: string]: Expression | undefined;\n };\n prefills?: SurveyItemPrefill[];\n\n constructor(rawItem: RawSurveyItem) {\n this._rawItem = rawItem;\n this.updateExpressions();\n this.id = this._rawItem.id;\n this.key = this._rawItem.key;\n this.config = this.parseConfig(this._rawItem.config);\n }\n\n /** Parse raw config from JSON into typed config. Override in subclasses. */\n abstract parseConfig(rawConfig: unknown): TConfig;\n abstract isInteractive(): boolean;\n abstract getResponseSlotDefinitions(): ResponseSlotDefinition[];\n\n protected getAdditionalResponseValueSlots(): ValueRefTypeLookup {\n return {};\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n const valueRefs: ValueRefTypeLookup = {};\n\n for (const slot of this.getResponseSlotDefinitions()) {\n valueRefs[`${this.id}...${ValueReferenceMethod.get}...${slot.slotId}`] = slot.valueType;\n valueRefs[`${this.id}...${ValueReferenceMethod.isDefined}...${slot.slotId}`] =\n ValueType.boolean;\n }\n\n Object.assign(valueRefs, this.getAdditionalResponseValueSlots());\n\n if (!byType) {\n return valueRefs;\n }\n\n return Object.fromEntries(\n Object.entries(valueRefs).filter(([, valueType]) => valueType === byType),\n );\n }\n\n get rawItem(): RawSurveyItem {\n return this._rawItem;\n }\n\n get metadata(): { [key: string]: string } {\n return this._rawItem.metadata ?? {};\n }\n\n set metadata(metadata: { [key: string]: string }) {\n this.updateRawItem({\n ...this._rawItem,\n metadata: metadata,\n });\n }\n\n get editorMetadata(): NonNullable<RawSurveyItem[\"editorMetadata\"]> {\n return this._rawItem.editorMetadata ?? {};\n }\n\n setCreatedAt(timestamp: string): void {\n this.updateRawItem({\n ...this._rawItem,\n editorMetadata: {\n ...this._rawItem.editorMetadata,\n createdAt: timestamp,\n },\n });\n }\n\n setModifiedAt(timestamp: string): void {\n this.updateRawItem({\n ...this._rawItem,\n editorMetadata: {\n ...this._rawItem.editorMetadata,\n createdAt: this._rawItem.editorMetadata?.createdAt ?? timestamp,\n updatedAt: timestamp,\n },\n });\n }\n\n updateRawItem(rawItem: RawSurveyItem) {\n if (rawItem.id !== this.id) {\n throw new Error(\"Cannot update raw item with a different id\");\n }\n this._rawItem = rawItem;\n this.updateExpressions();\n this.key = rawItem.key;\n this.config = this.parseConfig(rawItem.config);\n }\n\n private updateExpressions() {\n this.displayConditions = this._rawItem.displayConditions\n ? displayConditionsFromJson(this._rawItem.displayConditions)\n : undefined;\n this.disabledConditions = this._rawItem.disabledConditions\n ? disabledConditionsFromJson(this._rawItem.disabledConditions)\n : undefined;\n this.validations = this._rawItem.validations\n ? Object.fromEntries(\n Object.entries(this._rawItem.validations).map(([key, value]) => [\n key,\n Expression.deserialize(value),\n ]),\n )\n : undefined;\n this.prefills = this._rawItem.prefills?.map((prefill) => deserializeSurveyItemPrefill(prefill));\n }\n\n getReferenceUsages(): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n\n if (this.displayConditions) {\n // root\n for (const ref of this.displayConditions.root?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n\n // components\n for (const [componentKey, expression] of Object.entries(\n this.displayConditions.components || {},\n )) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.disabledConditions) {\n for (const [componentKey, expression] of Object.entries(\n this.disabledConditions.components || {},\n )) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.disabledConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.validations) {\n for (const [validationKey, expression] of Object.entries(this.validations)) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: validationKey,\n usageType: ReferenceUsageType.validations,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.prefills) {\n for (const prefill of this.prefills) {\n for (const ref of prefill.when?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: prefill.id,\n usageType: ReferenceUsageType.prefills,\n valueReference: ref,\n });\n }\n\n if (prefill.source.type === \"expression\") {\n for (const ref of prefill.source.expression.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: prefill.id,\n usageType: ReferenceUsageType.prefills,\n valueReference: ref,\n });\n }\n }\n }\n }\n\n return usages;\n }\n\n resolvePrefillTarget(target: SurveyItemPrefillTarget): ResponseSlotDefinition | undefined {\n const slotDefinitions = this.getResponseSlotDefinitions();\n const explicitMatch = slotDefinitions.find(\n (slot) => slot.prefillTarget !== undefined && prefillTargetsEqual(slot.prefillTarget, target),\n );\n if (explicitMatch) {\n return explicitMatch;\n }\n\n if (target.type === SurveyItemPrefillTargetType.itemResponse && slotDefinitions.length === 1) {\n return slotDefinitions[0];\n }\n\n return undefined;\n }\n\n normalizePrefillValue(\n _prefill: SurveyItemPrefill,\n targetSlot: ResponseSlotDefinition,\n value: ResponseValue,\n ): ResponseValue | undefined {\n return value.type === targetSlot.valueType ? value : undefined;\n }\n}\n\n/**\n * Constructor type for handler classes. Used by the registry to instantiate handlers.\n */\nexport type ItemCoreConstructor<TType extends string = string, TConfig = unknown> = new (\n rawItem: RawSurveyItem,\n) => SurveyItemCore<TType, TConfig>;\n","export enum ReservedSurveyItemTypes {\n Group = \"group\",\n PageBreak = \"page-break\",\n}\n","/**\n * SurveyItemKey stores the key of the item and the path to the item.\n */\n\nexport class SurveyItemKey {\n private _itemKey: string;\n private _path: Array<string>;\n private _keySeparator: string;\n\n constructor(itemKey: string, path: string[] | undefined, keySeparator: string = \".\") {\n this._itemKey = itemKey;\n this._path = path ?? [];\n this._keySeparator = keySeparator;\n }\n\n get itemKey(): string {\n return this._itemKey;\n }\n\n get path(): Array<string> {\n return this._path;\n }\n\n get parentFullKey(): string {\n return this._path.join(this._keySeparator);\n }\n\n get fullKey(): string {\n return [...this._path, this._itemKey].join(this._keySeparator);\n }\n\n get isRoot(): boolean {\n return this._path.length === 0;\n }\n\n get keySeparator(): string {\n return this._keySeparator;\n }\n\n set keySeparator(keySeparator: string) {\n this._keySeparator = keySeparator;\n }\n}\n","/**\n * Shared utilities for array operations.\n */\n\n/**\n * Swap two elements in an array by index.\n * @returns A new array with the elements swapped\n */\nexport function swapArrayElements<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n [result[fromIndex], result[toIndex]] = [result[toIndex], result[fromIndex]];\n return result;\n}\n\n/**\n * Move an element from one index to another.\n * @returns A new array with the element moved\n */\nexport function moveArrayElement<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n const [moved] = result.splice(fromIndex, 1);\n result.splice(toIndex, 0, moved);\n return result;\n}\n","import { ReservedSurveyItemTypes } from \"../items/types\";\nimport { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { moveArrayElement, swapArrayElements } from \"../utils/group-utils\";\n\n/**\n * Group item core.\n */\nexport type GroupConfig = {\n items?: string[];\n shuffleItems?: boolean;\n isRoot?: boolean;\n};\n\nexport class GroupItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.Group,\n GroupConfig\n> {\n readonly type = ReservedSurveyItemTypes.Group;\n\n parseConfig(rawConfig: unknown): GroupConfig {\n const cfg = (rawConfig ?? {}) as Partial<GroupConfig>;\n return {\n items: cfg.items,\n shuffleItems: cfg.shuffleItems,\n isRoot: cfg.isRoot,\n };\n }\n\n serializeConfig(): unknown {\n return this.config;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n\n isRoot(): boolean {\n return this.config.isRoot ?? false;\n }\n\n get items(): string[] {\n return this.config.items ?? [];\n }\n\n /**\n * Add a child item id to this group at the given index.\n * @param itemId The id of the item to add to this group.\n * @param index The index at which to add the item. If not provided, the item is added to the end of the group.\n */\n addChild(itemId: string, index?: number): void {\n const items = (this.config.items ??= []);\n const insertIndex = index !== undefined ? Math.min(index, items.length) : items.length;\n items.splice(insertIndex, 0, itemId);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Remove a child item id from this group.\n * @param itemId The id of the item to remove from this group.\n */\n removeChild(itemId: string): void {\n const items = (this.config.items ??= []);\n const index = items.indexOf(itemId);\n if (index !== -1) {\n items.splice(index, 1);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n }\n\n /**\n * Check if an item is a direct child of this group.\n */\n hasChild(itemId: string): boolean {\n return this.items.includes(itemId);\n }\n\n /** Whether items in this group should be shuffled. */\n get shuffleItems(): boolean {\n return this.config.shuffleItems ?? false;\n }\n\n set shuffleItems(value: boolean) {\n this.config.shuffleItems = value;\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Get the ordered list of child item ids.\n */\n getChildrenIds(): string[] {\n return [...this.items];\n }\n\n /**\n * Swap two items by their positions in the group.\n * @throws Error if indices are out of bounds\n */\n swapItemsByIndex(from: number, to: number): void {\n const items = this.items;\n if (from < 0 || from >= items.length || to < 0 || to >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (from === to) return;\n this.config.items = swapArrayElements(items, from, to);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Swap two items by their ids.\n * @throws Error if either id is not found in this group\n */\n swapItemsById(id: string, withId: string): void {\n const items = this.items;\n const index1 = items.indexOf(id);\n const index2 = items.indexOf(withId);\n if (index1 === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index2 === -1) {\n throw new Error(`Item '${withId}' not found in group '${this.key}'`);\n }\n this.swapItemsByIndex(index1, index2);\n }\n\n /**\n * Move an item by id to a specific index.\n * @throws Error if the item is not found or index is out of bounds\n */\n moveItemToIndex(id: string, index: number): void {\n const items = this.items;\n const fromIndex = items.indexOf(id);\n if (fromIndex === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index < 0 || index >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (fromIndex === index) return;\n this.config.items = moveArrayElement(items, fromIndex, index);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n}\n\n/**\n * Page break item core.\n */\nexport type PageBreakConfig = Record<string, never>;\n\nexport class PageBreakItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.PageBreak,\n PageBreakConfig\n> {\n readonly type = ReservedSurveyItemTypes.PageBreak;\n\n parseConfig(_rawConfig: unknown): PageBreakConfig {\n return {};\n }\n\n serializeConfig(): unknown {\n return undefined;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n}\n\n/**\n * Built-in item type.\n */\nexport type BuiltInItemType =\n | typeof ReservedSurveyItemTypes.Group\n | typeof ReservedSurveyItemTypes.PageBreak;\n\nexport const builtInItemCoreRegistry: Record<BuiltInItemType, ItemCoreConstructor> = {\n [ReservedSurveyItemTypes.Group]: GroupItemCore,\n [ReservedSurveyItemTypes.PageBreak]: PageBreakItemCore,\n};\n\nexport const isBuiltInItemType = (itemType: string): itemType is BuiltInItemType =>\n itemType in builtInItemCoreRegistry;\n","import { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { RawSurveyItem } from \"../items/survey-item-json\";\nimport { builtInItemCoreRegistry, isBuiltInItemType } from \"./built-in-items\";\nimport type { AnyItemExpressionDefinition } from \"../../expressions/item-expression-registry\";\n\n/**\n * Registry maps item type name → handler constructor.\n * Plugins extend this with their own handler classes.\n */\nexport type ItemTypeRegistry = Record<string, new (rawItem: RawSurveyItem) => SurveyItemCore>;\n\n/** Item type identifier (e.g. \"singleChoiceQuestion\", \"display\"). */\nexport type ItemTypeName = string;\n\n/** Capabilities of an item type (interactive, supports children). */\nexport interface ItemTypeCapabilities {\n interactive?: boolean;\n supportsChildren?: boolean;\n}\n\n/**\n * Definition of an item type: its name, constructor, and optional capabilities.\n * Used by editor/UI layers to compose registries.\n */\nexport interface ItemTypeDefinition {\n itemType: ItemTypeName;\n constructor: ItemCoreConstructor;\n capabilities?: ItemTypeCapabilities;\n expressions?: AnyItemExpressionDefinition[];\n}\n\n/** Registry mapping item type name → definition. */\nexport type ItemTypeDefinitionRegistry = Record<ItemTypeName, ItemTypeDefinition>;\n\n/** Convert constructor registry to explicit definitions for higher-layer composition. */\nexport function toItemTypeDefinitionRegistry(\n registry: ItemTypeRegistry,\n): ItemTypeDefinitionRegistry {\n return Object.fromEntries(\n Object.entries(registry).map(([itemType, constructor]) => [\n itemType,\n { itemType, constructor },\n ]),\n );\n}\n\n/**\n * Creates a handler instance for a raw survey item.\n * Uses built-in registry for group/page-break, otherwise the provided plugin registry.\n */\nexport function createItemCore(\n rawItem: RawSurveyItem,\n pluginRegistry?: ItemTypeRegistry,\n): SurveyItemCore {\n if (isBuiltInItemType(rawItem.itemType)) {\n const HandlerClass = builtInItemCoreRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n if (pluginRegistry && rawItem.itemType in pluginRegistry) {\n const HandlerClass = pluginRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n throw new Error(`Unknown item type: ${rawItem.itemType}`);\n}\n\n/**\n * Merge built-in handlers with plugin registry for a complete registry.\n */\nexport function createFullRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeRegistry {\n return {\n ...builtInItemCoreRegistry,\n ...pluginRegistry,\n };\n}\n\n/** Build full registry as explicit definitions for editor/ui composition. */\nexport function createItemTypeDefinitionRegistry(\n pluginRegistry?: ItemTypeRegistry,\n): ItemTypeDefinitionRegistry {\n return toItemTypeDefinitionRegistry(createFullRegistry(pluginRegistry));\n}\n","import { JsonTemplateValue } from \"../expressions/template-value\";\nimport { RawSurveyItem } from \"./items\";\nimport { JsonSurveyTranslations } from \"./utils/translations\";\n\nexport const CURRENT_SURVEY_SCHEMA =\n \"https://github.com/case-framework/case-survey-toolkit/packages/survey-core/schemas/survey-schema.json\";\n// TODO: generate schema from survey-core.ts\n\nexport interface SurveyVersion {\n id?: string;\n surveyKey: string;\n published?: number;\n unpublished?: number;\n versionId?: string;\n survey: RawSurvey;\n}\n\nexport type RawSurveyAsset = {\n kind: \"image\";\n source: {\n type: \"embedded\";\n mediaType: string;\n encoding: \"base64\";\n data: string;\n };\n metadata?: {\n name?: string;\n filename?: string;\n alt?: string;\n width?: number;\n height?: number;\n };\n};\n\nexport type RawSurvey = {\n $schema: string;\n maxItemsPerPage?: { large: number; small: number };\n\n surveyItems: Array<RawSurveyItem>;\n assets?: Record<string, RawSurveyAsset>;\n\n metadata?: {\n [key: string]: string;\n };\n templateValues?: {\n [templateValueKey: string]: JsonTemplateValue;\n };\n translations?: JsonSurveyTranslations;\n};\n","import { structuredCloneMethod } from \"../../utils\";\nimport { Content } from \"./content\";\n\nexport const validateLocale = (locale: string): void => {\n if (locale.trim() === \"\") {\n throw new Error(\"Locale cannot be empty\");\n }\n};\n\nexport class SurveyItemTranslations {\n private _translations?: {\n [locale: string]: JsonComponentContent;\n };\n\n constructor() {\n this._translations = {};\n }\n\n setContent(locale: string, contentKey: string, content?: Content): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations![locale] = {};\n }\n if (!content) {\n delete this._translations![locale][contentKey];\n } else {\n this._translations![locale][contentKey] = content;\n }\n }\n\n setAllForLocale(locale: string, content?: JsonComponentContent): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations![locale] = {};\n }\n this._translations![locale] = content || {};\n }\n\n get locales(): string[] {\n return Object.keys(this._translations || {});\n }\n\n getAllForLocale(locale: string): JsonComponentContent | undefined {\n return this._translations?.[locale];\n }\n\n getContent(locale: string, contentKey: string, fallbackLocale?: string): Content | undefined {\n const content = this._translations?.[locale]?.[contentKey];\n if (content) {\n return content;\n }\n if (fallbackLocale) {\n return this._translations?.[fallbackLocale]?.[contentKey];\n }\n return undefined;\n }\n\n /**\n * Create a deep clone that can be safely mutated before persisting with\n * `setItemTranslations` or `updateItemTranslations`.\n */\n clone(): SurveyItemTranslations {\n const cloned = new SurveyItemTranslations();\n\n for (const locale of this.locales) {\n const localeContent = this.getAllForLocale(locale);\n if (!localeContent) {\n continue;\n }\n\n cloned.setAllForLocale(locale, structuredCloneMethod(localeContent));\n }\n\n return cloned;\n }\n\n /**\n * Remove a single content key from every locale in this translation set.\n */\n removeContentKey(contentKey: string): void {\n for (const locale of this.locales) {\n delete this._translations?.[locale]?.[contentKey];\n }\n }\n\n /**\n * Remove every content key that is exactly the prefix or nested beneath it.\n */\n removeContentKeysWithPrefix(prefix: string): void {\n for (const locale of this.locales) {\n const localeContent = this._translations?.[locale];\n if (!localeContent) {\n continue;\n }\n\n for (const contentKey of Object.keys(localeContent)) {\n if (contentKey === prefix || contentKey.startsWith(prefix + \".\")) {\n delete localeContent[contentKey];\n }\n }\n }\n }\n\n /**\n * Remove empty locales in place.\n * Returns `undefined` when no translations remain so callers can pass the\n * result directly into `setItemTranslations` / `updateItemTranslations`.\n */\n compact(): SurveyItemTranslations | undefined {\n for (const locale of this.locales) {\n const localeContent = this._translations?.[locale];\n if (!localeContent) {\n continue;\n }\n\n if (Object.keys(localeContent).length === 0) {\n delete this._translations?.[locale];\n }\n }\n\n return this.locales.length > 0 ? this : undefined;\n }\n}\n\nexport interface SurveyCardTranslations {\n [locale: string]: SurveyCardContent;\n}\n\nexport class SurveyTranslations {\n private _translations: JsonSurveyTranslations;\n\n constructor(translations?: JsonSurveyTranslations) {\n this._translations = translations || {};\n }\n\n serialize(): JsonSurveyTranslations | undefined {\n if (this.locales.length === 0) {\n return undefined;\n }\n return this._translations;\n }\n\n get locales(): string[] {\n return Object.keys(this._translations);\n }\n\n /**\n * Register a locale even when it has no translated content yet.\n * Returns false when the locale is already present.\n */\n addLocale(locale: string): boolean {\n validateLocale(locale);\n if (this._translations[locale]) {\n return false;\n }\n\n this._translations[locale] = {};\n return true;\n }\n\n removeLocale(locale: string): void {\n validateLocale(locale);\n delete this._translations[locale];\n }\n\n renameLocale(oldLocale: string, newLocale: string): void {\n validateLocale(oldLocale);\n validateLocale(newLocale);\n if (this._translations[oldLocale]) {\n this._translations[newLocale] = this._translations[oldLocale];\n delete this._translations[oldLocale];\n }\n }\n\n cloneLocaleAs(locale: string, newLocale: string): void {\n validateLocale(locale);\n validateLocale(newLocale);\n if (this._translations[locale]) {\n this._translations[newLocale] = structuredCloneMethod(this._translations[locale]);\n }\n }\n\n get surveyCardContent(): SurveyCardTranslations | undefined {\n const translations: SurveyCardTranslations = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.surveyCardContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as SurveyCardContent;\n }\n }\n return translations;\n }\n\n get navigationContent(): { [locale: string]: NavigationContent } | undefined {\n const translations: { [locale: string]: NavigationContent } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.navigationContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as NavigationContent;\n }\n }\n return translations;\n }\n\n get validationMessages(): { [locale: string]: { invalidResponse?: Content } } | undefined {\n const translations: { [locale: string]: { invalidResponse?: Content } } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.validationMessages;\n if (contentForLocale) {\n translations[locale] = contentForLocale as { invalidResponse?: Content };\n }\n }\n return translations;\n }\n\n setSurveyCardContent(locale: string, content?: SurveyCardContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations[locale] = {};\n }\n this._translations[locale].surveyCardContent = content;\n }\n\n setNavigationContent(locale: string, content?: NavigationContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations[locale] = {};\n }\n this._translations[locale].navigationContent = content;\n }\n\n setValidationMessages(locale: string, content?: { invalidResponse?: Content }): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations[locale] = {};\n }\n this._translations[locale].validationMessages = content;\n }\n\n getItemTranslations(itemId: string): SurveyItemTranslations | undefined {\n const itemTranslations: SurveyItemTranslations = new SurveyItemTranslations();\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale].itemTranslations?.[itemId];\n itemTranslations.setAllForLocale(locale, contentForLocale as JsonComponentContent);\n }\n return itemTranslations.locales.length > 0 ? itemTranslations : undefined;\n }\n\n /**\n * Persist item translations after normalizing them:\n * empty keys/locales are removed automatically, and an empty translation set\n * clears the item's stored translations entirely.\n */\n setItemTranslations(itemId: string, itemContent?: SurveyItemTranslations): void {\n const normalizedItemContent = itemContent?.clone().compact();\n\n normalizedItemContent?.locales.forEach((locale) => validateLocale(locale));\n if (!normalizedItemContent) {\n for (const locale of this.locales) {\n if (this._translations[locale].itemTranslations?.[itemId]) {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n } else {\n const localesInUpdate = normalizedItemContent.locales;\n // Add new locales to the translations\n for (const locale of localesInUpdate) {\n if (!this.locales.includes(locale)) {\n this._translations[locale] = {};\n }\n }\n for (const locale of this.locales) {\n if (localesInUpdate.includes(locale)) {\n if (!this._translations[locale]) {\n this._translations[locale] = {};\n }\n if (!this._translations[locale].itemTranslations) {\n this._translations[locale].itemTranslations = {};\n }\n this._translations[locale].itemTranslations![itemId] =\n normalizedItemContent.getAllForLocale(locale)!;\n } else {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n }\n }\n\n /**\n * Rename a component key (within an item) - update key in all translations and remove old key\n * @param itemKey - The key of the item\n * @param oldKey - The old key of the component\n * @param newKey - The new key of the component\n */\n onComponentKeyChanged(itemKey: string, oldKey: string, newKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[\n itemKey\n ] as JsonComponentContent;\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(oldKey + \".\") || key === oldKey) {\n itemTranslations[key.replace(oldKey, newKey)] = { ...itemTranslations[key] };\n delete itemTranslations[key];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for a component\n * @param itemId - The id of the item\n * @param componentKey - The key of the component\n */\n onComponentDeleted(itemId: string, componentKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[itemId];\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(componentKey + \".\") || key === componentKey) {\n delete itemTranslations[key as keyof typeof itemTranslations];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for an item\n * @param id - The id of the item\n */\n onItemDeleted(id: string): void {\n for (const locale of this.locales) {\n delete this._translations![locale].itemTranslations?.[id];\n }\n }\n}\n\n/**\n * Json Schemas for translations\n */\nexport type JsonComponentContent = {\n [contentKey: string]: Content;\n};\n\nexport interface SurveyCardContent {\n name?: Content;\n description?: Content;\n typicalDuration?: Content;\n}\n\nexport interface NavigationContent {\n previousButtonText?: Content;\n nextButtonText?: Content;\n submitButtonText?: Content;\n pageIndicatorText?: Content;\n submitBoxMessage?: Content;\n}\n\nexport interface JsonSurveyTranslations {\n [locale: string]: {\n surveyCardContent?: SurveyCardContent;\n navigationContent?: NavigationContent;\n validationMessages?: {\n invalidResponse?: Content;\n };\n itemTranslations?: {\n [itemId: string]: JsonComponentContent;\n };\n };\n}\n","export enum ContentType {\n richText = \"richText\",\n plain = \"plain\",\n md = \"md\",\n}\n\nexport type ContentAttributes = Record<string, unknown>;\n\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\nexport type RichTextStyle = {\n weight?: \"strong\" | \"normal\";\n italic?: \"italic\" | \"normal\";\n underline?: \"underline\" | \"none\";\n color?: \"primary\" | \"accent\" | \"default\";\n};\n\nexport type RichTextTextInline = {\n type: \"text\";\n text: string;\n style?: RichTextStyle;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextTemplateInline = {\n type: \"template\";\n key: string;\n style?: RichTextStyle;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextLineBreakInline = {\n type: \"lineBreak\";\n attrs?: ContentAttributes;\n};\n\n/** Inline nodes allowed inside a {@link RichTextLinkInline} (no nested links). */\nexport type RichTextLinkChildInline =\n | RichTextTextInline\n | RichTextTemplateInline\n | RichTextLineBreakInline;\n\nexport type RichTextLinkInline = {\n type: \"link\";\n href: string;\n target?: string | null;\n rel?: string | null;\n title?: string | null;\n attrs?: ContentAttributes;\n children: RichTextLinkChildInline[];\n};\n\nexport type RichTextInlineExtension = {\n type: \"inlineExtension\";\n name: string;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextInlineNode =\n | RichTextTextInline\n | RichTextTemplateInline\n | RichTextLinkInline\n | RichTextLineBreakInline\n | RichTextInlineExtension;\n\nexport type RichTextParagraphBlock = {\n type: \"paragraph\";\n children: RichTextInlineNode[];\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextHeadingBlock = {\n type: \"heading\";\n level: 1 | 2 | 3 | 4 | 5 | 6;\n children: RichTextInlineNode[];\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextListItemBlock = {\n type: \"listItem\";\n children: RichTextParagraphBlock[];\n attrs?: ContentAttributes;\n};\n\nexport type RichTextBulletListBlock = {\n type: \"bulletList\";\n items: RichTextListItemBlock[];\n attrs?: ContentAttributes;\n};\n\nexport type SurveyContentImageSource =\n | {\n type: \"external\";\n url: string;\n }\n | {\n type: \"asset\";\n assetId: string;\n };\n\nexport type RichTextImageDimension = { unit: \"px\"; value: number } | { unit: \"%\"; value: number };\n\nexport type RichTextImageSize = {\n width?: RichTextImageDimension;\n height?: RichTextImageDimension;\n maxWidth?: RichTextImageDimension;\n maxHeight?: RichTextImageDimension;\n};\n\nexport type RichTextImageBlock = {\n type: \"image\";\n source: SurveyContentImageSource;\n alt?: string;\n caption?: RichTextParagraphBlock[];\n size?: RichTextImageSize;\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextInfoBoxBlock = {\n type: \"infoBox\";\n tone?: \"info\" | \"warning\";\n title?: RichTextInlineNode[];\n collapsible?: boolean;\n defaultOpen?: boolean;\n children: RichTextParagraphBlock[];\n attrs?: ContentAttributes;\n};\n\nexport type RichTextSeparatorBlock = {\n type: \"separator\";\n attrs?: ContentAttributes;\n};\n\nexport type RichTextBlockExtension = {\n type: \"blockExtension\";\n name: string;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextBlockNode =\n | RichTextParagraphBlock\n | RichTextHeadingBlock\n | RichTextBulletListBlock\n | RichTextImageBlock\n | RichTextInfoBoxBlock\n | RichTextSeparatorBlock\n | RichTextBlockExtension;\n\nexport type RichTextDocument = {\n type: \"doc\";\n blocks: RichTextBlockNode[];\n};\n\nexport type RichTextContent = {\n type: ContentType.richText;\n version: 1;\n doc: RichTextDocument;\n};\n\nexport type MDContent = {\n type: ContentType.md;\n content: string;\n};\n\nexport type PlainTextContent = {\n type: ContentType.plain;\n content: string;\n};\n\nexport type Content = RichTextContent | MDContent | PlainTextContent;\nexport type RichTextInline = RichTextInlineNode;\n\nexport interface ContentAssetUsage {\n assetId: string;\n blockIndex: number;\n}\n\nexport function hasRenderableRichTextBlock(block: RichTextBlockNode): boolean {\n switch (block.type) {\n case \"paragraph\":\n return block.children.length > 0;\n case \"heading\":\n return block.children.length > 0;\n case \"bulletList\":\n return block.items.some((item) =>\n item.children.some((paragraph) => paragraph.children.length > 0),\n );\n case \"image\":\n return true;\n case \"infoBox\":\n // Empty callouts are still intentional blocks (editor inserts title/body later).\n return true;\n case \"separator\":\n return true;\n case \"blockExtension\":\n return true;\n }\n}\n\nexport function hasRenderableRichTextContent(content: RichTextContent): boolean {\n return content.doc.blocks.some((block) => hasRenderableRichTextBlock(block));\n}\n\nexport function createRichTextContent(text = \"\"): RichTextContent {\n return {\n type: ContentType.richText,\n version: 1,\n doc: {\n type: \"doc\",\n blocks: [\n {\n type: \"paragraph\",\n children:\n text.length > 0\n ? text.split(\"\\n\").flatMap<RichTextInlineNode>((line, index) => {\n const parts: RichTextInlineNode[] = [];\n if (index > 0) {\n parts.push({ type: \"lineBreak\" });\n }\n if (line.length > 0) {\n parts.push({ type: \"text\", text: line });\n }\n return parts;\n })\n : [],\n },\n ],\n },\n };\n}\n\nfunction getPlainTextFromLinkChildren(children: RichTextLinkChildInline[]): string {\n return children\n .map((inline) => {\n switch (inline.type) {\n case \"text\":\n return inline.text;\n case \"template\":\n return `{${inline.key}}`;\n case \"lineBreak\":\n return \"\\n\";\n }\n })\n .join(\"\");\n}\n\nfunction getPlainTextFromInlineNodes(inlines: RichTextInlineNode[]): string {\n return inlines\n .map((inline) => {\n switch (inline.type) {\n case \"text\":\n return inline.text;\n case \"template\":\n return `{${inline.key}}`;\n case \"link\":\n return getPlainTextFromLinkChildren(inline.children);\n case \"lineBreak\":\n return \"\\n\";\n case \"inlineExtension\":\n return \"\";\n }\n })\n .join(\"\");\n}\n\nfunction getPlainTextFromParagraphs(paragraphs: RichTextParagraphBlock[]): string {\n return paragraphs.map((paragraph) => getPlainTextFromInlineNodes(paragraph.children)).join(\"\\n\");\n}\n\nfunction getPlainTextFromBlock(block: RichTextBlockNode): string {\n switch (block.type) {\n case \"paragraph\":\n return getPlainTextFromInlineNodes(block.children);\n case \"heading\":\n return getPlainTextFromInlineNodes(block.children);\n case \"bulletList\":\n return block.items.map((item) => getPlainTextFromParagraphs(item.children)).join(\"\\n\");\n case \"image\": {\n const captionText = block.caption ? getPlainTextFromParagraphs(block.caption) : \"\";\n return [block.alt ?? \"\", captionText].filter(Boolean).join(\"\\n\");\n }\n case \"infoBox\": {\n const titleText = block.title ? getPlainTextFromInlineNodes(block.title) : \"\";\n const bodyText = getPlainTextFromParagraphs(block.children);\n return [titleText, bodyText].filter(Boolean).join(\"\\n\");\n }\n case \"separator\":\n return \"\";\n case \"blockExtension\":\n return \"\";\n }\n}\n\nexport function getPlainTextFromRichTextContent(content: RichTextContent): string {\n return content.doc.blocks\n .map((block) => getPlainTextFromBlock(block))\n .filter((text) => text.length > 0)\n .join(\"\\n\")\n .trim();\n}\n\nexport function getContentPlainText(content?: Content): string {\n if (!content) {\n return \"\";\n }\n\n if (content.type !== ContentType.richText) {\n return content.content ?? \"\";\n }\n\n return getPlainTextFromRichTextContent(content);\n}\n\nexport function isContentEmpty(content?: Content): boolean {\n if (!content) {\n return true;\n }\n\n if (content.type !== ContentType.richText) {\n return content.content.trim().length === 0;\n }\n\n return !hasRenderableRichTextContent(content);\n}\n\nexport function getAssetUsagesFromContent(content?: Content): ContentAssetUsage[] {\n if (!content || content.type !== ContentType.richText) {\n return [];\n }\n\n const usages: ContentAssetUsage[] = [];\n\n content.doc.blocks.forEach((block, blockIndex) => {\n if (block.type === \"image\" && block.source.type === \"asset\") {\n usages.push({\n assetId: block.source.assetId,\n blockIndex,\n });\n }\n });\n\n return usages;\n}\n","import { CURRENT_SURVEY_SCHEMA, RawSurvey, RawSurveyAsset } from \"./survey-file-schema\";\nimport { SurveyItemTranslations, SurveyTranslations } from \"./utils/translations\";\nimport { SurveyItemCore, RawSurveyItem, ReservedSurveyItemTypes } from \"./items\";\nimport { ReferenceUsage, ReferenceUsageType } from \"./utils/value-reference\";\nimport { Content, getAssetUsagesFromContent } from \"./utils/content\";\nimport { SurveyItemKey } from \"./item-key\";\nimport {\n deserializeTemplateValues,\n serializeTemplateValues,\n TemplateValueDefinition,\n} from \"../expressions/template-value\";\nimport { ValueRefTypeLookup, ValueType } from \"./responses/value-types\";\nimport { ResponseSlotDefinition } from \"./responses/slot-definition\";\nimport { createItemCore, ItemTypeRegistry } from \"./registry/item-registry\";\nimport { GroupItemCore } from \"./registry/built-in-items\";\nimport { generateId, structuredCloneMethod } from \"../utils\";\n\nexport interface SurveyAssetUsage {\n assetId: string;\n itemId?: string;\n locale?: string;\n contentKey: string;\n usageScope: \"itemTranslation\" | \"surveyCard\" | \"navigation\" | \"validationMessages\";\n blockIndex: number;\n}\n\nexport class Survey {\n maxItemsPerPage?: { large: number; small: number };\n metadata?: {\n [key: string]: string;\n };\n surveyItems: Map<string, SurveyItemCore> = new Map();\n private _templateValues?: Map<string, TemplateValueDefinition> = new Map();\n private _assets?: Map<string, RawSurveyAsset> = new Map();\n\n private _translations?: SurveyTranslations;\n\n constructor(private readonly pluginRegistry?: ItemTypeRegistry) {\n this._translations = new SurveyTranslations();\n }\n\n /** Plugin registry used when parsing items. Exposed for editors that re-parse without their own registry. */\n getPluginRegistry(): ItemTypeRegistry | undefined {\n return this.pluginRegistry;\n }\n\n /**\n * Create a survey item from raw JSON data.\n * Uses the survey's plugin registry when available.\n */\n createItemFromRaw(rawItem: RawSurveyItem): SurveyItemCore {\n return createItemCore(rawItem, this.pluginRegistry);\n }\n\n /**\n * Create a minimal blank survey with a root group and one empty page.\n */\n static createBlankSurvey(pluginRegistry?: ItemTypeRegistry, surveyKey?: string): Survey {\n const newKey = surveyKey ?? \"survey\";\n const rawSurvey: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: [\n {\n id: generateId(),\n key: newKey,\n itemType: ReservedSurveyItemTypes.Group,\n config: { isRoot: true, items: [], shuffleItems: false },\n },\n ],\n };\n\n return Survey.fromJson(rawSurvey, pluginRegistry);\n }\n\n static fromJson(json: RawSurvey, pluginRegistry?: ItemTypeRegistry): Survey {\n const survey = new Survey(pluginRegistry);\n const rawSurvey = json as RawSurvey;\n if (rawSurvey.$schema !== CURRENT_SURVEY_SCHEMA) {\n throw new Error(`Unsupported survey schema: ${rawSurvey.$schema}`);\n }\n\n survey.surveyItems = new Map();\n if (!rawSurvey.surveyItems || rawSurvey.surveyItems.length === 0) {\n throw new Error(\"surveyItems is required\");\n }\n rawSurvey.surveyItems.forEach((item) => {\n const surveyItem = createItemCore(item, pluginRegistry);\n survey.surveyItems.set(surveyItem.id, surveyItem);\n });\n\n // Parse other fields\n if (rawSurvey.templateValues) {\n survey._templateValues = deserializeTemplateValues(rawSurvey.templateValues);\n }\n\n if (rawSurvey.assets) {\n survey._assets = new Map(Object.entries(rawSurvey.assets));\n }\n\n survey._translations = new SurveyTranslations(rawSurvey.translations);\n\n if (rawSurvey.maxItemsPerPage) {\n survey.maxItemsPerPage = rawSurvey.maxItemsPerPage;\n }\n\n if (rawSurvey.metadata) {\n survey.metadata = rawSurvey.metadata;\n }\n\n return survey;\n }\n\n serialize(): RawSurvey {\n const json: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: Array.from(this.surveyItems.values()).map((item) => item.rawItem),\n };\n\n // Export other fields\n json.translations = this._translations?.serialize();\n\n if (this._templateValues) {\n json.templateValues = serializeTemplateValues(this._templateValues);\n }\n\n if (this._assets && this._assets.size > 0) {\n json.assets = Object.fromEntries(this._assets.entries());\n }\n\n if (this.maxItemsPerPage) {\n json.maxItemsPerPage = this.maxItemsPerPage;\n }\n if (this.metadata) {\n json.metadata = this.metadata;\n }\n\n return json;\n }\n\n get surveyKey(): string | undefined {\n const rootItem = this.rootItem;\n if (!rootItem) {\n return undefined;\n }\n return this.rootItem.key;\n }\n\n get locales(): string[] {\n return this._translations?.locales || [];\n }\n\n get rootItem(): GroupItemCore | undefined {\n const rootItem = Array.from(this.surveyItems.values()).find(\n (item) => item instanceof GroupItemCore && item.isRoot,\n ) as GroupItemCore | undefined;\n return rootItem;\n }\n\n get keyIndex(): Array<{ itemId: string; key: string; keyPath: string[]; path: string[] }> {\n const index: Array<{ itemId: string; key: string; keyPath: string[]; path: string[] }> = [];\n for (const item of this.surveyItems.values()) {\n const path = this.getItemPath(item.id);\n index.push({\n itemId: item.id,\n key: item.key,\n keyPath: path.map((id) => this.surveyItems.get(id)?.key ?? \"\"),\n path: path,\n });\n }\n return index;\n }\n\n getItemPath(itemId: string): string[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n\n if (item instanceof GroupItemCore && item.isRoot()) {\n return [];\n }\n\n // find parent item for the given item id\n const parentItem = this.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Parent item for ${itemId} not found`);\n }\n return [...this.getItemPath(parentItem.id), parentItem.id];\n }\n\n getItemKey(itemId: string): SurveyItemKey | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return undefined;\n }\n const idPath = this.getItemPath(itemId);\n const keyPath = idPath.map((id) => this.surveyItems.get(id)?.key ?? \"\");\n return new SurveyItemKey(item.key, keyPath);\n }\n\n getParentItem(itemId: string): GroupItemCore | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n if (item instanceof GroupItemCore && item.isRoot()) {\n return undefined;\n }\n const parentItem = Array.from(this.surveyItems.values()).find(\n (item) => item instanceof GroupItemCore && item.config.items?.includes(itemId),\n ) as GroupItemCore | undefined;\n if (!parentItem) {\n return undefined;\n }\n return parentItem;\n }\n\n getChildrenItems(parentId: string): SurveyItemCore[] {\n const parentItem = this.surveyItems.get(parentId);\n if (!parentItem || !(parentItem instanceof GroupItemCore)) {\n return [];\n }\n return (\n ((parentItem as GroupItemCore).config.items\n ?.map((id) => this.surveyItems.get(id))\n ?.filter((item) => item !== undefined) as SurveyItemCore[]) || []\n );\n }\n\n getSiblings(itemId: string): SurveyItemCore[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return [];\n }\n const parentItem = this.getParentItem(itemId);\n return (\n (parentItem?.items\n ?.map((id) => this.surveyItems.get(id))\n ?.filter((item) => item !== undefined) as SurveyItemCore[]) || []\n );\n }\n\n get translations(): SurveyTranslations {\n if (!this._translations) {\n this._translations = new SurveyTranslations();\n }\n return this._translations;\n }\n\n getItemTranslations(id: string): SurveyItemTranslations | undefined {\n const item = this.surveyItems.get(id);\n if (!item) {\n throw new Error(`Item ${id} not found`);\n }\n\n return this._translations?.getItemTranslations(id);\n }\n\n getTemplateValue(templateValueKey: string): TemplateValueDefinition | undefined {\n return this._templateValues?.get(templateValueKey);\n }\n\n setTemplateValue(templateValueKey: string, templateValue: TemplateValueDefinition) {\n if (!this._templateValues) {\n this._templateValues = new Map();\n }\n this._templateValues?.set(templateValueKey, templateValue);\n }\n\n deleteTemplateValue(templateValueKey: string) {\n this._templateValues?.delete(templateValueKey);\n }\n\n getTemplateValueKeys(): string[] {\n return Array.from(this._templateValues?.keys() || []);\n }\n\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._assets?.get(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n if (!this._assets) {\n this._assets = new Map();\n }\n\n this._assets.set(assetId, structuredCloneMethod(asset));\n }\n\n deleteAsset(assetId: string): void {\n this._assets?.delete(assetId);\n }\n\n hasAsset(assetId: string): boolean {\n return this._assets?.has(assetId) ?? false;\n }\n\n getAssetIds(): string[] {\n return Array.from(this._assets?.keys() || []);\n }\n\n getAssets(): Map<string, RawSurveyAsset> {\n return new Map(\n Array.from(this._assets?.entries() || []).map(([assetId, asset]) => [\n assetId,\n structuredCloneMethod(asset),\n ]),\n );\n }\n\n getAssetUsages(filterAssetId?: string): SurveyAssetUsage[] {\n const usages: SurveyAssetUsage[] = [];\n const pushContentUsages = (\n content: Content | undefined,\n usageScope: SurveyAssetUsage[\"usageScope\"],\n contentKey: string,\n locale?: string,\n itemId?: string,\n ) => {\n for (const usage of getAssetUsagesFromContent(content)) {\n if (filterAssetId && usage.assetId !== filterAssetId) {\n continue;\n }\n\n usages.push({\n assetId: usage.assetId,\n itemId,\n locale,\n contentKey,\n usageScope,\n blockIndex: usage.blockIndex,\n });\n }\n };\n\n const serializedTranslations = this._translations?.serialize();\n const rootItemId = this.rootItem?.id;\n\n if (!serializedTranslations) {\n return usages;\n }\n\n for (const [locale, localeTranslations] of Object.entries(serializedTranslations)) {\n for (const [contentKey, content] of Object.entries(\n localeTranslations.surveyCardContent || {},\n )) {\n pushContentUsages(content, \"surveyCard\", contentKey, locale, rootItemId);\n }\n\n for (const [contentKey, content] of Object.entries(\n localeTranslations.navigationContent || {},\n )) {\n pushContentUsages(content, \"navigation\", contentKey, locale, rootItemId);\n }\n\n for (const [contentKey, content] of Object.entries(\n localeTranslations.validationMessages || {},\n )) {\n pushContentUsages(content, \"validationMessages\", contentKey, locale, rootItemId);\n }\n\n for (const [itemId, itemTranslations] of Object.entries(\n localeTranslations.itemTranslations || {},\n )) {\n for (const [contentKey, content] of Object.entries(itemTranslations || {})) {\n pushContentUsages(content, \"itemTranslation\", contentKey, locale, itemId);\n }\n }\n }\n\n return usages;\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n let valueRefs: ValueRefTypeLookup = {};\n for (const item of this.surveyItems.values()) {\n valueRefs = { ...valueRefs, ...item.getAvailableResponseValueSlots(byType) };\n }\n return valueRefs;\n }\n\n getResponseSlotDefinitions(): Array<{ itemId: string; slots: ResponseSlotDefinition[] }> {\n return Array.from(this.surveyItems.values()).map((item) => ({\n itemId: item.id,\n slots: item.getResponseSlotDefinitions(),\n }));\n }\n\n /**\n * Get all reference usages for the survey\n * @param forItemId - optional item id to filter usages for a specific item and its children (if not provided, all usages are returned)\n * @returns all reference usages for the survey (or for a specific item and its children)\n */\n getReferenceUsages(forItemId?: string): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n for (const item of this.surveyItems.values()) {\n if (forItemId && item.id !== forItemId && !this.isDescendantOf(item.id, forItemId)) {\n continue;\n }\n usages.push(...item.getReferenceUsages());\n }\n\n if (this._templateValues) {\n for (const [templateValueKey, templateValue] of this._templateValues.entries()) {\n for (const ref of templateValue.expression?.responseVariableRefs || []) {\n usages.push({\n itemId: templateValueKey,\n usageType: ReferenceUsageType.templateValues,\n valueReference: ref,\n });\n }\n }\n }\n\n return usages;\n }\n\n // Helper method to check if targetId is a descendant of ancestorId\n isDescendantOf(targetId: string, ancestorId: string): boolean {\n if (targetId === ancestorId) {\n return true;\n }\n const targetPath = this.getItemPath(targetId);\n return targetPath.includes(ancestorId);\n }\n}\n"],"mappings":";AAAA,SAAS,WAAW,MAAsB;CACxC,IAAI,OAAO;AAEX,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAQ,KAAK,WAAW,EAAE;AAC1B,SAAO,KAAK,KAAK,MAAM,SAAS;;AAGlC,QAAO,SAAS;;AAGlB,SAAgB,mBAAmB,MAA4B;CAC7D,IAAI,QAAQ,WAAW,KAAK;AAE5B,cAAa;AACX,UAAS,QAAQ,eAAgB;EACjC,IAAI,OAAO;AACX,SAAO,KAAK,KAAK,OAAQ,SAAS,IAAK,OAAO,EAAE;AAChD,UAAQ,OAAO,KAAK,KAAK,OAAQ,SAAS,GAAI,OAAO,GAAG;AACxD,WAAS,OAAQ,SAAS,QAAS,KAAK;;;AAI5C,SAAgB,aAAgB,QAAsB,SAAuB,KAAK,QAAa;CAC7F,MAAM,iBAAiB,CAAC,GAAG,OAAO;AAElC,MAAK,IAAI,IAAI,eAAe,SAAS,GAAG,IAAI,GAAG,KAAK;EAClD,MAAM,IAAI,KAAK,MAAM,QAAQ,IAAI,IAAI,GAAG;AACxC,GAAC,eAAe,IAAI,eAAe,MAAM,CAAC,eAAe,IAAI,eAAe,GAAG;;AAGjF,QAAO;;;;;;;AAQT,SAAgB,eAAe,QAAgB,SAAuB,KAAK,QAAkB;AAC3F,QAAO,aACL,MAAM,KAAK,EAAE,QAAQ,GAAG,GAAG,MAAM,EAAE,EACnC,OACD;;AAGH,SAAgB,sBAAyB,KAAW;AAClD,KAAI,OAAO,oBAAoB,YAC7B,QAAO,gBAAgB,IAAI;AAG7B,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AK,gBAAgB,SAAS,CAC5E,MAAK,MAAM,OAAO,cAAc,YAAY,wBAAwB,EAAE,CACpE,QAAO,KAAK;GACV,QAAQ;GACR,WAAA;GACA,gBAAgB;GACjB,CAAC;AAKR,SAAO;;CAIT,eAAe,UAAkB,YAA6B;AAC5D,MAAI,aAAa,WACf,QAAO;AAGT,SADmB,KAAK,YAAY,SACnB,CAAC,SAAS,WAAW"}
|
|
@@ -662,6 +662,11 @@ declare class SurveyTranslations {
|
|
|
662
662
|
constructor(translations?: JsonSurveyTranslations);
|
|
663
663
|
serialize(): JsonSurveyTranslations | undefined;
|
|
664
664
|
get locales(): string[];
|
|
665
|
+
/**
|
|
666
|
+
* Register a locale even when it has no translated content yet.
|
|
667
|
+
* Returns false when the locale is already present.
|
|
668
|
+
*/
|
|
669
|
+
addLocale(locale: string): boolean;
|
|
665
670
|
removeLocale(locale: string): void;
|
|
666
671
|
renameLocale(oldLocale: string, newLocale: string): void;
|
|
667
672
|
cloneLocaleAs(locale: string, newLocale: string): void;
|
|
@@ -987,4 +992,4 @@ declare class Survey {
|
|
|
987
992
|
}
|
|
988
993
|
//#endregion
|
|
989
994
|
export { RichTextLinkInline as $, ExpressionEditorConfig as $t, SurveyTranslations as A, ValueType as An, SurveyItemPrefillSource as At, RichTextBulletListBlock as B, ItemExpressionParameterInput as Bt, SurveyVersion as C, ReferenceArrayResponse as Cn, serializeTemplateValues as Ct, SurveyCardContent as D, StringArrayResponse as Dn, JsonSurveyItemPrefillTarget as Dt, NavigationContent as E, SlotResponseBase as En, JsonSurveyItemPrefillSource as Et, ContentType as F, prefillTargetsEqual as Ft, RichTextImageDimension as G, SurveyItemCore as Gt, RichTextDocument as H, buildItemExpression as Ht, MDContent as I, serializeSurveyItemPrefill as It, RichTextInline as J, RawSurveyItem as Jt, RichTextImageSize as K, SurveyItemCoreType as Kt, PlainTextContent as L, AnyItemExpressionDefinition as Lt, Content as M, isResponseValue as Mn, SurveyItemPrefillTargetType as Mt, ContentAssetUsage as N, SurveyItemPreviousResponseRef as Nt, SurveyCardTranslations as O, StringResponse as On, SurveyItemPrefill as Ot, ContentAttributes as P, deserializeSurveyItemPrefill as Pt, RichTextLinkChildInline as Q, Expression as Qt, RichTextBlockExtension as R, ItemExpressionDefinition as Rt, RawSurveyAsset as S, NumberResponse as Sn, serializeTemplateValue as St, JsonSurveyTranslations as T, ResponseValue as Tn, JsonSurveyItemPrefill as Tt, RichTextHeadingBlock as U, getItemExpressionDefinition as Ut, RichTextContent as V, ItemExpressionParameterOption as Vt, RichTextImageBlock as W, ItemCoreConstructor as Wt, RichTextInlineNode as X, ContextVariableExpression as Xt, RichTextInlineExtension as Y, ConstExpression as Yt, RichTextLineBreakInline as Z, ContextVariableType as Zt, createItemTypeDefinitionRegistry as _, DurationResponse as _n, TemplateValueBase as _t, GroupItemCore as a, JsonExpression as an, RichTextTextInline as at, CURRENT_SURVEY_SCHEMA as b, NumberArrayResponse as bn, deserializeTemplateValue as bt, builtInItemCoreRegistry as c, ResponseVariableExpression as cn, createRichTextContent as ct, ItemTypeDefinition as d, ValueReference as dn, getPlainTextFromRichTextContent as dt, ExpressionType as en, RichTextListItemBlock as et, ItemTypeDefinitionRegistry as f, ValueReferenceMethod as fn, hasRenderableRichTextBlock as ft, createItemCore as g, DurationArrayResponse as gn, TemplateDefTypes as gt, createFullRegistry as h, DateResponse as hn, JsonTemplateValue as ht, GroupConfig as i, JsonContextVariableExpression as in, RichTextTemplateInline as it, validateLocale as j, assertResponseValue as jn, SurveyItemPrefillTarget as jt, SurveyItemTranslations as k, ValueRefTypeLookup as kn, SurveyItemPrefillApplyMode as kt, isBuiltInItemType as l, ReferenceUsage as ln, getAssetUsagesFromContent as lt, ItemTypeRegistry as m, DateArrayResponse as mn, isContentEmpty as mt, SurveyAssetUsage as n, FunctionExpressionNames as nn, RichTextSeparatorBlock as nt, PageBreakConfig as o, JsonFunctionExpression as on, SurveyContentImageSource as ot, ItemTypeName as p, BooleanResponse as pn, hasRenderableRichTextContent as pt, RichTextInfoBoxBlock as q, ReservedSurveyItemTypes as qt, BuiltInItemType as r, JsonConstExpression as rn, RichTextStyle as rt, PageBreakItemCore as s, JsonResponseVariableExpression as sn, TextAlignment as st, Survey as t, FunctionExpression as tn, RichTextParagraphBlock as tt, ItemTypeCapabilities as u, ReferenceUsageType as un, getContentPlainText as ut, toItemTypeDefinitionRegistry as v, DurationUnit as vn, TemplateValueDefinition as vt, JsonComponentContent as w, ReferenceResponse as wn, ResponseSlotDefinition as wt, RawSurvey as x, NumberPrecision as xn, deserializeTemplateValues as xt, SurveyItemKey as y, DurationUnits as yn, TemplateValueFormatDate as yt, RichTextBlockNode as z, ItemExpressionParameterDefinition as zt };
|
|
990
|
-
//# sourceMappingURL=survey-
|
|
995
|
+
//# sourceMappingURL=survey-CwWxsuRb.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-DZ3RHkd2.d.mts","names":[],"sources":["../src/survey/responses/value-types.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/survey/items/survey-item-json.ts","../src/survey/items/types.ts","../src/survey/items/utils.ts","../src/survey/items/survey-item.ts","../src/expressions/item-expression-registry.ts","../src/survey/items/prefill.ts","../src/survey/responses/slot-definition.ts","../src/expressions/template-value.ts","../src/survey/utils/content.ts","../src/survey/utils/translations.ts","../src/survey/survey-file-schema.ts","../src/survey/item-key.ts","../src/survey/registry/item-registry.ts","../src/survey/registry/built-in-items.ts","../src/survey/survey.ts"],"mappings":";cAAa,SAAA;EAAA;;;;;;;;;;;;KAcD,SAAA,WAAoB,SAAA,eAAwB,SAAA;AAAA,cAE3C,aAAA;EAAA;;;;;;;;KAUD,YAAA,WAAuB,aAAA,eAA4B,aAAA;AAAA,cAElD,eAAA;EAAA,SAGH,GAAA;EAAA,SAAA,KAAA;AAAA;AAAA,KAEE,eAAA,WAA0B,eAAA,eAA8B,eAAA;AAAA,UAEnD,gBAAA,oBAAoC,SAAA;EACnD,IAAA,EAAM,UAAA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;EAAA,IA2BT,SAAA,CAAA;EAAA,IAQA,OAAA,CAAA;EAAA,IAIA,QAAA,CAAA,GAAY,aAAA;EAAA,IAOZ,QAAA,CAAA,GAAY,KAAA;IAAQ,MAAA;IAAgB,GAAA;IAAa,OAAA;IAAmB,IAAA;EAAA;EAcxE,WAAA,CAAY,MAAA;EAkBZ,UAAA,CAAW,MAAA,WAAiB,aAAA;EAU5B,aAAA,CAAc,MAAA,WAAiB,aAAA;EAiB/B,gBAAA,CAAiB,QAAA,WAAmB,cAAA;EAYpC,WAAA,CAAY,MAAA,WAAiB,cAAA;EAAA,IAazB,YAAA,CAAA,GAAgB,kBAAA;EAOpB,mBAAA,CAAoB,EAAA,WAAa,sBAAA;EASjC,gBAAA,CAAiB,gBAAA,WAA2B,uBAAA;EAI5C,gBAAA,CAAiB,gBAAA,UAA0B,aAAA,EAAe,uBAAA;EAO1D,mBAAA,CAAoB,gBAAA;EAIpB,oBAAA,CAAA;EAIA,QAAA,CAAS,OAAA,WAAkB,cAAA;EAK3B,QAAA,CAAS,OAAA,UAAiB,KAAA,EAAO,cAAA;EAQjC,WAAA,CAAY,OAAA;EAIZ,QAAA,CAAS,OAAA;EAIT,WAAA,CAAA;EAIA,SAAA,CAAA,GAAa,GAAA,SAAY,cAAA;EASzB,cAAA,CAAe,aAAA,YAAyB,gBAAA;EA+DxC,8BAAA,CAA+B,MAAA,GAAS,SAAA,GAAY,kBAAA;EAQpD,0BAAA,CAAA,GAA8B,KAAA;IAAQ,MAAA;IAAgB,KAAA,EAAO,sBAAA;EAAA;EjBnVrB;;;;;EiB+VxC,kBAAA,CAAmB,SAAA,YAAqB,cAAA;EAyBxC,cAAA,CAAe,QAAA,UAAkB,UAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"survey-CwWxsuRb.d.mts","names":[],"sources":["../src/survey/responses/value-types.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/survey/items/survey-item-json.ts","../src/survey/items/types.ts","../src/survey/items/utils.ts","../src/survey/items/survey-item.ts","../src/expressions/item-expression-registry.ts","../src/survey/items/prefill.ts","../src/survey/responses/slot-definition.ts","../src/expressions/template-value.ts","../src/survey/utils/content.ts","../src/survey/utils/translations.ts","../src/survey/survey-file-schema.ts","../src/survey/item-key.ts","../src/survey/registry/item-registry.ts","../src/survey/registry/built-in-items.ts","../src/survey/survey.ts"],"mappings":";cAAa,SAAA;EAAA;;;;;;;;;;;;KAcD,SAAA,WAAoB,SAAA,eAAwB,SAAA;AAAA,cAE3C,aAAA;EAAA;;;;;;;;KAUD,YAAA,WAAuB,aAAA,eAA4B,aAAA;AAAA,cAElD,eAAA;EAAA,SAGH,GAAA;EAAA,SAAA,KAAA;AAAA;AAAA,KAEE,eAAA,WAA0B,eAAA,eAA8B,eAAA;AAAA,UAEnD,gBAAA,oBAAoC,SAAA;EACnD,IAAA,EAAM,UAAA;AAAA;AAAA,UAGS,cAAA,SAAuB,gBAAA,QAAwB,SAAA,CAAU,MAAA;EACxE,KAAA;AAAA;AAAA,UAGe,gBAAA,SAAyB,gBAAA,QAAwB,SAAA,CAAU,QAAA;EAC1E,KAAA;EACA,IAAA,EAAM,YAAA;EACN,SAAA,GAAY,eAAA;AAAA;AAAA,UAGG,cAAA,SAAuB,gBAAA,QAAwB,SAAA,CAAU,MAAA;EACxE,KAAA;EACA,SAAA,GAAY,eAAA;AAAA;AAAA,UAGG,eAAA,SAAwB,gBAAA,QAAwB,SAAA,CAAU,OAAA;EACzE,KAAA;AAAA;AAAA,UAGe,iBAAA,SAA0B,gBAAA,QAAwB,SAAA,CAAU,SAAA;EAC3E,KAAA;AAAA;AAAA,UAGe,YAAA,SAAqB,gBAAA,QAAwB,SAAA,CAAU,IAAA;EACtE,KAAA;AAAA;AAAA,UAGe,mBAAA,SAA4B,gBAAA,QAAwB,SAAA,CAAU,WAAA;EAC7E,KAAA;AAAA;AAAA,UAGe,qBAAA,SAA8B,gBAAA,QAAwB,SAAA,CAAU,aAAA;EAC/E,KAAA;EACA,IA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AiB,KAAA,EAAO,cAAA;EAQjC,WAAA,CAAY,OAAA;EAIZ,QAAA,CAAS,OAAA;EAIT,WAAA,CAAA;EAIA,SAAA,CAAA,GAAa,GAAA,SAAY,cAAA;EASzB,cAAA,CAAe,aAAA,YAAyB,gBAAA;EA+DxC,8BAAA,CAA+B,MAAA,GAAS,SAAA,GAAY,kBAAA;EAQpD,0BAAA,CAAA,GAA8B,KAAA;IAAQ,MAAA;IAAgB,KAAA,EAAO,sBAAA;EAAA;EjBnVrB;;;;;EiB+VxC,kBAAA,CAAmB,SAAA,YAAqB,cAAA;EAyBxC,cAAA,CAAe,QAAA,UAAkB,UAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"survey-Dxt6iolo.mjs","names":[],"sources":["../src/utils.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/expressions/template-value.ts","../src/survey/responses/value-types.ts","../src/survey/items/utils.ts","../src/survey/items/prefill.ts","../src/survey/items/survey-item.ts","../src/survey/items/types.ts","../src/survey/item-key.ts","../src/survey/utils/group-utils.ts","../src/survey/registry/built-in-items.ts","../src/survey/registry/item-registry.ts","../src/survey/survey-file-schema.ts","../src/survey/utils/translations.ts","../src/survey/utils/content.ts","../src/survey/survey.ts"],"sourcesContent":["function hashString(seed: string): number {\n let hash = 2166136261;\n\n for (let i = 0; i < seed.length; i++) {\n hash ^= seed.charCodeAt(i);\n hash = Math.imul(hash, 16777619);\n }\n\n return hash >>> 0;\n}\n\nexport function createSeededRandom(seed: string): () => number {\n let state = hashString(seed);\n\n return () => {\n state = (state + 0x6d2b79f5) >>> 0;\n let next = state;\n next = Math.imul(next ^ (next >>> 15), next | 1);\n next ^= next + Math.imul(next ^ (next >>> 7), next | 61);\n return ((next ^ (next >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport function shuffleArray<T>(values: readonly T[], random: () => number = Math.random): T[] {\n const shuffledValues = [...values];\n\n for (let i = shuffledValues.length - 1; i > 0; i--) {\n const j = Math.floor(random() * (i + 1));\n [shuffledValues[i], shuffledValues[j]] = [shuffledValues[j], shuffledValues[i]];\n }\n\n return shuffledValues;\n}\n\n/**\n * Shuffles an array of indices using the Fisher-Yates shuffle algorithm\n * @param length - The length of the array to create indices for\n * @returns A shuffled array of indices from 0 to length-1\n */\nexport function shuffleIndices(length: number, random: () => number = Math.random): number[] {\n return shuffleArray(\n Array.from({ length }, (_, i) => i),\n random,\n );\n}\n\nexport function structuredCloneMethod<T>(obj: T): T {\n if (typeof structuredClone !== \"undefined\") {\n return structuredClone(obj);\n }\n // Fallback to JSON method\n return JSON.parse(JSON.stringify(obj));\n}\n\nconst ALPHABET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n\nexport function generateId(): string {\n const length = 10;\n const timestamp = Date.now();\n let encodedTimestamp = \"\";\n let t = timestamp;\n const base = ALPHABET.length;\n\n while (t > 0) {\n encodedTimestamp = ALPHABET.charAt(t % base) + encodedTimestamp;\n t = Math.floor(t / base);\n }\n\n let randomPart = \"\";\n for (let i = 0; i < length; i++) {\n randomPart += ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return randomPart + encodedTimestamp;\n}\n\n/** Alphanumeric chars without ambiguous ones (0/O, 1/I) for human-readable coding keys. */\nconst CODING_KEY_ALPHABET = \"23456789ABCDEFGHJKLMNPQRSTUVWXYZ\";\n\n/**\n * Generates a short random coding key suitable for item keys in exports/codebooks.\n * @param length - Key length (default 4)\n * @returns A random string of the specified length.\n */\nexport function generateCodingKey(length: number = 4): string {\n const base = CODING_KEY_ALPHABET.length;\n let key = \"\";\n for (let i = 0; i < length; i++) {\n key += CODING_KEY_ALPHABET.charAt(Math.floor(Math.random() * base));\n }\n return key;\n}\n","const SEPARATOR = \"...\";\n\nexport enum ValueReferenceMethod {\n get = \"get\",\n isDefined = \"isDefined\",\n}\n\nexport class ValueReference {\n _itemId: string;\n _name: ValueReferenceMethod;\n _slotId: string;\n\n constructor(str: string) {\n const parts = str.split(SEPARATOR);\n if (parts.length !== 3) {\n throw new Error(\"Invalid value reference: \" + str);\n }\n this._itemId = parts[0];\n this._name = parts[1] as ValueReferenceMethod;\n this._slotId = parts[2];\n }\n\n get itemId(): string {\n return this._itemId;\n }\n\n get name(): ValueReferenceMethod {\n return this._name;\n }\n\n get slotId(): string {\n return this._slotId;\n }\n\n set itemId(itemId: string) {\n this._itemId = itemId;\n }\n\n toString(): string {\n return `${this._itemId}${SEPARATOR}${this._name}${this._slotId ? SEPARATOR + this._slotId : \"\"}`;\n }\n\n static fromParts(itemId: string, name: ValueReferenceMethod, slotId: string): ValueReference {\n return new ValueReference(`${itemId}${SEPARATOR}${name}${SEPARATOR}${slotId}`);\n }\n}\n\nexport enum ReferenceUsageType {\n displayConditions = \"displayConditions\",\n templateValues = \"templateValues\",\n validations = \"validations\",\n disabledConditions = \"disabledConditions\",\n prefills = \"prefills\",\n}\n\nexport interface ReferenceUsage {\n itemId: string;\n fullComponentKey?: string;\n usageType?: ReferenceUsageType;\n valueReference: ValueReference;\n}\n","import { ResponseValue, ValueType } from \"../survey/responses\";\nimport { ValueReference } from \"../survey/utils/value-reference\";\n\nexport const ExpressionType = {\n Const: \"const\",\n ResponseVariable: \"responseVariable\",\n ContextVariable: \"contextVariable\",\n Function: \"function\",\n} as const;\n\nexport type ExpressionType = (typeof ExpressionType)[keyof typeof ExpressionType];\n\nexport const ContextVariableType = {\n Locale: \"locale\",\n ParticipantFlag: \"participantFlag\",\n CustomValue: \"customValue\",\n CustomExpression: \"customExpression\",\n} as const;\n\nexport type ContextVariableType = (typeof ContextVariableType)[keyof typeof ContextVariableType];\n\nexport interface ExpressionEditorConfig {\n usedTemplate?: string;\n label?: string;\n description?: string;\n}\n\nexport interface JsonConstExpression {\n type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonResponseVariableExpression {\n type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonContextVariableExpression {\n type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: JsonExpression;\n arguments?: Array<JsonExpression | undefined>;\n asType?: ValueType;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport interface JsonFunctionExpression {\n type: typeof ExpressionType.Function;\n functionName: string;\n arguments: Array<JsonExpression | undefined>;\n\n editorConfig?: ExpressionEditorConfig;\n}\n\nexport type JsonExpression =\n | JsonConstExpression\n | JsonResponseVariableExpression\n | JsonContextVariableExpression\n | JsonFunctionExpression;\n\n/**\n * Base class for all expressions.\n */\nexport abstract class Expression {\n type: ExpressionType;\n editorConfig?: ExpressionEditorConfig;\n\n constructor(type: ExpressionType, editorConfig?: ExpressionEditorConfig) {\n this.type = type;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression | undefined): Expression | undefined {\n if (!json) {\n return undefined;\n }\n\n switch (json.type) {\n case ExpressionType.Const:\n return ConstExpression.deserialize(json);\n case ExpressionType.ResponseVariable:\n return ResponseVariableExpression.deserialize(json);\n case ExpressionType.ContextVariable:\n return ContextVariableExpression.deserialize(json);\n case ExpressionType.Function:\n return FunctionExpression.deserialize(json);\n }\n }\n\n /**\n * Returns all unique response variable references in the expression.\n * @returns A list of ValueReference objects.\n */\n abstract get responseVariableRefs(): ValueReference[];\n abstract serialize(): JsonExpression | undefined;\n\n clone(): Expression {\n return (\n Expression.deserialize(this.serialize()) ??\n (() => {\n throw new Error(\"Failed to clone expression\");\n })()\n );\n }\n}\n\nexport class ConstExpression extends Expression {\n declare type: typeof ExpressionType.Const;\n value?: ResponseValue;\n\n constructor(value?: ResponseValue, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.Const, editorConfig);\n this.value = value;\n this.type = ExpressionType.Const;\n }\n\n static deserialize(json: JsonExpression): ConstExpression {\n if (json.type !== ExpressionType.Const) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n return new ConstExpression(json.value, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [];\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n value: this.value,\n editorConfig: this.editorConfig,\n };\n }\n\n updateItemKeyReferences(_oldItemKey: string, _newItemKey: string): boolean {\n // Const expressions don't have item references\n return false;\n }\n}\n\nexport class ResponseVariableExpression extends Expression {\n declare type: typeof ExpressionType.ResponseVariable;\n variableRef: string;\n\n constructor(variableRef: string, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ResponseVariable, editorConfig);\n this.variableRef = variableRef;\n this.type = ExpressionType.ResponseVariable;\n }\n\n static deserialize(json: JsonExpression): ResponseVariableExpression {\n if (json.type !== ExpressionType.ResponseVariable) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n return new ResponseVariableExpression(json.variableRef, json.editorConfig);\n }\n\n get responseVariableRefs(): ValueReference[] {\n return [new ValueReference(this.variableRef)];\n }\n\n get responseVariableRef(): ValueReference {\n return new ValueReference(this.variableRef);\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n variableRef: this.variableRef,\n editorConfig: this.editorConfig,\n };\n }\n}\n\nexport class ContextVariableExpression extends Expression {\n declare type: typeof ExpressionType.ContextVariable;\n\n contextType: ContextVariableType;\n key?: Expression;\n arguments?: Array<Expression | undefined>;\n asType?: ValueType;\n\n constructor(\n contextType: ContextVariableType,\n key?: Expression,\n args?: Array<Expression | undefined>,\n asType?: ValueType,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super(ExpressionType.ContextVariable, editorConfig);\n this.type = ExpressionType.ContextVariable;\n this.contextType = contextType;\n this.key = key;\n this.arguments = args;\n this.asType = asType;\n }\n\n static deserialize(json: JsonExpression): ContextVariableExpression {\n if (json.type !== ExpressionType.ContextVariable) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n return new ContextVariableExpression(\n json.contextType,\n Expression.deserialize(json.key),\n json.arguments?.map((arg) => Expression.deserialize(arg)),\n json.asType,\n json.editorConfig,\n );\n }\n\n get responseVariableRefs(): ValueReference[] {\n return (\n this.arguments\n ?.flatMap((arg) => arg?.responseVariableRefs)\n .filter((ref) => ref !== undefined) ?? []\n );\n }\n\n serialize(): JsonExpression {\n return {\n type: this.type,\n contextType: this.contextType,\n key: this.key?.serialize(),\n arguments: this.arguments?.map((arg) => arg?.serialize()),\n asType: this.asType,\n editorConfig: this.editorConfig,\n };\n }\n}\n\nexport enum FunctionExpressionNames {\n and = \"and\",\n or = \"or\",\n not = \"not\",\n\n list_contains = \"list_contains\",\n\n // numeric functions\n eq = \"eq\",\n gt = \"gt\",\n gte = \"gte\",\n lt = \"lt\",\n lte = \"lte\",\n in_range = \"in_range\",\n\n sum = \"sum\",\n min = \"min\",\n max = \"max\",\n\n // string functions\n str_eq = \"str_eq\",\n\n // date functions\n date_eq = \"date_eq\",\n}\n\nexport class FunctionExpression extends Expression {\n declare type: typeof ExpressionType.Function;\n functionName: FunctionExpressionNames;\n arguments: Array<Expression | undefined>;\n\n constructor(\n functionName: FunctionExpressionNames,\n args: Array<Expression | undefined>,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super(ExpressionType.Function);\n this.type = ExpressionType.Function;\n this.functionName = functionName;\n this.arguments = args;\n this.editorConfig = editorConfig;\n }\n\n static deserialize(json: JsonExpression): FunctionExpression {\n if (json.type !== ExpressionType.Function) {\n throw new Error(\"Invalid expression type: \" + json.type);\n }\n\n const functionName = json.functionName as FunctionExpressionNames;\n if (!Object.values(FunctionExpressionNames).includes(functionName)) {\n throw new Error(\"Invalid function name: \" + functionName);\n }\n\n const expr = new FunctionExpression(\n functionName,\n json.arguments.map((arg) => Expression.deserialize(arg)),\n );\n expr.editorConfig = json.editorConfig;\n return expr;\n }\n\n get responseVariableRefs(): ValueReference[] {\n const refs = this.arguments\n .flatMap((arg) => arg?.responseVariableRefs)\n .filter((ref) => ref !== undefined);\n const refStrings = refs.map((ref) => ref.toString());\n return [...new Set(refStrings)].map((ref) => new ValueReference(ref));\n }\n\n serialize(): JsonExpression | undefined {\n return {\n type: this.type,\n functionName: this.functionName,\n arguments: this.arguments.map((arg) => arg?.serialize()),\n editorConfig: this.editorConfig,\n };\n }\n}\n","import { ValueType } from \"../survey/responses\";\nimport { Expression, JsonExpression } from \"./expression\";\n\nexport enum TemplateDefTypes {\n Default = \"default\",\n Date2String = \"date2string\",\n}\n\nexport type TemplateValueBase = {\n type: TemplateDefTypes;\n returnType: ValueType;\n expression?: Expression;\n};\n\nexport type TemplateValueFormatDate = TemplateValueBase & {\n type: TemplateDefTypes.Date2String;\n returnType: typeof ValueType.string;\n dateFormat: string;\n};\n\nexport type TemplateValueDefinition = TemplateValueBase | TemplateValueFormatDate;\n\nexport const serializeTemplateValue = (\n templateValue: TemplateValueDefinition,\n): JsonTemplateValue => {\n const json: JsonTemplateValue = {\n type: templateValue.type,\n returnType: templateValue.returnType,\n expression: templateValue.expression?.serialize(),\n };\n if (templateValue.type === TemplateDefTypes.Date2String) {\n json.dateFormat = (templateValue as TemplateValueFormatDate).dateFormat;\n }\n return json;\n};\n\nexport const serializeTemplateValues = (\n templateValues: Map<string, TemplateValueDefinition>,\n): { [templateValueKey: string]: JsonTemplateValue } => {\n const json: { [templateValueKey: string]: JsonTemplateValue } = {};\n for (const [key, value] of templateValues.entries()) {\n json[key] = serializeTemplateValue(value);\n }\n return json;\n};\n\nexport const deserializeTemplateValue = (json: JsonTemplateValue): TemplateValueDefinition => {\n return {\n type: json.type,\n expression: json.expression ? Expression.deserialize(json.expression) : undefined,\n returnType: json.returnType,\n dateFormat: json.dateFormat,\n };\n};\n\nexport const deserializeTemplateValues = (json: {\n [templateValueKey: string]: JsonTemplateValue;\n}): Map<string, TemplateValueDefinition> => {\n return new Map(\n Object.entries(json).map(([key, value]) => [key, deserializeTemplateValue(value)]),\n );\n};\n\nexport interface JsonTemplateValue {\n type: TemplateDefTypes;\n expression?: JsonExpression;\n returnType: ValueType;\n dateFormat?: string;\n}\n","export const ValueType = {\n string: \"string\",\n duration: \"duration\",\n reference: \"reference\",\n number: \"number\",\n boolean: \"boolean\",\n date: \"date\",\n stringArray: \"string[]\",\n durationArray: \"duration[]\",\n referenceArray: \"reference[]\",\n numberArray: \"number[]\",\n dateArray: \"date[]\",\n} as const;\n\nexport type ValueType = (typeof ValueType)[keyof typeof ValueType];\n\nexport const DurationUnits = {\n seconds: \"seconds\",\n minutes: \"minutes\",\n hours: \"hours\",\n days: \"days\",\n weeks: \"weeks\",\n months: \"months\",\n years: \"years\",\n} as const;\n\nexport type DurationUnit = (typeof DurationUnits)[keyof typeof DurationUnits];\n\nexport const NumberPrecision = {\n int: \"int\",\n float: \"float\",\n} as const;\n\nexport type NumberPrecision = (typeof NumberPrecision)[keyof typeof NumberPrecision];\n\nexport interface SlotResponseBase<TValueType extends ValueType> {\n type: TValueType;\n}\n\nexport interface StringResponse extends SlotResponseBase<typeof ValueType.string> {\n value: string;\n}\n\nexport interface DurationResponse extends SlotResponseBase<typeof ValueType.duration> {\n value: number;\n unit: DurationUnit;\n precision?: NumberPrecision;\n}\n\nexport interface NumberResponse extends SlotResponseBase<typeof ValueType.number> {\n value: number;\n precision?: NumberPrecision;\n}\n\nexport interface BooleanResponse extends SlotResponseBase<typeof ValueType.boolean> {\n value: boolean;\n}\n\nexport interface ReferenceResponse extends SlotResponseBase<typeof ValueType.reference> {\n value: string;\n}\n\nexport interface DateResponse extends SlotResponseBase<typeof ValueType.date> {\n value: number;\n}\n\nexport interface StringArrayResponse extends SlotResponseBase<typeof ValueType.stringArray> {\n value: string[];\n}\n\nexport interface DurationArrayResponse extends SlotResponseBase<typeof ValueType.durationArray> {\n value: number[];\n unit: DurationUnit;\n precision?: NumberPrecision;\n}\n\nexport interface NumberArrayResponse extends SlotResponseBase<typeof ValueType.numberArray> {\n value: number[];\n precision?: NumberPrecision;\n}\n\nexport interface DateArrayResponse extends SlotResponseBase<typeof ValueType.dateArray> {\n value: number[];\n}\n\nexport interface ReferenceArrayResponse extends SlotResponseBase<typeof ValueType.referenceArray> {\n value: string[];\n}\n\nexport type ResponseValue =\n | StringResponse\n | DurationResponse\n | ReferenceResponse\n | NumberResponse\n | BooleanResponse\n | DateResponse\n | StringArrayResponse\n | DurationArrayResponse\n | NumberArrayResponse\n | DateArrayResponse\n | ReferenceArrayResponse;\n\nexport type ValueRefTypeLookup = {\n [valueRefString: string]: ValueType;\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\nfunction isNumberArray(value: unknown): value is number[] {\n return Array.isArray(value) && value.every((item) => isFiniteNumber(item));\n}\n\nfunction isOptionalNumberPrecision(value: unknown): value is NumberPrecision | undefined {\n return value === undefined || value === NumberPrecision.int || value === NumberPrecision.float;\n}\n\nfunction isDurationUnit(value: unknown): value is DurationUnit {\n return typeof value === \"string\" && Object.values(DurationUnits).includes(value as DurationUnit);\n}\n\nexport function isResponseValue(value: unknown): value is ResponseValue {\n if (!isPlainObject(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case ValueType.string:\n case ValueType.reference:\n return typeof value.value === \"string\";\n case ValueType.number:\n return isFiniteNumber(value.value) && isOptionalNumberPrecision(value.precision);\n case ValueType.boolean:\n return typeof value.value === \"boolean\";\n case ValueType.date:\n return isFiniteNumber(value.value);\n case ValueType.duration:\n return (\n isFiniteNumber(value.value) &&\n isDurationUnit(value.unit) &&\n isOptionalNumberPrecision(value.precision)\n );\n case ValueType.stringArray:\n case ValueType.referenceArray:\n return isStringArray(value.value);\n case ValueType.numberArray:\n case ValueType.dateArray:\n return (\n isNumberArray(value.value) &&\n (value.type !== ValueType.numberArray || isOptionalNumberPrecision(value.precision))\n );\n case ValueType.durationArray:\n return (\n isNumberArray(value.value) &&\n isDurationUnit(value.unit) &&\n isOptionalNumberPrecision(value.precision)\n );\n default:\n return false;\n }\n}\n\nexport function assertResponseValue(value: unknown, path: string): asserts value is ResponseValue {\n if (!isResponseValue(value)) {\n throw new Error(`Invalid response value at '${path}'`);\n }\n}\n","import { Expression, JsonExpression } from \"../../expressions\";\n\nexport interface DisplayConditions {\n root?: Expression;\n components?: {\n [componentKey: string]: Expression | undefined;\n };\n}\n\nexport interface JsonDisplayConditions {\n root?: JsonExpression;\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n };\n}\n\nexport interface JsonDisabledConditions {\n components?: {\n [componentKey: string]: JsonExpression | undefined;\n };\n}\n\nexport interface DisabledConditions {\n components?: {\n [componentKey: string]: Expression | undefined;\n };\n}\n\nexport const displayConditionsFromJson = (json: JsonDisplayConditions): DisplayConditions => {\n return {\n root: json.root ? Expression.deserialize(json.root) : undefined,\n components: json.components\n ? Object.fromEntries(\n Object.entries(json.components).map(([key, value]) => [\n key,\n Expression.deserialize(value),\n ]),\n )\n : undefined,\n };\n};\n\nexport const displayConditionsToJson = (\n displayConditions: DisplayConditions,\n): JsonDisplayConditions => {\n return {\n root: displayConditions.root ? displayConditions.root.serialize() : undefined,\n components: displayConditions.components\n ? Object.fromEntries(\n Object.entries(displayConditions.components).map(([key, value]) => [\n key,\n value?.serialize(),\n ]),\n )\n : undefined,\n };\n};\n\nexport const disabledConditionsFromJson = (json: JsonDisabledConditions): DisabledConditions => {\n return {\n components: json.components\n ? Object.fromEntries(\n Object.entries(json.components).map(([key, value]) => [\n key,\n Expression.deserialize(value),\n ]),\n )\n : undefined,\n };\n};\n\nexport const disabledConditionsToJson = (\n disabledConditions: DisabledConditions,\n): JsonDisabledConditions => {\n return {\n components: disabledConditions.components\n ? Object.fromEntries(\n Object.entries(disabledConditions.components).map(([key, value]) => [\n key,\n value?.serialize(),\n ]),\n )\n : undefined,\n };\n};\n","import { Expression, type JsonExpression } from \"../../expressions\";\nimport type { ResponseValue } from \"../responses\";\n\nexport const SurveyItemPrefillApplyMode = {\n ifEmpty: \"ifEmpty\",\n} as const;\n\nexport type SurveyItemPrefillApplyMode =\n (typeof SurveyItemPrefillApplyMode)[keyof typeof SurveyItemPrefillApplyMode];\n\nexport const SurveyItemPrefillTargetType = {\n itemResponse: \"itemResponse\",\n field: \"field\",\n embeddedField: \"embeddedField\",\n} as const;\n\nexport type SurveyItemPrefillTargetType =\n (typeof SurveyItemPrefillTargetType)[keyof typeof SurveyItemPrefillTargetType];\n\nexport type JsonSurveyItemPrefillTarget =\n | {\n type: typeof SurveyItemPrefillTargetType.itemResponse;\n }\n | {\n type: typeof SurveyItemPrefillTargetType.field;\n fieldId: string;\n }\n | {\n type: typeof SurveyItemPrefillTargetType.embeddedField;\n optionId: string;\n fieldId: string;\n };\n\nexport type SurveyItemPrefillTarget = JsonSurveyItemPrefillTarget;\n\nexport interface SurveyItemPreviousResponseRef {\n surveyKey?: string;\n itemId: string;\n target?: SurveyItemPrefillTarget;\n}\n\nexport type JsonSurveyItemPrefillSource =\n | {\n type: \"static\";\n value: ResponseValue;\n }\n | {\n type: \"expression\";\n expression: JsonExpression;\n }\n | {\n type: \"templateValue\";\n key: string;\n }\n | {\n type: \"previousResponse\";\n ref: SurveyItemPreviousResponseRef;\n ifUnsupported?: \"skip\";\n };\n\nexport type SurveyItemPrefillSource =\n | {\n type: \"static\";\n value: ResponseValue;\n }\n | {\n type: \"expression\";\n expression: Expression;\n }\n | {\n type: \"templateValue\";\n key: string;\n }\n | {\n type: \"previousResponse\";\n ref: SurveyItemPreviousResponseRef;\n ifUnsupported?: \"skip\";\n };\n\nexport interface JsonSurveyItemPrefill {\n id: string;\n target: JsonSurveyItemPrefillTarget;\n when?: JsonExpression;\n apply?: SurveyItemPrefillApplyMode;\n source: JsonSurveyItemPrefillSource;\n}\n\nexport interface SurveyItemPrefill {\n id: string;\n target: SurveyItemPrefillTarget;\n when?: Expression;\n apply?: SurveyItemPrefillApplyMode;\n source: SurveyItemPrefillSource;\n}\n\nexport function deserializeSurveyItemPrefill(json: JsonSurveyItemPrefill): SurveyItemPrefill {\n switch (json.source.type) {\n case \"static\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"static\",\n value: json.source.value,\n },\n };\n case \"expression\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"expression\",\n expression:\n Expression.deserialize(json.source.expression) ??\n (() => {\n throw new Error(`Prefill '${json.id}' is missing a valid expression source`);\n })(),\n },\n };\n case \"templateValue\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"templateValue\",\n key: json.source.key,\n },\n };\n case \"previousResponse\":\n return {\n id: json.id,\n target: json.target,\n when: Expression.deserialize(json.when),\n apply: json.apply,\n source: {\n type: \"previousResponse\",\n ref: json.source.ref,\n ifUnsupported: json.source.ifUnsupported,\n },\n };\n default:\n throw new Error(\n `Unsupported prefill source type: ${(json.source as { type?: string }).type}`,\n );\n }\n}\n\nexport function serializeSurveyItemPrefill(prefill: SurveyItemPrefill): JsonSurveyItemPrefill {\n switch (prefill.source.type) {\n case \"static\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"static\",\n value: prefill.source.value,\n },\n };\n case \"expression\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"expression\",\n expression:\n prefill.source.expression.serialize() ??\n (() => {\n throw new Error(\n `Prefill '${prefill.id}' cannot serialize an empty expression source`,\n );\n })(),\n },\n };\n case \"templateValue\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"templateValue\",\n key: prefill.source.key,\n },\n };\n case \"previousResponse\":\n return {\n id: prefill.id,\n target: prefill.target,\n when: prefill.when?.serialize(),\n apply: prefill.apply,\n source: {\n type: \"previousResponse\",\n ref: prefill.source.ref,\n ifUnsupported: prefill.source.ifUnsupported,\n },\n };\n default:\n throw new Error(\n `Unsupported prefill source type: ${(prefill.source as { type?: string }).type}`,\n );\n }\n}\n\nexport function prefillTargetsEqual(\n left: SurveyItemPrefillTarget,\n right: SurveyItemPrefillTarget,\n): boolean {\n if (left.type !== right.type) {\n return false;\n }\n\n switch (left.type) {\n case SurveyItemPrefillTargetType.itemResponse:\n return true;\n case SurveyItemPrefillTargetType.field:\n return (\n left.fieldId === (right as Extract<SurveyItemPrefillTarget, { type: \"field\" }>).fieldId\n );\n case SurveyItemPrefillTargetType.embeddedField:\n return (\n left.optionId ===\n (right as Extract<SurveyItemPrefillTarget, { type: \"embeddedField\" }>).optionId &&\n left.fieldId ===\n (right as Extract<SurveyItemPrefillTarget, { type: \"embeddedField\" }>).fieldId\n );\n default:\n return false;\n }\n}\n","import { Expression } from \"../../expressions\";\nimport { RawSurveyItem } from \"../items\";\nimport { ResponseSlotDefinition } from \"../responses/slot-definition\";\nimport { ResponseValue, ValueRefTypeLookup, ValueType } from \"../responses/value-types\";\nimport { ReferenceUsage, ReferenceUsageType, ValueReferenceMethod } from \"../utils/value-reference\";\nimport {\n DisabledConditions,\n disabledConditionsFromJson,\n DisplayConditions,\n displayConditionsFromJson,\n} from \"./utils\";\nimport {\n deserializeSurveyItemPrefill,\n prefillTargetsEqual,\n SurveyItemPrefill,\n SurveyItemPrefillTarget,\n SurveyItemPrefillTargetType,\n} from \"./prefill\";\n\n/**\n * Core contract for survey item handlers.\n * Every item type (built-in and plugin) is represented by a handler class implementing this interface.\n * The core uses these methods without any casting.\n */\nexport interface SurveyItemCoreType<TConfig = unknown> {\n readonly type: string;\n readonly id: string;\n readonly key: string;\n readonly config: TConfig;\n\n isInteractive(): boolean;\n getResponseSlotDefinitions(): ResponseSlotDefinition[];\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;\n}\n\n/**\n * Base class for survey item handlers.\n * Each handler holds type, id, key, and config (properly typed) and implements core methods.\n * Subclass for each item type; the core works with SurveyItemHandler only—no casting needed.\n */\nexport abstract class SurveyItemCore<\n TType extends string = string,\n TConfig = unknown,\n> implements SurveyItemCoreType<TConfig> {\n abstract readonly type: TType;\n readonly id: string;\n key: string;\n config: TConfig;\n\n private _rawItem: RawSurveyItem;\n\n displayConditions?: DisplayConditions;\n disabledConditions?: DisabledConditions;\n validations?: {\n [validationKey: string]: Expression | undefined;\n };\n prefills?: SurveyItemPrefill[];\n\n constructor(rawItem: RawSurveyItem) {\n this._rawItem = rawItem;\n this.updateExpressions();\n this.id = this._rawItem.id;\n this.key = this._rawItem.key;\n this.config = this.parseConfig(this._rawItem.config);\n }\n\n /** Parse raw config from JSON into typed config. Override in subclasses. */\n abstract parseConfig(rawConfig: unknown): TConfig;\n abstract isInteractive(): boolean;\n abstract getResponseSlotDefinitions(): ResponseSlotDefinition[];\n\n protected getAdditionalResponseValueSlots(): ValueRefTypeLookup {\n return {};\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n const valueRefs: ValueRefTypeLookup = {};\n\n for (const slot of this.getResponseSlotDefinitions()) {\n valueRefs[`${this.id}...${ValueReferenceMethod.get}...${slot.slotId}`] = slot.valueType;\n valueRefs[`${this.id}...${ValueReferenceMethod.isDefined}...${slot.slotId}`] =\n ValueType.boolean;\n }\n\n Object.assign(valueRefs, this.getAdditionalResponseValueSlots());\n\n if (!byType) {\n return valueRefs;\n }\n\n return Object.fromEntries(\n Object.entries(valueRefs).filter(([, valueType]) => valueType === byType),\n );\n }\n\n get rawItem(): RawSurveyItem {\n return this._rawItem;\n }\n\n get metadata(): { [key: string]: string } {\n return this._rawItem.metadata ?? {};\n }\n\n set metadata(metadata: { [key: string]: string }) {\n this.updateRawItem({\n ...this._rawItem,\n metadata: metadata,\n });\n }\n\n get editorMetadata(): NonNullable<RawSurveyItem[\"editorMetadata\"]> {\n return this._rawItem.editorMetadata ?? {};\n }\n\n setCreatedAt(timestamp: string): void {\n this.updateRawItem({\n ...this._rawItem,\n editorMetadata: {\n ...this._rawItem.editorMetadata,\n createdAt: timestamp,\n },\n });\n }\n\n setModifiedAt(timestamp: string): void {\n this.updateRawItem({\n ...this._rawItem,\n editorMetadata: {\n ...this._rawItem.editorMetadata,\n createdAt: this._rawItem.editorMetadata?.createdAt ?? timestamp,\n updatedAt: timestamp,\n },\n });\n }\n\n updateRawItem(rawItem: RawSurveyItem) {\n if (rawItem.id !== this.id) {\n throw new Error(\"Cannot update raw item with a different id\");\n }\n this._rawItem = rawItem;\n this.updateExpressions();\n this.key = rawItem.key;\n this.config = this.parseConfig(rawItem.config);\n }\n\n private updateExpressions() {\n this.displayConditions = this._rawItem.displayConditions\n ? displayConditionsFromJson(this._rawItem.displayConditions)\n : undefined;\n this.disabledConditions = this._rawItem.disabledConditions\n ? disabledConditionsFromJson(this._rawItem.disabledConditions)\n : undefined;\n this.validations = this._rawItem.validations\n ? Object.fromEntries(\n Object.entries(this._rawItem.validations).map(([key, value]) => [\n key,\n Expression.deserialize(value),\n ]),\n )\n : undefined;\n this.prefills = this._rawItem.prefills?.map((prefill) => deserializeSurveyItemPrefill(prefill));\n }\n\n getReferenceUsages(): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n\n if (this.displayConditions) {\n // root\n for (const ref of this.displayConditions.root?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n\n // components\n for (const [componentKey, expression] of Object.entries(\n this.displayConditions.components || {},\n )) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.displayConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.disabledConditions) {\n for (const [componentKey, expression] of Object.entries(\n this.disabledConditions.components || {},\n )) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: componentKey,\n usageType: ReferenceUsageType.disabledConditions,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.validations) {\n for (const [validationKey, expression] of Object.entries(this.validations)) {\n for (const ref of expression?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: validationKey,\n usageType: ReferenceUsageType.validations,\n valueReference: ref,\n });\n }\n }\n }\n\n if (this.prefills) {\n for (const prefill of this.prefills) {\n for (const ref of prefill.when?.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: prefill.id,\n usageType: ReferenceUsageType.prefills,\n valueReference: ref,\n });\n }\n\n if (prefill.source.type === \"expression\") {\n for (const ref of prefill.source.expression.responseVariableRefs || []) {\n usages.push({\n itemId: this.id,\n fullComponentKey: prefill.id,\n usageType: ReferenceUsageType.prefills,\n valueReference: ref,\n });\n }\n }\n }\n }\n\n return usages;\n }\n\n resolvePrefillTarget(target: SurveyItemPrefillTarget): ResponseSlotDefinition | undefined {\n const slotDefinitions = this.getResponseSlotDefinitions();\n const explicitMatch = slotDefinitions.find(\n (slot) => slot.prefillTarget !== undefined && prefillTargetsEqual(slot.prefillTarget, target),\n );\n if (explicitMatch) {\n return explicitMatch;\n }\n\n if (target.type === SurveyItemPrefillTargetType.itemResponse && slotDefinitions.length === 1) {\n return slotDefinitions[0];\n }\n\n return undefined;\n }\n\n normalizePrefillValue(\n _prefill: SurveyItemPrefill,\n targetSlot: ResponseSlotDefinition,\n value: ResponseValue,\n ): ResponseValue | undefined {\n return value.type === targetSlot.valueType ? value : undefined;\n }\n}\n\n/**\n * Constructor type for handler classes. Used by the registry to instantiate handlers.\n */\nexport type ItemCoreConstructor<TType extends string = string, TConfig = unknown> = new (\n rawItem: RawSurveyItem,\n) => SurveyItemCore<TType, TConfig>;\n","export enum ReservedSurveyItemTypes {\n Group = \"group\",\n PageBreak = \"page-break\",\n}\n","/**\n * SurveyItemKey stores the key of the item and the path to the item.\n */\n\nexport class SurveyItemKey {\n private _itemKey: string;\n private _path: Array<string>;\n private _keySeparator: string;\n\n constructor(itemKey: string, path: string[] | undefined, keySeparator: string = \".\") {\n this._itemKey = itemKey;\n this._path = path ?? [];\n this._keySeparator = keySeparator;\n }\n\n get itemKey(): string {\n return this._itemKey;\n }\n\n get path(): Array<string> {\n return this._path;\n }\n\n get parentFullKey(): string {\n return this._path.join(this._keySeparator);\n }\n\n get fullKey(): string {\n return [...this._path, this._itemKey].join(this._keySeparator);\n }\n\n get isRoot(): boolean {\n return this._path.length === 0;\n }\n\n get keySeparator(): string {\n return this._keySeparator;\n }\n\n set keySeparator(keySeparator: string) {\n this._keySeparator = keySeparator;\n }\n}\n","/**\n * Shared utilities for array operations.\n */\n\n/**\n * Swap two elements in an array by index.\n * @returns A new array with the elements swapped\n */\nexport function swapArrayElements<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n [result[fromIndex], result[toIndex]] = [result[toIndex], result[fromIndex]];\n return result;\n}\n\n/**\n * Move an element from one index to another.\n * @returns A new array with the element moved\n */\nexport function moveArrayElement<T>(arr: T[], fromIndex: number, toIndex: number): T[] {\n const result = [...arr];\n const [moved] = result.splice(fromIndex, 1);\n result.splice(toIndex, 0, moved);\n return result;\n}\n","import { ReservedSurveyItemTypes } from \"../items/types\";\nimport { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { moveArrayElement, swapArrayElements } from \"../utils/group-utils\";\n\n/**\n * Group item core.\n */\nexport type GroupConfig = {\n items?: string[];\n shuffleItems?: boolean;\n isRoot?: boolean;\n};\n\nexport class GroupItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.Group,\n GroupConfig\n> {\n readonly type = ReservedSurveyItemTypes.Group;\n\n parseConfig(rawConfig: unknown): GroupConfig {\n const cfg = (rawConfig ?? {}) as Partial<GroupConfig>;\n return {\n items: cfg.items,\n shuffleItems: cfg.shuffleItems,\n isRoot: cfg.isRoot,\n };\n }\n\n serializeConfig(): unknown {\n return this.config;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n\n isRoot(): boolean {\n return this.config.isRoot ?? false;\n }\n\n get items(): string[] {\n return this.config.items ?? [];\n }\n\n /**\n * Add a child item id to this group at the given index.\n * @param itemId The id of the item to add to this group.\n * @param index The index at which to add the item. If not provided, the item is added to the end of the group.\n */\n addChild(itemId: string, index?: number): void {\n const items = (this.config.items ??= []);\n const insertIndex = index !== undefined ? Math.min(index, items.length) : items.length;\n items.splice(insertIndex, 0, itemId);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Remove a child item id from this group.\n * @param itemId The id of the item to remove from this group.\n */\n removeChild(itemId: string): void {\n const items = (this.config.items ??= []);\n const index = items.indexOf(itemId);\n if (index !== -1) {\n items.splice(index, 1);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n }\n\n /**\n * Check if an item is a direct child of this group.\n */\n hasChild(itemId: string): boolean {\n return this.items.includes(itemId);\n }\n\n /** Whether items in this group should be shuffled. */\n get shuffleItems(): boolean {\n return this.config.shuffleItems ?? false;\n }\n\n set shuffleItems(value: boolean) {\n this.config.shuffleItems = value;\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Get the ordered list of child item ids.\n */\n getChildrenIds(): string[] {\n return [...this.items];\n }\n\n /**\n * Swap two items by their positions in the group.\n * @throws Error if indices are out of bounds\n */\n swapItemsByIndex(from: number, to: number): void {\n const items = this.items;\n if (from < 0 || from >= items.length || to < 0 || to >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (from === to) return;\n this.config.items = swapArrayElements(items, from, to);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n\n /**\n * Swap two items by their ids.\n * @throws Error if either id is not found in this group\n */\n swapItemsById(id: string, withId: string): void {\n const items = this.items;\n const index1 = items.indexOf(id);\n const index2 = items.indexOf(withId);\n if (index1 === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index2 === -1) {\n throw new Error(`Item '${withId}' not found in group '${this.key}'`);\n }\n this.swapItemsByIndex(index1, index2);\n }\n\n /**\n * Move an item by id to a specific index.\n * @throws Error if the item is not found or index is out of bounds\n */\n moveItemToIndex(id: string, index: number): void {\n const items = this.items;\n const fromIndex = items.indexOf(id);\n if (fromIndex === -1) {\n throw new Error(`Item '${id}' not found in group '${this.key}'`);\n }\n if (index < 0 || index >= items.length) {\n throw new Error(`Index out of bounds. Valid range is 0-${items.length - 1}`);\n }\n if (fromIndex === index) return;\n this.config.items = moveArrayElement(items, fromIndex, index);\n this.updateRawItem({\n ...this.rawItem,\n config: { ...this.config },\n });\n }\n}\n\n/**\n * Page break item core.\n */\nexport type PageBreakConfig = Record<string, never>;\n\nexport class PageBreakItemCore extends SurveyItemCore<\n typeof ReservedSurveyItemTypes.PageBreak,\n PageBreakConfig\n> {\n readonly type = ReservedSurveyItemTypes.PageBreak;\n\n parseConfig(_rawConfig: unknown): PageBreakConfig {\n return {};\n }\n\n serializeConfig(): unknown {\n return undefined;\n }\n\n isInteractive(): boolean {\n return false;\n }\n\n getResponseSlotDefinitions() {\n return [];\n }\n}\n\n/**\n * Built-in item type.\n */\nexport type BuiltInItemType =\n | typeof ReservedSurveyItemTypes.Group\n | typeof ReservedSurveyItemTypes.PageBreak;\n\nexport const builtInItemCoreRegistry: Record<BuiltInItemType, ItemCoreConstructor> = {\n [ReservedSurveyItemTypes.Group]: GroupItemCore,\n [ReservedSurveyItemTypes.PageBreak]: PageBreakItemCore,\n};\n\nexport const isBuiltInItemType = (itemType: string): itemType is BuiltInItemType =>\n itemType in builtInItemCoreRegistry;\n","import { ItemCoreConstructor, SurveyItemCore } from \"../items/survey-item\";\nimport { RawSurveyItem } from \"../items/survey-item-json\";\nimport { builtInItemCoreRegistry, isBuiltInItemType } from \"./built-in-items\";\nimport type { AnyItemExpressionDefinition } from \"../../expressions/item-expression-registry\";\n\n/**\n * Registry maps item type name → handler constructor.\n * Plugins extend this with their own handler classes.\n */\nexport type ItemTypeRegistry = Record<string, new (rawItem: RawSurveyItem) => SurveyItemCore>;\n\n/** Item type identifier (e.g. \"singleChoiceQuestion\", \"display\"). */\nexport type ItemTypeName = string;\n\n/** Capabilities of an item type (interactive, supports children). */\nexport interface ItemTypeCapabilities {\n interactive?: boolean;\n supportsChildren?: boolean;\n}\n\n/**\n * Definition of an item type: its name, constructor, and optional capabilities.\n * Used by editor/UI layers to compose registries.\n */\nexport interface ItemTypeDefinition {\n itemType: ItemTypeName;\n constructor: ItemCoreConstructor;\n capabilities?: ItemTypeCapabilities;\n expressions?: AnyItemExpressionDefinition[];\n}\n\n/** Registry mapping item type name → definition. */\nexport type ItemTypeDefinitionRegistry = Record<ItemTypeName, ItemTypeDefinition>;\n\n/** Convert constructor registry to explicit definitions for higher-layer composition. */\nexport function toItemTypeDefinitionRegistry(\n registry: ItemTypeRegistry,\n): ItemTypeDefinitionRegistry {\n return Object.fromEntries(\n Object.entries(registry).map(([itemType, constructor]) => [\n itemType,\n { itemType, constructor },\n ]),\n );\n}\n\n/**\n * Creates a handler instance for a raw survey item.\n * Uses built-in registry for group/page-break, otherwise the provided plugin registry.\n */\nexport function createItemCore(\n rawItem: RawSurveyItem,\n pluginRegistry?: ItemTypeRegistry,\n): SurveyItemCore {\n if (isBuiltInItemType(rawItem.itemType)) {\n const HandlerClass = builtInItemCoreRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n if (pluginRegistry && rawItem.itemType in pluginRegistry) {\n const HandlerClass = pluginRegistry[rawItem.itemType];\n return new HandlerClass(rawItem);\n }\n\n throw new Error(`Unknown item type: ${rawItem.itemType}`);\n}\n\n/**\n * Merge built-in handlers with plugin registry for a complete registry.\n */\nexport function createFullRegistry(pluginRegistry?: ItemTypeRegistry): ItemTypeRegistry {\n return {\n ...builtInItemCoreRegistry,\n ...pluginRegistry,\n };\n}\n\n/** Build full registry as explicit definitions for editor/ui composition. */\nexport function createItemTypeDefinitionRegistry(\n pluginRegistry?: ItemTypeRegistry,\n): ItemTypeDefinitionRegistry {\n return toItemTypeDefinitionRegistry(createFullRegistry(pluginRegistry));\n}\n","import { JsonTemplateValue } from \"../expressions/template-value\";\nimport { RawSurveyItem } from \"./items\";\nimport { JsonSurveyTranslations } from \"./utils/translations\";\n\nexport const CURRENT_SURVEY_SCHEMA =\n \"https://github.com/case-framework/case-survey-toolkit/packages/survey-core/schemas/survey-schema.json\";\n// TODO: generate schema from survey-core.ts\n\nexport interface SurveyVersion {\n id?: string;\n surveyKey: string;\n published?: number;\n unpublished?: number;\n versionId?: string;\n survey: RawSurvey;\n}\n\nexport type RawSurveyAsset = {\n kind: \"image\";\n source: {\n type: \"embedded\";\n mediaType: string;\n encoding: \"base64\";\n data: string;\n };\n metadata?: {\n name?: string;\n filename?: string;\n alt?: string;\n width?: number;\n height?: number;\n };\n};\n\nexport type RawSurvey = {\n $schema: string;\n maxItemsPerPage?: { large: number; small: number };\n\n surveyItems: Array<RawSurveyItem>;\n assets?: Record<string, RawSurveyAsset>;\n\n metadata?: {\n [key: string]: string;\n };\n templateValues?: {\n [templateValueKey: string]: JsonTemplateValue;\n };\n translations?: JsonSurveyTranslations;\n};\n","import { structuredCloneMethod } from \"../../utils\";\nimport { Content } from \"./content\";\n\nexport const validateLocale = (locale: string): void => {\n if (locale.trim() === \"\") {\n throw new Error(\"Locale cannot be empty\");\n }\n};\n\nexport class SurveyItemTranslations {\n private _translations?: {\n [locale: string]: JsonComponentContent;\n };\n\n constructor() {\n this._translations = {};\n }\n\n setContent(locale: string, contentKey: string, content?: Content): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations![locale] = {};\n }\n if (!content) {\n delete this._translations![locale][contentKey];\n } else {\n this._translations![locale][contentKey] = content;\n }\n }\n\n setAllForLocale(locale: string, content?: JsonComponentContent): void {\n validateLocale(locale);\n if (!this._translations?.[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations![locale] = {};\n }\n this._translations![locale] = content || {};\n }\n\n get locales(): string[] {\n return Object.keys(this._translations || {});\n }\n\n getAllForLocale(locale: string): JsonComponentContent | undefined {\n return this._translations?.[locale];\n }\n\n getContent(locale: string, contentKey: string, fallbackLocale?: string): Content | undefined {\n const content = this._translations?.[locale]?.[contentKey];\n if (content) {\n return content;\n }\n if (fallbackLocale) {\n return this._translations?.[fallbackLocale]?.[contentKey];\n }\n return undefined;\n }\n\n /**\n * Create a deep clone that can be safely mutated before persisting with\n * `setItemTranslations` or `updateItemTranslations`.\n */\n clone(): SurveyItemTranslations {\n const cloned = new SurveyItemTranslations();\n\n for (const locale of this.locales) {\n const localeContent = this.getAllForLocale(locale);\n if (!localeContent) {\n continue;\n }\n\n cloned.setAllForLocale(locale, structuredCloneMethod(localeContent));\n }\n\n return cloned;\n }\n\n /**\n * Remove a single content key from every locale in this translation set.\n */\n removeContentKey(contentKey: string): void {\n for (const locale of this.locales) {\n delete this._translations?.[locale]?.[contentKey];\n }\n }\n\n /**\n * Remove every content key that is exactly the prefix or nested beneath it.\n */\n removeContentKeysWithPrefix(prefix: string): void {\n for (const locale of this.locales) {\n const localeContent = this._translations?.[locale];\n if (!localeContent) {\n continue;\n }\n\n for (const contentKey of Object.keys(localeContent)) {\n if (contentKey === prefix || contentKey.startsWith(prefix + \".\")) {\n delete localeContent[contentKey];\n }\n }\n }\n }\n\n /**\n * Remove empty locales in place.\n * Returns `undefined` when no translations remain so callers can pass the\n * result directly into `setItemTranslations` / `updateItemTranslations`.\n */\n compact(): SurveyItemTranslations | undefined {\n for (const locale of this.locales) {\n const localeContent = this._translations?.[locale];\n if (!localeContent) {\n continue;\n }\n\n if (Object.keys(localeContent).length === 0) {\n delete this._translations?.[locale];\n }\n }\n\n return this.locales.length > 0 ? this : undefined;\n }\n}\n\nexport interface SurveyCardTranslations {\n [locale: string]: SurveyCardContent;\n}\n\nexport class SurveyTranslations {\n private _translations: JsonSurveyTranslations;\n\n constructor(translations?: JsonSurveyTranslations) {\n this._translations = translations || {};\n }\n\n serialize(): JsonSurveyTranslations | undefined {\n if (this.locales.length === 0) {\n return undefined;\n }\n return this._translations;\n }\n\n get locales(): string[] {\n return Object.keys(this._translations);\n }\n\n removeLocale(locale: string): void {\n validateLocale(locale);\n delete this._translations[locale];\n }\n\n renameLocale(oldLocale: string, newLocale: string): void {\n validateLocale(oldLocale);\n validateLocale(newLocale);\n if (this._translations[oldLocale]) {\n this._translations[newLocale] = this._translations[oldLocale];\n delete this._translations[oldLocale];\n }\n }\n\n cloneLocaleAs(locale: string, newLocale: string): void {\n validateLocale(locale);\n validateLocale(newLocale);\n if (this._translations[locale]) {\n this._translations[newLocale] = structuredCloneMethod(this._translations[locale]);\n }\n }\n\n get surveyCardContent(): SurveyCardTranslations | undefined {\n const translations: SurveyCardTranslations = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.surveyCardContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as SurveyCardContent;\n }\n }\n return translations;\n }\n\n get navigationContent(): { [locale: string]: NavigationContent } | undefined {\n const translations: { [locale: string]: NavigationContent } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.navigationContent;\n if (contentForLocale) {\n translations[locale] = contentForLocale as NavigationContent;\n }\n }\n return translations;\n }\n\n get validationMessages(): { [locale: string]: { invalidResponse?: Content } } | undefined {\n const translations: { [locale: string]: { invalidResponse?: Content } } = {};\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale]?.validationMessages;\n if (contentForLocale) {\n translations[locale] = contentForLocale as { invalidResponse?: Content };\n }\n }\n return translations;\n }\n\n setSurveyCardContent(locale: string, content?: SurveyCardContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations[locale] = {};\n }\n this._translations[locale].surveyCardContent = content;\n }\n\n setNavigationContent(locale: string, content?: NavigationContent): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations[locale] = {};\n }\n this._translations[locale].navigationContent = content;\n }\n\n setValidationMessages(locale: string, content?: { invalidResponse?: Content }): void {\n validateLocale(locale);\n if (!this._translations[locale]) {\n if (!content) {\n // No need to do anything if content is undefined\n return;\n }\n this._translations[locale] = {};\n }\n this._translations[locale].validationMessages = content;\n }\n\n getItemTranslations(itemId: string): SurveyItemTranslations | undefined {\n const itemTranslations: SurveyItemTranslations = new SurveyItemTranslations();\n for (const locale of this.locales) {\n const contentForLocale = this._translations?.[locale].itemTranslations?.[itemId];\n itemTranslations.setAllForLocale(locale, contentForLocale as JsonComponentContent);\n }\n return itemTranslations.locales.length > 0 ? itemTranslations : undefined;\n }\n\n /**\n * Persist item translations after normalizing them:\n * empty keys/locales are removed automatically, and an empty translation set\n * clears the item's stored translations entirely.\n */\n setItemTranslations(itemId: string, itemContent?: SurveyItemTranslations): void {\n const normalizedItemContent = itemContent?.clone().compact();\n\n normalizedItemContent?.locales.forEach((locale) => validateLocale(locale));\n if (!normalizedItemContent) {\n for (const locale of this.locales) {\n if (this._translations[locale].itemTranslations?.[itemId]) {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n } else {\n const localesInUpdate = normalizedItemContent.locales;\n // Add new locales to the translations\n for (const locale of localesInUpdate) {\n if (!this.locales.includes(locale)) {\n this._translations[locale] = {};\n }\n }\n for (const locale of this.locales) {\n if (localesInUpdate.includes(locale)) {\n if (!this._translations[locale]) {\n this._translations[locale] = {};\n }\n if (!this._translations[locale].itemTranslations) {\n this._translations[locale].itemTranslations = {};\n }\n this._translations[locale].itemTranslations![itemId] =\n normalizedItemContent.getAllForLocale(locale)!;\n } else {\n delete this._translations[locale].itemTranslations?.[itemId];\n }\n }\n }\n }\n\n /**\n * Rename a component key (within an item) - update key in all translations and remove old key\n * @param itemKey - The key of the item\n * @param oldKey - The old key of the component\n * @param newKey - The new key of the component\n */\n onComponentKeyChanged(itemKey: string, oldKey: string, newKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[\n itemKey\n ] as JsonComponentContent;\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(oldKey + \".\") || key === oldKey) {\n itemTranslations[key.replace(oldKey, newKey)] = { ...itemTranslations[key] };\n delete itemTranslations[key];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for a component\n * @param itemId - The id of the item\n * @param componentKey - The key of the component\n */\n onComponentDeleted(itemId: string, componentKey: string): void {\n for (const locale of this.locales) {\n const itemTranslations = this._translations?.[locale].itemTranslations?.[itemId];\n if (itemTranslations) {\n for (const key of Object.keys(itemTranslations)) {\n if (key.startsWith(componentKey + \".\") || key === componentKey) {\n delete itemTranslations[key as keyof typeof itemTranslations];\n }\n }\n }\n }\n }\n\n /**\n * Remove all translations for an item\n * @param id - The id of the item\n */\n onItemDeleted(id: string): void {\n for (const locale of this.locales) {\n delete this._translations![locale].itemTranslations?.[id];\n }\n }\n}\n\n/**\n * Json Schemas for translations\n */\nexport type JsonComponentContent = {\n [contentKey: string]: Content;\n};\n\nexport interface SurveyCardContent {\n name?: Content;\n description?: Content;\n typicalDuration?: Content;\n}\n\nexport interface NavigationContent {\n previousButtonText?: Content;\n nextButtonText?: Content;\n submitButtonText?: Content;\n pageIndicatorText?: Content;\n submitBoxMessage?: Content;\n}\n\nexport interface JsonSurveyTranslations {\n [locale: string]: {\n surveyCardContent?: SurveyCardContent;\n navigationContent?: NavigationContent;\n validationMessages?: {\n invalidResponse?: Content;\n };\n itemTranslations?: {\n [itemId: string]: JsonComponentContent;\n };\n };\n}\n","export enum ContentType {\n richText = \"richText\",\n plain = \"plain\",\n md = \"md\",\n}\n\nexport type ContentAttributes = Record<string, unknown>;\n\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\nexport type RichTextStyle = {\n weight?: \"strong\" | \"normal\";\n italic?: \"italic\" | \"normal\";\n underline?: \"underline\" | \"none\";\n color?: \"primary\" | \"accent\" | \"default\";\n};\n\nexport type RichTextTextInline = {\n type: \"text\";\n text: string;\n style?: RichTextStyle;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextTemplateInline = {\n type: \"template\";\n key: string;\n style?: RichTextStyle;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextLineBreakInline = {\n type: \"lineBreak\";\n attrs?: ContentAttributes;\n};\n\n/** Inline nodes allowed inside a {@link RichTextLinkInline} (no nested links). */\nexport type RichTextLinkChildInline =\n | RichTextTextInline\n | RichTextTemplateInline\n | RichTextLineBreakInline;\n\nexport type RichTextLinkInline = {\n type: \"link\";\n href: string;\n target?: string | null;\n rel?: string | null;\n title?: string | null;\n attrs?: ContentAttributes;\n children: RichTextLinkChildInline[];\n};\n\nexport type RichTextInlineExtension = {\n type: \"inlineExtension\";\n name: string;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextInlineNode =\n | RichTextTextInline\n | RichTextTemplateInline\n | RichTextLinkInline\n | RichTextLineBreakInline\n | RichTextInlineExtension;\n\nexport type RichTextParagraphBlock = {\n type: \"paragraph\";\n children: RichTextInlineNode[];\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextHeadingBlock = {\n type: \"heading\";\n level: 1 | 2 | 3 | 4 | 5 | 6;\n children: RichTextInlineNode[];\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextListItemBlock = {\n type: \"listItem\";\n children: RichTextParagraphBlock[];\n attrs?: ContentAttributes;\n};\n\nexport type RichTextBulletListBlock = {\n type: \"bulletList\";\n items: RichTextListItemBlock[];\n attrs?: ContentAttributes;\n};\n\nexport type SurveyContentImageSource =\n | {\n type: \"external\";\n url: string;\n }\n | {\n type: \"asset\";\n assetId: string;\n };\n\nexport type RichTextImageDimension = { unit: \"px\"; value: number } | { unit: \"%\"; value: number };\n\nexport type RichTextImageSize = {\n width?: RichTextImageDimension;\n height?: RichTextImageDimension;\n maxWidth?: RichTextImageDimension;\n maxHeight?: RichTextImageDimension;\n};\n\nexport type RichTextImageBlock = {\n type: \"image\";\n source: SurveyContentImageSource;\n alt?: string;\n caption?: RichTextParagraphBlock[];\n size?: RichTextImageSize;\n alignment?: TextAlignment;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextInfoBoxBlock = {\n type: \"infoBox\";\n tone?: \"info\" | \"warning\";\n title?: RichTextInlineNode[];\n collapsible?: boolean;\n defaultOpen?: boolean;\n children: RichTextParagraphBlock[];\n attrs?: ContentAttributes;\n};\n\nexport type RichTextSeparatorBlock = {\n type: \"separator\";\n attrs?: ContentAttributes;\n};\n\nexport type RichTextBlockExtension = {\n type: \"blockExtension\";\n name: string;\n attrs?: ContentAttributes;\n};\n\nexport type RichTextBlockNode =\n | RichTextParagraphBlock\n | RichTextHeadingBlock\n | RichTextBulletListBlock\n | RichTextImageBlock\n | RichTextInfoBoxBlock\n | RichTextSeparatorBlock\n | RichTextBlockExtension;\n\nexport type RichTextDocument = {\n type: \"doc\";\n blocks: RichTextBlockNode[];\n};\n\nexport type RichTextContent = {\n type: ContentType.richText;\n version: 1;\n doc: RichTextDocument;\n};\n\nexport type MDContent = {\n type: ContentType.md;\n content: string;\n};\n\nexport type PlainTextContent = {\n type: ContentType.plain;\n content: string;\n};\n\nexport type Content = RichTextContent | MDContent | PlainTextContent;\nexport type RichTextInline = RichTextInlineNode;\n\nexport interface ContentAssetUsage {\n assetId: string;\n blockIndex: number;\n}\n\nexport function hasRenderableRichTextBlock(block: RichTextBlockNode): boolean {\n switch (block.type) {\n case \"paragraph\":\n return block.children.length > 0;\n case \"heading\":\n return block.children.length > 0;\n case \"bulletList\":\n return block.items.some((item) =>\n item.children.some((paragraph) => paragraph.children.length > 0),\n );\n case \"image\":\n return true;\n case \"infoBox\":\n // Empty callouts are still intentional blocks (editor inserts title/body later).\n return true;\n case \"separator\":\n return true;\n case \"blockExtension\":\n return true;\n }\n}\n\nexport function hasRenderableRichTextContent(content: RichTextContent): boolean {\n return content.doc.blocks.some((block) => hasRenderableRichTextBlock(block));\n}\n\nexport function createRichTextContent(text = \"\"): RichTextContent {\n return {\n type: ContentType.richText,\n version: 1,\n doc: {\n type: \"doc\",\n blocks: [\n {\n type: \"paragraph\",\n children:\n text.length > 0\n ? text.split(\"\\n\").flatMap<RichTextInlineNode>((line, index) => {\n const parts: RichTextInlineNode[] = [];\n if (index > 0) {\n parts.push({ type: \"lineBreak\" });\n }\n if (line.length > 0) {\n parts.push({ type: \"text\", text: line });\n }\n return parts;\n })\n : [],\n },\n ],\n },\n };\n}\n\nfunction getPlainTextFromLinkChildren(children: RichTextLinkChildInline[]): string {\n return children\n .map((inline) => {\n switch (inline.type) {\n case \"text\":\n return inline.text;\n case \"template\":\n return `{${inline.key}}`;\n case \"lineBreak\":\n return \"\\n\";\n }\n })\n .join(\"\");\n}\n\nfunction getPlainTextFromInlineNodes(inlines: RichTextInlineNode[]): string {\n return inlines\n .map((inline) => {\n switch (inline.type) {\n case \"text\":\n return inline.text;\n case \"template\":\n return `{${inline.key}}`;\n case \"link\":\n return getPlainTextFromLinkChildren(inline.children);\n case \"lineBreak\":\n return \"\\n\";\n case \"inlineExtension\":\n return \"\";\n }\n })\n .join(\"\");\n}\n\nfunction getPlainTextFromParagraphs(paragraphs: RichTextParagraphBlock[]): string {\n return paragraphs.map((paragraph) => getPlainTextFromInlineNodes(paragraph.children)).join(\"\\n\");\n}\n\nfunction getPlainTextFromBlock(block: RichTextBlockNode): string {\n switch (block.type) {\n case \"paragraph\":\n return getPlainTextFromInlineNodes(block.children);\n case \"heading\":\n return getPlainTextFromInlineNodes(block.children);\n case \"bulletList\":\n return block.items.map((item) => getPlainTextFromParagraphs(item.children)).join(\"\\n\");\n case \"image\": {\n const captionText = block.caption ? getPlainTextFromParagraphs(block.caption) : \"\";\n return [block.alt ?? \"\", captionText].filter(Boolean).join(\"\\n\");\n }\n case \"infoBox\": {\n const titleText = block.title ? getPlainTextFromInlineNodes(block.title) : \"\";\n const bodyText = getPlainTextFromParagraphs(block.children);\n return [titleText, bodyText].filter(Boolean).join(\"\\n\");\n }\n case \"separator\":\n return \"\";\n case \"blockExtension\":\n return \"\";\n }\n}\n\nexport function getPlainTextFromRichTextContent(content: RichTextContent): string {\n return content.doc.blocks\n .map((block) => getPlainTextFromBlock(block))\n .filter((text) => text.length > 0)\n .join(\"\\n\")\n .trim();\n}\n\nexport function getContentPlainText(content?: Content): string {\n if (!content) {\n return \"\";\n }\n\n if (content.type !== ContentType.richText) {\n return content.content ?? \"\";\n }\n\n return getPlainTextFromRichTextContent(content);\n}\n\nexport function isContentEmpty(content?: Content): boolean {\n if (!content) {\n return true;\n }\n\n if (content.type !== ContentType.richText) {\n return content.content.trim().length === 0;\n }\n\n return !hasRenderableRichTextContent(content);\n}\n\nexport function getAssetUsagesFromContent(content?: Content): ContentAssetUsage[] {\n if (!content || content.type !== ContentType.richText) {\n return [];\n }\n\n const usages: ContentAssetUsage[] = [];\n\n content.doc.blocks.forEach((block, blockIndex) => {\n if (block.type === \"image\" && block.source.type === \"asset\") {\n usages.push({\n assetId: block.source.assetId,\n blockIndex,\n });\n }\n });\n\n return usages;\n}\n","import { CURRENT_SURVEY_SCHEMA, RawSurvey, RawSurveyAsset } from \"./survey-file-schema\";\nimport { SurveyItemTranslations, SurveyTranslations } from \"./utils/translations\";\nimport { SurveyItemCore, RawSurveyItem, ReservedSurveyItemTypes } from \"./items\";\nimport { ReferenceUsage, ReferenceUsageType } from \"./utils/value-reference\";\nimport { Content, getAssetUsagesFromContent } from \"./utils/content\";\nimport { SurveyItemKey } from \"./item-key\";\nimport {\n deserializeTemplateValues,\n serializeTemplateValues,\n TemplateValueDefinition,\n} from \"../expressions/template-value\";\nimport { ValueRefTypeLookup, ValueType } from \"./responses/value-types\";\nimport { ResponseSlotDefinition } from \"./responses/slot-definition\";\nimport { createItemCore, ItemTypeRegistry } from \"./registry/item-registry\";\nimport { GroupItemCore } from \"./registry/built-in-items\";\nimport { generateId, structuredCloneMethod } from \"../utils\";\n\nexport interface SurveyAssetUsage {\n assetId: string;\n itemId?: string;\n locale?: string;\n contentKey: string;\n usageScope: \"itemTranslation\" | \"surveyCard\" | \"navigation\" | \"validationMessages\";\n blockIndex: number;\n}\n\nexport class Survey {\n maxItemsPerPage?: { large: number; small: number };\n metadata?: {\n [key: string]: string;\n };\n surveyItems: Map<string, SurveyItemCore> = new Map();\n private _templateValues?: Map<string, TemplateValueDefinition> = new Map();\n private _assets?: Map<string, RawSurveyAsset> = new Map();\n\n private _translations?: SurveyTranslations;\n\n constructor(private readonly pluginRegistry?: ItemTypeRegistry) {\n this._translations = new SurveyTranslations();\n }\n\n /** Plugin registry used when parsing items. Exposed for editors that re-parse without their own registry. */\n getPluginRegistry(): ItemTypeRegistry | undefined {\n return this.pluginRegistry;\n }\n\n /**\n * Create a survey item from raw JSON data.\n * Uses the survey's plugin registry when available.\n */\n createItemFromRaw(rawItem: RawSurveyItem): SurveyItemCore {\n return createItemCore(rawItem, this.pluginRegistry);\n }\n\n /**\n * Create a minimal blank survey with a root group and one empty page.\n */\n static createBlankSurvey(pluginRegistry?: ItemTypeRegistry, surveyKey?: string): Survey {\n const newKey = surveyKey ?? \"survey\";\n const rawSurvey: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: [\n {\n id: generateId(),\n key: newKey,\n itemType: ReservedSurveyItemTypes.Group,\n config: { isRoot: true, items: [], shuffleItems: false },\n },\n ],\n };\n\n return Survey.fromJson(rawSurvey, pluginRegistry);\n }\n\n static fromJson(json: RawSurvey, pluginRegistry?: ItemTypeRegistry): Survey {\n const survey = new Survey(pluginRegistry);\n const rawSurvey = json as RawSurvey;\n if (rawSurvey.$schema !== CURRENT_SURVEY_SCHEMA) {\n throw new Error(`Unsupported survey schema: ${rawSurvey.$schema}`);\n }\n\n survey.surveyItems = new Map();\n if (!rawSurvey.surveyItems || rawSurvey.surveyItems.length === 0) {\n throw new Error(\"surveyItems is required\");\n }\n rawSurvey.surveyItems.forEach((item) => {\n const surveyItem = createItemCore(item, pluginRegistry);\n survey.surveyItems.set(surveyItem.id, surveyItem);\n });\n\n // Parse other fields\n if (rawSurvey.templateValues) {\n survey._templateValues = deserializeTemplateValues(rawSurvey.templateValues);\n }\n\n if (rawSurvey.assets) {\n survey._assets = new Map(Object.entries(rawSurvey.assets));\n }\n\n survey._translations = new SurveyTranslations(rawSurvey.translations);\n\n if (rawSurvey.maxItemsPerPage) {\n survey.maxItemsPerPage = rawSurvey.maxItemsPerPage;\n }\n\n if (rawSurvey.metadata) {\n survey.metadata = rawSurvey.metadata;\n }\n\n return survey;\n }\n\n serialize(): RawSurvey {\n const json: RawSurvey = {\n $schema: CURRENT_SURVEY_SCHEMA,\n surveyItems: Array.from(this.surveyItems.values()).map((item) => item.rawItem),\n };\n\n // Export other fields\n json.translations = this._translations?.serialize();\n\n if (this._templateValues) {\n json.templateValues = serializeTemplateValues(this._templateValues);\n }\n\n if (this._assets && this._assets.size > 0) {\n json.assets = Object.fromEntries(this._assets.entries());\n }\n\n if (this.maxItemsPerPage) {\n json.maxItemsPerPage = this.maxItemsPerPage;\n }\n if (this.metadata) {\n json.metadata = this.metadata;\n }\n\n return json;\n }\n\n get surveyKey(): string | undefined {\n const rootItem = this.rootItem;\n if (!rootItem) {\n return undefined;\n }\n return this.rootItem.key;\n }\n\n get locales(): string[] {\n return this._translations?.locales || [];\n }\n\n get rootItem(): GroupItemCore | undefined {\n const rootItem = Array.from(this.surveyItems.values()).find(\n (item) => item instanceof GroupItemCore && item.isRoot,\n ) as GroupItemCore | undefined;\n return rootItem;\n }\n\n get keyIndex(): Array<{ itemId: string; key: string; keyPath: string[]; path: string[] }> {\n const index: Array<{ itemId: string; key: string; keyPath: string[]; path: string[] }> = [];\n for (const item of this.surveyItems.values()) {\n const path = this.getItemPath(item.id);\n index.push({\n itemId: item.id,\n key: item.key,\n keyPath: path.map((id) => this.surveyItems.get(id)?.key ?? \"\"),\n path: path,\n });\n }\n return index;\n }\n\n getItemPath(itemId: string): string[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n\n if (item instanceof GroupItemCore && item.isRoot()) {\n return [];\n }\n\n // find parent item for the given item id\n const parentItem = this.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Parent item for ${itemId} not found`);\n }\n return [...this.getItemPath(parentItem.id), parentItem.id];\n }\n\n getItemKey(itemId: string): SurveyItemKey | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return undefined;\n }\n const idPath = this.getItemPath(itemId);\n const keyPath = idPath.map((id) => this.surveyItems.get(id)?.key ?? \"\");\n return new SurveyItemKey(item.key, keyPath);\n }\n\n getParentItem(itemId: string): GroupItemCore | undefined {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item ${itemId} not found`);\n }\n if (item instanceof GroupItemCore && item.isRoot()) {\n return undefined;\n }\n const parentItem = Array.from(this.surveyItems.values()).find(\n (item) => item instanceof GroupItemCore && item.config.items?.includes(itemId),\n ) as GroupItemCore | undefined;\n if (!parentItem) {\n return undefined;\n }\n return parentItem;\n }\n\n getChildrenItems(parentId: string): SurveyItemCore[] {\n const parentItem = this.surveyItems.get(parentId);\n if (!parentItem || !(parentItem instanceof GroupItemCore)) {\n return [];\n }\n return (\n ((parentItem as GroupItemCore).config.items\n ?.map((id) => this.surveyItems.get(id))\n ?.filter((item) => item !== undefined) as SurveyItemCore[]) || []\n );\n }\n\n getSiblings(itemId: string): SurveyItemCore[] {\n const item = this.surveyItems.get(itemId);\n if (!item) {\n return [];\n }\n const parentItem = this.getParentItem(itemId);\n return (\n (parentItem?.items\n ?.map((id) => this.surveyItems.get(id))\n ?.filter((item) => item !== undefined) as SurveyItemCore[]) || []\n );\n }\n\n get translations(): SurveyTranslations {\n if (!this._translations) {\n this._translations = new SurveyTranslations();\n }\n return this._translations;\n }\n\n getItemTranslations(id: string): SurveyItemTranslations | undefined {\n const item = this.surveyItems.get(id);\n if (!item) {\n throw new Error(`Item ${id} not found`);\n }\n\n return this._translations?.getItemTranslations(id);\n }\n\n getTemplateValue(templateValueKey: string): TemplateValueDefinition | undefined {\n return this._templateValues?.get(templateValueKey);\n }\n\n setTemplateValue(templateValueKey: string, templateValue: TemplateValueDefinition) {\n if (!this._templateValues) {\n this._templateValues = new Map();\n }\n this._templateValues?.set(templateValueKey, templateValue);\n }\n\n deleteTemplateValue(templateValueKey: string) {\n this._templateValues?.delete(templateValueKey);\n }\n\n getTemplateValueKeys(): string[] {\n return Array.from(this._templateValues?.keys() || []);\n }\n\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._assets?.get(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n if (!this._assets) {\n this._assets = new Map();\n }\n\n this._assets.set(assetId, structuredCloneMethod(asset));\n }\n\n deleteAsset(assetId: string): void {\n this._assets?.delete(assetId);\n }\n\n hasAsset(assetId: string): boolean {\n return this._assets?.has(assetId) ?? false;\n }\n\n getAssetIds(): string[] {\n return Array.from(this._assets?.keys() || []);\n }\n\n getAssets(): Map<string, RawSurveyAsset> {\n return new Map(\n Array.from(this._assets?.entries() || []).map(([assetId, asset]) => [\n assetId,\n structuredCloneMethod(asset),\n ]),\n );\n }\n\n getAssetUsages(filterAssetId?: string): SurveyAssetUsage[] {\n const usages: SurveyAssetUsage[] = [];\n const pushContentUsages = (\n content: Content | undefined,\n usageScope: SurveyAssetUsage[\"usageScope\"],\n contentKey: string,\n locale?: string,\n itemId?: string,\n ) => {\n for (const usage of getAssetUsagesFromContent(content)) {\n if (filterAssetId && usage.assetId !== filterAssetId) {\n continue;\n }\n\n usages.push({\n assetId: usage.assetId,\n itemId,\n locale,\n contentKey,\n usageScope,\n blockIndex: usage.blockIndex,\n });\n }\n };\n\n const serializedTranslations = this._translations?.serialize();\n const rootItemId = this.rootItem?.id;\n\n if (!serializedTranslations) {\n return usages;\n }\n\n for (const [locale, localeTranslations] of Object.entries(serializedTranslations)) {\n for (const [contentKey, content] of Object.entries(\n localeTranslations.surveyCardContent || {},\n )) {\n pushContentUsages(content, \"surveyCard\", contentKey, locale, rootItemId);\n }\n\n for (const [contentKey, content] of Object.entries(\n localeTranslations.navigationContent || {},\n )) {\n pushContentUsages(content, \"navigation\", contentKey, locale, rootItemId);\n }\n\n for (const [contentKey, content] of Object.entries(\n localeTranslations.validationMessages || {},\n )) {\n pushContentUsages(content, \"validationMessages\", contentKey, locale, rootItemId);\n }\n\n for (const [itemId, itemTranslations] of Object.entries(\n localeTranslations.itemTranslations || {},\n )) {\n for (const [contentKey, content] of Object.entries(itemTranslations || {})) {\n pushContentUsages(content, \"itemTranslation\", contentKey, locale, itemId);\n }\n }\n }\n\n return usages;\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n let valueRefs: ValueRefTypeLookup = {};\n for (const item of this.surveyItems.values()) {\n valueRefs = { ...valueRefs, ...item.getAvailableResponseValueSlots(byType) };\n }\n return valueRefs;\n }\n\n getResponseSlotDefinitions(): Array<{ itemId: string; slots: ResponseSlotDefinition[] }> {\n return Array.from(this.surveyItems.values()).map((item) => ({\n itemId: item.id,\n slots: item.getResponseSlotDefinitions(),\n }));\n }\n\n /**\n * Get all reference usages for the survey\n * @param forItemId - optional item id to filter usages for a specific item and its children (if not provided, all usages are returned)\n * @returns all reference usages for the survey (or for a specific item and its children)\n */\n getReferenceUsages(forItemId?: string): ReferenceUsage[] {\n const usages: ReferenceUsage[] = [];\n for (const item of this.surveyItems.values()) {\n if (forItemId && item.id !== forItemId && !this.isDescendantOf(item.id, forItemId)) {\n continue;\n }\n usages.push(...item.getReferenceUsages());\n }\n\n if (this._templateValues) {\n for (const [templateValueKey, templateValue] of this._templateValues.entries()) {\n for (const ref of templateValue.expression?.responseVariableRefs || []) {\n usages.push({\n itemId: templateValueKey,\n usageType: ReferenceUsageType.templateValues,\n valueReference: ref,\n });\n }\n }\n }\n\n return usages;\n }\n\n // Helper method to check if targetId is a descendant of ancestorId\n isDescendantOf(targetId: string, ancestorId: string): boolean {\n if (targetId === ancestorId) {\n return true;\n }\n const targetPath = this.getItemPath(targetId);\n return targetPath.includes(ancestorId);\n }\n}\n"],"mappings":";AAAA,SAAS,WAAW,MAAsB;CACxC,IAAI,OAAO;AAEX,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAQ,KAAK,WAAW,EAAE;AAC1B,SAAO,KAAK,KAAK,MAAM,SAAS;;AAGlC,QAAO,SAAS;;AAGlB,SAAgB,mBAAmB,MAA4B;CAC7D,IAAI,QAAQ,WAAW,KAAK;AAE5B,cAAa;AACX,UAAS,QAAQ,eAAgB;EACjC,IAAI,OAAO;AACX,SAAO,KAAK,KAAK,OAAQ,SAAS,IAAK,OAAO,EAAE;AAChD,UAAQ,OAAO,KAAK,KAAK,OAAQ,SAAS,GAAI,OAAO,GAAG;AACxD,WAAS,OAAQ,SAAS,QAAS,KAAK;;;AAI5C,SAAgB,aAAgB,QAAsB,SAAuB,KAAK,QAAa;CAC7F,MAAM,iBAAiB,CAAC,GAAG,OAAO;AAElC,MAAK,IAAI,IAAI,eAAe,SAAS,GAAG,IAAI,GAAG,KAAK;EAClD,MAAM,IAAI,KAAK,MAAM,QAAQ,IAAI,IAAI,GAAG;AACxC,GAAC,eAAe,IAAI,eAAe,MAAM,CAAC,eAAe,IAAI,eAAe,GAAG;;AAGjF,QAAO;;;;;;;AAQT,SAAgB,eAAe,QAAgB,SAAuB,KAAK,QAAkB;AAC3F,QAAO,aACL,MAAM,KAAK,EAAE,QAAQ,GAAG,GAAG,MAAM,EAAE,EACnC,OACD;;AAGH,SAAgB,sBAAyB,KAAW;AAClD,KAAI,OAAO,oBAAoB,YAC7B,QAAO,gBAAgB,IAAI;AAG7B,QAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;;AAGxC,MAAM,WAAW;AAEjB,SAAgB,aAAqB;CACnC,MAAM,SAAS;CACf,MAA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