@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260326104921 → 0.8.1-dev.20260326105727

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30,6 +30,232 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
+ // src/components/ToastService.tsx
34
+ var ToastService, ToastService_default;
35
+ var init_ToastService = __esm({
36
+ "src/components/ToastService.tsx"() {
37
+ "use strict";
38
+ ToastService = class _ToastService {
39
+ static initialize(showToast, closeToast) {
40
+ _ToastService.showToast = showToast;
41
+ _ToastService.closeToast = closeToast;
42
+ }
43
+ static showError(message) {
44
+ if (_ToastService.showToast) {
45
+ _ToastService.showToast(message, "error");
46
+ }
47
+ }
48
+ static showInfo(message) {
49
+ if (_ToastService.showToast) {
50
+ _ToastService.showToast(message, "info");
51
+ }
52
+ }
53
+ static close() {
54
+ if (_ToastService.closeToast) {
55
+ _ToastService.closeToast();
56
+ }
57
+ }
58
+ };
59
+ ToastService_default = ToastService;
60
+ }
61
+ });
62
+
63
+ // src/components/StyleTypes.tsx
64
+ var buttonClasses, progressClasses;
65
+ var init_StyleTypes = __esm({
66
+ "src/components/StyleTypes.tsx"() {
67
+ "use strict";
68
+ buttonClasses = /* @__PURE__ */ new Map([
69
+ ["Primary" /* Solid */, "btn-solid"],
70
+ ["PrimaryHollow" /* Hollow */, "btn-hollow"],
71
+ ["Link" /* Link */, "btn-link"]
72
+ ]);
73
+ progressClasses = /* @__PURE__ */ new Map([
74
+ ["Primary" /* Solid */, ""],
75
+ ["PrimaryHollow" /* Hollow */, ""],
76
+ ["Link" /* Link */, ""]
77
+ ]);
78
+ }
79
+ });
80
+
81
+ // src/components/ClientButton.tsx
82
+ var import_react22, import_jsx_runtime23, ClientButton, ClientButton_default;
83
+ var init_ClientButton = __esm({
84
+ "src/components/ClientButton.tsx"() {
85
+ "use strict";
86
+ "use client";
87
+ import_react22 = __toESM(require("react"));
88
+ init_ToastService();
89
+ init_StyleTypes();
90
+ import_jsx_runtime23 = require("react/jsx-runtime");
91
+ ClientButton = (props) => {
92
+ const execute = async (event) => {
93
+ if (props.onClick !== void 0) {
94
+ props.onClick();
95
+ } else {
96
+ ToastService_default.showError("No action defined.");
97
+ }
98
+ };
99
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
100
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react22.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
101
+ "button",
102
+ {
103
+ type: "button",
104
+ onClick: execute,
105
+ className: buttonClass + " " + props.className,
106
+ children: props.children
107
+ }
108
+ ) });
109
+ };
110
+ ClientButton_default = ClientButton;
111
+ }
112
+ });
113
+
114
+ // src/components/Confirm.tsx
115
+ var import_react23, import_jsx_runtime24, Confirm, Confirm_default;
116
+ var init_Confirm = __esm({
117
+ "src/components/Confirm.tsx"() {
118
+ "use strict";
119
+ "use client";
120
+ import_react23 = require("react");
121
+ init_ClientButton();
122
+ init_StyleTypes();
123
+ import_jsx_runtime24 = require("react/jsx-runtime");
124
+ Confirm = ({ message, onConfirm, onCancel }) => {
125
+ const [showModal, setShowModal] = (0, import_react23.useState)(true);
126
+ const handleConfirmAction = () => {
127
+ setShowModal(false);
128
+ if (onConfirm) {
129
+ onConfirm();
130
+ }
131
+ };
132
+ const handleCancelAction = () => {
133
+ setShowModal(false);
134
+ if (onCancel) {
135
+ onCancel();
136
+ }
137
+ };
138
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: showModal && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
139
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute inset-0 bg-black opacity-70" }),
140
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
141
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
142
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "mb-4", children: message }),
143
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex justify-end gap-8", children: [
144
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
145
+ ClientButton_default,
146
+ {
147
+ onClick: handleCancelAction,
148
+ ButtonType: "PrimaryHollow" /* Hollow */,
149
+ children: "Cancel"
150
+ }
151
+ ),
152
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
153
+ ClientButton_default,
154
+ {
155
+ onClick: handleConfirmAction,
156
+ children: "Confirm"
157
+ }
158
+ )
159
+ ] })
160
+ ] })
161
+ ] }) });
162
+ };
163
+ Confirm_default = Confirm;
164
+ {
165
+ }
166
+ }
167
+ });
168
+
169
+ // src/components/Button.tsx
170
+ var import_react24, import_jsx_runtime25, Button, Button_default;
171
+ var init_Button = __esm({
172
+ "src/components/Button.tsx"() {
173
+ "use strict";
174
+ "use client";
175
+ import_react24 = __toESM(require("react"));
176
+ init_ToastService();
177
+ init_StyleTypes();
178
+ init_Confirm();
179
+ import_jsx_runtime25 = require("react/jsx-runtime");
180
+ Button = (props) => {
181
+ const [inProgress, setInProgress] = (0, import_react24.useState)(false);
182
+ const [isActionPerformed, setIsActionPerformed] = (0, import_react24.useState)(false);
183
+ const [responseMessage, setResponseMessage] = (0, import_react24.useState)(null);
184
+ const [showModal, setShowModal] = (0, import_react24.useState)(null);
185
+ const execute = async (event) => {
186
+ event.preventDefault();
187
+ event.stopPropagation();
188
+ if (props.confirm) {
189
+ const confirmed = await showConfirmation("Are you sure you want to delete this item?");
190
+ setShowModal(null);
191
+ if (!confirmed) {
192
+ return;
193
+ }
194
+ }
195
+ if (props.oneTimeAction && isActionPerformed) {
196
+ return;
197
+ }
198
+ setInProgress(true);
199
+ let isValid = true;
200
+ if (props.onValidate !== void 0) {
201
+ isValid = await props.onValidate();
202
+ if (!isValid) {
203
+ setInProgress(false);
204
+ ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
205
+ return;
206
+ }
207
+ }
208
+ if (props.onClick !== void 0) {
209
+ let response = await props.onClick();
210
+ if (response.isSuccessful) {
211
+ setIsActionPerformed(true);
212
+ setResponseMessage(response.message);
213
+ if (props.showToast) {
214
+ ToastService_default.showInfo(response.message || "");
215
+ }
216
+ } else {
217
+ ToastService_default.showError(response.message || "");
218
+ }
219
+ } else {
220
+ ToastService_default.showError("No action defined.");
221
+ }
222
+ setInProgress(false);
223
+ };
224
+ const showConfirmation = (message) => {
225
+ return new Promise((resolve) => {
226
+ const onConfirm = () => resolve(true);
227
+ const onCancel = () => resolve(false);
228
+ setShowModal(/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
229
+ });
230
+ };
231
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
232
+ let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
233
+ const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
234
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react24.default.Fragment, { children: [
235
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
236
+ "button",
237
+ {
238
+ type: "submit",
239
+ onClick: execute,
240
+ disabled: props.disabled,
241
+ title: isDisabled ? "The button is disabled to prevent any action" : "",
242
+ className: buttonClass + " relative " + props.className,
243
+ children: [
244
+ isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
245
+ inProgress && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react24.default.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
246
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
247
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
248
+ ] }) })
249
+ ]
250
+ }
251
+ ),
252
+ showModal
253
+ ] });
254
+ };
255
+ Button_default = Button;
256
+ }
257
+ });
258
+
33
259
  // src/components/HlsPlayer.tsx
34
260
  var HlsPlayer_exports = {};
35
261
  __export(HlsPlayer_exports, {
@@ -169,6 +395,398 @@ var init_HlsPlayer = __esm({
169
395
  }
170
396
  });
171
397
 
398
+ // src/clients/CacheManage.tsx
399
+ var import_node_cache, CacheManager;
400
+ var init_CacheManage = __esm({
401
+ "src/clients/CacheManage.tsx"() {
402
+ "use strict";
403
+ import_node_cache = __toESM(require("node-cache"));
404
+ CacheManager = class _CacheManager {
405
+ constructor() {
406
+ this.maxCacheSize = 1e3;
407
+ this.cache = new import_node_cache.default({ stdTTL: 0, checkperiod: 300 });
408
+ }
409
+ static getInstance() {
410
+ if (!_CacheManager.instance) {
411
+ _CacheManager.instance = new _CacheManager();
412
+ }
413
+ return _CacheManager.instance;
414
+ }
415
+ get(key) {
416
+ return null;
417
+ }
418
+ set(key, data, ttl) {
419
+ }
420
+ clear() {
421
+ this.cache.flushAll();
422
+ }
423
+ size() {
424
+ return this.cache.keys().length;
425
+ }
426
+ destroy() {
427
+ this.cache.close();
428
+ }
429
+ };
430
+ }
431
+ });
432
+
433
+ // src/clients/ServiceClient.tsx
434
+ var ServerApiError, ServiceClient, ServiceClient_default;
435
+ var init_ServiceClient = __esm({
436
+ "src/clients/ServiceClient.tsx"() {
437
+ "use strict";
438
+ init_CacheManage();
439
+ ServerApiError = class extends Error {
440
+ constructor(data, status) {
441
+ super(data.message || "---");
442
+ this.status = status;
443
+ this.data = data;
444
+ this.data.isSuccessful = false;
445
+ }
446
+ };
447
+ ServiceClient = class {
448
+ constructor(apiBaseUrl, session) {
449
+ this.cacheManager = CacheManager.getInstance();
450
+ this.baseUrl = apiBaseUrl;
451
+ this.session = session;
452
+ }
453
+ buildFullPath(path, params) {
454
+ let updatedPath = path;
455
+ if (params) {
456
+ Object.keys(params).forEach((key) => {
457
+ updatedPath = updatedPath.replace(
458
+ `{${key}}`,
459
+ String(params[key])
460
+ );
461
+ });
462
+ }
463
+ return this.baseUrl + updatedPath;
464
+ }
465
+ getConfig() {
466
+ const config = { headers: {} };
467
+ if (this.session) {
468
+ if (this.session.oAuthToken) {
469
+ config.headers["Authorization"] = "Bearer " + this.session.oAuthToken;
470
+ }
471
+ config.headers["cid"] = this.session.cid || "";
472
+ config.headers["UserCurrencyCode"] = this.session.userCurrencyCode || "INR";
473
+ config.headers["MarketCode"] = this.session?.marketCode || "IND";
474
+ }
475
+ return config;
476
+ }
477
+ handleFetchError(error) {
478
+ console.log(error);
479
+ const serverApiError = error;
480
+ if (serverApiError) {
481
+ return serverApiError.data;
482
+ }
483
+ return {
484
+ message: "There is some error. Please try after sometime.",
485
+ isSuccessful: false
486
+ };
487
+ }
488
+ async fetchJsonWithCache(fullPath, config) {
489
+ const cacheKey = fullPath + "--" + (this.session?.marketCode || "IND");
490
+ const cachedData = this.cacheManager.get(cacheKey);
491
+ if (cachedData) {
492
+ return cachedData;
493
+ }
494
+ console.log("*****************CALLING API:", cacheKey, (/* @__PURE__ */ new Date()).toISOString());
495
+ const response = await fetch(fullPath, { headers: config.headers });
496
+ if (!response.ok) {
497
+ const apiErrorData = await response.json();
498
+ throw new ServerApiError(apiErrorData, response.status);
499
+ }
500
+ const cacheControl = response.headers.get("Cache-Control");
501
+ let revalidate = null;
502
+ if (cacheControl) {
503
+ const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
504
+ if (maxAgeMatch && maxAgeMatch[1]) {
505
+ const maxAge = parseInt(maxAgeMatch[1], 10);
506
+ revalidate = maxAge * 1e3;
507
+ }
508
+ }
509
+ const data = await response.json();
510
+ data.isSuccessful = true;
511
+ if (revalidate !== null && revalidate > 0) {
512
+ console.log("revalidate............I am caching:" + revalidate);
513
+ this.cacheManager.set(cacheKey, data, revalidate);
514
+ }
515
+ return data;
516
+ }
517
+ // private async refreshToken(): Promise<void> {
518
+ // console.log("*******************calling refresh token***********************");
519
+ // try {
520
+ // const response = await fetch(this.baseUrl + "/auth/storefront/login/refreshToken", {
521
+ // method: 'POST',
522
+ // headers: {
523
+ // 'Content-Type': 'application/json'
524
+ // },
525
+ // body: JSON.stringify({ refreshToken: this.session.refreshToken })
526
+ // });
527
+ // if (!response.ok) {
528
+ // throw new Error("Failed to refresh token");
529
+ // }
530
+ // const responseData = await response.json();
531
+ // this.session.oAuthToken = responseData.result.accessToken;
532
+ // if (typeof window === "undefined") {
533
+ // // Running on the server
534
+ // } else {
535
+ // await fetch("/api/login", {
536
+ // method: "post",
537
+ // headers: {
538
+ // "Content-Type": "application/json",
539
+ // },
540
+ // body: JSON.stringify({ session: this.session }),
541
+ // });
542
+ // }
543
+ // } catch (error: any) {
544
+ // throw new Error("Failed to refresh token");
545
+ // }
546
+ // }
547
+ async handleRequest(request) {
548
+ try {
549
+ return await request();
550
+ } catch (error) {
551
+ throw error;
552
+ }
553
+ }
554
+ async post(path, data) {
555
+ const request = async () => {
556
+ const fullPath = this.baseUrl + path;
557
+ const config = this.getConfig();
558
+ const response = await fetch(fullPath, {
559
+ method: "POST",
560
+ headers: {
561
+ ...config.headers,
562
+ "Content-Type": "application/json"
563
+ },
564
+ body: JSON.stringify(data)
565
+ });
566
+ if (!response.ok) {
567
+ const apiErrorData = await response.json();
568
+ throw new ServerApiError(apiErrorData, response.status);
569
+ }
570
+ const responseData = await response.json();
571
+ responseData.isSuccessful = true;
572
+ return responseData;
573
+ };
574
+ try {
575
+ return await this.handleRequest(request);
576
+ } catch (error) {
577
+ return this.handleFetchError(error);
578
+ }
579
+ }
580
+ async getSingle(path, params) {
581
+ const request = async () => {
582
+ const sanitizedParams = params ? Object.fromEntries(
583
+ Object.entries(params).map(([k, v]) => [k, String(v)])
584
+ ) : void 0;
585
+ const fullPath = this.buildFullPath(path, sanitizedParams);
586
+ const config = this.getConfig();
587
+ return await this.fetchJsonWithCache(fullPath, config);
588
+ };
589
+ try {
590
+ return await this.handleRequest(request);
591
+ } catch (error) {
592
+ return this.handleFetchError(error);
593
+ }
594
+ }
595
+ async get(path, params) {
596
+ const request = async () => {
597
+ const sanitizedParams = params ? Object.fromEntries(
598
+ Object.entries(params).map(([k, v]) => [k, String(v)])
599
+ ) : void 0;
600
+ const fullPath = this.buildFullPath(path, sanitizedParams);
601
+ const config = this.getConfig();
602
+ console.log(fullPath);
603
+ return await this.fetchJsonWithCache(fullPath, config);
604
+ };
605
+ try {
606
+ return await this.handleRequest(request);
607
+ } catch (error) {
608
+ return this.handleFetchError(error);
609
+ }
610
+ }
611
+ };
612
+ ServiceClient_default = ServiceClient;
613
+ }
614
+ });
615
+
616
+ // src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
617
+ var LinkNodeButton_exports = {};
618
+ __export(LinkNodeButton_exports, {
619
+ default: () => LinkNodeButton_default
620
+ });
621
+ var import_react35, import_jsx_runtime45, LinkNodeButton, LinkNodeButton_default;
622
+ var init_LinkNodeButton = __esm({
623
+ "src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx"() {
624
+ "use strict";
625
+ "use client";
626
+ import_react35 = require("react");
627
+ init_Button();
628
+ init_ServiceClient();
629
+ import_jsx_runtime45 = require("react/jsx-runtime");
630
+ LinkNodeButton = (props) => {
631
+ const { node, dataitem, children, linkText, linkType, linkUrl } = props;
632
+ const [isLoading, setIsLoading] = (0, import_react35.useState)(false);
633
+ const [error, setError] = (0, import_react35.useState)(null);
634
+ const extractFieldNames = (0, import_react35.useCallback)((template) => {
635
+ if (!template) return [];
636
+ const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
637
+ const matches = Array.from(template.matchAll(regex));
638
+ const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
639
+ return fieldNames;
640
+ }, []);
641
+ const replaceTemplateVariables = (0, import_react35.useCallback)((template, responseData) => {
642
+ if (!template) return template;
643
+ let result = template;
644
+ const fieldNames = extractFieldNames(template);
645
+ if (responseData) {
646
+ fieldNames.forEach((fieldName) => {
647
+ const value = getNestedValue3(responseData, fieldName);
648
+ if (value !== void 0) {
649
+ const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
650
+ const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
651
+ result = result.replace(regex1, String(value));
652
+ result = result.replace(regex2, String(value));
653
+ }
654
+ });
655
+ }
656
+ if (props.routeParameters) {
657
+ Object.entries(props.routeParameters).forEach(([key, value]) => {
658
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
659
+ result = result.replace(regex, String(value));
660
+ });
661
+ }
662
+ if (dataitem) {
663
+ Object.entries(dataitem).forEach(([key, value]) => {
664
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
665
+ result = result.replace(regex, String(value));
666
+ });
667
+ }
668
+ return result;
669
+ }, [props.routeParameters, dataitem, extractFieldNames]);
670
+ const getNestedValue3 = (0, import_react35.useCallback)((obj, path) => {
671
+ if (!obj || !path) return void 0;
672
+ if (obj[path] !== void 0) {
673
+ return obj[path];
674
+ }
675
+ const keys = path.split(".");
676
+ let current = obj;
677
+ for (const key of keys) {
678
+ if (current[key] === void 0) {
679
+ return void 0;
680
+ }
681
+ current = current[key];
682
+ }
683
+ return current;
684
+ }, []);
685
+ const onClick = (0, import_react35.useCallback)(async (e) => {
686
+ if (!node.postUrl) {
687
+ setError("No POST URL configured for this button");
688
+ return;
689
+ }
690
+ setIsLoading(true);
691
+ setError(null);
692
+ try {
693
+ const resolvedPostUrl = replaceTemplateVariables(node.postUrl);
694
+ let parsedPayload = {};
695
+ if (node.payload) {
696
+ try {
697
+ const payloadStr = replaceTemplateVariables(node.payload);
698
+ parsedPayload = JSON.parse(payloadStr);
699
+ console.log("Parsed payload:", parsedPayload);
700
+ } catch (err) {
701
+ console.error("Failed to parse payload JSON:", err);
702
+ parsedPayload = { error: "Invalid payload JSON" };
703
+ }
704
+ }
705
+ const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
706
+ const response = await serviceClient.post(resolvedPostUrl, parsedPayload);
707
+ console.log("API Response:", response);
708
+ if (response && !response.isSuccessful) {
709
+ const errorMessage = response.message || "API request failed";
710
+ setError(errorMessage);
711
+ setIsLoading(false);
712
+ return { isSuccessful: false, message: errorMessage };
713
+ }
714
+ if (response && node.redirectUrl) {
715
+ const fieldNames = extractFieldNames(node.redirectUrl);
716
+ console.log("Field names in redirect URL:", fieldNames);
717
+ const fieldValueMap = {};
718
+ fieldNames.forEach((fieldName) => {
719
+ const value = getNestedValue3(response, fieldName);
720
+ if (value !== void 0) {
721
+ fieldValueMap[fieldName] = String(value);
722
+ } else {
723
+ const resultValue = getNestedValue3(response, `result.${fieldName}`);
724
+ if (resultValue !== void 0) {
725
+ fieldValueMap[fieldName] = String(resultValue);
726
+ } else {
727
+ const dataValue = getNestedValue3(response, `data.${fieldName}`);
728
+ if (dataValue !== void 0) {
729
+ fieldValueMap[fieldName] = String(dataValue);
730
+ }
731
+ }
732
+ }
733
+ });
734
+ console.log("Field value map:", fieldValueMap);
735
+ const missingFields = fieldNames.filter((fieldName) => !fieldValueMap[fieldName]);
736
+ if (missingFields.length > 0) {
737
+ console.warn(`Missing field values for: ${missingFields.join(", ")}`);
738
+ }
739
+ let resolvedRedirectUrl = node.redirectUrl;
740
+ Object.entries(fieldValueMap).forEach(([fieldName, value]) => {
741
+ const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
742
+ const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
743
+ resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
744
+ resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
745
+ });
746
+ resolvedRedirectUrl = replaceTemplateVariables(resolvedRedirectUrl, response);
747
+ console.log("Final redirect URL:", resolvedRedirectUrl);
748
+ if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
749
+ window.location.href = resolvedRedirectUrl;
750
+ }
751
+ } else if (response && !response.result && response.message) {
752
+ setError(response.message);
753
+ throw new Error(response.message);
754
+ } else if (!response) {
755
+ setError("No response from server");
756
+ }
757
+ setIsLoading(false);
758
+ return { isSuccessful: true, response };
759
+ } catch (err) {
760
+ console.error("Button API call failed:", err);
761
+ setError(err.message || "An unexpected error occurred");
762
+ setIsLoading(false);
763
+ return { isSuccessful: false, message: err.message };
764
+ }
765
+ }, [node.postUrl, node.payload, node.redirectUrl, replaceTemplateVariables, extractFieldNames, getNestedValue3, props.apiBaseUrl, props.session]);
766
+ const renderButtonContent = () => {
767
+ if (children) {
768
+ return children;
769
+ }
770
+ if (linkText) {
771
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: linkText });
772
+ }
773
+ return node.title || "Button";
774
+ };
775
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "link-button-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
776
+ Button_default,
777
+ {
778
+ ButtonType: linkType,
779
+ onClick,
780
+ disabled: isLoading,
781
+ className: "w-full",
782
+ children: renderButtonContent()
783
+ }
784
+ ) });
785
+ };
786
+ LinkNodeButton_default = LinkNodeButton;
787
+ }
788
+ });
789
+
172
790
  // src/components/CopyButton.tsx
173
791
  var CopyButton_exports = {};
174
792
  __export(CopyButton_exports, {
@@ -1561,197 +2179,8 @@ var SelectWithSearchInput = (props) => {
1561
2179
  };
1562
2180
  var SelectWithSearchInput_default = SelectWithSearchInput;
1563
2181
 
1564
- // src/components/Button.tsx
1565
- var import_react24 = __toESM(require("react"));
1566
-
1567
- // src/components/ToastService.tsx
1568
- var ToastService = class _ToastService {
1569
- static initialize(showToast, closeToast) {
1570
- _ToastService.showToast = showToast;
1571
- _ToastService.closeToast = closeToast;
1572
- }
1573
- static showError(message) {
1574
- if (_ToastService.showToast) {
1575
- _ToastService.showToast(message, "error");
1576
- }
1577
- }
1578
- static showInfo(message) {
1579
- if (_ToastService.showToast) {
1580
- _ToastService.showToast(message, "info");
1581
- }
1582
- }
1583
- static close() {
1584
- if (_ToastService.closeToast) {
1585
- _ToastService.closeToast();
1586
- }
1587
- }
1588
- };
1589
- var ToastService_default = ToastService;
1590
-
1591
- // src/components/StyleTypes.tsx
1592
- var buttonClasses = /* @__PURE__ */ new Map([
1593
- ["Primary" /* Solid */, "btn-solid"],
1594
- ["PrimaryHollow" /* Hollow */, "btn-hollow"],
1595
- ["Link" /* Link */, "btn-link"]
1596
- ]);
1597
- var progressClasses = /* @__PURE__ */ new Map([
1598
- ["Primary" /* Solid */, ""],
1599
- ["PrimaryHollow" /* Hollow */, ""],
1600
- ["Link" /* Link */, ""]
1601
- ]);
1602
-
1603
- // src/components/Confirm.tsx
1604
- var import_react23 = require("react");
1605
-
1606
- // src/components/ClientButton.tsx
1607
- var import_react22 = __toESM(require("react"));
1608
- var import_jsx_runtime23 = require("react/jsx-runtime");
1609
- var ClientButton = (props) => {
1610
- const execute = async (event) => {
1611
- if (props.onClick !== void 0) {
1612
- props.onClick();
1613
- } else {
1614
- ToastService_default.showError("No action defined.");
1615
- }
1616
- };
1617
- let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
1618
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react22.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1619
- "button",
1620
- {
1621
- type: "button",
1622
- onClick: execute,
1623
- className: buttonClass + " " + props.className,
1624
- children: props.children
1625
- }
1626
- ) });
1627
- };
1628
- var ClientButton_default = ClientButton;
1629
-
1630
- // src/components/Confirm.tsx
1631
- var import_jsx_runtime24 = require("react/jsx-runtime");
1632
- var Confirm = ({ message, onConfirm, onCancel }) => {
1633
- const [showModal, setShowModal] = (0, import_react23.useState)(true);
1634
- const handleConfirmAction = () => {
1635
- setShowModal(false);
1636
- if (onConfirm) {
1637
- onConfirm();
1638
- }
1639
- };
1640
- const handleCancelAction = () => {
1641
- setShowModal(false);
1642
- if (onCancel) {
1643
- onCancel();
1644
- }
1645
- };
1646
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: showModal && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
1647
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute inset-0 bg-black opacity-70" }),
1648
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
1649
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
1650
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "mb-4", children: message }),
1651
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex justify-end gap-8", children: [
1652
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1653
- ClientButton_default,
1654
- {
1655
- onClick: handleCancelAction,
1656
- ButtonType: "PrimaryHollow" /* Hollow */,
1657
- children: "Cancel"
1658
- }
1659
- ),
1660
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1661
- ClientButton_default,
1662
- {
1663
- onClick: handleConfirmAction,
1664
- children: "Confirm"
1665
- }
1666
- )
1667
- ] })
1668
- ] })
1669
- ] }) });
1670
- };
1671
- var Confirm_default = Confirm;
1672
- {
1673
- }
1674
-
1675
- // src/components/Button.tsx
1676
- var import_jsx_runtime25 = require("react/jsx-runtime");
1677
- var Button = (props) => {
1678
- const [inProgress, setInProgress] = (0, import_react24.useState)(false);
1679
- const [isActionPerformed, setIsActionPerformed] = (0, import_react24.useState)(false);
1680
- const [responseMessage, setResponseMessage] = (0, import_react24.useState)(null);
1681
- const [showModal, setShowModal] = (0, import_react24.useState)(null);
1682
- const execute = async (event) => {
1683
- event.preventDefault();
1684
- event.stopPropagation();
1685
- if (props.confirm) {
1686
- const confirmed = await showConfirmation("Are you sure you want to delete this item?");
1687
- setShowModal(null);
1688
- if (!confirmed) {
1689
- return;
1690
- }
1691
- }
1692
- if (props.oneTimeAction && isActionPerformed) {
1693
- return;
1694
- }
1695
- setInProgress(true);
1696
- let isValid = true;
1697
- if (props.onValidate !== void 0) {
1698
- isValid = await props.onValidate();
1699
- if (!isValid) {
1700
- setInProgress(false);
1701
- ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
1702
- return;
1703
- }
1704
- }
1705
- if (props.onClick !== void 0) {
1706
- let response = await props.onClick();
1707
- if (response.isSuccessful) {
1708
- setIsActionPerformed(true);
1709
- setResponseMessage(response.message);
1710
- if (props.showToast) {
1711
- ToastService_default.showInfo(response.message || "");
1712
- }
1713
- } else {
1714
- ToastService_default.showError(response.message || "");
1715
- }
1716
- } else {
1717
- ToastService_default.showError("No action defined.");
1718
- }
1719
- setInProgress(false);
1720
- };
1721
- const showConfirmation = (message) => {
1722
- return new Promise((resolve) => {
1723
- const onConfirm = () => resolve(true);
1724
- const onCancel = () => resolve(false);
1725
- setShowModal(/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
1726
- });
1727
- };
1728
- let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
1729
- let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
1730
- const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
1731
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react24.default.Fragment, { children: [
1732
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
1733
- "button",
1734
- {
1735
- type: "submit",
1736
- onClick: execute,
1737
- disabled: props.disabled,
1738
- title: isDisabled ? "The button is disabled to prevent any action" : "",
1739
- className: buttonClass + " relative " + props.className,
1740
- children: [
1741
- isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
1742
- inProgress && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react24.default.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
1743
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
1744
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
1745
- ] }) })
1746
- ]
1747
- }
1748
- ),
1749
- showModal
1750
- ] });
1751
- };
1752
- var Button_default = Button;
1753
-
1754
2182
  // src/components/controls/edit/SelectWithSearchPanel.tsx
2183
+ init_Button();
1755
2184
  var import_react25 = __toESM(require("react"));
1756
2185
  var import_jsx_runtime26 = require("react/jsx-runtime");
1757
2186
  var SelectWithSearchPanel = (props) => {
@@ -2253,6 +2682,7 @@ var ContentView_default = ContentView;
2253
2682
 
2254
2683
  // src/components/dataForm/Hyperlink.tsx
2255
2684
  var import_link = __toESM(require("next/link"));
2685
+ init_StyleTypes();
2256
2686
  var import_jsx_runtime33 = require("react/jsx-runtime");
2257
2687
  function Hyperlink(props) {
2258
2688
  let linkClass = props.linkType ? buttonClasses.get(props.linkType) : "";
@@ -2274,6 +2704,9 @@ function Hyperlink(props) {
2274
2704
  ) : props.isHeading ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("h5", { className: props.className + "inline-block", children: props.children }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: props.className, children: props.children }) });
2275
2705
  }
2276
2706
 
2707
+ // src/components/dataForm/DataList.tsx
2708
+ init_StyleTypes();
2709
+
2277
2710
  // src/clients/OdataBuilder.tsx
2278
2711
  var OdataBuilder = class {
2279
2712
  constructor(url) {
@@ -3331,376 +3764,13 @@ var ImageNode = (props) => {
3331
3764
  };
3332
3765
  var ImageNode_default = ImageNode;
3333
3766
 
3334
- // src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
3335
- var import_react35 = require("react");
3336
-
3337
- // src/clients/CacheManage.tsx
3338
- var import_node_cache = __toESM(require("node-cache"));
3339
- var CacheManager = class _CacheManager {
3340
- constructor() {
3341
- this.maxCacheSize = 1e3;
3342
- this.cache = new import_node_cache.default({ stdTTL: 0, checkperiod: 300 });
3343
- }
3344
- static getInstance() {
3345
- if (!_CacheManager.instance) {
3346
- _CacheManager.instance = new _CacheManager();
3347
- }
3348
- return _CacheManager.instance;
3349
- }
3350
- get(key) {
3351
- return null;
3352
- }
3353
- set(key, data, ttl) {
3354
- }
3355
- clear() {
3356
- this.cache.flushAll();
3357
- }
3358
- size() {
3359
- return this.cache.keys().length;
3360
- }
3361
- destroy() {
3362
- this.cache.close();
3363
- }
3364
- };
3365
-
3366
- // src/clients/ServiceClient.tsx
3367
- var ServerApiError = class extends Error {
3368
- constructor(data, status) {
3369
- super(data.message || "---");
3370
- this.status = status;
3371
- this.data = data;
3372
- this.data.isSuccessful = false;
3373
- }
3374
- };
3375
- var ServiceClient = class {
3376
- constructor(apiBaseUrl, session) {
3377
- this.cacheManager = CacheManager.getInstance();
3378
- this.baseUrl = apiBaseUrl;
3379
- this.session = session;
3380
- }
3381
- buildFullPath(path, params) {
3382
- let updatedPath = path;
3383
- if (params) {
3384
- Object.keys(params).forEach((key) => {
3385
- updatedPath = updatedPath.replace(
3386
- `{${key}}`,
3387
- String(params[key])
3388
- );
3389
- });
3390
- }
3391
- return this.baseUrl + updatedPath;
3392
- }
3393
- getConfig() {
3394
- const config = { headers: {} };
3395
- if (this.session) {
3396
- if (this.session.oAuthToken) {
3397
- config.headers["Authorization"] = "Bearer " + this.session.oAuthToken;
3398
- }
3399
- config.headers["cid"] = this.session.cid || "";
3400
- config.headers["UserCurrencyCode"] = this.session.userCurrencyCode || "INR";
3401
- config.headers["MarketCode"] = this.session?.marketCode || "IND";
3402
- }
3403
- return config;
3404
- }
3405
- handleFetchError(error) {
3406
- console.log(error);
3407
- const serverApiError = error;
3408
- if (serverApiError) {
3409
- return serverApiError.data;
3410
- }
3411
- return {
3412
- message: "There is some error. Please try after sometime.",
3413
- isSuccessful: false
3414
- };
3415
- }
3416
- async fetchJsonWithCache(fullPath, config) {
3417
- const cacheKey = fullPath + "--" + (this.session?.marketCode || "IND");
3418
- const cachedData = this.cacheManager.get(cacheKey);
3419
- if (cachedData) {
3420
- return cachedData;
3421
- }
3422
- console.log("*****************CALLING API:", cacheKey, (/* @__PURE__ */ new Date()).toISOString());
3423
- const response = await fetch(fullPath, { headers: config.headers });
3424
- if (!response.ok) {
3425
- const apiErrorData = await response.json();
3426
- throw new ServerApiError(apiErrorData, response.status);
3427
- }
3428
- const cacheControl = response.headers.get("Cache-Control");
3429
- let revalidate = null;
3430
- if (cacheControl) {
3431
- const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
3432
- if (maxAgeMatch && maxAgeMatch[1]) {
3433
- const maxAge = parseInt(maxAgeMatch[1], 10);
3434
- revalidate = maxAge * 1e3;
3435
- }
3436
- }
3437
- const data = await response.json();
3438
- data.isSuccessful = true;
3439
- if (revalidate !== null && revalidate > 0) {
3440
- console.log("revalidate............I am caching:" + revalidate);
3441
- this.cacheManager.set(cacheKey, data, revalidate);
3442
- }
3443
- return data;
3444
- }
3445
- // private async refreshToken(): Promise<void> {
3446
- // console.log("*******************calling refresh token***********************");
3447
- // try {
3448
- // const response = await fetch(this.baseUrl + "/auth/storefront/login/refreshToken", {
3449
- // method: 'POST',
3450
- // headers: {
3451
- // 'Content-Type': 'application/json'
3452
- // },
3453
- // body: JSON.stringify({ refreshToken: this.session.refreshToken })
3454
- // });
3455
- // if (!response.ok) {
3456
- // throw new Error("Failed to refresh token");
3457
- // }
3458
- // const responseData = await response.json();
3459
- // this.session.oAuthToken = responseData.result.accessToken;
3460
- // if (typeof window === "undefined") {
3461
- // // Running on the server
3462
- // } else {
3463
- // await fetch("/api/login", {
3464
- // method: "post",
3465
- // headers: {
3466
- // "Content-Type": "application/json",
3467
- // },
3468
- // body: JSON.stringify({ session: this.session }),
3469
- // });
3470
- // }
3471
- // } catch (error: any) {
3472
- // throw new Error("Failed to refresh token");
3473
- // }
3474
- // }
3475
- async handleRequest(request) {
3476
- try {
3477
- return await request();
3478
- } catch (error) {
3479
- throw error;
3480
- }
3481
- }
3482
- async post(path, data) {
3483
- const request = async () => {
3484
- const fullPath = this.baseUrl + path;
3485
- const config = this.getConfig();
3486
- const response = await fetch(fullPath, {
3487
- method: "POST",
3488
- headers: {
3489
- ...config.headers,
3490
- "Content-Type": "application/json"
3491
- },
3492
- body: JSON.stringify(data)
3493
- });
3494
- if (!response.ok) {
3495
- const apiErrorData = await response.json();
3496
- throw new ServerApiError(apiErrorData, response.status);
3497
- }
3498
- const responseData = await response.json();
3499
- responseData.isSuccessful = true;
3500
- return responseData;
3501
- };
3502
- try {
3503
- return await this.handleRequest(request);
3504
- } catch (error) {
3505
- return this.handleFetchError(error);
3506
- }
3507
- }
3508
- async getSingle(path, params) {
3509
- const request = async () => {
3510
- const sanitizedParams = params ? Object.fromEntries(
3511
- Object.entries(params).map(([k, v]) => [k, String(v)])
3512
- ) : void 0;
3513
- const fullPath = this.buildFullPath(path, sanitizedParams);
3514
- const config = this.getConfig();
3515
- return await this.fetchJsonWithCache(fullPath, config);
3516
- };
3517
- try {
3518
- return await this.handleRequest(request);
3519
- } catch (error) {
3520
- return this.handleFetchError(error);
3521
- }
3522
- }
3523
- async get(path, params) {
3524
- const request = async () => {
3525
- const sanitizedParams = params ? Object.fromEntries(
3526
- Object.entries(params).map(([k, v]) => [k, String(v)])
3527
- ) : void 0;
3528
- const fullPath = this.buildFullPath(path, sanitizedParams);
3529
- const config = this.getConfig();
3530
- console.log(fullPath);
3531
- return await this.fetchJsonWithCache(fullPath, config);
3532
- };
3533
- try {
3534
- return await this.handleRequest(request);
3535
- } catch (error) {
3536
- return this.handleFetchError(error);
3537
- }
3538
- }
3539
- };
3540
- var ServiceClient_default = ServiceClient;
3541
-
3542
- // src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
3543
- var import_jsx_runtime45 = require("react/jsx-runtime");
3544
- var LinkNodeButton = (props) => {
3545
- const { node, dataitem, children, linkText, linkType, linkUrl } = props;
3546
- const [isLoading, setIsLoading] = (0, import_react35.useState)(false);
3547
- const [error, setError] = (0, import_react35.useState)(null);
3548
- const extractFieldNames = (0, import_react35.useCallback)((template) => {
3549
- if (!template) return [];
3550
- const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
3551
- const matches = Array.from(template.matchAll(regex));
3552
- const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
3553
- return fieldNames;
3554
- }, []);
3555
- const replaceTemplateVariables = (0, import_react35.useCallback)((template, responseData) => {
3556
- if (!template) return template;
3557
- let result = template;
3558
- const fieldNames = extractFieldNames(template);
3559
- if (responseData) {
3560
- fieldNames.forEach((fieldName) => {
3561
- const value = getNestedValue3(responseData, fieldName);
3562
- if (value !== void 0) {
3563
- const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
3564
- const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
3565
- result = result.replace(regex1, String(value));
3566
- result = result.replace(regex2, String(value));
3567
- }
3568
- });
3569
- }
3570
- if (props.routeParameters) {
3571
- Object.entries(props.routeParameters).forEach(([key, value]) => {
3572
- const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
3573
- result = result.replace(regex, String(value));
3574
- });
3575
- }
3576
- if (dataitem) {
3577
- Object.entries(dataitem).forEach(([key, value]) => {
3578
- const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
3579
- result = result.replace(regex, String(value));
3580
- });
3581
- }
3582
- return result;
3583
- }, [props.routeParameters, dataitem, extractFieldNames]);
3584
- const getNestedValue3 = (0, import_react35.useCallback)((obj, path) => {
3585
- if (!obj || !path) return void 0;
3586
- if (obj[path] !== void 0) {
3587
- return obj[path];
3588
- }
3589
- const keys = path.split(".");
3590
- let current = obj;
3591
- for (const key of keys) {
3592
- if (current[key] === void 0) {
3593
- return void 0;
3594
- }
3595
- current = current[key];
3596
- }
3597
- return current;
3598
- }, []);
3599
- const onClick = (0, import_react35.useCallback)(async (e) => {
3600
- if (!node.postUrl) {
3601
- setError("No POST URL configured for this button");
3602
- return;
3603
- }
3604
- setIsLoading(true);
3605
- setError(null);
3606
- try {
3607
- const resolvedPostUrl = replaceTemplateVariables(node.postUrl);
3608
- let parsedPayload = {};
3609
- if (node.payload) {
3610
- try {
3611
- const payloadStr = replaceTemplateVariables(node.payload);
3612
- parsedPayload = JSON.parse(payloadStr);
3613
- console.log("Parsed payload:", parsedPayload);
3614
- } catch (err) {
3615
- console.error("Failed to parse payload JSON:", err);
3616
- parsedPayload = { error: "Invalid payload JSON" };
3617
- }
3618
- }
3619
- const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
3620
- const response = await serviceClient.post(resolvedPostUrl, parsedPayload);
3621
- console.log("API Response:", response);
3622
- if (response && !response.isSuccessful) {
3623
- const errorMessage = response.message || "API request failed";
3624
- setError(errorMessage);
3625
- setIsLoading(false);
3626
- return { isSuccessful: false, message: errorMessage };
3627
- }
3628
- if (response && node.redirectUrl) {
3629
- const fieldNames = extractFieldNames(node.redirectUrl);
3630
- console.log("Field names in redirect URL:", fieldNames);
3631
- const fieldValueMap = {};
3632
- fieldNames.forEach((fieldName) => {
3633
- const value = getNestedValue3(response, fieldName);
3634
- if (value !== void 0) {
3635
- fieldValueMap[fieldName] = String(value);
3636
- } else {
3637
- const resultValue = getNestedValue3(response, `result.${fieldName}`);
3638
- if (resultValue !== void 0) {
3639
- fieldValueMap[fieldName] = String(resultValue);
3640
- } else {
3641
- const dataValue = getNestedValue3(response, `data.${fieldName}`);
3642
- if (dataValue !== void 0) {
3643
- fieldValueMap[fieldName] = String(dataValue);
3644
- }
3645
- }
3646
- }
3647
- });
3648
- console.log("Field value map:", fieldValueMap);
3649
- const missingFields = fieldNames.filter((fieldName) => !fieldValueMap[fieldName]);
3650
- if (missingFields.length > 0) {
3651
- console.warn(`Missing field values for: ${missingFields.join(", ")}`);
3652
- }
3653
- let resolvedRedirectUrl = node.redirectUrl;
3654
- Object.entries(fieldValueMap).forEach(([fieldName, value]) => {
3655
- const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
3656
- const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
3657
- resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
3658
- resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
3659
- });
3660
- resolvedRedirectUrl = replaceTemplateVariables(resolvedRedirectUrl, response);
3661
- console.log("Final redirect URL:", resolvedRedirectUrl);
3662
- if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
3663
- window.location.href = resolvedRedirectUrl;
3664
- }
3665
- } else if (response && !response.result && response.message) {
3666
- setError(response.message);
3667
- throw new Error(response.message);
3668
- } else if (!response) {
3669
- setError("No response from server");
3670
- }
3671
- setIsLoading(false);
3672
- return { isSuccessful: true, response };
3673
- } catch (err) {
3674
- console.error("Button API call failed:", err);
3675
- setError(err.message || "An unexpected error occurred");
3676
- setIsLoading(false);
3677
- return { isSuccessful: false, message: err.message };
3678
- }
3679
- }, [node.postUrl, node.payload, node.redirectUrl, replaceTemplateVariables, extractFieldNames, getNestedValue3, props.apiBaseUrl, props.session]);
3680
- const renderButtonContent = () => {
3681
- if (children) {
3682
- return children;
3683
- }
3684
- if (linkText) {
3685
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: linkText });
3686
- }
3687
- return node.title || "Button";
3688
- };
3689
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "link-button-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3690
- Button_default,
3691
- {
3692
- ButtonType: linkType,
3693
- onClick,
3694
- disabled: isLoading,
3695
- className: "w-full",
3696
- children: renderButtonContent()
3697
- }
3698
- ) });
3699
- };
3700
- var LinkNodeButton_default = LinkNodeButton;
3701
-
3702
3767
  // src/components/pageRenderingEngine/nodes/LinkNode.tsx
3768
+ init_StyleTypes();
3769
+ var import_dynamic2 = __toESM(require("next/dynamic"));
3703
3770
  var import_jsx_runtime46 = require("react/jsx-runtime");
3771
+ var LinkNodeButton2 = (0, import_dynamic2.default)(() => Promise.resolve().then(() => (init_LinkNodeButton(), LinkNodeButton_exports)), {
3772
+ ssr: false
3773
+ });
3704
3774
  var LinkNode = (props) => {
3705
3775
  const NodeTypes2 = {
3706
3776
  text: TextNode_default,
@@ -3772,7 +3842,7 @@ var LinkNode = (props) => {
3772
3842
  };
3773
3843
  if (isButton) {
3774
3844
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
3775
- LinkNodeButton_default,
3845
+ LinkNodeButton2,
3776
3846
  {
3777
3847
  node,
3778
3848
  dataitem,
@@ -4124,9 +4194,9 @@ var QuoteNode_default = QuoteNode;
4124
4194
 
4125
4195
  // src/components/pageRenderingEngine/nodes/CodeNode.tsx
4126
4196
  var import_react43 = __toESM(require("react"));
4127
- var import_dynamic2 = __toESM(require("next/dynamic"));
4197
+ var import_dynamic3 = __toESM(require("next/dynamic"));
4128
4198
  var import_jsx_runtime56 = require("react/jsx-runtime");
4129
- var CopyButton2 = (0, import_dynamic2.default)(() => Promise.resolve().then(() => (init_CopyButton(), CopyButton_exports)), {
4199
+ var CopyButton2 = (0, import_dynamic3.default)(() => Promise.resolve().then(() => (init_CopyButton(), CopyButton_exports)), {
4130
4200
  ssr: false,
4131
4201
  // optional: fallback UI while loading
4132
4202
  loading: () => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "text-gray-400 text-xs", children: "Copy" })
@@ -4294,6 +4364,7 @@ var InputControlNode = (props) => {
4294
4364
  var InputControlNode_default = InputControlNode;
4295
4365
 
4296
4366
  // src/components/pageRenderingEngine/nodes/FormContainerNode.tsx
4367
+ init_ServiceClient();
4297
4368
  var import_jsx_runtime60 = require("react/jsx-runtime");
4298
4369
  var FormContainerNode = (props) => {
4299
4370
  const NodeTypes2 = {
@@ -4347,9 +4418,9 @@ var FormContainerNode_default = FormContainerNode;
4347
4418
  var import_react49 = __toESM(require("react"));
4348
4419
 
4349
4420
  // src/components/pageRenderingEngine/nodes/EmbedNode.tsx
4350
- var import_dynamic3 = __toESM(require("next/dynamic"));
4421
+ var import_dynamic4 = __toESM(require("next/dynamic"));
4351
4422
  var import_jsx_runtime63 = require("react/jsx-runtime");
4352
- var IframeClient2 = (0, import_dynamic3.default)(() => Promise.resolve().then(() => (init_IframeClient(), IframeClient_exports)), {
4423
+ var IframeClient2 = (0, import_dynamic4.default)(() => Promise.resolve().then(() => (init_IframeClient(), IframeClient_exports)), {
4353
4424
  ssr: false
4354
4425
  });
4355
4426
  var EmbedNode = (props) => {
@@ -4365,6 +4436,9 @@ var EmbedNode = (props) => {
4365
4436
  };
4366
4437
  var EmbedNode_default = EmbedNode;
4367
4438
 
4439
+ // src/components/pageRenderingEngine/nodes/DivContainer.tsx
4440
+ init_ServiceClient();
4441
+
4368
4442
  // src/components/Slider.tsx
4369
4443
  var import_react47 = __toESM(require("react"));
4370
4444
  var import_jsx_runtime64 = require("react/jsx-runtime");
@@ -4871,6 +4945,7 @@ var NoDataFound_default = NoDataFound;
4871
4945
 
4872
4946
  // src/components/Pagination.tsx
4873
4947
  var import_react48 = require("react");
4948
+ init_StyleTypes();
4874
4949
  var import_jsx_runtime66 = require("react/jsx-runtime");
4875
4950
  var Pagination = (props) => {
4876
4951
  const { dataset, path, query, showPageSizeSelector = false, showJumpToPage = false } = props;
@@ -5038,9 +5113,9 @@ var Pagination = (props) => {
5038
5113
  var Pagination_default = Pagination;
5039
5114
 
5040
5115
  // src/components/pageRenderingEngine/nodes/ImageGalleryNode.tsx
5041
- var import_dynamic4 = __toESM(require("next/dynamic"));
5116
+ var import_dynamic5 = __toESM(require("next/dynamic"));
5042
5117
  var import_jsx_runtime67 = require("react/jsx-runtime");
5043
- var HlsPlayer1 = (0, import_dynamic4.default)(() => Promise.resolve().then(() => (init_HlsPlayer(), HlsPlayer_exports)), {
5118
+ var HlsPlayer1 = (0, import_dynamic5.default)(() => Promise.resolve().then(() => (init_HlsPlayer(), HlsPlayer_exports)), {
5044
5119
  ssr: false
5045
5120
  });
5046
5121
  var parseMaybeNumber = (value) => {