@servicetitan/dte-unlayer 0.157.0 → 0.159.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.
Files changed (166) hide show
  1. package/dist/api-core.js +22 -29
  2. package/dist/api-core.js.map +1 -1
  3. package/dist/api-custom-tools.js +23 -29
  4. package/dist/api-custom-tools.js.map +1 -1
  5. package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
  6. package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
  7. package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
  8. package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
  9. package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
  10. package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
  11. package/dist/business-calendar/business-calendar-requests.js +46 -0
  12. package/dist/business-calendar/business-calendar-requests.js.map +1 -0
  13. package/dist/business-calendar/business-calendar-state.d.ts +22 -0
  14. package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
  15. package/dist/business-calendar/business-calendar-state.js +74 -0
  16. package/dist/business-calendar/business-calendar-state.js.map +1 -0
  17. package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
  18. package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
  19. package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
  20. package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
  21. package/dist/display-conditions/ConditionGroup.js +15 -89
  22. package/dist/display-conditions/ConditionGroup.js.map +1 -1
  23. package/dist/display-conditions/ConditionGroupsSection.js +2 -70
  24. package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
  25. package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
  26. package/dist/display-conditions/ConditionRow.js +71 -296
  27. package/dist/display-conditions/ConditionRow.js.map +1 -1
  28. package/dist/display-conditions/DisplayConditionModal.js +40 -190
  29. package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
  30. package/dist/display-conditions/LookupValueControl.d.ts.map +1 -1
  31. package/dist/display-conditions/LookupValueControl.js +42 -109
  32. package/dist/display-conditions/LookupValueControl.js.map +1 -1
  33. package/dist/display-conditions/SeparatorWithChip.js +1 -10
  34. package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
  35. package/dist/display-conditions/constants.js +15 -20
  36. package/dist/display-conditions/constants.js.map +1 -1
  37. package/dist/display-conditions/displayConditionController.js +5 -8
  38. package/dist/display-conditions/displayConditionController.js.map +1 -1
  39. package/dist/display-conditions/lookupOptionsController.js +16 -16
  40. package/dist/display-conditions/lookupOptionsController.js.map +1 -1
  41. package/dist/display-conditions/nunjucks.js +98 -116
  42. package/dist/display-conditions/nunjucks.js.map +1 -1
  43. package/dist/display-conditions/schemaDataPoints.js +13 -11
  44. package/dist/display-conditions/schemaDataPoints.js.map +1 -1
  45. package/dist/display-conditions/types.js +23 -67
  46. package/dist/display-conditions/types.js.map +1 -1
  47. package/dist/display-conditions/useConditionForms.js +38 -56
  48. package/dist/display-conditions/useConditionForms.js.map +1 -1
  49. package/dist/display-conditions/useLookupOptions.js +24 -44
  50. package/dist/display-conditions/useLookupOptions.js.map +1 -1
  51. package/dist/e-sign-offset/ESignDateSignedOffsetModal.d.ts.map +1 -1
  52. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +48 -156
  53. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
  54. package/dist/e-sign-offset/ESignOffsetRuleRow.d.ts +3 -1
  55. package/dist/e-sign-offset/ESignOffsetRuleRow.d.ts.map +1 -1
  56. package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -71
  57. package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
  58. package/dist/e-sign-offset/eSignOffsetController.js +5 -8
  59. package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
  60. package/dist/editor-core-source.d.ts +2 -2
  61. package/dist/editor-core-source.d.ts.map +1 -1
  62. package/dist/editor-core-source.js +3 -3
  63. package/dist/editor-core-source.js.map +1 -1
  64. package/dist/editor-core.js +2 -2
  65. package/dist/editor-core.js.map +1 -1
  66. package/dist/editor.d.ts.map +1 -1
  67. package/dist/editor.js +56 -118
  68. package/dist/editor.js.map +1 -1
  69. package/dist/image-upload-error.js +3 -3
  70. package/dist/image-upload-error.js.map +1 -1
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +0 -1
  74. package/dist/index.js.map +1 -1
  75. package/dist/loadScript.js +7 -8
  76. package/dist/loadScript.js.map +1 -1
  77. package/dist/log.js +2 -3
  78. package/dist/log.js.map +1 -1
  79. package/dist/merge-tags.js +18 -17
  80. package/dist/merge-tags.js.map +1 -1
  81. package/dist/shared/configs.js +1 -2
  82. package/dist/shared/configs.js.map +1 -1
  83. package/dist/shared/const.d.ts +72 -0
  84. package/dist/shared/const.d.ts.map +1 -1
  85. package/dist/shared/const.js +13 -4
  86. package/dist/shared/const.js.map +1 -1
  87. package/dist/shared/date-calc.d.ts +32 -13
  88. package/dist/shared/date-calc.d.ts.map +1 -1
  89. package/dist/shared/date-calc.js +130 -76
  90. package/dist/shared/date-calc.js.map +1 -1
  91. package/dist/shared/e-sign-offset.js +46 -63
  92. package/dist/shared/e-sign-offset.js.map +1 -1
  93. package/dist/shared/edit-icon.js +0 -1
  94. package/dist/shared/edit-icon.js.map +1 -1
  95. package/dist/shared/fonts.js +16 -17
  96. package/dist/shared/fonts.js.map +1 -1
  97. package/dist/shared/forms.js +16 -38
  98. package/dist/shared/forms.js.map +1 -1
  99. package/dist/shared/instance-id.d.ts +3 -0
  100. package/dist/shared/instance-id.d.ts.map +1 -1
  101. package/dist/shared/instance-id.js +10 -7
  102. package/dist/shared/instance-id.js.map +1 -1
  103. package/dist/shared/nunjucks-helpers.js +2 -5
  104. package/dist/shared/nunjucks-helpers.js.map +1 -1
  105. package/dist/shared/schema.js +52 -96
  106. package/dist/shared/schema.js.map +1 -1
  107. package/dist/shared/tools.js +6 -13
  108. package/dist/shared/tools.js.map +1 -1
  109. package/dist/store.d.ts +15 -1
  110. package/dist/store.d.ts.map +1 -1
  111. package/dist/store.js +851 -547
  112. package/dist/store.js.map +1 -1
  113. package/dist/tools.js +133 -143
  114. package/dist/tools.js.map +1 -1
  115. package/dist/unlayer-interface.d.ts +25 -1
  116. package/dist/unlayer-interface.d.ts.map +1 -1
  117. package/dist/unlayer-interface.js +1 -2
  118. package/dist/unlayer-interface.js.map +1 -1
  119. package/dist/unlayer.js +86 -113
  120. package/dist/unlayer.js.map +1 -1
  121. package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
  122. package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
  123. package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
  124. package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
  125. package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
  126. package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
  127. package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
  128. package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
  129. package/dist/vendor/dte-shared/constants.d.ts +31 -0
  130. package/dist/vendor/dte-shared/constants.js +34 -0
  131. package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
  132. package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
  133. package/dist/vendor/dte-shared/index.d.ts +8 -0
  134. package/dist/vendor/dte-shared/index.js +7 -0
  135. package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
  136. package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
  137. package/dist/vendor/dte-shared/styles/schedule.css +19 -0
  138. package/dist/vendor/dte-shared/types.d.ts +129 -0
  139. package/dist/vendor/dte-shared/types.js +1 -0
  140. package/package.json +7 -1
  141. package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
  142. package/src/__tests__/business-calendar-requests.test.ts +166 -0
  143. package/src/__tests__/business-calendar-state.test.tsx +142 -0
  144. package/src/__tests__/condition-row.test.tsx +131 -0
  145. package/src/__tests__/date-calc.test.ts +145 -0
  146. package/src/__tests__/e-sign-offset-modal.test.tsx +124 -0
  147. package/src/__tests__/instance-id.test.ts +49 -0
  148. package/src/__tests__/store.business-calendar.test.ts +185 -0
  149. package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
  150. package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
  151. package/src/business-calendar/business-calendar-requests.ts +80 -0
  152. package/src/business-calendar/business-calendar-state.ts +113 -0
  153. package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
  154. package/src/display-conditions/ConditionRow.tsx +102 -175
  155. package/src/display-conditions/LookupValueControl.tsx +1 -12
  156. package/src/e-sign-offset/ESignDateSignedOffsetModal.tsx +20 -12
  157. package/src/e-sign-offset/ESignOffsetRuleRow.tsx +7 -2
  158. package/src/editor-core-source.ts +2 -2
  159. package/src/editor.tsx +15 -0
  160. package/src/index.ts +10 -0
  161. package/src/shared/const.ts +61 -0
  162. package/src/shared/date-calc.ts +155 -78
  163. package/src/shared/instance-id.ts +6 -1
  164. package/src/store.ts +68 -5
  165. package/src/unlayer-interface.tsx +25 -1
  166. package/src/unlayer.tsx +5 -5
package/dist/store.js CHANGED
@@ -1,47 +1,36 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
1
  import { emitESignOffsetRequest } from './e-sign-offset/eSignOffsetController';
15
2
  import { ImageUploadError } from './image-upload-error';
16
3
  import { loadScript } from './loadScript';
17
4
  import { logUnlayerError } from './log';
18
5
  import { toUnlayerMergeTags } from './merge-tags';
19
6
  import { defaultImageValidation } from './shared/configs';
7
+ import { E_SIGN_FIELD_TYPE_LABELS, } from './shared/const';
20
8
  import { normalizeESignOffsetSettings } from './shared/e-sign-offset';
21
9
  import { unlayerSupportedFonts } from './shared/fonts';
22
- import { getFormFieldSampleValue, parseFormFieldKey } from './shared/forms';
10
+ import { getFormFieldSampleValue, parseFormFieldKey, } from './shared/forms';
23
11
  import { schemaBuildMap, schemaIsDate } from './shared/schema';
24
12
  import { unlayerToolsParseTwinKey } from './shared/tools';
25
- import { unlayerToolsDedupeInstanceIds, unlayerToolsIterate, unlayerToolsNormalizeESignOffsets } from './tools';
26
- import { createUnlayerEditor, DesignUpdatedEventType } from './unlayer';
13
+ import { unlayerToolsDedupeInstanceIds, unlayerToolsIterate, unlayerToolsNormalizeESignOffsets, } from './tools';
14
+ import { createUnlayerEditor, DesignUpdatedEventType, } from './unlayer';
27
15
  const defaultScriptUrl = 'https://editor.unlayer.com/embed.js?2';
28
16
  const UNLAYER_TOOLS_READY_TIMEOUT_MS = 30000;
29
- const normalizeFontToken = (font)=>font.replace(/["']/g, '').split(',')[0].trim().toLowerCase();
30
- const getDesignFontTokens = (value, out)=>{
17
+ const normalizeFontToken = (font) => font.replace(/["']/g, '').split(',')[0].trim().toLowerCase();
18
+ const getDesignFontTokens = (value, out) => {
31
19
  if (!value || typeof value !== 'object') {
32
20
  return;
33
21
  }
34
22
  if (Array.isArray(value)) {
35
- for (const item of value){
23
+ for (const item of value) {
36
24
  getDesignFontTokens(item, out);
37
25
  }
38
26
  return;
39
27
  }
40
- for (const [key, fieldValue] of Object.entries(value)){
28
+ for (const [key, fieldValue] of Object.entries(value)) {
41
29
  if (key === 'fontFamily') {
42
30
  if (typeof fieldValue === 'string') {
43
31
  out.add(normalizeFontToken(fieldValue));
44
- } else if (fieldValue && typeof fieldValue === 'object') {
32
+ }
33
+ else if (fieldValue && typeof fieldValue === 'object') {
45
34
  const fontFamilyValue = fieldValue;
46
35
  if (typeof fontFamilyValue.label === 'string') {
47
36
  out.add(normalizeFontToken(fontFamilyValue.label));
@@ -56,25 +45,22 @@ const getDesignFontTokens = (value, out)=>{
56
45
  }
57
46
  }
58
47
  };
59
- const ensureChunksFonts = (data)=>{
60
- var _data, _chunks;
48
+ const ensureChunksFonts = (data) => {
49
+ var _a;
61
50
  if (!data || typeof data !== 'object') {
62
51
  return data;
63
52
  }
64
- (_chunks = (_data = data).chunks) !== null && _chunks !== void 0 ? _chunks : _data.chunks = {};
53
+ (_a = data.chunks) !== null && _a !== void 0 ? _a : (data.chunks = {});
65
54
  const existingFonts = Array.isArray(data.chunks.fonts) ? data.chunks.fonts : [];
66
- const existingLabels = new Set(existingFonts.map((f)=>f.label));
55
+ const existingLabels = new Set(existingFonts.map((f) => f.label));
67
56
  const usedFontTokens = new Set();
68
57
  getDesignFontTokens(data.design, usedFontTokens);
69
58
  const html = typeof data.html === 'string' ? data.html.toLowerCase() : '';
70
- for (const font of unlayerSupportedFonts){
59
+ for (const font of unlayerSupportedFonts) {
71
60
  const labelToken = normalizeFontToken(font.label);
72
61
  const valueToken = normalizeFontToken(font.value);
73
62
  const isUsedInDesign = usedFontTokens.has(labelToken) || usedFontTokens.has(valueToken);
74
- const isUsedInHtml = [
75
- labelToken,
76
- valueToken
77
- ].some((token)=>html.includes(token));
63
+ const isUsedInHtml = [labelToken, valueToken].some(token => html.includes(token));
78
64
  if ((isUsedInDesign || isUsedInHtml) && !existingLabels.has(font.label)) {
79
65
  existingFonts.push(font);
80
66
  existingLabels.add(font.label);
@@ -84,41 +70,42 @@ const ensureChunksFonts = (data)=>{
84
70
  return data;
85
71
  };
86
72
  const FORM_FIELD_DATA_POINT_PREFIX = 'FORM_FIELD_';
87
- const getByPath = (data, path)=>{
73
+ const getByPath = (data, path) => {
88
74
  if (!data || typeof data !== 'object') {
89
75
  return undefined;
90
76
  }
91
- return path.split('.').reduce((current, part)=>{
77
+ return path.split('.').reduce((current, part) => {
92
78
  if (!current || typeof current !== 'object') {
93
79
  return undefined;
94
80
  }
95
81
  return current[part];
96
82
  }, data);
97
83
  };
98
- const isPlainObject = (value)=>!!value && typeof value === 'object' && !Array.isArray(value);
99
- const deepMerge = (...sources)=>{
84
+ const isPlainObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
85
+ const deepMerge = (...sources) => {
100
86
  const out = {};
101
- for (const source of sources){
87
+ for (const source of sources) {
102
88
  if (!isPlainObject(source)) {
103
89
  continue;
104
90
  }
105
- for (const [key, value] of Object.entries(source)){
91
+ for (const [key, value] of Object.entries(source)) {
106
92
  if (isPlainObject(value) && isPlainObject(out[key])) {
107
93
  out[key] = deepMerge(out[key], value);
108
- } else {
94
+ }
95
+ else {
109
96
  out[key] = value;
110
97
  }
111
98
  }
112
99
  }
113
100
  return out;
114
101
  };
115
- const setByPath = (target, path, value)=>{
102
+ const setByPath = (target, path, value) => {
116
103
  const parts = path.split('.');
117
104
  if (!parts.length) {
118
105
  return;
119
106
  }
120
107
  let node = target;
121
- for(let i = 0; i < parts.length - 1; i += 1){
108
+ for (let i = 0; i < parts.length - 1; i += 1) {
122
109
  const key = parts[i];
123
110
  if (!isPlainObject(node[key])) {
124
111
  node[key] = {};
@@ -127,10 +114,10 @@ const setByPath = (target, path, value)=>{
127
114
  }
128
115
  node[parts[parts.length - 1]] = value;
129
116
  };
130
- const tokenizeFormulaFields = (expression)=>{
131
- var _expression_match;
117
+ const tokenizeFormulaFields = (expression) => {
118
+ var _a;
132
119
  const regex = /[A-Za-z_][A-Za-z0-9_.]*/g;
133
- return (_expression_match = expression.match(regex)) !== null && _expression_match !== void 0 ? _expression_match : [];
120
+ return (_a = expression.match(regex)) !== null && _a !== void 0 ? _a : [];
134
121
  };
135
122
  // We are using exclusive lists here, because we can't be sure that we know all unlayer event types
136
123
  const eventsNotChangingToolsList = [
@@ -139,585 +126,902 @@ const eventsNotChangingToolsList = [
139
126
  DesignUpdatedEventType.ColumnModified,
140
127
  DesignUpdatedEventType.RowMoved,
141
128
  DesignUpdatedEventType.RowModified,
142
- DesignUpdatedEventType.BodyModified
129
+ DesignUpdatedEventType.BodyModified,
143
130
  ];
144
131
  const eventsNotAddingTools = [
145
132
  ...eventsNotChangingToolsList,
146
133
  DesignUpdatedEventType.ContentRemoved,
147
134
  DesignUpdatedEventType.ColumnRemoved,
148
- DesignUpdatedEventType.RowRemoved
135
+ DesignUpdatedEventType.RowRemoved,
149
136
  ];
150
137
  export class UnlayerStore {
151
- constructor(props){
152
- var _ref, _ref1;
153
- _define_property(this, "props", void 0);
154
- _define_property(this, "unlayerRef", void 0);
155
- _define_property(this, "schemaDummyData", void 0);
156
- _define_property(this, "dateSchemaFieldKeys", void 0);
157
- _define_property(this, "editor", void 0);
158
- _define_property(this, "isInit", void 0);
159
- _define_property(this, "iframe", void 0);
160
- _define_property(this, "hasDesign", void 0);
161
- _define_property(this, "hasCoreLoaded", void 0);
162
- _define_property(this, "hasToolsRegistered", void 0);
163
- _define_property(this, "toolsReadyWatchdogId", void 0);
164
- _define_property(this, "formFieldsByFormId", void 0);
165
- _define_property(this, "formFieldSamples", void 0);
166
- _define_property(this, "isEditorReady", void 0);
167
- _define_property(this, "isMergeTagsApplied", void 0);
168
- _define_property(this, "mergeTagsConfig", void 0);
169
- _define_property(this, "onMessageCB", void 0);
170
- _define_property(this, "onChangeCB", void 0);
171
- _define_property(this, "onSnapshotSaveCB", void 0);
172
- _define_property(this, "onReadyCB", void 0);
173
- _define_property(this, "onImageCB", void 0);
174
- _define_property(this, "onErrorCB", void 0);
175
- _define_property(this, "onFormSelectCB", void 0);
176
- _define_property(this, "onCalcFieldOpenCB", void 0);
177
- _define_property(this, "onCalcFieldSelectCB", void 0);
178
- _define_property(this, "init", void 0);
179
- _define_property(this, "destroy", void 0);
180
- _define_property(this, "addTwin", void 0);
181
- _define_property(this, "setDesign", void 0);
182
- _define_property(this, "setOnChange", void 0);
183
- _define_property(this, "setOnSnapshotSave", void 0);
184
- _define_property(this, "setOnReady", void 0);
185
- _define_property(this, "setOnImage", void 0);
186
- _define_property(this, "setOnError", void 0);
187
- _define_property(this, "setOnMessage", void 0);
188
- _define_property(this, "setOnFormSelect", void 0);
189
- _define_property(this, "setOnCalcFieldOpen", void 0);
190
- _define_property(this, "setOnCalcFieldSelect", void 0);
191
- _define_property(this, "sendFormList", void 0);
192
- _define_property(this, "sendFormFields", void 0);
193
- _define_property(this, "sendCalcFieldLabels", void 0);
194
- /**
195
- * Replaces the editor's merge tag menu. Nested groups passed to `createEditor` stop DTE
196
- * custom tools from registering, so init only carries the flat shape and the grouped
197
- * config is applied here once the editor is ready. A call before that (including the
198
- * initial props) is parked; a later call replaces it. A failed apply is retried on the
199
- * next `design:loaded`.
200
- */ _define_property(this, "setMergeTags", void 0);
201
- _define_property(this, "applyMergeTags", void 0);
202
- _define_property(this, "onEditorReady", void 0);
203
- _define_property(this, "onDesignLoaded", void 0);
204
- _define_property(this, "onDesignUpdated", void 0);
205
- _define_property(this, "onPostMessage", void 0);
206
- _define_property(this, "openESignOffsetRules", void 0);
207
- _define_property(this, "updateFormFieldSamples", void 0);
208
- _define_property(this, "collectCalculatedFieldKeys", void 0);
209
- _define_property(this, "resolveDemoValue", void 0);
210
- _define_property(this, "buildCalculatedFieldDemoData", void 0);
211
- _define_property(this, "sendMessage", void 0);
212
- _define_property(this, "uploadImage", void 0);
213
- _define_property(this, "startToolsReadyWatchdog", void 0);
214
- _define_property(this, "clearToolsReadyWatchdog", void 0);
215
- _define_property(this, "validateImage", void 0);
216
- this.props = props;
217
- this.isInit = false;
218
- this.hasDesign = false;
219
- this.hasCoreLoaded = false;
220
- this.hasToolsRegistered = false;
221
- this.formFieldsByFormId = {};
222
- this.formFieldSamples = {};
223
- this.isEditorReady = false;
224
- this.isMergeTagsApplied = false;
225
- this.init = async (container)=>{
226
- if (this.isInit) {
227
- return;
228
- }
229
- this.isInit = true;
230
- try {
231
- var // The host may already have pushed a newer set through `setMergeTags`; keep it.
232
- _this_mergeTagsConfig, _container_querySelector;
233
- setTimeout(()=>window.addEventListener('message', this.onPostMessage));
234
- await loadScript(defaultScriptUrl);
235
- if (!window.unlayer) {
236
- throw new Error('Unlayer embed script loaded but window.unlayer is missing');
237
- }
238
- this.editor = createUnlayerEditor(container, this.props);
239
- (_this_mergeTagsConfig = this.mergeTagsConfig) !== null && _this_mergeTagsConfig !== void 0 ? _this_mergeTagsConfig : this.mergeTagsConfig = toUnlayerMergeTags(this.props.mergeTags);
240
- this.editor.addEventListener('editor:ready', this.onEditorReady);
241
- this.editor.addEventListener('design:loaded', this.onDesignLoaded);
242
- this.editor.addEventListener('design:updated', this.onDesignUpdated);
243
- this.editor.registerCallback('image', this.uploadImage);
244
- this.iframe = (_container_querySelector = container.querySelector(`iframe`)) !== null && _container_querySelector !== void 0 ? _container_querySelector : undefined;
245
- if (!this.iframe) {
246
- logUnlayerError('Unlayer iframe was not created after createEditor');
247
- }
248
- this.startToolsReadyWatchdog();
249
- } catch (error) {
250
- this.isInit = false;
138
+ constructor(props) {
139
+ var _a, _b;
140
+ Object.defineProperty(this, "props", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: props
145
+ });
146
+ Object.defineProperty(this, "unlayerRef", {
147
+ enumerable: true,
148
+ configurable: true,
149
+ writable: true,
150
+ value: void 0
151
+ });
152
+ Object.defineProperty(this, "schemaDummyData", {
153
+ enumerable: true,
154
+ configurable: true,
155
+ writable: true,
156
+ value: void 0
157
+ });
158
+ Object.defineProperty(this, "dateSchemaFieldKeys", {
159
+ enumerable: true,
160
+ configurable: true,
161
+ writable: true,
162
+ value: void 0
163
+ });
164
+ Object.defineProperty(this, "editor", {
165
+ enumerable: true,
166
+ configurable: true,
167
+ writable: true,
168
+ value: void 0
169
+ });
170
+ Object.defineProperty(this, "isInit", {
171
+ enumerable: true,
172
+ configurable: true,
173
+ writable: true,
174
+ value: false
175
+ });
176
+ Object.defineProperty(this, "iframe", {
177
+ enumerable: true,
178
+ configurable: true,
179
+ writable: true,
180
+ value: void 0
181
+ });
182
+ Object.defineProperty(this, "hasDesign", {
183
+ enumerable: true,
184
+ configurable: true,
185
+ writable: true,
186
+ value: false
187
+ });
188
+ Object.defineProperty(this, "hasCoreLoaded", {
189
+ enumerable: true,
190
+ configurable: true,
191
+ writable: true,
192
+ value: false
193
+ });
194
+ Object.defineProperty(this, "hasToolsRegistered", {
195
+ enumerable: true,
196
+ configurable: true,
197
+ writable: true,
198
+ value: false
199
+ });
200
+ Object.defineProperty(this, "toolsReadyWatchdogId", {
201
+ enumerable: true,
202
+ configurable: true,
203
+ writable: true,
204
+ value: void 0
205
+ });
206
+ Object.defineProperty(this, "formFieldsByFormId", {
207
+ enumerable: true,
208
+ configurable: true,
209
+ writable: true,
210
+ value: {}
211
+ });
212
+ Object.defineProperty(this, "formFieldSamples", {
213
+ enumerable: true,
214
+ configurable: true,
215
+ writable: true,
216
+ value: {}
217
+ });
218
+ Object.defineProperty(this, "isEditorReady", {
219
+ enumerable: true,
220
+ configurable: true,
221
+ writable: true,
222
+ value: false
223
+ });
224
+ Object.defineProperty(this, "isMergeTagsApplied", {
225
+ enumerable: true,
226
+ configurable: true,
227
+ writable: true,
228
+ value: false
229
+ });
230
+ Object.defineProperty(this, "mergeTagsConfig", {
231
+ enumerable: true,
232
+ configurable: true,
233
+ writable: true,
234
+ value: void 0
235
+ });
236
+ /** Latest `--business-calendar-state` payload, and the last one sent to the iframe. */
237
+ Object.defineProperty(this, "businessCalendarStateJson", {
238
+ enumerable: true,
239
+ configurable: true,
240
+ writable: true,
241
+ value: void 0
242
+ });
243
+ Object.defineProperty(this, "sentBusinessCalendarStateJson", {
244
+ enumerable: true,
245
+ configurable: true,
246
+ writable: true,
247
+ value: void 0
248
+ });
249
+ Object.defineProperty(this, "onMessageCB", {
250
+ enumerable: true,
251
+ configurable: true,
252
+ writable: true,
253
+ value: void 0
254
+ });
255
+ Object.defineProperty(this, "onChangeCB", {
256
+ enumerable: true,
257
+ configurable: true,
258
+ writable: true,
259
+ value: void 0
260
+ });
261
+ Object.defineProperty(this, "onSnapshotSaveCB", {
262
+ enumerable: true,
263
+ configurable: true,
264
+ writable: true,
265
+ value: void 0
266
+ });
267
+ Object.defineProperty(this, "onReadyCB", {
268
+ enumerable: true,
269
+ configurable: true,
270
+ writable: true,
271
+ value: void 0
272
+ });
273
+ Object.defineProperty(this, "onImageCB", {
274
+ enumerable: true,
275
+ configurable: true,
276
+ writable: true,
277
+ value: void 0
278
+ });
279
+ Object.defineProperty(this, "onErrorCB", {
280
+ enumerable: true,
281
+ configurable: true,
282
+ writable: true,
283
+ value: void 0
284
+ });
285
+ Object.defineProperty(this, "onFormSelectCB", {
286
+ enumerable: true,
287
+ configurable: true,
288
+ writable: true,
289
+ value: void 0
290
+ });
291
+ Object.defineProperty(this, "onCalcFieldOpenCB", {
292
+ enumerable: true,
293
+ configurable: true,
294
+ writable: true,
295
+ value: void 0
296
+ });
297
+ Object.defineProperty(this, "onCalcFieldSelectCB", {
298
+ enumerable: true,
299
+ configurable: true,
300
+ writable: true,
301
+ value: void 0
302
+ });
303
+ Object.defineProperty(this, "onBusinessCalendarRequestCB", {
304
+ enumerable: true,
305
+ configurable: true,
306
+ writable: true,
307
+ value: void 0
308
+ });
309
+ Object.defineProperty(this, "init", {
310
+ enumerable: true,
311
+ configurable: true,
312
+ writable: true,
313
+ value: async (container) => {
314
+ var _a, _b;
315
+ if (this.isInit) {
316
+ return;
317
+ }
318
+ this.isInit = true;
319
+ try {
320
+ setTimeout(() => window.addEventListener('message', this.onPostMessage));
321
+ await loadScript(defaultScriptUrl);
322
+ if (!window.unlayer) {
323
+ throw new Error('Unlayer embed script loaded but window.unlayer is missing');
324
+ }
325
+ this.editor = createUnlayerEditor(container, this.props);
326
+ // The host may already have pushed a newer set through `setMergeTags`; keep it.
327
+ (_a = this.mergeTagsConfig) !== null && _a !== void 0 ? _a : (this.mergeTagsConfig = toUnlayerMergeTags(this.props.mergeTags));
328
+ this.editor.addEventListener('editor:ready', this.onEditorReady);
329
+ this.editor.addEventListener('design:loaded', this.onDesignLoaded);
330
+ this.editor.addEventListener('design:updated', this.onDesignUpdated);
331
+ this.editor.registerCallback('image', this.uploadImage);
332
+ this.iframe = (_b = container.querySelector(`iframe`)) !== null && _b !== void 0 ? _b : undefined;
333
+ if (!this.iframe) {
334
+ logUnlayerError('Unlayer iframe was not created after createEditor');
335
+ }
336
+ this.startToolsReadyWatchdog();
337
+ }
338
+ catch (error) {
339
+ this.isInit = false;
340
+ this.clearToolsReadyWatchdog();
341
+ logUnlayerError('Failed to initialize Unlayer editor', error);
342
+ throw error;
343
+ }
344
+ }
345
+ });
346
+ Object.defineProperty(this, "destroy", {
347
+ enumerable: true,
348
+ configurable: true,
349
+ writable: true,
350
+ value: () => {
251
351
  this.clearToolsReadyWatchdog();
252
- logUnlayerError('Failed to initialize Unlayer editor', error);
253
- throw error;
352
+ window.removeEventListener('message', this.onPostMessage);
353
+ if (this.editor) {
354
+ this.editor.removeEventListener('editor:ready', this.onEditorReady);
355
+ this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
356
+ this.editor.removeEventListener('design:updated', this.onDesignUpdated);
357
+ this.editor.unregisterCallback('image', this.uploadImage);
358
+ this.editor = undefined;
359
+ }
254
360
  }
255
- };
256
- this.destroy = ()=>{
257
- this.clearToolsReadyWatchdog();
258
- window.removeEventListener('message', this.onPostMessage);
259
- if (this.editor) {
260
- this.editor.removeEventListener('editor:ready', this.onEditorReady);
261
- this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
262
- this.editor.removeEventListener('design:updated', this.onDesignUpdated);
263
- this.editor.unregisterCallback('image', this.uploadImage);
264
- this.editor = undefined;
361
+ });
362
+ Object.defineProperty(this, "addTwin", {
363
+ enumerable: true,
364
+ configurable: true,
365
+ writable: true,
366
+ value: (twin) => {
367
+ var _a;
368
+ (_a = this.props.toolTwins) === null || _a === void 0 ? void 0 : _a.push(twin);
369
+ this.sendMessage('--add-twin', JSON.parse(JSON.stringify(twin)));
265
370
  }
266
- };
267
- this.addTwin = (twin)=>{
268
- var _this_props_toolTwins;
269
- (_this_props_toolTwins = this.props.toolTwins) === null || _this_props_toolTwins === void 0 ? void 0 : _this_props_toolTwins.push(twin);
270
- this.sendMessage('--add-twin', JSON.parse(JSON.stringify(twin)));
271
- };
272
- this.setDesign = (design)=>{
273
- if (!this.editor) {
274
- return;
371
+ });
372
+ Object.defineProperty(this, "setDesign", {
373
+ enumerable: true,
374
+ configurable: true,
375
+ writable: true,
376
+ value: (design) => {
377
+ if (!this.editor) {
378
+ return;
379
+ }
380
+ this.hasDesign = !!design;
381
+ if (design) {
382
+ this.editor.loadDesign(design);
383
+ }
275
384
  }
276
- this.hasDesign = !!design;
277
- if (design) {
278
- this.editor.loadDesign(design);
385
+ });
386
+ Object.defineProperty(this, "setOnChange", {
387
+ enumerable: true,
388
+ configurable: true,
389
+ writable: true,
390
+ value: (onChange) => {
391
+ this.onChangeCB = onChange;
279
392
  }
280
- };
281
- this.setOnChange = (onChange)=>{
282
- this.onChangeCB = onChange;
283
- };
284
- this.setOnSnapshotSave = (onSnapshotSave)=>{
285
- this.onSnapshotSaveCB = onSnapshotSave;
286
- };
287
- this.setOnReady = (onReady)=>{
288
- this.onReadyCB = onReady;
289
- };
290
- this.setOnImage = (onImage)=>{
291
- this.onImageCB = onImage;
292
- };
293
- this.setOnError = (onError)=>{
294
- this.onErrorCB = onError;
295
- };
296
- this.setOnMessage = (onMessage)=>{
297
- this.onMessageCB = onMessage;
298
- };
299
- this.setOnFormSelect = (onFormSelect)=>{
300
- this.onFormSelectCB = onFormSelect;
301
- };
302
- this.setOnCalcFieldOpen = (onCalcFieldOpen)=>{
303
- this.onCalcFieldOpenCB = onCalcFieldOpen;
304
- };
305
- this.setOnCalcFieldSelect = (onCalcFieldSelect)=>{
306
- this.onCalcFieldSelectCB = onCalcFieldSelect;
307
- };
308
- this.sendFormList = (forms)=>{
309
- this.sendMessage('--form-list', {
310
- forms
311
- });
312
- };
313
- this.sendFormFields = (formId, fields)=>{
314
- this.formFieldsByFormId[formId] = fields;
315
- this.updateFormFieldSamples(formId, fields);
316
- this.sendMessage('--form-fields', {
317
- formId,
318
- fields
319
- });
320
- };
321
- this.sendCalcFieldLabels = (labels)=>{
322
- this.sendMessage('--calc-field-labels', {
323
- labels
324
- });
325
- };
326
- this.setMergeTags = (tags)=>{
327
- this.mergeTagsConfig = toUnlayerMergeTags(tags);
328
- this.isMergeTagsApplied = false;
329
- this.applyMergeTags();
330
- };
331
- this.applyMergeTags = ()=>{
332
- if (!this.editor || !this.isEditorReady || this.isMergeTagsApplied || !this.mergeTagsConfig) {
333
- return;
393
+ });
394
+ Object.defineProperty(this, "setOnSnapshotSave", {
395
+ enumerable: true,
396
+ configurable: true,
397
+ writable: true,
398
+ value: (onSnapshotSave) => {
399
+ this.onSnapshotSaveCB = onSnapshotSave;
334
400
  }
335
- try {
336
- this.editor.setMergeTags(this.mergeTagsConfig);
337
- this.isMergeTagsApplied = true;
338
- } catch (error) {
339
- logUnlayerError('Failed to apply merge tags', error);
401
+ });
402
+ Object.defineProperty(this, "setOnReady", {
403
+ enumerable: true,
404
+ configurable: true,
405
+ writable: true,
406
+ value: (onReady) => {
407
+ this.onReadyCB = onReady;
340
408
  }
341
- };
342
- this.onEditorReady = ()=>{
343
- this.isEditorReady = true;
344
- this.applyMergeTags();
345
- };
346
- this.onDesignLoaded = ()=>{
347
- // A loaded design means the editor is up even if `editor:ready` never reached us.
348
- this.onEditorReady();
349
- if (!this.hasDesign) {
350
- var _this_editor;
351
- this.hasDesign = true;
352
- (_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.setBodyValues({
353
- backgroundColor: 'rgba(0,0,0,0)',
354
- contentWidth: '100%'
355
- });
409
+ });
410
+ Object.defineProperty(this, "setOnImage", {
411
+ enumerable: true,
412
+ configurable: true,
413
+ writable: true,
414
+ value: (onImage) => {
415
+ this.onImageCB = onImage;
356
416
  }
357
- };
358
- this.onDesignUpdated = (event)=>{
359
- const isToolAdded = !eventsNotAddingTools.includes(event.type);
360
- const isToolsListChanged = !eventsNotChangingToolsList.includes(event.type);
361
- if (isToolAdded) {
362
- var _this_editor;
363
- (_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.exportHtml((data)=>{
364
- var _event_item_values__meta, _event_item_values, _event_item, _this_onChangeCB, _this;
365
- let hasChanges = false;
366
- unlayerToolsIterate(data.design, (tool)=>{
367
- var _tool_slug;
368
- const realTool = tool.slug ? unlayerToolsParseTwinKey((_tool_slug = tool.slug) !== null && _tool_slug !== void 0 ? _tool_slug : '') : undefined;
369
- if (realTool) {
370
- hasChanges = true;
371
- if (tool.slug) {
372
- delete data.design.counters[`u_content_custom_${tool.slug}`];
373
- delete tool.values._meta.htmlID;
417
+ });
418
+ Object.defineProperty(this, "setOnError", {
419
+ enumerable: true,
420
+ configurable: true,
421
+ writable: true,
422
+ value: (onError) => {
423
+ this.onErrorCB = onError;
424
+ }
425
+ });
426
+ Object.defineProperty(this, "setOnMessage", {
427
+ enumerable: true,
428
+ configurable: true,
429
+ writable: true,
430
+ value: (onMessage) => {
431
+ this.onMessageCB = onMessage;
432
+ }
433
+ });
434
+ Object.defineProperty(this, "setOnFormSelect", {
435
+ enumerable: true,
436
+ configurable: true,
437
+ writable: true,
438
+ value: (onFormSelect) => {
439
+ this.onFormSelectCB = onFormSelect;
440
+ }
441
+ });
442
+ Object.defineProperty(this, "setOnCalcFieldOpen", {
443
+ enumerable: true,
444
+ configurable: true,
445
+ writable: true,
446
+ value: (onCalcFieldOpen) => {
447
+ this.onCalcFieldOpenCB = onCalcFieldOpen;
448
+ }
449
+ });
450
+ Object.defineProperty(this, "setOnCalcFieldSelect", {
451
+ enumerable: true,
452
+ configurable: true,
453
+ writable: true,
454
+ value: (onCalcFieldSelect) => {
455
+ this.onCalcFieldSelectCB = onCalcFieldSelect;
456
+ }
457
+ });
458
+ Object.defineProperty(this, "setOnBusinessCalendarRequest", {
459
+ enumerable: true,
460
+ configurable: true,
461
+ writable: true,
462
+ value: (onBusinessCalendarRequest) => {
463
+ this.onBusinessCalendarRequestCB = onBusinessCalendarRequest;
464
+ }
465
+ });
466
+ /** Tells the iframe how a schedule `delete` request ended. */
467
+ Object.defineProperty(this, "sendBusinessCalendarResult", {
468
+ enumerable: true,
469
+ configurable: true,
470
+ writable: true,
471
+ value: (result) => {
472
+ this.sendMessage('--business-calendar-result', JSON.parse(JSON.stringify(result)));
473
+ }
474
+ });
475
+ /**
476
+ * Keeps the schedule state for the iframe and sends it once the tools core has loaded (it
477
+ * goes out again right after `--config`). An unchanged state isn't sent again.
478
+ */
479
+ Object.defineProperty(this, "setBusinessCalendarState", {
480
+ enumerable: true,
481
+ configurable: true,
482
+ writable: true,
483
+ value: (state) => {
484
+ this.businessCalendarStateJson = JSON.stringify(state);
485
+ if (this.hasCoreLoaded &&
486
+ this.businessCalendarStateJson !== this.sentBusinessCalendarStateJson) {
487
+ this.sendBusinessCalendarState();
488
+ }
489
+ }
490
+ });
491
+ Object.defineProperty(this, "sendFormList", {
492
+ enumerable: true,
493
+ configurable: true,
494
+ writable: true,
495
+ value: (forms) => {
496
+ this.sendMessage('--form-list', { forms });
497
+ }
498
+ });
499
+ Object.defineProperty(this, "sendFormFields", {
500
+ enumerable: true,
501
+ configurable: true,
502
+ writable: true,
503
+ value: (formId, fields) => {
504
+ this.formFieldsByFormId[formId] = fields;
505
+ this.updateFormFieldSamples(formId, fields);
506
+ this.sendMessage('--form-fields', { formId, fields });
507
+ }
508
+ });
509
+ Object.defineProperty(this, "sendCalcFieldLabels", {
510
+ enumerable: true,
511
+ configurable: true,
512
+ writable: true,
513
+ value: (labels) => {
514
+ this.sendMessage('--calc-field-labels', { labels });
515
+ }
516
+ });
517
+ /**
518
+ * Replaces the editor's merge tag menu. Nested groups passed to `createEditor` stop DTE
519
+ * custom tools from registering, so init only carries the flat shape and the grouped
520
+ * config is applied here once the editor is ready. A call before that (including the
521
+ * initial props) is parked; a later call replaces it. A failed apply is retried on the
522
+ * next `design:loaded`.
523
+ */
524
+ Object.defineProperty(this, "setMergeTags", {
525
+ enumerable: true,
526
+ configurable: true,
527
+ writable: true,
528
+ value: (tags) => {
529
+ this.mergeTagsConfig = toUnlayerMergeTags(tags);
530
+ this.isMergeTagsApplied = false;
531
+ this.applyMergeTags();
532
+ }
533
+ });
534
+ Object.defineProperty(this, "applyMergeTags", {
535
+ enumerable: true,
536
+ configurable: true,
537
+ writable: true,
538
+ value: () => {
539
+ if (!this.editor ||
540
+ !this.isEditorReady ||
541
+ this.isMergeTagsApplied ||
542
+ !this.mergeTagsConfig) {
543
+ return;
544
+ }
545
+ try {
546
+ this.editor.setMergeTags(this.mergeTagsConfig);
547
+ this.isMergeTagsApplied = true;
548
+ }
549
+ catch (error) {
550
+ logUnlayerError('Failed to apply merge tags', error);
551
+ }
552
+ }
553
+ });
554
+ Object.defineProperty(this, "onEditorReady", {
555
+ enumerable: true,
556
+ configurable: true,
557
+ writable: true,
558
+ value: () => {
559
+ this.isEditorReady = true;
560
+ this.applyMergeTags();
561
+ }
562
+ });
563
+ Object.defineProperty(this, "onDesignLoaded", {
564
+ enumerable: true,
565
+ configurable: true,
566
+ writable: true,
567
+ value: () => {
568
+ var _a;
569
+ // A loaded design means the editor is up even if `editor:ready` never reached us.
570
+ this.onEditorReady();
571
+ if (!this.hasDesign) {
572
+ this.hasDesign = true;
573
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setBodyValues({
574
+ backgroundColor: 'rgba(0,0,0,0)',
575
+ contentWidth: '100%',
576
+ });
577
+ }
578
+ }
579
+ });
580
+ Object.defineProperty(this, "onDesignUpdated", {
581
+ enumerable: true,
582
+ configurable: true,
583
+ writable: true,
584
+ value: (event) => {
585
+ var _a, _b;
586
+ const isToolAdded = !eventsNotAddingTools.includes(event.type);
587
+ const isToolsListChanged = !eventsNotChangingToolsList.includes(event.type);
588
+ if (isToolAdded) {
589
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
590
+ var _a, _b, _c, _d;
591
+ let hasChanges = false;
592
+ unlayerToolsIterate(data.design, tool => {
593
+ var _a;
594
+ const realTool = tool.slug
595
+ ? unlayerToolsParseTwinKey((_a = tool.slug) !== null && _a !== void 0 ? _a : '')
596
+ : undefined;
597
+ if (realTool) {
598
+ hasChanges = true;
599
+ if (tool.slug) {
600
+ delete data.design.counters[`u_content_custom_${tool.slug}`];
601
+ delete tool.values._meta.htmlID;
602
+ }
603
+ tool.type = realTool.type;
604
+ tool.slug = realTool.slug;
374
605
  }
375
- tool.type = realTool.type;
376
- tool.slug = realTool.slug;
606
+ });
607
+ // Duplicated contents/rows carry the original's instance GUIDs; give copies new ones.
608
+ if (unlayerToolsDedupeInstanceIds(data.design, (_c = (_b = (_a = event.item) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.htmlID)) {
609
+ hasChanges = true;
610
+ }
611
+ if (hasChanges) {
612
+ this.setDesign(data.design);
377
613
  }
614
+ (_d = this.onChangeCB) === null || _d === void 0 ? void 0 : _d.call(this, { isToolsListChanged });
378
615
  });
379
- // Duplicated contents/rows carry the original's instance GUIDs; give copies new ones.
380
- if (unlayerToolsDedupeInstanceIds(data.design, (_event_item = event.item) === null || _event_item === void 0 ? void 0 : (_event_item_values = _event_item.values) === null || _event_item_values === void 0 ? void 0 : (_event_item_values__meta = _event_item_values._meta) === null || _event_item_values__meta === void 0 ? void 0 : _event_item_values__meta.htmlID)) {
381
- hasChanges = true;
616
+ }
617
+ else {
618
+ (_b = this.onChangeCB) === null || _b === void 0 ? void 0 : _b.call(this, { isToolsListChanged });
619
+ }
620
+ }
621
+ });
622
+ Object.defineProperty(this, "onPostMessage", {
623
+ enumerable: true,
624
+ configurable: true,
625
+ writable: true,
626
+ value: (e) => {
627
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
628
+ if (!((_a = e.data) === null || _a === void 0 ? void 0 : _a['-dte-message-from'])) {
629
+ return;
630
+ }
631
+ const type = (_c = (_b = e.data) === null || _b === void 0 ? void 0 : _b['-dte-message-from']) === null || _c === void 0 ? void 0 : _c.type;
632
+ const data = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d['-dte-message-from']) === null || _e === void 0 ? void 0 : _e.data;
633
+ if (!type) {
634
+ return;
635
+ }
636
+ if (type === '--ready' || type === '--registered') {
637
+ this.hasToolsRegistered = true;
638
+ this.clearToolsReadyWatchdog();
639
+ (_f = this.onReadyCB) === null || _f === void 0 ? void 0 : _f.call(this);
640
+ }
641
+ else if (type === '--core-loaded') {
642
+ this.hasCoreLoaded = true;
643
+ const configData = {
644
+ dummyData: this.props.dummyData,
645
+ schema: this.props.schema,
646
+ generics: this.props.generics,
647
+ genericConfigMode: this.props.genericConfigMode,
648
+ isSnapshotMode: this.props.isSnapshotMode,
649
+ holidays: this.props.holidays,
650
+ fieldCalendars: this.props.fieldCalendars,
651
+ conditionalRulesEnabled: !!this.props.displayConditions || !!this.props.onConditionalsOpen,
652
+ };
653
+ this.sendMessage('--config', JSON.parse(JSON.stringify(configData)));
654
+ // Always: a reloaded tools core starts without it.
655
+ this.sendBusinessCalendarState();
656
+ }
657
+ else if (type === '--form-select') {
658
+ (_g = this.onFormSelectCB) === null || _g === void 0 ? void 0 : _g.call(this, data === null || data === void 0 ? void 0 : data.formId);
659
+ }
660
+ else if (type === '--calc-field-open') {
661
+ (_h = this.onCalcFieldOpenCB) === null || _h === void 0 ? void 0 : _h.call(this, (_j = data === null || data === void 0 ? void 0 : data.usedFormIds) !== null && _j !== void 0 ? _j : []);
662
+ }
663
+ else if (type === '--esign-offset-open') {
664
+ this.openESignOffsetRules(data);
665
+ }
666
+ else if (type === '--business-calendar-request') {
667
+ // It can delete a tenant schedule and replace bindings: only from this editor's iframe.
668
+ if (e.source === ((_k = this.iframe) === null || _k === void 0 ? void 0 : _k.contentWindow)) {
669
+ this.routeBusinessCalendarRequest(data);
382
670
  }
383
- if (hasChanges) {
384
- this.setDesign(data.design);
671
+ }
672
+ else if (type === '--calc-field-select') {
673
+ if (this.onCalcFieldSelectCB) {
674
+ this.onCalcFieldSelectCB((_l = data === null || data === void 0 ? void 0 : data.fieldKeys) !== null && _l !== void 0 ? _l : []);
385
675
  }
386
- (_this_onChangeCB = (_this = this).onChangeCB) === null || _this_onChangeCB === void 0 ? void 0 : _this_onChangeCB.call(_this, {
387
- isToolsListChanged
388
- });
389
- });
390
- } else {
391
- var _this_onChangeCB, _this;
392
- (_this_onChangeCB = (_this = this).onChangeCB) === null || _this_onChangeCB === void 0 ? void 0 : _this_onChangeCB.call(_this, {
393
- isToolsListChanged
394
- });
395
- }
396
- };
397
- this.onPostMessage = (e)=>{
398
- var _e_data, _e_data_dtemessagefrom, _e_data1, _e_data_dtemessagefrom1, _e_data2, _this_onMessageCB, _this;
399
- if (!((_e_data = e.data) === null || _e_data === void 0 ? void 0 : _e_data['-dte-message-from'])) {
400
- return;
401
- }
402
- const type = (_e_data1 = e.data) === null || _e_data1 === void 0 ? void 0 : (_e_data_dtemessagefrom = _e_data1['-dte-message-from']) === null || _e_data_dtemessagefrom === void 0 ? void 0 : _e_data_dtemessagefrom.type;
403
- const data = (_e_data2 = e.data) === null || _e_data2 === void 0 ? void 0 : (_e_data_dtemessagefrom1 = _e_data2['-dte-message-from']) === null || _e_data_dtemessagefrom1 === void 0 ? void 0 : _e_data_dtemessagefrom1.data;
404
- if (!type) {
405
- return;
406
- }
407
- if (type === '--ready' || type === '--registered') {
408
- var _this_onReadyCB, _this1;
409
- this.hasToolsRegistered = true;
410
- this.clearToolsReadyWatchdog();
411
- (_this_onReadyCB = (_this1 = this).onReadyCB) === null || _this_onReadyCB === void 0 ? void 0 : _this_onReadyCB.call(_this1);
412
- } else if (type === '--core-loaded') {
413
- this.hasCoreLoaded = true;
414
- const configData = {
415
- dummyData: this.props.dummyData,
416
- schema: this.props.schema,
417
- generics: this.props.generics,
418
- genericConfigMode: this.props.genericConfigMode,
419
- isSnapshotMode: this.props.isSnapshotMode,
420
- holidays: this.props.holidays,
421
- conditionalRulesEnabled: !!this.props.displayConditions || !!this.props.onConditionalsOpen
422
- };
423
- this.sendMessage('--config', JSON.parse(JSON.stringify(configData)));
424
- } else if (type === '--form-select') {
425
- var _this_onFormSelectCB, _this2;
426
- (_this_onFormSelectCB = (_this2 = this).onFormSelectCB) === null || _this_onFormSelectCB === void 0 ? void 0 : _this_onFormSelectCB.call(_this2, data === null || data === void 0 ? void 0 : data.formId);
427
- } else if (type === '--calc-field-open') {
428
- var _ref;
429
- var _this_onCalcFieldOpenCB, _this3;
430
- (_this_onCalcFieldOpenCB = (_this3 = this).onCalcFieldOpenCB) === null || _this_onCalcFieldOpenCB === void 0 ? void 0 : _this_onCalcFieldOpenCB.call(_this3, (_ref = data === null || data === void 0 ? void 0 : data.usedFormIds) !== null && _ref !== void 0 ? _ref : []);
431
- } else if (type === '--esign-offset-open') {
432
- this.openESignOffsetRules(data);
433
- } else if (type === '--calc-field-select') {
434
- if (this.onCalcFieldSelectCB) {
435
- var _ref1;
436
- this.onCalcFieldSelectCB((_ref1 = data === null || data === void 0 ? void 0 : data.fieldKeys) !== null && _ref1 !== void 0 ? _ref1 : []);
437
- } else {
438
- this.sendCalcFieldLabels({});
439
- }
440
- } else if (type === '--data-loaded') {
441
- var _this_props_units;
442
- const data = {
443
- customTools: this.props.tools.map((tool)=>({
444
- key: tool.key
445
- })),
446
- toolTwins: this.props.toolTwins,
447
- eSignRecipients: this.props.eSignRecipients,
448
- eSignFieldTypes: this.props.eSignFieldTypes,
449
- units: (_this_props_units = this.props.units) === null || _this_props_units === void 0 ? void 0 : _this_props_units.map((unit)=>({
676
+ else {
677
+ this.sendCalcFieldLabels({});
678
+ }
679
+ }
680
+ else if (type === '--data-loaded') {
681
+ const data = {
682
+ customTools: this.props.tools.map(tool => ({ key: tool.key })),
683
+ toolTwins: this.props.toolTwins,
684
+ eSignRecipients: this.props.eSignRecipients,
685
+ eSignFieldTypes: this.props.eSignFieldTypes,
686
+ eSignFieldTypeLabels: E_SIGN_FIELD_TYPE_LABELS,
687
+ units: (_m = this.props.units) === null || _m === void 0 ? void 0 : _m.map(unit => ({
450
688
  ...unit,
451
689
  values: {
452
690
  ...unit.values,
453
- adminConfig: undefined
454
- }
455
- }))
456
- };
457
- this.sendMessage('--register', JSON.parse(JSON.stringify(data)));
458
- } else if (type === '--save-snapshot') {
459
- var _this_editor;
460
- (_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.exportHtml((template)=>{
461
- unlayerToolsIterate(template.design, (tool)=>{
462
- var _tool_values_twin, _tool_values;
463
- if (((_tool_values = tool.values) === null || _tool_values === void 0 ? void 0 : (_tool_values_twin = _tool_values.twin) === null || _tool_values_twin === void 0 ? void 0 : _tool_values_twin.id) === data.id) {
464
- var _this_onSnapshotSaveCB, _this;
465
- if (!tool.slug) {
466
- return;
691
+ adminConfig: undefined,
692
+ },
693
+ })),
694
+ };
695
+ this.sendMessage('--register', JSON.parse(JSON.stringify(data)));
696
+ }
697
+ else if (type === '--save-snapshot') {
698
+ (_o = this.editor) === null || _o === void 0 ? void 0 : _o.exportHtml(template => {
699
+ unlayerToolsIterate(template.design, tool => {
700
+ var _a, _b, _c;
701
+ if (((_b = (_a = tool.values) === null || _a === void 0 ? void 0 : _a.twin) === null || _b === void 0 ? void 0 : _b.id) === data.id) {
702
+ if (!tool.slug) {
703
+ return;
704
+ }
705
+ (_c = this.onSnapshotSaveCB) === null || _c === void 0 ? void 0 : _c.call(this, {
706
+ title: '',
707
+ tool: tool.slug,
708
+ values: tool.values,
709
+ });
710
+ return false;
467
711
  }
468
- (_this_onSnapshotSaveCB = (_this = this).onSnapshotSaveCB) === null || _this_onSnapshotSaveCB === void 0 ? void 0 : _this_onSnapshotSaveCB.call(_this, {
469
- title: '',
470
- tool: tool.slug,
471
- values: tool.values
472
- });
473
- return false;
474
- }
712
+ });
475
713
  });
476
- });
714
+ }
715
+ (_p = this.onMessageCB) === null || _p === void 0 ? void 0 : _p.call(this, type, data);
477
716
  }
478
- (_this_onMessageCB = (_this = this).onMessageCB) === null || _this_onMessageCB === void 0 ? void 0 : _this_onMessageCB.call(_this, type, data);
479
- };
480
- this.openESignOffsetRules = (data)=>{
481
- const requestId = data === null || data === void 0 ? void 0 : data.requestId;
482
- if (!requestId) {
483
- return;
484
- }
485
- emitESignOffsetRequest({
486
- value: normalizeESignOffsetSettings(data.value),
487
- done: (value)=>{
488
- const result = {
489
- requestId,
490
- value
491
- };
492
- this.sendMessage('--esign-offset-result', JSON.parse(JSON.stringify(result)));
717
+ });
718
+ Object.defineProperty(this, "openESignOffsetRules", {
719
+ enumerable: true,
720
+ configurable: true,
721
+ writable: true,
722
+ value: (data) => {
723
+ const requestId = data === null || data === void 0 ? void 0 : data.requestId;
724
+ if (!requestId) {
725
+ return;
493
726
  }
494
- });
495
- };
496
- this.updateFormFieldSamples = (formId, fields)=>{
497
- fields.forEach((field, index)=>{
498
- var _field_id;
499
- const normalizedFieldId = String((_field_id = field.id) !== null && _field_id !== void 0 ? _field_id : '').replaceAll('-', '');
500
- if (!normalizedFieldId) {
727
+ emitESignOffsetRequest({
728
+ value: normalizeESignOffsetSettings(data.value),
729
+ done: value => {
730
+ const result = { requestId, value };
731
+ this.sendMessage('--esign-offset-result', JSON.parse(JSON.stringify(result)));
732
+ },
733
+ });
734
+ }
735
+ });
736
+ Object.defineProperty(this, "routeBusinessCalendarRequest", {
737
+ enumerable: true,
738
+ configurable: true,
739
+ writable: true,
740
+ value: (data) => {
741
+ var _a;
742
+ if (!(data === null || data === void 0 ? void 0 : data.action) || !data.fieldKey) {
501
743
  return;
502
744
  }
503
- const sampleValue = getFormFieldSampleValue(field, index);
504
- setByPath(this.formFieldSamples, `__submission_fields.${formId}.${normalizedFieldId}`, sampleValue);
505
- this.formFieldSamples[`${FORM_FIELD_DATA_POINT_PREFIX}${normalizedFieldId}`] = sampleValue;
506
- });
507
- };
508
- this.collectCalculatedFieldKeys = (design)=>{
509
- const keys = new Set();
510
- if (!design) {
511
- return keys;
745
+ (_a = this.onBusinessCalendarRequestCB) === null || _a === void 0 ? void 0 : _a.call(this, data);
512
746
  }
513
- unlayerToolsIterate(design, (tool)=>{
514
- var _tool_values;
515
- const calc = (_tool_values = tool.values) === null || _tool_values === void 0 ? void 0 : _tool_values.calculation;
516
- if (!calc || typeof calc !== 'object') {
747
+ });
748
+ Object.defineProperty(this, "sendBusinessCalendarState", {
749
+ enumerable: true,
750
+ configurable: true,
751
+ writable: true,
752
+ value: () => {
753
+ if (!this.businessCalendarStateJson) {
517
754
  return;
518
755
  }
519
- if (typeof calc.expression === 'string') {
520
- for (const key of tokenizeFormulaFields(calc.expression)){
521
- keys.add(key);
756
+ this.sentBusinessCalendarStateJson = this.businessCalendarStateJson;
757
+ this.sendMessage('--business-calendar-state', JSON.parse(this.businessCalendarStateJson));
758
+ }
759
+ });
760
+ Object.defineProperty(this, "updateFormFieldSamples", {
761
+ enumerable: true,
762
+ configurable: true,
763
+ writable: true,
764
+ value: (formId, fields) => {
765
+ fields.forEach((field, index) => {
766
+ var _a;
767
+ const normalizedFieldId = String((_a = field.id) !== null && _a !== void 0 ? _a : '').replaceAll('-', '');
768
+ if (!normalizedFieldId) {
769
+ return;
522
770
  }
771
+ const sampleValue = getFormFieldSampleValue(field, index);
772
+ setByPath(this.formFieldSamples, `__submission_fields.${formId}.${normalizedFieldId}`, sampleValue);
773
+ this.formFieldSamples[`${FORM_FIELD_DATA_POINT_PREFIX}${normalizedFieldId}`] =
774
+ sampleValue;
775
+ });
776
+ }
777
+ });
778
+ Object.defineProperty(this, "collectCalculatedFieldKeys", {
779
+ enumerable: true,
780
+ configurable: true,
781
+ writable: true,
782
+ value: (design) => {
783
+ const keys = new Set();
784
+ if (!design) {
785
+ return keys;
523
786
  }
524
- if (calc.fieldLabels && typeof calc.fieldLabels === 'object') {
525
- Object.keys(calc.fieldLabels).forEach((key)=>keys.add(key));
526
- }
527
- });
528
- return keys;
529
- };
530
- this.resolveDemoValue = (key, fallbackIndex, sourceData)=>{
531
- const parsedFormField = parseFormFieldKey(key);
532
- if (parsedFormField) {
533
- var _this_formFieldsByFormId_parsedFormField_formId;
534
- const normalizedFieldId = parsedFormField.fieldId;
535
- const formFields = (_this_formFieldsByFormId_parsedFormField_formId = this.formFieldsByFormId[parsedFormField.formId]) !== null && _this_formFieldsByFormId_parsedFormField_formId !== void 0 ? _this_formFieldsByFormId_parsedFormField_formId : [];
536
- const fieldIndex = formFields.findIndex((field)=>{
537
- var _field_id;
538
- return String((_field_id = field.id) !== null && _field_id !== void 0 ? _field_id : '').replaceAll('-', '') === normalizedFieldId;
787
+ unlayerToolsIterate(design, tool => {
788
+ var _a;
789
+ const calc = (_a = tool.values) === null || _a === void 0 ? void 0 : _a.calculation;
790
+ if (!calc || typeof calc !== 'object') {
791
+ return;
792
+ }
793
+ if (typeof calc.expression === 'string') {
794
+ for (const key of tokenizeFormulaFields(calc.expression)) {
795
+ keys.add(key);
796
+ }
797
+ }
798
+ if (calc.fieldLabels && typeof calc.fieldLabels === 'object') {
799
+ Object.keys(calc.fieldLabels).forEach(key => keys.add(key));
800
+ }
539
801
  });
540
- const field = fieldIndex >= 0 ? formFields[fieldIndex] : undefined;
541
- const sample = field ? getFormFieldSampleValue(field, fieldIndex) : getByPath(this.formFieldSamples, `__submission_fields.${parsedFormField.formId}.${normalizedFieldId}`);
542
- if (sample !== undefined) {
543
- return sample;
802
+ return keys;
803
+ }
804
+ });
805
+ Object.defineProperty(this, "resolveDemoValue", {
806
+ enumerable: true,
807
+ configurable: true,
808
+ writable: true,
809
+ value: (key, fallbackIndex, sourceData) => {
810
+ var _a;
811
+ const parsedFormField = parseFormFieldKey(key);
812
+ if (parsedFormField) {
813
+ const normalizedFieldId = parsedFormField.fieldId;
814
+ const formFields = (_a = this.formFieldsByFormId[parsedFormField.formId]) !== null && _a !== void 0 ? _a : [];
815
+ const fieldIndex = formFields.findIndex(field => { var _a; return String((_a = field.id) !== null && _a !== void 0 ? _a : '').replaceAll('-', '') === normalizedFieldId; });
816
+ const field = fieldIndex >= 0 ? formFields[fieldIndex] : undefined;
817
+ const sample = field
818
+ ? getFormFieldSampleValue(field, fieldIndex)
819
+ : getByPath(this.formFieldSamples, `__submission_fields.${parsedFormField.formId}.${normalizedFieldId}`);
820
+ if (sample !== undefined) {
821
+ return sample;
822
+ }
823
+ return this.dateSchemaFieldKeys.has(key) ? '2026-01-15' : 44 + fallbackIndex;
824
+ }
825
+ const existing = getByPath(sourceData, key);
826
+ if (existing !== undefined) {
827
+ return existing;
828
+ }
829
+ if (this.dateSchemaFieldKeys.has(key)) {
830
+ return '2026-01-15';
544
831
  }
545
- return this.dateSchemaFieldKeys.has(key) ? '2026-01-15' : 44 + fallbackIndex;
832
+ return 44 + fallbackIndex;
546
833
  }
547
- const existing = getByPath(sourceData, key);
548
- if (existing !== undefined) {
549
- return existing;
834
+ });
835
+ Object.defineProperty(this, "buildCalculatedFieldDemoData", {
836
+ enumerable: true,
837
+ configurable: true,
838
+ writable: true,
839
+ value: (design) => {
840
+ const demoData = {};
841
+ const usedKeys = Array.from(this.collectCalculatedFieldKeys(design));
842
+ const sourceData = deepMerge(this.schemaDummyData, this.props.dummyData, this.formFieldSamples);
843
+ usedKeys.forEach((key, index) => {
844
+ const value = this.resolveDemoValue(key, index, sourceData);
845
+ setByPath(demoData, key, value);
846
+ });
847
+ return demoData;
550
848
  }
551
- if (this.dateSchemaFieldKeys.has(key)) {
552
- return '2026-01-15';
849
+ });
850
+ Object.defineProperty(this, "sendMessage", {
851
+ enumerable: true,
852
+ configurable: true,
853
+ writable: true,
854
+ value: (type, data) => {
855
+ var _a, _b;
856
+ (_b = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage({
857
+ '-dte-message-to': {
858
+ type,
859
+ data,
860
+ },
861
+ }, '*');
553
862
  }
554
- return 44 + fallbackIndex;
555
- };
556
- this.buildCalculatedFieldDemoData = (design)=>{
557
- const demoData = {};
558
- const usedKeys = Array.from(this.collectCalculatedFieldKeys(design));
559
- const sourceData = deepMerge(this.schemaDummyData, this.props.dummyData, this.formFieldSamples);
560
- usedKeys.forEach((key, index)=>{
561
- const value = this.resolveDemoValue(key, index, sourceData);
562
- setByPath(demoData, key, value);
563
- });
564
- return demoData;
565
- };
566
- this.sendMessage = (type, data)=>{
567
- var _this_iframe_contentWindow, _this_iframe;
568
- (_this_iframe = this.iframe) === null || _this_iframe === void 0 ? void 0 : (_this_iframe_contentWindow = _this_iframe.contentWindow) === null || _this_iframe_contentWindow === void 0 ? void 0 : _this_iframe_contentWindow.postMessage({
569
- '-dte-message-to': {
570
- type,
571
- data
572
- }
573
- }, '*');
574
- };
575
- this.uploadImage = async (data, done)=>{
576
- var _this_props_imageValidation;
577
- var _data_attachments;
578
- if (!this.onImageCB) {
579
- done({
580
- progress: 100
581
- });
582
- throw new Error('image upload is not implemented');
583
- }
584
- if (!((_data_attachments = data.attachments) === null || _data_attachments === void 0 ? void 0 : _data_attachments.length)) {
585
- return;
586
- }
587
- const file = data.attachments[0];
588
- const res = await this.validateImage(file, {
589
- ...defaultImageValidation,
590
- ...(_this_props_imageValidation = this.props.imageValidation) !== null && _this_props_imageValidation !== void 0 ? _this_props_imageValidation : {}
591
- });
592
- if (!res.isValid) {
593
- var _this_onErrorCB, _this;
594
- logUnlayerError(`Image validation failed: ${res.title}`, res.description);
595
- (_this_onErrorCB = (_this = this).onErrorCB) === null || _this_onErrorCB === void 0 ? void 0 : _this_onErrorCB.call(_this, res.title, res.description);
596
- return;
597
- }
598
- /*
599
- * Unlayer only leaves its "uploading" state when `done` receives a url, so `done` must not be
600
- * called before the upload succeeds or after it fails, otherwise the image widget gets stuck.
601
- */ try {
602
- const { url } = await this.onImageCB(file);
603
- done({
604
- progress: 100,
605
- url
863
+ });
864
+ Object.defineProperty(this, "uploadImage", {
865
+ enumerable: true,
866
+ configurable: true,
867
+ writable: true,
868
+ value: async (data, done) => {
869
+ var _a, _b, _c, _d;
870
+ if (!this.onImageCB) {
871
+ done({ progress: 100 });
872
+ throw new Error('image upload is not implemented');
873
+ }
874
+ if (!((_a = data.attachments) === null || _a === void 0 ? void 0 : _a.length)) {
875
+ return;
876
+ }
877
+ const file = data.attachments[0];
878
+ const res = await this.validateImage(file, {
879
+ ...defaultImageValidation,
880
+ ...((_b = this.props.imageValidation) !== null && _b !== void 0 ? _b : {}),
606
881
  });
607
- } catch (error) {
608
- var _this_onErrorCB1, _this1;
609
- logUnlayerError('Image upload failed', error);
610
- (_this_onErrorCB1 = (_this1 = this).onErrorCB) === null || _this_onErrorCB1 === void 0 ? void 0 : _this_onErrorCB1.call(_this1, 'Image upload failed', error instanceof ImageUploadError ? error.message : 'Something went wrong while uploading the image. Please try again or select another image.');
882
+ if (!res.isValid) {
883
+ logUnlayerError(`Image validation failed: ${res.title}`, res.description);
884
+ (_c = this.onErrorCB) === null || _c === void 0 ? void 0 : _c.call(this, res.title, res.description);
885
+ return;
886
+ }
887
+ /*
888
+ * Unlayer only leaves its "uploading" state when `done` receives a url, so `done` must not be
889
+ * called before the upload succeeds or after it fails, otherwise the image widget gets stuck.
890
+ */
891
+ try {
892
+ const { url } = await this.onImageCB(file);
893
+ done({ progress: 100, url });
894
+ }
895
+ catch (error) {
896
+ logUnlayerError('Image upload failed', error);
897
+ (_d = this.onErrorCB) === null || _d === void 0 ? void 0 : _d.call(this, 'Image upload failed', error instanceof ImageUploadError
898
+ ? error.message
899
+ : 'Something went wrong while uploading the image. Please try again or select another image.');
900
+ }
611
901
  }
612
- };
613
- this.startToolsReadyWatchdog = ()=>{
614
- this.clearToolsReadyWatchdog();
615
- this.toolsReadyWatchdogId = window.setTimeout(()=>{
616
- var _this_onErrorCB, _this;
617
- if (this.hasToolsRegistered) {
902
+ });
903
+ Object.defineProperty(this, "startToolsReadyWatchdog", {
904
+ enumerable: true,
905
+ configurable: true,
906
+ writable: true,
907
+ value: () => {
908
+ this.clearToolsReadyWatchdog();
909
+ this.toolsReadyWatchdogId = window.setTimeout(() => {
910
+ var _a;
911
+ if (this.hasToolsRegistered) {
912
+ return;
913
+ }
914
+ logUnlayerError('Unlayer custom tools did not finish loading. customJS may not have run, or tool registration stalled.', {
915
+ hasCoreLoaded: this.hasCoreLoaded,
916
+ hasToolsRegistered: this.hasToolsRegistered,
917
+ });
918
+ (_a = this.onErrorCB) === null || _a === void 0 ? void 0 : _a.call(this, 'Editor failed to load custom tools', 'Unlayer custom tools did not finish loading. Check the browser console for [dte-unlayer] details.');
919
+ }, UNLAYER_TOOLS_READY_TIMEOUT_MS);
920
+ }
921
+ });
922
+ Object.defineProperty(this, "clearToolsReadyWatchdog", {
923
+ enumerable: true,
924
+ configurable: true,
925
+ writable: true,
926
+ value: () => {
927
+ if (this.toolsReadyWatchdogId === undefined) {
618
928
  return;
619
929
  }
620
- logUnlayerError('Unlayer custom tools did not finish loading. customJS may not have run, or tool registration stalled.', {
621
- hasCoreLoaded: this.hasCoreLoaded,
622
- hasToolsRegistered: this.hasToolsRegistered
623
- });
624
- (_this_onErrorCB = (_this = this).onErrorCB) === null || _this_onErrorCB === void 0 ? void 0 : _this_onErrorCB.call(_this, 'Editor failed to load custom tools', 'Unlayer custom tools did not finish loading. Check the browser console for [dte-unlayer] details.');
625
- }, UNLAYER_TOOLS_READY_TIMEOUT_MS);
626
- };
627
- this.clearToolsReadyWatchdog = ()=>{
628
- if (this.toolsReadyWatchdogId === undefined) {
629
- return;
930
+ window.clearTimeout(this.toolsReadyWatchdogId);
931
+ this.toolsReadyWatchdogId = undefined;
630
932
  }
631
- window.clearTimeout(this.toolsReadyWatchdogId);
632
- this.toolsReadyWatchdogId = undefined;
633
- };
634
- this.validateImage = async (file, imageValidation)=>{
635
- const { maxFileSize, maxHeight, maxWidth } = imageValidation;
636
- if (file.size > maxFileSize) {
637
- const maxSizeMB = (maxFileSize / 1024 / 1024).toFixed(2);
638
- const fileSizeMB = (file.size / 1024 / 1024).toFixed(2);
639
- return {
640
- isValid: false,
641
- title: 'Image size limit reached',
642
- description: `This image is ${fileSizeMB}MB, which is above the ${maxSizeMB}MB limit. Please upload a smaller file to continue.`
643
- };
644
- }
645
- return new Promise((resolve)=>{
646
- const img = new Image();
647
- const objectUrl = URL.createObjectURL(file);
648
- img.onload = ()=>{
649
- URL.revokeObjectURL(objectUrl);
650
- const { height, width } = img;
651
- if (width > maxWidth || height > maxHeight) {
933
+ });
934
+ Object.defineProperty(this, "validateImage", {
935
+ enumerable: true,
936
+ configurable: true,
937
+ writable: true,
938
+ value: async (file, imageValidation) => {
939
+ const { maxFileSize, maxHeight, maxWidth } = imageValidation;
940
+ if (file.size > maxFileSize) {
941
+ const maxSizeMB = (maxFileSize / 1024 / 1024).toFixed(2);
942
+ const fileSizeMB = (file.size / 1024 / 1024).toFixed(2);
943
+ return {
944
+ isValid: false,
945
+ title: 'Image size limit reached',
946
+ description: `This image is ${fileSizeMB}MB, which is above the ${maxSizeMB}MB limit. Please upload a smaller file to continue.`,
947
+ };
948
+ }
949
+ return new Promise(resolve => {
950
+ const img = new Image();
951
+ const objectUrl = URL.createObjectURL(file);
952
+ img.onload = () => {
953
+ URL.revokeObjectURL(objectUrl);
954
+ const { height, width } = img;
955
+ if (width > maxWidth || height > maxHeight) {
956
+ resolve({
957
+ isValid: false,
958
+ title: 'Dimension limit reached',
959
+ description: `These image dimensions (${width}x${height}px) exceed the ${maxWidth}x${maxHeight}px limit. Please resize the image and try again.`,
960
+ });
961
+ }
962
+ else {
963
+ resolve({ isValid: true, title: '', description: '' });
964
+ }
965
+ };
966
+ img.onerror = () => {
967
+ URL.revokeObjectURL(objectUrl);
652
968
  resolve({
653
969
  isValid: false,
654
- title: 'Dimension limit reached',
655
- description: `These image dimensions (${width}x${height}px) exceed the ${maxWidth}x${maxHeight}px limit. Please resize the image and try again.`
656
- });
657
- } else {
658
- resolve({
659
- isValid: true,
660
- title: '',
661
- description: ''
970
+ title: 'The image is broken',
971
+ description: 'Looks like this image isn’t valid. Please choose another image and try again.',
662
972
  });
663
- }
664
- };
665
- img.onerror = ()=>{
666
- URL.revokeObjectURL(objectUrl);
667
- resolve({
668
- isValid: false,
669
- title: 'The image is broken',
670
- description: 'Looks like this image isn’t valid. Please choose another image and try again.'
671
- });
672
- };
673
- img.src = objectUrl;
674
- });
675
- };
973
+ };
974
+ img.src = objectUrl;
975
+ });
976
+ }
977
+ });
676
978
  const schemaData = this.props.schema ? schemaBuildMap(this.props.schema) : undefined;
677
- this.schemaDummyData = (_ref = schemaData === null || schemaData === void 0 ? void 0 : schemaData.dummyData) !== null && _ref !== void 0 ? _ref : {};
678
- this.dateSchemaFieldKeys = new Set(Object.values((_ref1 = schemaData === null || schemaData === void 0 ? void 0 : schemaData.map) !== null && _ref1 !== void 0 ? _ref1 : {}).filter((field)=>field.isValue && schemaIsDate(field.node)).map((field)=>field.fullKey));
979
+ this.schemaDummyData = ((_a = schemaData === null || schemaData === void 0 ? void 0 : schemaData.dummyData) !== null && _a !== void 0 ? _a : {});
980
+ this.dateSchemaFieldKeys = new Set(Object.values((_b = schemaData === null || schemaData === void 0 ? void 0 : schemaData.map) !== null && _b !== void 0 ? _b : {})
981
+ .filter(field => field.isValue && schemaIsDate(field.node))
982
+ .map(field => field.fullKey));
983
+ // Each entry's type value is derived from it; the name shown can differ (E_SIGN_FIELD_TYPE_LABELS).
679
984
  this.props.eSignFieldTypes = [
680
985
  'Signature',
681
986
  'Initials',
682
987
  'Date Signed',
683
988
  'Date Signed Offset',
684
- 'Full Name'
989
+ 'Full Name',
685
990
  ];
686
991
  this.unlayerRef = {
687
- loadDesign: (design)=>{
688
- var _this_editor;
689
- (_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.loadDesign(design);
992
+ loadDesign: design => {
993
+ var _a;
994
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.loadDesign(design);
690
995
  },
691
- saveDesign: (cb)=>{
692
- var _this_editor;
693
- (_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.saveDesign((design)=>{
996
+ saveDesign: cb => {
997
+ var _a;
998
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.saveDesign(design => {
694
999
  unlayerToolsNormalizeESignOffsets(design);
695
1000
  cb(design);
696
1001
  });
697
1002
  },
698
- exportHtml: (cb)=>{
699
- var _this_editor;
700
- (_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.exportHtml((data)=>{
1003
+ exportHtml: cb => {
1004
+ var _a;
1005
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
701
1006
  const result = ensureChunksFonts(data);
702
1007
  unlayerToolsNormalizeESignOffsets(result === null || result === void 0 ? void 0 : result.design);
703
1008
  result.demoData = this.buildCalculatedFieldDemoData(result.design);
704
1009
  cb(result);
705
1010
  });
706
1011
  },
707
- sendFormList: (forms)=>{
1012
+ sendFormList: forms => {
708
1013
  this.sendFormList(forms);
709
1014
  },
710
- sendFormFields: (formId, fields)=>{
1015
+ sendFormFields: (formId, fields) => {
711
1016
  this.sendFormFields(formId, fields);
712
1017
  },
713
- sendCalcFieldLabels: (labels)=>{
1018
+ sendCalcFieldLabels: labels => {
714
1019
  this.sendCalcFieldLabels(labels);
715
1020
  },
716
- setMergeTags: (tags)=>{
1021
+ setMergeTags: tags => {
717
1022
  this.setMergeTags(tags);
718
- }
1023
+ },
719
1024
  };
720
1025
  }
721
1026
  }
722
-
723
1027
  //# sourceMappingURL=store.js.map