@case-framework/survey-core 0.7.0 → 0.8.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-Bl6qCinx.mjs","names":[],"sources":["../src/calendar-date.ts","../src/survey/responses/value-types.ts","../src/survey/responses/item-response.ts","../src/survey/responses/survey-response.ts","../src/survey/responses/utils.ts","../src/survey/responses/value-domain.ts","../src/survey/responses/variable-naming.ts","../src/survey/responses/slot-registry.ts","../src/survey/utils/value-reference.ts","../src/expressions/expression.ts","../src/expressions/expression-evaluator.ts","../src/expressions/template-value.ts","../src/expressions/date-functions.ts","../src/expressions/reference-integrity.ts","../src/expressions/editors/expression-editor.ts","../src/expressions/editors/expression-editor-generators.ts","../src/survey/items/types.ts","../src/utils.ts","../src/survey/items/utils.ts","../src/survey/items/prefill.ts","../src/survey/items/survey-item.ts","../src/survey/item-display-name.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","../src/response-exporter/column-id.ts","../src/response-exporter/types.ts","../src/response-exporter/slot-formatter.ts","../src/response-exporter/projection.ts"],"sourcesContent":["import { format } from \"date-fns/format\";\n\n/** Gregorian calendar values, without a time or timezone. Precision is part of the value. */\nexport type CalendarDate = string;\nexport type CalendarDatePrecision = \"year\" | \"year-month\" | \"year-month-day\";\nexport type CalendarDateUnit = \"years\" | \"months\" | \"days\";\nconst pad = (n: number, width = 2) => String(n).padStart(width, \"0\");\nconst daysInMonth = (year: number, month: number) =>\n month === 2\n ? year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n ? 29\n : 28\n : [4, 6, 9, 11].includes(month)\n ? 30\n : 31;\n\nexport function isCalendarDate(value: unknown): value is CalendarDate {\n if (typeof value !== \"string\" || !/^\\d{4}(?:-\\d{2}(?:-\\d{2})?)?$/.test(value)) return false;\n const [year, month, day] = value.split(\"-\").map(Number);\n return (\n year >= 1 &&\n year <= 9999 &&\n (month === undefined ||\n (month >= 1 &&\n month <= 12 &&\n (day === undefined || (day >= 1 && day <= daysInMonth(year, month)))))\n );\n}\nexport function calendarDatePrecision(value: CalendarDate): CalendarDatePrecision {\n if (!isCalendarDate(value)) throw new Error(`Invalid calendar date: ${value}`);\n return value.length === 4 ? \"year\" : value.length === 7 ? \"year-month\" : \"year-month-day\";\n}\nexport function calendarDateFromLocalDate(\n date: Date,\n precision: CalendarDatePrecision = \"year-month-day\",\n): CalendarDate {\n const value = [pad(date.getFullYear(), 4), pad(date.getMonth() + 1), pad(date.getDate())]\n .slice(0, precision === \"year\" ? 1 : precision === \"year-month\" ? 2 : 3)\n .join(\"-\");\n if (!isCalendarDate(value)) throw new Error(\"Invalid calendar date\");\n return value;\n}\n/** Adapter for calendar widgets only. Never serialize this Date as an instant. */\nexport function calendarDateToLocalDate(value: CalendarDate): Date {\n calendarDatePrecision(value);\n const [year, month = 1, day = 1] = value.split(\"-\").map(Number);\n const date = new Date(0);\n date.setFullYear(year, month - 1, day);\n date.setHours(12, 0, 0, 0);\n return date;\n}\nexport function calendarDateBounds(value: CalendarDate): [CalendarDate, CalendarDate] {\n calendarDatePrecision(value);\n const [year, month] = value.split(\"-\").map(Number);\n if (value.length === 4) return [`${value}-01-01`, `${value}-12-31`];\n if (value.length === 7) return [`${value}-01`, `${value}-${pad(daysInMonth(year, month))}`];\n return [value, value];\n}\n/** Ordering requires equal precision; callers must explicitly choose interval semantics otherwise. */\nexport function compareCalendarDates(a: CalendarDate, b: CalendarDate): number | undefined {\n if (!isCalendarDate(a) || !isCalendarDate(b) || a.length !== b.length) return undefined;\n return a === b ? 0 : a < b ? -1 : 1;\n}\nfunction utcDate(value: CalendarDate): Date {\n const [year, month = 1, day = 1] = value.split(\"-\").map(Number);\n const date = new Date(0);\n date.setUTCFullYear(year, month - 1, day);\n return date;\n}\nexport function addCalendarDate(\n value: CalendarDate,\n amount: number,\n unit: CalendarDateUnit,\n): CalendarDate | undefined {\n if (!isCalendarDate(value) || !Number.isSafeInteger(amount)) return undefined;\n if (amount === 0) return value;\n if ((unit === \"days\" && value.length !== 10) || (unit === \"months\" && value.length < 7))\n return undefined;\n const [year, month = 1, day = 1] = value.split(\"-\").map(Number);\n let result: string;\n if (unit === \"days\") {\n const date = utcDate(value);\n date.setUTCDate(date.getUTCDate() + amount);\n result = `${pad(date.getUTCFullYear(), 4)}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;\n } else {\n const index = (year - 1) * 12 + month - 1 + amount * (unit === \"years\" ? 12 : 1);\n const nextYear = Math.floor(index / 12) + 1;\n const nextMonth = (((index % 12) + 12) % 12) + 1;\n result =\n `${pad(nextYear, 4)}-${pad(nextMonth)}-${pad(Math.min(day, daysInMonth(nextYear, nextMonth)))}`.slice(\n 0,\n value.length,\n );\n }\n return isCalendarDate(result) ? result : undefined;\n}\n/** Signed difference a - b in the value's precision unit (days, months, or years). */\nexport function differenceCalendarDates(a: CalendarDate, b: CalendarDate): number | undefined {\n if (compareCalendarDates(a, b) === undefined) return undefined;\n if (a.length === 10) return (utcDate(a).getTime() - utcDate(b).getTime()) / 86400000;\n const [ay, am = 1] = a.split(\"-\").map(Number);\n const [by, bm = 1] = b.split(\"-\").map(Number);\n return a.length === 4 ? ay - by : (ay - by) * 12 + am - bm;\n}\n// date-fns clones Date subclasses when calculating calendar fields. Keep every local\n// accessor/mutator in UTC so formatting also works on dates skipped by a timezone.\nclass CalendarFormattingDate extends Date {\n getTimezoneOffset() {\n return 0;\n }\n getFullYear() {\n return this.getUTCFullYear();\n }\n getMonth() {\n return this.getUTCMonth();\n }\n getDate() {\n return this.getUTCDate();\n }\n getDay() {\n return this.getUTCDay();\n }\n getHours() {\n return this.getUTCHours();\n }\n getMinutes() {\n return this.getUTCMinutes();\n }\n getSeconds() {\n return this.getUTCSeconds();\n }\n getMilliseconds() {\n return this.getUTCMilliseconds();\n }\n setFullYear(...args: Parameters<Date[\"setFullYear\"]>) {\n return this.setUTCFullYear(...args);\n }\n setMonth(...args: Parameters<Date[\"setMonth\"]>) {\n return this.setUTCMonth(...args);\n }\n setDate(...args: Parameters<Date[\"setDate\"]>) {\n return this.setUTCDate(...args);\n }\n setHours(...args: Parameters<Date[\"setHours\"]>) {\n return this.setUTCHours(...args);\n }\n setMinutes(...args: Parameters<Date[\"setMinutes\"]>) {\n return this.setUTCMinutes(...args);\n }\n setSeconds(...args: Parameters<Date[\"setSeconds\"]>) {\n return this.setUTCSeconds(...args);\n }\n setMilliseconds(...args: Parameters<Date[\"setMilliseconds\"]>) {\n return this.setUTCMilliseconds(...args);\n }\n}\n\n/** Partial dates retain their precision even if a display pattern requests absent components. */\nexport function formatCalendarDate(value: CalendarDate, pattern: string): string {\n calendarDatePrecision(value);\n if (value.length !== 10) return value;\n return format(new CalendarFormattingDate(utcDate(value).getTime()), pattern);\n}\n","import { isCalendarDate, type CalendarDate } from \"../../calendar-date\";\nexport 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: CalendarDate;\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: CalendarDate[];\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 isCalendarDate(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.dateArray:\n return Array.isArray(value.value) && value.value.every(isCalendarDate);\n case ValueType.numberArray:\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 { ItemResponseMeta } from \"./response-meta\";\nimport { assertResponseValue, ResponseValue } from \"./value-types\";\n\nexport interface JsonSurveyItemResponse {\n itemId: string;\n itemType: string;\n meta?: ItemResponseMeta;\n response?: JsonResponseItem;\n}\n\nexport interface JsonResponseItem {\n slots: Record<string, ResponseValue>;\n}\n\n/**\n * SurveyItemResponse to store the response of a survey item.\n */\nexport class SurveyItemResponse {\n itemId: string;\n meta?: ItemResponseMeta;\n response?: ResponseItem;\n itemType: string;\n\n constructor(\n itemDef: {\n itemId: string;\n itemType: string;\n },\n response?: ResponseItem,\n ) {\n this.itemId = itemDef.itemId;\n this.response = response;\n this.itemType = itemDef.itemType;\n }\n\n serialize(): JsonSurveyItemResponse {\n return {\n itemId: this.itemId,\n itemType: this.itemType,\n meta: this.meta,\n response: this.response?.serialize(),\n };\n }\n\n static deserialize(json: JsonSurveyItemResponse): SurveyItemResponse {\n if (!json || typeof json !== \"object\" || Array.isArray(json)) {\n throw new Error(\"Invalid survey item response payload\");\n }\n if (typeof json.itemId !== \"string\" || json.itemId.trim().length === 0) {\n throw new Error(\"Survey item response is missing a valid itemId\");\n }\n if (typeof json.itemType !== \"string\" || json.itemType.trim().length === 0) {\n throw new Error(\"Survey item response is missing a valid itemType\");\n }\n\n const itemDef: {\n itemId: string;\n itemType: string;\n } = {\n itemId: json.itemId,\n itemType: json.itemType,\n };\n\n const response = json.response ? ResponseItem.deserialize(json.response) : undefined;\n\n const newResponse = new SurveyItemResponse(itemDef, response);\n newResponse.meta = json.meta;\n return newResponse;\n }\n}\n\nexport class ResponseItem {\n private _slots: Map<string, ResponseValue>;\n\n constructor(initialValues?: Array<[slotId: string, slotResponse: ResponseValue]>) {\n this._slots = new Map(initialValues ?? []);\n }\n\n get(slotId: string): ResponseValue | undefined {\n return this._slots.get(slotId);\n }\n\n setSlotValue(slotId: string, slotResponse?: ResponseValue) {\n if (slotResponse) {\n this._slots.set(slotId, slotResponse);\n } else {\n this._slots.delete(slotId);\n }\n }\n\n serialize(): JsonResponseItem | undefined {\n if (this._slots.size === 0) {\n return undefined;\n }\n\n return {\n slots: Object.fromEntries(this._slots.entries()),\n };\n }\n\n isEmpty(): boolean {\n return this._slots.size === 0;\n }\n\n clone(): ResponseItem {\n return new ResponseItem(Array.from(this._slots.entries()));\n }\n\n static deserialize(json: JsonResponseItem): ResponseItem {\n if (!json || typeof json !== \"object\" || Array.isArray(json)) {\n throw new Error(\"Invalid response item payload\");\n }\n\n const { slots } = json;\n if (!slots || typeof slots !== \"object\" || Array.isArray(slots)) {\n throw new Error(\"Invalid response slots payload\");\n }\n\n const slotValues = Object.entries(slots).map(([slotId, slotResponse]) => {\n if (slotId.trim().length === 0) {\n throw new Error(\"Response slot id cannot be empty\");\n }\n assertResponseValue(slotResponse, `response.slots.${slotId}`);\n return [slotId, slotResponse] as [string, ResponseValue];\n });\n\n return new ResponseItem(slotValues);\n }\n}\n","import { SurveyItemResponse } from \"./item-response\";\nimport { type ItemResponseMeta, type SurveyEvent } from \"./response-meta\";\nimport { assertResponseValue, type ResponseValue } from \"./value-types\";\n\nexport const SURVEY_RESPONSE_SCHEMA_VERSION = 2;\nexport interface ResponseEvaluationContext {\n locale: string;\n participantFlags?: Record<string, string>;\n}\n\nexport type SurveyResponseContext = Record<string, ResponseValue>;\n\n/** Publication and schema association belong to the host, never to an answer address. */\nexport class SurveyResponse {\n key: string;\n participantId?: string;\n submittedAt?: number;\n answers: Record<string, ResponseValue> = Object.create(null);\n itemMetadata: Record<string, ItemResponseMeta> = Object.create(null);\n events: SurveyEvent[] = [];\n context?: SurveyResponseContext;\n evaluationContext?: ResponseEvaluationContext;\n\n constructor(key: string) {\n this.key = key;\n }\n\n /** Collect an engine item view into a flat submission, rejecting ambiguous ownership. */\n addItemResponse(item: SurveyItemResponse): void {\n const slots = item.response?.serialize()?.slots ?? {};\n for (const slotId of Object.keys(slots)) {\n if (Object.hasOwn(this.answers, slotId))\n throw new Error(`Duplicate submission slot: ${slotId}`);\n }\n Object.assign(this.answers, structuredClone(slots));\n if (item.meta) this.itemMetadata[item.itemId] = structuredClone(item.meta);\n }\n\n serialize(): JsonSurveyResponse {\n return structuredClone({\n schemaVersion: SURVEY_RESPONSE_SCHEMA_VERSION,\n key: this.key,\n participantId: this.participantId,\n submittedAt: this.submittedAt,\n answers: this.answers,\n itemMetadata: this.itemMetadata,\n events: this.events,\n context: this.context,\n evaluationContext: this.evaluationContext,\n });\n }\n\n static deserialize(json: JsonSurveyResponse): SurveyResponse {\n if (!json || typeof json !== \"object\" || Array.isArray(json))\n throw new Error(\"Invalid survey response payload\");\n if (json.schemaVersion !== SURVEY_RESPONSE_SCHEMA_VERSION)\n throw new Error(`Unsupported survey response schema version: ${String(json.schemaVersion)}`);\n if (typeof json.key !== \"string\" || !json.key.trim())\n throw new Error(\"Survey response is missing a valid key\");\n const readValues = (value: unknown, name: string): Record<string, ResponseValue> => {\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n throw new Error(`Invalid ${name} object`);\n const values: Record<string, ResponseValue> = Object.create(null);\n for (const [key, entry] of Object.entries(value)) {\n if (!key.trim()) throw new Error(`Empty ${name} key`);\n assertResponseValue(entry, `${name}.${key}`);\n values[key] = structuredClone(entry);\n }\n return values;\n };\n const response = new SurveyResponse(json.key);\n response.answers = readValues(json.answers, \"answers\");\n response.participantId = json.participantId;\n response.submittedAt = json.submittedAt;\n if (\n json.itemMetadata !== undefined &&\n (!json.itemMetadata ||\n typeof json.itemMetadata !== \"object\" ||\n Array.isArray(json.itemMetadata))\n )\n throw new Error(\"Invalid itemMetadata object\");\n response.itemMetadata = structuredClone(json.itemMetadata ?? {});\n if (!Array.isArray(json.events)) throw new Error(\"Invalid response events\");\n response.events = structuredClone(json.events);\n if (json.context !== undefined) response.context = readValues(json.context, \"context\");\n if (json.evaluationContext !== undefined) {\n const context = json.evaluationContext;\n if (\n !context ||\n typeof context !== \"object\" ||\n typeof context.locale !== \"string\" ||\n !context.locale ||\n (context.participantFlags !== undefined &&\n (!context.participantFlags ||\n typeof context.participantFlags !== \"object\" ||\n Array.isArray(context.participantFlags) ||\n Object.values(context.participantFlags).some((value) => typeof value !== \"string\")))\n )\n throw new Error(\"Invalid response evaluation context\");\n response.evaluationContext = structuredClone(context);\n }\n return response;\n }\n}\n\nexport interface JsonSurveyResponse {\n schemaVersion: typeof SURVEY_RESPONSE_SCHEMA_VERSION;\n key: string;\n participantId?: string;\n submittedAt?: number;\n answers: Record<string, ResponseValue>;\n itemMetadata?: Record<string, ItemResponseMeta>;\n events: SurveyEvent[];\n context?: SurveyResponseContext;\n evaluationContext?: ResponseEvaluationContext;\n}\n","import { calendarDateFromLocalDate } from \"../../calendar-date\";\nimport { DurationUnits, ResponseValue, ValueType } from \"./value-types\";\n\nexport const initValueForType = (returnType: ValueType): ResponseValue => {\n switch (returnType) {\n case ValueType.string:\n return {\n type: ValueType.string,\n value: \"\",\n };\n case ValueType.number:\n return {\n type: ValueType.number,\n value: 0,\n };\n case ValueType.boolean:\n return {\n type: ValueType.boolean,\n value: false,\n };\n case ValueType.date:\n return {\n type: ValueType.date,\n value: calendarDateFromLocalDate(new Date()),\n };\n case ValueType.stringArray:\n return {\n type: ValueType.stringArray,\n value: [],\n };\n case ValueType.numberArray:\n return {\n type: ValueType.numberArray,\n value: [],\n };\n case ValueType.dateArray:\n return {\n type: ValueType.dateArray,\n value: [],\n };\n case ValueType.duration:\n return {\n type: ValueType.duration,\n value: 0,\n unit: DurationUnits.seconds,\n };\n case ValueType.reference:\n return {\n type: ValueType.reference,\n value: \"\",\n };\n case ValueType.durationArray:\n return {\n type: ValueType.durationArray,\n value: [],\n unit: DurationUnits.seconds,\n };\n case ValueType.referenceArray:\n return {\n type: ValueType.referenceArray,\n value: [],\n };\n default:\n throw new Error(\"Invalid return type: \" + returnType);\n }\n};\n","import { isResponseValue, type ResponseValue, type ValueType } from \"./value-types\";\n\n/** Finite domains describe individual selectable values, including for array slots. */\nexport function responseValueElements(value: ResponseValue): ResponseValue[] {\n if (!Array.isArray(value.value)) return [value];\n const type = value.type.slice(0, -2) as ValueType;\n return value.value.map((entry) => ({ ...value, type, value: entry }) as ResponseValue);\n}\n\nexport function responseValuesEqual(left: ResponseValue, right: ResponseValue): boolean {\n return (\n left.type === right.type &&\n JSON.stringify(left.value) === JSON.stringify(right.value) &&\n (!(\"unit\" in left) || (\"unit\" in right && left.unit === right.unit))\n );\n}\n\n/** No coercion: an export code or label is never a categorical option identity. */\nexport function invalidResponseDomainValues(\n value: ResponseValue,\n allowedValues: readonly ResponseValue[],\n): ResponseValue[] {\n const domain = allowedValues.flatMap(responseValueElements);\n return responseValueElements(value).filter(\n (entry) => !domain.some((allowed) => responseValuesEqual(entry, allowed)),\n );\n}\n\nexport function validateResponseSlotValue(\n slot: { slotId: string; valueType: ValueType; allowedValues?: readonly ResponseValue[] },\n value: unknown,\n): string[] {\n if (!isResponseValue(value)) return [`Slot \"${slot.slotId}\" has an invalid typed value.`];\n if (value.type !== slot.valueType)\n return [`Slot \"${slot.slotId}\" requires ${slot.valueType}, received ${value.type}.`];\n if (!slot.allowedValues) return [];\n return invalidResponseDomainValues(value, slot.allowedValues).map(\n (entry) =>\n `Slot \"${slot.slotId}\" contains invalid value ${JSON.stringify(entry)}. Allowed values: ${JSON.stringify(slot.allowedValues)}.`,\n );\n}\n","export const RESPONSE_VARIABLE_NAME_MAX_LENGTH = 32;\nexport const isValidResponseVariableName = (name: string): boolean =>\n name.length <= RESPONSE_VARIABLE_NAME_MAX_LENGTH && /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/.test(name);\n\n/** Generate an initial suggestion; explicit rename operations validate instead of coercing. */\nexport function suggestResponseVariableName(text: string, fallback = \"response\"): string {\n const normalized = text\n .replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n .normalize(\"NFKD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n const value = /^[a-z]/.test(normalized) ? normalized : `${fallback}_${normalized}`;\n return (value || fallback).slice(0, RESPONSE_VARIABLE_NAME_MAX_LENGTH).replace(/_+$/g, \"\");\n}\n\nexport function allocateResponseVariableName(\n base: string,\n used: ReadonlySet<string>,\n maxLength = RESPONSE_VARIABLE_NAME_MAX_LENGTH,\n): string {\n if (!isValidResponseVariableName(base))\n throw new Error(\n `Invalid response variable name \"${base}\"; use lowercase snake_case, starting with a letter, at most 32 characters`,\n );\n if (base.length <= maxLength && !used.has(base)) return base;\n const indexed = /^(.*)_([1-9][0-9]*)$/.exec(base);\n const stemBase = indexed ? indexed[1] : base;\n const start = indexed ? BigInt(indexed[2]) + 1n : 2n;\n for (let n = start; ; n++) {\n const suffix = `_${n}`;\n const stem = stemBase.slice(0, Math.max(0, maxLength - suffix.length)).replace(/_+$/g, \"\");\n if (!stem) throw new Error(\"The variable naming suffix leaves no room for a name\");\n const name = `${stem}${suffix}`;\n if (!used.has(name)) return name;\n }\n}\n\n/** Paths are derived from the current declaration, never used as persistent answer identities. */\nexport type ResponseNamingSource =\n | { kind: \"variable\"; path: (string | number)[] }\n | {\n kind: \"matrix\";\n prefixPath: (string | number)[];\n rowPath?: (string | number)[];\n columnPath?: (string | number)[];\n suffix?: string;\n };\n","import { isValidResponseVariableName } from \"./variable-naming\";\nimport type { ResponseSlotDefinition } from \"./slot-definition\";\nimport { isResponseValue, ValueType } from \"./value-types\";\nimport { responseValueElements, validateResponseSlotValue } from \"./value-domain\";\n\nexport interface OwnedResponseSlotDefinition extends ResponseSlotDefinition {\n itemId: string;\n primitiveId: string;\n}\n\nexport interface ResponseSlotDiagnostic {\n code:\n | \"duplicate-slot-id\"\n | \"invalid-slot\"\n | \"invalid-domain\"\n | \"invalid-variable-name\"\n | \"duplicate-variable-name\"\n | \"unknown-dependency\"\n | \"computed-cycle\"\n | \"unknown-slot\"\n | \"invalid-answer\";\n slotId: string;\n itemId?: string;\n message: string;\n}\n\n/** A detached, derived index. Ambiguous identities never resolve to an arbitrary owner. */\nexport class ResponseSlotRegistry {\n private readonly slots = new Map<string, OwnedResponseSlotDefinition>();\n readonly diagnostics: ResponseSlotDiagnostic[] = [];\n\n constructor(\n declarations: readonly { itemId: string; slots: readonly ResponseSlotDefinition[] }[],\n ) {\n const seen = new Set<string>();\n for (const declaration of declarations) {\n for (const definition of declaration.slots) {\n const slot: OwnedResponseSlotDefinition = structuredClone({\n ...definition,\n itemId: declaration.itemId,\n primitiveId: definition.primitiveId ?? declaration.itemId,\n });\n if (\n !slot.slotId.trim() ||\n !slot.primitiveId.trim() ||\n !slot.itemId.trim() ||\n !Object.values(ValueType).includes(slot.valueType)\n ) {\n this.diagnostics.push({\n code: \"invalid-slot\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: \"Response slots require nonempty identities and a supported value type.\",\n });\n continue;\n }\n if (seen.has(slot.slotId)) {\n this.slots.delete(slot.slotId);\n this.diagnostics.push({\n code: \"duplicate-slot-id\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: `Slot \"${slot.slotId}\" is declared more than once. Allocate unique persistent identities before using this schema.`,\n });\n continue;\n }\n seen.add(slot.slotId);\n this.slots.set(slot.slotId, slot);\n const elementType = slot.valueType.endsWith(\"[]\")\n ? slot.valueType.slice(0, -2)\n : slot.valueType;\n if (\n slot.allowedValues?.some(\n (value) =>\n !isResponseValue(value) ||\n responseValueElements(value).some((entry) => entry.type !== elementType),\n )\n ) {\n this.diagnostics.push({\n code: \"invalid-domain\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: `The allowed values for slot \"${slot.slotId}\" must have type ${elementType}.`,\n });\n }\n if (\n slot.referenceValueScores &&\n ((slot.valueType !== ValueType.reference &&\n slot.valueType !== ValueType.referenceArray) ||\n Object.entries(slot.referenceValueScores).some(\n ([id, score]) =>\n !Number.isFinite(score) ||\n (slot.allowedValues &&\n !slot.allowedValues.some(\n (value) => value.type === ValueType.reference && value.value === id,\n )),\n ))\n ) {\n this.diagnostics.push({\n code: \"invalid-domain\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: `Scores for slot \"${slot.slotId}\" must map allowed option IDs to finite numbers.`,\n });\n }\n }\n }\n const names = new Map<string, string>();\n for (const slot of this.slots.values()) {\n if (typeof slot.variableName !== \"string\" || !isValidResponseVariableName(slot.variableName))\n this.diagnostics.push({\n code: \"invalid-variable-name\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: `Variable \"${slot.variableName}\" must use lowercase snake_case, start with a letter and contain at most 32 characters.`,\n });\n const previous = names.get(slot.variableName);\n if (previous)\n this.diagnostics.push({\n code: \"duplicate-variable-name\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: `Variable name \"${slot.variableName}\" is already used by slot \"${previous}\".`,\n });\n names.set(slot.variableName, slot.slotId);\n }\n for (const slot of this.slots.values()) {\n for (const dependency of slot.computed?.sourceSlotIds ?? []) {\n if (!this.slots.has(dependency))\n this.diagnostics.push({\n code: \"unknown-dependency\",\n slotId: slot.slotId,\n itemId: slot.itemId,\n message: `Computed slot \"${slot.slotId}\" depends on unknown or ambiguous slot \"${dependency}\".`,\n });\n }\n }\n const active = new Set<string>();\n const visited = new Set<string>();\n const visit = (id: string) => {\n if (active.has(id)) {\n this.diagnostics.push({\n code: \"computed-cycle\",\n slotId: id,\n message: `Computed slot \"${id}\" participates in a dependency cycle.`,\n });\n return;\n }\n if (visited.has(id)) return;\n active.add(id);\n for (const dependency of this.slots.get(id)?.computed?.sourceSlotIds ?? []) visit(dependency);\n active.delete(id);\n visited.add(id);\n };\n for (const id of this.slots.keys()) visit(id);\n }\n\n get(slotId: string): OwnedResponseSlotDefinition | undefined {\n const slot = this.slots.get(slotId);\n return slot && structuredClone(slot);\n }\n\n get definitions(): OwnedResponseSlotDefinition[] {\n return structuredClone([...this.slots.values()]);\n }\n\n assertValid(): void {\n if (this.diagnostics.length)\n throw new Error(this.diagnostics.map((entry) => entry.message).join(\"\\n\"));\n }\n\n validateAnswers(answers: Readonly<Record<string, unknown>>): ResponseSlotDiagnostic[] {\n const diagnostics = [...this.diagnostics];\n for (const [slotId, value] of Object.entries(answers)) {\n const slot = this.slots.get(slotId);\n if (!slot) {\n diagnostics.push({\n code: \"unknown-slot\",\n slotId,\n message: `Answer references unknown or ambiguous slot \"${slotId}\".`,\n });\n continue;\n }\n const issues = slot.computed\n ? [`Computed slot \"${slotId}\" cannot contain a stored answer.`]\n : validateResponseSlotValue(slot, value);\n for (const message of issues)\n diagnostics.push({ code: \"invalid-answer\", slotId, itemId: slot.itemId, message });\n }\n return diagnostics;\n }\n}\n","export enum ValueReferenceMethod {\n get = \"get\",\n isDefined = \"isDefined\",\n}\n\nexport interface JsonValueReference {\n slotId: string;\n method: \"get\" | \"isDefined\";\n}\n\n/** Slot identity is opaque. String keys are an internal JSON-tuple lookup codec. */\nexport class ValueReference {\n readonly slotId: string;\n readonly name: ValueReferenceMethod;\n\n constructor(reference: JsonValueReference | string) {\n let value: unknown = reference;\n if (typeof reference === \"string\") {\n const tuple: unknown = JSON.parse(reference);\n if (!Array.isArray(tuple) || tuple.length !== 2)\n throw new Error(\"Invalid response-reference lookup key\");\n value = { slotId: tuple[0], method: tuple[1] };\n }\n const parsed = value as Partial<JsonValueReference> | undefined;\n if (\n !parsed ||\n typeof parsed.slotId !== \"string\" ||\n !parsed.slotId.trim() ||\n (parsed.method !== \"get\" && parsed.method !== \"isDefined\")\n )\n throw new Error(\"Response references require a slotId and get or isDefined method\");\n this.slotId = parsed.slotId;\n this.name = parsed.method as ValueReferenceMethod;\n }\n\n serialize(): JsonValueReference {\n return { slotId: this.slotId, method: this.name };\n }\n toString(): string {\n return JSON.stringify([this.slotId, this.name]);\n }\n static fromParts(slotId: string, method: ValueReferenceMethod): ValueReference {\n return new ValueReference({ slotId, method });\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 { assertResponseValue } from \"../survey/responses/value-types\";\nimport { ResponseValue, ValueType } from \"../survey/responses\";\nimport { ValueReference, type JsonValueReference } 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: JsonValueReference;\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 if (value?.type === \"date\" || value?.type === \"date[]\")\n assertResponseValue(value, \"expression.value\");\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: JsonValueReference | string, editorConfig?: ExpressionEditorConfig) {\n super(ExpressionType.ResponseVariable, editorConfig);\n this.variableRef = new ValueReference(variableRef).toString();\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 if (typeof json.variableRef !== \"object\")\n throw new Error(\"Response expressions require a structured slot reference\");\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.responseVariableRef.serialize(),\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 [this.key, ...(this.arguments ?? [])].flatMap((arg) => arg?.responseVariableRefs ?? []);\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 date_gt = \"date_gt\",\n date_gte = \"date_gte\",\n date_lt = \"date_lt\",\n date_lte = \"date_lte\",\n date_add_days = \"date_add_days\",\n date_add_months = \"date_add_months\",\n date_add_years = \"date_add_years\",\n date_diff = \"date_diff\",\n date_min = \"date_min\",\n date_max = \"date_max\",\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 {\n isCalendarDate,\n compareCalendarDates,\n addCalendarDate,\n differenceCalendarDates,\n} from \"../calendar-date\";\nimport {\n BooleanResponse,\n NumberResponse,\n ResponseValue,\n SurveyItemResponse,\n ValueType,\n} from \"../survey/responses\";\nimport { ValueReferenceMethod } from \"../survey/utils/value-reference\";\nimport { SurveyContext } from \"../survey/utils/context\";\nimport {\n ConstExpression,\n ContextVariableExpression,\n ContextVariableType,\n Expression,\n ExpressionType,\n FunctionExpression,\n FunctionExpressionNames,\n ResponseVariableExpression,\n} from \"./expression\";\n\nexport interface ExpressionContext {\n surveyContext: SurveyContext;\n resolveComputedValue?: (slotId: string) => ResponseValue | undefined;\n resolveResponseValue?: (slotId: string) => ResponseValue | undefined;\n responses: {\n [key: string]: SurveyItemResponse;\n };\n}\n\nexport class ExpressionEvaluator {\n private context?: ExpressionContext;\n\n constructor(context?: ExpressionContext) {\n this.context = context;\n }\n\n eval(expression: Expression | undefined): ResponseValue | undefined {\n if (expression === undefined) {\n return undefined;\n }\n switch (expression.type) {\n case ExpressionType.Const:\n return this.evaluateConst(expression as ConstExpression);\n case ExpressionType.Function:\n return this.evaluateFunction(expression as FunctionExpression);\n case ExpressionType.ResponseVariable:\n return this.evaluateResponseVariable(expression as ResponseVariableExpression);\n case ExpressionType.ContextVariable:\n return this.evaluateContextVariable(expression as ContextVariableExpression);\n default:\n throw new Error(`Unsupported expression type: ${expression.type}`);\n }\n }\n\n setContext(context: ExpressionContext) {\n this.context = context;\n }\n\n private evaluateConst(expression: ConstExpression): ResponseValue | undefined {\n return expression.value;\n }\n\n private resolveStoredValue(slotId: string): ResponseValue | undefined {\n if (this.context?.resolveResponseValue) return this.context.resolveResponseValue(slotId);\n const values = Object.values(this.context?.responses ?? {})\n .map((item) => item.response?.get(slotId))\n .filter((value) => value !== undefined);\n if (values.length > 1) throw new Error(`Ambiguous response slot \"${slotId}\"`);\n return values[0];\n }\n\n private evaluateResponseVariable(\n expression: ResponseVariableExpression,\n ): ResponseValue | undefined {\n const varRef = expression.responseVariableRef;\n\n switch (varRef.name) {\n case ValueReferenceMethod.get:\n return (\n this.context?.resolveComputedValue?.(varRef.slotId) ??\n this.resolveStoredValue(varRef.slotId)\n );\n case ValueReferenceMethod.isDefined:\n return {\n type: ValueType.boolean,\n value:\n (this.context?.resolveComputedValue?.(varRef.slotId) ??\n this.resolveStoredValue(varRef.slotId)) !== undefined,\n };\n default:\n throw new Error(`Unsupported value reference method: ${varRef.name}`);\n }\n }\n\n private evaluateFunction(expression: FunctionExpression): ResponseValue | undefined {\n switch (expression.functionName) {\n case FunctionExpressionNames.and:\n return this.evaluateAnd(expression);\n case FunctionExpressionNames.or:\n return this.evaluateOr(expression);\n case FunctionExpressionNames.not:\n return this.evaluateNot(expression);\n case FunctionExpressionNames.date_eq:\n case FunctionExpressionNames.date_gt:\n case FunctionExpressionNames.date_gte:\n case FunctionExpressionNames.date_lt:\n case FunctionExpressionNames.date_lte:\n case FunctionExpressionNames.date_add_days:\n case FunctionExpressionNames.date_add_months:\n case FunctionExpressionNames.date_add_years:\n case FunctionExpressionNames.date_diff:\n case FunctionExpressionNames.date_min:\n case FunctionExpressionNames.date_max:\n return this.evaluateDateFunction(expression);\n // string methods:\n case FunctionExpressionNames.str_eq:\n return this.evaluateStrEq(expression);\n // numeric methods:\n case FunctionExpressionNames.eq:\n return this.evaluateEq(expression);\n case FunctionExpressionNames.gt:\n return this.evaluateGt(expression);\n case FunctionExpressionNames.gte:\n return this.evaluateGte(expression);\n case FunctionExpressionNames.lt:\n return this.evaluateLt(expression);\n case FunctionExpressionNames.lte:\n return this.evaluateLte(expression);\n case FunctionExpressionNames.in_range:\n return this.evaluateInRange(expression);\n case FunctionExpressionNames.sum:\n return this.evaluateSum(expression);\n case FunctionExpressionNames.min:\n return this.evaluateMin(expression);\n case FunctionExpressionNames.max:\n return this.evaluateMax(expression);\n // list methods:\n case FunctionExpressionNames.list_contains:\n return this.evaluateListContains(expression);\n\n default:\n throw new Error(`Unsupported function: ${expression.functionName}`);\n }\n // TODO: implement function evaluation\n return undefined;\n }\n\n private evaluateContextVariable(\n expression: ContextVariableExpression,\n ): ResponseValue | undefined {\n if (!this.context?.surveyContext) {\n return undefined;\n }\n\n const surveyContext = this.context.surveyContext;\n\n switch (expression.contextType) {\n case ContextVariableType.Locale:\n return {\n type: ValueType.string,\n value: surveyContext.locale,\n };\n\n case ContextVariableType.ParticipantFlag: {\n if (!expression.key) {\n return undefined;\n }\n\n const flagKey = this.eval(expression.key);\n if (flagKey?.type !== ValueType.string || flagKey.value === undefined) {\n return undefined;\n }\n\n const flagValue = surveyContext.participantFlags?.[flagKey.value];\n\n // Handle different return types for participant flags\n switch (expression.asType) {\n case ValueType.boolean:\n // exists?\n return { type: ValueType.boolean, value: flagValue !== undefined };\n case ValueType.string:\n if (flagValue === undefined) {\n return undefined;\n }\n return { type: ValueType.string, value: flagValue };\n case ValueType.number: {\n if (flagValue === undefined) {\n return undefined;\n }\n const numValue = parseFloat(flagValue);\n return isNaN(numValue) ? undefined : { type: ValueType.number, value: numValue };\n }\n case ValueType.date: {\n if (flagValue === undefined) {\n return undefined;\n }\n return isCalendarDate(flagValue)\n ? { type: ValueType.date, value: flagValue }\n : undefined;\n }\n default:\n if (flagValue === undefined) {\n return undefined;\n }\n return { type: ValueType.string, value: flagValue };\n }\n }\n\n case ContextVariableType.CustomValue: {\n if (!expression.key) {\n return undefined;\n }\n\n const customKey = this.eval(expression.key);\n if (customKey?.type !== ValueType.string || customKey.value === undefined) {\n return undefined;\n }\n\n const customValue = surveyContext.customValues?.[customKey.value];\n if (customValue === undefined) {\n return undefined;\n }\n\n // Type checking for custom values\n if (expression.asType !== undefined) {\n if (customValue?.type !== expression.asType) {\n throw new Error(\n `Custom value type does not match expected type, got ${customValue?.type} and expected ${expression.asType}`,\n );\n }\n }\n return customValue;\n }\n\n case ContextVariableType.CustomExpression: {\n if (!expression.key) {\n return undefined;\n }\n\n const expressionKey = this.eval(expression.key);\n if (expressionKey?.type !== ValueType.string || expressionKey.value === undefined) {\n return undefined;\n }\n\n const customExpression = surveyContext.customExpressions?.[expressionKey.value];\n if (typeof customExpression !== ExpressionType.Function || customExpression === undefined) {\n return undefined;\n }\n\n try {\n const args = expression.arguments;\n const result = customExpression(args);\n\n // Type checking for custom expression results\n\n if (expression.asType !== undefined) {\n if (result?.type !== expression.asType) {\n throw new Error(\n `Custom expression result type does not match expected type, got ${result?.type} and expected ${expression.asType}`,\n );\n }\n }\n return result;\n } catch (error) {\n throw new Error(`Error evaluating custom expression: ${error}`);\n }\n }\n }\n }\n\n private evaluateDateFunction(expression: FunctionExpression): ResponseValue | undefined {\n const name = expression.functionName;\n const aggregate =\n name === FunctionExpressionNames.date_min || name === FunctionExpressionNames.date_max;\n if (aggregate ? expression.arguments.length < 1 : expression.arguments.length !== 2)\n throw new Error(`${name} expects ${aggregate ? \"at least 1 argument\" : \"2 arguments\"}`);\n const args = expression.arguments.map((arg) => this.eval(arg));\n if (args.some((arg) => arg === undefined)) return undefined;\n const first = args[0];\n if (first?.type !== ValueType.date || !isCalendarDate(first.value)) return undefined;\n if (name.startsWith(\"date_add_\")) {\n const amount = args[1];\n if (amount?.type !== ValueType.number) return undefined;\n const unit =\n name === FunctionExpressionNames.date_add_days\n ? \"days\"\n : name === FunctionExpressionNames.date_add_months\n ? \"months\"\n : \"years\";\n const value = addCalendarDate(first.value, amount.value, unit);\n return value === undefined ? undefined : { type: ValueType.date, value };\n }\n const dates: string[] = [];\n for (const arg of args) {\n if (arg?.type !== ValueType.date || !isCalendarDate(arg.value)) return undefined;\n dates.push(arg.value);\n }\n if (name === FunctionExpressionNames.date_eq)\n return { type: ValueType.boolean, value: dates[0] === dates[1] };\n if (dates.some((date) => date.length !== first.value.length)) return undefined;\n if (aggregate)\n return {\n type: ValueType.date,\n value: dates.reduce((a, b) =>\n name === FunctionExpressionNames.date_min ? (a < b ? a : b) : a > b ? a : b,\n ),\n };\n if (name === FunctionExpressionNames.date_diff)\n return { type: ValueType.number, value: differenceCalendarDates(dates[0], dates[1])! };\n const comparison = compareCalendarDates(dates[0], dates[1])!;\n return {\n type: ValueType.boolean,\n value:\n name === FunctionExpressionNames.date_gt\n ? comparison > 0\n : name === FunctionExpressionNames.date_gte\n ? comparison >= 0\n : name === FunctionExpressionNames.date_lt\n ? comparison < 0\n : comparison <= 0,\n };\n }\n\n private evaluateAnd(expression: FunctionExpression): BooleanResponse {\n return {\n type: ValueType.boolean,\n value: expression.arguments.every((arg) => this.eval(arg)?.value === true),\n };\n }\n\n private evaluateOr(expression: FunctionExpression): BooleanResponse {\n return {\n type: ValueType.boolean,\n value: expression.arguments.some((arg) => this.eval(arg)?.value === true),\n };\n }\n\n private evaluateNot(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 1 || expression.arguments[0] === undefined) {\n throw new Error(`Not function expects 1 argument, got ${expression.arguments.length}`);\n }\n\n const resolvedValue = this.eval(expression.arguments[0]);\n if (resolvedValue?.type !== ValueType.boolean) {\n throw new Error(`Not function expects a boolean argument, got ${resolvedValue?.type}`);\n }\n\n if (resolvedValue === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n return {\n type: ValueType.boolean,\n value: !resolvedValue.value,\n };\n }\n\n private evaluateListContains(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(\n `List contains function expects 2 arguments, got ${expression.arguments.length}`,\n );\n }\n const resolvedList = this.eval(expression.arguments[0]);\n const resolvedItem = this.eval(expression.arguments[1]);\n\n if (resolvedList === undefined || resolvedItem === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n const allowedListTypes = [ValueType.stringArray, ValueType.referenceArray] as string[];\n const allowedItemTypes = [ValueType.string, ValueType.reference] as string[];\n\n const resolvedListType = resolvedList.type as ValueType;\n const resolvedItemType = resolvedItem.type as ValueType;\n\n if (\n !allowedListTypes.includes(resolvedListType) ||\n !allowedItemTypes.includes(resolvedItemType)\n ) {\n throw new Error(\n `List contains function expects a string array list and a string item, got ${resolvedList?.type} and ${resolvedItem?.type}`,\n );\n }\n\n const list = resolvedList.value as string[];\n const item = resolvedItem.value as string;\n\n return {\n type: ValueType.boolean,\n value: list.includes(item),\n };\n }\n\n private evaluateStrEq(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(\n `String equals function expects 2 arguments, got ${expression.arguments.length}`,\n );\n }\n const resolvedA = this.eval(expression.arguments[0]);\n const resolvedB = this.eval(expression.arguments[1]);\n\n if (resolvedA === undefined || resolvedB === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (resolvedA?.type !== ValueType.string || resolvedB?.type !== ValueType.string) {\n throw new Error(\n `String equals function expects strings for all arguments, got ${resolvedA?.type} and ${resolvedB?.type}`,\n );\n }\n\n return {\n type: ValueType.boolean,\n value: resolvedA.value === resolvedB.value,\n };\n }\n\n private evaluateEq(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(`Equals function expects 2 arguments, got ${expression.arguments.length}`);\n }\n const resolvedA = this.eval(expression.arguments[0]);\n const resolvedB = this.eval(expression.arguments[1]);\n\n if (resolvedA === undefined || resolvedB === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (resolvedA?.type !== resolvedB?.type) {\n throw new Error(\n `Equals function expects the same type for all arguments, got ${resolvedA?.type} and ${resolvedB?.type}`,\n );\n }\n\n return {\n type: ValueType.boolean,\n value: resolvedA.value === resolvedB.value,\n };\n }\n\n private evaluateGt(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(\n `Greater than function expects 2 arguments, got ${expression.arguments.length}`,\n );\n }\n const resolvedA = this.eval(expression.arguments[0]);\n const resolvedB = this.eval(expression.arguments[1]);\n\n if (resolvedA === undefined || resolvedB === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (resolvedA?.type !== resolvedB?.type) {\n throw new Error(\n `Greater than function expects the same type for all arguments, got ${resolvedA?.type} and ${resolvedB?.type}`,\n );\n }\n\n return {\n type: ValueType.boolean,\n value: resolvedA.value > resolvedB.value,\n };\n }\n\n private evaluateGte(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(\n `Greater than or equal to function expects 2 arguments, got ${expression.arguments.length}`,\n );\n }\n const resolvedA = this.eval(expression.arguments[0]);\n const resolvedB = this.eval(expression.arguments[1]);\n\n if (resolvedA === undefined || resolvedB === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (resolvedA?.type !== resolvedB?.type) {\n throw new Error(\n `Greater than or equal to function expects the same type for all arguments, got ${resolvedA?.type} and ${resolvedB?.type}`,\n );\n }\n\n return {\n type: ValueType.boolean,\n value: resolvedA.value >= resolvedB.value,\n };\n }\n\n private evaluateLt(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(`Less than function expects 2 arguments, got ${expression.arguments.length}`);\n }\n const resolvedA = this.eval(expression.arguments[0]);\n const resolvedB = this.eval(expression.arguments[1]);\n\n if (resolvedA === undefined || resolvedB === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (resolvedA?.type !== resolvedB?.type) {\n throw new Error(\n `Less than function expects the same type for all arguments, got ${resolvedA?.type} and ${resolvedB?.type}`,\n );\n }\n\n return {\n type: ValueType.boolean,\n value: resolvedA.value < resolvedB.value,\n };\n }\n\n private evaluateLte(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 2) {\n throw new Error(\n `Less than or equal to function expects 2 arguments, got ${expression.arguments.length}`,\n );\n }\n const resolvedA = this.eval(expression.arguments[0]);\n const resolvedB = this.eval(expression.arguments[1]);\n\n if (resolvedA === undefined || resolvedB === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (resolvedA?.type !== resolvedB?.type) {\n throw new Error(\n `Less than or equal to function expects the same type for all arguments, got ${resolvedA?.type} and ${resolvedB?.type}`,\n );\n }\n\n return {\n type: ValueType.boolean,\n value: resolvedA.value <= resolvedB.value,\n };\n }\n\n private evaluateInRange(expression: FunctionExpression): BooleanResponse {\n if (expression.arguments.length !== 4) {\n throw new Error(`In range function expects 4 arguments, got ${expression.arguments.length}`);\n }\n const resolvedValue = this.eval(expression.arguments[0]);\n const resolvedMin = this.eval(expression.arguments[1]);\n const resolvedMax = this.eval(expression.arguments[2]);\n const resolvedInclusive = this.eval(expression.arguments[3])?.value === true;\n\n if (resolvedValue === undefined || resolvedMin === undefined || resolvedMax === undefined) {\n return {\n type: ValueType.boolean,\n value: false,\n };\n }\n\n if (\n resolvedValue?.type !== ValueType.number ||\n resolvedMin?.type !== ValueType.number ||\n resolvedMax?.type !== ValueType.number\n ) {\n throw new Error(\n `In range function expects numbers for all arguments, got ${resolvedValue?.type} and ${resolvedMin?.type} and ${resolvedMax?.type}`,\n );\n }\n\n if (resolvedInclusive) {\n return {\n type: ValueType.boolean,\n value: resolvedValue.value >= resolvedMin.value && resolvedValue.value <= resolvedMax.value,\n };\n }\n return {\n type: ValueType.boolean,\n value: resolvedValue.value > resolvedMin.value && resolvedValue.value < resolvedMax.value,\n };\n }\n\n private evaluateSum(expression: FunctionExpression): NumberResponse {\n if (expression.arguments.length < 1) {\n throw new Error(\n `Sum function expects at least 1 argument, got ${expression.arguments.length}`,\n );\n }\n return expression.arguments.reduce(\n (sum, arg) => {\n if (arg === undefined) {\n return sum;\n }\n const resolvedValue = this.eval(arg);\n if (resolvedValue === undefined) {\n return sum;\n }\n if (resolvedValue?.type === ValueType.number) {\n return {\n type: ValueType.number,\n value: sum.value + resolvedValue.value,\n };\n }\n throw new Error(\n `Sum function expects all arguments to be numbers, got ${resolvedValue?.type}`,\n );\n },\n {\n type: ValueType.number,\n value: 0,\n },\n );\n }\n\n private evaluateMin(expression: FunctionExpression): NumberResponse {\n if (expression.arguments.length < 1) {\n throw new Error(\n `Min function expects at least 1 argument, got ${expression.arguments.length}`,\n );\n }\n return expression.arguments.reduce(\n (min, arg) => {\n if (arg === undefined) {\n return min;\n }\n const resolvedValue = this.eval(arg);\n if (resolvedValue === undefined) {\n return min;\n }\n if (resolvedValue?.type === ValueType.number) {\n return {\n type: ValueType.number,\n value: Math.min(min.value, resolvedValue.value),\n };\n }\n throw new Error(\n `Min function expects all arguments to be numbers, got ${typeof resolvedValue}`,\n );\n },\n {\n type: ValueType.number,\n value: Infinity,\n },\n );\n }\n\n private evaluateMax(expression: FunctionExpression): NumberResponse {\n if (expression.arguments.length < 1) {\n throw new Error(\n `Max function expects at least 1 argument, got ${expression.arguments.length}`,\n );\n }\n return expression.arguments.reduce(\n (max, arg) => {\n if (arg === undefined) {\n return max;\n }\n const resolvedValue = this.eval(arg);\n if (resolvedValue === undefined) {\n return max;\n }\n if (resolvedValue?.type === ValueType.number) {\n return {\n type: ValueType.number,\n value: Math.max(max.value, resolvedValue.value),\n };\n }\n throw new Error(\n `Max function expects all arguments to be numbers, got ${typeof resolvedValue}`,\n );\n },\n {\n type: ValueType.number,\n value: -Infinity,\n },\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","import { ValueType } from \"../survey/responses/value-types\";\n\n/** Shared signatures used by authoring, reference diagnostics and assistant validation. */\nexport const DATE_FUNCTION_SIGNATURES: Record<\n string,\n { args: ValueType[]; variadic?: boolean; returns: ValueType }\n> = {\n date_eq: { args: [ValueType.date, ValueType.date], returns: ValueType.boolean },\n date_gt: { args: [ValueType.date, ValueType.date], returns: ValueType.boolean },\n date_gte: { args: [ValueType.date, ValueType.date], returns: ValueType.boolean },\n date_lt: { args: [ValueType.date, ValueType.date], returns: ValueType.boolean },\n date_lte: { args: [ValueType.date, ValueType.date], returns: ValueType.boolean },\n date_add_days: { args: [ValueType.date, ValueType.number], returns: ValueType.date },\n date_add_months: { args: [ValueType.date, ValueType.number], returns: ValueType.date },\n date_add_years: { args: [ValueType.date, ValueType.number], returns: ValueType.date },\n date_diff: { args: [ValueType.date, ValueType.date], returns: ValueType.number },\n date_min: { args: [ValueType.date], variadic: true, returns: ValueType.date },\n date_max: { args: [ValueType.date], variadic: true, returns: ValueType.date },\n};\n","import { DATE_FUNCTION_SIGNATURES } from \"./date-functions\";\nimport type { RawSurvey } from \"../survey/survey-file-schema\";\nimport type { RawSurveyItem } from \"../survey/items\";\nimport { ValueType, type ResponseValue } from \"../survey/responses/value-types\";\nimport { invalidResponseDomainValues } from \"../survey/responses/value-domain\";\nimport { ValueReference } from \"../survey/utils/value-reference\";\nimport {\n Expression,\n ExpressionType,\n FunctionExpressionNames,\n type JsonExpression,\n} from \"./expression\";\n\nexport interface SurveyExpressionLocation {\n expression: JsonExpression;\n location: string;\n ownerItemId?: string;\n ownerItemKey?: string;\n ownerScope: \"component\" | \"item\" | \"survey\";\n surface:\n | \"display-condition\"\n | \"disabled-condition\"\n | \"validation\"\n | \"prefill-condition\"\n | \"prefill-source\"\n | \"template-value\";\n}\n\n// Adding an owner scope or expression surface requires an explicit decision about whether it\n// contributes edges to the currently item-scoped visibility graph.\nconst ITEM_DISPLAY_DEPENDENCY_OWNER_SCOPE_POLICY = {\n component: false,\n item: true,\n survey: false,\n} as const satisfies Record<SurveyExpressionLocation[\"ownerScope\"], boolean>;\n\nconst ITEM_DISPLAY_DEPENDENCY_SURFACE_POLICY = {\n \"display-condition\": true,\n \"disabled-condition\": false,\n validation: false,\n \"prefill-condition\": false,\n \"prefill-source\": false,\n \"template-value\": false,\n} as const satisfies Record<SurveyExpressionLocation[\"surface\"], boolean>;\n\nexport interface SurveyExpressionResponseSlot {\n ref: string;\n itemId?: string;\n valueType: ValueType;\n allowedReferenceValues?: string[];\n allowedValues?: ResponseValue[];\n}\n\nexport type SurveyExpressionReferenceDiagnosticCode =\n | \"invalid-expression\"\n | \"unknown-response-ref\"\n | \"expression-reference-type-mismatch\"\n | \"unknown-reference-value\"\n | \"display-condition-cycle\";\n\nexport type SurveyExpressionReferenceDiagnosticDisposition = \"advisory\" | \"blocking\";\nexport type SurveyExpressionReferenceDiagnosticCategory =\n | \"display-dependency\"\n | \"reference-integrity\";\n\nexport interface SurveyExpressionReferenceDiagnosticPolicy {\n category: SurveyExpressionReferenceDiagnosticCategory;\n disposition: SurveyExpressionReferenceDiagnosticDisposition;\n}\n\n/**\n * Display-condition cycles prevent active-response evaluation, even with prefills.\n * This item-level analysis is complemented by ActiveResponsePlan's full runtime graph,\n * which also includes inherited visibility, component activation and computed dependencies.\n */\nexport const SURVEY_EXPRESSION_REFERENCE_DIAGNOSTIC_POLICY = {\n \"invalid-expression\": {\n category: \"reference-integrity\",\n disposition: \"blocking\",\n },\n \"unknown-response-ref\": {\n category: \"reference-integrity\",\n disposition: \"blocking\",\n },\n \"expression-reference-type-mismatch\": {\n category: \"reference-integrity\",\n disposition: \"blocking\",\n },\n \"unknown-reference-value\": {\n category: \"reference-integrity\",\n disposition: \"blocking\",\n },\n \"display-condition-cycle\": {\n category: \"display-dependency\",\n disposition: \"blocking\",\n },\n} as const satisfies Record<\n SurveyExpressionReferenceDiagnosticCode,\n SurveyExpressionReferenceDiagnosticPolicy\n>;\n\nexport interface SurveyExpressionReferenceDiagnostic {\n category: SurveyExpressionReferenceDiagnosticCategory;\n code: SurveyExpressionReferenceDiagnosticCode;\n disposition: SurveyExpressionReferenceDiagnosticDisposition;\n message: string;\n location: string;\n ownerItemId?: string;\n ownerItemKey?: string;\n reference?: string;\n referenceValue?: string;\n candidates?: string[];\n}\n\ntype SurveyExpressionReferenceDiagnosticInput = Omit<\n SurveyExpressionReferenceDiagnostic,\n \"category\" | \"disposition\"\n>;\n\nconst createExpressionReferenceDiagnostic = (\n diagnostic: SurveyExpressionReferenceDiagnosticInput,\n): SurveyExpressionReferenceDiagnostic => ({\n ...diagnostic,\n ...SURVEY_EXPRESSION_REFERENCE_DIAGNOSTIC_POLICY[diagnostic.code],\n});\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isJsonExpression = (value: unknown): value is JsonExpression =>\n isRecord(value) && typeof value.type === \"string\";\n\n/** Discover references even when a sibling expression is malformed and cannot deserialize. */\nexport function collectExpressionResponseReferences(expression: unknown): ValueReference[] {\n const refs = new Map<string, ValueReference>();\n const visit = (node: unknown) => {\n if (!isRecord(node)) return;\n if (node.type === ExpressionType.ResponseVariable && isRecord(node.variableRef)) {\n try {\n const reference = new ValueReference(\n node.variableRef as unknown as import(\"../survey/utils/value-reference\").JsonValueReference,\n );\n refs.set(reference.toString(), reference);\n } catch {\n // Invalid references remain the responsibility of integrity diagnostics.\n }\n }\n if (node.type === ExpressionType.ContextVariable) visit(node.key);\n if (node.type === ExpressionType.Function || node.type === ExpressionType.ContextVariable) {\n if (Array.isArray(node.arguments)) node.arguments.forEach(visit);\n }\n };\n visit(expression);\n return [...refs.values()];\n}\n\n/** Shared by integrity diagnostics and deletion guards for config-owned bounds. */\nexport const collectConfigValueExpressions = (\n config: unknown,\n): { expression: JsonExpression; location: string }[] => {\n const locations: { expression: JsonExpression; location: string }[] = [];\n const visit = (value: unknown, path: string) => {\n if (!value || typeof value !== \"object\") return;\n for (const [key, child] of Object.entries(value)) {\n const location = `${path}.${key}`;\n if (key === \"valueExpression\") {\n if (isJsonExpression(child)) locations.push({ expression: child, location });\n } else visit(child, location);\n }\n };\n visit(config, \"config\");\n return locations;\n};\n\nconst collectItemExpressionLocations = (item: RawSurveyItem): SurveyExpressionLocation[] => {\n const locations: SurveyExpressionLocation[] = [];\n const add = (\n expression: unknown,\n location: string,\n ownerScope: SurveyExpressionLocation[\"ownerScope\"],\n surface: SurveyExpressionLocation[\"surface\"],\n ) => {\n if (!isJsonExpression(expression)) return;\n locations.push({\n expression,\n location,\n ownerItemId: item.id,\n ownerItemKey: item.metadata?.itemLabel ?? \"\",\n ownerScope,\n surface,\n });\n };\n\n add(item.displayConditions?.root, \"displayConditions.root\", \"item\", \"display-condition\");\n for (const [componentId, expression] of Object.entries(\n item.displayConditions?.components ?? {},\n )) {\n add(\n expression,\n `displayConditions.components.${componentId}`,\n \"component\",\n \"display-condition\",\n );\n }\n for (const [componentId, expression] of Object.entries(\n item.disabledConditions?.components ?? {},\n )) {\n add(\n expression,\n `disabledConditions.components.${componentId}`,\n \"component\",\n \"disabled-condition\",\n );\n }\n for (const [validationKey, expression] of Object.entries(item.validations ?? {})) {\n add(expression, `validations.${validationKey}`, \"item\", \"validation\");\n }\n for (const [prefillIndex, prefill] of (item.prefills ?? []).entries()) {\n const prefillId = prefill.id || String(prefillIndex);\n add(prefill.when, `prefills.${prefillId}.when`, \"item\", \"prefill-condition\");\n if (prefill.source.type === \"expression\") {\n add(\n prefill.source.expression,\n `prefills.${prefillId}.source.expression`,\n \"item\",\n \"prefill-source\",\n );\n }\n }\n\n for (const { expression, location } of collectConfigValueExpressions(item.config)) {\n add(expression, location, \"item\", \"validation\");\n }\n return locations;\n};\n\nexport const collectSurveyExpressionLocations = (survey: RawSurvey): SurveyExpressionLocation[] => [\n ...survey.surveyItems.flatMap(collectItemExpressionLocations),\n ...Object.entries(survey.templateValues ?? {}).flatMap(([templateKey, templateValue]) =>\n templateValue.expression\n ? [\n {\n expression: templateValue.expression,\n location: `templateValues.${templateKey}.expression`,\n ownerScope: \"survey\" as const,\n surface: \"template-value\" as const,\n },\n ]\n : [],\n ),\n];\n\nconst candidateRefs = (unknownRef: string, availableRefs: string[]) => {\n let parsed: ValueReference | undefined;\n try {\n parsed = new ValueReference(unknownRef);\n } catch {\n return availableRefs.slice(0, 5);\n }\n const sameItemAndMethod = availableRefs.filter((candidate) => {\n try {\n const candidateRef = new ValueReference(candidate);\n return candidateRef.name === parsed?.name;\n } catch {\n return false;\n }\n });\n return (sameItemAndMethod.length > 0 ? sameItemAndMethod : availableRefs).slice(0, 5);\n};\n\ninterface ItemDisplayDependencyEdge {\n fromItemId: string;\n location: SurveyExpressionLocation;\n reference: string;\n toItemId: string;\n}\n\nconst findCyclicItemDisplayDependencyEdges = ({\n edges,\n itemIds,\n}: {\n edges: ItemDisplayDependencyEdge[];\n itemIds: string[];\n}): Array<{ cycleItemIds: string[]; edge: ItemDisplayDependencyEdge }> => {\n const adjacency = new Map(itemIds.map((itemId) => [itemId, new Set<string>()]));\n const reverseAdjacency = new Map(itemIds.map((itemId) => [itemId, new Set<string>()]));\n for (const edge of edges) {\n adjacency.get(edge.fromItemId)?.add(edge.toItemId);\n reverseAdjacency.get(edge.toItemId)?.add(edge.fromItemId);\n }\n\n const finishOrder: string[] = [];\n const visited = new Set<string>();\n for (const startItemId of itemIds) {\n if (visited.has(startItemId)) continue;\n const stack: Array<{ expanded: boolean; itemId: string }> = [\n { expanded: false, itemId: startItemId },\n ];\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current) break;\n if (current.expanded) {\n finishOrder.push(current.itemId);\n continue;\n }\n if (visited.has(current.itemId)) continue;\n visited.add(current.itemId);\n stack.push({ expanded: true, itemId: current.itemId });\n const dependencies = [...(adjacency.get(current.itemId) ?? [])];\n for (let index = dependencies.length - 1; index >= 0; index -= 1) {\n const dependencyId = dependencies[index];\n if (visited.has(dependencyId)) continue;\n stack.push({ expanded: false, itemId: dependencyId });\n }\n }\n }\n\n const componentByItemId = new Map<string, number>();\n const componentMembers = new Map<number, string[]>();\n for (const startItemId of finishOrder.reverse()) {\n if (componentByItemId.has(startItemId)) continue;\n const componentId = componentMembers.size;\n const members: string[] = [];\n const stack = [startItemId];\n componentByItemId.set(startItemId, componentId);\n while (stack.length > 0) {\n const itemId = stack.pop();\n if (!itemId) break;\n members.push(itemId);\n for (const dependencyOwnerId of reverseAdjacency.get(itemId) ?? []) {\n if (componentByItemId.has(dependencyOwnerId)) continue;\n componentByItemId.set(dependencyOwnerId, componentId);\n stack.push(dependencyOwnerId);\n }\n }\n componentMembers.set(componentId, members.sort());\n }\n\n return edges.flatMap((edge) => {\n const componentId = componentByItemId.get(edge.fromItemId);\n if (componentId === undefined || componentId !== componentByItemId.get(edge.toItemId))\n return [];\n const cycleItemIds = componentMembers.get(componentId) ?? [];\n if (edge.fromItemId !== edge.toItemId && cycleItemIds.length < 2) return [];\n return [{ edge, cycleItemIds }];\n });\n};\n\nconst inferExpressionType = (\n expression: JsonExpression | undefined,\n slots: ReadonlyMap<string, SurveyExpressionResponseSlot>,\n): ValueType | undefined => {\n if (!expression) return undefined;\n if (expression.type === ExpressionType.Const) return expression.value?.type;\n if (expression.type === ExpressionType.ResponseVariable) {\n return slots.get(new ValueReference(expression.variableRef).toString())?.valueType;\n }\n if (expression.type === ExpressionType.ContextVariable) {\n return expression.contextType === \"locale\" ? ValueType.string : expression.asType;\n }\n switch (expression.functionName) {\n case FunctionExpressionNames.and:\n case FunctionExpressionNames.or:\n case FunctionExpressionNames.not:\n case FunctionExpressionNames.eq:\n case FunctionExpressionNames.gt:\n case FunctionExpressionNames.gte:\n case FunctionExpressionNames.lt:\n case FunctionExpressionNames.lte:\n case FunctionExpressionNames.in_range:\n case FunctionExpressionNames.list_contains:\n case FunctionExpressionNames.str_eq:\n case FunctionExpressionNames.date_eq:\n case FunctionExpressionNames.date_gt:\n case FunctionExpressionNames.date_gte:\n case FunctionExpressionNames.date_lt:\n case FunctionExpressionNames.date_lte:\n return ValueType.boolean;\n case FunctionExpressionNames.date_add_days:\n case FunctionExpressionNames.date_add_months:\n case FunctionExpressionNames.date_add_years:\n case FunctionExpressionNames.date_min:\n case FunctionExpressionNames.date_max:\n return ValueType.date;\n case FunctionExpressionNames.date_diff:\n return ValueType.number;\n case FunctionExpressionNames.sum:\n case FunctionExpressionNames.min:\n case FunctionExpressionNames.max:\n return ValueType.number;\n }\n};\n\nconst itemTypeForList = (type: ValueType | undefined): ValueType | undefined => {\n switch (type) {\n case ValueType.stringArray:\n return ValueType.string;\n case ValueType.referenceArray:\n return ValueType.reference;\n case ValueType.numberArray:\n return ValueType.number;\n case ValueType.dateArray:\n return ValueType.date;\n case ValueType.durationArray:\n return ValueType.duration;\n default:\n return undefined;\n }\n};\n\nconst inspectFunctionReferenceCompatibility = ({\n diagnostics,\n expression,\n location,\n slots,\n}: {\n diagnostics: SurveyExpressionReferenceDiagnosticInput[];\n expression: JsonExpression;\n location: SurveyExpressionLocation;\n slots: ReadonlyMap<string, SurveyExpressionResponseSlot>;\n}) => {\n if (expression.type === ExpressionType.ContextVariable) {\n for (const argument of [expression.key, ...(expression.arguments ?? [])]) {\n if (argument)\n inspectFunctionReferenceCompatibility({\n diagnostics,\n expression: argument,\n location,\n slots,\n });\n }\n return;\n }\n if (expression.type !== ExpressionType.Function) return;\n expression.arguments.forEach((argument) => {\n if (argument) {\n inspectFunctionReferenceCompatibility({ diagnostics, expression: argument, location, slots });\n }\n });\n\n const signature = DATE_FUNCTION_SIGNATURES[expression.functionName];\n if (signature) {\n const invalidArity = signature.variadic\n ? expression.arguments.length < 1\n : expression.arguments.length !== signature.args.length;\n const invalidType = expression.arguments.some((arg, i) => {\n const actual = inferExpressionType(arg, slots);\n return actual && actual !== signature.args[signature.variadic ? 0 : i];\n });\n if (invalidArity || invalidType)\n diagnostics.push({\n code: \"expression-reference-type-mismatch\",\n message: `${location.location} has invalid arguments for ${expression.functionName}.`,\n location: location.location,\n ownerItemId: location.ownerItemId,\n ownerItemKey: location.ownerItemKey,\n });\n }\n const [left, right] = expression.arguments;\n const leftType = inferExpressionType(left, slots);\n const rightType = inferExpressionType(right, slots);\n const mismatch =\n expression.functionName === FunctionExpressionNames.list_contains\n ? Boolean(leftType && rightType && itemTypeForList(leftType) !== rightType)\n : expression.functionName === FunctionExpressionNames.eq\n ? Boolean(leftType && rightType && leftType !== rightType)\n : false;\n if (mismatch) {\n diagnostics.push({\n code: \"expression-reference-type-mismatch\",\n message: `${location.location} compares incompatible values (${leftType} and ${rightType}).`,\n location: location.location,\n ownerItemId: location.ownerItemId,\n ownerItemKey: location.ownerItemKey,\n });\n }\n\n if (\n expression.functionName !== FunctionExpressionNames.eq &&\n expression.functionName !== FunctionExpressionNames.str_eq &&\n expression.functionName !== FunctionExpressionNames.list_contains\n ) {\n return;\n }\n const pairs = [\n [left, right],\n [right, left],\n ] as const;\n for (const [variable, constant] of pairs) {\n if (\n variable?.type !== ExpressionType.ResponseVariable ||\n constant?.type !== ExpressionType.Const ||\n !constant.value\n ) {\n continue;\n }\n const slot = slots.get(new ValueReference(variable.variableRef).toString());\n const domain =\n slot?.allowedValues ??\n slot?.allowedReferenceValues?.map((value) => ({\n type: ValueType.reference,\n value,\n }));\n if (!domain) continue;\n for (const invalid of invalidResponseDomainValues(constant.value, domain)) {\n const referenceValue =\n typeof invalid.value === \"string\" ? invalid.value : JSON.stringify(invalid.value);\n diagnostics.push({\n code: \"unknown-reference-value\",\n message: `${location.location} compares slot \"${variable.variableRef.slotId}\" with invalid value ${JSON.stringify(invalid)}. Allowed values: ${JSON.stringify(domain)}.`,\n location: location.location,\n ownerItemId: location.ownerItemId,\n ownerItemKey: location.ownerItemKey,\n reference: new ValueReference(variable.variableRef).toString(),\n referenceValue,\n candidates: domain.map((value) => String(value.value)),\n });\n }\n }\n};\n\nexport const analyzeSurveyExpressionReferences = ({\n responseSlots,\n survey,\n}: {\n responseSlots: SurveyExpressionResponseSlot[];\n survey: RawSurvey;\n}): SurveyExpressionReferenceDiagnostic[] => {\n const slots = new Map(responseSlots.map((slot) => [slot.ref, slot]));\n const availableRefs = responseSlots.map((slot) => slot.ref);\n const diagnostics: SurveyExpressionReferenceDiagnosticInput[] = [];\n const surveyItemIds = survey.surveyItems.map((item) => item.id);\n const surveyItemIdSet = new Set(surveyItemIds);\n const itemDisplayDependencyEdges: ItemDisplayDependencyEdge[] = [];\n\n for (const location of collectSurveyExpressionLocations(survey)) {\n let parsed: Expression | undefined;\n try {\n parsed = Expression.deserialize(location.expression);\n } catch (error) {\n diagnostics.push({\n code: \"invalid-expression\",\n message: `${location.location} contains invalid expression JSON: ${error instanceof Error ? error.message : String(error)}`,\n location: location.location,\n ownerItemId: location.ownerItemId,\n ownerItemKey: location.ownerItemKey,\n });\n continue;\n }\n for (const ref of parsed?.responseVariableRefs ?? []) {\n const reference = ref.toString();\n if (\n location.ownerItemId &&\n ITEM_DISPLAY_DEPENDENCY_OWNER_SCOPE_POLICY[location.ownerScope] &&\n ITEM_DISPLAY_DEPENDENCY_SURFACE_POLICY[location.surface] &&\n surveyItemIdSet.has(slots.get(reference)?.itemId ?? \"\")\n ) {\n itemDisplayDependencyEdges.push({\n fromItemId: location.ownerItemId,\n location,\n reference,\n toItemId: slots.get(reference)!.itemId!,\n });\n }\n if (!slots.has(reference)) {\n diagnostics.push({\n code: \"unknown-response-ref\",\n message: `${location.location} references unknown response slot \"${reference}\".`,\n location: location.location,\n ownerItemId: location.ownerItemId,\n ownerItemKey: location.ownerItemKey,\n reference,\n candidates: candidateRefs(reference, availableRefs),\n });\n }\n }\n if (location.location.endsWith(\".valueExpression\")) {\n const actual = inferExpressionType(location.expression, slots);\n if (actual && actual !== ValueType.date)\n diagnostics.push({\n code: \"expression-reference-type-mismatch\",\n message: `${location.location} must return a date.`,\n location: location.location,\n ownerItemId: location.ownerItemId,\n ownerItemKey: location.ownerItemKey,\n });\n }\n inspectFunctionReferenceCompatibility({\n diagnostics,\n expression: location.expression,\n location,\n slots,\n });\n }\n\n for (const { cycleItemIds, edge } of findCyclicItemDisplayDependencyEdges({\n edges: itemDisplayDependencyEdges,\n itemIds: surveyItemIds,\n })) {\n const isSelfReference = edge.fromItemId === edge.toItemId;\n diagnostics.push({\n code: \"display-condition-cycle\",\n message: isSelfReference\n ? `${edge.location.location} for item \"${edge.fromItemId}\" references its own response \"${edge.reference}\", creating a circular display dependency.`\n : `${edge.location.location} for item \"${edge.fromItemId}\" references item \"${edge.toItemId}\" within a circular display dependency among ${cycleItemIds.map((itemId) => `\"${itemId}\"`).join(\", \")}.`,\n location: edge.location.location,\n ownerItemId: edge.location.ownerItemId,\n ownerItemKey: edge.location.ownerItemKey,\n reference: edge.reference,\n });\n }\n\n return diagnostics.map(createExpressionReferenceDiagnostic);\n};\n\nexport const expressionReferenceDiagnosticKey = (diagnostic: SurveyExpressionReferenceDiagnostic) =>\n [\n diagnostic.code,\n diagnostic.ownerItemId ?? \"survey\",\n diagnostic.location,\n diagnostic.reference ?? \"\",\n diagnostic.referenceValue ?? \"\",\n ].join(\"\\u0000\");\n\nexport const findIntroducedExpressionReferenceDiagnosticsIncludingAdvisories = ({\n after,\n before,\n}: {\n after: SurveyExpressionReferenceDiagnostic[];\n before: SurveyExpressionReferenceDiagnostic[];\n}) => {\n const existing = new Set(before.map(expressionReferenceDiagnosticKey));\n return after.filter((diagnostic) => !existing.has(expressionReferenceDiagnosticKey(diagnostic)));\n};\n\nexport const isBlockingSurveyExpressionReferenceDiagnostic = (\n diagnostic: Pick<SurveyExpressionReferenceDiagnostic, \"disposition\">,\n): boolean => {\n const disposition = diagnostic.disposition;\n switch (disposition) {\n case \"blocking\":\n return true;\n case \"advisory\":\n return false;\n default: {\n const exhaustiveDisposition: never = disposition;\n void exhaustiveDisposition;\n return true;\n }\n }\n};\n\nexport const findIntroducedBlockingExpressionReferenceDiagnostics = ({\n after,\n before,\n}: {\n after: SurveyExpressionReferenceDiagnostic[];\n before: SurveyExpressionReferenceDiagnostic[];\n}): SurveyExpressionReferenceDiagnostic[] =>\n findIntroducedExpressionReferenceDiagnosticsIncludingAdvisories({ after, before }).filter(\n isBlockingSurveyExpressionReferenceDiagnostic,\n );\n\nexport const replaceResponseVariableReferences = <T>(\n value: T,\n replacements: Readonly<Record<string, string>>,\n optionReplacements: Readonly<Record<string, string>> = {},\n): { changed: boolean; value: T } => {\n let changed = false;\n const visit = (current: unknown): unknown => {\n if (Array.isArray(current)) return current.map(visit);\n if (!isRecord(current)) return current;\n const next = Object.fromEntries(\n Object.entries(current).map(([key, entry]) => [key, visit(entry)]),\n );\n if (\n next.type === ExpressionType.ResponseVariable &&\n isRecord(next.variableRef) &&\n typeof next.variableRef.slotId === \"string\" &&\n replacements[next.variableRef.slotId]\n ) {\n next.variableRef.slotId = replacements[next.variableRef.slotId];\n changed = true;\n }\n if (next.type === ExpressionType.Const && isRecord(next.value)) {\n const remap = (id: string) => {\n if (!Object.hasOwn(optionReplacements, id)) return id;\n changed = true;\n return optionReplacements[id];\n };\n if (next.value.type === ValueType.reference && typeof next.value.value === \"string\")\n next.value.value = remap(next.value.value);\n if (next.value.type === ValueType.referenceArray && Array.isArray(next.value.value))\n next.value.value = next.value.value.map((id) => (typeof id === \"string\" ? remap(id) : id));\n }\n return next;\n };\n const rewritten = visit(value) as T;\n return { changed, value: rewritten };\n};\n\nexport const responseValueReferenceIds = (values: ResponseValue[] | undefined) =>\n values?.flatMap((value) =>\n value.type === ValueType.reference\n ? [value.value]\n : value.type === ValueType.referenceArray\n ? value.value\n : [],\n );\n","import { type CalendarDate } from \"../../calendar-date\";\n// TODO: constant expression editor\n// TODO: context variable expression editor\n// TODO: function expression editor\n\nimport {\n Expression,\n FunctionExpression,\n ExpressionEditorConfig,\n FunctionExpressionNames,\n ConstExpression,\n ResponseVariableExpression,\n ContextVariableType,\n ContextVariableExpression,\n} from \"../../expressions/expression\";\nimport { ValueType } from \"../../survey/responses/value-types\";\nimport { ValueReference } from \"../../survey/utils/value-reference\";\n\n// ================================\n// EXPRESSION EDITOR CLASSES\n// ================================\nexport abstract class ExpressionEditor {\n returnType!: ValueType;\n protected _editorConfig?: ExpressionEditorConfig;\n\n abstract getExpression(): Expression | undefined;\n\n get editorConfig(): ExpressionEditorConfig | undefined {\n return this._editorConfig;\n }\n\n withEditorConfig(editorConfig: ExpressionEditorConfig): ExpressionEditor {\n this._editorConfig = editorConfig;\n return this;\n }\n}\n\n// ================================\n// CONST EDITORS\n// ================================\nexport class ConstStringArrayEditor extends ExpressionEditor {\n readonly returnType = ValueType.stringArray;\n\n private _values: string[];\n\n constructor(values: string[], editorConfig?: ExpressionEditorConfig) {\n super();\n this._values = values;\n this._editorConfig = editorConfig;\n }\n\n get values(): string[] {\n return this._values;\n }\n\n set values(values: string[]) {\n this._values = values;\n }\n\n getExpression(): Expression | undefined {\n return new ConstExpression(\n { type: ValueType.stringArray, value: this._values },\n this._editorConfig,\n );\n }\n}\n\nexport class ConstStringEditor extends ExpressionEditor {\n readonly returnType = ValueType.string;\n\n private _value: string;\n\n constructor(value: string, editorConfig?: ExpressionEditorConfig) {\n super();\n this._value = value;\n this._editorConfig = editorConfig;\n }\n\n get value(): string {\n return this._value;\n }\n\n set value(value: string) {\n this._value = value;\n }\n\n getExpression(): Expression | undefined {\n return new ConstExpression({ type: ValueType.string, value: this._value }, this._editorConfig);\n }\n}\n\nexport class ConstNumberEditor extends ExpressionEditor {\n readonly returnType = ValueType.number;\n\n private _value: number;\n\n constructor(value: number, editorConfig?: ExpressionEditorConfig) {\n super();\n this._value = value;\n this._editorConfig = editorConfig;\n }\n\n get value(): number {\n return this._value;\n }\n\n set value(value: number) {\n this._value = value;\n }\n\n getExpression(): Expression | undefined {\n return new ConstExpression({ type: ValueType.number, value: this._value }, this._editorConfig);\n }\n}\n\nexport class ConstBooleanEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n\n private _value: boolean;\n\n constructor(value: boolean, editorConfig?: ExpressionEditorConfig) {\n super();\n this._value = value;\n this._editorConfig = editorConfig;\n }\n\n get value(): boolean {\n return this._value;\n }\n\n set value(value: boolean) {\n this._value = value;\n }\n\n getExpression(): Expression | undefined {\n return new ConstExpression({ type: ValueType.boolean, value: this._value }, this._editorConfig);\n }\n}\n\nexport class ConstDateEditor extends ExpressionEditor {\n readonly returnType = ValueType.date;\n\n private _value: CalendarDate;\n\n constructor(value: CalendarDate, editorConfig?: ExpressionEditorConfig) {\n super();\n this._value = value;\n this._editorConfig = editorConfig;\n }\n\n get value(): CalendarDate {\n return this._value;\n }\n\n set value(value: CalendarDate) {\n this._value = value;\n }\n\n getExpression(): Expression | undefined {\n const value = this._value;\n return new ConstExpression({ type: ValueType.date, value: value }, this._editorConfig);\n }\n}\n\nexport class ConstNumberArrayEditor extends ExpressionEditor {\n readonly returnType = ValueType.numberArray;\n\n private _values: number[];\n\n constructor(values: number[], editorConfig?: ExpressionEditorConfig) {\n super();\n this._values = values;\n this._editorConfig = editorConfig;\n }\n\n get values(): number[] {\n return this._values;\n }\n\n set values(values: number[]) {\n this._values = values;\n }\n\n getExpression(): Expression | undefined {\n return new ConstExpression(\n { type: ValueType.numberArray, value: this._values },\n this._editorConfig,\n );\n }\n}\n\nexport class ConstDateArrayEditor extends ExpressionEditor {\n readonly returnType = ValueType.dateArray;\n\n private _values: CalendarDate[];\n\n constructor(values: CalendarDate[], editorConfig?: ExpressionEditorConfig) {\n super();\n this._values = values;\n this._editorConfig = editorConfig;\n }\n\n get values(): CalendarDate[] {\n return this._values;\n }\n\n set values(values: CalendarDate[]) {\n this._values = values;\n }\n\n getExpression(): Expression | undefined {\n const value = this._values;\n return new ConstExpression({ type: ValueType.dateArray, value: value }, this._editorConfig);\n }\n}\n\n// ================================\n// RESPONSE VARIABLE EXPRESSION EDITOR CLASSES\n// ================================\n\nexport class ResponseVariableEditor extends ExpressionEditor {\n private _variableName: string;\n private _variableRef: ValueReference;\n\n constructor(\n variableName: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n variableType: ValueType,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super();\n this._variableName = new ValueReference(variableName).toString();\n this._variableRef = new ValueReference(variableName);\n this._editorConfig = editorConfig;\n this.returnType = variableType;\n }\n\n get variableName(): string {\n return this._variableName;\n }\n\n get variableRef(): ValueReference {\n return this._variableRef;\n }\n\n getExpression(): Expression | undefined {\n return new ResponseVariableExpression(this._variableName, this._editorConfig);\n }\n}\n\n// ================================\n// CONTEXT VARIABLE EXPRESSION EDITOR CLASSES\n// ================================\n\nabstract class ContextVariableEditor extends ExpressionEditor {\n private _contextType: ContextVariableType;\n private _key?: ExpressionEditor;\n private _args?: ExpressionEditor[];\n private _asType?: ValueType;\n\n constructor(\n contextType: ContextVariableType,\n key?: ExpressionEditor,\n args?: ExpressionEditor[],\n asType?: ValueType,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super();\n this._contextType = contextType;\n this._key = key;\n this._args = args;\n this._asType = asType;\n this._editorConfig = editorConfig;\n }\n\n getExpression(): Expression | undefined {\n return new ContextVariableExpression(\n this._contextType,\n this._key?.getExpression(),\n this._args?.map((arg) => arg.getExpression()),\n this._asType,\n this._editorConfig,\n );\n }\n}\n\nexport class CtxLocaleEditor extends ContextVariableEditor {\n readonly returnType = ValueType.string;\n\n constructor(editorConfig?: ExpressionEditorConfig) {\n super(ContextVariableType.Locale, undefined, undefined, ValueType.string, editorConfig);\n }\n}\n\nexport class CtxPFlagIsDefinedEditor extends ContextVariableEditor {\n readonly returnType = ValueType.boolean;\n\n constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super(ContextVariableType.ParticipantFlag, key, undefined, ValueType.boolean, editorConfig);\n }\n}\n\nexport class CtxPFlagStringEditor extends ContextVariableEditor {\n readonly returnType = ValueType.string;\n\n constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super(ContextVariableType.ParticipantFlag, key, undefined, ValueType.string, editorConfig);\n }\n}\n\nexport class CtxPFlagNumEditor extends ContextVariableEditor {\n readonly returnType = ValueType.number;\n\n constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super(ContextVariableType.ParticipantFlag, key, undefined, ValueType.number, editorConfig);\n }\n}\n\nexport class CtxPFlagDateEditor extends ContextVariableEditor {\n readonly returnType = ValueType.date;\n\n constructor(key: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super(ContextVariableType.ParticipantFlag, key, undefined, ValueType.date, editorConfig);\n }\n}\n\nexport class CtxCustomValueEditor extends ContextVariableEditor {\n constructor(key: ExpressionEditor, asType: ValueType, editorConfig?: ExpressionEditorConfig) {\n super(ContextVariableType.CustomValue, key, undefined, asType, editorConfig);\n this.returnType = asType;\n }\n}\n\nexport class CtxCustomExpressionEditor extends ContextVariableEditor {\n constructor(\n key: ExpressionEditor,\n args: ExpressionEditor[],\n asType: ValueType,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super(ContextVariableType.CustomExpression, key, args, asType, editorConfig);\n this.returnType = asType;\n }\n}\n\n// ================================\n// GROUP EXPRESSION EDITOR CLASSES\n// ================================\nabstract class GroupExpressionEditor extends ExpressionEditor {\n private _args: ExpressionEditor[];\n\n constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig) {\n super();\n this._args = args;\n this._editorConfig = editorConfig;\n }\n\n get args(): ExpressionEditor[] {\n return this._args;\n }\n\n addArg(arg: ExpressionEditor, position?: number) {\n if (position === undefined) {\n this._args.push(arg);\n } else {\n this._args.splice(position, 0, arg);\n }\n }\n\n removeArg(position: number) {\n this._args.splice(position, 1);\n }\n\n replaceArg(position: number, arg: ExpressionEditor) {\n this._args[position] = arg;\n }\n\n swapArgs(activeIndex: number, overIndex: number) {\n const newOrder = [...this._args];\n newOrder.splice(activeIndex, 1);\n newOrder.splice(overIndex, 0, this._args[activeIndex]);\n this._args = newOrder;\n }\n}\n\nexport class AndExpressionEditor extends GroupExpressionEditor {\n readonly returnType = ValueType.boolean;\n\n constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig) {\n if (args.some((arg) => arg.returnType !== ValueType.boolean)) {\n throw new Error(\"And expression editor must have boolean arguments\");\n }\n super(args, editorConfig);\n }\n\n getExpression(): Expression | undefined {\n return new FunctionExpression(\n FunctionExpressionNames.and,\n this.args.map((arg) => arg.getExpression()),\n this._editorConfig,\n );\n }\n}\n\nexport class OrExpressionEditor extends GroupExpressionEditor {\n readonly returnType = ValueType.boolean;\n\n constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig) {\n if (args.some((arg) => arg.returnType !== ValueType.boolean)) {\n throw new Error(\"Or expression editor must have boolean arguments\");\n }\n super(args, editorConfig);\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.or,\n this.args.map((arg) => arg.getExpression()),\n this._editorConfig,\n );\n }\n}\n\n// ================================\n// LIST EXPRESSION EDITOR CLASSES\n// ================================\n\nexport class StrListContainsExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _list: ExpressionEditor | undefined;\n private _item: ExpressionEditor | undefined;\n\n constructor(\n list: ExpressionEditor,\n item: ExpressionEditor,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super();\n if (list.returnType !== ValueType.stringArray) {\n throw new Error(\"List contains expression editor must have a string array list\");\n }\n if (item.returnType !== ValueType.string) {\n throw new Error(\"List contains expression editor must have a string item\");\n }\n this._list = list;\n this._item = item;\n this._editorConfig = editorConfig;\n }\n\n get list(): ExpressionEditor | undefined {\n return this._list;\n }\n\n get item(): ExpressionEditor | undefined {\n return this._item;\n }\n\n set list(list: ExpressionEditor | undefined) {\n this._list = list;\n }\n\n set item(item: ExpressionEditor | undefined) {\n this._item = item;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.list_contains,\n [this._list?.getExpression(), this._item?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\n// ================================\n// STRING EXPRESSION EDITOR CLASSES\n// ================================\n\nexport class StrEqExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _a: ExpressionEditor | undefined;\n private _b: ExpressionEditor | undefined;\n\n constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super();\n this._a = a;\n this._b = b;\n this._editorConfig = editorConfig;\n }\n\n get a(): ExpressionEditor | undefined {\n return this._a;\n }\n\n get b(): ExpressionEditor | undefined {\n return this._b;\n }\n\n set a(a: ExpressionEditor | undefined) {\n this._a = a;\n }\n\n set b(b: ExpressionEditor | undefined) {\n this._b = b;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.str_eq,\n [this._a?.getExpression(), this._b?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\n// ================================\n// NUMBER EXPRESSION EDITOR CLASSES\n// ================================\n\nexport class EqExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _a: ExpressionEditor | undefined;\n private _b: ExpressionEditor | undefined;\n\n constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super();\n this._a = a;\n this._b = b;\n this._editorConfig = editorConfig;\n }\n\n get a(): ExpressionEditor | undefined {\n return this._a;\n }\n\n get b(): ExpressionEditor | undefined {\n return this._b;\n }\n\n set a(a: ExpressionEditor | undefined) {\n this._a = a;\n }\n\n set b(b: ExpressionEditor | undefined) {\n this._b = b;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.eq,\n [this._a?.getExpression(), this._b?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\nexport class GtExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _a: ExpressionEditor | undefined;\n private _b: ExpressionEditor | undefined;\n\n constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super();\n this._a = a;\n this._b = b;\n this._editorConfig = editorConfig;\n }\n\n get a(): ExpressionEditor | undefined {\n return this._a;\n }\n\n get b(): ExpressionEditor | undefined {\n return this._b;\n }\n\n set a(a: ExpressionEditor | undefined) {\n this._a = a;\n }\n\n set b(b: ExpressionEditor | undefined) {\n this._b = b;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.gt,\n [this._a?.getExpression(), this._b?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\nexport class GteExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _a: ExpressionEditor | undefined;\n private _b: ExpressionEditor | undefined;\n\n constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super();\n this._a = a;\n this._b = b;\n this._editorConfig = editorConfig;\n }\n\n get a(): ExpressionEditor | undefined {\n return this._a;\n }\n\n get b(): ExpressionEditor | undefined {\n return this._b;\n }\n\n set a(a: ExpressionEditor | undefined) {\n this._a = a;\n }\n\n set b(b: ExpressionEditor | undefined) {\n this._b = b;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.gte,\n [this._a?.getExpression(), this._b?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\nexport class LtExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _a: ExpressionEditor | undefined;\n private _b: ExpressionEditor | undefined;\n\n constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super();\n this._a = a;\n this._b = b;\n this._editorConfig = editorConfig;\n }\n\n get a(): ExpressionEditor | undefined {\n return this._a;\n }\n\n get b(): ExpressionEditor | undefined {\n return this._b;\n }\n\n set a(a: ExpressionEditor | undefined) {\n this._a = a;\n }\n\n set b(b: ExpressionEditor | undefined) {\n this._b = b;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.lt,\n [this._a?.getExpression(), this._b?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\nexport class LteExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n private _a: ExpressionEditor | undefined;\n private _b: ExpressionEditor | undefined;\n\n constructor(a: ExpressionEditor, b: ExpressionEditor, editorConfig?: ExpressionEditorConfig) {\n super();\n this._a = a;\n this._b = b;\n this._editorConfig = editorConfig;\n }\n\n get a(): ExpressionEditor | undefined {\n return this._a;\n }\n\n get b(): ExpressionEditor | undefined {\n return this._b;\n }\n\n set b(b: ExpressionEditor | undefined) {\n this._b = b;\n }\n\n set a(a: ExpressionEditor | undefined) {\n this._a = a;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.lte,\n [this._a?.getExpression(), this._b?.getExpression()],\n this._editorConfig,\n );\n }\n}\n\nexport class InRangeExpressionEditor extends ExpressionEditor {\n readonly returnType = ValueType.boolean;\n value: ExpressionEditor | undefined;\n min: ExpressionEditor | undefined;\n max: ExpressionEditor | undefined;\n inclusive: ExpressionEditor | undefined;\n\n constructor(\n value: ExpressionEditor,\n min: ExpressionEditor,\n max: ExpressionEditor,\n inclusive: ExpressionEditor,\n editorConfig?: ExpressionEditorConfig,\n ) {\n super();\n this.value = value;\n this.min = min;\n this.max = max;\n this.inclusive = inclusive;\n this._editorConfig = editorConfig;\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.in_range,\n [\n this.value?.getExpression(),\n this.min?.getExpression(),\n this.max?.getExpression(),\n this.inclusive?.getExpression(),\n ],\n this._editorConfig,\n );\n }\n}\n\nexport class SumExpressionEditor extends GroupExpressionEditor {\n readonly returnType = ValueType.number;\n\n constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig) {\n super(args, editorConfig);\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.sum,\n this.args.map((arg) => arg.getExpression()),\n this._editorConfig,\n );\n }\n}\n\nexport class MinExpressionEditor extends GroupExpressionEditor {\n readonly returnType = ValueType.number;\n\n constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig) {\n super(args, editorConfig);\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.min,\n this.args.map((arg) => arg.getExpression()),\n this._editorConfig,\n );\n }\n}\n\nexport class MaxExpressionEditor extends GroupExpressionEditor {\n readonly returnType = ValueType.number;\n\n constructor(args: ExpressionEditor[], editorConfig?: ExpressionEditorConfig) {\n super(args, editorConfig);\n }\n\n getExpression(): Expression {\n return new FunctionExpression(\n FunctionExpressionNames.max,\n this.args.map((arg) => arg.getExpression()),\n this._editorConfig,\n );\n }\n}\n","import { FunctionExpression, FunctionExpressionNames } from \"../expression\";\nimport { ValueType } from \"../../survey/responses/value-types\";\nimport {\n AndExpressionEditor,\n ConstStringArrayEditor,\n ConstStringEditor,\n ExpressionEditor,\n StrListContainsExpressionEditor,\n OrExpressionEditor,\n ResponseVariableEditor,\n ConstNumberArrayEditor,\n ConstNumberEditor,\n ConstBooleanEditor,\n ConstDateEditor,\n ConstDateArrayEditor,\n StrEqExpressionEditor,\n EqExpressionEditor,\n GtExpressionEditor,\n GteExpressionEditor,\n LteExpressionEditor,\n LtExpressionEditor,\n InRangeExpressionEditor,\n SumExpressionEditor,\n MinExpressionEditor,\n MaxExpressionEditor,\n CtxLocaleEditor,\n CtxPFlagIsDefinedEditor,\n CtxPFlagStringEditor,\n CtxPFlagNumEditor,\n CtxPFlagDateEditor,\n CtxCustomValueEditor,\n CtxCustomExpressionEditor,\n} from \"./expression-editor\";\n\n// ================================\n// CONST EXPRESSIONS\n// ================================\nexport const const_string_array = (...values: string[]): ExpressionEditor => {\n return new ConstStringArrayEditor(values);\n};\n\nexport const const_string = (value: string): ExpressionEditor => {\n return new ConstStringEditor(value);\n};\n\nexport const const_number_array = (...values: number[]): ExpressionEditor => {\n return new ConstNumberArrayEditor(values);\n};\n\nexport const const_number = (value: number): ExpressionEditor => {\n return new ConstNumberEditor(value);\n};\n\nexport const const_boolean = (value: boolean): ExpressionEditor => {\n return new ConstBooleanEditor(value);\n};\n\nexport const const_date = (value: string): ExpressionEditor => {\n return new ConstDateEditor(value);\n};\n\nexport const const_date_array = (...values: string[]): ExpressionEditor => {\n return new ConstDateArrayEditor(values);\n};\n\n// ================================\n// RESPONSE VARIABLE EXPRESSIONS\n// ================================\nexport const response_string = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.string);\n};\n\nexport const response_string_array = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.stringArray);\n};\n\nexport const response_number = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.number);\n};\n\nexport const response_boolean = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.boolean);\n};\n\nexport const response_date = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.date);\n};\n\nexport const response_number_array = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.numberArray);\n};\n\nexport const response_date_array = (\n valueRef: string | import(\"../../survey/utils/value-reference\").JsonValueReference,\n): ExpressionEditor => {\n return new ResponseVariableEditor(valueRef, ValueType.dateArray);\n};\n\n// ================================\n// CONTEXT VARIABLE EXPRESSIONS\n// ================================\nexport const ctx_locale = (): ExpressionEditor => {\n return new CtxLocaleEditor();\n};\n\nexport const ctx_pflag_is_defined = (key: ExpressionEditor): ExpressionEditor => {\n return new CtxPFlagIsDefinedEditor(key);\n};\n\nexport const ctx_pflag_string = (key: ExpressionEditor): ExpressionEditor => {\n return new CtxPFlagStringEditor(key);\n};\n\nexport const ctx_pflag_num = (key: ExpressionEditor): ExpressionEditor => {\n return new CtxPFlagNumEditor(key);\n};\n\nexport const ctx_pflag_date = (key: ExpressionEditor): ExpressionEditor => {\n return new CtxPFlagDateEditor(key);\n};\n\nexport const ctx_custom_value = (key: ExpressionEditor, dType: ValueType): ExpressionEditor => {\n return new CtxCustomValueEditor(key, dType);\n};\n\nexport const ctx_custom_expression = (\n key: ExpressionEditor,\n args: ExpressionEditor[],\n returnType: ValueType,\n): ExpressionEditor => {\n return new CtxCustomExpressionEditor(key, args, returnType);\n};\n\n// ================================\n// LOGIC EXPRESSIONS\n// ================================\nexport const and = (...args: ExpressionEditor[]): ExpressionEditor => {\n return new AndExpressionEditor(args);\n};\n\nexport const or = (...args: ExpressionEditor[]): ExpressionEditor => {\n return new OrExpressionEditor(args);\n};\n\n// ================================\n// LIST EXPRESSIONS\n// ================================\n\nexport const str_list_contains = (\n list: ExpressionEditor,\n item: ExpressionEditor,\n): ExpressionEditor => {\n return new StrListContainsExpressionEditor(list, item);\n};\n\n// ================================\n// STRING EXPRESSIONS\n// ================================\n\nexport const str_eq = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor => {\n return new StrEqExpressionEditor(a, b);\n};\n\n// ================================\n// NUMBER EXPRESSIONS\n// ================================\n\nexport const eq = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor => {\n return new EqExpressionEditor(a, b);\n};\n\nexport const gt = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor => {\n return new GtExpressionEditor(a, b);\n};\n\nexport const gte = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor => {\n return new GteExpressionEditor(a, b);\n};\n\nexport const lt = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor => {\n return new LtExpressionEditor(a, b);\n};\n\nexport const lte = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor => {\n return new LteExpressionEditor(a, b);\n};\n\nexport const in_range = (\n value: ExpressionEditor,\n min: ExpressionEditor,\n max: ExpressionEditor,\n inclusive: ExpressionEditor,\n): ExpressionEditor => {\n return new InRangeExpressionEditor(value, min, max, inclusive);\n};\n\nexport const sum = (...args: ExpressionEditor[]): ExpressionEditor => {\n return new SumExpressionEditor(args);\n};\n\nexport const min = (...args: ExpressionEditor[]): ExpressionEditor => {\n return new MinExpressionEditor(args);\n};\n\nexport const max = (...args: ExpressionEditor[]): ExpressionEditor => {\n return new MaxExpressionEditor(args);\n};\n\nclass CalendarFunctionEditor extends ExpressionEditor {\n constructor(\n readonly name: FunctionExpressionNames,\n readonly args: ExpressionEditor[],\n readonly returnType: ValueType,\n ) {\n super();\n }\n getExpression() {\n return new FunctionExpression(\n this.name,\n this.args.map((arg) => arg.getExpression()),\n );\n }\n}\nexport const date_eq = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_eq, [a, b], ValueType.boolean);\nexport const date_gt = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_gt, [a, b], ValueType.boolean);\nexport const date_gte = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_gte, [a, b], ValueType.boolean);\nexport const date_lt = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_lt, [a, b], ValueType.boolean);\nexport const date_lte = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_lte, [a, b], ValueType.boolean);\nexport const date_add_days = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_add_days, [a, b], ValueType.date);\nexport const date_add_months = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_add_months, [a, b], ValueType.date);\nexport const date_add_years = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_add_years, [a, b], ValueType.date);\nexport const date_diff = (a: ExpressionEditor, b: ExpressionEditor): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_diff, [a, b], ValueType.number);\nexport const date_min = (...args: ExpressionEditor[]): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_min, args, ValueType.date);\nexport const date_max = (...args: ExpressionEditor[]): ExpressionEditor =>\n new CalendarFunctionEditor(FunctionExpressionNames.date_max, args, ValueType.date);\n","export enum ReservedSurveyItemTypes {\n Group = \"group\",\n PageBreak = \"page-break\",\n}\n","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 (obj === undefined) return obj;\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\n/** Resolve a sibling key using the editor's stable numeric suffix convention. */\nexport function resolveUniqueItemKey(key: string, siblingKeys: ReadonlySet<string>): string {\n let candidate = key;\n let suffix = 1;\n while (siblingKeys.has(candidate)) candidate = `${key}_${suffix++}`;\n return candidate;\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 slotId: string;\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 {\n collectConfigValueExpressions,\n collectExpressionResponseReferences,\n} from \"../../expressions/reference-integrity\";\nimport type { JsonExpression } from \"../../expressions/expression\";\nimport { Expression } from \"../../expressions\";\nimport { RawSurveyItem } from \"../items\";\nimport { ResponseSlotDefinition } from \"../responses/slot-definition\";\nimport { ResponseValue, ValueRefTypeLookup, ValueType } from \"../responses/value-types\";\nimport type { ResponseItem } from \"../responses/item-response\";\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 config: TConfig;\n\n isInteractive(): boolean;\n getResponseSlotDefinitions(): ResponseSlotDefinition[];\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup;\n}\n\nexport interface ResponseNormalizationDiagnostic {\n code: string;\n message: string;\n slotId?: string;\n}\n\nexport interface NormalizedItemResponse {\n response?: ResponseItem;\n diagnostics?: ResponseNormalizationDiagnostic[];\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 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.config = this.parseConfig(this._rawItem.config);\n }\n\n /** Primitive authors can identify meaningful headings without exposing option/decorative text. */\n getOutlineContentKeys(): readonly string[] {\n return [\"title\", \"prompt\"];\n }\n getCompositionTypes(): readonly string[] {\n return [this.type];\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 /**\n * Validate/canonicalize updates, initial responses, and configured prefills before evaluation.\n * Prefills are applied one slot at a time, so multi-slot items must allow partial responses.\n */\n normalizeResponse(response: ResponseItem | undefined): NormalizedItemResponse {\n return { response };\n }\n\n /** Opt-in component ownership for copy/paste. Existing item formats remain unchanged. */\n getOwnedComponentIds(): string[] {\n return [];\n }\n\n /** Slots omitted from submissions when their component condition is false; session answers are retained. */\n getConditionalResponseSlots(): Array<{ slotId: string; componentId: string }> {\n return [];\n }\n\n /** Dependencies used when projecting a stored answer (for example visible choice options). */\n getActiveResponseDependencies(_slotId: string): { slotIds: string[]; componentIds: string[] } {\n return { slotIds: [], componentIds: [] };\n }\n\n /** Project retained data without mutating it. Dependencies must be declared above. */\n getActiveResponseValue(\n _slotId: string,\n value: ResponseValue | undefined,\n _isVisible: (componentId: string) => boolean,\n _getAnswer: (slotId: string) => ResponseValue | undefined,\n ): ResponseValue | undefined {\n return value;\n }\n\n /** Source slots used by a computed reference, for component visibility cycle diagnostics. */\n getComputedResponseDependencies(slotId: string): string[] {\n return (\n this.getResponseSlotDefinitions().find((slot) => slot.slotId === slotId)?.computed\n ?.sourceSlotIds ?? []\n );\n }\n\n /** Computed references are read-only, evaluated on demand, never persisted/exported as answers. */\n getComputedResponseValue(\n _slotId: string,\n _response: ResponseItem | undefined,\n _isVisible: (componentId: string) => boolean,\n ): ResponseValue | undefined {\n return undefined;\n }\n\n getResponseValidationValues(\n _response: ResponseItem | undefined,\n _isVisible: (componentId: string) => boolean,\n _evaluate?: (expression: JsonExpression) => ResponseValue | undefined,\n ): Record<string, boolean> {\n return {};\n }\n\n /** Runtime-only checks; authoring may retain incomplete drafts. */\n getExecutionConfigurationIssues(): string[] {\n return [];\n }\n\n getAvailableResponseValueSlots(byType?: ValueType): ValueRefTypeLookup {\n const valueRefs: ValueRefTypeLookup = {};\n\n for (const slot of this.getResponseSlotDefinitions()) {\n valueRefs[JSON.stringify([slot.slotId, ValueReferenceMethod.get])] = slot.valueType;\n valueRefs[JSON.stringify([slot.slotId, ValueReferenceMethod.isDefined])] = ValueType.boolean;\n }\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, config: this.config };\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.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 for (const { expression, location } of collectConfigValueExpressions(this.config)) {\n for (const ref of collectExpressionResponseReferences(expression)) {\n usages.push({\n itemId: this.id,\n fullComponentKey: location,\n usageType: ReferenceUsageType.validations,\n valueReference: ref,\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 interface ItemDisplayPath {\n itemId: string;\n name: string;\n path: string[];\n namePath: string[];\n breadcrumb: string;\n parentBreadcrumb: string;\n}\n\nexport function getCompositionLabel(types: readonly string[], locale: string): string {\n const language = locale.split(\"-\")[0];\n const labels: Record<string, Record<string, string>> = {\n en: {\n choiceItem: \"Choice\",\n formItem: \"Form\",\n formMatrix: \"Form matrix\",\n choiceMatrix: \"Choice matrix\",\n consentItem: \"Consent\",\n infoItem: \"Information\",\n group: \"Group\",\n \"page-break\": \"Page break\",\n empty: \"Empty item\",\n },\n nl: {\n choiceItem: \"Keuze\",\n formItem: \"Formulier\",\n formMatrix: \"Formuliermatrix\",\n choiceMatrix: \"Keuzematrix\",\n consentItem: \"Toestemming\",\n infoItem: \"Informatie\",\n group: \"Groep\",\n \"page-break\": \"Pagina-einde\",\n empty: \"Leeg item\",\n },\n de: {\n choiceItem: \"Auswahl\",\n formItem: \"Formular\",\n formMatrix: \"Formularmatrix\",\n choiceMatrix: \"Auswahlmatrix\",\n consentItem: \"Einwilligung\",\n infoItem: \"Information\",\n group: \"Gruppe\",\n \"page-break\": \"Seitenumbruch\",\n empty: \"Leeres Element\",\n },\n };\n const dictionary = labels[language] ?? labels.en;\n return (\n [...new Set(types)]\n .map((type) => dictionary[type])\n .filter(Boolean)\n .join(\" + \") || dictionary.empty\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.metadata?.itemLabel ?? \"\"}'`);\n }\n if (index2 === -1) {\n throw new Error(`Item '${withId}' not found in group '${this.metadata?.itemLabel ?? \"\"}'`);\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.metadata?.itemLabel ?? \"\"}'`);\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_VERSION = 2;\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 schemaVersion: number;\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 = structuredCloneMethod(translations || {});\n }\n\n /** Cheap revision fork. Every writer replaces its path before changing it. */\n fork(): SurveyTranslations {\n const next = new SurveyTranslations();\n next._translations = this._translations;\n return next;\n }\n\n serialize(): JsonSurveyTranslations | undefined {\n return this.locales.length ? structuredCloneMethod(this._translations) : undefined;\n }\n\n get locales(): string[] {\n return Object.keys(this._translations);\n }\n\n private replaceLocale(locale: string, value: JsonSurveyTranslations[string]): void {\n this._translations = { ...this._translations, [locale]: value };\n }\n\n private replaceItem(\n locale: string,\n itemId: string,\n fields?: JsonComponentContent,\n keepEmpty = false,\n ): void {\n const current = this._translations[locale] ?? {};\n const items = { ...current.itemTranslations };\n if (fields && (keepEmpty || Object.keys(fields).length)) items[itemId] = fields;\n else delete items[itemId];\n this.replaceLocale(locale, { ...current, itemTranslations: items });\n }\n\n addLocale(locale: string): boolean {\n validateLocale(locale);\n if (this._translations[locale]) return false;\n this.replaceLocale(locale, {});\n return true;\n }\n\n removeLocale(locale: string): void {\n validateLocale(locale);\n const next = { ...this._translations };\n delete next[locale];\n this._translations = next;\n }\n\n renameLocale(oldLocale: string, newLocale: string): void {\n validateLocale(oldLocale);\n validateLocale(newLocale);\n if (this._translations[oldLocale]) {\n this.replaceLocale(newLocale, this._translations[oldLocale]);\n this.removeLocale(oldLocale);\n }\n }\n\n cloneLocaleAs(locale: string, newLocale: string): void {\n validateLocale(locale);\n validateLocale(newLocale);\n if (this._translations[locale]) this.replaceLocale(newLocale, this._translations[locale]);\n }\n\n get surveyCardContent(): SurveyCardTranslations | undefined {\n const result: SurveyCardTranslations = {};\n for (const locale of this.locales) {\n const content = this._translations[locale].surveyCardContent;\n if (content) result[locale] = structuredCloneMethod(content);\n }\n return result;\n }\n\n get navigationContent(): { [locale: string]: NavigationContent } | undefined {\n const result: { [locale: string]: NavigationContent } = {};\n for (const locale of this.locales) {\n const content = this._translations[locale].navigationContent;\n if (content) result[locale] = structuredCloneMethod(content);\n }\n return result;\n }\n\n get validationMessages(): { [locale: string]: { invalidResponse?: Content } } | undefined {\n const result: { [locale: string]: { invalidResponse?: Content } } = {};\n for (const locale of this.locales) {\n const content = this._translations[locale].validationMessages;\n if (content) result[locale] = structuredCloneMethod(content);\n }\n return result;\n }\n\n setSurveyCardContent(locale: string, content?: SurveyCardContent): void {\n validateLocale(locale);\n if (!content && !this._translations[locale]) return;\n this.replaceLocale(locale, {\n ...this._translations[locale],\n surveyCardContent: structuredCloneMethod(content),\n });\n }\n\n setNavigationContent(locale: string, content?: NavigationContent): void {\n validateLocale(locale);\n if (!content && !this._translations[locale]) return;\n this.replaceLocale(locale, {\n ...this._translations[locale],\n navigationContent: structuredCloneMethod(content),\n });\n }\n\n setValidationMessages(locale: string, content?: { invalidResponse?: Content }): void {\n validateLocale(locale);\n if (!content && !this._translations[locale]) return;\n this.replaceLocale(locale, {\n ...this._translations[locale],\n validationMessages: structuredCloneMethod(content),\n });\n }\n\n getItemTranslationContent(\n itemId: string,\n locale: string,\n contentKey: string,\n fallbackLocale?: string,\n ): Content | undefined {\n const value =\n this._translations[locale]?.itemTranslations?.[itemId]?.[contentKey] ??\n (fallbackLocale\n ? this._translations[fallbackLocale]?.itemTranslations?.[itemId]?.[contentKey]\n : undefined);\n return structuredCloneMethod(value);\n }\n\n setItemTranslationContent(\n itemId: string,\n locale: string,\n contentKey: string,\n content?: Content,\n ): boolean {\n validateLocale(locale);\n const current = this._translations[locale]?.itemTranslations?.[itemId];\n if (JSON.stringify(current?.[contentKey]) === JSON.stringify(content)) return false;\n const fields = { ...current };\n if (content === undefined) delete fields[contentKey];\n else fields[contentKey] = structuredCloneMethod(content);\n this.replaceItem(locale, itemId, fields);\n return true;\n }\n\n getItemTranslations(itemId: string): SurveyItemTranslations | undefined {\n const result = new SurveyItemTranslations();\n for (const locale of this.locales) {\n result.setAllForLocale(\n locale,\n structuredCloneMethod(this._translations[locale].itemTranslations?.[itemId]),\n );\n }\n return result.locales.length ? result : undefined;\n }\n\n setItemTranslations(itemId: string, content?: SurveyItemTranslations): void {\n const normalized = content?.clone().compact();\n for (const locale of new Set([...this.locales, ...(normalized?.locales ?? [])])) {\n validateLocale(locale);\n const fields = normalized?.getAllForLocale(locale);\n if (fields || this._translations[locale]?.itemTranslations?.[itemId])\n this.replaceItem(locale, itemId, fields);\n }\n }\n\n onComponentKeyChanged(itemId: string, oldKey: string, newKey: string): void {\n for (const locale of this.locales) {\n const current = this._translations[locale].itemTranslations?.[itemId];\n if (!current) continue;\n const fields = { ...current };\n for (const key of Object.keys(current)) {\n if (key === oldKey || key.startsWith(oldKey + \".\")) {\n fields[key.replace(oldKey, newKey)] = current[key];\n delete fields[key];\n }\n }\n this.replaceItem(locale, itemId, fields, true);\n }\n }\n\n onComponentDeleted(itemId: string, componentKey: string): void {\n for (const locale of this.locales) {\n const current = this._translations[locale].itemTranslations?.[itemId];\n if (!current) continue;\n const fields = { ...current };\n for (const key of Object.keys(current)) {\n if (key === componentKey || key.startsWith(componentKey + \".\")) delete fields[key];\n }\n this.replaceItem(locale, itemId, fields, true);\n }\n }\n\n onItemDeleted(itemId: string): void {\n for (const locale of this.locales) {\n if (this._translations[locale].itemTranslations?.[itemId]) this.replaceItem(locale, itemId);\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 {\n CURRENT_SURVEY_SCHEMA_VERSION,\n CURRENT_SURVEY_SCHEMA,\n RawSurvey,\n RawSurveyAsset,\n} 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, getContentPlainText } from \"./utils/content\";\nimport { getCompositionLabel, type ItemDisplayPath } from \"./item-display-name\";\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 { ResponseSlotRegistry } from \"./responses/slot-registry\";\nimport { createItemCore, ItemTypeRegistry } from \"./registry/item-registry\";\nimport { GroupItemCore } from \"./registry/built-in-items\";\nimport { generateId, structuredCloneMethod } from \"../utils\";\nimport {\n analyzeSurveyExpressionReferences,\n isBlockingSurveyExpressionReferenceDiagnostic,\n type SurveyExpressionResponseSlot,\n} from \"../expressions/reference-integrity\";\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 /**\n * Derive a read revision from an already detached view. Editable core instances\n * are never reused: the changed item is reconstructed from owned raw data.\n * Other detached items are unchanged by translation publication.\n */\n withItemTranslationContent(\n rawItem: RawSurveyItem,\n locale: string,\n contentKey: string,\n content?: Content,\n ): Survey {\n const next = new Survey(this.pluginRegistry);\n next.surveyItems = new Map(this.surveyItems);\n next.surveyItems.set(rawItem.id, next.createItemFromRaw(structuredCloneMethod(rawItem)));\n next._translations = this.translations.fork();\n next._translations.setItemTranslationContent(rawItem.id, locale, contentKey, content);\n next._assets = this._assets;\n next._templateValues = this._templateValues;\n next.metadata = this.metadata;\n next.maxItemsPerPage = this.maxItemsPerPage;\n return next;\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 schemaVersion: CURRENT_SURVEY_SCHEMA_VERSION,\n metadata: { surveyKey: newKey },\n surveyItems: [\n {\n id: generateId(),\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 if (rawSurvey.schemaVersion !== CURRENT_SURVEY_SCHEMA_VERSION)\n throw new Error(\n `Unsupported survey format version: ${String(rawSurvey.schemaVersion)}. Recreate this draft using the current 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 if (survey.surveyItems.has(item.id))\n throw new Error(`Duplicate survey item identity: ${item.id}`);\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 schemaVersion: CURRENT_SURVEY_SCHEMA_VERSION,\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 return this.metadata?.surveyKey;\n }\n\n resolveItemEditorName(itemId: string, locale = this.locales[0] ?? \"en\"): string {\n const item = this.surveyItems.get(itemId);\n if (!item) return getCompositionLabel([], locale);\n const explicit = item.metadata.itemLabel?.trim();\n if (explicit) return explicit;\n const translations = this.getItemTranslations(itemId);\n for (const key of item.getOutlineContentKeys()) {\n const content = translations?.getContent(locale, key, this.locales[0]);\n if (content) {\n const summary = getContentPlainText(content).replace(/\\s+/g, \" \").trim();\n if (summary) return summary;\n }\n }\n return getCompositionLabel(item.getCompositionTypes(), locale);\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 itemOutline(): ItemDisplayPath[] {\n return [...this.surveyItems.keys()].map((id) => this.getItemDisplayPath(id)!);\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 getItemDisplayPath(\n itemId: string,\n locale = this.locales[0] ?? \"en\",\n ): ItemDisplayPath | undefined {\n if (!this.surveyItems.has(itemId)) return;\n const path = this.getItemPath(itemId);\n const name = this.resolveItemEditorName(itemId, locale);\n const namePath = path.map((id) => this.resolveItemEditorName(id, locale));\n return {\n itemId,\n name,\n path,\n namePath,\n breadcrumb: [...namePath, name].join(\" / \"),\n parentBreadcrumb: namePath.join(\" / \"),\n };\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\n .getResponseSlotDefinitions()\n .map((slot) => ({ ...slot, exportSettings: item.rawItem.responseSettings?.[slot.slotId] })),\n }));\n }\n\n /** Compile a detached index from item declarations; diagnostics retain incomplete drafts. */\n getResponseSlotRegistry(): ResponseSlotRegistry {\n const declarations = this.getResponseSlotDefinitions().map(({ itemId, slots }) => ({\n itemId,\n slots: slots.map((slot) => ({\n ...slot,\n ...(slot.referenceValueLabelKeys\n ? {\n referenceValueLabels: Object.fromEntries(\n this.locales.map((locale) => [\n locale,\n Object.fromEntries(\n Object.entries(slot.referenceValueLabelKeys!).map(([id, key]) => [\n id,\n getContentPlainText(\n this.getItemTranslations(itemId)?.getContent(locale, key, this.locales[0]),\n ),\n ]),\n ),\n ]),\n ),\n }\n : {}),\n })),\n }));\n const registry = new ResponseSlotRegistry(declarations);\n for (const { itemId, slots } of declarations)\n for (const slotId of Object.keys(\n this.surveyItems.get(itemId)!.rawItem.responseSettings ?? {},\n )) {\n if (!slots.some((slot) => slot.slotId === slotId))\n registry.diagnostics.push({\n code: \"unknown-slot\",\n slotId,\n itemId,\n message: `Response settings reference an unknown variable \"${slotId}\" on item \"${itemId}\".`,\n });\n }\n return registry;\n }\n\n /** One typed declaration path for editor, runtime and export integrity checks. */\n getExpressionResponseSlots(): SurveyExpressionResponseSlot[] {\n return this.getResponseSlotRegistry().definitions.flatMap((slot) =>\n ([\"get\", \"isDefined\"] as const).map((method) => ({\n ref: JSON.stringify([slot.slotId, method]),\n itemId: slot.itemId,\n valueType: method === \"get\" ? slot.valueType : ValueType.boolean,\n ...(method === \"get\" && slot.allowedValues ? { allowedValues: slot.allowedValues } : {}),\n })),\n );\n }\n\n getExpressionReferenceDiagnostics() {\n return analyzeSurveyExpressionReferences({\n survey: this.serialize(),\n responseSlots: this.getExpressionResponseSlots(),\n });\n }\n\n getBlockingExpressionIssues(): string[] {\n return this.getExpressionReferenceDiagnostics()\n .filter(isBlockingSurveyExpressionReferenceDiagnostic)\n .map((diagnostic) => diagnostic.message);\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","/** One opaque codec shared by export projections, profiles and codebooks. */\nexport type ExportColumnIdentity =\n | readonly [\"response\", string, \"value\"]\n | readonly [\"response\", string, \"option\", string]\n | readonly [\"meta\", string]\n | readonly [\"context\", string];\n\nexport function encodeExportColumnId(identity: ExportColumnIdentity): string {\n return JSON.stringify(identity);\n}\n\nexport function decodeExportColumnId(value: string): ExportColumnIdentity {\n const tuple: unknown = JSON.parse(value);\n if (\n !Array.isArray(tuple) ||\n tuple.some((part) => typeof part !== \"string\") ||\n !(\n (tuple.length === 2 && (tuple[0] === \"meta\" || tuple[0] === \"context\")) ||\n (tuple[0] === \"response\" &&\n ((tuple.length === 3 && tuple[2] === \"value\") ||\n (tuple.length === 4 && tuple[2] === \"option\")))\n )\n )\n throw new Error(`Invalid export column ID: ${value}`);\n if (JSON.stringify(tuple) !== value)\n throw new Error(\"Export column IDs must use the canonical JSON tuple encoding\");\n return tuple as unknown as ExportColumnIdentity;\n}\n","import type { ResponseValue, ValueType } from \"../survey/responses/value-types\";\nimport type { Survey } from \"../survey/survey\";\n\n/** Meta column keys in fixed order (common attributes first). */\nexport const META_COLUMN_ORDER = [\n \"submittedAt\",\n \"participantId\",\n \"responseId\",\n \"sourceId\",\n] as const;\n\nexport type MetaColumnKey = (typeof META_COLUMN_ORDER)[number];\n\n/** Built-in transform modes for slot export. */\nexport const SlotTransformMode = {\n default: \"default\",\n mask: \"mask\",\n dateFormat: \"dateFormat\",\n} as const;\n\nexport type SlotTransformMode = (typeof SlotTransformMode)[keyof typeof SlotTransformMode];\n\n/** Slot identifier for profile overrides. */\nexport interface SlotRef {\n slotId: string;\n}\n\n/** Configuration for dateFormat transform. Uses date-fns format pattern. */\nexport interface DateFormatConfig {\n pattern: string;\n}\n\n/** Slot-level override in exporter profile. */\nexport interface SlotTransformConfig {\n include?: boolean;\n categorical?: \"codes\" | \"labels\" | \"ids\";\n multiple?: \"json\" | \"delimited\" | \"indicators\";\n delimiter?: string;\n locale?: string;\n optionCodes?: Record<string, string>;\n optionLabels?: Record<string, string>;\n booleanValues?: { true: string; false: string };\n precision?: number;\n durationUnit?: import(\"../survey/responses/value-types\").DurationUnit;\n /** Built-in mode or custom formatter key. */\n mode: SlotTransformMode | string;\n /** For dateFormat: date-fns format pattern (e.g. 'yyyy-MM-dd'). */\n dateFormat?: DateFormatConfig;\n /** For mask: replacement string (default '***'). */\n maskChar?: string;\n}\n\nexport const EXPORTER_PROFILE_SCHEMA_VERSION = 1;\n\n/** Versioned export settings, associated explicitly with a supplied schema. */\nexport interface ExporterProfile {\n schemaVersion: typeof EXPORTER_PROFILE_SCHEMA_VERSION;\n /** Slot-level overrides. Key: exact opaque slot ID. Profile overrides always win over defaults. */\n slotOverrides?: Record<string, SlotTransformConfig>;\n /** Header overrides keyed by stable column id. */\n columnHeaders?: Record<string, string>;\n /** Overrides for context keys. Key = context key name. */\n contextOverrides?: Record<string, SlotTransformConfig>;\n /** Ordered list of response column ids. Columns in this list appear in this order; others follow alphabetically. */\n responseColumnOrder?: string[];\n /** Ordered list of context column keys. If omitted, context columns are alphabetical. */\n contextColumnOrder?: string[];\n}\n\n/** The host supplies the exact definition used to collect these submissions. */\nexport interface ExportBatch {\n schema: Survey;\n responses: import(\"../survey/responses/survey-response\").SurveyResponse[];\n profile?: ExporterProfile;\n sourceId?: string;\n}\n\nexport interface CombinedExportOptions {\n profile?: ExporterProfile;\n codingPolicy?: \"original\" | \"harmonized\";\n}\n\n/** Source of an export column. */\nexport const ExportColumnSource = {\n meta: \"meta\",\n context: \"context\",\n response: \"response\",\n} as const;\ntype ExportColumnSource = (typeof ExportColumnSource)[keyof typeof ExportColumnSource];\n\n/** Single export column. */\nexport interface ExportColumn {\n /** Stable internal identifier used for ordering/deduplication. */\n id: string;\n /** Exported column header written to CSV. */\n header: string;\n source: ExportColumnSource;\n /** For meta: the meta field name. */\n metaField?: MetaColumnKey;\n /** For context: the context key. */\n contextKey?: string;\n /** For response: item/slot ids and value type. */\n itemId?: string;\n slotId?: string;\n valueType?: ValueType;\n optionId?: string;\n}\n\n/** Single export row: key -> string value. */\nexport type ExportRow = Record<string, string>;\n\n/** CSV export options. */\nexport interface CsvExportOptions {\n /** Cell separator (default ','). */\n separator?: string;\n /** Line ending (default '\\n'). */\n lineEnding?: string;\n /** Include header row (default true). */\n includeHeader?: boolean;\n}\n\n/** Parameters for single-slot export (unit-testable). */\nexport interface ExportSingleSlotParams {\n /** Optional categorical codes for reference values. Missing or blank mappings are errors. */\n referenceValueKeys?: Record<string, string>;\n value: ResponseValue | undefined;\n valueType: ValueType;\n /** Resolved formatter config (default or profile override). */\n transformConfig: SlotTransformConfig;\n}\n","import { formatCalendarDate } from \"../calendar-date\";\nimport { ResponseValue, ValueType, NumberPrecision } from \"../survey/responses/value-types\";\nimport { SlotTransformMode, type ExportSingleSlotParams, type SlotTransformConfig } from \"./types\";\n\n/** Default transform config when no profile override. */\nexport const DEFAULT_TRANSFORM: SlotTransformConfig = {\n mode: SlotTransformMode.default,\n};\n\n/**\n * Export a single response slot to a string. Pure function for unit testing.\n * Uses default formatting by ValueType unless overridden by transformConfig.\n */\nexport function exportSingleResponseSlot(params: ExportSingleSlotParams): string {\n const { value, valueType, transformConfig } = params;\n\n if (value === undefined || value === null) {\n return \"\";\n }\n\n const mode = transformConfig.mode;\n\n if (mode === SlotTransformMode.mask) {\n return maskValue(value, transformConfig.maskChar ?? \"***\");\n }\n\n if (\n mode === SlotTransformMode.dateFormat &&\n (valueType === ValueType.date || valueType === ValueType.dateArray)\n ) {\n return formatDateValue(value, transformConfig.dateFormat?.pattern ?? \"yyyy-MM-dd\");\n }\n\n if (value.type === ValueType.reference || value.type === ValueType.referenceArray) {\n const keys =\n transformConfig.categorical === \"labels\"\n ? transformConfig.optionLabels\n : (transformConfig.optionCodes ?? params.referenceValueKeys);\n const exportReference = (id: string) => {\n if (transformConfig.categorical === \"ids\") return id;\n const key = keys && Object.hasOwn(keys, id) ? keys[id] : undefined;\n if (typeof key !== \"string\" || !key.trim())\n throw new Error(`Missing categorical export mapping for option \"${id}\"`);\n return key.trim();\n };\n return value.type === ValueType.reference\n ? exportReference(value.value)\n : JSON.stringify(value.value.map(exportReference));\n }\n return formatDefault(value);\n}\n\nexport const BooleanExportValues = {\n TRUE: \"TRUE\",\n FALSE: \"FALSE\",\n} as const;\nexport type BooleanExportValues = (typeof BooleanExportValues)[keyof typeof BooleanExportValues];\n\nfunction formatDefault(value: ResponseValue): string {\n switch (value.type) {\n case ValueType.string:\n return String(value.value);\n case ValueType.reference:\n return String(value.value);\n case ValueType.boolean:\n return value.value ? BooleanExportValues.TRUE : BooleanExportValues.FALSE;\n case ValueType.number: {\n const p = (value as { precision?: NumberPrecision }).precision;\n return p === NumberPrecision.int ? String(Math.floor(value.value)) : String(value.value);\n }\n case ValueType.date:\n return value.value;\n case ValueType.duration: {\n const d = value as { value: number; unit: string; precision?: NumberPrecision };\n const num = d.precision === NumberPrecision.int ? Math.floor(d.value) : d.value;\n return `${num} ${d.unit}`;\n }\n case ValueType.stringArray:\n return (value as { value: string[] }).value.join(\"; \");\n case ValueType.referenceArray:\n return (value as { value: string[] }).value.join(\"; \");\n case ValueType.numberArray: {\n const arr = (value as { value: number[]; precision?: NumberPrecision }).value;\n const prec = (value as { precision?: NumberPrecision }).precision;\n const fmt = (n: number) => (prec === NumberPrecision.int ? Math.floor(n) : n);\n return arr.map(fmt).join(\"; \");\n }\n case ValueType.dateArray: {\n return value.value.join(\"; \");\n }\n case ValueType.durationArray: {\n const d = value as { value: number[]; unit: string; precision?: NumberPrecision };\n const prec = d.precision === NumberPrecision.int;\n const fmt = (n: number) => (prec ? Math.floor(n) : n);\n return d.value.map((v) => `${fmt(v)} ${d.unit}`).join(\"; \");\n }\n default:\n return String((value as { value?: unknown }).value ?? \"\");\n }\n}\n\nfunction formatDateValue(value: ResponseValue, pattern: string): string {\n if (value.type === ValueType.date) {\n return formatCalendarDate(value.value, pattern);\n }\n if (value.type === ValueType.dateArray) {\n return value.value.map((date) => formatCalendarDate(date, pattern)).join(\"; \");\n }\n return formatDefault(value);\n}\n\nfunction maskValue(value: ResponseValue, maskChar: string): string {\n const str = valueToString(value);\n return str ? maskChar : \"\";\n}\n\nfunction valueToString(value: ResponseValue): string {\n switch (value.type) {\n case ValueType.string:\n case ValueType.reference:\n return String(value.value);\n case ValueType.stringArray:\n case ValueType.referenceArray:\n return (value as { value: string[] }).value.join(\" \");\n default:\n return String((value as { value?: unknown }).value ?? \"\");\n }\n}\n","import { formatCalendarDate } from \"../calendar-date\";\nimport type { OwnedResponseSlotDefinition, ResponseValue } from \"../survey/responses\";\nimport { DurationUnits, ValueType } from \"../survey/responses/value-types\";\nimport { encodeExportColumnId } from \"./column-id\";\nimport { exportSingleResponseSlot } from \"./slot-formatter\";\nimport type { ExportColumn, SlotTransformConfig } from \"./types\";\n\nexport function optionIds(slot: OwnedResponseSlotDefinition): string[] {\n return [\n ...new Set(\n (slot.allowedValues ?? []).flatMap((value) =>\n value.type === ValueType.reference\n ? [value.value]\n : value.type === ValueType.referenceArray\n ? value.value\n : [],\n ),\n ),\n ];\n}\nexport function optionMapping(\n slot: OwnedResponseSlotDefinition,\n config: SlotTransformConfig,\n): Record<string, string> {\n const ids = optionIds(slot);\n const encoding = config.categorical ?? \"codes\";\n const mapping =\n encoding === \"ids\"\n ? Object.fromEntries(ids.map((id) => [id, id]))\n : encoding === \"labels\"\n ? (config.optionLabels ?? slot.referenceValueLabels?.[config.locale ?? \"en\"] ?? {})\n : (config.optionCodes ?? slot.referenceValueKeys ?? {});\n const used = new Set<string>();\n for (const id of ids) {\n if (typeof mapping[id] !== \"string\" || !mapping[id].trim())\n throw new Error(\n `Variable \"${slot.variableName}\" has no ${encoding} mapping for option \"${id}\"`,\n );\n if (used.has(mapping[id]))\n throw new Error(\n `Variable \"${slot.variableName}\" has ambiguous ${encoding} mapping \"${mapping[id]}\"`,\n );\n used.add(mapping[id]);\n }\n for (const id of [\n ...Object.keys(config.optionCodes ?? {}),\n ...Object.keys(config.optionLabels ?? {}),\n ])\n if (!ids.includes(id))\n throw new Error(`Mapping for \"${slot.variableName}\" contains unknown option \"${id}\"`);\n return mapping;\n}\n\n/** Compile every declared role before applying inclusion settings. */\nexport function projectSlot(\n slot: OwnedResponseSlotDefinition,\n config: SlotTransformConfig,\n allRoles = false,\n): ExportColumn[] {\n if (![\"default\", \"mask\", \"dateFormat\"].includes(config.mode))\n throw new Error(`Unsupported export transform \"${config.mode}\"`);\n if (config.categorical && ![\"codes\", \"labels\", \"ids\"].includes(config.categorical))\n throw new Error(\"Unsupported categorical encoding\");\n if (config.multiple && ![\"json\", \"delimited\", \"indicators\"].includes(config.multiple))\n throw new Error(\"Unsupported multiple-selection encoding\");\n if (config.mode === \"dateFormat\" && slot.valueType !== \"date\" && slot.valueType !== \"date[]\")\n throw new Error(\"Date formatting requires a date variable\");\n if (config.mode === \"dateFormat\") {\n const pattern = config.dateFormat?.pattern ?? \"yyyy-MM-dd\";\n if (!pattern.trim()) throw new Error(\"Date export pattern cannot be empty\");\n formatCalendarDate(\"2026-01-15\", pattern);\n }\n if (\n config.durationUnit &&\n (!Object.values(DurationUnits).includes(config.durationUnit) ||\n !slot.valueType.startsWith(\"duration\"))\n )\n throw new Error(\"Duration units require a duration variable and a supported unit\");\n if (\n config.booleanValues &&\n (!config.booleanValues.true ||\n !config.booleanValues.false ||\n config.booleanValues.true === config.booleanValues.false)\n )\n throw new Error(\"Boolean export values must be distinct and nonempty\");\n const categorical =\n slot.valueType === ValueType.reference || slot.valueType === ValueType.referenceArray;\n if (config.multiple && slot.valueType !== ValueType.referenceArray)\n throw new Error(\n `Multiple-selection encoding requires a reference[] variable: ${slot.variableName}`,\n );\n if ((config.categorical || config.optionCodes || config.optionLabels) && !categorical)\n throw new Error(`Categorical encoding requires a categorical variable: ${slot.variableName}`);\n if (config.booleanValues && slot.valueType !== ValueType.boolean)\n throw new Error(`Boolean encoding requires a boolean variable: ${slot.variableName}`);\n if (\n config.precision !== undefined &&\n ![\"number\", \"number[]\", \"duration\", \"duration[]\"].includes(slot.valueType)\n )\n throw new Error(\"Precision requires a numeric or duration variable\");\n if (\n config.precision !== undefined &&\n (!Number.isInteger(config.precision) || config.precision < 0 || config.precision > 15)\n )\n throw new Error(\"Precision must be an integer between 0 and 15\");\n if (\n config.multiple === \"delimited\" &&\n (!config.delimiter || config.delimiter.includes('\"') || /[\\r\\n]/.test(config.delimiter))\n )\n throw new Error(\n \"Delimited selection export requires an explicit delimiter without quotes or line breaks\",\n );\n if (!allRoles && (config.include === false || (slot.computed && config.include !== true)))\n return [];\n const mapping = categorical && !allRoles ? optionMapping(slot, config) : {};\n const base = {\n source: \"response\" as const,\n itemId: slot.itemId,\n slotId: slot.slotId,\n valueType: slot.valueType,\n };\n const scalar = {\n ...base,\n id: encodeExportColumnId([\"response\", slot.slotId, \"value\"]),\n header: slot.variableName,\n };\n const indicators = () =>\n optionIds(slot).map((optionId) => ({\n ...base,\n id: encodeExportColumnId([\"response\", slot.slotId, \"option\", optionId]),\n header: `${slot.variableName}_${mapping[optionId] ?? optionId}`,\n optionId,\n }));\n return allRoles\n ? [scalar, ...(slot.valueType === ValueType.referenceArray ? indicators() : [])]\n : config.multiple === \"indicators\"\n ? indicators()\n : [scalar];\n}\n\nexport function formatProjectedValue(\n slot: OwnedResponseSlotDefinition,\n column: ExportColumn,\n value: ResponseValue | undefined,\n config: SlotTransformConfig,\n): string {\n if (value === undefined) return \"\";\n if (config.mode === \"mask\") return config.maskChar ?? \"***\";\n if (value.type === ValueType.reference || value.type === ValueType.referenceArray) {\n const mapping = optionMapping(slot, config);\n const values = value.type === ValueType.reference ? [value.value] : value.value;\n if (values.some((id) => !Object.hasOwn(mapping, id)))\n throw new Error(`Unmapped option in \"${slot.variableName}\"`);\n if (column.optionId) return values.includes(column.optionId) ? \"1\" : \"0\";\n const encoded = values.map((id) => mapping[id]);\n if (value.type === ValueType.reference) return encoded[0];\n if (config.multiple === \"delimited\")\n return encoded.map((entry) => `\"${entry.replaceAll('\"', '\"\"')}\"`).join(config.delimiter!);\n return JSON.stringify(encoded);\n }\n if (value.type === ValueType.boolean) {\n const values = config.booleanValues ?? { true: \"TRUE\", false: \"FALSE\" };\n if (!values.true || !values.false || values.true === values.false)\n throw new Error(\"Boolean export values must be distinct and nonempty\");\n return value.value ? values.true : values.false;\n }\n if (value.type === ValueType.duration || value.type === ValueType.durationArray) {\n const unit = config.durationUnit ?? \"seconds\";\n const seconds: Record<string, number> = {\n seconds: 1,\n minutes: 60,\n hours: 3600,\n days: 86400,\n weeks: 604800,\n };\n if (unit !== value.unit && (!seconds[unit] || !seconds[value.unit]))\n throw new Error(\"Calendar months and years cannot be converted to fixed durations\");\n const convert = (number: number) => {\n const n = number * (unit === value.unit ? 1 : seconds[value.unit] / seconds[unit]);\n return config.precision === undefined ? String(n) : n.toFixed(config.precision);\n };\n return Array.isArray(value.value)\n ? JSON.stringify(value.value.map(convert))\n : convert(value.value);\n }\n if (value.type === ValueType.number && config.precision !== undefined)\n return value.value.toFixed(config.precision);\n if (value.type === ValueType.numberArray && config.precision !== undefined)\n return `[${value.value.map((number) => number.toFixed(config.precision)).join(\",\")}]`;\n if (Array.isArray(value.value) && config.mode !== \"dateFormat\")\n return JSON.stringify(value.value);\n return exportSingleResponseSlot({ value, valueType: slot.valueType, transformConfig: config });\n}\n\n/** Collect draft diagnostics without stopping at the first unfinished variable. */\nexport function getDefaultProjectionIssues(survey: import(\"../survey/survey\").Survey): string[] {\n const issues: string[] = [];\n const headers = new Set<string>([\"submittedAt\", \"participantId\", \"responseId\", \"sourceId\"]);\n for (const slot of survey.getResponseSlotRegistry().definitions) {\n try {\n for (const column of projectSlot(slot, { mode: \"default\", ...slot.exportSettings })) {\n if (headers.has(column.header))\n issues.push(`Duplicate export column header '${column.header}'`);\n headers.add(column.header);\n }\n } catch (error) {\n issues.push(error instanceof Error ? error.message : String(error));\n }\n }\n return issues;\n}\n\n/** Fully resolved output semantics, shared by compatibility checks and codebooks. */\nexport function resolvedSlotEncoding(\n slot: OwnedResponseSlotDefinition,\n config: SlotTransformConfig,\n): SlotTransformConfig {\n const encoding: SlotTransformConfig = {\n mode: config.mode,\n include: config.include ?? !slot.computed,\n };\n if (config.mode === \"mask\") return { ...encoding, maskChar: config.maskChar ?? \"***\" };\n if (config.mode === \"dateFormat\")\n encoding.dateFormat = { pattern: config.dateFormat?.pattern ?? \"yyyy-MM-dd\" };\n if (slot.valueType === \"reference\" || slot.valueType === \"reference[]\") {\n encoding.categorical = config.categorical ?? \"codes\";\n if (encoding.categorical === \"labels\") {\n encoding.locale = config.locale ?? \"en\";\n encoding.optionLabels = optionMapping(slot, config);\n } else if (encoding.categorical === \"codes\") encoding.optionCodes = optionMapping(slot, config);\n if (slot.valueType === \"reference[]\") {\n encoding.multiple = config.multiple ?? \"json\";\n if (encoding.multiple === \"delimited\") encoding.delimiter = config.delimiter;\n }\n }\n if (slot.valueType === \"boolean\")\n encoding.booleanValues = config.booleanValues ?? { true: \"TRUE\", false: \"FALSE\" };\n if (slot.valueType.startsWith(\"duration\"))\n encoding.durationUnit = config.durationUnit ?? \"seconds\";\n if (config.precision !== undefined) encoding.precision = config.precision;\n return structuredClone(encoding);\n}\n"],"mappings":";;AAMA,MAAM,OAAO,GAAW,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,GAAG;AACnE,MAAM,eAAe,MAAc,UACjC,UAAU,IACN,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ,KACpD,KACA,KACF;CAAC;CAAG;CAAG;CAAG;AAAE,CAAC,CAAC,SAAS,KAAK,IAC1B,KACA;AAER,SAAgB,eAAe,OAAuC;CACpE,IAAI,OAAO,UAAU,YAAY,CAAC,gCAAgC,KAAK,KAAK,GAAG,OAAO;CACtF,MAAM,CAAC,MAAM,OAAO,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtD,OACE,QAAQ,KACR,QAAQ,SACP,UAAU,KAAA,KACR,SAAS,KACR,SAAS,OACR,QAAQ,KAAA,KAAc,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