udp-stencil-component-library 25.18.2-beta.6 → 25.18.2-beta.8

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.
Files changed (73) hide show
  1. package/dist/cjs/index.cjs.js +138 -0
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil-library.cjs.js +1 -1
  5. package/dist/cjs/udp-forms-renderer.cjs.entry.js +591 -603
  6. package/dist/cjs/udp-forms-renderer.entry.cjs.js.map +1 -1
  7. package/dist/cjs/udp-forms-ui.cjs.entry.js +1 -4
  8. package/dist/cjs/udp-forms-ui.entry.cjs.js.map +1 -1
  9. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-ui/udp-forms-ui.js +1 -4
  10. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-ui/udp-forms-ui.js.map +1 -1
  11. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/comments-crud-utils.js +153 -0
  12. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/comments-crud-utils.js.map +1 -0
  13. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.js +104 -0
  14. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.js.map +1 -0
  15. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/{udp-forms-renderer-utils.js → udp-forms-renderer-utils/utils.js} +48 -2
  16. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/utils.js.map +1 -0
  17. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer.js +187 -310
  18. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer.js.map +1 -1
  19. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-handler/UdpFormHandler.js +13 -13
  20. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-handler/UdpFormHandler.js.map +1 -1
  21. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandler.js +142 -0
  22. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandler.js.map +1 -0
  23. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandlerFactory.js +3 -10
  24. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandlerFactory.js.map +1 -1
  25. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/IFormSubmissionHandler.js.map +1 -1
  26. package/dist/collection/components/forms/udp-forms/udp-forms-utils/types.js.map +1 -1
  27. package/dist/collection/index.js +1 -0
  28. package/dist/collection/index.js.map +1 -1
  29. package/dist/collection/udp-utilities/udp-websocket-client/udp-websocket-client.js +137 -0
  30. package/dist/collection/udp-utilities/udp-websocket-client/udp-websocket-client.js.map +1 -0
  31. package/dist/components/index.js +138 -1
  32. package/dist/components/index.js.map +1 -1
  33. package/dist/components/udp-forms-renderer.js +593 -608
  34. package/dist/components/udp-forms-renderer.js.map +1 -1
  35. package/dist/components/udp-forms-ui2.js +1 -4
  36. package/dist/components/udp-forms-ui2.js.map +1 -1
  37. package/dist/docs.json +1 -1
  38. package/dist/esm/index.js +138 -1
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/loader.js +1 -1
  41. package/dist/esm/stencil-library.js +1 -1
  42. package/dist/esm/udp-forms-renderer.entry.js +592 -604
  43. package/dist/esm/udp-forms-renderer.entry.js.map +1 -1
  44. package/dist/esm/udp-forms-ui.entry.js +1 -4
  45. package/dist/esm/udp-forms-ui.entry.js.map +1 -1
  46. package/dist/stencil-library/index.esm.js +1 -1
  47. package/dist/stencil-library/index.esm.js.map +1 -1
  48. package/dist/stencil-library/stencil-library.esm.js +1 -1
  49. package/dist/stencil-library/udp-forms-renderer.entry.esm.js.map +1 -1
  50. package/dist/stencil-library/udp-forms-renderer.entry.js +1 -1
  51. package/dist/stencil-library/udp-forms-renderer.entry.js.map +1 -1
  52. package/dist/stencil-library/udp-forms-ui.entry.esm.js.map +1 -1
  53. package/dist/stencil-library/udp-forms-ui.entry.js +1 -1
  54. package/dist/stencil-library/udp-forms-ui.entry.js.map +1 -1
  55. package/dist/types/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/comments-crud-utils.d.ts +31 -0
  56. package/dist/types/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.d.ts +17 -0
  57. package/dist/types/components/forms/udp-forms/udp-forms-renderer/{udp-forms-renderer-utils.d.ts → udp-forms-renderer-utils/utils.d.ts} +4 -0
  58. package/dist/types/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer.d.ts +6 -10
  59. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-handler/UdpFormHandler.d.ts +5 -6
  60. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandler.d.ts +42 -0
  61. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandlerFactory.d.ts +1 -1
  62. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/IFormSubmissionHandler.d.ts +44 -5
  63. package/dist/types/components/forms/udp-forms/udp-forms-utils/types.d.ts +16 -0
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/udp-utilities/udp-websocket-client/udp-websocket-client.d.ts +34 -0
  66. package/package.json +1 -1
  67. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils.js.map +0 -1
  68. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PrivateFormSubmissionHandler.js +0 -264
  69. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PrivateFormSubmissionHandler.js.map +0 -1
  70. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.js +0 -63
  71. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.js.map +0 -1
  72. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PrivateFormSubmissionHandler.d.ts +0 -131
  73. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.d.ts +0 -15
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repeated-section-utils.js","sourceRoot":"","sources":["../../../../../../src/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAIpE,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAU,EAAE;IACxD,OAAO,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;AACvG,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,eAAoB,EAAO,EAAE;IAC7D,IAAI,CAAC,eAAe;QAAE,OAAO,EAAE,CAAC;IAChC,IAAI,OAAO,eAAe,KAAK,QAAQ;QAAE,OAAO,eAAe,CAAC;IAChE,IAAI,OAAO,eAAe,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACnD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC;IAC7C,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,MAIjD,EAAiF,EAAE;;IAClF,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAElD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AAqB,GAAG,SAAS,CAAC;QAE1C,OAAO,CAAC,aAAa,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC5D,MAAM,kBAAkB,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YAC9C,kBAAkB,CAAC,qBAAqB,GAAG,GAAG,aAAa,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YACxE,OAAO,kBAAkB,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAC9B,UAAU,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;YACvE,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["import { findRepeatGroupKeys } from './utils';\nimport { UdpFormsFieldTypeEnum } from '../../udp-forms-utils/enums';\nimport { DynamicSection, SubmissionResponseData } from '../../udp-forms-utils/types';\n\n\nconst getSectionKey = (section: DynamicSection): string => {\n return section.isOriginalSection ? section.name : `${section.name}_${section.sectionPositionSuffix}`;\n};\n\nconst safeParseFieldProperties = (fieldProperties: any): any => {\n if (!fieldProperties) return {};\n if (typeof fieldProperties === 'object') return fieldProperties;\n if (typeof fieldProperties !== 'string') return {};\n try {\n return JSON.parse(fieldProperties || '{}');\n } catch {\n return {};\n }\n};\n\nexport const computeDuplicateRepeatableSection = (params: {\n dynamicSections: DynamicSection[];\n values: SubmissionResponseData;\n index: number;\n}): { nextDynamicSections: DynamicSection[]; nextValues: SubmissionResponseData } => {\n const { dynamicSections, values, index } = params;\n\n const sectionToClone = dynamicSections[index];\n if (!sectionToClone) return { nextDynamicSections: dynamicSections, nextValues: values };\n\n const cloningSectionName = sectionToClone.name;\n\n // Find existing repeat group indices\n const repeatKeys = findRepeatGroupKeys(cloningSectionName, values);\n const nextRepeatIndex = repeatKeys.length > 0 ? Math.max(...repeatKeys) + 1 : 2;\n\n const clonedSection: DynamicSection = {\n ...structuredClone(sectionToClone),\n formQuestions: (sectionToClone.formQuestions || []).map(q => {\n const newQuestionObj = structuredClone(q);\n newQuestionObj.questionIdentifierKey = `${cloningSectionName}_${nextRepeatIndex}.${q.name}`;\n return newQuestionObj;\n }),\n isOriginalSection: false,\n sectionPositionSuffix: nextRepeatIndex,\n };\n\n // Find the last index of this section group\n let insertAtIndex = index;\n for (let i = index + 1; i < dynamicSections.length; i++) {\n const s = dynamicSections[i];\n if (s.name === cloningSectionName) insertAtIndex = i;\n else break;\n }\n\n const nextDynamicSections: DynamicSection[] = [\n ...dynamicSections.slice(0, insertAtIndex + 1),\n clonedSection,\n ...dynamicSections.slice(insertAtIndex + 1),\n ];\n\n const nextValues: SubmissionResponseData = structuredClone(values || {});\n const newSectionKey = `${cloningSectionName}_${nextRepeatIndex}`;\n const sourceSectionKey = getSectionKey(sectionToClone);\n\n for (const q of clonedSection.formQuestions || []) {\n if (!nextValues[newSectionKey]) nextValues[newSectionKey] = {} as any;\n\n let value: any = '';\n if (q.fieldTypeId === UdpFormsFieldTypeEnum.Paragraph) {\n const sourceVal = values?.[sourceSectionKey]?.[q.name]?.value;\n const props = safeParseFieldProperties(q.fieldProperties);\n const paragraphDefault = props?.paragraphText ?? '';\n value = sourceVal ?? paragraphDefault;\n }\n\n nextValues[newSectionKey][q.name] = { value, comments: [], metadata: {} };\n }\n\n return { nextDynamicSections, nextValues };\n};\n\nexport const computeDeleteRepeatableSection = (params: {\n dynamicSections: DynamicSection[];\n values: SubmissionResponseData;\n index: number;\n}): { nextDynamicSections: DynamicSection[]; nextValues: SubmissionResponseData } => {\n const { dynamicSections, values, index } = params;\n\n const sectionToDelete = dynamicSections[index];\n if (!sectionToDelete || sectionToDelete.isOriginalSection) {\n return { nextDynamicSections: dynamicSections, nextValues: values };\n }\n\n const deleteSectionName = sectionToDelete.name;\n const deleteSuffix = sectionToDelete.sectionPositionSuffix;\n const sectionKeyToDelete = `${deleteSectionName}_${deleteSuffix}`;\n\n const nextValues: SubmissionResponseData = { ...(values || {}) };\n delete nextValues[sectionKeyToDelete];\n\n const updatedSections: DynamicSection[] = structuredClone(dynamicSections);\n updatedSections.splice(index, 1);\n\n // Shift all later repeatable sections backward by 1\n updatedSections.forEach(section => {\n if (\n section.name !== deleteSectionName ||\n section.isOriginalSection ||\n (section.sectionPositionSuffix ?? 0) <= (deleteSuffix ?? 0)\n ) {\n return;\n }\n\n const oldSuffix = section.sectionPositionSuffix as number;\n const oldSectionKey = `${deleteSectionName}_${oldSuffix}`;\n\n const newSuffix = oldSuffix - 1;\n const newSectionKey = `${deleteSectionName}_${newSuffix}`;\n\n section.sectionPositionSuffix = newSuffix;\n\n section.formQuestions = (section.formQuestions || []).map(q => {\n const newSectionQuestion = structuredClone(q);\n newSectionQuestion.questionIdentifierKey = `${newSectionKey}.${q.name}`;\n return newSectionQuestion;\n });\n\n if (nextValues[oldSectionKey]) {\n nextValues[newSectionKey] = structuredClone(nextValues[oldSectionKey]);\n delete nextValues[oldSectionKey];\n }\n });\n\n return { nextDynamicSections: updatedSections, nextValues };\n};"]}
@@ -1,4 +1,4 @@
1
- import { UdpFormsFieldTypeEnum } from "../udp-forms-utils/enums";
1
+ import { UdpFormsFieldTypeEnum, UdpFormsPageIdEnum } from "../../udp-forms-utils/enums";
2
2
  // utility to find repeat group keys from current values
3
3
  export const findRepeatGroupKeys = (sectionName, values) => {
4
4
  const keys = Object.keys(values);
@@ -192,4 +192,50 @@ export const applyUrlSeedValuesForAll = (dynamicSections, urlContext) => {
192
192
  });
193
193
  return merged;
194
194
  };
195
- //# sourceMappingURL=udp-forms-renderer-utils.js.map
195
+ export const replaceUrlWithSubmissionId = (submissionId, history) => {
196
+ // build a URL that preserves the current pathname + hash but replaces the query string
197
+ const pathname = typeof window !== 'undefined' ? window.location.pathname : `/page/${UdpFormsPageIdEnum.FormRendererPageId}`;
198
+ const hash = typeof window !== 'undefined' ? window.location.hash : '';
199
+ const newUrl = `${pathname}?udpf_submissionId=${submissionId}${hash}`;
200
+ const h = history;
201
+ // Prefer history.replace when available, handle react-router v6 navigate function, fallback to push or native replaceState
202
+ if (h) {
203
+ if (typeof h.replace === 'function') {
204
+ h.replace(newUrl);
205
+ return;
206
+ }
207
+ if (typeof h.push === 'function') {
208
+ h.push(newUrl);
209
+ return;
210
+ }
211
+ // react-router v6 exposes a navigate function
212
+ if (typeof h === 'function') {
213
+ try {
214
+ h(newUrl, { replace: true });
215
+ }
216
+ catch (_a) {
217
+ h(newUrl);
218
+ }
219
+ return;
220
+ }
221
+ }
222
+ if (typeof window !== 'undefined' && window.history && typeof window.history.replaceState === 'function') {
223
+ window.history.replaceState({}, '', newUrl);
224
+ }
225
+ else if (typeof window !== 'undefined') {
226
+ window.location.href = newUrl;
227
+ }
228
+ };
229
+ export const enqueueSnackbarSuccess = (message, enqueueSnackbar) => {
230
+ enqueueSnackbar === null || enqueueSnackbar === void 0 ? void 0 : enqueueSnackbar(message, {
231
+ variant: 'success',
232
+ anchorOrigin: { vertical: 'top', horizontal: 'center' },
233
+ });
234
+ };
235
+ export const enqueueSnackbarError = (message, enqueueSnackbar) => {
236
+ enqueueSnackbar === null || enqueueSnackbar === void 0 ? void 0 : enqueueSnackbar(message, {
237
+ variant: 'error',
238
+ anchorOrigin: { vertical: 'top', horizontal: 'center' },
239
+ });
240
+ };
241
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../src/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGxF,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,W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n\n// utility to find repeat group keys from current values\nexport const findRepeatGroupKeys = (sectionName: string, values: Object): number[] => {\n const keys = Object.keys(values);\n const repeatGroupSet = new Set<number>();\n\n // Match: sectionName_2\n const regex = new RegExp(`^${sectionName}_(\\\\d+)`);\n\n keys.forEach(key => {\n const match = key.match(regex);\n if (match && match[1]) {\n repeatGroupSet.add(Number(match[1]));\n }\n });\n\n return Array.from(repeatGroupSet).sort((a, b) => a - b);\n};\n\n\n// build dynamic sections based on the master form\nexport const initializeDynamicSections = (udpForm, currentValues) => {\n const dynamicSections: any[] = [];\n const sortedSections = structuredClone(udpForm.udpFormUdpFormSection).sort(\n (a, b) => a.order - b.order,\n );\n\n for (const section of sortedSections) {\n section.sectionProperties = JSON.parse(section.sectionProperties || {});\n const repeatGroupKeys = findRepeatGroupKeys(section.name, currentValues);\n section.isOriginalSection = true;\n section.sectionPositionSuffix = 1; // default position\n\n // always add the original section into dynamic sections\n dynamicSections.push({\n ...structuredClone(section),\n // dynamicSectionName: section.name,\n formQuestions: structuredClone(udpForm.formQuestions)\n .filter(q => q.formSectionId === section.id)\n .sort((a, b) => a.questionOrder - b.questionOrder)\n .map(q => ({\n ...q,\n questionIdentifierKey: `${section.name}.${q.name}`,\n isShowCommentInput: true,\n })),\n });\n\n // create then add additional sections if there are repeated sections\n if (section.sectionProperties?.isRepeatable && repeatGroupKeys.length > 0) {\n const maxRepeatedSectionSuffix = Math.max(...repeatGroupKeys); // create a new section for the max value of repeat group keys, even if there are no saved answers\n\n // for (const repeatKey of repeatGroupKeys) { // create a section only for the suffix saved\n for (let repeatKey = 2; repeatKey <= maxRepeatedSectionSuffix; repeatKey++) {\n const clonedSection = {\n ...structuredClone(section),\n formQuestions: structuredClone(udpForm.formQuestions)\n .filter(q => q.formSectionId === section.id)\n .sort((a, b) => a.questionOrder - b.questionOrder)\n .map(q => ({\n ...q,\n questionIdentifierKey: `${section.name}_${repeatKey}.${q.name}`,\n isShowCommentInput: true,\n })),\n isOriginalSection: false,\n sectionPositionSuffix: repeatKey,\n };\n dynamicSections.push(clonedSection);\n }\n }\n }\n\n return dynamicSections;\n};\n\n// urlContext is derived from query params that start with `udpf_` (see useUdpFormParameters).\n// Keys are stored without the prefix, e.g. `udpf_section1_3.question1=val` -> urlContext['section1_3.question1'] = 'val'\n// This helper finds the maximum repeat suffix requested by urlContext for a given section base name.\n// Example: { 'sectionA_3.q1': 'x', 'sectionA_2.q2': 'y' } -> { sectionA: 3 }\nexport const getMaxRepeatSuffixBySectionFromUrlContext = (urlContext: Record<string, any> | undefined | null) => {\n const context = (urlContext && typeof urlContext === 'object') ? urlContext : {};\n const maxBySection: Record<string, number> = {};\n\n Object.keys(context).forEach(key => {\n // Expect keys like: sectionName_3.questionName\n // Only treat it as a repeat hint if it has a dot after the suffix.\n const match = key.match(/^([^._?&#]+)_(\\d+)\\./);\n if (!match) return;\n const baseSectionName = match[1];\n const suffix = Number(match[2]);\n if (!Number.isFinite(suffix) || suffix < 2) return;\n\n const existing = maxBySection[baseSectionName] ?? 1;\n if (suffix > existing) maxBySection[baseSectionName] = suffix;\n });\n\n return maxBySection;\n};\n\n// build dynamic sections based on the master form plus optional repeat hints from URL context\nexport const initializeDynamicSectionsWithUrlContext = (udpForm, currentValues, urlContext) => {\n const maxRepeatFromUrl = getMaxRepeatSuffixBySectionFromUrlContext(urlContext);\n\n const dynamicSections: any[] = [];\n const sortedSections = structuredClone(udpForm.udpFormUdpFormSection).sort(\n (a, b) => a.order - b.order,\n );\n\n for (const section of sortedSections) {\n section.sectionProperties = JSON.parse(section.sectionProperties || {});\n\n const repeatGroupKeys = findRepeatGroupKeys(section.name, currentValues);\n const maxRepeatedFromValues = repeatGroupKeys.length > 0 ? Math.max(...repeatGroupKeys) : 1;\n const maxRepeatedFromUrl = maxRepeatFromUrl?.[section.name] ?? 1;\n const maxRepeatedSectionSuffix = Math.max(maxRepeatedFromValues, maxRepeatedFromUrl);\n\n section.isOriginalSection = true;\n section.sectionPositionSuffix = 1; // default position\n\n // always add the original section into dynamic sections\n dynamicSections.push({\n ...structuredClone(section),\n formQuestions: structuredClone(udpForm.formQuestions)\n .filter(q => q.formSectionId === section.id)\n .sort((a, b) => a.questionOrder - b.questionOrder)\n .map(q => ({\n ...q,\n questionIdentifierKey: `${section.name}.${q.name}`,\n isShowCommentInput: true,\n })),\n });\n\n // create then add additional sections if repeatable and suffix requested by saved values or url\n if (section.sectionProperties?.isRepeatable && maxRepeatedSectionSuffix >= 2) {\n for (let repeatKey = 2; repeatKey <= maxRepeatedSectionSuffix; repeatKey++) {\n const clonedSection = {\n ...structuredClone(section),\n formQuestions: structuredClone(udpForm.formQuestions)\n .filter(q => q.formSectionId === section.id)\n .sort((a, b) => a.questionOrder - b.questionOrder)\n .map(q => ({\n ...q,\n questionIdentifierKey: `${section.name}_${repeatKey}.${q.name}`,\n isShowCommentInput: true,\n })),\n isOriginalSection: false,\n sectionPositionSuffix: repeatKey,\n };\n dynamicSections.push(clonedSection);\n }\n }\n }\n\n return dynamicSections;\n};\n\n\nexport const applyUrlSeedValuesForAll = (dynamicSections, urlContext) => {\n if (!Array.isArray(dynamicSections)) return;\n\n // urlContext is derived from query params that start with `udpf_` (see useUdpFormParameters).\n // Keys are stored without the prefix, e.g. `udpf_section1.question1=val` -> urlContext['section1.question1'] = 'val'\n const context = (urlContext && typeof urlContext === 'object') ? urlContext : {};\n // Build a case-insensitive view of urlContext so callers can use udpf_ keys without worrying about case.\n // If duplicate keys exist with different casing, the last one encountered wins.\n const contextCI: Record<string, any> = {};\n Object.keys(context).forEach(k => {\n contextCI[String(k).toLowerCase()] = (context as any)[k];\n });\n\n // 1) Collect URL values into nested structure: { [sectionKey]: { [questionName]: { value, comments: [] } } }\n const urlValuesNested: {\n [sectionKey: string]: { [qName: string]: { value: any; comments: any[] } };\n } = {};\n dynamicSections.forEach(section => {\n const sectionKey = section.isOriginalSection\n ? section.name\n : `${section.name}_${section.sectionPositionSuffix}`;\n (section.formQuestions || []).forEach(q => {\n if (!q) return;\n const candidates = [q.processedSubmissionName, q.questionIdentifierKey, q.name].filter(\n Boolean,\n ) as string[];\n let urlVal: any = undefined;\n for (const c of candidates) {\n const key = String(c).toLowerCase();\n if (Object.prototype.hasOwnProperty.call(contextCI, key)) {\n urlVal = contextCI[key];\n break;\n }\n }\n if (urlVal !== undefined && urlVal !== null) {\n if (!urlValuesNested[sectionKey]) urlValuesNested[sectionKey] = {};\n urlValuesNested[sectionKey][q.name] = { value: urlVal, comments: [] };\n }\n });\n });\n\n // Caller is responsible for merging with saved submissionResponseData.\n // Here we only return the url-derived seed values + paragraph defaults.\n const merged: { [sectionKey: string]: { [qName: string]: { value: any; comments: any[] } } } = {};\n Object.entries(urlValuesNested).forEach(([sectionKey, qMap]) => {\n if (!merged[sectionKey]) merged[sectionKey] = {} as any;\n Object.entries(qMap).forEach(([qName, valObj]) => {\n const existing = merged[sectionKey][qName];\n // Only set from URL if no saved value exists (null/undefined/empty-string)\n const isMissing =\n existing == null ||\n existing.value == null ||\n (typeof existing.value === 'string' && existing.value.trim() === '');\n if (isMissing) {\n merged[sectionKey][qName] = valObj;\n }\n });\n });\n\n // 3) Paragraph defaults: if still undefined/null, use fieldProperties.paragraphText\n dynamicSections.forEach(section => {\n const sectionKey = section.isOriginalSection\n ? section.name\n : `${section.name}_${section.sectionPositionSuffix}`;\n if (!merged[sectionKey]) merged[sectionKey] = {} as any;\n (section.formQuestions || []).forEach(q => {\n if (!q) return;\n if (q.fieldTypeId === UdpFormsFieldTypeEnum.Paragraph) {\n const existing = merged[sectionKey][q.name];\n const isMissing =\n existing == null ||\n existing.value == null ||\n (typeof existing.value === 'string' && existing.value.trim() === '');\n if (isMissing) {\n let fieldProps: any = q?.fieldProperties;\n if (typeof fieldProps === 'string') {\n try {\n fieldProps = JSON.parse(fieldProps || '{}');\n } catch {\n fieldProps = {};\n }\n }\n merged[sectionKey][q.name] = {\n value: fieldProps?.paragraphText ?? '',\n comments: [],\n };\n }\n }\n });\n });\n\n return merged;\n};\n\n\n\n\nexport const replaceUrlWithSubmissionId = (submissionId: Guid, history: any) => {\n // build a URL that preserves the current pathname + hash but replaces the query string\n const pathname = typeof window !== 'undefined' ? window.location.pathname : `/page/${UdpFormsPageIdEnum.FormRendererPageId}`;\n const hash = typeof window !== 'undefined' ? window.location.hash : '';\n const newUrl = `${pathname}?udpf_submissionId=${submissionId}${hash}`;\n\n const h = history as any;\n\n // Prefer history.replace when available, handle react-router v6 navigate function, fallback to push or native replaceState\n if (h) {\n if (typeof h.replace === 'function') {\n h.replace(newUrl);\n return;\n }\n if (typeof h.push === 'function') {\n h.push(newUrl);\n return;\n }\n // react-router v6 exposes a navigate function\n if (typeof h === 'function') {\n try {\n h(newUrl, { replace: true });\n } catch {\n h(newUrl);\n }\n return;\n }\n }\n\n if (typeof window !== 'undefined' && window.history && typeof window.history.replaceState === 'function') {\n window.history.replaceState({}, '', newUrl);\n } else if (typeof window !== 'undefined') {\n window.location.href = newUrl;\n }\n}\n\n\nexport const enqueueSnackbarSuccess = (message: string, enqueueSnackbar: Function) => {\n enqueueSnackbar?.(message, {\n variant: 'success',\n anchorOrigin: { vertical: 'top', horizontal: 'center' },\n });\n};\n\nexport const enqueueSnackbarError = (message: string, enqueueSnackbar: Function) => {\n enqueueSnackbar?.(message, {\n variant: 'error',\n anchorOrigin: { vertical: 'top', horizontal: 'center' },\n });\n};"]}