@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260722101954

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 (60) hide show
  1. package/dist/CopyButton-UPJPMJUB.mjs +57 -0
  2. package/dist/CopyButton-XONTQQW7.mjs +55 -0
  3. package/dist/DateTimeViewClient-22GW4AD7.mjs +14 -0
  4. package/dist/DateTimeViewClient-K5FE5VSN.mjs +14 -0
  5. package/dist/DateTimeViewClient-M7V35KUW.mjs +16 -0
  6. package/dist/DateTimeViewClient-R3M6ISVK.mjs +16 -0
  7. package/dist/DateViewClient-4CTEMOMJ.mjs +7 -0
  8. package/dist/DateViewClient-ELEHLGWS.mjs +7 -0
  9. package/dist/DateViewClient-JBS5UXMD.mjs +9 -0
  10. package/dist/DateViewClient-VLTRN47D.mjs +9 -0
  11. package/dist/EnterAnimationClient-4OKXLKSA.mjs +45 -0
  12. package/dist/EnterAnimationClient-ZN3NLFNO.mjs +47 -0
  13. package/dist/HlsPlayer-57543DTW.mjs +599 -0
  14. package/dist/HlsPlayer-5AWFZ2P6.mjs +601 -0
  15. package/dist/IframeClient-J22NMEVY.mjs +96 -0
  16. package/dist/IframeClient-RGJFZ5P2.mjs +98 -0
  17. package/dist/InputControlClient-7NS4QUWO.mjs +677 -0
  18. package/dist/InputControlClient-AZRPSTUZ.mjs +677 -0
  19. package/dist/InputControlClient-BUOYZNWQ.mjs +675 -0
  20. package/dist/InputControlClient-HIZOJLKW.mjs +677 -0
  21. package/dist/LinkNodeButton-AOEDCCL7.mjs +227 -0
  22. package/dist/LinkNodeButton-BIZA2NPE.mjs +225 -0
  23. package/dist/LinkNodeButton-LX3KKGZY.mjs +173 -0
  24. package/dist/LinkNodeButton-U7T2NP22.mjs +374 -0
  25. package/dist/Pagination-6OFACRMQ.mjs +229 -0
  26. package/dist/Pagination-NCJCOYHF.mjs +181 -0
  27. package/dist/Pagination-OQT7Q2XO.mjs +183 -0
  28. package/dist/Pagination-T7YN2OMV.mjs +183 -0
  29. package/dist/Slider-554BKC7N.mjs +322 -0
  30. package/dist/Slider-PEIVH6A5.mjs +320 -0
  31. package/dist/chunk-23WJE3YB.mjs +253 -0
  32. package/dist/chunk-3GWLDT7C.mjs +204 -0
  33. package/dist/chunk-3R4VVVNK.mjs +903 -0
  34. package/dist/chunk-56HSDML5.mjs +22 -0
  35. package/dist/chunk-5GHPW7SJ.mjs +111 -0
  36. package/dist/chunk-7ZFZLN56.mjs +903 -0
  37. package/dist/chunk-DBHUCH4B.mjs +109 -0
  38. package/dist/chunk-DKW4DXCU.mjs +120 -0
  39. package/dist/chunk-FI2KJBK2.mjs +110 -0
  40. package/dist/chunk-IMNQO57B.mjs +25 -0
  41. package/dist/chunk-JKP4XOZB.mjs +214 -0
  42. package/dist/chunk-OGGIS4AN.mjs +201 -0
  43. package/dist/chunk-RHVNJMS4.mjs +251 -0
  44. package/dist/chunk-SPRVN5IM.mjs +118 -0
  45. package/dist/chunk-TVL6KVD5.mjs +229 -0
  46. package/dist/chunk-UFKPTMM7.mjs +199 -0
  47. package/dist/chunk-WEV5U33G.mjs +207 -0
  48. package/dist/chunk-X3YSXTD2.mjs +201 -0
  49. package/dist/chunk-XG6SXZWP.mjs +115 -0
  50. package/dist/chunk-YBNWT4TV.mjs +123 -0
  51. package/dist/chunk-YG6FKKQJ.mjs +900 -0
  52. package/dist/index.d.mts +456 -0
  53. package/dist/index.d.ts +456 -0
  54. package/dist/index.js +8566 -0
  55. package/dist/index.mjs +4285 -0
  56. package/dist/server.d.mts +113 -0
  57. package/dist/server.d.ts +113 -0
  58. package/dist/server.js +5179 -0
  59. package/dist/server.mjs +2736 -0
  60. package/package.json +95 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,4285 @@
1
+ import {
2
+ OdataBuilder
3
+ } from "./chunk-UFKPTMM7.mjs";
4
+ import {
5
+ AssetUtility_default,
6
+ BooleanSelect_default,
7
+ CheckboxInput_default,
8
+ ColorInput_default,
9
+ DateTimeInput_default,
10
+ EmailInput_default,
11
+ LineTextInput_default,
12
+ MoneyInput_default,
13
+ MultilineTextInput_default,
14
+ NumberInput_default,
15
+ OtpInput_default,
16
+ PercentageInput_default,
17
+ PhoneInput_default,
18
+ SelectWithSearchInput_default,
19
+ TimeInput_default
20
+ } from "./chunk-YG6FKKQJ.mjs";
21
+ import {
22
+ Constants,
23
+ Hyperlink,
24
+ Icon_default,
25
+ InputControlType_default
26
+ } from "./chunk-DBHUCH4B.mjs";
27
+ import {
28
+ ServiceClient_default
29
+ } from "./chunk-3GWLDT7C.mjs";
30
+ import {
31
+ Button_default,
32
+ ClientButton_default,
33
+ ToastService_default
34
+ } from "./chunk-RHVNJMS4.mjs";
35
+ import "./chunk-56HSDML5.mjs";
36
+
37
+ // src/components/controls/view/ViewControl.tsx
38
+ import React13 from "react";
39
+
40
+ // src/components/controls/view/ViewControlTypes.tsx
41
+ var ViewControlTypes = {
42
+ lineText: "lineText",
43
+ emailText: "email",
44
+ asset: "asset",
45
+ video: "video",
46
+ multilineTextBullets: "multilineTextBullets",
47
+ boolean: "boolean",
48
+ checkboxInput: "boolean",
49
+ money: "money",
50
+ date: "date",
51
+ time: "time",
52
+ datetime: "datetime",
53
+ number: "number",
54
+ multilineText: "multilineText",
55
+ multilinetext: "multilinetext",
56
+ moneyText: "moneyText",
57
+ percentage: "percentage",
58
+ status: "status",
59
+ statusBg: "statusBg",
60
+ progressIndicator: "progressIndicator",
61
+ timeUntilStarts: "timeUntilStarts",
62
+ timeUntilStartsStyled: "timeUntilStartsStyled",
63
+ aiGeneratedSummary: "aiGeneratedSummary",
64
+ booleanView: "booleanView",
65
+ text: "text"
66
+ };
67
+ var ViewControlTypes_default = ViewControlTypes;
68
+
69
+ // src/components/controls/view/NumberView.tsx
70
+ import React from "react";
71
+ import { jsx } from "react/jsx-runtime";
72
+ var NumberView = (props) => {
73
+ return /* @__PURE__ */ jsx(React.Fragment, { children: props.value });
74
+ };
75
+ var NumberView_default = NumberView;
76
+
77
+ // src/components/controls/view/DateView.tsx
78
+ import dynamic from "next/dynamic";
79
+ var DateView = dynamic(() => import("./DateViewClient-4CTEMOMJ.mjs"), {
80
+ ssr: false
81
+ });
82
+ var DateView_default = DateView;
83
+
84
+ // src/components/controls/view/BooleanView.tsx
85
+ import React2 from "react";
86
+ import { jsx as jsx2 } from "react/jsx-runtime";
87
+ var BooleanView = (props) => {
88
+ const { value, customProps } = props;
89
+ const showOnlyTrueIcon = customProps?.showOnlyTrueIcon;
90
+ console.log("BooleanView Debug:", {
91
+ value,
92
+ type: typeof value,
93
+ customProps,
94
+ showOnlyTrueIcon
95
+ });
96
+ const booleanValue = (() => {
97
+ if (typeof value === "boolean") return value;
98
+ if (typeof value === "string") {
99
+ return value.toLowerCase() === "true";
100
+ }
101
+ if (typeof value === "number") {
102
+ return value === 1;
103
+ }
104
+ return false;
105
+ })();
106
+ if (showOnlyTrueIcon) {
107
+ return /* @__PURE__ */ jsx2(React2.Fragment, { children: booleanValue === true && /* @__PURE__ */ jsx2(
108
+ "svg",
109
+ {
110
+ className: "w-15 h-8 text-green-600",
111
+ fill: "currentColor",
112
+ viewBox: "0 0 20 20",
113
+ children: /* @__PURE__ */ jsx2(
114
+ "path",
115
+ {
116
+ fillRule: "evenodd",
117
+ d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
118
+ clipRule: "evenodd"
119
+ }
120
+ )
121
+ }
122
+ ) });
123
+ }
124
+ return /* @__PURE__ */ jsx2(React2.Fragment, { children: booleanValue ? "true" : "false" });
125
+ };
126
+ var BooleanView_default = BooleanView;
127
+
128
+ // src/components/controls/view/Asset.tsx
129
+ import React3 from "react";
130
+
131
+ // src/components/DeviceAssetSelector.tsx
132
+ import dynamic2 from "next/dynamic";
133
+ import { jsx as jsx3 } from "react/jsx-runtime";
134
+ var HlsPlayer = dynamic2(() => import("./HlsPlayer-57543DTW.mjs"), { ssr: false });
135
+ var FORMAT_CLASSES = {
136
+ center: "justify-center",
137
+ left: "justify-start",
138
+ right: "justify-end"
139
+ };
140
+ var DeviceAssetSelector = ({
141
+ assets,
142
+ assetBaseUrl,
143
+ session,
144
+ width,
145
+ tag,
146
+ nodeProps,
147
+ device
148
+ }) => {
149
+ const targetTag = tag || nodeProps?.tag;
150
+ const selectAssetByDevice = (assets2, currentDevice) => assets2.find((a) => a.device === currentDevice) ?? assets2.find((a) => !a.device || a.device === "");
151
+ const selectAsset = () => {
152
+ if (!assets?.length) return void 0;
153
+ if (targetTag) {
154
+ const tagged = assets.filter((a) => a.tag === targetTag);
155
+ if (tagged.length) {
156
+ return tagged.find((a) => a.device === device) ?? tagged.find((a) => !a.device || a.device === "");
157
+ }
158
+ }
159
+ return selectAssetByDevice(assets, device);
160
+ };
161
+ const selectedAsset = selectAsset();
162
+ if (!selectedAsset) return null;
163
+ const resolvedAssetUrl = AssetUtility_default.resolveUrl(assetBaseUrl, selectedAsset.assetUrl);
164
+ const resolvedThumbnailUrl = selectedAsset.posterUrl ? AssetUtility_default.resolveUrl(assetBaseUrl, selectedAsset.posterUrl) : void 0;
165
+ const title = selectedAsset.title || nodeProps?.title;
166
+ const isHls = resolvedAssetUrl?.endsWith(".m3u8");
167
+ const showControls = nodeProps?.showControls === "true";
168
+ const loop = nodeProps?.loop === "true";
169
+ const styles = {
170
+ ...nodeProps?.borderRadius && { borderRadius: nodeProps.borderRadius },
171
+ ...nodeProps?.width && { width: nodeProps.width },
172
+ ...nodeProps?.height && { height: nodeProps.height }
173
+ };
174
+ const renderMedia = () => isHls ? /* @__PURE__ */ jsx3(
175
+ HlsPlayer,
176
+ {
177
+ assetUrl: resolvedAssetUrl,
178
+ posterUrl: resolvedThumbnailUrl,
179
+ intrinsicWidth: selectedAsset.intrinsicWidth?.toString(),
180
+ intrinsicHeight: selectedAsset.intrinsicHeight?.toString(),
181
+ showControls,
182
+ loop,
183
+ playOptions: nodeProps?.playOptions,
184
+ apiBaseUrl: assetBaseUrl,
185
+ session
186
+ }
187
+ ) : /* @__PURE__ */ jsx3(
188
+ "img",
189
+ {
190
+ style: styles,
191
+ loading: "lazy",
192
+ className: "object-cover w-full",
193
+ src: resolvedAssetUrl,
194
+ width: selectedAsset.intrinsicWidth,
195
+ height: selectedAsset.intrinsicHeight,
196
+ alt: title || "Asset image"
197
+ }
198
+ );
199
+ if (width) return /* @__PURE__ */ jsx3("div", { style: { width }, children: renderMedia() });
200
+ if (nodeProps?.format) {
201
+ return /* @__PURE__ */ jsx3("div", { className: `flex ${FORMAT_CLASSES[nodeProps.format] ?? ""}`, children: renderMedia() });
202
+ }
203
+ return renderMedia();
204
+ };
205
+ var DeviceAssetSelector_default = DeviceAssetSelector;
206
+
207
+ // src/components/controls/view/Asset.tsx
208
+ import { jsx as jsx4 } from "react/jsx-runtime";
209
+ var MediaAsset = (props) => {
210
+ let assets;
211
+ if (props.value != void 0 && props.value != null && props.value != "") {
212
+ try {
213
+ assets = JSON.parse(props.value);
214
+ console.log("Parsed Assets: ", assets);
215
+ } catch (error) {
216
+ console.error("Error parsing assets:", error);
217
+ }
218
+ }
219
+ if (!assets || assets.length === 0) {
220
+ return null;
221
+ }
222
+ console.log(props.customProps?.tag, "Tag in MediaAsset");
223
+ return /* @__PURE__ */ jsx4(React3.Fragment, { children: /* @__PURE__ */ jsx4(
224
+ DeviceAssetSelector_default,
225
+ {
226
+ assets,
227
+ apiBaseUrl: props.apiBaseUrl,
228
+ assetBaseUrl: props.assetBaseUrl ? props.assetBaseUrl : props.apiBaseUrl,
229
+ session: props,
230
+ width: props.width,
231
+ customProps: props.customProps,
232
+ tag: props.customProps?.tag
233
+ }
234
+ ) });
235
+ };
236
+ var Asset_default = MediaAsset;
237
+
238
+ // src/components/controls/view/LineTextView.tsx
239
+ import React4 from "react";
240
+ import { jsx as jsx5 } from "react/jsx-runtime";
241
+ var LineText = (props) => {
242
+ return /* @__PURE__ */ jsx5(React4.Fragment, { children: props.value });
243
+ };
244
+ var LineTextView_default = LineText;
245
+
246
+ // src/components/controls/view/EmailTextView.tsx
247
+ import React5 from "react";
248
+ import { jsx as jsx6 } from "react/jsx-runtime";
249
+ var EmailText = (props) => {
250
+ return /* @__PURE__ */ jsx6(React5.Fragment, { children: props.value });
251
+ };
252
+ var EmailTextView_default = EmailText;
253
+
254
+ // src/components/controls/view/StatusBgView.tsx
255
+ import React6 from "react";
256
+ import { jsx as jsx7 } from "react/jsx-runtime";
257
+ var StatusBg = (props) => {
258
+ return /* @__PURE__ */ jsx7(React6.Fragment, { children: props.value && props.value != "" && /* @__PURE__ */ jsx7("span", { className: "py-0.5 px-1.5 text-xs capitalize text-white font-semibold rounded bg-status bg-status-" + props.value, children: props.value }) });
259
+ };
260
+ var StatusBgView_default = StatusBg;
261
+
262
+ // src/components/controls/view/StatusView.tsx
263
+ import React7 from "react";
264
+ import { jsx as jsx8 } from "react/jsx-runtime";
265
+ var Status = (props) => {
266
+ return /* @__PURE__ */ jsx8(React7.Fragment, { children: /* @__PURE__ */ jsx8("span", { className: "capitalize font-semibold rounded text-status text-status-" + props.value, children: props.value }) });
267
+ };
268
+ var StatusView_default = Status;
269
+
270
+ // src/components/controls/view/MoneyView.tsx
271
+ import React8 from "react";
272
+
273
+ // src/components/utilities/CurrencyUtility.tsx
274
+ var CurrencyUtility = class {
275
+ static getCurrencySymbol(currencyCode) {
276
+ switch (currencyCode) {
277
+ case "USD":
278
+ return "$";
279
+ case "INR":
280
+ return "\u20B9";
281
+ case "EUR":
282
+ return "\u20AC";
283
+ // Add more cases for other currency codes as needed
284
+ default:
285
+ return currencyCode;
286
+ }
287
+ }
288
+ };
289
+ var CurrencyUtility_default = CurrencyUtility;
290
+
291
+ // src/components/controls/view/MoneyView.tsx
292
+ import { jsx as jsx9, jsxs } from "react/jsx-runtime";
293
+ var Money = (props) => {
294
+ const parsedNumber = parseFloat(props.value);
295
+ return /* @__PURE__ */ jsx9(React8.Fragment, { children: !Number.isNaN(parsedNumber) && /* @__PURE__ */ jsxs(React8.Fragment, { children: [
296
+ /* @__PURE__ */ jsx9("span", { className: "mr-0.5", children: CurrencyUtility_default.getCurrencySymbol(props.unit) }),
297
+ parsedNumber.toLocaleString()
298
+ ] }) });
299
+ };
300
+ var MoneyView_default = Money;
301
+
302
+ // src/components/controls/view/MultilineTextBulletsView.tsx
303
+ import React9 from "react";
304
+ import { jsx as jsx10 } from "react/jsx-runtime";
305
+ var MultilineTextBullets = (props) => {
306
+ const lines = props.value?.split("\\n");
307
+ return /* @__PURE__ */ jsx10(React9.Fragment, { children: /* @__PURE__ */ jsx10("ul", { className: "list-disc", children: lines && lines.map((line, index) => {
308
+ return /* @__PURE__ */ jsx10("li", { children: line }, index);
309
+ }) }) });
310
+ };
311
+ var MultilineTextBulletsView_default = MultilineTextBullets;
312
+
313
+ // src/components/controls/view/MultilineTextView.tsx
314
+ import React10 from "react";
315
+ import { jsx as jsx11 } from "react/jsx-runtime";
316
+ var MultilineText = (props) => {
317
+ return /* @__PURE__ */ jsx11(React10.Fragment, { children: /* @__PURE__ */ jsx11("span", { className: "whitespace-pre-line", children: props.value }) });
318
+ };
319
+ var MultilineTextView_default = MultilineText;
320
+
321
+ // src/components/controls/view/PercentageView.tsx
322
+ import React11 from "react";
323
+ import { jsxs as jsxs2 } from "react/jsx-runtime";
324
+ var PercentageView = (props) => {
325
+ return /* @__PURE__ */ jsxs2(React11.Fragment, { children: [
326
+ props.value,
327
+ "%"
328
+ ] });
329
+ };
330
+ var PercentageView_default = PercentageView;
331
+
332
+ // src/components/controls/view/ProgressIndicator.tsx
333
+ import React12 from "react";
334
+ import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
335
+ var ProgressIndicator = (props) => {
336
+ const percentage = 100;
337
+ const circumference = Math.PI * 56;
338
+ const offset = circumference * (1 - percentage / 100);
339
+ return /* @__PURE__ */ jsx12(React12.Fragment, { children: /* @__PURE__ */ jsxs3("div", { className: "relative w-48 h-48", children: [
340
+ /* @__PURE__ */ jsx12("div", { className: "absolute top-0 left-0 w-full h-full rounded-full border border-gray-200" }),
341
+ /* @__PURE__ */ jsx12("div", { className: "absolute top-0 left-0 w-full h-full rounded-full overflow-hidden", children: /* @__PURE__ */ jsx12("div", { className: "w-full h-full rounded-full border-t-8 border-green-500", style: { transform: `rotate(-90deg)`, clipPath: `inset(0px ${offset}px 0px 0px)` } }) }),
342
+ /* @__PURE__ */ jsx12("div", { className: "absolute top-0 left-0 w-full h-full flex items-center justify-center text-lg font-bold text-gray-800", children: /* @__PURE__ */ jsxs3("span", { children: [
343
+ percentage,
344
+ "%"
345
+ ] }) })
346
+ ] }) });
347
+ };
348
+ var ProgressIndicator_default = ProgressIndicator;
349
+
350
+ // src/components/controls/view/AiGeneratedSummary.tsx
351
+ import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
352
+ var AiGeneratedSummary = (props) => {
353
+ const lines = props.value?.split("\n").filter((line) => line.trim() !== "") || [];
354
+ return /* @__PURE__ */ jsxs4("details", { className: "group rounded-xl border-2 bg-white shadow-sm border-p overflow-hidden", children: [
355
+ /* @__PURE__ */ jsx13("summary", { className: "flex items-start justify-between cursor-pointer list-none", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-start gap-3 ", children: [
356
+ /* @__PURE__ */ jsx13("div", { className: "bg-primary-base bg-transparent rounded mt-1 p-1", children: /* @__PURE__ */ jsx13("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: "1.5", stroke: "currentColor", className: "w-5", children: /* @__PURE__ */ jsx13("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z" }) }) }),
357
+ /* @__PURE__ */ jsxs4("div", { children: [
358
+ /* @__PURE__ */ jsx13("h3", { className: "text-lg font-semibold ", children: "Quick Read" }),
359
+ /* @__PURE__ */ jsx13("p", { className: "text-sm text-gray-500 mb-0", children: "Summary is AI-generated, author-reviewed" })
360
+ ] })
361
+ ] }) }),
362
+ /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13("ul", { className: "list-disc pl-6 space-y-3 text-gray-700 ps-4 pl-4", children: lines.map((line, index) => /* @__PURE__ */ jsx13("li", { className: "m-0", children: line }, index)) }) })
363
+ ] });
364
+ };
365
+ var AiGeneratedSummary_default = AiGeneratedSummary;
366
+
367
+ // src/components/controls/view/DateTimeVew.tsx
368
+ import dynamic3 from "next/dynamic";
369
+ var DateTimeView = dynamic3(() => import("./DateTimeViewClient-K5FE5VSN.mjs"), {
370
+ ssr: false
371
+ });
372
+ var DateTimeVew_default = DateTimeView;
373
+
374
+ // src/components/controls/view/ViewControl.tsx
375
+ import { jsx as jsx14 } from "react/jsx-runtime";
376
+ var ViewControl = (props) => {
377
+ const ControlComponents = {
378
+ [ViewControlTypes_default.lineText]: LineTextView_default,
379
+ [ViewControlTypes_default.emailText]: EmailTextView_default,
380
+ [ViewControlTypes_default.asset]: Asset_default,
381
+ [ViewControlTypes_default.multilineTextBullets]: MultilineTextBulletsView_default,
382
+ [ViewControlTypes_default.boolean]: BooleanView_default,
383
+ [ViewControlTypes_default.checkboxInput]: BooleanView_default,
384
+ // [ViewControlTypes.timeUntilStarts]: TimeUntilStarts,
385
+ [ViewControlTypes_default.money]: MoneyView_default,
386
+ [ViewControlTypes_default.date]: DateView_default,
387
+ [ViewControlTypes_default.time]: DateView_default,
388
+ [ViewControlTypes_default.datetime]: DateTimeVew_default,
389
+ [ViewControlTypes_default.number]: NumberView_default,
390
+ [ViewControlTypes_default.multilineText]: MultilineTextView_default,
391
+ [ViewControlTypes_default.multilinetext]: MultilineTextView_default,
392
+ [ViewControlTypes_default.moneyText]: MoneyView_default,
393
+ [ViewControlTypes_default.percentage]: PercentageView_default,
394
+ [ViewControlTypes_default.status]: StatusView_default,
395
+ [ViewControlTypes_default.statusBg]: StatusBgView_default,
396
+ [ViewControlTypes_default.progressIndicator]: ProgressIndicator_default,
397
+ // [ViewControlTypes.timeUntilStarts]: TimeUntilStarts,
398
+ // [ViewControlTypes.timeUntilStartsStyled]: TimeUntilStartsStyled,
399
+ [ViewControlTypes_default.aiGeneratedSummary]: AiGeneratedSummary_default,
400
+ [ViewControlTypes_default.booleanView]: BooleanView_default,
401
+ [ViewControlTypes_default.text]: LineTextView_default
402
+ };
403
+ const SelectedControlComponent = props.controlType ? ControlComponents[props.controlType] : void 0;
404
+ return /* @__PURE__ */ jsx14(React13.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ jsx14(SelectedControlComponent, { ...props }) : "Control not found:" + props.controlType });
405
+ };
406
+ var ViewControl_default = ViewControl;
407
+
408
+ // src/components/controls/edit/InputControl.tsx
409
+ import dynamic4 from "next/dynamic";
410
+ var InputControl = dynamic4(() => import("./InputControlClient-BUOYZNWQ.mjs"), {
411
+ ssr: false
412
+ });
413
+ var InputControl_default = InputControl;
414
+
415
+ // src/components/pageRenderingEngine/PageBodyRenderer.tsx
416
+ import React23 from "react";
417
+
418
+ // src/components/pageRenderingEngine/nodes/ParagraphNode.tsx
419
+ import React15 from "react";
420
+
421
+ // src/components/pageRenderingEngine/nodes/TextNode.tsx
422
+ import { jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
423
+ var TextNode = (props) => {
424
+ function cssStringToJson(cssString) {
425
+ const styleObject = {};
426
+ const matches = cssString?.match(/([\w-]+)\s*:\s*([^;]+)\s*;/g);
427
+ if (matches) {
428
+ matches.forEach((match) => {
429
+ const parts = match.match(/([\w-]+)\s*:\s*([^;]+)\s*;/);
430
+ if (parts && parts.length === 3) {
431
+ const property = parts[1].trim();
432
+ const value = parts[2].trim();
433
+ styleObject[property] = value;
434
+ }
435
+ });
436
+ }
437
+ return styleObject;
438
+ }
439
+ function toCamelCase2(str) {
440
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
441
+ }
442
+ function convertKeysToCamelCase2(obj) {
443
+ if (Array.isArray(obj)) {
444
+ return obj.map(convertKeysToCamelCase2);
445
+ } else if (obj !== null && typeof obj === "object") {
446
+ return Object.fromEntries(
447
+ Object.entries(obj).filter(([_, value]) => value !== "").map(([key, value]) => [
448
+ toCamelCase2(key),
449
+ convertKeysToCamelCase2(value)
450
+ ])
451
+ );
452
+ }
453
+ return obj;
454
+ }
455
+ function getFormatClass(format) {
456
+ const classes = [];
457
+ if (format & 1) classes.push("font-medium");
458
+ if (format & 2) classes.push("italic");
459
+ if (format & 4) classes.push("line-through");
460
+ if (format & 8) classes.push("underline");
461
+ if (format & 256) classes.push("lowercase");
462
+ if (format & 512) classes.push("uppercase");
463
+ if (format & 1024) classes.push("capitalize");
464
+ return classes.join(" ");
465
+ }
466
+ const styles = convertKeysToCamelCase2(cssStringToJson(props.node.style));
467
+ function replacePlaceholders(template, dataItem) {
468
+ {
469
+ }
470
+ return template.replace(/{(\w+)}/g, (_, key) => {
471
+ {
472
+ }
473
+ return key in dataItem ? dataItem[key] : `{${key}}`;
474
+ });
475
+ }
476
+ function renderWithLineBreaks(text) {
477
+ return text.split("\n").map((line, index, arr) => /* @__PURE__ */ jsxs5("span", { children: [
478
+ line,
479
+ index < arr.length - 1 && /* @__PURE__ */ jsx15("br", {})
480
+ ] }, index));
481
+ }
482
+ const displayText = props.linkText ? props.linkText : props.node.text;
483
+ const finalText = props.dataitem && props.linkText ? displayText : props.dataitem ? replacePlaceholders(props.node.text, props.dataitem) : props.node.text;
484
+ const content = typeof finalText === "string" ? renderWithLineBreaks(finalText) : finalText;
485
+ const formattedContent = props.node.format & 64 ? /* @__PURE__ */ jsx15("sup", { children: content }) : props.node.format & 32 ? /* @__PURE__ */ jsx15("sub", { children: content }) : content;
486
+ return (
487
+ // @ts-expect-error custom code
488
+ /* @__PURE__ */ jsx15("span", { style: { ...styles }, className: getFormatClass(props.node.format), children: formattedContent })
489
+ );
490
+ };
491
+ var TextNode_default = TextNode;
492
+
493
+ // src/components/pageRenderingEngine/nodes/LineBreakNode.tsx
494
+ import { jsx as jsx16 } from "react/jsx-runtime";
495
+ var LineBreakNode = () => {
496
+ return /* @__PURE__ */ jsx16("div", { className: "py-0.5 lg:py-1.5" });
497
+ };
498
+ var LineBreakNode_default = LineBreakNode;
499
+
500
+ // src/components/pageRenderingEngine/nodes/LinkNode.tsx
501
+ import React14 from "react";
502
+
503
+ // src/components/pageRenderingEngine/nodes/ImageNode.tsx
504
+ import dynamic5 from "next/dynamic";
505
+ import { jsx as jsx17 } from "react/jsx-runtime";
506
+ var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-57543DTW.mjs"), { ssr: false });
507
+ var getNestedValue = (obj, path) => {
508
+ if (!obj || !path) return void 0;
509
+ return path.split(".").reduce((current, key) => {
510
+ return current && current[key] !== void 0 ? current[key] : void 0;
511
+ }, obj);
512
+ };
513
+ var ImageNode = (props) => {
514
+ let assets;
515
+ let imageUrl;
516
+ let posterUrl;
517
+ const currentDevice = props.device;
518
+ if (props.node.device) {
519
+ const nodeDevice = props.node.device;
520
+ if (nodeDevice !== currentDevice) return null;
521
+ }
522
+ if (props.node.imageUrl.startsWith("http")) {
523
+ imageUrl = props.node.imageUrl;
524
+ posterUrl = AssetUtility_default.resolveUrl(props.assetBaseUrl, props.node.posterUrl);
525
+ } else if (props.dataitem && props.node.datafield) {
526
+ const image = getNestedValue(props.dataitem, props.node.datafield);
527
+ if (typeof image === "string") {
528
+ const trimmed = image.trim();
529
+ if (trimmed) {
530
+ assets = JSON.parse(trimmed);
531
+ }
532
+ } else if (Array.isArray(image)) {
533
+ assets = image;
534
+ } else if (image && typeof image === "object") {
535
+ assets = [image];
536
+ }
537
+ if (assets && assets.length > 0) {
538
+ return /* @__PURE__ */ jsx17(
539
+ DeviceAssetSelector_default,
540
+ {
541
+ device: props.device,
542
+ assets,
543
+ assetBaseUrl: props.assetBaseUrl,
544
+ session: props.session,
545
+ nodeProps: {
546
+ title: props.node.title,
547
+ showControls: props.node.showControls,
548
+ loop: props.node.loop,
549
+ playOptions: props.node.playOptions,
550
+ borderRadius: props.node.borderRadius,
551
+ width: props.node.width,
552
+ height: props.node.height,
553
+ format: props.node.format,
554
+ tag: props.node.tag,
555
+ placementCode: props.node.placementCode
556
+ }
557
+ }
558
+ );
559
+ } else {
560
+ imageUrl = AssetUtility_default.resolveUrl(props.assetBaseUrl, props.node.imageUrl);
561
+ posterUrl = AssetUtility_default.resolveUrl(props.assetBaseUrl, props.node.posterUrl);
562
+ }
563
+ } else {
564
+ imageUrl = AssetUtility_default.resolveUrl(props.assetBaseUrl, props.node.imageUrl);
565
+ posterUrl = AssetUtility_default.resolveUrl(props.assetBaseUrl, props.node.posterUrl);
566
+ }
567
+ if (!imageUrl) return null;
568
+ const styles = {
569
+ ...props.node.height && { height: props.node.height },
570
+ ...props.node.borderRadius && { borderRadius: props.node.borderRadius },
571
+ ...props.node.width && { width: props.node.width }
572
+ };
573
+ const FORMAT_CLASSES2 = {
574
+ center: "justify-center",
575
+ left: "justify-start",
576
+ right: "justify-end"
577
+ };
578
+ const isHls = imageUrl.endsWith(".m3u8");
579
+ const renderMedia = () => isHls ? /* @__PURE__ */ jsx17(
580
+ HlsPlayer2,
581
+ {
582
+ assetUrl: imageUrl,
583
+ posterUrl,
584
+ intrinsicWidth: props.node.intrinsicWidth,
585
+ intrinsicHeight: props.node.intrinsicHeight,
586
+ showControls: props.node.showControls === "true",
587
+ loop: props.node.loop === "true",
588
+ playOptions: props.node.playOptions,
589
+ apiBaseUrl: props.apiBaseUrl,
590
+ session: props.session
591
+ }
592
+ ) : /* @__PURE__ */ jsx17(
593
+ "img",
594
+ {
595
+ style: styles,
596
+ loading: "lazy",
597
+ className: "object-cover",
598
+ src: imageUrl,
599
+ width: props.node.intrinsicWidth,
600
+ alt: props.node.title,
601
+ height: props.node.intrinsicHeight
602
+ }
603
+ );
604
+ if (props.node.width) {
605
+ return /* @__PURE__ */ jsx17("div", { className: `flex ${FORMAT_CLASSES2[props.node.format] ?? ""}`, children: renderMedia() });
606
+ }
607
+ return renderMedia();
608
+ };
609
+ var ImageNode_default = ImageNode;
610
+
611
+ // src/components/pageRenderingEngine/nodes/LinkNode.tsx
612
+ import dynamic6 from "next/dynamic";
613
+ import { Fragment, jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
614
+ var LinkNodeButton = dynamic6(() => import("./LinkNodeButton-BIZA2NPE.mjs"), {
615
+ ssr: false
616
+ });
617
+ function getNestedValue2(obj, path) {
618
+ if (!obj || !path) return void 0;
619
+ return path.split(".").reduce((current, key) => {
620
+ return current && current[key] !== void 0 ? current[key] : void 0;
621
+ }, obj);
622
+ }
623
+ var LinkNode = (props) => {
624
+ const NodeTypes2 = {
625
+ text: TextNode_default,
626
+ image: ImageNode_default
627
+ };
628
+ const { node, dataitem } = props;
629
+ let linkUrl = node.url;
630
+ if (node.datafield_link_url && dataitem) {
631
+ const dynamicUrl = getNestedValue2(dataitem, node.datafield_link_url);
632
+ if (dynamicUrl && typeof dynamicUrl === "string") {
633
+ linkUrl = dynamicUrl;
634
+ }
635
+ }
636
+ if (props.routeParameters && linkUrl && linkUrl.includes("{")) {
637
+ Object.keys(props.routeParameters).forEach((param) => {
638
+ const value = props.routeParameters[param];
639
+ if (value !== void 0 && value !== null) {
640
+ linkUrl = linkUrl.replace(
641
+ new RegExp(`\\{${param}\\}`, "gi"),
642
+ encodeURIComponent(String(value))
643
+ );
644
+ }
645
+ });
646
+ }
647
+ let linkText = null;
648
+ if (node.datafield_link_text && dataitem) {
649
+ const dynamicText = dataitem[node.datafield_link_text];
650
+ if (dynamicText && typeof dynamicText === "string") {
651
+ linkText = dynamicText;
652
+ }
653
+ }
654
+ const getLinkTypeFromCssClass = (cssClass) => {
655
+ const classToTypeMap = {
656
+ Primary: "Primary" /* Solid */,
657
+ PrimaryHollow: "PrimaryHollow" /* Hollow */,
658
+ Link: "Link" /* Link */
659
+ };
660
+ return classToTypeMap[cssClass];
661
+ };
662
+ const linkType = node.cssClass ? getLinkTypeFromCssClass(node.cssClass) : void 0;
663
+ const isButton = node.isButton === true;
664
+ const renderChildren = () => {
665
+ if (!node.children || node.children.length === 0) return null;
666
+ return /* @__PURE__ */ jsx18(Fragment, { children: node.children.map((childNode, index) => {
667
+ const SelectedNode = NodeTypes2[childNode.type];
668
+ if (!SelectedNode) {
669
+ console.warn("Unknown node type:", childNode.type);
670
+ return null;
671
+ }
672
+ return /* @__PURE__ */ jsx18(React14.Fragment, { children: /* @__PURE__ */ jsx18(
673
+ SelectedNode,
674
+ {
675
+ node: childNode,
676
+ dataitem,
677
+ linkText,
678
+ routeParameters: props.routeParameters
679
+ }
680
+ ) }, index);
681
+ }) });
682
+ };
683
+ const renderFallback = () => {
684
+ if ((!node.children || node.children.length === 0) && linkText) {
685
+ return /* @__PURE__ */ jsx18("span", { children: linkText });
686
+ }
687
+ if ((!node.children || node.children.length === 0) && !linkText) {
688
+ return /* @__PURE__ */ jsx18("br", {});
689
+ }
690
+ return null;
691
+ };
692
+ if (isButton) {
693
+ return /* @__PURE__ */ jsxs6(
694
+ LinkNodeButton,
695
+ {
696
+ node,
697
+ dataitem,
698
+ routeParameters: props.routeParameters,
699
+ session: props.session,
700
+ apiBaseUrl: props.apiBaseUrl || "",
701
+ linkText,
702
+ linkType,
703
+ linkUrl,
704
+ children: [
705
+ renderChildren(),
706
+ renderFallback()
707
+ ]
708
+ }
709
+ );
710
+ }
711
+ return /* @__PURE__ */ jsxs6(
712
+ Hyperlink,
713
+ {
714
+ href: linkUrl || "#",
715
+ linkType,
716
+ alt: linkText || node.title || "",
717
+ children: [
718
+ renderChildren(),
719
+ renderFallback()
720
+ ]
721
+ }
722
+ );
723
+ };
724
+ var LinkNode_default = LinkNode;
725
+
726
+ // src/components/pageRenderingEngine/nodes/SVGIconNode.tsx
727
+ import { jsx as jsx19 } from "react/jsx-runtime";
728
+ var SVGIconNode = ({ node }) => {
729
+ if (!node?.svgCode) return null;
730
+ return /* @__PURE__ */ jsx19(
731
+ "span",
732
+ {
733
+ style: {
734
+ display: "flex",
735
+ width: node.width,
736
+ height: node.height,
737
+ color: node.color
738
+ },
739
+ dangerouslySetInnerHTML: { __html: node.svgCode }
740
+ }
741
+ );
742
+ };
743
+ var SVGIconNode_default = SVGIconNode;
744
+
745
+ // src/components/pageRenderingEngine/nodes/EquationNode.tsx
746
+ import katex from "katex";
747
+ import { jsx as jsx20 } from "react/jsx-runtime";
748
+ var EquationNode = ({ node }) => {
749
+ const { equation, inline } = node;
750
+ let html = "";
751
+ try {
752
+ html = katex.renderToString(equation, {
753
+ displayMode: !inline,
754
+ throwOnError: false
755
+ });
756
+ } catch (error) {
757
+ html = katex.renderToString(`\\text{Invalid equation}`, {
758
+ throwOnError: false
759
+ });
760
+ }
761
+ if (inline) {
762
+ return /* @__PURE__ */ jsx20(
763
+ "span",
764
+ {
765
+ className: "katex-inline",
766
+ dangerouslySetInnerHTML: { __html: html }
767
+ }
768
+ );
769
+ }
770
+ return /* @__PURE__ */ jsx20(
771
+ "div",
772
+ {
773
+ className: "katex-block my-3 text-center",
774
+ dangerouslySetInnerHTML: { __html: html }
775
+ }
776
+ );
777
+ };
778
+ var EquationNode_default = EquationNode;
779
+
780
+ // src/components/pageRenderingEngine/nodes/DatafieldNode.tsx
781
+ import { jsx as jsx21 } from "react/jsx-runtime";
782
+ function getNestedProperty(obj, path) {
783
+ if (!obj || !path) return null;
784
+ if (path.includes(".")) {
785
+ return path.split(".").reduce((prev, curr) => {
786
+ if (prev && typeof prev === "object") {
787
+ return prev[curr];
788
+ }
789
+ return null;
790
+ }, obj);
791
+ }
792
+ const value = obj[path];
793
+ if (Array.isArray(value)) {
794
+ return value.map((item, index) => /* @__PURE__ */ jsx21("div", { children: String(item) }, index));
795
+ }
796
+ return value;
797
+ }
798
+ var DatafieldNode = (props) => {
799
+ function cssStringToJson(cssString) {
800
+ const styleObject = {};
801
+ const matches = cssString?.match(/([\w-]+)\s*:\s*([^;]+)\s*;/g);
802
+ if (matches) {
803
+ matches.forEach((match) => {
804
+ const parts = match.match(/([\w-]+)\s*:\s*([^;]+)\s*;/);
805
+ if (parts && parts.length === 3) {
806
+ styleObject[parts[1].trim()] = parts[2].trim();
807
+ }
808
+ });
809
+ }
810
+ return styleObject;
811
+ }
812
+ function toCamelCase2(str) {
813
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
814
+ }
815
+ function convertKeysToCamelCase2(obj) {
816
+ return Object.fromEntries(
817
+ Object.entries(obj).map(([key, value2]) => [
818
+ toCamelCase2(key),
819
+ value2
820
+ ])
821
+ );
822
+ }
823
+ const Formats = [
824
+ "",
825
+ "font-medium",
826
+ "italic",
827
+ "font-medium italic",
828
+ "",
829
+ "",
830
+ "",
831
+ "",
832
+ "underline",
833
+ "font-medium underline",
834
+ "italic underline",
835
+ "italic underline font-medium"
836
+ ];
837
+ const styles = convertKeysToCamelCase2(
838
+ cssStringToJson(props.node.style)
839
+ );
840
+ const fieldName = props.node.fieldName ?? "";
841
+ const value = props.dataitem ? getNestedProperty(props.dataitem, fieldName) : null;
842
+ const isEmptyValue = value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0 || typeof value === "object" && value !== null && Object.keys(value).length === 0;
843
+ const maxLines = props.node.maxLines;
844
+ if (maxLines && Number(maxLines) > 0) {
845
+ Object.assign(styles, {
846
+ display: "-webkit-box",
847
+ overflow: "hidden",
848
+ WebkitBoxOrient: "vertical",
849
+ WebkitLineClamp: String(maxLines)
850
+ });
851
+ }
852
+ const dataType = props.node.dataType;
853
+ if (isEmptyValue) return null;
854
+ if (dataType === "rawContent") {
855
+ return /* @__PURE__ */ jsx21(
856
+ PageBodyRenderer_default,
857
+ {
858
+ rawBody: String(value ?? `@databound[${fieldName}]`),
859
+ routeParameters: props.routeParameters,
860
+ query: props.query,
861
+ session: props.session,
862
+ host: props.host,
863
+ path: props.path,
864
+ apiBaseUrl: props.apiBaseUrl,
865
+ breadcrumb: props.breadcrumb,
866
+ donotApplyContainerClass: true,
867
+ widgetRenderer: props.widgetRenderer
868
+ }
869
+ );
870
+ }
871
+ return /* @__PURE__ */ jsx21(
872
+ "span",
873
+ {
874
+ className: `datafield-node ${props.node.format < Formats.length ? Formats[props.node.format] : ""}`,
875
+ style: styles,
876
+ children: /* @__PURE__ */ jsx21(
877
+ ViewControl_default,
878
+ {
879
+ controlType: dataType,
880
+ value: value ?? `@databound[${fieldName}]`
881
+ }
882
+ )
883
+ }
884
+ );
885
+ };
886
+ var DatafieldNode_default = DatafieldNode;
887
+
888
+ // src/components/pageRenderingEngine/nodes/ParagraphNode.tsx
889
+ import { Fragment as Fragment2, jsx as jsx22, jsxs as jsxs7 } from "react/jsx-runtime";
890
+ var ParagraphNode = (props) => {
891
+ const NodeTypes2 = {
892
+ ["text"]: TextNode_default,
893
+ ["linebreak"]: LineBreakNode_default,
894
+ ["link"]: LinkNode_default,
895
+ ["datafield"]: DatafieldNode_default,
896
+ ["equation"]: EquationNode_default,
897
+ ["svg-icon"]: SVGIconNode_default
898
+ };
899
+ const FormatClass = {
900
+ "center": "text-center",
901
+ "right": "text-right"
902
+ };
903
+ {
904
+ }
905
+ const formatClasses = FormatClass[props.node.format] || "";
906
+ const isInlineOnlyParent = props.parentTag === "summary";
907
+ const hasChildren = props.node.children && props.node.children.length > 0;
908
+ if (isInlineOnlyParent) {
909
+ return /* @__PURE__ */ jsx22(Fragment2, { children: hasChildren && props.node.children.map((node, index) => {
910
+ const SelectedNode = NodeTypes2[node.type];
911
+ return /* @__PURE__ */ jsx22(React15.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx22(
912
+ SelectedNode,
913
+ {
914
+ node,
915
+ dataitem: props.dataitem,
916
+ session: props.session,
917
+ apiBaseUrl: props.apiBaseUrl,
918
+ routeParameters: props.routeParameters
919
+ }
920
+ ) }, index);
921
+ }) });
922
+ }
923
+ return /* @__PURE__ */ jsxs7("div", { className: " " + formatClasses, children: [
924
+ hasChildren && props.node.children.map((node, index) => {
925
+ const SelectedNode = NodeTypes2[node.type];
926
+ return /* @__PURE__ */ jsx22(React15.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx22(
927
+ SelectedNode,
928
+ {
929
+ node,
930
+ dataitem: props.dataitem,
931
+ session: props.session,
932
+ apiBaseUrl: props.apiBaseUrl,
933
+ routeParameters: props.routeParameters
934
+ }
935
+ ) }, index);
936
+ }),
937
+ !hasChildren && /* @__PURE__ */ jsx22("div", { className: "py-1.5 lg:py-2" })
938
+ ] });
939
+ };
940
+ var ParagraphNode_default = ParagraphNode;
941
+
942
+ // src/components/pageRenderingEngine/nodes/HeadingNode.tsx
943
+ import React16 from "react";
944
+ import { Fragment as Fragment3, jsx as jsx23 } from "react/jsx-runtime";
945
+ var HeadingNode = (props) => {
946
+ const NodeTypes2 = {
947
+ ["text"]: TextNode_default,
948
+ ["link"]: LinkNode_default,
949
+ ["svg-icon"]: SVGIconNode_default,
950
+ ["linebreak"]: LineBreakNode_default,
951
+ ["datafield"]: DatafieldNode_default
952
+ };
953
+ const HeadingTag = `${props.node.tag}`;
954
+ const FormatClass = {
955
+ "center": "text-center"
956
+ };
957
+ {
958
+ }
959
+ const formatClasses = FormatClass[props.node.format] || "";
960
+ return /* @__PURE__ */ jsx23(Fragment3, { children: React16.createElement(
961
+ HeadingTag,
962
+ { className: formatClasses },
963
+ props.node.children && props.node.children.map((childNode, index) => {
964
+ const SelectedNode = NodeTypes2[childNode.type];
965
+ return /* @__PURE__ */ jsx23(React16.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx23(SelectedNode, { node: childNode, dataitem: props.dataitem, session: props.session, apiBaseUrl: props.apiBaseUrl, routeParameters: props.routeParameters }) }, index);
966
+ })
967
+ ) });
968
+ };
969
+ var HeadingNode_default = HeadingNode;
970
+
971
+ // src/components/pageRenderingEngine/nodes/ListNode.tsx
972
+ import React18 from "react";
973
+
974
+ // src/components/pageRenderingEngine/nodes/ListItemNode.tsx
975
+ import React17 from "react";
976
+ import { jsx as jsx24 } from "react/jsx-runtime";
977
+ var ListItemNode = (props) => {
978
+ const NodeTypes2 = {
979
+ text: TextNode_default,
980
+ linebreak: LineBreakNode_default,
981
+ link: LinkNode_default,
982
+ list: ListNode_default
983
+ };
984
+ let foundFirstBreak = false;
985
+ const firstTextChild = props.node.children?.find((c) => c.type === "text");
986
+ let liStyle = {};
987
+ if (firstTextChild?.style) {
988
+ const match = firstTextChild.style.match(/font-size\s*:\s*([^;]+);?/);
989
+ if (match) {
990
+ liStyle.fontSize = match[1].trim();
991
+ }
992
+ }
993
+ return /* @__PURE__ */ jsx24("li", { style: liStyle, children: props.node.children && props.node.children.map((node, index) => {
994
+ const SelectedNode = NodeTypes2[node.type];
995
+ if (node.type === "linebreak") {
996
+ if (!foundFirstBreak) {
997
+ foundFirstBreak = true;
998
+ return /* @__PURE__ */ jsx24("div", {}, index);
999
+ } else {
1000
+ return /* @__PURE__ */ jsx24("div", { className: "py-1 lg:py-2" }, index);
1001
+ }
1002
+ } else {
1003
+ foundFirstBreak = false;
1004
+ return /* @__PURE__ */ jsx24(React17.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx24(SelectedNode, { node, dataitem: props.dataitem, routeParameters: props.routeParameters }) }, index);
1005
+ }
1006
+ }) });
1007
+ };
1008
+ var ListItemNode_default = ListItemNode;
1009
+
1010
+ // src/components/pageRenderingEngine/nodes/ListNode.tsx
1011
+ import { jsx as jsx25, jsxs as jsxs8 } from "react/jsx-runtime";
1012
+ var ListNode = (props) => {
1013
+ const NodeTypes2 = {
1014
+ listitem: ListItemNode_default
1015
+ };
1016
+ return /* @__PURE__ */ jsxs8(React18.Fragment, { children: [
1017
+ props.node.listType == "bullet" && /* @__PURE__ */ jsx25("ul", { children: props.node.children && props.node.children.map((node, index) => {
1018
+ const SelectedNode = NodeTypes2[node.type];
1019
+ return /* @__PURE__ */ jsx25(React18.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx25(SelectedNode, { node, dataitem: props.dataitem, routeParameters: props.routeParameters }) }, index);
1020
+ }) }),
1021
+ props.node.listType == "number" && /* @__PURE__ */ jsx25("ol", { children: props.node.children && props.node.children.map((node, index) => {
1022
+ const SelectedNode = NodeTypes2[node.type];
1023
+ return /* @__PURE__ */ jsx25(React18.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx25(SelectedNode, { node, dataitem: props.dataitem, routeParameters: props.routeParameters }) }, index);
1024
+ }) })
1025
+ ] });
1026
+ };
1027
+ var ListNode_default = ListNode;
1028
+
1029
+ // src/components/pageRenderingEngine/nodes/QuoteNode.tsx
1030
+ import React19 from "react";
1031
+ import { jsx as jsx26 } from "react/jsx-runtime";
1032
+ var QuoteNode = (props) => {
1033
+ const NodeTypes2 = {
1034
+ ["text"]: TextNode_default,
1035
+ ["linebreak"]: LineBreakNode_default,
1036
+ ["link"]: LinkNode_default
1037
+ };
1038
+ return /* @__PURE__ */ jsx26("blockquote", { children: props.node.children && props.node.children.map((node, index) => {
1039
+ const SelectedNode = NodeTypes2[node.type];
1040
+ return /* @__PURE__ */ jsx26(React19.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx26(SelectedNode, { node, session: props.session, apiBaseUrl: props.apiBaseUrl, routeParameters: props.routeParameters }) }, index);
1041
+ }) });
1042
+ };
1043
+ var QuoteNode_default = QuoteNode;
1044
+
1045
+ // src/components/pageRenderingEngine/nodes/CodeNode.tsx
1046
+ import React20 from "react";
1047
+ import dynamic7 from "next/dynamic";
1048
+ import { jsx as jsx27, jsxs as jsxs9 } from "react/jsx-runtime";
1049
+ var CopyButton = dynamic7(() => import("./CopyButton-XONTQQW7.mjs"), {
1050
+ ssr: false,
1051
+ // optional: fallback UI while loading
1052
+ loading: () => /* @__PURE__ */ jsx27("span", { className: "text-gray-400 text-xs", children: "Copy" })
1053
+ });
1054
+ var CodeNode = (props) => {
1055
+ const NodeTypes2 = {
1056
+ text: TextNode_default,
1057
+ linebreak: LineBreakNode_default,
1058
+ link: LinkNode_default
1059
+ };
1060
+ const textContent = props.node?.children?.map((node) => {
1061
+ if (node.type === "text") return node.text || "";
1062
+ if (node.type === "linebreak") return "\n";
1063
+ if (node.type === "link") return node.text || node.url || "";
1064
+ return "";
1065
+ }).join("") ?? "";
1066
+ return /* @__PURE__ */ jsxs9("div", { children: [
1067
+ /* @__PURE__ */ jsxs9("div", { className: "flex items-center relative bg-neutral-strong px-4 py-3 text-xs font-sans justify-between rounded-t-md ", children: [
1068
+ /* @__PURE__ */ jsx27("span", { children: "Code Snippet" }),
1069
+ /* @__PURE__ */ jsx27(CopyButton, { text: textContent })
1070
+ ] }),
1071
+ /* @__PURE__ */ jsx27("code", { className: "bg-neutral-soft p-4 text-sm whitespace-pre-wrap border border-2 block", children: props.node.children && props.node.children.map((node, index) => {
1072
+ const SelectedNode = NodeTypes2[node.type];
1073
+ return /* @__PURE__ */ jsx27(React20.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx27(
1074
+ SelectedNode,
1075
+ {
1076
+ node,
1077
+ session: props.session,
1078
+ apiBaseUrl: props.apiBaseUrl,
1079
+ routeParameters: props.routeParameters
1080
+ }
1081
+ ) }, index);
1082
+ }) })
1083
+ ] });
1084
+ };
1085
+ var CodeNode_default = CodeNode;
1086
+
1087
+ // src/components/pageRenderingEngine/nodes/HorizontalRuleNode.tsx
1088
+ import { jsx as jsx28 } from "react/jsx-runtime";
1089
+ var HorizontalRuleNode = () => {
1090
+ return /* @__PURE__ */ jsx28("hr", {});
1091
+ };
1092
+ var HorizontalRuleNode_default = HorizontalRuleNode;
1093
+
1094
+ // src/components/pageRenderingEngine/nodes/WidgetNode.tsx
1095
+ import React21 from "react";
1096
+ import { Fragment as Fragment4, jsx as jsx29 } from "react/jsx-runtime";
1097
+ var WidgetNode = (props) => {
1098
+ const getWidgetParameters = () => {
1099
+ const widgetInputParameters = {
1100
+ ...props.routeParameters ?? {}
1101
+ };
1102
+ const rawWidgetParams = props.node.widgetParameters ?? props.node.widgetParams;
1103
+ let widgetParameters = {};
1104
+ const isJSON = (str) => {
1105
+ const s = str.trim();
1106
+ return s.startsWith("{") && s.endsWith("}") || s.startsWith("[") && s.endsWith("]");
1107
+ };
1108
+ if (rawWidgetParams) {
1109
+ if (typeof rawWidgetParams === "string" && isJSON(rawWidgetParams)) {
1110
+ try {
1111
+ widgetParameters = JSON.parse(rawWidgetParams);
1112
+ } catch {
1113
+ widgetParameters = {};
1114
+ }
1115
+ } else if (typeof rawWidgetParams === "object") {
1116
+ widgetParameters = rawWidgetParams;
1117
+ }
1118
+ }
1119
+ if (props.dataitem && typeof props.dataitem === "object") {
1120
+ Object.keys(widgetParameters).forEach((key) => {
1121
+ if (props.dataitem[key] !== void 0 && props.dataitem[key] !== null) {
1122
+ widgetParameters[key] = props.dataitem[key];
1123
+ }
1124
+ });
1125
+ }
1126
+ const resolveValue = (val) => {
1127
+ if (typeof val === "string") {
1128
+ const m = /^\{(.+)\}$/.exec(val);
1129
+ if (m) {
1130
+ const actualKey = m[1];
1131
+ return props.routeParameters?.[actualKey] ?? val;
1132
+ }
1133
+ return val;
1134
+ }
1135
+ if (Array.isArray(val)) {
1136
+ return val.map(resolveValue);
1137
+ }
1138
+ if (val && typeof val === "object") {
1139
+ const out = {};
1140
+ for (const k of Object.keys(val)) {
1141
+ out[k] = resolveValue(val[k]);
1142
+ }
1143
+ return out;
1144
+ }
1145
+ return val;
1146
+ };
1147
+ for (const key of Object.keys(widgetParameters)) {
1148
+ const rawVal = widgetParameters[key];
1149
+ if (rawVal === "route") {
1150
+ widgetInputParameters[key] = key === "itemPath" ? props.path : widgetInputParameters[key] ?? null;
1151
+ } else {
1152
+ widgetInputParameters[key] = resolveValue(rawVal);
1153
+ }
1154
+ }
1155
+ widgetInputParameters["widgetTitle"] = props.node.widgetTitle;
1156
+ return widgetInputParameters;
1157
+ };
1158
+ const widgetCode = props.node?.widgetCode;
1159
+ if (!widgetCode) {
1160
+ return /* @__PURE__ */ jsx29(Fragment4, { children: "Invalid widget" });
1161
+ }
1162
+ const widgetParams = getWidgetParameters();
1163
+ const WidgetRenderer = props.widgetRenderer;
1164
+ if (!WidgetRenderer) {
1165
+ return null;
1166
+ }
1167
+ return (
1168
+ // eslint-disable-next-line react-hooks/static-components
1169
+ /* @__PURE__ */ jsx29(React21.Fragment, { children: /* @__PURE__ */ jsx29(
1170
+ WidgetRenderer,
1171
+ {
1172
+ params: widgetParams,
1173
+ query: props.query,
1174
+ session: props.session,
1175
+ host: props.host,
1176
+ path: props.path,
1177
+ apiBaseUrl: props.apiBaseUrl,
1178
+ widgetCode
1179
+ }
1180
+ ) })
1181
+ );
1182
+ };
1183
+ var WidgetNode_default = WidgetNode;
1184
+
1185
+ // src/components/pageRenderingEngine/nodes/DivContainer.tsx
1186
+ import dynamic10 from "next/dynamic";
1187
+ import React22 from "react";
1188
+
1189
+ // src/components/pageRenderingEngine/nodes/EmbedNode.tsx
1190
+ import dynamic8 from "next/dynamic";
1191
+ import { jsx as jsx30 } from "react/jsx-runtime";
1192
+ var IframeClient = dynamic8(() => import("./IframeClient-J22NMEVY.mjs"), {
1193
+ ssr: false
1194
+ });
1195
+ var EmbedNode = (props) => {
1196
+ let src;
1197
+ if (props.node.provider == "youtube") {
1198
+ src = `https://www.youtube-nocookie.com/embed/${props.node.embedSrc}`;
1199
+ } else if (props.node.provider == "bunny") {
1200
+ src = `https://iframe.mediadelivery.net/embed/${props.node.embedSrc}?autoplay=false&loop=false&muted=false&preload=true&responsive=true`;
1201
+ } else {
1202
+ src = props.node.embedSrc;
1203
+ }
1204
+ return /* @__PURE__ */ jsx30("div", { className: "aspect-video", children: src && /* @__PURE__ */ jsx30(IframeClient, { src }) });
1205
+ };
1206
+ var EmbedNode_default = EmbedNode;
1207
+
1208
+ // src/components/utilities/AnimationUtility.tsx
1209
+ var normalizeSelector = (guid) => {
1210
+ const trimmedGuid = guid?.trim();
1211
+ if (!trimmedGuid) {
1212
+ return ".animation-fallback";
1213
+ }
1214
+ const baseValue = trimmedGuid.replace(/^#/, "").replace(/^\./, "");
1215
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
1216
+ return `#${CSS.escape(baseValue)}`;
1217
+ }
1218
+ return `#${baseValue}`;
1219
+ };
1220
+ var AnimationUtility = class {
1221
+ static generateAnimationCSS(config, guid) {
1222
+ const {
1223
+ duration = 700,
1224
+ delay = 0,
1225
+ easing = "ease-out",
1226
+ distance = 30,
1227
+ scaleStart = 1,
1228
+ scaleEnd = 1.2,
1229
+ repeat = 1,
1230
+ intensity = 20,
1231
+ speedPerChar = 100,
1232
+ cursor = true,
1233
+ mode = "enter",
1234
+ direction = "left",
1235
+ backgroundColor,
1236
+ borderColor
1237
+ } = config;
1238
+ let base = "", visible = "", keyframes = "";
1239
+ const selector = normalizeSelector(guid);
1240
+ switch (config.animation) {
1241
+ case "Fade":
1242
+ base = `opacity:0; transition:opacity ${duration}ms ${easing} ${delay}ms;`;
1243
+ visible = `opacity:1;`;
1244
+ break;
1245
+ case "FadeInUp":
1246
+ base = `opacity:0; transform:translateY(${distance}px); transition:all ${duration}ms ${easing} ${delay}ms;`;
1247
+ visible = `opacity:1; transform:translateY(0);`;
1248
+ break;
1249
+ case "Slide":
1250
+ const slideTransform = this.getSlideTransform(direction, distance);
1251
+ base = `opacity:0; transform:${slideTransform.start}; transition:all ${duration}ms ${easing} ${delay}ms; will-change: transform, opacity;`;
1252
+ visible = `opacity:1; transform:${slideTransform.end}; will-change: unset;`;
1253
+ break;
1254
+ case "ZoomIn":
1255
+ if (mode === "enter") {
1256
+ base = `opacity:0; transform:scale(${scaleStart}); transition:all ${duration}ms ${easing} ${delay}ms;`;
1257
+ visible = `opacity:1; transform:scale(${scaleEnd});`;
1258
+ } else {
1259
+ base = `transform:scale(${scaleStart}); transition:transform ${duration / 1e3}s ${easing} ${delay / 1e3}s;`;
1260
+ visible = `transform:scale(${scaleEnd});`;
1261
+ }
1262
+ break;
1263
+ case "Bounce":
1264
+ keyframes = `
1265
+ @keyframes bounce {
1266
+ 0%,20%,50%,80%,100% { transform: translateY(0); }
1267
+ 40% { transform: translateY(-${intensity}px); }
1268
+ 60% { transform: translateY(-${intensity / 2}px); }
1269
+ }
1270
+ `;
1271
+ if (mode === "enter") {
1272
+ base = `opacity:0;`;
1273
+ visible = `opacity:1; animation: bounce ${duration}ms ${easing} ${delay}ms ${repeat};`;
1274
+ } else {
1275
+ base = ``;
1276
+ visible = `animation: bounce ${duration / 1e3}s ${easing} ${delay / 1e3}s ${repeat};`;
1277
+ }
1278
+ break;
1279
+ case "Background":
1280
+ base = `transition: background-color ${duration}ms ${easing} ${delay}ms;`;
1281
+ visible = `background-color: ${backgroundColor};`;
1282
+ break;
1283
+ case "Border":
1284
+ base = `transition: border-color ${duration}ms ${easing} ${delay}ms;`;
1285
+ visible = `border-color: ${borderColor};`;
1286
+ break;
1287
+ case "Typewriter":
1288
+ keyframes = `
1289
+ @keyframes typewriter { from { width: 0 } to { width: 100% } }
1290
+ @keyframes blink { 50% { border-color: transparent } }
1291
+ `;
1292
+ base = `
1293
+ overflow:hidden;
1294
+ border-right:${cursor ? "2px solid black" : "none"};
1295
+ white-space:nowrap;
1296
+ width:0;
1297
+ margin:0 auto;
1298
+ `;
1299
+ visible = `
1300
+ animation:typewriter ${speedPerChar * 30}ms steps(30,end) ${delay}ms forwards
1301
+ ${cursor ? ", blink .75s step-end infinite" : ""};
1302
+ `;
1303
+ break;
1304
+ }
1305
+ if (mode === "hover") {
1306
+ return `
1307
+ ${keyframes}
1308
+ ${selector} { ${base} }
1309
+ ${selector}:hover { ${visible} }
1310
+ `;
1311
+ } else {
1312
+ return `
1313
+ ${keyframes}
1314
+ ${selector} { ${base} }
1315
+ ${selector}.visible { ${visible} }
1316
+ `;
1317
+ }
1318
+ }
1319
+ // Helper method to generate slide transforms based on direction
1320
+ static getSlideTransform(direction, distance) {
1321
+ switch (direction) {
1322
+ case "left":
1323
+ return { start: `translateX(${distance}px)`, end: `translateX(0)` };
1324
+ case "right":
1325
+ return { start: `translateX(-${distance}px)`, end: `translateX(0)` };
1326
+ case "up":
1327
+ return { start: `translateY(${distance}px)`, end: `translateY(0)` };
1328
+ case "down":
1329
+ return { start: `translateY(-${distance}px)`, end: `translateY(0)` };
1330
+ default:
1331
+ return { start: `translateX(${distance}px)`, end: `translateX(0)` };
1332
+ }
1333
+ }
1334
+ };
1335
+ var AnimationUtility_default = AnimationUtility;
1336
+
1337
+ // src/components/utilities/PathUtility.tsx
1338
+ var PathUtility = class {
1339
+ constructor() {
1340
+ }
1341
+ normalizePath(path) {
1342
+ if (path == null) {
1343
+ return "/";
1344
+ }
1345
+ const trimmedPath = path.replace(/^\/|\/$/g, "");
1346
+ return trimmedPath === "" ? "/" : "/" + trimmedPath + "/";
1347
+ }
1348
+ joinAndNormalizePaths(path1, path2) {
1349
+ path1 = path1.replace(/\/$/, "");
1350
+ path2 = path2.replace(/^\//, "");
1351
+ const joinedPath = `${path1}/${path2}`;
1352
+ const normalizedPath = joinedPath.replace(/\/{2,}/g, "/");
1353
+ return normalizedPath === "" ? "/" : "/" + normalizedPath;
1354
+ }
1355
+ removeLeadingAndTrailingSlashes(path) {
1356
+ if (path == null) {
1357
+ return "/";
1358
+ }
1359
+ const trimmedPath = path.replace(/^\/|\/$/g, "");
1360
+ return trimmedPath;
1361
+ }
1362
+ removeTrailingSlash(path) {
1363
+ if (path == null) {
1364
+ return "/";
1365
+ }
1366
+ const trimmedPath = path.replace(/\/$/, "");
1367
+ return trimmedPath;
1368
+ }
1369
+ joinPaths(path1, path2) {
1370
+ if (!path1.endsWith("/") && !path2.startsWith("/")) {
1371
+ return `${path1}/${path2}`;
1372
+ } else if (path1.endsWith("/") && path2.startsWith("/")) {
1373
+ return `${path1}${path2.substr(1)}`;
1374
+ } else {
1375
+ return `${path1}${path2}`;
1376
+ }
1377
+ }
1378
+ getFirstSegment(path) {
1379
+ if (!path || path === "/") {
1380
+ return "";
1381
+ }
1382
+ const segments = path.split("/").filter(Boolean);
1383
+ return segments.length > 0 ? segments[0] : "";
1384
+ }
1385
+ getFileNameFromUrl(url) {
1386
+ if (!url || url.indexOf("/") === -1) {
1387
+ return url;
1388
+ }
1389
+ const parts = url.split("/");
1390
+ const filename = parts[parts.length - 1];
1391
+ return filename;
1392
+ }
1393
+ };
1394
+ var PathUtility_default = new PathUtility();
1395
+
1396
+ // src/components/NoDataFound.tsx
1397
+ import { jsx as jsx31, jsxs as jsxs10 } from "react/jsx-runtime";
1398
+ var NoDataFound = () => {
1399
+ return /* @__PURE__ */ jsxs10("div", { className: "flex flex-col items-center justify-center py-12 px-4 text-center bg-neutral-weak", children: [
1400
+ /* @__PURE__ */ jsx31("div", { className: "mb-5", children: /* @__PURE__ */ jsx31("div", { className: "mx-auto w-20 h-20 rounded-full flex items-center justify-center bg-neutral-soft", children: /* @__PURE__ */ jsx31(
1401
+ "svg",
1402
+ {
1403
+ className: "w-10 h-10",
1404
+ fill: "none",
1405
+ stroke: "currentColor",
1406
+ viewBox: "0 0 24 24",
1407
+ xmlns: "http://www.w3.org/2000/svg",
1408
+ children: /* @__PURE__ */ jsx31(
1409
+ "path",
1410
+ {
1411
+ strokeLinecap: "round",
1412
+ strokeLinejoin: "round",
1413
+ strokeWidth: "1.5",
1414
+ d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"
1415
+ }
1416
+ )
1417
+ }
1418
+ ) }) }),
1419
+ /* @__PURE__ */ jsx31("h3", { className: "text-lg font-medium mb-2", children: "No data available" }),
1420
+ /* @__PURE__ */ jsx31("p", { className: " max-w-sm mb-0", children: "No records found. Data may be empty or not available at the moment." })
1421
+ ] });
1422
+ };
1423
+ var NoDataFound_default = NoDataFound;
1424
+
1425
+ // src/components/pageRenderingEngine/nodes/ImageGalleryNode.tsx
1426
+ import dynamic9 from "next/dynamic";
1427
+ import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs11 } from "react/jsx-runtime";
1428
+ var HlsPlayer3 = dynamic9(() => import("./HlsPlayer-57543DTW.mjs"), { ssr: false });
1429
+ var deviceToMediaQuery = (device) => {
1430
+ switch (device) {
1431
+ case "lg":
1432
+ return "(min-width: 769px)";
1433
+ case "md":
1434
+ return "(min-width: 481px) and (max-width: 768px)";
1435
+ case "sm":
1436
+ return "(max-width: 480px)";
1437
+ default:
1438
+ return null;
1439
+ }
1440
+ };
1441
+ var DEVICE_ORDER = ["lg", "md", "sm", "tv"];
1442
+ var parseMaybeNumber = (value) => {
1443
+ if (typeof value === "number")
1444
+ return Number.isFinite(value) ? value : void 0;
1445
+ if (typeof value !== "string") return void 0;
1446
+ const n = Number(value);
1447
+ return Number.isFinite(n) ? n : void 0;
1448
+ };
1449
+ function resolveAssetUrl(fieldValue, tag) {
1450
+ if (!fieldValue) {
1451
+ return void 0;
1452
+ }
1453
+ if (typeof fieldValue === "string") {
1454
+ const trimmed = fieldValue.trim();
1455
+ if (trimmed.startsWith("itemassets/") || trimmed.startsWith("/itemassets/") || trimmed.startsWith("http")) {
1456
+ return trimmed;
1457
+ }
1458
+ try {
1459
+ const parsed = JSON.parse(trimmed);
1460
+ return resolveAssetUrl(parsed, tag);
1461
+ } catch {
1462
+ return void 0;
1463
+ }
1464
+ }
1465
+ if (Array.isArray(fieldValue)) {
1466
+ const asset = tag ? fieldValue.find(
1467
+ (x) => x?.tag?.toLowerCase() === tag?.toLowerCase()
1468
+ ) : fieldValue[0];
1469
+ return asset?.assetUrl;
1470
+ }
1471
+ if (typeof fieldValue === "object" && fieldValue !== null) {
1472
+ const assetObject = fieldValue;
1473
+ if (assetObject.assetUrl) {
1474
+ return assetObject.assetUrl;
1475
+ }
1476
+ }
1477
+ return void 0;
1478
+ }
1479
+ var getNestedValue3 = (obj, path) => {
1480
+ if (!obj || !path) {
1481
+ return void 0;
1482
+ }
1483
+ return path.split(".").reduce((current, key) => {
1484
+ return current?.[key];
1485
+ }, obj);
1486
+ };
1487
+ var ImageGalleryNode = (props) => {
1488
+ const resolveImageUrl = (image) => {
1489
+ let imageUrl = image.imageUrl;
1490
+ if (image.datafield && props.dataitem) {
1491
+ const fieldValue = getNestedValue3(props.dataitem, image.datafield);
1492
+ const resolvedAsset = resolveAssetUrl(fieldValue, image.tag);
1493
+ if (resolvedAsset) {
1494
+ imageUrl = resolvedAsset;
1495
+ }
1496
+ }
1497
+ if (!imageUrl) {
1498
+ return "";
1499
+ }
1500
+ if (imageUrl.startsWith("http")) {
1501
+ return imageUrl;
1502
+ }
1503
+ const base = props.assetBaseUrl.replace(/\/$/, "");
1504
+ const path = imageUrl.replace(/^\//, "");
1505
+ return `${base}/${path}`;
1506
+ };
1507
+ const resolvePosterUrl = (posterUrl) => {
1508
+ if (!posterUrl) return void 0;
1509
+ return AssetUtility_default.resolveUrl(props.assetBaseUrl, posterUrl);
1510
+ };
1511
+ const rawImages = Array.isArray(props.node.images) ? props.node.images : [];
1512
+ const hlsImages = rawImages.filter(
1513
+ (img) => resolveImageUrl(img).endsWith(".m3u8")
1514
+ );
1515
+ const staticImages = rawImages.filter(
1516
+ (img) => !resolveImageUrl(img).endsWith(".m3u8")
1517
+ );
1518
+ const hlsSources = [
1519
+ ...DEVICE_ORDER.flatMap((deviceKey) => {
1520
+ const img = hlsImages.find((i) => i.device === deviceKey);
1521
+ if (!img) return [];
1522
+ const src = resolveImageUrl(img);
1523
+ if (!src) return [];
1524
+ const media = deviceToMediaQuery(img.device);
1525
+ const posterUrl = resolvePosterUrl(img.posterUrl);
1526
+ return [
1527
+ {
1528
+ src,
1529
+ ...media ? { media } : {},
1530
+ ...posterUrl ? { posterUrl } : {}
1531
+ }
1532
+ ];
1533
+ }),
1534
+ ...hlsImages.filter((img) => !img.device).map((img) => {
1535
+ const src = resolveImageUrl(img);
1536
+ const posterUrl = resolvePosterUrl(img.posterUrl);
1537
+ return { src, ...posterUrl ? { posterUrl } : {} };
1538
+ }).filter((s) => !!s.src)
1539
+ ];
1540
+ const primaryHls = hlsImages.find((img) => !img.device) ?? hlsImages[0];
1541
+ const hlsIntrinsicWidth = primaryHls ? parseMaybeNumber(primaryHls.intrinsicWidth)?.toString() : void 0;
1542
+ const hlsIntrinsicHeight = primaryHls ? parseMaybeNumber(primaryHls.intrinsicHeight)?.toString() : void 0;
1543
+ const hlsStyles = {};
1544
+ if (primaryHls?.height) hlsStyles.height = primaryHls.height;
1545
+ if (primaryHls?.width) hlsStyles.width = primaryHls.width;
1546
+ if (primaryHls?.borderRadius)
1547
+ hlsStyles.borderRadius = primaryHls.borderRadius;
1548
+ const staticSources = staticImages.filter((img) => !!img.device);
1549
+ const staticFallback = staticImages.find((img) => !img.device) ?? null;
1550
+ const FormatClass = {
1551
+ center: "justify-center",
1552
+ left: "justify-start",
1553
+ right: "justify-end"
1554
+ };
1555
+ const formatClasses = FormatClass[props.node.format || ""] || "";
1556
+ return /* @__PURE__ */ jsxs11(Fragment5, { children: [
1557
+ hlsSources.length > 0 && /* @__PURE__ */ jsx32(Fragment5, { children: /* @__PURE__ */ jsx32(
1558
+ HlsPlayer3,
1559
+ {
1560
+ sources: hlsSources,
1561
+ intrinsicWidth: hlsIntrinsicWidth,
1562
+ intrinsicHeight: hlsIntrinsicHeight,
1563
+ showControls: primaryHls?.showControls ?? false,
1564
+ loop: primaryHls?.loop ?? false,
1565
+ playOptions: primaryHls?.playOptions ?? "",
1566
+ placementCode: primaryHls?.placementCode ?? "",
1567
+ apiBaseUrl: props.apiBaseUrl,
1568
+ session: props.session,
1569
+ styles: hlsStyles
1570
+ }
1571
+ ) }),
1572
+ (staticFallback || staticSources.length > 0) && /* @__PURE__ */ jsx32(Fragment5, { children: staticFallback ? /* @__PURE__ */ jsxs11("picture", { children: [
1573
+ DEVICE_ORDER.map((deviceKey) => {
1574
+ const match = staticSources.find(
1575
+ (img) => img.device === deviceKey
1576
+ );
1577
+ if (!match) {
1578
+ return null;
1579
+ }
1580
+ const srcUrl = resolveImageUrl(match);
1581
+ if (!srcUrl) {
1582
+ return null;
1583
+ }
1584
+ return /* @__PURE__ */ jsx32(
1585
+ "source",
1586
+ {
1587
+ media: deviceToMediaQuery(match.device),
1588
+ srcSet: srcUrl,
1589
+ width: parseMaybeNumber(match.intrinsicWidth),
1590
+ height: parseMaybeNumber(match.intrinsicHeight)
1591
+ },
1592
+ deviceKey
1593
+ );
1594
+ }),
1595
+ (() => {
1596
+ const img = staticFallback;
1597
+ const imageUrl = resolveImageUrl(img);
1598
+ if (!imageUrl) {
1599
+ return null;
1600
+ }
1601
+ const styles = {
1602
+ width: img.width || "auto",
1603
+ height: img.height || "auto"
1604
+ };
1605
+ if (img.borderRadius) {
1606
+ styles.borderRadius = img.borderRadius;
1607
+ }
1608
+ return /* @__PURE__ */ jsx32(
1609
+ "img",
1610
+ {
1611
+ loading: "lazy",
1612
+ style: styles,
1613
+ className: "object-cover max-w-full",
1614
+ src: imageUrl,
1615
+ width: parseMaybeNumber(img.intrinsicWidth),
1616
+ height: parseMaybeNumber(img.intrinsicHeight),
1617
+ alt: img.title ?? "Gallery image"
1618
+ }
1619
+ );
1620
+ })()
1621
+ ] }) : (
1622
+ /* Case 2: Only device-specific images exist */
1623
+ /* @__PURE__ */ jsx32(Fragment5, { children: staticSources.map((img, index) => {
1624
+ const imageUrl = resolveImageUrl(img);
1625
+ if (!imageUrl) {
1626
+ return null;
1627
+ }
1628
+ const styles = {
1629
+ width: img.width || "auto",
1630
+ height: img.height || "auto"
1631
+ };
1632
+ if (img.borderRadius) {
1633
+ styles.borderRadius = img.borderRadius;
1634
+ }
1635
+ let display = "none";
1636
+ switch (img.device) {
1637
+ case "sm":
1638
+ display = props.device === "sm" ? "block" : "none";
1639
+ break;
1640
+ case "md":
1641
+ display = props.device === "md" ? "block" : "none";
1642
+ break;
1643
+ case "lg":
1644
+ display = props.device === "lg" ? "block" : "none";
1645
+ break;
1646
+ default:
1647
+ display = "block";
1648
+ }
1649
+ return /* @__PURE__ */ jsx32(
1650
+ "img",
1651
+ {
1652
+ loading: "lazy",
1653
+ src: imageUrl,
1654
+ style: {
1655
+ ...styles,
1656
+ display
1657
+ },
1658
+ className: "object-cover max-w-full",
1659
+ width: parseMaybeNumber(img.intrinsicWidth),
1660
+ height: parseMaybeNumber(img.intrinsicHeight),
1661
+ alt: img.title ?? "Gallery image"
1662
+ },
1663
+ index
1664
+ );
1665
+ }) })
1666
+ ) })
1667
+ ] });
1668
+ };
1669
+ var ImageGalleryNode_default = ImageGalleryNode;
1670
+
1671
+ // src/components/pageRenderingEngine/nodes/DivContainer.tsx
1672
+ import Link from "next/link";
1673
+
1674
+ // src/utilities/RoleUtility.tsx
1675
+ var decodeJWT = (token) => {
1676
+ if (!token) return null;
1677
+ try {
1678
+ const cleanToken = token.replace(/^Bearer\s+/i, "");
1679
+ const parts = cleanToken.split(".");
1680
+ if (parts.length !== 3) {
1681
+ console.warn("Invalid JWT token format");
1682
+ return null;
1683
+ }
1684
+ const payload = parts[1];
1685
+ const decoded = JSON.parse(atob(payload));
1686
+ return decoded;
1687
+ } catch (error) {
1688
+ console.warn("Failed to decode JWT token:", error);
1689
+ return null;
1690
+ }
1691
+ };
1692
+ var extractRolesFromToken = (decodedPayload) => {
1693
+ if (!decodedPayload) return [];
1694
+ const roles = [];
1695
+ if (decodedPayload.role && typeof decodedPayload.role === "string") {
1696
+ roles.push(decodedPayload.role);
1697
+ }
1698
+ if (decodedPayload.rolecode && typeof decodedPayload.rolecode === "string") {
1699
+ roles.push(decodedPayload.rolecode);
1700
+ }
1701
+ if (decodedPayload.roles && Array.isArray(decodedPayload.roles)) {
1702
+ roles.push(...decodedPayload.roles);
1703
+ }
1704
+ if (decodedPayload.realm_access?.roles && Array.isArray(decodedPayload.realm_access.roles)) {
1705
+ roles.push(...decodedPayload.realm_access.roles);
1706
+ }
1707
+ if (decodedPayload.resource_access && typeof decodedPayload.resource_access === "object") {
1708
+ Object.values(decodedPayload.resource_access).forEach((resource) => {
1709
+ if (resource?.roles && Array.isArray(resource.roles)) {
1710
+ roles.push(...resource.roles);
1711
+ }
1712
+ });
1713
+ }
1714
+ return [...new Set(roles)];
1715
+ };
1716
+ var getUserRoles = (oAuthToken) => {
1717
+ const decodedPayload = decodeJWT(oAuthToken);
1718
+ return extractRolesFromToken(decodedPayload);
1719
+ };
1720
+ var hasRole = (userRoles, requiredRole) => {
1721
+ if (!requiredRole || !userRoles) return false;
1722
+ return userRoles.some(
1723
+ (role) => role.toLowerCase() === requiredRole.toLowerCase()
1724
+ );
1725
+ };
1726
+ var shouldRenderByRole = (roleCode, userRoles) => {
1727
+ if (!roleCode || roleCode.trim() === "") {
1728
+ return true;
1729
+ }
1730
+ const trimmedRoleCode = roleCode.trim();
1731
+ if (trimmedRoleCode.startsWith("!")) {
1732
+ const requiredRole = trimmedRoleCode.substring(1);
1733
+ return !hasRole(userRoles, requiredRole);
1734
+ }
1735
+ return hasRole(userRoles, trimmedRoleCode);
1736
+ };
1737
+ var validateRoleVisibility = (roleCode, oAuthToken) => {
1738
+ const userRoles = getUserRoles(oAuthToken);
1739
+ return shouldRenderByRole(roleCode, userRoles);
1740
+ };
1741
+
1742
+ // src/utilities/VisibilityUtility.tsx
1743
+ var getNestedValue4 = (obj, path) => {
1744
+ if (!obj || !path) return void 0;
1745
+ return path.split(".").reduce((current, key) => {
1746
+ return current && current[key] !== void 0 ? current[key] : void 0;
1747
+ }, obj);
1748
+ };
1749
+ var shouldRenderByFieldVisibility = (fieldVisibleOnTrue, dataItem) => {
1750
+ if (!fieldVisibleOnTrue) {
1751
+ return true;
1752
+ }
1753
+ const condition = fieldVisibleOnTrue.trim();
1754
+ const isNegated = condition.startsWith("!");
1755
+ const fieldName = isNegated ? condition.substring(1).trim() : condition;
1756
+ const fieldValue = getNestedValue4(dataItem, fieldName);
1757
+ if (fieldValue == null || fieldValue === 0) {
1758
+ return false;
1759
+ }
1760
+ return isNegated ? fieldValue !== true : fieldValue !== false;
1761
+ };
1762
+ var shouldRenderByRole2 = (roleCode, oAuthToken) => {
1763
+ if (!roleCode || roleCode.trim() === "") {
1764
+ return true;
1765
+ }
1766
+ return validateRoleVisibility(roleCode, oAuthToken ?? void 0);
1767
+ };
1768
+ var shouldRenderByVisibility = (visibility, session) => {
1769
+ const normalizedVisibility = visibility?.trim().toLowerCase();
1770
+ const hasAuthToken = Boolean(session?.oAuthToken?.trim());
1771
+ switch (normalizedVisibility) {
1772
+ case "authorized":
1773
+ return hasAuthToken;
1774
+ case "anonymous":
1775
+ return !hasAuthToken;
1776
+ case "all":
1777
+ case "":
1778
+ case null:
1779
+ case void 0:
1780
+ default:
1781
+ return true;
1782
+ }
1783
+ };
1784
+ var shouldRenderContainer = (node, dataItem, session) => {
1785
+ return shouldRenderByVisibility(node.visibility, session) && shouldRenderByRole2(node.roleCode, session?.oAuthToken) && shouldRenderByFieldVisibility(node.fieldVisibleOnTrue, dataItem);
1786
+ };
1787
+
1788
+ // src/components/pageRenderingEngine/nodes/DocumentNode.tsx
1789
+ import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
1790
+ var getNestedValue5 = (obj, path) => {
1791
+ if (!obj || !path) return void 0;
1792
+ return path.split(".").reduce((current, key) => {
1793
+ return current && current[key] !== void 0 ? current[key] : void 0;
1794
+ }, obj);
1795
+ };
1796
+ var PdfIcon = () => /* @__PURE__ */ jsxs12(
1797
+ "svg",
1798
+ {
1799
+ xmlns: "http://www.w3.org/2000/svg",
1800
+ viewBox: "0 0 48 48",
1801
+ className: "w-10 h-10",
1802
+ children: [
1803
+ /* @__PURE__ */ jsx33(
1804
+ "path",
1805
+ {
1806
+ fill: "#e53935",
1807
+ d: "M38,42H10c-2.209,0-4-1.791-4-4V10c0-2.209,1.791-4,4-4h28c2.209,0,4,1.791,4,4v28 C42,40.209,40.209,42,38,42z"
1808
+ }
1809
+ ),
1810
+ /* @__PURE__ */ jsx33(
1811
+ "path",
1812
+ {
1813
+ fill: "#fff",
1814
+ d: "M34.841,26.799c-1.692-1.757-6.314-1.041-7.42-0.911c-1.627-1.562-2.734-3.45-3.124-4.101 c0.586-1.757,0.976-3.515,1.041-5.402c0-1.627-0.651-3.385-2.473-3.385c-0.651,0-1.237,0.391-1.562,0.911 c-0.781,1.367-0.456,4.101,0.781,6.899c-0.716,2.018-1.367,3.97-3.189,7.42c-1.888,0.781-5.858,2.604-6.183,4.556 c-0.13,0.586,0.065,1.172,0.521,1.627C13.688,34.805,14.273,35,14.859,35c2.408,0,4.751-3.32,6.379-6.118 c1.367-0.456,3.515-1.107,5.663-1.497c2.538,2.213,4.751,2.538,5.923,2.538c1.562,0,2.148-0.651,2.343-1.237 C35.492,28.036,35.297,27.32,34.841,26.799z M33.214,27.905c-0.065,0.456-0.651,0.911-1.692,0.651 c-1.237-0.325-2.343-0.911-3.32-1.692c0.846-0.13,2.734-0.325,4.101-0.065C32.824,26.929,33.344,27.254,33.214,27.905z M22.344,14.497c0.13-0.195,0.325-0.325,0.521-0.325c0.586,0,0.716,0.716,0.716,1.302c-0.065,1.367-0.325,2.734-0.781,4.036 C21.824,16.905,22.019,15.083,22.344,14.497z M22.214,27.124c0.521-1.041,1.237-2.864,1.497-3.645 c0.586,0.976,1.562,2.148,2.083,2.669C25.794,26.213,23.776,26.604,22.214,27.124z M18.374,29.728 c-1.497,2.473-3.059,4.036-3.905,4.036c-0.13,0-0.26-0.065-0.391-0.13c-0.195-0.13-0.26-0.325-0.195-0.586 C14.078,32.136,15.77,30.899,18.374,29.728z"
1815
+ }
1816
+ )
1817
+ ]
1818
+ }
1819
+ );
1820
+ var ExcelIcon = () => /* @__PURE__ */ jsxs12(
1821
+ "svg",
1822
+ {
1823
+ xmlns: "http://www.w3.org/2000/svg",
1824
+ viewBox: "0 0 48 48",
1825
+ className: "w-10 h-10",
1826
+ children: [
1827
+ /* @__PURE__ */ jsx33(
1828
+ "path",
1829
+ {
1830
+ fill: "#169154",
1831
+ d: "M29,6H15.744C14.781,6,14,6.781,14,7.744v7.259h15V6z"
1832
+ }
1833
+ ),
1834
+ /* @__PURE__ */ jsx33(
1835
+ "path",
1836
+ {
1837
+ fill: "#18482a",
1838
+ d: "M14,33.054v7.202C14,41.219,14.781,42,15.743,42H29v-8.946H14z"
1839
+ }
1840
+ ),
1841
+ /* @__PURE__ */ jsx33("path", { fill: "#0c8045", d: "M14 15.003H29V24.005000000000003H14z" }),
1842
+ /* @__PURE__ */ jsx33("path", { fill: "#17472a", d: "M14 24.005H29V33.055H14z" }),
1843
+ /* @__PURE__ */ jsxs12("g", { children: [
1844
+ /* @__PURE__ */ jsx33(
1845
+ "path",
1846
+ {
1847
+ fill: "#29c27f",
1848
+ d: "M42.256,6H29v9.003h15V7.744C44,6.781,43.219,6,42.256,6z"
1849
+ }
1850
+ ),
1851
+ /* @__PURE__ */ jsx33(
1852
+ "path",
1853
+ {
1854
+ fill: "#27663f",
1855
+ d: "M29,33.054V42h13.257C43.219,42,44,41.219,44,40.257v-7.202H29z"
1856
+ }
1857
+ ),
1858
+ /* @__PURE__ */ jsx33("path", { fill: "#19ac65", d: "M29 15.003H44V24.005000000000003H29z" }),
1859
+ /* @__PURE__ */ jsx33("path", { fill: "#129652", d: "M29 24.005H44V33.055H29z" })
1860
+ ] }),
1861
+ /* @__PURE__ */ jsx33(
1862
+ "path",
1863
+ {
1864
+ fill: "#0c7238",
1865
+ d: "M22.319,34H5.681C4.753,34,4,33.247,4,32.319V15.681C4,14.753,4.753,14,5.681,14h16.638 C23.247,14,24,14.753,24,15.681v16.638C24,33.247,23.247,34,22.319,34z"
1866
+ }
1867
+ ),
1868
+ /* @__PURE__ */ jsx33(
1869
+ "path",
1870
+ {
1871
+ fill: "#fff",
1872
+ d: "M9.807 19L12.193 19 14.129 22.754 16.175 19 18.404 19 15.333 24 18.474 29 16.123 29 14.013 25.07 11.912 29 9.526 29 12.719 23.982z"
1873
+ }
1874
+ )
1875
+ ]
1876
+ }
1877
+ );
1878
+ var WordIcon = () => /* @__PURE__ */ jsxs12(
1879
+ "svg",
1880
+ {
1881
+ xmlns: "http://www.w3.org/2000/svg",
1882
+ viewBox: "0 0 48 48",
1883
+ className: "w-10 h-10",
1884
+ baseProfile: "basic",
1885
+ children: [
1886
+ /* @__PURE__ */ jsx33(
1887
+ "path",
1888
+ {
1889
+ fill: "#283593",
1890
+ d: "M9,33.595l14.911-18.706L41,26v13.306C41,41.346,39.346,43,37.306,43H15.332 C11.835,43,9,40.164,9,36.667C9,36.667,9,33.595,9,33.595z"
1891
+ }
1892
+ ),
1893
+ /* @__PURE__ */ jsxs12(
1894
+ "linearGradient",
1895
+ {
1896
+ id: "qh2LT5tehRDFkLLfb-odWa",
1897
+ x1: "9",
1898
+ x2: "33.506",
1899
+ y1: "364.445",
1900
+ y2: "364.445",
1901
+ gradientTransform: "translate(0 -339.89)",
1902
+ gradientUnits: "userSpaceOnUse",
1903
+ children: [
1904
+ /* @__PURE__ */ jsx33("stop", { offset: "0", "stop-color": "#66c0ff" }),
1905
+ /* @__PURE__ */ jsx33("stop", { offset: ".26", "stop-color": "#0094f0" })
1906
+ ]
1907
+ }
1908
+ ),
1909
+ /* @__PURE__ */ jsx33(
1910
+ "path",
1911
+ {
1912
+ fill: "url(#qh2LT5tehRDFkLLfb-odWa)",
1913
+ d: "M9,20.208c0-2.624,2.126-4.75,4.749-4.75h21.857L41,12.778v13.527 C41,28.346,39.346,30,37.306,30H15.332C11.835,30,9,32.836,9,36.333L9,20.208L9,20.208z"
1914
+ }
1915
+ ),
1916
+ /* @__PURE__ */ jsx33(
1917
+ "path",
1918
+ {
1919
+ fill: "#1e88e5",
1920
+ "fill-opacity": ".6",
1921
+ d: "M9,20.208c0-2.624,2.126-4.75,4.749-4.75h21.857L41,12.778v13.527 C41,28.346,39.346,30,37.306,30H15.332C11.835,30,9,32.836,9,36.333L9,20.208L9,20.208z"
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ jsx33(
1925
+ "path",
1926
+ {
1927
+ fill: "#00e5ff",
1928
+ d: "M9,10.333C9,6.836,11.835,4,15.332,4h21.975C39.346,4,41,5.654,41,7.694v5.611 C41,15.346,39.346,17,37.306,17H15.332C11.835,17,9,19.836,9,23.333C9,23.333,9,10.333,9,10.333z"
1929
+ }
1930
+ ),
1931
+ /* @__PURE__ */ jsx33(
1932
+ "path",
1933
+ {
1934
+ fill: "#1565c0",
1935
+ d: "M7.5,23h10c1.933,0,3.5,1.567,3.5,3.5v10c0,1.933-1.567,3.5-3.5,3.5h-10C5.567,40,4,38.433,4,36.5 v-10C4,24.567,5.567,23,7.5,23z"
1936
+ }
1937
+ ),
1938
+ /* @__PURE__ */ jsx33(
1939
+ "path",
1940
+ {
1941
+ fill: "#fff",
1942
+ d: "M18.327,26.643l-2.092,9.713l-2.501,0.002L12.5,30.529l-1.293,5.829H8.683l-2.01-9.713h2.062 l1.24,6.41l1.232-6.41h2.528l1.291,6.41l1.21-6.41L18.327,26.643L18.327,26.643z"
1943
+ }
1944
+ )
1945
+ ]
1946
+ }
1947
+ );
1948
+ var StandardIcon = () => /* @__PURE__ */ jsxs12(
1949
+ "svg",
1950
+ {
1951
+ xmlns: "http://www.w3.org/2000/svg",
1952
+ viewBox: "0 0 48 48",
1953
+ className: "w-10 h-10",
1954
+ children: [
1955
+ /* @__PURE__ */ jsx33("path", { fill: "#90CAF9", d: "M40 45L8 45 8 3 30 3 40 13z" }),
1956
+ /* @__PURE__ */ jsx33("path", { fill: "#E1F5FE", d: "M38.5 14L29 14 29 4.5z" })
1957
+ ]
1958
+ }
1959
+ );
1960
+ var PowerPointIcon = () => /* @__PURE__ */ jsxs12(
1961
+ "svg",
1962
+ {
1963
+ xmlns: "http://www.w3.org/2000/svg",
1964
+ viewBox: "0 0 48 48",
1965
+ className: "w-10 h-10",
1966
+ children: [
1967
+ /* @__PURE__ */ jsx33(
1968
+ "path",
1969
+ {
1970
+ fill: "#dc4c2c",
1971
+ d: "M8,24c0,9.941,8.059,18,18,18s18-8.059,18-18H26H8z"
1972
+ }
1973
+ ),
1974
+ /* @__PURE__ */ jsx33("path", { fill: "#f7a278", d: "M26,6v18h18C44,14.059,35.941,6,26,6z" }),
1975
+ /* @__PURE__ */ jsx33("path", { fill: "#c06346", d: "M26,6C16.059,6,8,14.059,8,24h18V6z" }),
1976
+ /* @__PURE__ */ jsx33(
1977
+ "path",
1978
+ {
1979
+ fill: "#9b341f",
1980
+ d: "M22.319,34H5.681C4.753,34,4,33.247,4,32.319V15.681C4,14.753,4.753,14,5.681,14h16.638 C23.247,14,24,14.753,24,15.681v16.638C24,33.247,23.247,34,22.319,34z"
1981
+ }
1982
+ ),
1983
+ /* @__PURE__ */ jsx33(
1984
+ "path",
1985
+ {
1986
+ fill: "#fff",
1987
+ d: "M14.673,19.012H10v10h2.024v-3.521H14.3c1.876,0,3.397-1.521,3.397-3.397v-0.058 C17.697,20.366,16.343,19.012,14.673,19.012z M15.57,22.358c0,0.859-0.697,1.556-1.556,1.556h-1.99v-3.325h1.99 c0.859,0,1.556,0.697,1.556,1.556V22.358z"
1988
+ }
1989
+ )
1990
+ ]
1991
+ }
1992
+ );
1993
+ var TextIcon = () => /* @__PURE__ */ jsxs12(
1994
+ "svg",
1995
+ {
1996
+ xmlns: "http://www.w3.org/2000/svg",
1997
+ viewBox: "0 0 48 48",
1998
+ className: "w-10 h-10",
1999
+ children: [
2000
+ /* @__PURE__ */ jsx33("path", { fill: "#90CAF9", d: "M40 45L8 45 8 3 30 3 40 13z" }),
2001
+ /* @__PURE__ */ jsx33("path", { fill: "#E1F5FE", d: "M38.5 14L29 14 29 4.5z" }),
2002
+ /* @__PURE__ */ jsx33(
2003
+ "path",
2004
+ {
2005
+ fill: "#1976D2",
2006
+ d: "M16 21H33V23H16zM16 25H29V27H16zM16 29H33V31H16zM16 33H29V35H16z"
2007
+ }
2008
+ )
2009
+ ]
2010
+ }
2011
+ );
2012
+ var ArchiveIcon = () => /* @__PURE__ */ jsxs12(
2013
+ "svg",
2014
+ {
2015
+ xmlns: "http://www.w3.org/2000/svg",
2016
+ zoomAndPan: "magnify",
2017
+ viewBox: "0 0 75 74.999997",
2018
+ preserveAspectRatio: "xMidYMid meet",
2019
+ version: "1.0",
2020
+ className: "w-10 h-10",
2021
+ children: [
2022
+ /* @__PURE__ */ jsx33("defs", { children: /* @__PURE__ */ jsx33("clipPath", { id: "273d29c8a6", children: /* @__PURE__ */ jsx33(
2023
+ "path",
2024
+ {
2025
+ d: "M 8.90625 0 L 65.90625 0 L 65.90625 75 L 8.90625 75 Z M 8.90625 0 ",
2026
+ "clip-rule": "nonzero"
2027
+ }
2028
+ ) }) }),
2029
+ /* @__PURE__ */ jsx33("g", { "clip-path": "url(#273d29c8a6)", children: /* @__PURE__ */ jsx33(
2030
+ "path",
2031
+ {
2032
+ fill: "#ff9100",
2033
+ d: "M 65.882812 75 L 8.929688 75 L 8.929688 0 L 48.085938 0 L 65.882812 17.855469 Z M 65.882812 75 ",
2034
+ "fill-opacity": "1",
2035
+ "fill-rule": "nonzero"
2036
+ }
2037
+ ) }),
2038
+ /* @__PURE__ */ jsx33(
2039
+ "path",
2040
+ {
2041
+ fill: "#fbe9e7",
2042
+ d: "M 63.214844 19.644531 L 46.304688 19.644531 L 46.304688 2.679688 Z M 63.214844 19.644531 ",
2043
+ "fill-opacity": "1",
2044
+ "fill-rule": "nonzero"
2045
+ }
2046
+ ),
2047
+ /* @__PURE__ */ jsx33(
2048
+ "path",
2049
+ {
2050
+ fill: "#ffe0b2",
2051
+ d: "M 26.523438 50.59375 L 33.824219 50.59375 L 33.824219 53.570312 L 22.339844 53.570312 L 22.339844 51.410156 L 29.566406 38.789062 L 22.265625 38.789062 L 22.265625 35.796875 L 33.691406 35.796875 L 33.691406 37.910156 Z M 26.523438 50.59375 ",
2052
+ "fill-opacity": "1",
2053
+ "fill-rule": "nonzero"
2054
+ }
2055
+ ),
2056
+ /* @__PURE__ */ jsx33(
2057
+ "path",
2058
+ {
2059
+ fill: "#ffe0b2",
2060
+ d: "M 36.183594 35.796875 L 39.757812 35.796875 L 39.757812 53.570312 L 36.183594 53.570312 Z M 36.183594 35.796875 ",
2061
+ "fill-opacity": "1",
2062
+ "fill-rule": "nonzero"
2063
+ }
2064
+ ),
2065
+ /* @__PURE__ */ jsx33(
2066
+ "path",
2067
+ {
2068
+ fill: "#ffe0b2",
2069
+ d: "M 46.34375 47.320312 L 46.34375 53.570312 L 42.765625 53.570312 L 42.765625 35.796875 L 48.800781 35.796875 C 50.550781 35.796875 51.953125 36.34375 52.992188 37.433594 C 54.035156 38.523438 54.554688 39.9375 54.554688 41.683594 C 54.554688 43.425781 54.039062 44.796875 53.011719 45.808594 C 51.980469 46.820312 50.550781 47.320312 48.726562 47.320312 Z M 46.34375 44.332031 L 48.800781 44.332031 C 49.484375 44.332031 50.007812 44.105469 50.382812 43.660156 C 50.757812 43.210938 50.941406 42.5625 50.941406 41.707031 C 50.941406 40.816406 50.753906 40.113281 50.371094 39.585938 C 49.988281 39.0625 49.476562 38.796875 48.839844 38.789062 L 46.34375 38.789062 Z M 46.34375 44.332031 ",
2070
+ "fill-opacity": "1",
2071
+ "fill-rule": "nonzero"
2072
+ }
2073
+ )
2074
+ ]
2075
+ }
2076
+ );
2077
+ var getFileDetails = (url) => {
2078
+ const extMatch = url.match(/\.([a-zA-Z0-9]+)(?:[\?#]|$)/);
2079
+ const ext = extMatch ? extMatch[1].toLowerCase() : "";
2080
+ let Icon = StandardIcon;
2081
+ let extLabel = "FILE";
2082
+ if (ext === "pdf") {
2083
+ Icon = PdfIcon;
2084
+ extLabel = "PDF";
2085
+ } else if (["xls", "xlsx", "csv"].includes(ext)) {
2086
+ Icon = ExcelIcon;
2087
+ extLabel = "Excel";
2088
+ } else if (["doc", "docx"].includes(ext)) {
2089
+ Icon = WordIcon;
2090
+ extLabel = "Word";
2091
+ } else if (["ppt", "pptx"].includes(ext)) {
2092
+ Icon = PowerPointIcon;
2093
+ extLabel = "PowerPoint";
2094
+ } else if (["txt", "rtf"].includes(ext)) {
2095
+ Icon = TextIcon;
2096
+ extLabel = "Text";
2097
+ } else if (["zip", "rar", "7z"].includes(ext)) {
2098
+ Icon = ArchiveIcon;
2099
+ extLabel = "Archive";
2100
+ } else if (ext) {
2101
+ extLabel = ext.toUpperCase();
2102
+ }
2103
+ return { Icon, extLabel };
2104
+ };
2105
+ var DocumentNode = (props) => {
2106
+ console.log("DocumentNode rendered");
2107
+ console.log("props", props);
2108
+ console.log("dataitem", props.dataitem);
2109
+ console.log("node", props.node);
2110
+ let documents = [];
2111
+ if (props.dataitem && props.node.documentKey) {
2112
+ const docData = getNestedValue5(props.dataitem, props.node.documentKey);
2113
+ if (typeof docData === "string") {
2114
+ const trimmed = docData.trim();
2115
+ if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
2116
+ try {
2117
+ const parsed = JSON.parse(trimmed);
2118
+ if (Array.isArray(parsed)) {
2119
+ documents = parsed.filter(
2120
+ (item) => item && item.assetUrl
2121
+ );
2122
+ } else if (parsed?.assetUrl) {
2123
+ documents = [parsed];
2124
+ }
2125
+ } catch {
2126
+ }
2127
+ } else {
2128
+ documents = [
2129
+ {
2130
+ assetUrl: docData
2131
+ }
2132
+ ];
2133
+ }
2134
+ } else if (Array.isArray(docData)) {
2135
+ documents = docData.filter((item) => item && item.assetUrl);
2136
+ } else if (docData && typeof docData === "object" && docData.assetUrl) {
2137
+ documents = [docData];
2138
+ }
2139
+ }
2140
+ if (documents.length === 0) {
2141
+ return /* @__PURE__ */ jsx33(Fragment6, { children: /* @__PURE__ */ jsxs12("div", { className: "py-4 px-2 bg-neutral-weak border rounded text-center flex flex-col gap-2", children: [
2142
+ /* @__PURE__ */ jsx33("div", { className: "mx-auto w-10 h-10 rounded-full flex items-center justify-center bg-neutral-soft", children: /* @__PURE__ */ jsx33(
2143
+ "svg",
2144
+ {
2145
+ className: "w-5 h-5",
2146
+ fill: "none",
2147
+ stroke: "currentColor",
2148
+ viewBox: "0 0 24 24",
2149
+ xmlns: "http://www.w3.org/2000/svg",
2150
+ children: /* @__PURE__ */ jsx33(
2151
+ "path",
2152
+ {
2153
+ strokeLinecap: "round",
2154
+ strokeLinejoin: "round",
2155
+ strokeWidth: "1.5",
2156
+ d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"
2157
+ }
2158
+ )
2159
+ }
2160
+ ) }),
2161
+ /* @__PURE__ */ jsx33("div", { className: "text-sm font-medium", children: "No documents found" }),
2162
+ /* @__PURE__ */ jsx33("div", { className: "text-xs", children: "No records found. Data may be empty or not available at the moment." })
2163
+ ] }) });
2164
+ }
2165
+ return /* @__PURE__ */ jsx33("div", { className: "", children: documents.map((doc, index) => {
2166
+ const documentUrl = AssetUtility_default.resolveUrl(
2167
+ props.assetBaseUrl,
2168
+ doc.assetUrl
2169
+ );
2170
+ let documentTitle = doc.title;
2171
+ if (!documentUrl) {
2172
+ return null;
2173
+ }
2174
+ if (!documentTitle) {
2175
+ try {
2176
+ const pathName = new URL(documentUrl).pathname;
2177
+ documentTitle = pathName.split("/").pop()?.replace(/\.[^/.]+$/, "") || "Document";
2178
+ } catch {
2179
+ documentTitle = documentUrl.split("/").pop()?.replace(/\.[^/.]+$/, "") || "Document";
2180
+ }
2181
+ }
2182
+ const { Icon, extLabel } = getFileDetails(documentUrl);
2183
+ return /* @__PURE__ */ jsxs12(
2184
+ "div",
2185
+ {
2186
+ className: `flex items-center justify-between py-4 bg-default gap-4 ${index !== 0 ? "border-t" : ""}`,
2187
+ children: [
2188
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center space-x-4", children: [
2189
+ /* @__PURE__ */ jsx33("div", { className: "flex items-center justify-center p-2 rounded bg-neutral-soft", children: /* @__PURE__ */ jsx33(Icon, {}) }),
2190
+ /* @__PURE__ */ jsx33("div", { className: "flex items-baseline space-x-2", children: /* @__PURE__ */ jsx33("h4", { className: "text-base font-semibold", children: documentTitle }) })
2191
+ ] }),
2192
+ /* @__PURE__ */ jsxs12(
2193
+ "a",
2194
+ {
2195
+ href: documentUrl,
2196
+ target: "_blank",
2197
+ rel: "noopener noreferrer",
2198
+ className: "inline-flex items-center px-4 py-2 text-sm font-medium bg-default border rounded focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors",
2199
+ children: [
2200
+ /* @__PURE__ */ jsxs12(
2201
+ "svg",
2202
+ {
2203
+ className: "w-4 h-4 mr-2",
2204
+ fill: "none",
2205
+ stroke: "currentColor",
2206
+ viewBox: "0 0 24 24",
2207
+ children: [
2208
+ /* @__PURE__ */ jsx33(
2209
+ "path",
2210
+ {
2211
+ strokeLinecap: "round",
2212
+ strokeLinejoin: "round",
2213
+ strokeWidth: "2",
2214
+ d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
2215
+ }
2216
+ ),
2217
+ /* @__PURE__ */ jsx33(
2218
+ "path",
2219
+ {
2220
+ strokeLinecap: "round",
2221
+ strokeLinejoin: "round",
2222
+ strokeWidth: "2",
2223
+ d: "M12 12v5m0 0l-3-3m3 3l3-3M12 8v4"
2224
+ }
2225
+ )
2226
+ ]
2227
+ }
2228
+ ),
2229
+ "Download"
2230
+ ]
2231
+ }
2232
+ )
2233
+ ]
2234
+ },
2235
+ `${documentUrl}-${index}`
2236
+ );
2237
+ }) });
2238
+ };
2239
+ var DocumentNode_default = DocumentNode;
2240
+
2241
+ // src/components/pageRenderingEngine/nodes/DivContainer.tsx
2242
+ import { jsx as jsx34, jsxs as jsxs13 } from "react/jsx-runtime";
2243
+ var Pagination = dynamic10(() => import("./Pagination-NCJCOYHF.mjs"), { ssr: true });
2244
+ var Slider = dynamic10(() => import("./Slider-PEIVH6A5.mjs"), {
2245
+ ssr: false
2246
+ });
2247
+ function toCamelCase(str) {
2248
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
2249
+ }
2250
+ function convertKeysToCamelCase(obj) {
2251
+ if (!obj || typeof obj !== "object") return obj;
2252
+ if (Array.isArray(obj)) return obj.map(convertKeysToCamelCase);
2253
+ return Object.fromEntries(
2254
+ Object.entries(obj).filter(([_, value]) => value !== "" && value !== void 0).map(([key, value]) => [toCamelCase(key), convertKeysToCamelCase(value)])
2255
+ );
2256
+ }
2257
+ var getNestedValue6 = (obj, path) => {
2258
+ if (!obj || !path) return void 0;
2259
+ return path.split(".").reduce((current, key) => {
2260
+ {
2261
+ }
2262
+ return current && current[key] !== void 0 ? current[key] : void 0;
2263
+ }, obj);
2264
+ };
2265
+ function resolveAssetUrl2(fieldValue, tag) {
2266
+ if (!fieldValue) {
2267
+ return void 0;
2268
+ }
2269
+ if (typeof fieldValue === "string") {
2270
+ const trimmed = fieldValue.trim();
2271
+ if (trimmed.startsWith("itemassets/") || trimmed.startsWith("/itemassets/") || trimmed.startsWith("http")) {
2272
+ return trimmed;
2273
+ }
2274
+ try {
2275
+ const parsed = JSON.parse(trimmed);
2276
+ return resolveAssetUrl2(parsed, tag);
2277
+ } catch {
2278
+ return void 0;
2279
+ }
2280
+ }
2281
+ if (Array.isArray(fieldValue)) {
2282
+ const asset = tag ? fieldValue.find(
2283
+ (x) => x?.tag?.toLowerCase() === tag?.toLowerCase()
2284
+ ) : fieldValue[0];
2285
+ return asset?.assetUrl;
2286
+ }
2287
+ if (typeof fieldValue === "object" && fieldValue !== null) {
2288
+ const assetObject = fieldValue;
2289
+ if (assetObject.assetUrl) {
2290
+ return assetObject.assetUrl;
2291
+ }
2292
+ }
2293
+ return void 0;
2294
+ }
2295
+ function generateCompleteBackgroundString(layers, apiBaseUrl, dataItem) {
2296
+ if (!layers || !Array.isArray(layers)) return "";
2297
+ return layers.filter((layer) => layer && layer.type && layer.value).map((layer) => {
2298
+ if (layer.type === "image" && typeof layer.value === "object") {
2299
+ const imageValue = layer.value;
2300
+ let assetUrl = imageValue.assetUrl || "";
2301
+ if (layer.datafield && dataItem) {
2302
+ const fieldValue = getNestedValue6(dataItem, layer.datafield);
2303
+ const resolvedAssetUrl = resolveAssetUrl2(fieldValue, layer.tag);
2304
+ if (resolvedAssetUrl) {
2305
+ assetUrl = resolvedAssetUrl;
2306
+ }
2307
+ }
2308
+ if (!assetUrl) {
2309
+ return "";
2310
+ }
2311
+ const url = `url('${AssetUtility_default.resolveUrl(apiBaseUrl, assetUrl)}')`;
2312
+ const repeat = layer.repeat || "no-repeat";
2313
+ const position = layer.position || "center";
2314
+ const size = layer.size || "auto";
2315
+ const attachment = layer.attachment || "scroll";
2316
+ return `${url} ${position} / ${size} ${repeat} ${attachment}`;
2317
+ }
2318
+ if (layer.type === "gradient" && typeof layer.value === "object") {
2319
+ const gradient = layer.value;
2320
+ if (!gradient.colors || !gradient.direction) {
2321
+ return "";
2322
+ }
2323
+ const colors = gradient.colors.map(
2324
+ (colorStop) => `color-mix(in srgb, ${colorStop.color}, transparent ${colorStop.transparency ?? 0}%) ${colorStop.start || "0%"}`
2325
+ ).join(", ");
2326
+ return `linear-gradient(${gradient.direction}, ${colors})`;
2327
+ }
2328
+ return "";
2329
+ }).filter((bg) => bg.trim() !== "").join(", ");
2330
+ }
2331
+ var generateCssString = (guid, stylesObject, tabletStylesObject, mobileStylesObject) => {
2332
+ const gridColumns = stylesObject?.gridTemplateColumns ? String(stylesObject.gridTemplateColumns).match(/\d+/g) ?? [] : [];
2333
+ const hasGridProperties = (gridColumns?.length ?? 0) > 0;
2334
+ const largeCols = hasGridProperties ? parseInt(gridColumns[0]) : 4;
2335
+ const tabletColumns = hasGridProperties ? Math.ceil(parseInt(gridColumns[0]) / 2) : 2;
2336
+ const mobileColumns = 1;
2337
+ const cssRules = Object.entries(stylesObject || {}).filter(([_, value]) => value !== void 0 && value !== "").map(([key, value]) => {
2338
+ const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
2339
+ return `${cssKey}: ${value};`;
2340
+ });
2341
+ let css = `#${guid} {
2342
+ ${cssRules.join(
2343
+ "\n"
2344
+ )}
2345
+ transition: all 0.3s ease-in-out; }`;
2346
+ if (tabletStylesObject) {
2347
+ const tabletCssRules = Object.entries(tabletStylesObject).filter(([_, value]) => value !== void 0 && value !== "").map(([key, value]) => {
2348
+ const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
2349
+ return `${cssKey}: ${value};`;
2350
+ });
2351
+ if (tabletCssRules.length > 0) {
2352
+ css += `
2353
+ @media (max-width: 768px) {
2354
+ #${guid} {
2355
+ ${tabletCssRules.join("\n")}
2356
+ }
2357
+ }`;
2358
+ }
2359
+ }
2360
+ if (mobileStylesObject) {
2361
+ const mobileCssRules = Object.entries(mobileStylesObject).filter(([_, value]) => value !== void 0 && value !== "").map(([key, value]) => {
2362
+ const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
2363
+ return `${cssKey}: ${value};`;
2364
+ });
2365
+ if (mobileCssRules.length > 0) {
2366
+ css += `
2367
+ @media (max-width: 480px) {
2368
+ #${guid} {
2369
+ ${mobileCssRules.join("\n")}
2370
+ }
2371
+ }`;
2372
+ }
2373
+ }
2374
+ const updatedTabletStyles = convertKeysToCamelCase(
2375
+ tabletStylesObject
2376
+ );
2377
+ const updatedMobileStyles = convertKeysToCamelCase(
2378
+ mobileStylesObject
2379
+ );
2380
+ if (hasGridProperties) {
2381
+ const tabletHasGrid = tabletStylesObject?.gridTemplateColumns !== void 0 || tabletStylesObject?.["grid-template-columns"] !== void 0;
2382
+ const mobileHasGrid = mobileStylesObject?.gridTemplateColumns !== void 0 || mobileStylesObject?.["grid-template-columns"] !== void 0;
2383
+ if (!tabletHasGrid) {
2384
+ css += `
2385
+ @media (max-width: 768px) {
2386
+ #${guid} {
2387
+ grid-template-columns: repeat(${tabletColumns}, minmax(0, 1fr));
2388
+ }
2389
+ }`;
2390
+ }
2391
+ if (!mobileHasGrid) {
2392
+ css += `
2393
+ @media (max-width: 480px) {
2394
+ #${guid} {
2395
+ grid-template-columns: repeat(${mobileColumns}, minmax(0, 1fr));
2396
+ grid-column: unset;
2397
+ column-gap: unset;
2398
+ }
2399
+ }`;
2400
+ }
2401
+ }
2402
+ return {
2403
+ css,
2404
+ gridColsLarge: largeCols,
2405
+ gridColsMedium: tabletColumns,
2406
+ gridColsSmall: mobileColumns
2407
+ };
2408
+ };
2409
+ var DivContainer = async (props) => {
2410
+ const NodeTypes2 = {
2411
+ paragraph: ParagraphNode_default,
2412
+ heading: HeadingNode_default,
2413
+ list: ListNode_default,
2414
+ quote: QuoteNode_default,
2415
+ code: CodeNode_default,
2416
+ image: ImageNode_default,
2417
+ "image-gallery": ImageGalleryNode_default,
2418
+ horizontalrule: HorizontalRuleNode_default,
2419
+ widget: WidgetNode_default,
2420
+ embed: EmbedNode_default,
2421
+ "div-container": DivContainer,
2422
+ text: TextNode_default,
2423
+ datafield: DatafieldNode_default,
2424
+ "svg-icon": SVGIconNode_default,
2425
+ document: DocumentNode_default
2426
+ };
2427
+ const styles = props.node.cssProperties;
2428
+ const mobileStyles = props.node.mobileCssProperties;
2429
+ const tabletStyles = props.node.tabletCssProperties;
2430
+ const dataBindingProperties = props.node.dataBinding;
2431
+ const updatedStyles = convertKeysToCamelCase(styles);
2432
+ let containerPaddingClass = "";
2433
+ if (props.node.containerPadding == "small") {
2434
+ containerPaddingClass = "container-small";
2435
+ } else if (props.node.containerPadding == "large") {
2436
+ containerPaddingClass = "container-large";
2437
+ }
2438
+ {
2439
+ }
2440
+ const updatedStyle = { ...updatedStyles };
2441
+ const guid = "css" + crypto.randomUUID().toLocaleLowerCase();
2442
+ const animationSelector = `#${guid}`;
2443
+ const { enterAnimation, exitAnimation, hoverAnimation } = props.node;
2444
+ let animationCSS = "";
2445
+ if (enterAnimation?.name) {
2446
+ animationCSS += AnimationUtility_default.generateAnimationCSS(
2447
+ {
2448
+ animation: enterAnimation.name,
2449
+ mode: "enter",
2450
+ ...enterAnimation.properties
2451
+ },
2452
+ animationSelector
2453
+ );
2454
+ }
2455
+ if (hoverAnimation?.name) {
2456
+ animationCSS += AnimationUtility_default.generateAnimationCSS(
2457
+ {
2458
+ animation: hoverAnimation.name,
2459
+ mode: "hover",
2460
+ ...hoverAnimation.properties
2461
+ },
2462
+ animationSelector
2463
+ );
2464
+ }
2465
+ const isHidden = !shouldRenderContainer(
2466
+ {
2467
+ visibility: props.node.visibility,
2468
+ roleCode: props.node.roleCode,
2469
+ fieldVisibleOnTrue: props.node.fieldVisibleOnTrue
2470
+ },
2471
+ props.dataitem,
2472
+ props.session
2473
+ );
2474
+ let odataString = void 0;
2475
+ let endpoint = void 0;
2476
+ let result = null;
2477
+ let response = null;
2478
+ let childCollectionData = null;
2479
+ if (dataBindingProperties) {
2480
+ const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
2481
+ endpoint = dataBindingProperties.dataSource;
2482
+ {
2483
+ }
2484
+ endpoint = endpoint.replace(/\{(\w+)\}/g, (_, key) => {
2485
+ return props.routeParameters?.[key] ?? `{${key}}`;
2486
+ });
2487
+ if (dataBindingProperties.applyODataParams) {
2488
+ odataString = OdataBuilder.getOdataQueryString(props.query);
2489
+ if (odataString) {
2490
+ const separator = endpoint.includes("?") ? "&" : "?";
2491
+ endpoint += separator + odataString;
2492
+ }
2493
+ }
2494
+ response = await serviceClient.get(endpoint);
2495
+ result = response?.result;
2496
+ if (dataBindingProperties.showNoResultsMessage && (result === void 0 || result.length == 0)) {
2497
+ return /* @__PURE__ */ jsx34(NoDataFound_default, {});
2498
+ }
2499
+ if (dataBindingProperties.childCollectionName && props.dataitem) {
2500
+ childCollectionData = getNestedValue6(
2501
+ props.dataitem,
2502
+ dataBindingProperties.childCollectionName
2503
+ );
2504
+ }
2505
+ }
2506
+ const cssResult = generateCssString(
2507
+ guid,
2508
+ updatedStyle,
2509
+ tabletStyles,
2510
+ mobileStyles
2511
+ );
2512
+ function renderNode(node, props2, dataitem, key, href) {
2513
+ {
2514
+ }
2515
+ const SelectedNode = NodeTypes2[node.type];
2516
+ if (!SelectedNode) return null;
2517
+ return /* @__PURE__ */ jsx34(React22.Fragment, { children: /* @__PURE__ */ jsx34(
2518
+ SelectedNode,
2519
+ {
2520
+ node,
2521
+ parentTag: Wrapper,
2522
+ routeParameters: props2.routeParameters,
2523
+ query: props2.query,
2524
+ session: props2.session,
2525
+ host: props2.host,
2526
+ path: props2.path,
2527
+ apiBaseUrl: props2.apiBaseUrl,
2528
+ breadcrumb: props2.breadcrumb,
2529
+ dataitem,
2530
+ href,
2531
+ assetBaseUrl: props2.assetBaseUrl,
2532
+ device: props2.device,
2533
+ widgetRenderer: props2.widgetRenderer
2534
+ }
2535
+ ) }, key);
2536
+ }
2537
+ function renderChildren(nodes, props2, data, key, href) {
2538
+ if (!nodes) return null;
2539
+ const childNodes = nodes.map((node, index) => {
2540
+ if (
2541
+ // @ts-expect-error custom code
2542
+ node.type === "div-container" && node.dataBinding?.childCollectionName && data
2543
+ ) {
2544
+ return renderNode(node, props2, data, index, href);
2545
+ }
2546
+ return renderNode(node, props2, data, index, href);
2547
+ });
2548
+ return childNodes;
2549
+ }
2550
+ function queryObjectToString(query) {
2551
+ if (!query) return "";
2552
+ return Object.entries(query).map(
2553
+ ([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`
2554
+ ).join("&");
2555
+ }
2556
+ function resolveHrefTemplate(template, dataItem) {
2557
+ return template.replace(/\{([^}]+)\}/g, (match, key) => {
2558
+ return dataItem[key] !== void 0 ? dataItem[key] : match;
2559
+ });
2560
+ }
2561
+ const dataToRender = (() => {
2562
+ if (childCollectionData && Array.isArray(childCollectionData)) {
2563
+ return childCollectionData;
2564
+ }
2565
+ if (result && props.node.dataBinding?.responseType === "array") {
2566
+ return result;
2567
+ }
2568
+ if (result && props.node.dataBinding?.responseType === "object") {
2569
+ return [result];
2570
+ }
2571
+ return [props.dataitem];
2572
+ })();
2573
+ const backgroundDataItem = dataToRender.length > 0 ? dataToRender[0] : props.dataitem;
2574
+ const background = generateCompleteBackgroundString(
2575
+ props.node.backgroundLayers,
2576
+ props.assetBaseUrl,
2577
+ backgroundDataItem
2578
+ );
2579
+ const backgroundStyle = background && background !== "" ? { background } : {};
2580
+ const combinedStyles = {
2581
+ ...backgroundStyle
2582
+ };
2583
+ if (props.node.enableBackgroundClipText) {
2584
+ combinedStyles.WebkitBackgroundClip = "text";
2585
+ combinedStyles.backgroundClip = "text";
2586
+ }
2587
+ const renderLink = result && props.node.dataBinding?.responseType === "array" ? true : false;
2588
+ {
2589
+ }
2590
+ let Wrapper;
2591
+ let wrapperProps;
2592
+ let noLinkColor = false;
2593
+ switch (true) {
2594
+ case props.node.componentProperties?.type === "slider":
2595
+ Wrapper = Slider;
2596
+ const largeCols = props.node.componentProperties?.columns || 4;
2597
+ const slidesToShow = {
2598
+ large: largeCols,
2599
+ medium: Math.ceil(largeCols / 2),
2600
+ small: 1
2601
+ };
2602
+ wrapperProps = {
2603
+ ...props.node.componentProperties,
2604
+ slidesToShow
2605
+ };
2606
+ break;
2607
+ case !!(props.node.href || props.href):
2608
+ Wrapper = Link;
2609
+ let href = props.node.href || props.href;
2610
+ if (href?.includes("{")) {
2611
+ href = resolveHrefTemplate(href, props.dataitem);
2612
+ }
2613
+ const currentPath = decodeURIComponent(
2614
+ PathUtility_default.removeTrailingSlash(props.path) + "?" + queryObjectToString(props.query)
2615
+ );
2616
+ const resolvedHref = decodeURIComponent(href || "");
2617
+ const isSelected = currentPath === resolvedHref;
2618
+ noLinkColor = true;
2619
+ wrapperProps = {
2620
+ href,
2621
+ "data-isselected": isSelected,
2622
+ "data-path": currentPath,
2623
+ "data-href": resolvedHref
2624
+ };
2625
+ break;
2626
+ default: {
2627
+ const replacementTag = props.node.replaceDivTagWith;
2628
+ const allowedTags = ["div", "section", "article", "details", "summary"];
2629
+ if (replacementTag && allowedTags.includes(replacementTag)) {
2630
+ {
2631
+ }
2632
+ Wrapper = replacementTag;
2633
+ } else {
2634
+ Wrapper = "div";
2635
+ }
2636
+ wrapperProps = {};
2637
+ break;
2638
+ }
2639
+ }
2640
+ if (isHidden) {
2641
+ return null;
2642
+ }
2643
+ const classNames = [
2644
+ containerPaddingClass,
2645
+ props.node.autoFormat && "auto-format",
2646
+ props.node.bgClass,
2647
+ noLinkColor && "no-link-color",
2648
+ !!props.node.enterAnimation && "enter-animation"
2649
+ ].filter(Boolean).join(" ");
2650
+ return /* @__PURE__ */ jsxs13(React22.Fragment, { children: [
2651
+ /* @__PURE__ */ jsx34(
2652
+ "style",
2653
+ {
2654
+ dangerouslySetInnerHTML: { __html: cssResult.css + animationCSS }
2655
+ }
2656
+ ),
2657
+ /* @__PURE__ */ jsx34(
2658
+ Wrapper,
2659
+ {
2660
+ id: guid,
2661
+ style: combinedStyles,
2662
+ className: classNames || void 0,
2663
+ ...wrapperProps,
2664
+ children: dataToRender.map(
2665
+ (item, idx) => item?.links?.view && renderLink ? renderChildren(
2666
+ props.node.children,
2667
+ props,
2668
+ item,
2669
+ idx,
2670
+ props.href ? void 0 : item?.links?.view
2671
+ )?.map((child, i) => /* @__PURE__ */ jsx34(React22.Fragment, { children: child }, i)) : renderChildren(props.node.children, props, item, idx)
2672
+ )
2673
+ }
2674
+ ),
2675
+ dataBindingProperties && props.node.dataBinding.enablePagination && /* @__PURE__ */ jsx34("div", { children: /* @__PURE__ */ jsx34(
2676
+ Pagination,
2677
+ {
2678
+ path: props.path,
2679
+ query: props.query,
2680
+ dataset: response
2681
+ }
2682
+ ) })
2683
+ ] });
2684
+ };
2685
+ var DivContainer_default = DivContainer;
2686
+
2687
+ // src/components/pageRenderingEngine/PageBodyRenderer.tsx
2688
+ import { jsx as jsx35 } from "react/jsx-runtime";
2689
+ var NodeTypes = {
2690
+ ["paragraph"]: ParagraphNode_default,
2691
+ ["heading"]: HeadingNode_default,
2692
+ ["list"]: ListNode_default,
2693
+ ["quote"]: QuoteNode_default,
2694
+ ["code"]: CodeNode_default,
2695
+ ["image"]: ImageNode_default,
2696
+ ["image-gallery"]: ImageGalleryNode_default,
2697
+ ["horizontalrule"]: HorizontalRuleNode_default,
2698
+ ["widget"]: WidgetNode_default,
2699
+ // ["form-container"]: FormContainerNode,
2700
+ ["div-container"]: DivContainer_default,
2701
+ ["svg-icon"]: SVGIconNode_default,
2702
+ ["embed"]: EmbedNode_default,
2703
+ ["document"]: DocumentNode_default
2704
+ };
2705
+ var PageBodyRenderer = (props) => {
2706
+ let pageBodyTree;
2707
+ if (props.rawBody != void 0 && props.rawBody != null && props.rawBody != "") {
2708
+ try {
2709
+ pageBodyTree = JSON.parse(props.rawBody.toString());
2710
+ } catch (error) {
2711
+ }
2712
+ }
2713
+ let rootNode;
2714
+ if (pageBodyTree && pageBodyTree.root) {
2715
+ rootNode = pageBodyTree.root;
2716
+ }
2717
+ const shouldRenderNode = (node) => {
2718
+ {
2719
+ }
2720
+ if (node.type === "div-container" && node.roleCode) {
2721
+ return validateRoleVisibility(node.roleCode, props.session?.oAuthToken);
2722
+ }
2723
+ return true;
2724
+ };
2725
+ return /* @__PURE__ */ jsx35(React23.Fragment, { children: rootNode && rootNode?.children?.map((node, index) => {
2726
+ {
2727
+ }
2728
+ const SelectedNode = NodeTypes[node.type];
2729
+ if (!shouldRenderNode(node)) {
2730
+ return null;
2731
+ }
2732
+ return /* @__PURE__ */ jsx35(React23.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx35(React23.Fragment, { children: node.type == "layout-container" ? /* @__PURE__ */ jsx35(React23.Fragment, { children: /* @__PURE__ */ jsx35(
2733
+ SelectedNode,
2734
+ {
2735
+ node,
2736
+ firstNode: true,
2737
+ routeParameters: props.routeParameters,
2738
+ query: props.query,
2739
+ session: props.session,
2740
+ host: props.host,
2741
+ path: props.path,
2742
+ apiBaseUrl: props.apiBaseUrl,
2743
+ serviceClient: props.serviceClient,
2744
+ assetBaseUrl: props.assetBaseUrl,
2745
+ device: props.device,
2746
+ widgetRenderer: props.widgetRenderer
2747
+ }
2748
+ ) }) : /* @__PURE__ */ jsx35(React23.Fragment, { children: /* @__PURE__ */ jsx35(
2749
+ SelectedNode,
2750
+ {
2751
+ node,
2752
+ routeParameters: props.routeParameters,
2753
+ query: props.query,
2754
+ session: props.session,
2755
+ host: props.host,
2756
+ path: props.path,
2757
+ apiBaseUrl: props.apiBaseUrl,
2758
+ serviceClient: props.serviceClient,
2759
+ assetBaseUrl: props.assetBaseUrl,
2760
+ device: props.device,
2761
+ widgetRenderer: props.widgetRenderer
2762
+ }
2763
+ ) }) }) }, index);
2764
+ }) });
2765
+ };
2766
+ var PageBodyRenderer_default = PageBodyRenderer;
2767
+
2768
+ // src/components/pageRenderingEngine/EnterAnimationHydrator.tsx
2769
+ import { useEffect } from "react";
2770
+ var ENTER_ANIMATION_SELECTOR = ".enter-animation";
2771
+ function EnterAnimationHydrator() {
2772
+ useEffect(() => {
2773
+ let observer;
2774
+ const observedElements = /* @__PURE__ */ new WeakSet();
2775
+ const revealAnimatedElements = () => {
2776
+ const animatedElements = document.querySelectorAll(ENTER_ANIMATION_SELECTOR);
2777
+ if (!("IntersectionObserver" in window)) {
2778
+ animatedElements.forEach((element) => {
2779
+ element.classList.add("visible");
2780
+ });
2781
+ return;
2782
+ }
2783
+ observer ?? (observer = new IntersectionObserver(
2784
+ (entries) => {
2785
+ entries.forEach((entry) => {
2786
+ if (entry.isIntersecting) {
2787
+ entry.target.classList.add("visible");
2788
+ observer?.unobserve(entry.target);
2789
+ }
2790
+ });
2791
+ },
2792
+ { threshold: 0.1 }
2793
+ ));
2794
+ animatedElements.forEach((element) => {
2795
+ if (element.classList.contains("visible") || observedElements.has(element)) {
2796
+ return;
2797
+ }
2798
+ observedElements.add(element);
2799
+ observer?.observe(element);
2800
+ });
2801
+ };
2802
+ revealAnimatedElements();
2803
+ const mutationObserver = new MutationObserver(revealAnimatedElements);
2804
+ mutationObserver.observe(document.body, {
2805
+ childList: true,
2806
+ subtree: true
2807
+ });
2808
+ return () => {
2809
+ mutationObserver.disconnect();
2810
+ observer?.disconnect();
2811
+ };
2812
+ }, []);
2813
+ return null;
2814
+ }
2815
+
2816
+ // src/components/Toast.tsx
2817
+ import { useCallback, useEffect as useEffect2, useRef, useState } from "react";
2818
+ import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs14 } from "react/jsx-runtime";
2819
+ var Toast = () => {
2820
+ const [showToast, setShowToast] = useState(false);
2821
+ const [message, setMessage] = useState("");
2822
+ const [messageType, setMessageType] = useState("error");
2823
+ const timeoutRef = useRef(null);
2824
+ const closeToast = useCallback(() => {
2825
+ if (timeoutRef.current) {
2826
+ clearTimeout(timeoutRef.current);
2827
+ timeoutRef.current = null;
2828
+ }
2829
+ setShowToast(false);
2830
+ }, []);
2831
+ const showMessage = useCallback((message2, messageType2) => {
2832
+ if (timeoutRef.current) {
2833
+ clearTimeout(timeoutRef.current);
2834
+ }
2835
+ setShowToast(true);
2836
+ setMessage(message2);
2837
+ setMessageType(messageType2);
2838
+ timeoutRef.current = setTimeout(() => {
2839
+ setShowToast(false);
2840
+ timeoutRef.current = null;
2841
+ }, 4e3);
2842
+ }, []);
2843
+ useEffect2(() => {
2844
+ ToastService_default.initialize(showMessage, closeToast);
2845
+ return () => {
2846
+ closeToast();
2847
+ ToastService_default.initialize(() => {
2848
+ }, () => {
2849
+ });
2850
+ };
2851
+ }, [closeToast, showMessage]);
2852
+ return /* @__PURE__ */ jsx36(Fragment7, { children: showToast && /* @__PURE__ */ jsx36("div", { className: "fixed top-2 flex justify-center w-1/2 max-w-xl left-1/2 -translate-x-1/2", style: { zIndex: 1e3 }, children: /* @__PURE__ */ jsxs14("div", { className: `w-full items-center flex justify-between p-3 rounded-md relative shadow border bg-${messageType}-soft`, children: [
2853
+ /* @__PURE__ */ jsx36(
2854
+ "span",
2855
+ {
2856
+ className: "font-medium text-inherit text-sm",
2857
+ style: { whiteSpace: "pre-line" },
2858
+ children: message
2859
+ }
2860
+ ),
2861
+ /* @__PURE__ */ jsx36("button", { className: "absolute right-2 top-2 ml-2 focus:outline-none", onClick: closeToast, children: /* @__PURE__ */ jsx36(
2862
+ "svg",
2863
+ {
2864
+ xmlns: "http://www.w3.org/2000/svg",
2865
+ className: "h-4 w-4",
2866
+ fill: "none",
2867
+ viewBox: "0 0 24 24",
2868
+ stroke: "currentColor",
2869
+ children: /* @__PURE__ */ jsx36("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M6 18L18 6M6 6l12 12" })
2870
+ }
2871
+ ) })
2872
+ ] }) }) });
2873
+ };
2874
+ var Toast_default = Toast;
2875
+
2876
+ // src/components/NavigationTabsV2.tsx
2877
+ import Link2 from "next/link";
2878
+ import { usePathname } from "next/navigation";
2879
+ import { jsx as jsx37 } from "react/jsx-runtime";
2880
+ function resolveRoutePlaceholders(route, params) {
2881
+ return route.replace(/\{([^}]+)\}/g, (match, key) => {
2882
+ const value = params[key];
2883
+ if (value === void 0 || value === null) {
2884
+ console.warn(`No value found for route param: ${key}`);
2885
+ return "";
2886
+ }
2887
+ return value;
2888
+ });
2889
+ }
2890
+ var NavigationTabsV2 = ({ tabs, params = {} }) => {
2891
+ const pathname = usePathname();
2892
+ const shouldHideTabs = pathname?.includes("/add");
2893
+ if (shouldHideTabs) return null;
2894
+ const mappedTabs = tabs?.sort((a, b) => a.displayOrder - b.displayOrder)?.map((tab) => ({
2895
+ tabTitle: tab.tabTitle,
2896
+ displayOrder: tab.displayOrder,
2897
+ landingPageUrl: resolveRoutePlaceholders(
2898
+ tab.landingPageUrl,
2899
+ params
2900
+ ),
2901
+ isActive: tab.isActive
2902
+ })) || [];
2903
+ if (mappedTabs.length === 0) return null;
2904
+ return /* @__PURE__ */ jsx37("div", { className: "flex border-b bg-white rounded-t mb-3", children: mappedTabs.map(({ tabTitle, landingPageUrl, isActive }) => {
2905
+ return /* @__PURE__ */ jsx37(Link2, { href: landingPageUrl, className: "-mb-px", children: /* @__PURE__ */ jsx37(
2906
+ "div",
2907
+ {
2908
+ className: `text-sm font-medium border-b-2 px-6 py-2 transition
2909
+ ${isActive ? "bg-info-base" : "bg-neutral-weak "}`,
2910
+ children: tabTitle
2911
+ }
2912
+ ) }, landingPageUrl);
2913
+ }) });
2914
+ };
2915
+ var NavigationTabsV2_default = NavigationTabsV2;
2916
+
2917
+ // src/components/dataForm/DataList.tsx
2918
+ import React27, { useEffect as useEffect3, useState as useState2, useCallback as useCallback2, useReducer } from "react";
2919
+ import { useRouter } from "next/navigation";
2920
+
2921
+ // src/components/dataForm/NoContentView.tsx
2922
+ import React25 from "react";
2923
+ import { jsx as jsx38 } from "react/jsx-runtime";
2924
+ var NoContentView = (props) => {
2925
+ return /* @__PURE__ */ jsx38(React25.Fragment, { children: props.isDataFound === false && props.children });
2926
+ };
2927
+ var NoContentView_default = NoContentView;
2928
+
2929
+ // src/components/dataForm/ContentView.tsx
2930
+ import React26 from "react";
2931
+ import { jsx as jsx39, jsxs as jsxs15 } from "react/jsx-runtime";
2932
+ var ContentView = (props) => {
2933
+ return /* @__PURE__ */ jsxs15(React26.Fragment, { children: [
2934
+ props.isDataFound == null && /* @__PURE__ */ jsx39("div", { className: "", children: /* @__PURE__ */ jsxs15("div", { className: "bg-gray-200 rounded-md p-4 animate-pulse", children: [
2935
+ /* @__PURE__ */ jsxs15("div", { className: "flex items-center mb-4", children: [
2936
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 h-8 w-8 rounded-full animate-pulse" }),
2937
+ /* @__PURE__ */ jsxs15("div", { className: "ml-2", children: [
2938
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 h-3 w-16 animate-pulse" }),
2939
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 h-2 w-12 animate-pulse" })
2940
+ ] })
2941
+ ] }),
2942
+ /* @__PURE__ */ jsxs15("div", { className: "grid grid-cols-3 gap-4 mt-6", children: [
2943
+ /* @__PURE__ */ jsxs15("div", { className: "animate-pulse", children: [
2944
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-12 mb-2" }),
2945
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-24 mb-2" }),
2946
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-32 mb-2" }),
2947
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-16 mb-2" }),
2948
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-28 mb-2" })
2949
+ ] }),
2950
+ /* @__PURE__ */ jsxs15("div", { className: "animate-pulse", children: [
2951
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-12 mb-2" }),
2952
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-24 mb-2" }),
2953
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-32 mb-2" }),
2954
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-16 mb-2" }),
2955
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-28 mb-2" })
2956
+ ] }),
2957
+ /* @__PURE__ */ jsxs15("div", { className: "animate-pulse", children: [
2958
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-12 mb-2" }),
2959
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-24 mb-2" }),
2960
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-32 mb-2" }),
2961
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-16 mb-2" }),
2962
+ /* @__PURE__ */ jsx39("div", { className: "bg-gray-300 rounded-full h-3 w-28 mb-2" })
2963
+ ] })
2964
+ ] })
2965
+ ] }) }),
2966
+ props.isDataFound === true && props.children
2967
+ ] });
2968
+ };
2969
+ var ContentView_default = ContentView;
2970
+
2971
+ // src/FormReducer.tsx
2972
+ var FORM_INPUT_UPDATE = "FORM_INPUT_UPDATE";
2973
+ var FORM_INITIAL_UPDATE = "FORM_INITIAL_UPDATE";
2974
+ function setNestedProperty(obj, path, value) {
2975
+ if (path.includes(".")) {
2976
+ const keys = path.split(".");
2977
+ const lastKey = keys.pop();
2978
+ const newObj = { ...obj };
2979
+ let current = newObj;
2980
+ keys.forEach((key) => {
2981
+ current[key] = { ...current[key] };
2982
+ current = current[key];
2983
+ });
2984
+ current[lastKey] = value;
2985
+ return newObj;
2986
+ }
2987
+ return {
2988
+ ...obj,
2989
+ [path]: value
2990
+ };
2991
+ }
2992
+ function FormReducer(state, action) {
2993
+ switch (action.type) {
2994
+ case FORM_INPUT_UPDATE:
2995
+ if (!action.name) return state;
2996
+ return {
2997
+ inputValues: setNestedProperty(
2998
+ state.inputValues,
2999
+ action.name.toString(),
3000
+ action.value
3001
+ ),
3002
+ lastPropertyChanged: action.name.toString()
3003
+ };
3004
+ case FORM_INITIAL_UPDATE:
3005
+ return {
3006
+ inputValues: { ...action.values },
3007
+ lastPropertyChanged: action.name?.toString() || ""
3008
+ };
3009
+ default:
3010
+ return state;
3011
+ }
3012
+ }
3013
+ var FormReducer_default = FormReducer;
3014
+
3015
+ // src/components/dataForm/DataList.tsx
3016
+ import { Fragment as Fragment8, jsx as jsx40, jsxs as jsxs16 } from "react/jsx-runtime";
3017
+ var DataList = (props) => {
3018
+ const router = useRouter();
3019
+ let builder = new OdataBuilder(props.path);
3020
+ let orderBy = "";
3021
+ let activePageNumber = 0;
3022
+ let pages = 0;
3023
+ console.log(props.addLinkText);
3024
+ const [isDataFound, setIsDataFound] = useState2(null);
3025
+ const [searchTerm, setSearchTerm] = useState2(props.query?.searchTerm ?? "");
3026
+ useEffect3(() => {
3027
+ if (props?.dataset) {
3028
+ if (props?.dataset.result && props.dataset.result.length > 0) {
3029
+ setIsDataFound(true);
3030
+ } else {
3031
+ setIsDataFound(false);
3032
+ }
3033
+ }
3034
+ }, [props.dataset]);
3035
+ useEffect3(() => {
3036
+ if (!props.query?.["$filter"] || !props.filters) return;
3037
+ const filterQuery = props.query["$filter"];
3038
+ props.filters.forEach((filter) => {
3039
+ const regex = new RegExp(`${filter.name}\\s+eq\\s+'?([^']+)'?`);
3040
+ const match = filterQuery.match(regex);
3041
+ if (match) {
3042
+ dispatch({
3043
+ type: FORM_INPUT_UPDATE,
3044
+ name: filter.name,
3045
+ value: match[1]
3046
+ });
3047
+ }
3048
+ });
3049
+ }, [props.query, props.filters]);
3050
+ function getNestedProperty2(obj, path) {
3051
+ if (path.includes(".")) {
3052
+ return path.split(".").reduce((prev, curr) => prev ? prev[curr] : null, obj);
3053
+ } else if (Array.isArray(obj[path])) {
3054
+ return obj[path].map((item, index) => /* @__PURE__ */ jsx40("div", { children: item }, index));
3055
+ } else {
3056
+ return obj[path];
3057
+ }
3058
+ }
3059
+ const initialState = {
3060
+ inputValues: {},
3061
+ lastPropertyChanged: ""
3062
+ };
3063
+ const [formState, dispatch] = useReducer(FormReducer_default, initialState);
3064
+ const getSearchableColumns = () => {
3065
+ return props.columns?.filter((c) => c.isSearchable)?.map((c) => c.name)?.join(",");
3066
+ };
3067
+ const handleFilterChange = useCallback2(
3068
+ (updatedValues) => {
3069
+ dispatch({
3070
+ type: FORM_INPUT_UPDATE,
3071
+ name: updatedValues.name,
3072
+ value: updatedValues.value
3073
+ });
3074
+ console.log("ddddaaa", updatedValues.value);
3075
+ let builder2 = new OdataBuilder(props.path);
3076
+ builder2 = builder2.setQuery(props.query);
3077
+ if (updatedValues.value != "" && updatedValues.value != null) {
3078
+ const filter = props.filters?.find((x) => x.name == updatedValues.name);
3079
+ if (filter?.dataTypeCode == "number") {
3080
+ router.push(
3081
+ builder2.getNewFilterUrl(
3082
+ updatedValues.name.toString() + " eq " + updatedValues.value
3083
+ )
3084
+ );
3085
+ } else {
3086
+ router.push(
3087
+ builder2.getNewFilterUrl(
3088
+ updatedValues.name.toString() + " eq '" + updatedValues.value + "'"
3089
+ )
3090
+ );
3091
+ }
3092
+ } else {
3093
+ router.push(builder2.getNewFilterUrl(""));
3094
+ }
3095
+ },
3096
+ [dispatch, props, router]
3097
+ );
3098
+ useEffect3(() => {
3099
+ if (!props.columns.some((col) => col.isSearchable)) {
3100
+ return;
3101
+ }
3102
+ if (searchTerm === (props.query?.searchTerm ?? "")) {
3103
+ return;
3104
+ }
3105
+ const timeout = setTimeout(() => {
3106
+ const builder2 = new OdataBuilder(props.path);
3107
+ builder2.setQuery({
3108
+ ...props.query,
3109
+ searchTerm,
3110
+ searchCols: getSearchableColumns(),
3111
+ $skip: "0"
3112
+ });
3113
+ router.push(builder2.getUrl());
3114
+ }, 500);
3115
+ return () => clearTimeout(timeout);
3116
+ }, [searchTerm]);
3117
+ builder = builder.setQuery(props.query);
3118
+ orderBy = builder.getOrderBy();
3119
+ activePageNumber = builder.getPageNumber(Constants.pagesize);
3120
+ let label = "";
3121
+ if (props.dataset && props.dataset.count) {
3122
+ pages = Math.ceil(props.dataset.count / Constants.pagesize);
3123
+ label = `Showing ${(activePageNumber - 1) * Constants.pagesize + 1} - `;
3124
+ if (activePageNumber * Constants.pagesize > props.dataset.count) {
3125
+ label = label + `${props.dataset.count} of ${props.dataset.count} results`;
3126
+ } else {
3127
+ label = label + `${activePageNumber * Constants.pagesize} of ${props.dataset.count} results`;
3128
+ }
3129
+ }
3130
+ const renderPageNumbers = () => {
3131
+ if (pages <= 10) {
3132
+ return Array.from({ length: pages }, (_, index) => index + 1).map(
3133
+ (page) => /* @__PURE__ */ jsx40(React27.Fragment, { children: activePageNumber !== page ? /* @__PURE__ */ jsx40(
3134
+ Hyperlink,
3135
+ {
3136
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3137
+ href: builder.getNewPageUrl(page),
3138
+ children: page
3139
+ }
3140
+ ) : /* @__PURE__ */ jsx40("span", { className: "px-3 py-1 border-t border-b border-gray-300 bg-primary-base", children: page }) }, page)
3141
+ );
3142
+ } else {
3143
+ const showFirstPages = activePageNumber <= 5;
3144
+ const showLastPages = activePageNumber > pages - 5;
3145
+ if (showFirstPages) {
3146
+ return /* @__PURE__ */ jsxs16(Fragment8, { children: [
3147
+ Array.from({ length: 8 }, (_, index) => index + 1).map((page) => /* @__PURE__ */ jsx40(React27.Fragment, { children: activePageNumber !== page ? /* @__PURE__ */ jsx40(
3148
+ Hyperlink,
3149
+ {
3150
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3151
+ href: builder.getNewPageUrl(page),
3152
+ children: page
3153
+ }
3154
+ ) : /* @__PURE__ */ jsx40("span", { className: "px-3 py-1 border-t border-b border-gray-300 bg-primary-base", children: page }) }, page)),
3155
+ /* @__PURE__ */ jsx40("span", { className: "px-2 py-1", children: "..." }),
3156
+ /* @__PURE__ */ jsx40(
3157
+ Hyperlink,
3158
+ {
3159
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3160
+ href: builder.getNewPageUrl(pages - 1),
3161
+ children: pages - 1
3162
+ }
3163
+ ),
3164
+ /* @__PURE__ */ jsx40(
3165
+ Hyperlink,
3166
+ {
3167
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3168
+ href: builder.getNewPageUrl(pages),
3169
+ children: pages
3170
+ }
3171
+ ),
3172
+ /* @__PURE__ */ jsx40("div", { className: "relative inline-block", children: /* @__PURE__ */ jsxs16(
3173
+ "select",
3174
+ {
3175
+ className: " py-1 border border-gray-300 bg-white text-gray-700 appearance-none rounded-none",
3176
+ value: activePageNumber > 8 && activePageNumber < pages - 1 ? activePageNumber : "",
3177
+ onChange: (e) => {
3178
+ const page = parseInt(e.target.value);
3179
+ if (page) {
3180
+ router.push(builder.getNewPageUrl(page));
3181
+ }
3182
+ },
3183
+ children: [
3184
+ /* @__PURE__ */ jsx40("option", { className: "", value: "", children: "Jump to" }),
3185
+ Array.from(
3186
+ { length: Math.max(0, pages - 10) },
3187
+ (_, index) => index + 9
3188
+ ).map((page) => /* @__PURE__ */ jsx40("option", { value: page, children: page }, page))
3189
+ ]
3190
+ }
3191
+ ) })
3192
+ ] });
3193
+ } else if (showLastPages) {
3194
+ return /* @__PURE__ */ jsxs16(Fragment8, { children: [
3195
+ /* @__PURE__ */ jsx40(
3196
+ Hyperlink,
3197
+ {
3198
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3199
+ href: builder.getNewPageUrl(1),
3200
+ children: "1"
3201
+ }
3202
+ ),
3203
+ /* @__PURE__ */ jsx40(
3204
+ Hyperlink,
3205
+ {
3206
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3207
+ href: builder.getNewPageUrl(2),
3208
+ children: "2"
3209
+ }
3210
+ ),
3211
+ /* @__PURE__ */ jsx40("span", { className: "px-2 py-1", children: "..." }),
3212
+ Array.from({ length: 8 }, (_, index) => pages - 7 + index).map(
3213
+ (page) => /* @__PURE__ */ jsx40(React27.Fragment, { children: activePageNumber !== page ? /* @__PURE__ */ jsx40(
3214
+ Hyperlink,
3215
+ {
3216
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3217
+ href: builder.getNewPageUrl(page),
3218
+ children: page
3219
+ }
3220
+ ) : /* @__PURE__ */ jsx40("span", { className: "px-3 py-1 border-t border-b border-gray-300 bg-primary-base", children: page }) }, page)
3221
+ )
3222
+ ] });
3223
+ } else {
3224
+ return /* @__PURE__ */ jsxs16(Fragment8, { children: [
3225
+ /* @__PURE__ */ jsx40(
3226
+ Hyperlink,
3227
+ {
3228
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3229
+ href: builder.getNewPageUrl(1),
3230
+ children: "1"
3231
+ }
3232
+ ),
3233
+ /* @__PURE__ */ jsx40(
3234
+ Hyperlink,
3235
+ {
3236
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3237
+ href: builder.getNewPageUrl(2),
3238
+ children: "2"
3239
+ }
3240
+ ),
3241
+ /* @__PURE__ */ jsx40("span", { className: "px-2 py-1", children: "..." }),
3242
+ Array.from(
3243
+ { length: 5 },
3244
+ (_, index) => activePageNumber - 2 + index
3245
+ ).map((page) => /* @__PURE__ */ jsx40(React27.Fragment, { children: activePageNumber !== page ? /* @__PURE__ */ jsx40(
3246
+ Hyperlink,
3247
+ {
3248
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3249
+ href: builder.getNewPageUrl(page),
3250
+ children: page
3251
+ }
3252
+ ) : /* @__PURE__ */ jsx40("span", { className: "px-3 py-1 border-t border-b border-gray-300 bg-primary-base", children: page }) }, page)),
3253
+ /* @__PURE__ */ jsx40("span", { className: "px-2 py-1", children: "..." }),
3254
+ /* @__PURE__ */ jsx40(
3255
+ Hyperlink,
3256
+ {
3257
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3258
+ href: builder.getNewPageUrl(pages - 1),
3259
+ children: pages - 1
3260
+ }
3261
+ ),
3262
+ /* @__PURE__ */ jsx40(
3263
+ Hyperlink,
3264
+ {
3265
+ className: "px-3 py-1 border-t border-b border-gray-300 bg-white text-gray-700 hover:bg-gray-100",
3266
+ href: builder.getNewPageUrl(pages),
3267
+ children: pages
3268
+ }
3269
+ ),
3270
+ /* @__PURE__ */ jsx40("div", { className: "relative inline-block", children: /* @__PURE__ */ jsxs16(
3271
+ "select",
3272
+ {
3273
+ className: "px-2 py-1 border border-gray-300 bg-white text-gray-700 appearance-none rounded-none",
3274
+ value: activePageNumber > 2 && activePageNumber < pages - 1 ? activePageNumber : "",
3275
+ onChange: (e) => {
3276
+ const page = parseInt(e.target.value);
3277
+ if (page) {
3278
+ router.push(builder.getNewPageUrl(page));
3279
+ }
3280
+ },
3281
+ children: [
3282
+ /* @__PURE__ */ jsx40("option", { value: "", children: "Jump to" }),
3283
+ Array.from({ length: pages - 4 }, (_, index) => index + 3).filter((page) => page > 2 && page < pages - 1).map((page) => /* @__PURE__ */ jsx40("option", { value: page, children: page }, page))
3284
+ ]
3285
+ }
3286
+ ) })
3287
+ ] });
3288
+ }
3289
+ }
3290
+ };
3291
+ return /* @__PURE__ */ jsxs16(React27.Fragment, { children: [
3292
+ /* @__PURE__ */ jsxs16(ContentView_default, { isDataFound, children: [
3293
+ (props.title || props.filters || props.addLinkHref) && /* @__PURE__ */ jsxs16(
3294
+ "div",
3295
+ {
3296
+ className: `flex justify-between items-center bg-white pl-6 pr-2 h-14 mb-3 shadow-sm rounded-md sticky top-0`,
3297
+ children: [
3298
+ props.title ? /* @__PURE__ */ jsx40("div", { className: "inline-flex items-center gap-2", children: /* @__PURE__ */ jsx40("h2", { className: "text-lg font-semibold text-black-800", children: props.title }) }) : /* @__PURE__ */ jsx40("div", {}),
3299
+ /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-3", children: [
3300
+ props.columns.some((col) => col.isSearchable) && /* @__PURE__ */ jsx40(
3301
+ InputControl_default,
3302
+ {
3303
+ name: "Search_input",
3304
+ controlType: InputControlType_default.lineTextInput,
3305
+ value: searchTerm,
3306
+ callback: (e) => setSearchTerm(e.value),
3307
+ attributes: {
3308
+ placeholder: `Search by ${props.columns.filter((col) => col.isSearchable).map((col) => col.label).join(", ")}`
3309
+ }
3310
+ }
3311
+ ),
3312
+ props.filters && props.filters.map((filter) => /* @__PURE__ */ jsx40(
3313
+ InputControl_default,
3314
+ {
3315
+ name: filter.name,
3316
+ controlType: InputControlType_default.select,
3317
+ value: formState.inputValues[filter.name],
3318
+ dataSource: filter.servicePath,
3319
+ dataKeyFieldName: filter.dataKeyFieldName,
3320
+ dataTextFieldName: filter.dataTextFieldName,
3321
+ serviceClient: props.serviceClient,
3322
+ callback: handleFilterChange,
3323
+ attributes: { placeholder: filter.placeholder }
3324
+ },
3325
+ filter.name
3326
+ )),
3327
+ props.addLinkHref && /* @__PURE__ */ jsxs16(
3328
+ Hyperlink,
3329
+ {
3330
+ className: "gap-1",
3331
+ linkType: "Primary" /* Solid */,
3332
+ href: props.addLinkHref,
3333
+ children: [
3334
+ /* @__PURE__ */ jsx40(Icon_default, { name: "plus", className: "w-4 h-4" }),
3335
+ /* @__PURE__ */ jsx40("span", { className: "text-sm font-medium", children: props.addLinkText || "Add New" })
3336
+ ]
3337
+ }
3338
+ )
3339
+ ] })
3340
+ ]
3341
+ }
3342
+ ),
3343
+ /* @__PURE__ */ jsx40("div", { className: "flex-1 overflow-y-auto justify-end bg-white rounded shadow h-[calc(100vh-14rem)]", children: /* @__PURE__ */ jsxs16("table", { className: "w-full divide-y divide-gray-200", children: [
3344
+ /* @__PURE__ */ jsx40("thead", { className: "bg-gray-50 sticky top-0", children: /* @__PURE__ */ jsx40("tr", { children: props?.columns?.map((column) => {
3345
+ let url = builder.getNewOrderByUrl(column.name);
3346
+ let icon = "chevronUpDown";
3347
+ if (orderBy.includes(`${column.name} desc`)) {
3348
+ icon = "chevronDown";
3349
+ url = builder.getNewOrderByUrl(column.name);
3350
+ } else if (orderBy.includes(`${column.name}`)) {
3351
+ icon = "chevronUp";
3352
+ url = builder.getNewOrderByUrl(column.name + " desc");
3353
+ }
3354
+ return /* @__PURE__ */ jsx40(
3355
+ "th",
3356
+ {
3357
+ className: "px-6 py-3 text-left font-medium bg-neutral-soft " + (column.enableSorting ? "cursor-pointer " : "") + column.width + (column.controlType == ViewControlTypes_default.money ? " text-right" : ""),
3358
+ children: /* @__PURE__ */ jsx40(
3359
+ Hyperlink,
3360
+ {
3361
+ href: column.enableSorting ? url : void 0,
3362
+ className: "!text-neutral-contrast ",
3363
+ children: /* @__PURE__ */ jsxs16("span", { className: "flex items-center space-x-1", children: [
3364
+ /* @__PURE__ */ jsx40("span", { className: "text-black", children: column.label }),
3365
+ column.enableSorting && /* @__PURE__ */ jsx40(Icon_default, { className: "w-4 h-4", name: icon })
3366
+ ] })
3367
+ }
3368
+ )
3369
+ },
3370
+ column.name
3371
+ );
3372
+ }) }) }),
3373
+ /* @__PURE__ */ jsx40("tbody", { className: "divide-y divide-gray-200 ", children: props.dataset?.result?.map((dataitem, index) => {
3374
+ let validityClass = "";
3375
+ console.log("dataitem", dataitem);
3376
+ if (props.recordValidityColumnName && getNestedProperty2(dataitem, props.recordValidityColumnName) == false) {
3377
+ validityClass = "bg-alert-200";
3378
+ }
3379
+ return /* @__PURE__ */ jsx40("tr", { className: validityClass, children: props?.columns?.map((column, colindex) => {
3380
+ console.log("column", column);
3381
+ return /* @__PURE__ */ jsx40(React27.Fragment, { children: /* @__PURE__ */ jsx40(
3382
+ "td",
3383
+ {
3384
+ className: "px-6 py-2 whitespace-normal " + (column.controlType == ViewControlTypes_default.money ? "" : ""),
3385
+ children: column.addhref === true ? /* @__PURE__ */ jsx40(
3386
+ Hyperlink,
3387
+ {
3388
+ className: "",
3389
+ href: `https://${dataitem[column.name]}`,
3390
+ children: /* @__PURE__ */ jsx40(
3391
+ ViewControl_default,
3392
+ {
3393
+ controlType: column.controlType,
3394
+ value: getNestedProperty2(
3395
+ dataitem,
3396
+ column.name
3397
+ ),
3398
+ format: column.format,
3399
+ customProps: column.customProps
3400
+ }
3401
+ )
3402
+ }
3403
+ ) : column.showAsLink ? /* @__PURE__ */ jsx40(
3404
+ Hyperlink,
3405
+ {
3406
+ href: props.path + dataitem[props.columns[0].name] + "/" + (dataitem.linkUrlSegment ?? column.linkUrlSegment),
3407
+ children: /* @__PURE__ */ jsx40(
3408
+ ViewControl_default,
3409
+ {
3410
+ controlType: column.controlType,
3411
+ value: getNestedProperty2(dataitem, column.name) || column.emptyValueLabel,
3412
+ format: column.format,
3413
+ customProps: column.customProps
3414
+ }
3415
+ )
3416
+ }
3417
+ ) : /* @__PURE__ */ jsx40(
3418
+ ViewControl_default,
3419
+ {
3420
+ controlType: column.controlType,
3421
+ value: getNestedProperty2(dataitem, column.name),
3422
+ format: column.format,
3423
+ customProps: column.customProps
3424
+ }
3425
+ )
3426
+ }
3427
+ ) }, colindex);
3428
+ }) }, index);
3429
+ }) })
3430
+ ] }) }),
3431
+ /* @__PURE__ */ jsx40("div", { className: "pt-4 border-t border-t-gray-50 sticky bottom-0 h-11 mt-2 ", children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center justify-between", children: [
3432
+ /* @__PURE__ */ jsx40("div", { className: "text-gray-700", children: label }),
3433
+ /* @__PURE__ */ jsxs16("div", { className: "flex space-x-2 items-center", children: [
3434
+ activePageNumber > 1 && /* @__PURE__ */ jsx40(
3435
+ Hyperlink,
3436
+ {
3437
+ className: "px-3 py-1 rounded-l-md border border-gray-300 bg-white text-gray-500 hover:bg-gray-200",
3438
+ href: builder.getNewPageUrl(activePageNumber - 1),
3439
+ children: "Prev"
3440
+ }
3441
+ ),
3442
+ activePageNumber <= 1 && /* @__PURE__ */ jsx40("div", { className: "px-3 py-1 rounded-l-md border border-gray-300 bg-gray-200 text-gray-500 hover:bg-gray-200", children: "Prev" }),
3443
+ renderPageNumbers(),
3444
+ activePageNumber < pages && /* @__PURE__ */ jsx40(
3445
+ Hyperlink,
3446
+ {
3447
+ className: "px-3 py-1 rounded-r-md border border-gray-300 bg-white text-gray-500 hover:bg-gray-200",
3448
+ href: builder.getNewPageUrl(activePageNumber + 1),
3449
+ children: "Next"
3450
+ }
3451
+ ),
3452
+ activePageNumber >= pages && /* @__PURE__ */ jsx40("div", { className: "px-3 py-1 rounded-r-md border border-gray-300 bg-gray-200 text-gray-500", children: "Next" })
3453
+ ] })
3454
+ ] }) })
3455
+ ] }),
3456
+ /* @__PURE__ */ jsxs16(NoContentView_default, { isDataFound, children: [
3457
+ (props.title || props.filters || props.addLinkHref) && /* @__PURE__ */ jsxs16(
3458
+ "div",
3459
+ {
3460
+ className: `flex justify-between items-center bg-white pl-6 pr-2 h-14 mb-3 shadow-sm rounded-md border-b border-neutral-200`,
3461
+ children: [
3462
+ props.title ? /* @__PURE__ */ jsx40("div", { className: "inline-flex items-center gap-2", children: /* @__PURE__ */ jsx40("h2", { className: "text-lg font-semibold text-black", children: props.title }) }) : /* @__PURE__ */ jsx40("div", {}),
3463
+ /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-3", children: [
3464
+ props.columns.some((col) => col.isSearchable) && /* @__PURE__ */ jsx40(
3465
+ InputControl_default,
3466
+ {
3467
+ name: "Search_input",
3468
+ controlType: InputControlType_default.lineTextInput,
3469
+ value: searchTerm,
3470
+ callback: (e) => setSearchTerm(e.value),
3471
+ attributes: {
3472
+ placeholder: `Search by ${props.columns.filter((col) => col.isSearchable).map((col) => col.label).join(", ")}`
3473
+ }
3474
+ }
3475
+ ),
3476
+ props.filters && props.filters.map((filter) => /* @__PURE__ */ jsx40(
3477
+ InputControl_default,
3478
+ {
3479
+ name: filter.name,
3480
+ controlType: InputControlType_default.select,
3481
+ value: formState.inputValues[filter.name],
3482
+ dataSource: filter.servicePath,
3483
+ dataKeyFieldName: filter.dataKeyFieldName,
3484
+ dataTextFieldName: filter.dataTextFieldName,
3485
+ serviceClient: props.serviceClient,
3486
+ callback: handleFilterChange,
3487
+ attributes: { placeholder: filter.placeholder }
3488
+ },
3489
+ filter.name
3490
+ )),
3491
+ props.addLinkHref && /* @__PURE__ */ jsxs16(
3492
+ Hyperlink,
3493
+ {
3494
+ className: "gap-1",
3495
+ linkType: "Primary" /* Solid */,
3496
+ href: props.addLinkHref,
3497
+ children: [
3498
+ /* @__PURE__ */ jsx40(Icon_default, { name: "plus", className: "w-4 h-4" }),
3499
+ /* @__PURE__ */ jsx40("span", { className: "text-sm font-medium", children: props.addLinkText || "Add New" })
3500
+ ]
3501
+ }
3502
+ )
3503
+ ] })
3504
+ ]
3505
+ }
3506
+ ),
3507
+ /* @__PURE__ */ jsxs16("div", { className: "flex-grow overflow-y-auto justify-end bg-white rounded shadow h-[75vh]", children: [
3508
+ /* @__PURE__ */ jsx40("div", { children: /* @__PURE__ */ jsx40("table", { className: "w-full divide-y divide-gray-200", children: /* @__PURE__ */ jsx40("thead", { className: "bg-gray-50", children: /* @__PURE__ */ jsx40("tr", { children: props?.columns?.map((column) => {
3509
+ let url = builder.getNewOrderByUrl(column.name);
3510
+ let icon = "chevronUpDown";
3511
+ if (orderBy.includes(`${column.name} desc`)) {
3512
+ icon = "chevronDown";
3513
+ url = builder.getNewOrderByUrl(column.name);
3514
+ } else if (orderBy.includes(`${column.name}`)) {
3515
+ icon = "chevronUp";
3516
+ url = builder.getNewOrderByUrl(column.name + " desc");
3517
+ }
3518
+ return /* @__PURE__ */ jsx40(
3519
+ "th",
3520
+ {
3521
+ className: "px-6 py-3 text-left font-medium bg-neutral-soft " + (column.enableSorting ? "cursor-pointer " : "") + column.width + (column.controlType == ViewControlTypes_default.money ? " text-right" : ""),
3522
+ children: /* @__PURE__ */ jsx40(
3523
+ Hyperlink,
3524
+ {
3525
+ href: column.enableSorting ? url : void 0,
3526
+ className: "text-body-950",
3527
+ children: /* @__PURE__ */ jsxs16("span", { className: "flex items-center space-x-1", children: [
3528
+ /* @__PURE__ */ jsx40("span", { children: column.label }),
3529
+ column.enableSorting && /* @__PURE__ */ jsx40(Icon_default, { className: "w-4 h-4", name: icon })
3530
+ ] })
3531
+ }
3532
+ )
3533
+ },
3534
+ column.name
3535
+ );
3536
+ }) }) }) }) }),
3537
+ /* @__PURE__ */ jsx40("div", { className: "w-full text-center bg-transparent pt-5", children: "There are no entries in the table at the moment." })
3538
+ ] })
3539
+ ] })
3540
+ ] });
3541
+ };
3542
+ var DataList_default = DataList;
3543
+
3544
+ // src/components/dataForm/DataListRenderer.tsx
3545
+ import React28, { useState as useState3, useEffect as useEffect4 } from "react";
3546
+ import { usePathname as usePathname2 } from "next/navigation";
3547
+ import { jsx as jsx41, jsxs as jsxs17 } from "react/jsx-runtime";
3548
+ var viewControlMap = {
3549
+ number: ViewControlTypes.number,
3550
+ lineText: ViewControlTypes.lineText,
3551
+ multilineText: ViewControlTypes.multilineText,
3552
+ date: ViewControlTypes.date,
3553
+ boolean: ViewControlTypes.boolean
3554
+ };
3555
+ function resolveRoutePlaceholders2(route, params) {
3556
+ return route.replace(/\{([^}]+)\}/g, (match, key) => {
3557
+ const value = params[key];
3558
+ if (value === void 0 || value === null) {
3559
+ console.warn(`No value found for route param: ${key}`);
3560
+ return "";
3561
+ }
3562
+ return value;
3563
+ });
3564
+ }
3565
+ function mapApiToColumns(siteForm) {
3566
+ const cols = siteForm?.siteFormDataList?.siteFormDataListColumns ?? [];
3567
+ return cols.map((col) => ({
3568
+ label: col.label,
3569
+ name: col.columnName,
3570
+ controlType: viewControlMap[col.controlTypeCode] ?? ViewControlTypes.lineText,
3571
+ enableSorting: col.enableSorting ?? false,
3572
+ isSearchable: col.isSearchable ?? false,
3573
+ width: "w-2/12",
3574
+ showAsLink: col.showAsLink ?? false,
3575
+ linkUrlSegment: col.linkUrlSegment ?? void 0,
3576
+ emptyValueLabel: col.emptyValueLabel ?? void 0
3577
+ }));
3578
+ }
3579
+ function mapApiToFilters(siteForm) {
3580
+ const filter = siteForm?.siteFormDataList?.siteFormDataListFilters ?? [];
3581
+ return filter.map((fil) => ({
3582
+ placeholder: fil.placeholder,
3583
+ name: fil.columnName,
3584
+ servicePath: fil.serviceRoute,
3585
+ dataTextFieldName: fil.dataTextFieldName,
3586
+ controlType: SelectWithSearchInput_default,
3587
+ dataKeyFieldName: fil.dataKeyFieldName,
3588
+ dataTypeCode: fil.isKeyNumber ? "number" : "string"
3589
+ }));
3590
+ }
3591
+ var DataListRenderer = ({
3592
+ formDefinition,
3593
+ apiBaseUrl,
3594
+ session,
3595
+ params,
3596
+ tabs,
3597
+ query,
3598
+ path,
3599
+ widgetProps
3600
+ }) => {
3601
+ const serviceClient = new ServiceClient_default(apiBaseUrl, session);
3602
+ const [columns, setColumns] = useState3([]);
3603
+ const [dataset, setDataset] = useState3();
3604
+ const [filter, setFilters] = useState3([]);
3605
+ const [addLinkHref, setAddLinkHref] = useState3("");
3606
+ const [addLinkText, setAddLinkText] = useState3("");
3607
+ const [serviceRoute, setServiceRoute] = useState3("");
3608
+ const pathname = usePathname2();
3609
+ useEffect4(() => {
3610
+ if (!formDefinition) return;
3611
+ setColumns(mapApiToColumns(formDefinition));
3612
+ setFilters(mapApiToFilters(formDefinition));
3613
+ setServiceRoute(formDefinition?.siteFormDataList?.serviceRoute ?? "/");
3614
+ const rawAddLinkHref = formDefinition?.siteFormDataList?.addLinkHref ?? "";
3615
+ const resolvedAddLinkHref = resolveRoutePlaceholders2(
3616
+ rawAddLinkHref,
3617
+ params
3618
+ );
3619
+ setAddLinkHref(resolvedAddLinkHref);
3620
+ setAddLinkText(formDefinition?.siteFormDataList?.addLinkText ?? "");
3621
+ }, [formDefinition, params]);
3622
+ useEffect4(() => {
3623
+ const fetchData = async () => {
3624
+ if (!serviceRoute) return;
3625
+ const resolvedRoute = resolveRoutePlaceholders2(serviceRoute, params);
3626
+ const queryString = OdataBuilder.getOdataQueryString(query);
3627
+ const separator = resolvedRoute.includes("?") ? "&" : "?";
3628
+ const finalUrl = resolvedRoute + (queryString ? separator + queryString : "");
3629
+ const result = await serviceClient.get(finalUrl);
3630
+ setDataset(result);
3631
+ };
3632
+ fetchData();
3633
+ }, [serviceRoute, query, params]);
3634
+ const resolvedTabs = (tabs ?? []).map((tab) => {
3635
+ const landingPageUrl = resolveRoutePlaceholders2(tab.landingPageUrl, params);
3636
+ return {
3637
+ ...tab,
3638
+ landingPageUrl,
3639
+ isActive: landingPageUrl === pathname
3640
+ };
3641
+ });
3642
+ return /* @__PURE__ */ jsxs17(React28.Fragment, { children: [
3643
+ resolvedTabs.length > 0 && // <NavigationTabsV2
3644
+ // tabs={resolvedTabs}
3645
+ // params={(widgetProps?.params ?? params) as Record<string, any>}
3646
+ // />
3647
+ /* @__PURE__ */ jsx41(NavigationTabsV2_default, { tabs, params: widgetProps.params }),
3648
+ /* @__PURE__ */ jsx41(
3649
+ DataList_default,
3650
+ {
3651
+ addLinkHref,
3652
+ addLinkText,
3653
+ title: (formDefinition?.formTitle || "") + "-V2",
3654
+ path,
3655
+ columns,
3656
+ dataset,
3657
+ filters: filter,
3658
+ serviceClient,
3659
+ query
3660
+ }
3661
+ )
3662
+ ] });
3663
+ };
3664
+ var DataListRenderer_default = DataListRenderer;
3665
+
3666
+ // src/components/dataForm/DataForm.tsx
3667
+ import React30, { useCallback as useCallback4, useEffect as useEffect5, useReducer as useReducer2, useRef as useRef2 } from "react";
3668
+
3669
+ // src/components/dataForm/DataFormChildSection.tsx
3670
+ import React29, { useCallback as useCallback3 } from "react";
3671
+
3672
+ // src/components/dataForm/StyleTypes.tsx
3673
+ var StyleTypes2 = /* @__PURE__ */ ((StyleTypes3) => {
3674
+ StyleTypes3["Primary"] = "Primary";
3675
+ StyleTypes3["PrimaryHollow"] = "PrimaryHollow";
3676
+ StyleTypes3["Secondary"] = "Secondary";
3677
+ StyleTypes3["SecondaryHollow"] = "SecondaryHollow";
3678
+ StyleTypes3["Neutral"] = "Neutral";
3679
+ StyleTypes3["NeutralHollow"] = "NeutralHollow";
3680
+ StyleTypes3["Link"] = "Link";
3681
+ StyleTypes3["Ripple"] = "Ripple";
3682
+ StyleTypes3["Danger"] = "Danger";
3683
+ StyleTypes3["Light"] = "Light";
3684
+ return StyleTypes3;
3685
+ })(StyleTypes2 || {});
3686
+
3687
+ // src/components/dataForm/FormReducer.tsx
3688
+ var FORM_CHILD_INPUT_UPDATE = "FORM_CHILD_INPUT_UPDATE";
3689
+ var FORM_CHILD_ONE_TO_ONE_UPDATE = "FORM_CHILD_ONE_TO_ONE_UPDATE";
3690
+ var FORM_CHILD_ROW_ADD = "FORM_CHILD_ROW_ADD";
3691
+
3692
+ // src/components/dataForm/DataFormChildSection.tsx
3693
+ import { jsx as jsx42, jsxs as jsxs18 } from "react/jsx-runtime";
3694
+ var DataFormChildSection = (props) => {
3695
+ const { section } = props;
3696
+ const isOneToOne = section.relationshipType === "one-to-one";
3697
+ const childItems = props.childItems || [];
3698
+ const getChildItemsForRendering = () => {
3699
+ if (isOneToOne) {
3700
+ return [{ item: props.childItems ?? {}, originalIndex: 0 }];
3701
+ }
3702
+ return childItems.map((item, originalIndex) => ({ item, originalIndex })).filter((x) => !x.item.isDeleted) || [];
3703
+ };
3704
+ const childItemsToRender = getChildItemsForRendering();
3705
+ const handleChildInputChange = useCallback3(
3706
+ (updatedValues) => {
3707
+ if (isOneToOne) {
3708
+ props.callback({
3709
+ sectionName: props.section.name,
3710
+ actionType: FORM_CHILD_ONE_TO_ONE_UPDATE,
3711
+ name: updatedValues.name,
3712
+ value: updatedValues.value,
3713
+ rowIndex: -1
3714
+ });
3715
+ } else {
3716
+ const filteredIndex = updatedValues.index;
3717
+ const visibleItem = childItemsToRender[filteredIndex];
3718
+ if (visibleItem) {
3719
+ props.callback({
3720
+ sectionName: props.section.name,
3721
+ actionType: FORM_CHILD_INPUT_UPDATE,
3722
+ name: updatedValues.name,
3723
+ value: updatedValues.value,
3724
+ rowIndex: visibleItem.originalIndex
3725
+ // Use ORIGINAL index!
3726
+ });
3727
+ }
3728
+ }
3729
+ },
3730
+ [props, isOneToOne, childItemsToRender]
3731
+ );
3732
+ const onAddRow = useCallback3(() => {
3733
+ props.callback({
3734
+ sectionName: props.section.name,
3735
+ actionType: FORM_CHILD_ROW_ADD,
3736
+ name: "all",
3737
+ value: null,
3738
+ rowIndex: -1
3739
+ });
3740
+ }, [props]);
3741
+ const onDeleteRow = useCallback3(
3742
+ (filteredIndex) => {
3743
+ const visibleItem = childItemsToRender[filteredIndex];
3744
+ if (visibleItem) {
3745
+ props.callback({
3746
+ sectionName: props.section.name,
3747
+ actionType: FORM_CHILD_INPUT_UPDATE,
3748
+ name: "isDeleted",
3749
+ value: true,
3750
+ rowIndex: visibleItem.originalIndex
3751
+ // Use ORIGINAL index!
3752
+ });
3753
+ }
3754
+ },
3755
+ [props, childItemsToRender]
3756
+ );
3757
+ console.log("Rendering Child Section:", {
3758
+ childItemsToRender,
3759
+ allChildItems: childItems
3760
+ });
3761
+ return /* @__PURE__ */ jsx42(React29.Fragment, { children: /* @__PURE__ */ jsxs18("div", { className: "rounded border-neutral-200 border px-6 py-4 mb-2", children: [
3762
+ section.sectionTitle && /* @__PURE__ */ jsx42("div", { className: "mb-4 text-lg font-medium text-body-950", children: section.sectionTitle }),
3763
+ /* @__PURE__ */ jsx42("div", { className: "flex-grow flex flex-col justify-between overflow-y-auto", children: /* @__PURE__ */ jsxs18("div", { className: "flex flex-col justify-between gap-2", children: [
3764
+ /* @__PURE__ */ jsx42("div", { children: /* @__PURE__ */ jsxs18("table", { className: "w-full border-separate divide-y divide-gray-200", children: [
3765
+ (!isOneToOne || childItemsToRender.length > 0) && /* @__PURE__ */ jsx42("thead", { className: "", children: section.sectionRows.map((sectionRow, sectionRowIndex) => {
3766
+ return /* @__PURE__ */ jsxs18("tr", { className: "", children: [
3767
+ sectionRow.elements.map((field, index) => {
3768
+ return /* @__PURE__ */ jsx42(
3769
+ "th",
3770
+ {
3771
+ className: "py-3 font-normal text-left",
3772
+ children: field.attributes?.label
3773
+ },
3774
+ field.name
3775
+ );
3776
+ }),
3777
+ !section.readonly && !isOneToOne && /* @__PURE__ */ jsx42("th", { className: "py-3 font-normal text-left", children: "Actions" })
3778
+ ] }, sectionRowIndex);
3779
+ }) }),
3780
+ /* @__PURE__ */ jsx42("tbody", { className: "divide-y divide-gray-200", children: childItemsToRender.map((visibleItem, filteredIndex) => {
3781
+ const { item, originalIndex } = visibleItem;
3782
+ const rowKey = originalIndex;
3783
+ return /* @__PURE__ */ jsx42(React29.Fragment, { children: section.sectionRows.map(
3784
+ (sectionRow, sectionRowIndex) => {
3785
+ return /* @__PURE__ */ jsxs18(
3786
+ "tr",
3787
+ {
3788
+ className: "",
3789
+ children: [
3790
+ sectionRow.elements.map((field, index) => {
3791
+ return /* @__PURE__ */ jsx42("td", { children: /* @__PURE__ */ jsx42("div", { className: "flex-1", children: /* @__PURE__ */ jsx42("div", { className: "w-11/12", children: /* @__PURE__ */ jsx42(
3792
+ InputControl_default,
3793
+ {
3794
+ index: filteredIndex,
3795
+ name: field.name,
3796
+ controlType: field.controlType,
3797
+ value: item[field.name],
3798
+ dataset: field.dataset,
3799
+ dataKeyFieldName: field.dataKeyFieldName,
3800
+ dataTextFieldName: field.dataTextFieldName,
3801
+ callback: handleChildInputChange,
3802
+ attributes: {
3803
+ ...field.attributes,
3804
+ label: ""
3805
+ },
3806
+ serviceClient: props.serviceClient,
3807
+ entityType: field.entityType
3808
+ }
3809
+ ) }) }) }, field.name);
3810
+ }),
3811
+ !section.readonly && !isOneToOne && /* @__PURE__ */ jsx42("td", { children: /* @__PURE__ */ jsx42(
3812
+ ClientButton_default,
3813
+ {
3814
+ ButtonType: StyleTypes2.Hollow,
3815
+ onClick: () => {
3816
+ onDeleteRow(filteredIndex);
3817
+ },
3818
+ dataRole: "delete",
3819
+ tabIndex: -1,
3820
+ children: /* @__PURE__ */ jsx42(
3821
+ Icon_default,
3822
+ {
3823
+ className: "w-4 h-4",
3824
+ name: "delete"
3825
+ }
3826
+ )
3827
+ }
3828
+ ) })
3829
+ ]
3830
+ },
3831
+ `${rowKey}_${sectionRowIndex}`
3832
+ );
3833
+ }
3834
+ ) }, rowKey);
3835
+ }) })
3836
+ ] }) }),
3837
+ !section.readonly && !isOneToOne && /* @__PURE__ */ jsx42("div", { className: "ml-1", children: /* @__PURE__ */ jsx42(
3838
+ ClientButton_default,
3839
+ {
3840
+ ButtonType: "Link" /* Link */,
3841
+ onClick: onAddRow,
3842
+ dataRole: "add",
3843
+ children: "Add new"
3844
+ }
3845
+ ) })
3846
+ ] }) })
3847
+ ] }) });
3848
+ };
3849
+ var DataFormChildSection_default = DataFormChildSection;
3850
+
3851
+ // src/components/dataForm/DataForm.tsx
3852
+ import { jsx as jsx43, jsxs as jsxs19 } from "react/jsx-runtime";
3853
+ var DataForm = (props) => {
3854
+ const formRef = useRef2(null);
3855
+ console.log(props.dataItem, "dssads");
3856
+ const initialState = {
3857
+ inputValues: {},
3858
+ lastPropertyChanged: ""
3859
+ };
3860
+ const childInitialState = {
3861
+ inputValues: []
3862
+ };
3863
+ const [formState, dispatch] = useReducer2(FormReducer_default, initialState);
3864
+ console.log(props.sections, "sections");
3865
+ const clearHiddenChildSections = useCallback4(
3866
+ (changedProperty, newValues) => {
3867
+ if (!props.sections) return;
3868
+ const allChildSections = [];
3869
+ props.sections.forEach((section) => {
3870
+ if (section.childSections) {
3871
+ section.childSections.forEach((childSection) => {
3872
+ if (childSection.name) {
3873
+ allChildSections.push({
3874
+ name: childSection.name,
3875
+ section: childSection
3876
+ });
3877
+ }
3878
+ });
3879
+ }
3880
+ });
3881
+ allChildSections.forEach(({ name, section }) => {
3882
+ const wasVisible = evalutateCondition(
3883
+ formState.inputValues,
3884
+ section.visible
3885
+ );
3886
+ const isNowVisible = evalutateCondition(newValues, section.visible);
3887
+ if (wasVisible && !isNowVisible) {
3888
+ const currentValue = newValues[name];
3889
+ if (currentValue && (Array.isArray(currentValue) && currentValue.length > 0 || typeof currentValue === "object" && Object.keys(currentValue).length > 0)) {
3890
+ dispatch({
3891
+ // @ts-ignore
3892
+ type: "FORM_CHILD_CLEAR",
3893
+ childName: name,
3894
+ name,
3895
+ value: section.relationshipType === "one-to-one" ? {} : []
3896
+ });
3897
+ }
3898
+ }
3899
+ });
3900
+ },
3901
+ [props.sections, formState.inputValues]
3902
+ );
3903
+ const handleInputChange = useCallback4(
3904
+ async (updatedValues) => {
3905
+ dispatch({
3906
+ type: FORM_INPUT_UPDATE,
3907
+ name: updatedValues.name,
3908
+ value: updatedValues.value
3909
+ });
3910
+ const newInputValues = {
3911
+ ...formState.inputValues,
3912
+ [updatedValues.name]: updatedValues.value
3913
+ };
3914
+ clearHiddenChildSections(updatedValues.name, newInputValues);
3915
+ },
3916
+ [dispatch, formState.inputValues, clearHiddenChildSections]
3917
+ );
3918
+ const fetchData = useCallback4(async () => {
3919
+ if (!props.rules) return;
3920
+ if (Object.keys(formState.inputValues).length === 0) {
3921
+ return;
3922
+ }
3923
+ console.log("on change called");
3924
+ const changeRule = props.rules.onChangeRules?.find(
3925
+ (x) => x.name === formState.lastPropertyChanged
3926
+ );
3927
+ if (!changeRule) return;
3928
+ if (changeRule.triggerCondition && !evalutateCondition(formState.inputValues, changeRule.triggerCondition)) {
3929
+ console.log("Trigger condition not met, skipping API call.");
3930
+ return;
3931
+ }
3932
+ const url = replacePlaceholders(
3933
+ changeRule.getApiEndpoint,
3934
+ formState.inputValues,
3935
+ props.params
3936
+ );
3937
+ try {
3938
+ const response = await props.serviceClient.get(url);
3939
+ dispatch({
3940
+ type: FORM_INPUT_UPDATE,
3941
+ name: "dnsRecords",
3942
+ // @ts-ignore
3943
+ value: response?.result?.dnsRecords
3944
+ });
3945
+ } catch (error) {
3946
+ console.error("Error fetching data:", error);
3947
+ }
3948
+ }, [formState.lastPropertyChanged, formState.inputValues]);
3949
+ useEffect5(() => {
3950
+ fetchData();
3951
+ }, [formState.inputValues, formState.lastPropertyChanged]);
3952
+ function replacePlaceholders(template, context, params) {
3953
+ console.log("from replace:");
3954
+ console.log(params);
3955
+ console.log(template);
3956
+ return template.replace(
3957
+ /\{(context|params)\.([\w]+)\}/g,
3958
+ (_, type, key) => {
3959
+ if (type === "context" && context && key in context && context[key]) {
3960
+ return String(context[key]);
3961
+ }
3962
+ if (type === "params" && params && key in params && params[key]) {
3963
+ return String(params[key]);
3964
+ }
3965
+ return "";
3966
+ }
3967
+ );
3968
+ }
3969
+ const handleChildSectionChangeCallback = useCallback4(
3970
+ (params) => {
3971
+ dispatch({
3972
+ type: params.actionType,
3973
+ name: params.name,
3974
+ value: params.value,
3975
+ // @ts-ignore
3976
+ childName: params.sectionName,
3977
+ rowIndex: params.rowIndex
3978
+ });
3979
+ },
3980
+ [dispatch]
3981
+ );
3982
+ const onValidate = async () => {
3983
+ if (formRef.current && !formRef.current.checkValidity()) {
3984
+ formRef.current.classList.add("validated");
3985
+ return false;
3986
+ } else {
3987
+ return true;
3988
+ }
3989
+ };
3990
+ function normalizeChildSections(values, isEdit, sections) {
3991
+ if (!sections) return values;
3992
+ const cloned = structuredClone(values);
3993
+ sections.forEach((section) => {
3994
+ section.childSections?.forEach((child) => {
3995
+ const childName = child.name;
3996
+ const relation = child.relationshipType;
3997
+ const childValue = cloned[childName];
3998
+ if (!childValue) return;
3999
+ if (relation === "one-to-many" && Array.isArray(childValue)) {
4000
+ cloned[childName] = childValue.filter((row) => {
4001
+ if (isEdit) return true;
4002
+ return !row.isDeleted;
4003
+ });
4004
+ }
4005
+ if (relation === "one-to-one" && typeof childValue === "object") {
4006
+ if (!isEdit && childValue.isDeleted) {
4007
+ delete cloned[childName];
4008
+ }
4009
+ }
4010
+ });
4011
+ });
4012
+ return cloned;
4013
+ }
4014
+ const onClick = useCallback4(async () => {
4015
+ if (props.onClick) {
4016
+ const isEdit = props.dataItem && Object.keys(props.dataItem).length > 0;
4017
+ const normalizedValues = normalizeChildSections(
4018
+ formState.inputValues,
4019
+ !!isEdit,
4020
+ props.sections
4021
+ );
4022
+ return await props.onClick({
4023
+ ...formState,
4024
+ inputValues: normalizedValues
4025
+ });
4026
+ } else {
4027
+ return { isSuccessful: true };
4028
+ }
4029
+ }, [formState, props]);
4030
+ const handleAdditionalOnClick = useCallback4(async () => {
4031
+ if (props.additionalActions?.onClick) {
4032
+ return await props.additionalActions.onClick(formState);
4033
+ } else {
4034
+ return { isSuccessful: true, message: "Action completed successfully" };
4035
+ }
4036
+ }, [formState, props]);
4037
+ const onDelete = useCallback4(async () => {
4038
+ if (props.onDelete) {
4039
+ return await props.onDelete(formState);
4040
+ } else {
4041
+ return { isSuccessful: true };
4042
+ }
4043
+ }, [formState, props]);
4044
+ useEffect5(() => {
4045
+ if (props.dataItem) {
4046
+ dispatch({
4047
+ type: FORM_INITIAL_UPDATE,
4048
+ values: props.dataItem,
4049
+ name: "all"
4050
+ });
4051
+ }
4052
+ }, [props.dataItem]);
4053
+ function getNestedProperty2(obj, path) {
4054
+ if (path.includes(".")) {
4055
+ return path.split(".").reduce((prev, curr) => prev ? prev[curr] : null, obj);
4056
+ } else {
4057
+ return obj[path];
4058
+ }
4059
+ }
4060
+ function evalutateCondition(context, expression) {
4061
+ if (expression === null || expression === void 0) {
4062
+ return true;
4063
+ }
4064
+ try {
4065
+ const evaluator = new Function("context", `return ${expression};`);
4066
+ return evaluator(context);
4067
+ } catch (error) {
4068
+ console.error("Error evaluating expression:", error);
4069
+ return false;
4070
+ }
4071
+ }
4072
+ return /* @__PURE__ */ jsx43(React30.Fragment, { children: /* @__PURE__ */ jsxs19("div", { className: "flex-grow flex flex-col", children: [
4073
+ props.title && /* @__PURE__ */ jsx43("div", { className: "inline-flex items-center gap-2 px-6 py-3 border border-neutral-200 bg-white shadow-sm rounded-t-md", children: /* @__PURE__ */ jsxs19(
4074
+ "div",
4075
+ {
4076
+ className: "inline-flex items-center gap-2 cursor-pointer",
4077
+ onClick: () => window.history.back(),
4078
+ children: [
4079
+ /* @__PURE__ */ jsx43(Icon_default, { name: "chevronLeft", className: "w-4 h-4 text-primary-800" }),
4080
+ /* @__PURE__ */ jsx43("h2", { className: "text-lg font-semibold text-primary-800", children: props.title })
4081
+ ]
4082
+ }
4083
+ ) }),
4084
+ /* @__PURE__ */ jsx43(
4085
+ "form",
4086
+ {
4087
+ className: "group space-y-6 pb-6 overflow-y-auto",
4088
+ noValidate: true,
4089
+ ref: formRef,
4090
+ onKeyDown: (e) => {
4091
+ if (e.key === "Enter") {
4092
+ const activeElement = document.activeElement;
4093
+ console.log(activeElement);
4094
+ if (activeElement.tagName === "INPUT") {
4095
+ e.preventDefault();
4096
+ }
4097
+ if (activeElement.tagName === "BUTTON" && activeElement.dataset.role === "add") {
4098
+ return;
4099
+ }
4100
+ if (activeElement.tagName === "BUTTON" && activeElement.dataset.role === "delete") {
4101
+ e.preventDefault();
4102
+ }
4103
+ }
4104
+ },
4105
+ children: /* @__PURE__ */ jsx43("div", { className: "flex flex-col gap-6", children: props.sections?.map((section, sectionIndex) => {
4106
+ return /* @__PURE__ */ jsx43(React30.Fragment, { children: !section.isChildSection && /* @__PURE__ */ jsxs19("div", { className: " rounded-b-lg bg-white shadow border-neutral-200 border px-8 py-6 ", children: [
4107
+ section.sectionRows?.map(
4108
+ (sectionRow, sectionRowIndex) => {
4109
+ const elementsCount = sectionRow.elements.length;
4110
+ let isVisible = true;
4111
+ if (sectionRow.visible) {
4112
+ isVisible = evalutateCondition(
4113
+ formState.inputValues,
4114
+ sectionRow.visible
4115
+ );
4116
+ }
4117
+ return /* @__PURE__ */ jsx43(React30.Fragment, { children: isVisible && /* @__PURE__ */ jsx43("div", { className: "lg:flex gap-14 flex-1 mb-4 ", children: sectionRow.elements.map((field, index) => {
4118
+ return /* @__PURE__ */ jsxs19(
4119
+ "div",
4120
+ {
4121
+ className: sectionRow.grow ? "grow" : "",
4122
+ children: [
4123
+ /* @__PURE__ */ jsx43("div", { children: field.controlType }),
4124
+ /* @__PURE__ */ jsx43(
4125
+ InputControl_default,
4126
+ {
4127
+ name: field.name,
4128
+ controlType: field.controlType,
4129
+ value: getNestedProperty2(
4130
+ formState.inputValues,
4131
+ field.name
4132
+ ),
4133
+ callback: handleInputChange,
4134
+ dataSourceDependsOn: field.dataSourceDependsOn,
4135
+ dependentValue: field.dataSourceDependsOn ? formState.inputValues[field.dataSourceDependsOn] : "",
4136
+ dataSource: field.dataSource,
4137
+ dataset: field.dataset,
4138
+ dataKeyFieldName: field.dataKeyFieldName,
4139
+ dataTextFieldName: field.dataTextFieldName,
4140
+ attributes: field.attributes,
4141
+ serviceClient: props.serviceClient,
4142
+ assetsUploadPath: props.dataItem ? props.dataItem["assetsUploadPath"] : null,
4143
+ entityType: field.entityType,
4144
+ uploadInSharedLocation: field.uploadInSharedLocation
4145
+ }
4146
+ )
4147
+ ]
4148
+ },
4149
+ field.name
4150
+ );
4151
+ }) }) }, sectionRowIndex);
4152
+ }
4153
+ ),
4154
+ /* @__PURE__ */ jsx43("div", { children: section.childSections?.map(
4155
+ (childSection, childSectionIndex) => {
4156
+ return /* @__PURE__ */ jsx43("div", { children: childSection.name && evalutateCondition(
4157
+ formState.inputValues,
4158
+ childSection.visible
4159
+ ) && /* @__PURE__ */ jsx43(
4160
+ DataFormChildSection_default,
4161
+ {
4162
+ section: childSection,
4163
+ childItems: formState.inputValues[childSection.name],
4164
+ callback: handleChildSectionChangeCallback,
4165
+ serviceClient: props.serviceClient
4166
+ }
4167
+ ) }, childSectionIndex);
4168
+ }
4169
+ ) })
4170
+ ] }) }, sectionIndex);
4171
+ }) })
4172
+ }
4173
+ ),
4174
+ /* @__PURE__ */ jsxs19("div", { className: "flex px-6 py-3 mt-2 mb-2 justify-end items-center gap-5", children: [
4175
+ /* @__PURE__ */ jsx43("div", { children: props.additionalActions && /* @__PURE__ */ jsx43(
4176
+ Button_default,
4177
+ {
4178
+ ButtonType: "PrimaryHollow" /* Hollow */,
4179
+ onClick: handleAdditionalOnClick,
4180
+ children: props.additionalActions.title
4181
+ }
4182
+ ) }),
4183
+ /* @__PURE__ */ jsx43("div", { children: props.onDelete && /* @__PURE__ */ jsx43(
4184
+ Button_default,
4185
+ {
4186
+ ButtonType: "PrimaryHollow" /* Hollow */,
4187
+ onClick: onDelete,
4188
+ showToast: true,
4189
+ confirm: true,
4190
+ confirmationMessage: "Are you sure you want to delete this record?",
4191
+ children: "Delete"
4192
+ }
4193
+ ) }),
4194
+ /* @__PURE__ */ jsx43("div", { children: props.onClick && /* @__PURE__ */ jsx43(
4195
+ Button_default,
4196
+ {
4197
+ onValidate,
4198
+ onClick,
4199
+ showToast: true,
4200
+ ButtonType: "Primary" /* Solid */,
4201
+ className: "py-2 leading-6",
4202
+ children: props.buttonText ? `${props.buttonText}` : "Save Changes"
4203
+ }
4204
+ ) })
4205
+ ] })
4206
+ ] }) });
4207
+ };
4208
+ var DataForm_default = DataForm;
4209
+
4210
+ // src/components/dataForm/DataFormRenderer.tsx
4211
+ import { jsx as jsx44, jsxs as jsxs20 } from "react/jsx-runtime";
4212
+ function getAction(actions, code) {
4213
+ return actions?.find((a) => a.actionCode === code);
4214
+ }
4215
+ var DataFormRenderer = ({
4216
+ formDefinition,
4217
+ dataItem,
4218
+ params,
4219
+ tabs,
4220
+ apiBaseUrl,
4221
+ session,
4222
+ widgetProps,
4223
+ onSave,
4224
+ onDelete,
4225
+ onCancelAdd,
4226
+ isAddPage,
4227
+ entityId
4228
+ }) => {
4229
+ const serviceClient = new ServiceClient_default(apiBaseUrl, session);
4230
+ if (!formDefinition) return null;
4231
+ const idParamName = formDefinition.siteFormDataForm?.entityIdParamName ?? "id";
4232
+ const deleteAction = getAction(
4233
+ formDefinition.siteFormDataForm?.actions ?? [],
4234
+ "Delete"
4235
+ );
4236
+ const hasDataItem = dataItem && Object.keys(dataItem).length > 0;
4237
+ return /* @__PURE__ */ jsxs20("div", { className: "flex-grow flex flex-col", children: [
4238
+ widgetProps && /* @__PURE__ */ jsx44(NavigationTabsV2_default, { tabs, params: widgetProps.params }),
4239
+ /* @__PURE__ */ jsx44(
4240
+ DataForm_default,
4241
+ {
4242
+ title: !isAddPage ? "Edit " + formDefinition.formTitle + "- v2" : "Add " + formDefinition.formTitle + "- v2",
4243
+ sections: formDefinition.siteFormDataForm?.sections ?? [],
4244
+ dataItem,
4245
+ onClick: onSave,
4246
+ onDelete: !isAddPage && deleteAction && (entityId || hasDataItem) ? onDelete : void 0,
4247
+ additionalActions: isAddPage ? {
4248
+ name: "cancel",
4249
+ title: "Cancel",
4250
+ onClick: onCancelAdd
4251
+ } : void 0,
4252
+ serviceClient
4253
+ }
4254
+ )
4255
+ ] });
4256
+ };
4257
+ var DataFormRenderer_default = DataFormRenderer;
4258
+ export {
4259
+ BooleanSelect_default as BooleanSelect,
4260
+ Button_default as Button,
4261
+ CheckboxInput_default as CheckboxInput,
4262
+ ColorInput_default as ColorInput,
4263
+ DataFormRenderer_default as DataFormRenderer,
4264
+ DataList_default as DataList,
4265
+ DataListRenderer_default as DataListRenderer,
4266
+ DateTimeInput_default as DateTimeInput,
4267
+ EmailInput_default as EmailInput,
4268
+ EnterAnimationHydrator,
4269
+ InputControl_default as InputControl,
4270
+ InputControlType_default as InputControlType,
4271
+ LineTextInput_default as LineTextInput,
4272
+ MoneyInput_default as MoneyInput,
4273
+ MultilineTextInput_default as MultilineTextInput,
4274
+ NavigationTabsV2_default as NavigationTabsV2,
4275
+ NumberInput_default as NumberInput,
4276
+ OtpInput_default as OtpInput,
4277
+ PageBodyRenderer_default as PageBodyRenderer,
4278
+ PercentageInput_default as PercentageInput,
4279
+ PhoneInput_default as PhoneInput,
4280
+ TimeInput_default as TimeInput,
4281
+ Toast_default as Toast,
4282
+ ToastService_default as ToastService,
4283
+ ViewControl_default as ViewControl,
4284
+ ViewControlTypes_default as ViewControlTypes
4285
+ };