@codee-sh/medusa-plugin-notification-emails 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.medusa/server/emails-previews/contact-form.js +5 -7
  2. package/.medusa/server/emails-previews/inventory-level.js +23 -0
  3. package/.medusa/server/emails-previews/order-completed.js +20 -14
  4. package/.medusa/server/emails-previews/order-placed.js +19 -13
  5. package/.medusa/server/src/admin/index.js +385 -2364
  6. package/.medusa/server/src/admin/index.mjs +307 -2286
  7. package/.medusa/server/src/api/admin/notification-plugin/render-template/route.js +2 -2
  8. package/.medusa/server/src/hooks/api/orders.js +3 -2
  9. package/.medusa/server/src/templates/emails/base-template/index.js +23 -0
  10. package/.medusa/server/src/templates/emails/base-template/template.js +25 -0
  11. package/.medusa/server/src/templates/emails/blocks/components/heading.js +15 -0
  12. package/.medusa/server/src/templates/emails/blocks/components/product-item.js +14 -0
  13. package/.medusa/server/src/templates/emails/blocks/components/repeater.js +26 -0
  14. package/.medusa/server/src/templates/emails/blocks/components/row.js +13 -0
  15. package/.medusa/server/src/templates/emails/blocks/components/section.js +14 -0
  16. package/.medusa/server/src/templates/emails/blocks/components/separator.js +13 -0
  17. package/.medusa/server/src/templates/emails/blocks/components/text.js +15 -0
  18. package/.medusa/server/src/templates/emails/blocks/index.js +41 -0
  19. package/.medusa/server/src/templates/{shared/i18n → emails/blocks}/types.js +1 -1
  20. package/.medusa/server/src/templates/emails/contact-form/config.js +95 -0
  21. package/.medusa/server/src/templates/emails/contact-form/index.js +6 -17
  22. package/.medusa/server/src/templates/emails/contact-form/translations/de.json +14 -0
  23. package/.medusa/server/src/templates/emails/contact-form/translations/en.json +12 -14
  24. package/.medusa/server/src/templates/emails/contact-form/translations/pl.json +8 -10
  25. package/.medusa/server/src/templates/emails/index.js +183 -92
  26. package/.medusa/server/src/templates/emails/inventory-level/config.js +126 -0
  27. package/.medusa/server/src/templates/emails/inventory-level/index.js +6 -17
  28. package/.medusa/server/src/templates/emails/order-completed/config.js +233 -0
  29. package/.medusa/server/src/templates/emails/order-completed/index.js +6 -17
  30. package/.medusa/server/src/templates/emails/order-completed/translations/en.json +2 -1
  31. package/.medusa/server/src/templates/emails/order-completed/translations/pl.json +2 -1
  32. package/.medusa/server/src/templates/emails/order-placed/config.js +221 -0
  33. package/.medusa/server/src/templates/emails/order-placed/index.js +6 -17
  34. package/.medusa/server/src/templates/emails/order-placed/translations/en.json +1 -1
  35. package/.medusa/server/src/templates/emails/order-placed/translations/pl.json +1 -1
  36. package/.medusa/server/src/templates/emails/types.js +2 -1
  37. package/.medusa/server/src/utils/i18n/i18n.js +194 -0
  38. package/.medusa/server/src/utils/i18n/index.js +18 -0
  39. package/.medusa/server/src/utils/index.js +5 -1
  40. package/.medusa/server/src/utils/is-defined.js +7 -0
  41. package/.medusa/server/src/utils/is-object.js +7 -0
  42. package/.medusa/server/src/utils/pick-value-from-object.js +28 -0
  43. package/package.json +18 -11
  44. package/.medusa/server/src/templates/emails/contact-form/template.js +0 -28
  45. package/.medusa/server/src/templates/emails/contact-form/translations/index.js +0 -15
  46. package/.medusa/server/src/templates/emails/contact-form/types.js +0 -3
  47. package/.medusa/server/src/templates/emails/inventory-level/template.js +0 -28
  48. package/.medusa/server/src/templates/emails/inventory-level/types.js +0 -3
  49. package/.medusa/server/src/templates/emails/order-completed/template.js +0 -36
  50. package/.medusa/server/src/templates/emails/order-completed/types.js +0 -3
  51. package/.medusa/server/src/templates/emails/order-placed/template.js +0 -36
  52. package/.medusa/server/src/templates/emails/order-placed/types.js +0 -3
  53. package/.medusa/server/src/templates/shared/i18n/index.js +0 -6
  54. package/.medusa/server/src/templates/shared/i18n/languages.js +0 -187
  55. package/.medusa/server/src/templates/shared/i18n/utils.js +0 -186
@@ -5,11 +5,11 @@ const ui = require("@medusajs/ui");
5
5
  const reactI18next = require("react-i18next");
6
6
  const reactQuery = require("@tanstack/react-query");
7
7
  const Medusa = require("@medusajs/js-sdk");
8
- const React = require("react");
8
+ const react = require("react");
9
9
  const icons = require("@medusajs/icons");
10
10
  const reactRouterDom = require("react-router-dom");
11
- require("@react-email/render");
12
- require("@react-email/components");
11
+ const components = require("@react-email/components");
12
+ const render = require("@react-email/render");
13
13
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
14
  const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
15
15
  const sdk = new Medusa__default.default({
@@ -54,7 +54,7 @@ const Actions$1 = ({ onSend, isPending, isError, eventsData }) => {
54
54
  ] });
55
55
  };
56
56
  const SelectAction$1 = ({ onSend, isPending }) => {
57
- const [selectedEvent, setSelectedEvent] = React.useState("order.placed");
57
+ const [selectedEvent, setSelectedEvent] = react.useState("order.placed");
58
58
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
59
59
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-2", children: [
60
60
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "flex-shrink-0", children: "Select event:" }),
@@ -100,7 +100,7 @@ const Actions = ({ onSend, isPending, isError, eventsData }) => {
100
100
  ] });
101
101
  };
102
102
  const SelectAction = ({ onSend, isPending }) => {
103
- const [selectedEvent, setSelectedEvent] = React.useState("payment.captured");
103
+ const [selectedEvent, setSelectedEvent] = react.useState("payment.captured");
104
104
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
105
105
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-2", children: [
106
106
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "flex-shrink-0", children: "Select event:" }),
@@ -182,12 +182,12 @@ const useListNotifications = (params, options) => {
182
182
  return { data, ...rest };
183
183
  };
184
184
  const NotificationsList = ({ entityId, entityType }) => {
185
- const [pagination, setPagination] = React.useState({
185
+ const [pagination, setPagination] = react.useState({
186
186
  pageSize: 8,
187
187
  pageIndex: 0
188
188
  });
189
189
  const limit = 8;
190
- const offset = React.useMemo(() => {
190
+ const offset = react.useMemo(() => {
191
191
  return pagination.pageIndex * limit;
192
192
  }, [pagination]);
193
193
  const { data: notificationsData, isLoading: isNotificationsLoading } = useListNotifications({
@@ -307,19 +307,19 @@ function _objectWithoutPropertiesLoose(r, e) {
307
307
  return t;
308
308
  }
309
309
  var initialState$5 = {};
310
- var Context$5 = /* @__PURE__ */ React.createContext(initialState$5);
310
+ var Context$5 = /* @__PURE__ */ react.createContext(initialState$5);
311
311
  var reducer$5 = (state, action) => _extends({}, state, action);
312
312
  var useShowToolsStore = () => {
313
- return React.useContext(Context$5);
313
+ return react.useContext(Context$5);
314
314
  };
315
- var DispatchShowTools = /* @__PURE__ */ React.createContext(() => {
315
+ var DispatchShowTools = /* @__PURE__ */ react.createContext(() => {
316
316
  });
317
317
  DispatchShowTools.displayName = "JVR.DispatchShowTools";
318
318
  function useShowTools() {
319
- return React.useReducer(reducer$5, initialState$5);
319
+ return react.useReducer(reducer$5, initialState$5);
320
320
  }
321
321
  function useShowToolsDispatch() {
322
- return React.useContext(DispatchShowTools);
322
+ return react.useContext(DispatchShowTools);
323
323
  }
324
324
  var ShowTools = (_ref) => {
325
325
  var {
@@ -337,19 +337,19 @@ var ShowTools = (_ref) => {
337
337
  };
338
338
  ShowTools.displayName = "JVR.ShowTools";
339
339
  var initialState$4 = {};
340
- var Context$4 = /* @__PURE__ */ React.createContext(initialState$4);
340
+ var Context$4 = /* @__PURE__ */ react.createContext(initialState$4);
341
341
  var reducer$4 = (state, action) => _extends({}, state, action);
342
342
  var useExpandsStore = () => {
343
- return React.useContext(Context$4);
343
+ return react.useContext(Context$4);
344
344
  };
345
- var DispatchExpands = /* @__PURE__ */ React.createContext(() => {
345
+ var DispatchExpands = /* @__PURE__ */ react.createContext(() => {
346
346
  });
347
347
  DispatchExpands.displayName = "JVR.DispatchExpands";
348
348
  function useExpands() {
349
- return React.useReducer(reducer$4, initialState$4);
349
+ return react.useReducer(reducer$4, initialState$4);
350
350
  }
351
351
  function useExpandsDispatch() {
352
- return React.useContext(DispatchExpands);
352
+ return react.useContext(DispatchExpands);
353
353
  }
354
354
  var Expands = (_ref) => {
355
355
  var {
@@ -487,19 +487,19 @@ var initialState$3 = {
487
487
  children: "date"
488
488
  }
489
489
  };
490
- var Context$3 = /* @__PURE__ */ React.createContext(initialState$3);
490
+ var Context$3 = /* @__PURE__ */ react.createContext(initialState$3);
491
491
  var reducer$3 = (state, action) => _extends({}, state, action);
492
492
  var useTypesStore = () => {
493
- return React.useContext(Context$3);
493
+ return react.useContext(Context$3);
494
494
  };
495
- var DispatchTypes = /* @__PURE__ */ React.createContext(() => {
495
+ var DispatchTypes = /* @__PURE__ */ react.createContext(() => {
496
496
  });
497
497
  DispatchTypes.displayName = "JVR.DispatchTypes";
498
498
  function useTypes() {
499
- return React.useReducer(reducer$3, initialState$3);
499
+ return react.useReducer(reducer$3, initialState$3);
500
500
  }
501
501
  function useTypesDispatch() {
502
- return React.useContext(DispatchTypes);
502
+ return react.useContext(DispatchTypes);
503
503
  }
504
504
  function Types(_ref) {
505
505
  var {
@@ -608,19 +608,19 @@ var initialState$2 = {
608
608
  children: "}"
609
609
  }
610
610
  };
611
- var Context$2 = /* @__PURE__ */ React.createContext(initialState$2);
611
+ var Context$2 = /* @__PURE__ */ react.createContext(initialState$2);
612
612
  var reducer$2 = (state, action) => _extends({}, state, action);
613
613
  var useSymbolsStore = () => {
614
- return React.useContext(Context$2);
614
+ return react.useContext(Context$2);
615
615
  };
616
- var DispatchSymbols = /* @__PURE__ */ React.createContext(() => {
616
+ var DispatchSymbols = /* @__PURE__ */ react.createContext(() => {
617
617
  });
618
618
  DispatchSymbols.displayName = "JVR.DispatchSymbols";
619
619
  function useSymbols() {
620
- return React.useReducer(reducer$2, initialState$2);
620
+ return react.useReducer(reducer$2, initialState$2);
621
621
  }
622
622
  function useSymbolsDispatch() {
623
- return React.useContext(DispatchSymbols);
623
+ return react.useContext(DispatchSymbols);
624
624
  }
625
625
  var Symbols = (_ref) => {
626
626
  var {
@@ -683,19 +683,19 @@ var initialState$1 = {
683
683
  className: "w-rjv-object-key"
684
684
  }
685
685
  };
686
- var Context$1 = /* @__PURE__ */ React.createContext(initialState$1);
686
+ var Context$1 = /* @__PURE__ */ react.createContext(initialState$1);
687
687
  var reducer$1 = (state, action) => _extends({}, state, action);
688
688
  var useSectionStore = () => {
689
- return React.useContext(Context$1);
689
+ return react.useContext(Context$1);
690
690
  };
691
- var DispatchSection = /* @__PURE__ */ React.createContext(() => {
691
+ var DispatchSection = /* @__PURE__ */ react.createContext(() => {
692
692
  });
693
693
  DispatchSection.displayName = "JVR.DispatchSection";
694
694
  function useSection() {
695
- return React.useReducer(reducer$1, initialState$1);
695
+ return react.useReducer(reducer$1, initialState$1);
696
696
  }
697
697
  function useSectionDispatch() {
698
- return React.useContext(DispatchSection);
698
+ return react.useContext(DispatchSection);
699
699
  }
700
700
  var Section = (_ref) => {
701
701
  var {
@@ -716,16 +716,16 @@ var initialState = {
716
716
  objectSortKeys: false,
717
717
  indentWidth: 15
718
718
  };
719
- var Context = /* @__PURE__ */ React.createContext(initialState);
719
+ var Context = /* @__PURE__ */ react.createContext(initialState);
720
720
  Context.displayName = "JVR.Context";
721
- var DispatchContext = /* @__PURE__ */ React.createContext(() => {
721
+ var DispatchContext = /* @__PURE__ */ react.createContext(() => {
722
722
  });
723
723
  DispatchContext.displayName = "JVR.DispatchContext";
724
724
  function reducer(state, action) {
725
725
  return _extends({}, state, action);
726
726
  }
727
727
  var useStore = () => {
728
- return React.useContext(Context);
728
+ return react.useContext(Context);
729
729
  };
730
730
  var Provider = (_ref) => {
731
731
  var {
@@ -733,13 +733,13 @@ var Provider = (_ref) => {
733
733
  initialState: init,
734
734
  initialTypes
735
735
  } = _ref;
736
- var [state, dispatch] = React.useReducer(reducer, Object.assign({}, initialState, init));
736
+ var [state, dispatch] = react.useReducer(reducer, Object.assign({}, initialState, init));
737
737
  var [showTools, showToolsDispatch] = useShowTools();
738
738
  var [expands, expandsDispatch] = useExpands();
739
739
  var [types, typesDispatch] = useTypes();
740
740
  var [symbols, symbolsDispatch] = useSymbols();
741
741
  var [section, sectionDispatch] = useSection();
742
- React.useEffect(() => dispatch(_extends({}, init)), [init]);
742
+ react.useEffect(() => dispatch(_extends({}, init)), [init]);
743
743
  return /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, {
744
744
  value: state,
745
745
  children: /* @__PURE__ */ jsxRuntime.jsx(DispatchContext.Provider, {
@@ -787,7 +787,7 @@ var Quote$1 = (props) => {
787
787
  if (isNumber) return null;
788
788
  var {
789
789
  as,
790
- render
790
+ render: render2
791
791
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$5);
792
792
  var Elm = as || "span";
793
793
  var elmProps = _extends({}, other, reset);
@@ -797,7 +797,7 @@ var Quote$1 = (props) => {
797
797
  keyName,
798
798
  keys: keys || (keyName ? [keyName] : [])
799
799
  };
800
- var child = render && typeof render === "function" && render(elmProps, result);
800
+ var child = render2 && typeof render2 === "function" && render2(elmProps, result);
801
801
  if (child) return child;
802
802
  return /* @__PURE__ */ jsxRuntime.jsx(Elm, _extends({}, elmProps));
803
803
  };
@@ -809,11 +809,11 @@ var ValueQuote$1 = (props) => {
809
809
  var other = _extends({}, (_objectDestructuringEmpty(props), props));
810
810
  var {
811
811
  as,
812
- render
812
+ render: render2
813
813
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded3$1);
814
814
  var Elm = as || "span";
815
815
  var elmProps = _extends({}, other, reset);
816
- var child = render && typeof render === "function" && render(elmProps, {});
816
+ var child = render2 && typeof render2 === "function" && render2(elmProps, {});
817
817
  if (child) return child;
818
818
  return /* @__PURE__ */ jsxRuntime.jsx(Elm, _extends({}, elmProps));
819
819
  };
@@ -830,10 +830,10 @@ var Colon$1 = (props) => {
830
830
  } = useSymbolsStore();
831
831
  var {
832
832
  as,
833
- render
833
+ render: render2
834
834
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded4$1);
835
835
  var Elm = as || "span";
836
- var child = render && typeof render === "function" && render(reset, {
836
+ var child = render2 && typeof render2 === "function" && render2(reset, {
837
837
  value,
838
838
  parentValue,
839
839
  keyName,
@@ -860,10 +860,10 @@ var Arrow$1 = (props) => {
860
860
  var {
861
861
  as,
862
862
  style,
863
- render
863
+ render: render2
864
864
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded5$1);
865
865
  var Elm = as || "span";
866
- var isRender = render && typeof render === "function";
866
+ var isRender = render2 && typeof render2 === "function";
867
867
  var elmProps = _extends({}, reset, {
868
868
  "data-expanded": isExpanded,
869
869
  style: _extends({}, style, resetStyle)
@@ -874,7 +874,7 @@ var Arrow$1 = (props) => {
874
874
  keyName,
875
875
  keys: keys || (keyName ? [keyName] : [])
876
876
  };
877
- var child = isRender && render(elmProps, result);
877
+ var child = isRender && render2(elmProps, result);
878
878
  if (child) return child;
879
879
  return /* @__PURE__ */ jsxRuntime.jsx(Elm, _extends({}, reset, {
880
880
  style: _extends({}, style, resetStyle)
@@ -911,10 +911,10 @@ var BracketsOpen = (props) => {
911
911
  }
912
912
  var {
913
913
  as: elm,
914
- render
914
+ render: render2
915
915
  } = BraceLeft2, resetProps = _objectWithoutPropertiesLoose(BraceLeft2, _excluded7$1);
916
916
  var BraceLeftComp = elm || "span";
917
- var child = render && typeof render === "function" && render(resetProps, result);
917
+ var child = render2 && typeof render2 === "function" && render2(resetProps, result);
918
918
  if (child) return child;
919
919
  return /* @__PURE__ */ jsxRuntime.jsx(BraceLeftComp, _extends({}, resetProps));
920
920
  };
@@ -951,10 +951,10 @@ var BracketsClose = (props) => {
951
951
  }
952
952
  var {
953
953
  as: elm,
954
- render
954
+ render: render2
955
955
  } = BraceRight2, reset = _objectWithoutPropertiesLoose(BraceRight2, _excluded9$1);
956
956
  var BraceRightComp = elm || "span";
957
- var child = render && typeof render === "function" && render(reset, result);
957
+ var child = render2 && typeof render2 === "function" && render2(reset, result);
958
958
  if (child) return child;
959
959
  return /* @__PURE__ */ jsxRuntime.jsx(BraceRightComp, _extends({}, reset));
960
960
  };
@@ -1037,10 +1037,10 @@ var SetComp = (_ref) => {
1037
1037
  if (!isSet || !displayDataTypes) return null;
1038
1038
  var {
1039
1039
  as,
1040
- render
1040
+ render: render2
1041
1041
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$8);
1042
- var isRender = render && typeof render === "function";
1043
- var type = isRender && render(reset, {
1042
+ var isRender = render2 && typeof render2 === "function";
1043
+ var type = isRender && render2(reset, {
1044
1044
  type: "type",
1045
1045
  value,
1046
1046
  keyName
@@ -1063,10 +1063,10 @@ var MapComp = (_ref2) => {
1063
1063
  if (!isMap || !displayDataTypes) return null;
1064
1064
  var {
1065
1065
  as,
1066
- render
1066
+ render: render2
1067
1067
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$4);
1068
- var isRender = render && typeof render === "function";
1069
- var type = isRender && render(reset, {
1068
+ var isRender = render2 && typeof render2 === "function";
1069
+ var type = isRender && render2(reset, {
1070
1070
  type: "type",
1071
1071
  value,
1072
1072
  keyName
@@ -1096,11 +1096,11 @@ var TypeString = (_ref3) => {
1096
1096
  } = useStore();
1097
1097
  var {
1098
1098
  as,
1099
- render
1099
+ render: render2
1100
1100
  } = Str, reset = _objectWithoutPropertiesLoose(Str, _excluded3);
1101
1101
  var childrenStr = children;
1102
- var [shorten, setShorten] = React.useState(length && childrenStr.length > length);
1103
- React.useEffect(() => setShorten(length && childrenStr.length > length), [length]);
1102
+ var [shorten, setShorten] = react.useState(length && childrenStr.length > length);
1103
+ react.useEffect(() => setShorten(length && childrenStr.length > length), [length]);
1104
1104
  var Comp = as || "span";
1105
1105
  var style = _extends({}, defalutStyle, Str.style || {});
1106
1106
  if (length > 0) {
@@ -1114,8 +1114,8 @@ var TypeString = (_ref3) => {
1114
1114
  }
1115
1115
  }
1116
1116
  var text = shorten ? "" + childrenStr.slice(0, length) + stringEllipsis : childrenStr;
1117
- var isRender = render && typeof render === "function";
1118
- var type = isRender && render(_extends({}, reset, {
1117
+ var isRender = render2 && typeof render2 === "function";
1118
+ var type = isRender && render2(_extends({}, reset, {
1119
1119
  style
1120
1120
  }), {
1121
1121
  type: "type",
@@ -1124,7 +1124,7 @@ var TypeString = (_ref3) => {
1124
1124
  keys
1125
1125
  });
1126
1126
  var cls = shorten ? "w-rjv-value w-rjv-value-short" : "w-rjv-value";
1127
- var child = isRender && render(_extends({}, reset, {
1127
+ var child = isRender && render2(_extends({}, reset, {
1128
1128
  children: text,
1129
1129
  className: cls
1130
1130
  }), {
@@ -1133,10 +1133,10 @@ var TypeString = (_ref3) => {
1133
1133
  keyName,
1134
1134
  keys
1135
1135
  });
1136
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1136
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1137
1137
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1138
1138
  style
1139
- }))), child || /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1139
+ }))), child || /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1140
1140
  children: [/* @__PURE__ */ jsxRuntime.jsx(ValueQuote$1, {}), /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1141
1141
  className: cls,
1142
1142
  children: text
@@ -1157,12 +1157,12 @@ var TypeTrue = (_ref4) => {
1157
1157
  } = useTypesStore();
1158
1158
  var {
1159
1159
  as,
1160
- render
1160
+ render: render2
1161
1161
  } = True2, reset = _objectWithoutPropertiesLoose(True2, _excluded4);
1162
1162
  var Comp = as || "span";
1163
1163
  var style = _extends({}, defalutStyle, True2.style || {});
1164
- var isRender = render && typeof render === "function";
1165
- var type = isRender && render(_extends({}, reset, {
1164
+ var isRender = render2 && typeof render2 === "function";
1165
+ var type = isRender && render2(_extends({}, reset, {
1166
1166
  style
1167
1167
  }), {
1168
1168
  type: "type",
@@ -1170,7 +1170,7 @@ var TypeTrue = (_ref4) => {
1170
1170
  keyName,
1171
1171
  keys
1172
1172
  });
1173
- var child = isRender && render(_extends({}, reset, {
1173
+ var child = isRender && render2(_extends({}, reset, {
1174
1174
  children,
1175
1175
  className: "w-rjv-value"
1176
1176
  }), {
@@ -1179,7 +1179,7 @@ var TypeTrue = (_ref4) => {
1179
1179
  keyName,
1180
1180
  keys
1181
1181
  });
1182
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1182
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1183
1183
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1184
1184
  style
1185
1185
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1201,12 +1201,12 @@ var TypeFalse = (_ref5) => {
1201
1201
  } = useTypesStore();
1202
1202
  var {
1203
1203
  as,
1204
- render
1204
+ render: render2
1205
1205
  } = False2, reset = _objectWithoutPropertiesLoose(False2, _excluded5);
1206
1206
  var Comp = as || "span";
1207
1207
  var style = _extends({}, defalutStyle, False2.style || {});
1208
- var isRender = render && typeof render === "function";
1209
- var type = isRender && render(_extends({}, reset, {
1208
+ var isRender = render2 && typeof render2 === "function";
1209
+ var type = isRender && render2(_extends({}, reset, {
1210
1210
  style
1211
1211
  }), {
1212
1212
  type: "type",
@@ -1214,7 +1214,7 @@ var TypeFalse = (_ref5) => {
1214
1214
  keyName,
1215
1215
  keys
1216
1216
  });
1217
- var child = isRender && render(_extends({}, reset, {
1217
+ var child = isRender && render2(_extends({}, reset, {
1218
1218
  children,
1219
1219
  className: "w-rjv-value"
1220
1220
  }), {
@@ -1223,7 +1223,7 @@ var TypeFalse = (_ref5) => {
1223
1223
  keyName,
1224
1224
  keys
1225
1225
  });
1226
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1226
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1227
1227
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1228
1228
  style
1229
1229
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1245,12 +1245,12 @@ var TypeFloat = (_ref6) => {
1245
1245
  } = useTypesStore();
1246
1246
  var {
1247
1247
  as,
1248
- render
1248
+ render: render2
1249
1249
  } = Float2, reset = _objectWithoutPropertiesLoose(Float2, _excluded6);
1250
1250
  var Comp = as || "span";
1251
1251
  var style = _extends({}, defalutStyle, Float2.style || {});
1252
- var isRender = render && typeof render === "function";
1253
- var type = isRender && render(_extends({}, reset, {
1252
+ var isRender = render2 && typeof render2 === "function";
1253
+ var type = isRender && render2(_extends({}, reset, {
1254
1254
  style
1255
1255
  }), {
1256
1256
  type: "type",
@@ -1258,7 +1258,7 @@ var TypeFloat = (_ref6) => {
1258
1258
  keyName,
1259
1259
  keys
1260
1260
  });
1261
- var child = isRender && render(_extends({}, reset, {
1261
+ var child = isRender && render2(_extends({}, reset, {
1262
1262
  children,
1263
1263
  className: "w-rjv-value"
1264
1264
  }), {
@@ -1267,7 +1267,7 @@ var TypeFloat = (_ref6) => {
1267
1267
  keyName,
1268
1268
  keys
1269
1269
  });
1270
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1270
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1271
1271
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1272
1272
  style
1273
1273
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1289,12 +1289,12 @@ var TypeInt = (_ref7) => {
1289
1289
  } = useTypesStore();
1290
1290
  var {
1291
1291
  as,
1292
- render
1292
+ render: render2
1293
1293
  } = Int2, reset = _objectWithoutPropertiesLoose(Int2, _excluded7);
1294
1294
  var Comp = as || "span";
1295
1295
  var style = _extends({}, defalutStyle, Int2.style || {});
1296
- var isRender = render && typeof render === "function";
1297
- var type = isRender && render(_extends({}, reset, {
1296
+ var isRender = render2 && typeof render2 === "function";
1297
+ var type = isRender && render2(_extends({}, reset, {
1298
1298
  style
1299
1299
  }), {
1300
1300
  type: "type",
@@ -1302,7 +1302,7 @@ var TypeInt = (_ref7) => {
1302
1302
  keyName,
1303
1303
  keys
1304
1304
  });
1305
- var child = isRender && render(_extends({}, reset, {
1305
+ var child = isRender && render2(_extends({}, reset, {
1306
1306
  children,
1307
1307
  className: "w-rjv-value"
1308
1308
  }), {
@@ -1311,7 +1311,7 @@ var TypeInt = (_ref7) => {
1311
1311
  keyName,
1312
1312
  keys
1313
1313
  });
1314
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1314
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1315
1315
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1316
1316
  style
1317
1317
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1333,12 +1333,12 @@ var TypeBigint = (_ref8) => {
1333
1333
  } = useTypesStore();
1334
1334
  var {
1335
1335
  as,
1336
- render
1336
+ render: render2
1337
1337
  } = CompBigint, reset = _objectWithoutPropertiesLoose(CompBigint, _excluded8);
1338
1338
  var Comp = as || "span";
1339
1339
  var style = _extends({}, defalutStyle, CompBigint.style || {});
1340
- var isRender = render && typeof render === "function";
1341
- var type = isRender && render(_extends({}, reset, {
1340
+ var isRender = render2 && typeof render2 === "function";
1341
+ var type = isRender && render2(_extends({}, reset, {
1342
1342
  style
1343
1343
  }), {
1344
1344
  type: "type",
@@ -1346,7 +1346,7 @@ var TypeBigint = (_ref8) => {
1346
1346
  keyName,
1347
1347
  keys
1348
1348
  });
1349
- var child = isRender && render(_extends({}, reset, {
1349
+ var child = isRender && render2(_extends({}, reset, {
1350
1350
  children,
1351
1351
  className: "w-rjv-value"
1352
1352
  }), {
@@ -1355,7 +1355,7 @@ var TypeBigint = (_ref8) => {
1355
1355
  keyName,
1356
1356
  keys
1357
1357
  });
1358
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1358
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1359
1359
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1360
1360
  style
1361
1361
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1377,12 +1377,12 @@ var TypeUrl = (_ref9) => {
1377
1377
  } = useTypesStore();
1378
1378
  var {
1379
1379
  as,
1380
- render
1380
+ render: render2
1381
1381
  } = Url2, reset = _objectWithoutPropertiesLoose(Url2, _excluded9);
1382
1382
  var Comp = as || "span";
1383
1383
  var style = _extends({}, defalutStyle, Url2.style);
1384
- var isRender = render && typeof render === "function";
1385
- var type = isRender && render(_extends({}, reset, {
1384
+ var isRender = render2 && typeof render2 === "function";
1385
+ var type = isRender && render2(_extends({}, reset, {
1386
1386
  style
1387
1387
  }), {
1388
1388
  type: "type",
@@ -1390,7 +1390,7 @@ var TypeUrl = (_ref9) => {
1390
1390
  keyName,
1391
1391
  keys
1392
1392
  });
1393
- var child = isRender && render(_extends({}, reset, {
1393
+ var child = isRender && render2(_extends({}, reset, {
1394
1394
  children: children == null ? void 0 : children.href,
1395
1395
  className: "w-rjv-value"
1396
1396
  }), {
@@ -1399,7 +1399,7 @@ var TypeUrl = (_ref9) => {
1399
1399
  keyName,
1400
1400
  keys
1401
1401
  });
1402
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1402
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1403
1403
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1404
1404
  style
1405
1405
  }))), child || /* @__PURE__ */ jsxRuntime.jsxs("a", _extends({
@@ -1424,12 +1424,12 @@ var TypeDate = (_ref0) => {
1424
1424
  } = useTypesStore();
1425
1425
  var {
1426
1426
  as,
1427
- render
1427
+ render: render2
1428
1428
  } = CompData, reset = _objectWithoutPropertiesLoose(CompData, _excluded0);
1429
1429
  var Comp = as || "span";
1430
1430
  var style = _extends({}, defalutStyle, CompData.style || {});
1431
- var isRender = render && typeof render === "function";
1432
- var type = isRender && render(_extends({}, reset, {
1431
+ var isRender = render2 && typeof render2 === "function";
1432
+ var type = isRender && render2(_extends({}, reset, {
1433
1433
  style
1434
1434
  }), {
1435
1435
  type: "type",
@@ -1438,7 +1438,7 @@ var TypeDate = (_ref0) => {
1438
1438
  keys
1439
1439
  });
1440
1440
  var childStr = children instanceof Date ? children.toLocaleString() : children;
1441
- var child = isRender && render(_extends({}, reset, {
1441
+ var child = isRender && render2(_extends({}, reset, {
1442
1442
  children: childStr,
1443
1443
  className: "w-rjv-value"
1444
1444
  }), {
@@ -1447,7 +1447,7 @@ var TypeDate = (_ref0) => {
1447
1447
  keyName,
1448
1448
  keys
1449
1449
  });
1450
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1450
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1451
1451
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1452
1452
  style
1453
1453
  }))), child || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
@@ -1469,12 +1469,12 @@ var TypeUndefined = (_ref1) => {
1469
1469
  } = useTypesStore();
1470
1470
  var {
1471
1471
  as,
1472
- render
1472
+ render: render2
1473
1473
  } = Undefined2, reset = _objectWithoutPropertiesLoose(Undefined2, _excluded1);
1474
1474
  var Comp = as || "span";
1475
1475
  var style = _extends({}, defalutStyle, Undefined2.style || {});
1476
- var isRender = render && typeof render === "function";
1477
- var type = isRender && render(_extends({}, reset, {
1476
+ var isRender = render2 && typeof render2 === "function";
1477
+ var type = isRender && render2(_extends({}, reset, {
1478
1478
  style
1479
1479
  }), {
1480
1480
  type: "type",
@@ -1482,7 +1482,7 @@ var TypeUndefined = (_ref1) => {
1482
1482
  keyName,
1483
1483
  keys
1484
1484
  });
1485
- var child = isRender && render(_extends({}, reset, {
1485
+ var child = isRender && render2(_extends({}, reset, {
1486
1486
  children,
1487
1487
  className: "w-rjv-value"
1488
1488
  }), {
@@ -1491,7 +1491,7 @@ var TypeUndefined = (_ref1) => {
1491
1491
  keyName,
1492
1492
  keys
1493
1493
  });
1494
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1494
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1495
1495
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1496
1496
  style
1497
1497
  }))), child]
@@ -1510,12 +1510,12 @@ var TypeNull = (_ref10) => {
1510
1510
  } = useTypesStore();
1511
1511
  var {
1512
1512
  as,
1513
- render
1513
+ render: render2
1514
1514
  } = Null2, reset = _objectWithoutPropertiesLoose(Null2, _excluded10);
1515
1515
  var Comp = as || "span";
1516
1516
  var style = _extends({}, defalutStyle, Null2.style || {});
1517
- var isRender = render && typeof render === "function";
1518
- var type = isRender && render(_extends({}, reset, {
1517
+ var isRender = render2 && typeof render2 === "function";
1518
+ var type = isRender && render2(_extends({}, reset, {
1519
1519
  style
1520
1520
  }), {
1521
1521
  type: "type",
@@ -1523,7 +1523,7 @@ var TypeNull = (_ref10) => {
1523
1523
  keyName,
1524
1524
  keys
1525
1525
  });
1526
- var child = isRender && render(_extends({}, reset, {
1526
+ var child = isRender && render2(_extends({}, reset, {
1527
1527
  children,
1528
1528
  className: "w-rjv-value"
1529
1529
  }), {
@@ -1532,7 +1532,7 @@ var TypeNull = (_ref10) => {
1532
1532
  keyName,
1533
1533
  keys
1534
1534
  });
1535
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1535
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1536
1536
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1537
1537
  style
1538
1538
  }))), child]
@@ -1551,12 +1551,12 @@ var TypeNan = (_ref11) => {
1551
1551
  } = useTypesStore();
1552
1552
  var {
1553
1553
  as,
1554
- render
1554
+ render: render2
1555
1555
  } = Nan2, reset = _objectWithoutPropertiesLoose(Nan2, _excluded11);
1556
1556
  var Comp = as || "span";
1557
1557
  var style = _extends({}, defalutStyle, Nan2.style || {});
1558
- var isRender = render && typeof render === "function";
1559
- var type = isRender && render(_extends({}, reset, {
1558
+ var isRender = render2 && typeof render2 === "function";
1559
+ var type = isRender && render2(_extends({}, reset, {
1560
1560
  style
1561
1561
  }), {
1562
1562
  type: "type",
@@ -1564,7 +1564,7 @@ var TypeNan = (_ref11) => {
1564
1564
  keyName,
1565
1565
  keys
1566
1566
  });
1567
- var child = isRender && render(_extends({}, reset, {
1567
+ var child = isRender && render2(_extends({}, reset, {
1568
1568
  children: children == null ? void 0 : children.toString(),
1569
1569
  className: "w-rjv-value"
1570
1570
  }), {
@@ -1573,7 +1573,7 @@ var TypeNan = (_ref11) => {
1573
1573
  keyName,
1574
1574
  keys
1575
1575
  });
1576
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
1576
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
1577
1577
  children: [displayDataTypes && (type || /* @__PURE__ */ jsxRuntime.jsx(Comp, _extends({}, reset, {
1578
1578
  style
1579
1579
  }))), child]
@@ -1654,7 +1654,7 @@ function useSymbolsRender(currentProps, props, key) {
1654
1654
  style: _extends({}, currentProps.style, props.style),
1655
1655
  children: props.children || currentProps.children
1656
1656
  });
1657
- React.useEffect(() => dispatch({
1657
+ react.useEffect(() => dispatch({
1658
1658
  [key]: reset
1659
1659
  }), [props]);
1660
1660
  }
@@ -1666,7 +1666,7 @@ function useTypesRender(currentProps, props, key) {
1666
1666
  style: _extends({}, currentProps.style, props.style),
1667
1667
  children: props.children || currentProps.children
1668
1668
  });
1669
- React.useEffect(() => dispatch({
1669
+ react.useEffect(() => dispatch({
1670
1670
  [key]: reset
1671
1671
  }), [props]);
1672
1672
  }
@@ -1678,7 +1678,7 @@ function useSectionRender(currentProps, props, key) {
1678
1678
  style: _extends({}, currentProps.style, props.style),
1679
1679
  children: props.children || currentProps.children
1680
1680
  });
1681
- React.useEffect(() => dispatch({
1681
+ react.useEffect(() => dispatch({
1682
1682
  [key]: reset
1683
1683
  }), [props]);
1684
1684
  }
@@ -1708,11 +1708,11 @@ var KeyNameComp = (props) => {
1708
1708
  } = useSectionStore();
1709
1709
  var {
1710
1710
  as,
1711
- render
1711
+ render: render2
1712
1712
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$7);
1713
1713
  reset.style = _extends({}, reset.style, style);
1714
1714
  var Elm = as || "span";
1715
- var child = render && typeof render === "function" && render(_extends({}, reset, {
1715
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, reset, {
1716
1716
  children
1717
1717
  }), {
1718
1718
  value,
@@ -1748,10 +1748,10 @@ var RowComp = (props) => {
1748
1748
  } = useSectionStore();
1749
1749
  var {
1750
1750
  as,
1751
- render
1751
+ render: render2
1752
1752
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$3);
1753
1753
  var Elm = as || "div";
1754
- var child = render && typeof render === "function" && render(_extends({}, other, reset, {
1754
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, other, reset, {
1755
1755
  children
1756
1756
  }), {
1757
1757
  value,
@@ -1766,8 +1766,8 @@ var RowComp = (props) => {
1766
1766
  };
1767
1767
  RowComp.displayName = "JVR.RowComp";
1768
1768
  function usePrevious(value) {
1769
- var ref = React.useRef();
1770
- React.useEffect(() => {
1769
+ var ref = react.useRef();
1770
+ react.useEffect(() => {
1771
1771
  ref.current = value;
1772
1772
  });
1773
1773
  return ref.current;
@@ -1779,7 +1779,7 @@ function useHighlight(_ref) {
1779
1779
  highlightContainer
1780
1780
  } = _ref;
1781
1781
  var prevValue = usePrevious(value);
1782
- var isHighlight = React.useMemo(() => {
1782
+ var isHighlight = react.useMemo(() => {
1783
1783
  if (!highlightUpdates || prevValue === void 0) return false;
1784
1784
  if (typeof value !== typeof prevValue) {
1785
1785
  return true;
@@ -1798,7 +1798,7 @@ function useHighlight(_ref) {
1798
1798
  return true;
1799
1799
  }
1800
1800
  }, [highlightUpdates, value]);
1801
- React.useEffect(() => {
1801
+ react.useEffect(() => {
1802
1802
  if (highlightContainer && highlightContainer.current && isHighlight && "animate" in highlightContainer.current) {
1803
1803
  highlightContainer.current.animate([{
1804
1804
  backgroundColor: "var(--w-rjv-update-color, #ebcb8b)"
@@ -1828,7 +1828,7 @@ var Copied$2 = (props) => {
1828
1828
  } = useStore();
1829
1829
  var showTools = useShowToolsStore();
1830
1830
  var isShowTools = showTools[expandKey];
1831
- var [copied, setCopied] = React.useState(false);
1831
+ var [copied, setCopied] = react.useState(false);
1832
1832
  var {
1833
1833
  Copied: Comp = {}
1834
1834
  } = useSectionStore();
@@ -1889,13 +1889,13 @@ var Copied$2 = (props) => {
1889
1889
  onClick: click
1890
1890
  };
1891
1891
  var {
1892
- render
1892
+ render: render2
1893
1893
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$2);
1894
1894
  var elmProps = _extends({}, reset, other, svgProps, {
1895
1895
  style: _extends({}, reset.style, other.style, svgProps.style)
1896
1896
  });
1897
- var isRender = render && typeof render === "function";
1898
- var child = isRender && render(_extends({}, elmProps, {
1897
+ var isRender = render2 && typeof render2 === "function";
1898
+ var child = isRender && render2(_extends({}, elmProps, {
1899
1899
  "data-copied": copied
1900
1900
  }), {
1901
1901
  value,
@@ -1923,7 +1923,7 @@ var Copied$2 = (props) => {
1923
1923
  };
1924
1924
  Copied$2.displayName = "JVR.Copied";
1925
1925
  function useIdCompat() {
1926
- var idRef = React.useRef(null);
1926
+ var idRef = react.useRef(null);
1927
1927
  if (idRef.current === null) {
1928
1928
  idRef.current = "custom-id-" + Math.random().toString(36).substr(2, 9);
1929
1929
  }
@@ -2006,7 +2006,7 @@ var KayName = (props) => {
2006
2006
  highlightUpdates
2007
2007
  } = useStore();
2008
2008
  var isNumber = typeof keyName === "number";
2009
- var highlightContainer = React.useRef(null);
2009
+ var highlightContainer = react.useRef(null);
2010
2010
  useHighlight({
2011
2011
  value,
2012
2012
  highlightUpdates,
@@ -2018,7 +2018,7 @@ var KayName = (props) => {
2018
2018
  keys,
2019
2019
  parentValue
2020
2020
  };
2021
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, {
2021
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, {
2022
2022
  children: [/* @__PURE__ */ jsxRuntime.jsxs("span", {
2023
2023
  ref: highlightContainer,
2024
2024
  children: [/* @__PURE__ */ jsxRuntime.jsx(Quote$1, _extends({
@@ -2115,13 +2115,13 @@ var CountInfoExtraComps = (props) => {
2115
2115
  } = useSectionStore();
2116
2116
  var {
2117
2117
  as,
2118
- render
2118
+ render: render2
2119
2119
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$1);
2120
- if (!render && !reset.children) return null;
2120
+ if (!render2 && !reset.children) return null;
2121
2121
  var Elm = as || "span";
2122
- var isRender = render && typeof render === "function";
2122
+ var isRender = render2 && typeof render2 === "function";
2123
2123
  var elmProps = _extends({}, reset, other);
2124
- var child = isRender && render(elmProps, {
2124
+ var child = isRender && render2(elmProps, {
2125
2125
  value,
2126
2126
  keyName
2127
2127
  });
@@ -2152,7 +2152,7 @@ var CountInfoComp = (props) => {
2152
2152
  if (!displayObjectSize) return null;
2153
2153
  var {
2154
2154
  as,
2155
- render
2155
+ render: render2
2156
2156
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
2157
2157
  var Elm = as || "span";
2158
2158
  reset.style = _extends({}, reset.style, props.style);
@@ -2161,8 +2161,8 @@ var CountInfoComp = (props) => {
2161
2161
  reset.children = len + " item" + (len === 1 ? "" : "s");
2162
2162
  }
2163
2163
  var elmProps = _extends({}, reset, other);
2164
- var isRender = render && typeof render === "function";
2165
- var child = isRender && render(_extends({}, elmProps, {
2164
+ var isRender = render2 && typeof render2 === "function";
2165
+ var child = isRender && render2(_extends({}, elmProps, {
2166
2166
  "data-length": len
2167
2167
  }), {
2168
2168
  value,
@@ -2192,10 +2192,10 @@ var EllipsisComp = (_ref) => {
2192
2192
  } = useSectionStore();
2193
2193
  var {
2194
2194
  as,
2195
- render
2195
+ render: render2
2196
2196
  } = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded$2);
2197
2197
  var Elm = as || "span";
2198
- var child = render && typeof render === "function" && render(_extends({}, reset, {
2198
+ var child = render2 && typeof render2 === "function" && render2(_extends({}, reset, {
2199
2199
  "data-expanded": isExpanded
2200
2200
  }), {
2201
2201
  value,
@@ -2309,7 +2309,7 @@ var NestedOpen = (props) => {
2309
2309
  };
2310
2310
  NestedOpen.displayName = "JVR.NestedOpen";
2311
2311
  var _excluded$1 = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keys", "keyName"];
2312
- var Container = /* @__PURE__ */ React.forwardRef((props, ref) => {
2312
+ var Container = /* @__PURE__ */ react.forwardRef((props, ref) => {
2313
2313
  var {
2314
2314
  className = "",
2315
2315
  parentValue,
@@ -2537,7 +2537,7 @@ var Copied$1 = (props) => {
2537
2537
  };
2538
2538
  Copied$1.displayName = "JVR.Copied";
2539
2539
  var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied", "beforeCopy"];
2540
- var JsonView = /* @__PURE__ */ React.forwardRef((props, ref) => {
2540
+ var JsonView = /* @__PURE__ */ react.forwardRef((props, ref) => {
2541
2541
  var {
2542
2542
  className = "",
2543
2543
  style,
@@ -2670,7 +2670,7 @@ const JsonViewSection = ({ data }) => {
2670
2670
  ] })
2671
2671
  ] }),
2672
2672
  /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Body, { className: "flex flex-1 flex-col overflow-hidden px-[5px] py-0 pb-[5px]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-contrast-bg-subtle flex-1 overflow-auto rounded-b-[4px] rounded-t-lg p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
2673
- React.Suspense,
2673
+ react.Suspense,
2674
2674
  {
2675
2675
  fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full flex-col" }),
2676
2676
  children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2743,7 +2743,7 @@ const JsonViewSection = ({ data }) => {
2743
2743
  ] });
2744
2744
  };
2745
2745
  const Copied = ({ style, value }) => {
2746
- const [copied, setCopied] = React.useState(false);
2746
+ const [copied, setCopied] = react.useState(false);
2747
2747
  const handler = (e) => {
2748
2748
  e.stopPropagation();
2749
2749
  setCopied(true);
@@ -2834,11 +2834,11 @@ const SingleColumnPage = ({
2834
2834
  }
2835
2835
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-3", children: [
2836
2836
  before.map((Component, i) => {
2837
- return /* @__PURE__ */ React.createElement(Component, { ...widgetProps, key: i });
2837
+ return /* @__PURE__ */ react.createElement(Component, { ...widgetProps, key: i });
2838
2838
  }),
2839
2839
  children,
2840
2840
  after.map((Component, i) => {
2841
- return /* @__PURE__ */ React.createElement(Component, { ...widgetProps, key: i });
2841
+ return /* @__PURE__ */ react.createElement(Component, { ...widgetProps, key: i });
2842
2842
  }),
2843
2843
  showMetadata && /* @__PURE__ */ jsxRuntime.jsx(MetadataSection, { data }),
2844
2844
  showJSON && /* @__PURE__ */ jsxRuntime.jsx(JsonViewSection, { data }),
@@ -2846,12 +2846,12 @@ const SingleColumnPage = ({
2846
2846
  ] });
2847
2847
  };
2848
2848
  const NotificationsFullList = () => {
2849
- const [pagination, setPagination] = React.useState({
2849
+ const [pagination, setPagination] = react.useState({
2850
2850
  pageSize: 8,
2851
2851
  pageIndex: 0
2852
2852
  });
2853
2853
  const limit = 8;
2854
- const offset = React.useMemo(() => {
2854
+ const offset = react.useMemo(() => {
2855
2855
  return pagination.pageIndex * limit;
2856
2856
  }, [pagination]);
2857
2857
  const { data: notificationsData, isLoading: isNotificationsLoading } = useListNotifications({
@@ -2949,7 +2949,7 @@ const config$1 = adminSdk.defineRouteConfig({
2949
2949
  icon: icons.ListBullet
2950
2950
  });
2951
2951
  const useOrders = (params = {}, options) => {
2952
- const { limit = 100, offset = 0, extraKey = [], enabled, fields = "id,display_id" } = params;
2952
+ const { limit = 100, offset = 0, extraKey = [], enabled, fields = "id,display_id", order = "-created_at" } = params;
2953
2953
  const queryKey = [
2954
2954
  "orders",
2955
2955
  ...extraKey
@@ -2957,7 +2957,8 @@ const useOrders = (params = {}, options) => {
2957
2957
  const query = {
2958
2958
  limit,
2959
2959
  offset,
2960
- fields
2960
+ fields,
2961
+ order
2961
2962
  };
2962
2963
  const { data, ...rest } = reactQuery.useQuery({
2963
2964
  queryKey,
@@ -7376,2238 +7377,259 @@ const getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc,
7376
7377
  acc = acc + (paymentCollection.captured_amount - paymentCollection.refunded_amount);
7377
7378
  return acc;
7378
7379
  }, 0);
7379
- const TEMPLATES_NAMES = {
7380
- ORDER_PLACED: "order-placed",
7381
- CONTACT_FORM: "contact-form"
7382
- };
7383
- const isString = (obj) => typeof obj === "string";
7384
- const defer = () => {
7385
- let res;
7386
- let rej;
7387
- const promise = new Promise((resolve, reject) => {
7388
- res = resolve;
7389
- rej = reject;
7390
- });
7391
- promise.resolve = res;
7392
- promise.reject = rej;
7393
- return promise;
7394
- };
7395
- const makeString = (object) => {
7396
- if (object == null) return "";
7397
- return "" + object;
7398
- };
7399
- const copy = (a, s, t) => {
7400
- a.forEach((m) => {
7401
- if (s[m]) t[m] = s[m];
7402
- });
7403
- };
7404
- const lastOfPathSeparatorRegExp = /###/g;
7405
- const cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
7406
- const canNotTraverseDeeper = (object) => !object || isString(object);
7407
- const getLastOfPath = (object, path, Empty) => {
7408
- const stack = !isString(path) ? path : path.split(".");
7409
- let stackIndex = 0;
7410
- while (stackIndex < stack.length - 1) {
7411
- if (canNotTraverseDeeper(object)) return {};
7412
- const key = cleanKey(stack[stackIndex]);
7413
- if (!object[key] && Empty) object[key] = new Empty();
7414
- if (Object.prototype.hasOwnProperty.call(object, key)) {
7415
- object = object[key];
7416
- } else {
7417
- object = {};
7418
- }
7419
- ++stackIndex;
7420
- }
7421
- if (canNotTraverseDeeper(object)) return {};
7422
- return {
7423
- obj: object,
7424
- k: cleanKey(stack[stackIndex])
7425
- };
7426
- };
7427
- const setPath = (object, path, newValue) => {
7428
- const {
7429
- obj,
7430
- k
7431
- } = getLastOfPath(object, path, Object);
7432
- if (obj !== void 0 || path.length === 1) {
7433
- obj[k] = newValue;
7434
- return;
7435
- }
7436
- let e = path[path.length - 1];
7437
- let p = path.slice(0, path.length - 1);
7438
- let last = getLastOfPath(object, p, Object);
7439
- while (last.obj === void 0 && p.length) {
7440
- e = `${p[p.length - 1]}.${e}`;
7441
- p = p.slice(0, p.length - 1);
7442
- last = getLastOfPath(object, p, Object);
7443
- if ((last == null ? void 0 : last.obj) && typeof last.obj[`${last.k}.${e}`] !== "undefined") {
7444
- last.obj = void 0;
7445
- }
7446
- }
7447
- last.obj[`${last.k}.${e}`] = newValue;
7448
- };
7449
- const pushPath = (object, path, newValue, concat) => {
7450
- const {
7451
- obj,
7452
- k
7453
- } = getLastOfPath(object, path, Object);
7454
- obj[k] = obj[k] || [];
7455
- obj[k].push(newValue);
7456
- };
7457
- const getPath = (object, path) => {
7458
- const {
7459
- obj,
7460
- k
7461
- } = getLastOfPath(object, path);
7462
- if (!obj) return void 0;
7463
- if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
7464
- return obj[k];
7465
- };
7466
- const getPathWithDefaults = (data, defaultData, key) => {
7467
- const value = getPath(data, key);
7468
- if (value !== void 0) {
7469
- return value;
7470
- }
7471
- return getPath(defaultData, key);
7472
- };
7473
- const deepExtend = (target, source, overwrite) => {
7474
- for (const prop in source) {
7475
- if (prop !== "__proto__" && prop !== "constructor") {
7476
- if (prop in target) {
7477
- if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
7478
- if (overwrite) target[prop] = source[prop];
7479
- } else {
7480
- deepExtend(target[prop], source[prop], overwrite);
7481
- }
7482
- } else {
7483
- target[prop] = source[prop];
7484
- }
7485
- }
7486
- }
7487
- return target;
7488
- };
7489
- const regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
7490
- var _entityMap = {
7491
- "&": "&amp;",
7492
- "<": "&lt;",
7493
- ">": "&gt;",
7494
- '"': "&quot;",
7495
- "'": "&#39;",
7496
- "/": "&#x2F;"
7497
- };
7498
- const escape = (data) => {
7499
- if (isString(data)) {
7500
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
7501
- }
7502
- return data;
7503
- };
7504
- class RegExpCache {
7505
- constructor(capacity) {
7506
- this.capacity = capacity;
7507
- this.regExpMap = /* @__PURE__ */ new Map();
7508
- this.regExpQueue = [];
7509
- }
7510
- getRegExp(pattern) {
7511
- const regExpFromCache = this.regExpMap.get(pattern);
7512
- if (regExpFromCache !== void 0) {
7513
- return regExpFromCache;
7514
- }
7515
- const regExpNew = new RegExp(pattern);
7516
- if (this.regExpQueue.length === this.capacity) {
7517
- this.regExpMap.delete(this.regExpQueue.shift());
7518
- }
7519
- this.regExpMap.set(pattern, regExpNew);
7520
- this.regExpQueue.push(pattern);
7521
- return regExpNew;
7522
- }
7380
+ function SectionBlock({
7381
+ id,
7382
+ props,
7383
+ data,
7384
+ isLastBlock,
7385
+ isFirstBlock
7386
+ }) {
7387
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Section, { className: "m-0 p-0", children: /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blocks: props.blocks || [], data }) });
7523
7388
  }
7524
- const chars = [" ", ",", "?", "!", ";"];
7525
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
7526
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
7527
- nsSeparator = nsSeparator || "";
7528
- keySeparator = keySeparator || "";
7529
- const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
7530
- if (possibleChars.length === 0) return true;
7531
- const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
7532
- let matched = !r.test(key);
7533
- if (!matched) {
7534
- const ki = key.indexOf(keySeparator);
7535
- if (ki > 0 && !r.test(key.substring(0, ki))) {
7536
- matched = true;
7537
- }
7538
- }
7539
- return matched;
7540
- };
7541
- const deepFind = (obj, path, keySeparator = ".") => {
7542
- if (!obj) return void 0;
7543
- if (obj[path]) {
7544
- if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
7545
- return obj[path];
7546
- }
7547
- const tokens = path.split(keySeparator);
7548
- let current = obj;
7549
- for (let i = 0; i < tokens.length; ) {
7550
- if (!current || typeof current !== "object") {
7551
- return void 0;
7552
- }
7553
- let next;
7554
- let nextPath = "";
7555
- for (let j = i; j < tokens.length; ++j) {
7556
- if (j !== i) {
7557
- nextPath += keySeparator;
7558
- }
7559
- nextPath += tokens[j];
7560
- next = current[nextPath];
7561
- if (next !== void 0) {
7562
- if (["string", "number", "boolean"].indexOf(typeof next) > -1 && j < tokens.length - 1) {
7563
- continue;
7564
- }
7565
- i += j - i + 1;
7566
- break;
7567
- }
7568
- }
7569
- current = next;
7570
- }
7571
- return current;
7572
- };
7573
- const getCleanedCode = (code) => code == null ? void 0 : code.replace("_", "-");
7574
- const consoleLogger = {
7575
- type: "logger",
7576
- log(args) {
7577
- this.output("log", args);
7578
- },
7579
- warn(args) {
7580
- this.output("warn", args);
7581
- },
7582
- error(args) {
7583
- this.output("error", args);
7584
- },
7585
- output(type, args) {
7586
- var _a, _b;
7587
- (_b = (_a = console == null ? void 0 : console[type]) == null ? void 0 : _a.apply) == null ? void 0 : _b.call(_a, console, args);
7588
- }
7589
- };
7590
- class Logger {
7591
- constructor(concreteLogger, options = {}) {
7592
- this.init(concreteLogger, options);
7593
- }
7594
- init(concreteLogger, options = {}) {
7595
- this.prefix = options.prefix || "i18next:";
7596
- this.logger = concreteLogger || consoleLogger;
7597
- this.options = options;
7598
- this.debug = options.debug;
7599
- }
7600
- log(...args) {
7601
- return this.forward(args, "log", "", true);
7602
- }
7603
- warn(...args) {
7604
- return this.forward(args, "warn", "", true);
7605
- }
7606
- error(...args) {
7607
- return this.forward(args, "error", "");
7608
- }
7609
- deprecate(...args) {
7610
- return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
7611
- }
7612
- forward(args, lvl, prefix, debugOnly) {
7613
- if (debugOnly && !this.debug) return null;
7614
- if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
7615
- return this.logger[lvl](args);
7616
- }
7617
- create(moduleName) {
7618
- return new Logger(this.logger, {
7619
- ...{
7620
- prefix: `${this.prefix}:${moduleName}:`
7621
- },
7622
- ...this.options
7623
- });
7624
- }
7625
- clone(options) {
7626
- options = options || this.options;
7627
- options.prefix = options.prefix || this.prefix;
7628
- return new Logger(this.logger, options);
7629
- }
7389
+ function TextBlock({
7390
+ id,
7391
+ props,
7392
+ isLastBlock,
7393
+ isFirstBlock
7394
+ }) {
7395
+ const className = ui.clx(
7396
+ isLastBlock ? "mb-0" : "mb-4",
7397
+ isFirstBlock && "mt-0"
7398
+ );
7399
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Text, { className, children: typeof props.value === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value }, id);
7630
7400
  }
7631
- var baseLogger = new Logger();
7632
- class EventEmitter {
7633
- constructor() {
7634
- this.observers = {};
7635
- }
7636
- on(events, listener) {
7637
- events.split(" ").forEach((event) => {
7638
- if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
7639
- const numListeners = this.observers[event].get(listener) || 0;
7640
- this.observers[event].set(listener, numListeners + 1);
7641
- });
7642
- return this;
7643
- }
7644
- off(event, listener) {
7645
- if (!this.observers[event]) return;
7646
- if (!listener) {
7647
- delete this.observers[event];
7648
- return;
7649
- }
7650
- this.observers[event].delete(listener);
7651
- }
7652
- emit(event, ...args) {
7653
- if (this.observers[event]) {
7654
- const cloned = Array.from(this.observers[event].entries());
7655
- cloned.forEach(([observer, numTimesAdded]) => {
7656
- for (let i = 0; i < numTimesAdded; i++) {
7657
- observer(...args);
7658
- }
7659
- });
7660
- }
7661
- if (this.observers["*"]) {
7662
- const cloned = Array.from(this.observers["*"].entries());
7663
- cloned.forEach(([observer, numTimesAdded]) => {
7664
- for (let i = 0; i < numTimesAdded; i++) {
7665
- observer.apply(observer, [event, ...args]);
7666
- }
7667
- });
7668
- }
7669
- }
7401
+ function RepeaterBlock({
7402
+ id,
7403
+ props,
7404
+ data
7405
+ }) {
7406
+ const array = props.itemBlocks;
7407
+ return /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blocks: array, data });
7670
7408
  }
7671
- class ResourceStore extends EventEmitter {
7672
- constructor(data, options = {
7673
- ns: ["translation"],
7674
- defaultNS: "translation"
7675
- }) {
7676
- super();
7677
- this.data = data || {};
7678
- this.options = options;
7679
- if (this.options.keySeparator === void 0) {
7680
- this.options.keySeparator = ".";
7681
- }
7682
- if (this.options.ignoreJSONStructure === void 0) {
7683
- this.options.ignoreJSONStructure = true;
7684
- }
7685
- }
7686
- addNamespaces(ns) {
7687
- if (this.options.ns.indexOf(ns) < 0) {
7688
- this.options.ns.push(ns);
7689
- }
7690
- }
7691
- removeNamespaces(ns) {
7692
- const index = this.options.ns.indexOf(ns);
7693
- if (index > -1) {
7694
- this.options.ns.splice(index, 1);
7695
- }
7696
- }
7697
- getResource(lng, ns, key, options = {}) {
7698
- var _a, _b;
7699
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7700
- const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
7701
- let path;
7702
- if (lng.indexOf(".") > -1) {
7703
- path = lng.split(".");
7704
- } else {
7705
- path = [lng, ns];
7706
- if (key) {
7707
- if (Array.isArray(key)) {
7708
- path.push(...key);
7709
- } else if (isString(key) && keySeparator) {
7710
- path.push(...key.split(keySeparator));
7711
- } else {
7712
- path.push(key);
7713
- }
7714
- }
7715
- }
7716
- const result = getPath(this.data, path);
7717
- if (!result && !ns && !key && lng.indexOf(".") > -1) {
7718
- lng = path[0];
7719
- ns = path[1];
7720
- key = path.slice(2).join(".");
7721
- }
7722
- if (result || !ignoreJSONStructure || !isString(key)) return result;
7723
- return deepFind((_b = (_a = this.data) == null ? void 0 : _a[lng]) == null ? void 0 : _b[ns], key, keySeparator);
7724
- }
7725
- addResource(lng, ns, key, value, options = {
7726
- silent: false
7727
- }) {
7728
- const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
7729
- let path = [lng, ns];
7730
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
7731
- if (lng.indexOf(".") > -1) {
7732
- path = lng.split(".");
7733
- value = ns;
7734
- ns = path[1];
7735
- }
7736
- this.addNamespaces(ns);
7737
- setPath(this.data, path, value);
7738
- if (!options.silent) this.emit("added", lng, ns, key, value);
7739
- }
7740
- addResources(lng, ns, resources, options = {
7741
- silent: false
7742
- }) {
7743
- for (const m in resources) {
7744
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
7745
- silent: true
7746
- });
7747
- }
7748
- if (!options.silent) this.emit("added", lng, ns, resources);
7749
- }
7750
- addResourceBundle(lng, ns, resources, deep, overwrite, options = {
7751
- silent: false,
7752
- skipCopy: false
7753
- }) {
7754
- let path = [lng, ns];
7755
- if (lng.indexOf(".") > -1) {
7756
- path = lng.split(".");
7757
- deep = resources;
7758
- resources = ns;
7759
- ns = path[1];
7760
- }
7761
- this.addNamespaces(ns);
7762
- let pack = getPath(this.data, path) || {};
7763
- if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
7764
- if (deep) {
7765
- deepExtend(pack, resources, overwrite);
7766
- } else {
7767
- pack = {
7768
- ...pack,
7769
- ...resources
7770
- };
7771
- }
7772
- setPath(this.data, path, pack);
7773
- if (!options.silent) this.emit("added", lng, ns, resources);
7774
- }
7775
- removeResourceBundle(lng, ns) {
7776
- if (this.hasResourceBundle(lng, ns)) {
7777
- delete this.data[lng][ns];
7778
- }
7779
- this.removeNamespaces(ns);
7780
- this.emit("removed", lng, ns);
7781
- }
7782
- hasResourceBundle(lng, ns) {
7783
- return this.getResource(lng, ns) !== void 0;
7784
- }
7785
- getResourceBundle(lng, ns) {
7786
- if (!ns) ns = this.options.defaultNS;
7787
- return this.getResource(lng, ns);
7788
- }
7789
- getDataByLanguage(lng) {
7790
- return this.data[lng];
7791
- }
7792
- hasLanguageSomeTranslations(lng) {
7793
- const data = this.getDataByLanguage(lng);
7794
- const n = data && Object.keys(data) || [];
7795
- return !!n.find((v) => data[v] && Object.keys(data[v]).length > 0);
7796
- }
7797
- toJSON() {
7798
- return this.data;
7799
- }
7409
+ function HeadingBlock({
7410
+ id,
7411
+ props,
7412
+ data,
7413
+ isLastBlock,
7414
+ isFirstBlock
7415
+ }) {
7416
+ const className = ui.clx(
7417
+ "text-xl",
7418
+ "font-bold",
7419
+ isLastBlock ? "mb-0" : "mb-4",
7420
+ isFirstBlock ? "mt-0" : "mt-4"
7421
+ );
7422
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Heading, { className, children: props.value });
7800
7423
  }
7801
- var postProcessor = {
7802
- processors: {},
7803
- addPostProcessor(module2) {
7804
- this.processors[module2.name] = module2;
7805
- },
7806
- handle(processors, value, key, options, translator) {
7807
- processors.forEach((processor) => {
7808
- var _a;
7809
- value = ((_a = this.processors[processor]) == null ? void 0 : _a.process(value, key, options, translator)) ?? value;
7810
- });
7811
- return value;
7812
- }
7813
- };
7814
- const PATH_KEY = Symbol("i18next/PATH_KEY");
7815
- function createProxy() {
7816
- const state = [];
7817
- const handler = /* @__PURE__ */ Object.create(null);
7818
- let proxy;
7819
- handler.get = (target, key) => {
7820
- var _a;
7821
- (_a = proxy == null ? void 0 : proxy.revoke) == null ? void 0 : _a.call(proxy);
7822
- if (key === PATH_KEY) return state;
7823
- state.push(key);
7824
- proxy = Proxy.revocable(target, handler);
7825
- return proxy.proxy;
7826
- };
7827
- return Proxy.revocable(/* @__PURE__ */ Object.create(null), handler).proxy;
7424
+ function RowBlock({
7425
+ id,
7426
+ props,
7427
+ data,
7428
+ isLastBlock,
7429
+ isFirstBlock
7430
+ }) {
7431
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Row, { children: [
7432
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "font-semibold", children: props.label }),
7433
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "text-right", children: typeof props.value === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value })
7434
+ ] });
7828
7435
  }
7829
- function keysFromSelector(selector, opts) {
7830
- const {
7831
- [PATH_KEY]: path
7832
- } = selector(createProxy());
7833
- return path.join((opts == null ? void 0 : opts.keySeparator) ?? ".");
7436
+ function SeparatorBlock({
7437
+ id,
7438
+ props,
7439
+ isLastBlock,
7440
+ isFirstBlock
7441
+ }) {
7442
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Hr, { className: "my-4 border-ui-border" });
7834
7443
  }
7835
- const checkedLoadedFor = {};
7836
- const shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
7837
- class Translator extends EventEmitter {
7838
- constructor(services, options = {}) {
7839
- super();
7840
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], services, this);
7841
- this.options = options;
7842
- if (this.options.keySeparator === void 0) {
7843
- this.options.keySeparator = ".";
7844
- }
7845
- this.logger = baseLogger.create("translator");
7846
- }
7847
- changeLanguage(lng) {
7848
- if (lng) this.language = lng;
7849
- }
7850
- exists(key, o = {
7851
- interpolation: {}
7852
- }) {
7853
- const opt = {
7854
- ...o
7855
- };
7856
- if (key == null) return false;
7857
- const resolved = this.resolve(key, opt);
7858
- if ((resolved == null ? void 0 : resolved.res) === void 0) return false;
7859
- const isObject = shouldHandleAsObject(resolved.res);
7860
- if (opt.returnObjects === false && isObject) {
7861
- return false;
7862
- }
7863
- return true;
7864
- }
7865
- extractFromKey(key, opt) {
7866
- let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
7867
- if (nsSeparator === void 0) nsSeparator = ":";
7868
- const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
7869
- let namespaces = opt.ns || this.options.defaultNS || [];
7870
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
7871
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
7872
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
7873
- const m = key.match(this.interpolator.nestingRegexp);
7874
- if (m && m.length > 0) {
7875
- return {
7876
- key,
7877
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7878
- };
7879
- }
7880
- const parts = key.split(nsSeparator);
7881
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
7882
- key = parts.join(keySeparator);
7883
- }
7884
- return {
7885
- key,
7886
- namespaces: isString(namespaces) ? [namespaces] : namespaces
7887
- };
7888
- }
7889
- translate(keys, o, lastKey) {
7890
- let opt = typeof o === "object" ? {
7891
- ...o
7892
- } : o;
7893
- if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
7894
- opt = this.options.overloadTranslationOptionHandler(arguments);
7895
- }
7896
- if (typeof opt === "object") opt = {
7897
- ...opt
7898
- };
7899
- if (!opt) opt = {};
7900
- if (keys == null) return "";
7901
- if (typeof keys === "function") keys = keysFromSelector(keys, {
7902
- ...this.options,
7903
- ...opt
7904
- });
7905
- if (!Array.isArray(keys)) keys = [String(keys)];
7906
- const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
7907
- const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
7908
- const {
7909
- key,
7910
- namespaces
7911
- } = this.extractFromKey(keys[keys.length - 1], opt);
7912
- const namespace = namespaces[namespaces.length - 1];
7913
- let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
7914
- if (nsSeparator === void 0) nsSeparator = ":";
7915
- const lng = opt.lng || this.language;
7916
- const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
7917
- if ((lng == null ? void 0 : lng.toLowerCase()) === "cimode") {
7918
- if (appendNamespaceToCIMode) {
7919
- if (returnDetails) {
7920
- return {
7921
- res: `${namespace}${nsSeparator}${key}`,
7922
- usedKey: key,
7923
- exactUsedKey: key,
7924
- usedLng: lng,
7925
- usedNS: namespace,
7926
- usedParams: this.getUsedParamsDetails(opt)
7927
- };
7928
- }
7929
- return `${namespace}${nsSeparator}${key}`;
7930
- }
7931
- if (returnDetails) {
7932
- return {
7933
- res: key,
7934
- usedKey: key,
7935
- exactUsedKey: key,
7936
- usedLng: lng,
7937
- usedNS: namespace,
7938
- usedParams: this.getUsedParamsDetails(opt)
7939
- };
7940
- }
7941
- return key;
7942
- }
7943
- const resolved = this.resolve(keys, opt);
7944
- let res = resolved == null ? void 0 : resolved.res;
7945
- const resUsedKey = (resolved == null ? void 0 : resolved.usedKey) || key;
7946
- const resExactUsedKey = (resolved == null ? void 0 : resolved.exactUsedKey) || key;
7947
- const noObject = ["[object Number]", "[object Function]", "[object RegExp]"];
7948
- const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
7949
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
7950
- const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
7951
- const hasDefaultValue = Translator.hasDefaultValue(opt);
7952
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
7953
- const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
7954
- ordinal: false
7955
- }) : "";
7956
- const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
7957
- const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
7958
- let resForObjHndl = res;
7959
- if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
7960
- resForObjHndl = defaultValue;
7961
- }
7962
- const handleAsObject = shouldHandleAsObject(resForObjHndl);
7963
- const resType = Object.prototype.toString.apply(resForObjHndl);
7964
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
7965
- if (!opt.returnObjects && !this.options.returnObjects) {
7966
- if (!this.options.returnedObjectHandler) {
7967
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
7968
- }
7969
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
7970
- ...opt,
7971
- ns: namespaces
7972
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
7973
- if (returnDetails) {
7974
- resolved.res = r;
7975
- resolved.usedParams = this.getUsedParamsDetails(opt);
7976
- return resolved;
7977
- }
7978
- return r;
7979
- }
7980
- if (keySeparator) {
7981
- const resTypeIsArray = Array.isArray(resForObjHndl);
7982
- const copy2 = resTypeIsArray ? [] : {};
7983
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
7984
- for (const m in resForObjHndl) {
7985
- if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
7986
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
7987
- if (hasDefaultValue && !res) {
7988
- copy2[m] = this.translate(deepKey, {
7989
- ...opt,
7990
- defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
7991
- ...{
7992
- joinArrays: false,
7993
- ns: namespaces
7994
- }
7995
- });
7996
- } else {
7997
- copy2[m] = this.translate(deepKey, {
7998
- ...opt,
7999
- ...{
8000
- joinArrays: false,
8001
- ns: namespaces
8002
- }
8003
- });
8004
- }
8005
- if (copy2[m] === deepKey) copy2[m] = resForObjHndl[m];
8006
- }
8007
- }
8008
- res = copy2;
8009
- }
8010
- } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
8011
- res = res.join(joinArrays);
8012
- if (res) res = this.extendTranslation(res, keys, opt, lastKey);
8013
- } else {
8014
- let usedDefault = false;
8015
- let usedKey = false;
8016
- if (!this.isValidLookup(res) && hasDefaultValue) {
8017
- usedDefault = true;
8018
- res = defaultValue;
8019
- }
8020
- if (!this.isValidLookup(res)) {
8021
- usedKey = true;
8022
- res = key;
8023
- }
8024
- const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
8025
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
8026
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
8027
- if (usedKey || usedDefault || updateMissing) {
8028
- this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
8029
- if (keySeparator) {
8030
- const fk = this.resolve(key, {
8031
- ...opt,
8032
- keySeparator: false
8033
- });
8034
- if (fk && fk.res) this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
8035
- }
8036
- let lngs = [];
8037
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
8038
- if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) {
8039
- for (let i = 0; i < fallbackLngs.length; i++) {
8040
- lngs.push(fallbackLngs[i]);
8041
- }
8042
- } else if (this.options.saveMissingTo === "all") {
8043
- lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
8044
- } else {
8045
- lngs.push(opt.lng || this.language);
8046
- }
8047
- const send = (l, k, specificDefaultValue) => {
8048
- var _a;
8049
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
8050
- if (this.options.missingKeyHandler) {
8051
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
8052
- } else if ((_a = this.backendConnector) == null ? void 0 : _a.saveMissing) {
8053
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
8054
- }
8055
- this.emit("missingKey", l, namespace, k, res);
8056
- };
8057
- if (this.options.saveMissing) {
8058
- if (this.options.saveMissingPlurals && needsPluralHandling) {
8059
- lngs.forEach((language) => {
8060
- const suffixes = this.pluralResolver.getSuffixes(language, opt);
8061
- if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
8062
- suffixes.push(`${this.options.pluralSeparator}zero`);
8063
- }
8064
- suffixes.forEach((suffix) => {
8065
- send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
8066
- });
8067
- });
8068
- } else {
8069
- send(lngs, key, defaultValue);
8070
- }
8071
- }
8072
- }
8073
- res = this.extendTranslation(res, keys, opt, resolved, lastKey);
8074
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
8075
- res = `${namespace}${nsSeparator}${key}`;
8076
- }
8077
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
8078
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
8079
- }
8080
- }
8081
- if (returnDetails) {
8082
- resolved.res = res;
8083
- resolved.usedParams = this.getUsedParamsDetails(opt);
8084
- return resolved;
8085
- }
8086
- return res;
8087
- }
8088
- extendTranslation(res, key, opt, resolved, lastKey) {
8089
- var _a, _b;
8090
- if ((_a = this.i18nFormat) == null ? void 0 : _a.parse) {
8091
- res = this.i18nFormat.parse(res, {
8092
- ...this.options.interpolation.defaultVariables,
8093
- ...opt
8094
- }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
8095
- resolved
8096
- });
8097
- } else if (!opt.skipInterpolation) {
8098
- if (opt.interpolation) this.interpolator.init({
8099
- ...opt,
8100
- ...{
8101
- interpolation: {
8102
- ...this.options.interpolation,
8103
- ...opt.interpolation
8104
- }
8105
- }
8106
- });
8107
- const skipOnVariables = isString(res) && (((_b = opt == null ? void 0 : opt.interpolation) == null ? void 0 : _b.skipOnVariables) !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
8108
- let nestBef;
8109
- if (skipOnVariables) {
8110
- const nb = res.match(this.interpolator.nestingRegexp);
8111
- nestBef = nb && nb.length;
8112
- }
8113
- let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
8114
- if (this.options.interpolation.defaultVariables) data = {
8115
- ...this.options.interpolation.defaultVariables,
8116
- ...data
8117
- };
8118
- res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
8119
- if (skipOnVariables) {
8120
- const na = res.match(this.interpolator.nestingRegexp);
8121
- const nestAft = na && na.length;
8122
- if (nestBef < nestAft) opt.nest = false;
8123
- }
8124
- if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
8125
- if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
8126
- if ((lastKey == null ? void 0 : lastKey[0]) === args[0] && !opt.context) {
8127
- this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
7444
+ function ProductItemBlock({
7445
+ props,
7446
+ data,
7447
+ isLastBlock,
7448
+ isFirstBlock
7449
+ }) {
7450
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Row, { children: [
7451
+ props.thumbnail && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7452
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "w-[50px]", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: props.thumbnail, width: 50, height: 50 }) }),
7453
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "w-[12px]" })
7454
+ ] }),
7455
+ /* @__PURE__ */ jsxRuntime.jsx(components.Column, { className: "text-left", children: typeof props.value === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: props.value } }) : props.value })
7456
+ ] });
7457
+ }
7458
+ function BlockRenderer({ blocks, data }) {
7459
+ return blocks.map((block, index) => {
7460
+ const blockKey = block.id || `block-${index}`;
7461
+ const isLastBlock = index === blocks.length - 1;
7462
+ const isFirstBlock = index === 0;
7463
+ switch (block.type) {
7464
+ case "section":
7465
+ return /* @__PURE__ */ jsxRuntime.jsx(
7466
+ SectionBlock,
7467
+ {
7468
+ id: blockKey,
7469
+ props: block.props,
7470
+ data,
7471
+ isLastBlock,
7472
+ isFirstBlock
7473
+ },
7474
+ blockKey
7475
+ );
7476
+ case "row":
7477
+ return /* @__PURE__ */ jsxRuntime.jsx(
7478
+ RowBlock,
7479
+ {
7480
+ id: blockKey,
7481
+ props: block.props,
7482
+ data,
7483
+ isLastBlock,
7484
+ isFirstBlock
7485
+ },
7486
+ blockKey
7487
+ );
7488
+ case "product-item":
7489
+ return /* @__PURE__ */ jsxRuntime.jsx(
7490
+ ProductItemBlock,
7491
+ {
7492
+ id: blockKey,
7493
+ props: block.props,
7494
+ data,
7495
+ isLastBlock,
7496
+ isFirstBlock
7497
+ },
7498
+ blockKey
7499
+ );
7500
+ case "heading":
7501
+ return /* @__PURE__ */ jsxRuntime.jsx(
7502
+ HeadingBlock,
7503
+ {
7504
+ id: blockKey,
7505
+ props: block.props,
7506
+ data,
7507
+ isLastBlock,
7508
+ isFirstBlock
7509
+ },
7510
+ blockKey
7511
+ );
7512
+ case "text":
7513
+ return /* @__PURE__ */ jsxRuntime.jsx(
7514
+ TextBlock,
7515
+ {
7516
+ id: blockKey,
7517
+ props: block.props,
7518
+ isLastBlock,
7519
+ isFirstBlock
7520
+ },
7521
+ blockKey
7522
+ );
7523
+ case "separator":
7524
+ return /* @__PURE__ */ jsxRuntime.jsx(
7525
+ SeparatorBlock,
7526
+ {
7527
+ id: blockKey,
7528
+ props: block.props,
7529
+ isLastBlock,
7530
+ isFirstBlock
7531
+ },
7532
+ blockKey
7533
+ );
7534
+ case "repeater":
7535
+ if (!data) {
7536
+ console.warn("RepeaterBlock requires data prop");
8128
7537
  return null;
8129
7538
  }
8130
- return this.translate(...args, key);
8131
- }, opt);
8132
- if (opt.interpolation) this.interpolator.reset();
7539
+ return /* @__PURE__ */ jsxRuntime.jsx(
7540
+ RepeaterBlock,
7541
+ {
7542
+ id: blockKey,
7543
+ props: block.props,
7544
+ data
7545
+ },
7546
+ blockKey
7547
+ );
7548
+ default:
7549
+ return null;
8133
7550
  }
8134
- const postProcess = opt.postProcess || this.options.postProcess;
8135
- const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
8136
- if (res != null && (postProcessorNames == null ? void 0 : postProcessorNames.length) && opt.applyPostProcessor !== false) {
8137
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
8138
- i18nResolved: {
8139
- ...resolved,
8140
- usedParams: this.getUsedParamsDetails(opt)
7551
+ });
7552
+ }
7553
+ function renderHTMLReact(data, options) {
7554
+ const theme = options.theme || {};
7555
+ const blocks = options.blocks || [];
7556
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Html, { children: [
7557
+ /* @__PURE__ */ jsxRuntime.jsx(components.Head, {}),
7558
+ /* @__PURE__ */ jsxRuntime.jsx(
7559
+ components.Tailwind,
7560
+ {
7561
+ config: {
7562
+ presets: [components.pixelBasedPreset],
7563
+ theme
8141
7564
  },
8142
- ...opt
8143
- } : opt, this);
8144
- }
8145
- return res;
8146
- }
8147
- resolve(keys, opt = {}) {
8148
- let found;
8149
- let usedKey;
8150
- let exactUsedKey;
8151
- let usedLng;
8152
- let usedNS;
8153
- if (isString(keys)) keys = [keys];
8154
- keys.forEach((k) => {
8155
- if (this.isValidLookup(found)) return;
8156
- const extracted = this.extractFromKey(k, opt);
8157
- const key = extracted.key;
8158
- usedKey = key;
8159
- let namespaces = extracted.namespaces;
8160
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
8161
- const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
8162
- const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
8163
- const needsContextHandling = opt.context !== void 0 && (isString(opt.context) || typeof opt.context === "number") && opt.context !== "";
8164
- const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
8165
- namespaces.forEach((ns) => {
8166
- var _a, _b;
8167
- if (this.isValidLookup(found)) return;
8168
- usedNS = ns;
8169
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && ((_a = this.utils) == null ? void 0 : _a.hasLoadedNamespace) && !((_b = this.utils) == null ? void 0 : _b.hasLoadedNamespace(usedNS))) {
8170
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
8171
- this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
8172
- }
8173
- codes.forEach((code) => {
8174
- var _a2;
8175
- if (this.isValidLookup(found)) return;
8176
- usedLng = code;
8177
- const finalKeys = [key];
8178
- if ((_a2 = this.i18nFormat) == null ? void 0 : _a2.addLookupKeys) {
8179
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
8180
- } else {
8181
- let pluralSuffix;
8182
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
8183
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
8184
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
8185
- if (needsPluralHandling) {
8186
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8187
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8188
- }
8189
- finalKeys.push(key + pluralSuffix);
8190
- if (needsZeroSuffixLookup) {
8191
- finalKeys.push(key + zeroSuffix);
8192
- }
8193
- }
8194
- if (needsContextHandling) {
8195
- const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
8196
- finalKeys.push(contextKey);
8197
- if (needsPluralHandling) {
8198
- if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
8199
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
8200
- }
8201
- finalKeys.push(contextKey + pluralSuffix);
8202
- if (needsZeroSuffixLookup) {
8203
- finalKeys.push(contextKey + zeroSuffix);
8204
- }
8205
- }
8206
- }
8207
- }
8208
- let possibleKey;
8209
- while (possibleKey = finalKeys.pop()) {
8210
- if (!this.isValidLookup(found)) {
8211
- exactUsedKey = possibleKey;
8212
- found = this.getResource(code, ns, possibleKey, opt);
8213
- }
8214
- }
8215
- });
8216
- });
8217
- });
8218
- return {
8219
- res: found,
8220
- usedKey,
8221
- exactUsedKey,
8222
- usedLng,
8223
- usedNS
8224
- };
8225
- }
8226
- isValidLookup(res) {
8227
- return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
8228
- }
8229
- getResource(code, ns, key, options = {}) {
8230
- var _a;
8231
- if ((_a = this.i18nFormat) == null ? void 0 : _a.getResource) return this.i18nFormat.getResource(code, ns, key, options);
8232
- return this.resourceStore.getResource(code, ns, key, options);
8233
- }
8234
- getUsedParamsDetails(options = {}) {
8235
- const optionsKeys = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"];
8236
- const useOptionsReplaceForData = options.replace && !isString(options.replace);
8237
- let data = useOptionsReplaceForData ? options.replace : options;
8238
- if (useOptionsReplaceForData && typeof options.count !== "undefined") {
8239
- data.count = options.count;
8240
- }
8241
- if (this.options.interpolation.defaultVariables) {
8242
- data = {
8243
- ...this.options.interpolation.defaultVariables,
8244
- ...data
8245
- };
8246
- }
8247
- if (!useOptionsReplaceForData) {
8248
- data = {
8249
- ...data
8250
- };
8251
- for (const key of optionsKeys) {
8252
- delete data[key];
7565
+ children: /* @__PURE__ */ jsxRuntime.jsx(components.Body, { className: "mx-auto my-auto px-4 font-arial font-normal text-base bg-ui-bg text-ui-text", children: /* @__PURE__ */ jsxRuntime.jsx(components.Container, { className: "py-4", children: /* @__PURE__ */ jsxRuntime.jsx(BlockRenderer, { blocks, data }) }) })
8253
7566
  }
8254
- }
8255
- return data;
8256
- }
8257
- static hasDefaultValue(options) {
8258
- const prefix = "defaultValue";
8259
- for (const option in options) {
8260
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && void 0 !== options[option]) {
8261
- return true;
8262
- }
8263
- }
8264
- return false;
8265
- }
7567
+ )
7568
+ ] });
8266
7569
  }
8267
- class LanguageUtil {
8268
- constructor(options) {
8269
- this.options = options;
8270
- this.supportedLngs = this.options.supportedLngs || false;
8271
- this.logger = baseLogger.create("languageUtils");
8272
- }
8273
- getScriptPartFromCode(code) {
8274
- code = getCleanedCode(code);
8275
- if (!code || code.indexOf("-") < 0) return null;
8276
- const p = code.split("-");
8277
- if (p.length === 2) return null;
8278
- p.pop();
8279
- if (p[p.length - 1].toLowerCase() === "x") return null;
8280
- return this.formatLanguageCode(p.join("-"));
8281
- }
8282
- getLanguagePartFromCode(code) {
8283
- code = getCleanedCode(code);
8284
- if (!code || code.indexOf("-") < 0) return code;
8285
- const p = code.split("-");
8286
- return this.formatLanguageCode(p[0]);
8287
- }
8288
- formatLanguageCode(code) {
8289
- if (isString(code) && code.indexOf("-") > -1) {
8290
- let formattedCode;
8291
- try {
8292
- formattedCode = Intl.getCanonicalLocales(code)[0];
8293
- } catch (e) {
8294
- }
8295
- if (formattedCode && this.options.lowerCaseLng) {
8296
- formattedCode = formattedCode.toLowerCase();
8297
- }
8298
- if (formattedCode) return formattedCode;
8299
- if (this.options.lowerCaseLng) {
8300
- return code.toLowerCase();
8301
- }
8302
- return code;
8303
- }
8304
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
8305
- }
8306
- isSupportedCode(code) {
8307
- if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
8308
- code = this.getLanguagePartFromCode(code);
8309
- }
8310
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
8311
- }
8312
- getBestMatchFromCodes(codes) {
8313
- if (!codes) return null;
8314
- let found;
8315
- codes.forEach((code) => {
8316
- if (found) return;
8317
- const cleanedLng = this.formatLanguageCode(code);
8318
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
8319
- });
8320
- if (!found && this.options.supportedLngs) {
8321
- codes.forEach((code) => {
8322
- if (found) return;
8323
- const lngScOnly = this.getScriptPartFromCode(code);
8324
- if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
8325
- const lngOnly = this.getLanguagePartFromCode(code);
8326
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
8327
- found = this.options.supportedLngs.find((supportedLng) => {
8328
- if (supportedLng === lngOnly) return supportedLng;
8329
- if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
8330
- if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
8331
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
8332
- });
8333
- });
8334
- }
8335
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
8336
- return found;
8337
- }
8338
- getFallbackCodes(fallbacks, code) {
8339
- if (!fallbacks) return [];
8340
- if (typeof fallbacks === "function") fallbacks = fallbacks(code);
8341
- if (isString(fallbacks)) fallbacks = [fallbacks];
8342
- if (Array.isArray(fallbacks)) return fallbacks;
8343
- if (!code) return fallbacks.default || [];
8344
- let found = fallbacks[code];
8345
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
8346
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
8347
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
8348
- if (!found) found = fallbacks.default;
8349
- return found || [];
8350
- }
8351
- toResolveHierarchy(code, fallbackCode) {
8352
- const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
8353
- const codes = [];
8354
- const addCode = (c) => {
8355
- if (!c) return;
8356
- if (this.isSupportedCode(c)) {
8357
- codes.push(c);
8358
- } else {
8359
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
8360
- }
8361
- };
8362
- if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
8363
- if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
8364
- if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
8365
- if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
8366
- } else if (isString(code)) {
8367
- addCode(this.formatLanguageCode(code));
8368
- }
8369
- fallbackCodes.forEach((fc) => {
8370
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
8371
- });
8372
- return codes;
8373
- }
7570
+ async function renderHTML(data, options) {
7571
+ return await render.pretty(await render.render(renderHTMLReact(data, options)));
8374
7572
  }
8375
- const suffixesOrder = {
8376
- zero: 0,
8377
- one: 1,
8378
- two: 2,
8379
- few: 3,
8380
- many: 4,
8381
- other: 5
8382
- };
8383
- const dummyRule = {
8384
- select: (count) => count === 1 ? "one" : "other",
8385
- resolvedOptions: () => ({
8386
- pluralCategories: ["one", "other"]
8387
- })
8388
- };
8389
- class PluralResolver {
8390
- constructor(languageUtils, options = {}) {
8391
- this.languageUtils = languageUtils;
8392
- this.options = options;
8393
- this.logger = baseLogger.create("pluralResolver");
8394
- this.pluralRulesCache = {};
8395
- }
8396
- addRule(lng, obj) {
8397
- this.rules[lng] = obj;
8398
- }
8399
- clearCache() {
8400
- this.pluralRulesCache = {};
8401
- }
8402
- getRule(code, options = {}) {
8403
- const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
8404
- const type = options.ordinal ? "ordinal" : "cardinal";
8405
- const cacheKey = JSON.stringify({
8406
- cleanedCode,
8407
- type
8408
- });
8409
- if (cacheKey in this.pluralRulesCache) {
8410
- return this.pluralRulesCache[cacheKey];
8411
- }
8412
- let rule;
8413
- try {
8414
- rule = new Intl.PluralRules(cleanedCode, {
8415
- type
8416
- });
8417
- } catch (err) {
8418
- if (!Intl) {
8419
- this.logger.error("No Intl support, please use an Intl polyfill!");
8420
- return dummyRule;
8421
- }
8422
- if (!code.match(/-|_/)) return dummyRule;
8423
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
8424
- rule = this.getRule(lngPart, options);
8425
- }
8426
- this.pluralRulesCache[cacheKey] = rule;
8427
- return rule;
8428
- }
8429
- needsPlural(code, options = {}) {
8430
- let rule = this.getRule(code, options);
8431
- if (!rule) rule = this.getRule("dev", options);
8432
- return (rule == null ? void 0 : rule.resolvedOptions().pluralCategories.length) > 1;
8433
- }
8434
- getPluralFormsOfKey(code, key, options = {}) {
8435
- return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
8436
- }
8437
- getSuffixes(code, options = {}) {
8438
- let rule = this.getRule(code, options);
8439
- if (!rule) rule = this.getRule("dev", options);
8440
- if (!rule) return [];
8441
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
8442
- }
8443
- getSuffix(code, count, options = {}) {
8444
- const rule = this.getRule(code, options);
8445
- if (rule) {
8446
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
8447
- }
8448
- this.logger.warn(`no plural rule found for: ${code}`);
8449
- return this.getSuffix("dev", count, options);
8450
- }
7573
+ async function renderText(data, options) {
7574
+ const html = await render.render(renderHTMLReact(data, options));
7575
+ return render.toPlainText(html);
8451
7576
  }
8452
- const deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
8453
- let path = getPathWithDefaults(data, defaultData, key);
8454
- if (!path && ignoreJSONStructure && isString(key)) {
8455
- path = deepFind(data, key, keySeparator);
8456
- if (path === void 0) path = deepFind(defaultData, key, keySeparator);
8457
- }
8458
- return path;
8459
- };
8460
- const regexSafe = (val) => val.replace(/\$/g, "$$$$");
8461
- class Interpolator {
8462
- constructor(options = {}) {
8463
- var _a;
8464
- this.logger = baseLogger.create("interpolator");
8465
- this.options = options;
8466
- this.format = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.format) || ((value) => value);
8467
- this.init(options);
8468
- }
8469
- init(options = {}) {
8470
- if (!options.interpolation) options.interpolation = {
8471
- escapeValue: true
8472
- };
8473
- const {
8474
- escape: escape$1,
8475
- escapeValue,
8476
- useRawValueToEscape,
8477
- prefix,
8478
- prefixEscaped,
8479
- suffix,
8480
- suffixEscaped,
8481
- formatSeparator,
8482
- unescapeSuffix,
8483
- unescapePrefix,
8484
- nestingPrefix,
8485
- nestingPrefixEscaped,
8486
- nestingSuffix,
8487
- nestingSuffixEscaped,
8488
- nestingOptionsSeparator,
8489
- maxReplaces,
8490
- alwaysFormat
8491
- } = options.interpolation;
8492
- this.escape = escape$1 !== void 0 ? escape$1 : escape;
8493
- this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
8494
- this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
8495
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
8496
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
8497
- this.formatSeparator = formatSeparator || ",";
8498
- this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
8499
- this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
8500
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
8501
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
8502
- this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
8503
- this.maxReplaces = maxReplaces || 1e3;
8504
- this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
8505
- this.resetRegExp();
8506
- }
8507
- reset() {
8508
- if (this.options) this.init(this.options);
8509
- }
8510
- resetRegExp() {
8511
- const getOrResetRegExp = (existingRegExp, pattern) => {
8512
- if ((existingRegExp == null ? void 0 : existingRegExp.source) === pattern) {
8513
- existingRegExp.lastIndex = 0;
8514
- return existingRegExp;
8515
- }
8516
- return new RegExp(pattern, "g");
8517
- };
8518
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
8519
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
8520
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
8521
- }
8522
- interpolate(str, data, lng, options) {
8523
- var _a;
8524
- let match2;
8525
- let value;
8526
- let replaces;
8527
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
8528
- const handleFormat = (key) => {
8529
- if (key.indexOf(this.formatSeparator) < 0) {
8530
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
8531
- return this.alwaysFormat ? this.format(path, void 0, lng, {
8532
- ...options,
8533
- ...data,
8534
- interpolationkey: key
8535
- }) : path;
8536
- }
8537
- const p = key.split(this.formatSeparator);
8538
- const k = p.shift().trim();
8539
- const f = p.join(this.formatSeparator).trim();
8540
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
8541
- ...options,
8542
- ...data,
8543
- interpolationkey: k
8544
- });
8545
- };
8546
- this.resetRegExp();
8547
- const missingInterpolationHandler = (options == null ? void 0 : options.missingInterpolationHandler) || this.options.missingInterpolationHandler;
8548
- const skipOnVariables = ((_a = options == null ? void 0 : options.interpolation) == null ? void 0 : _a.skipOnVariables) !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
8549
- const todos = [{
8550
- regex: this.regexpUnescape,
8551
- safeValue: (val) => regexSafe(val)
8552
- }, {
8553
- regex: this.regexp,
8554
- safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
8555
- }];
8556
- todos.forEach((todo) => {
8557
- replaces = 0;
8558
- while (match2 = todo.regex.exec(str)) {
8559
- const matchedVar = match2[1].trim();
8560
- value = handleFormat(matchedVar);
8561
- if (value === void 0) {
8562
- if (typeof missingInterpolationHandler === "function") {
8563
- const temp = missingInterpolationHandler(str, match2, options);
8564
- value = isString(temp) ? temp : "";
8565
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
8566
- value = "";
8567
- } else if (skipOnVariables) {
8568
- value = match2[0];
8569
- continue;
8570
- } else {
8571
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
8572
- value = "";
8573
- }
8574
- } else if (!isString(value) && !this.useRawValueToEscape) {
8575
- value = makeString(value);
8576
- }
8577
- const safeValue = todo.safeValue(value);
8578
- str = str.replace(match2[0], safeValue);
8579
- if (skipOnVariables) {
8580
- todo.regex.lastIndex += value.length;
8581
- todo.regex.lastIndex -= match2[0].length;
8582
- } else {
8583
- todo.regex.lastIndex = 0;
8584
- }
8585
- replaces++;
8586
- if (replaces >= this.maxReplaces) {
8587
- break;
8588
- }
8589
- }
8590
- });
8591
- return str;
8592
- }
8593
- nest(str, fc, options = {}) {
8594
- let match2;
8595
- let value;
8596
- let clonedOptions;
8597
- const handleHasOptions = (key, inheritedOptions) => {
8598
- const sep = this.nestingOptionsSeparator;
8599
- if (key.indexOf(sep) < 0) return key;
8600
- const c = key.split(new RegExp(`${sep}[ ]*{`));
8601
- let optionsString = `{${c[1]}`;
8602
- key = c[0];
8603
- optionsString = this.interpolate(optionsString, clonedOptions);
8604
- const matchedSingleQuotes = optionsString.match(/'/g);
8605
- const matchedDoubleQuotes = optionsString.match(/"/g);
8606
- if (((matchedSingleQuotes == null ? void 0 : matchedSingleQuotes.length) ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
8607
- optionsString = optionsString.replace(/'/g, '"');
8608
- }
8609
- try {
8610
- clonedOptions = JSON.parse(optionsString);
8611
- if (inheritedOptions) clonedOptions = {
8612
- ...inheritedOptions,
8613
- ...clonedOptions
8614
- };
8615
- } catch (e) {
8616
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
8617
- return `${key}${sep}${optionsString}`;
8618
- }
8619
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
8620
- return key;
8621
- };
8622
- while (match2 = this.nestingRegexp.exec(str)) {
8623
- let formatters2 = [];
8624
- clonedOptions = {
8625
- ...options
8626
- };
8627
- clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
8628
- clonedOptions.applyPostProcessor = false;
8629
- delete clonedOptions.defaultValue;
8630
- const keyEndIndex = /{.*}/.test(match2[1]) ? match2[1].lastIndexOf("}") + 1 : match2[1].indexOf(this.formatSeparator);
8631
- if (keyEndIndex !== -1) {
8632
- formatters2 = match2[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
8633
- match2[1] = match2[1].slice(0, keyEndIndex);
8634
- }
8635
- value = fc(handleHasOptions.call(this, match2[1].trim(), clonedOptions), clonedOptions);
8636
- if (value && match2[0] === str && !isString(value)) return value;
8637
- if (!isString(value)) value = makeString(value);
8638
- if (!value) {
8639
- this.logger.warn(`missed to resolve ${match2[1]} for nesting ${str}`);
8640
- value = "";
8641
- }
8642
- if (formatters2.length) {
8643
- value = formatters2.reduce((v, f) => this.format(v, f, options.lng, {
8644
- ...options,
8645
- interpolationkey: match2[1].trim()
8646
- }), value.trim());
8647
- }
8648
- str = str.replace(match2[0], value);
8649
- this.regexp.lastIndex = 0;
8650
- }
8651
- return str;
8652
- }
7577
+ async function getBaseTemplateHtml(data, options) {
7578
+ return await renderHTML(data, options);
8653
7579
  }
8654
- const parseFormatStr = (formatStr) => {
8655
- let formatName = formatStr.toLowerCase().trim();
8656
- const formatOptions = {};
8657
- if (formatStr.indexOf("(") > -1) {
8658
- const p = formatStr.split("(");
8659
- formatName = p[0].toLowerCase().trim();
8660
- const optStr = p[1].substring(0, p[1].length - 1);
8661
- if (formatName === "currency" && optStr.indexOf(":") < 0) {
8662
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
8663
- } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
8664
- if (!formatOptions.range) formatOptions.range = optStr.trim();
8665
- } else {
8666
- const opts = optStr.split(";");
8667
- opts.forEach((opt) => {
8668
- if (opt) {
8669
- const [key, ...rest] = opt.split(":");
8670
- const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
8671
- const trimmedKey = key.trim();
8672
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
8673
- if (val === "false") formatOptions[trimmedKey] = false;
8674
- if (val === "true") formatOptions[trimmedKey] = true;
8675
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
8676
- }
8677
- });
8678
- }
8679
- }
8680
- return {
8681
- formatName,
8682
- formatOptions
8683
- };
8684
- };
8685
- const createCachedFormatter = (fn) => {
8686
- const cache = {};
8687
- return (v, l, o) => {
8688
- let optForCache = o;
8689
- if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
8690
- optForCache = {
8691
- ...optForCache,
8692
- [o.interpolationkey]: void 0
8693
- };
8694
- }
8695
- const key = l + JSON.stringify(optForCache);
8696
- let frm = cache[key];
8697
- if (!frm) {
8698
- frm = fn(getCleanedCode(l), o);
8699
- cache[key] = frm;
8700
- }
8701
- return frm(v);
8702
- };
8703
- };
8704
- const createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
8705
- class Formatter {
8706
- constructor(options = {}) {
8707
- this.logger = baseLogger.create("formatter");
8708
- this.options = options;
8709
- this.init(options);
8710
- }
8711
- init(services, options = {
8712
- interpolation: {}
8713
- }) {
8714
- this.formatSeparator = options.interpolation.formatSeparator || ",";
8715
- const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
8716
- this.formats = {
8717
- number: cf((lng, opt) => {
8718
- const formatter = new Intl.NumberFormat(lng, {
8719
- ...opt
8720
- });
8721
- return (val) => formatter.format(val);
8722
- }),
8723
- currency: cf((lng, opt) => {
8724
- const formatter = new Intl.NumberFormat(lng, {
8725
- ...opt,
8726
- style: "currency"
8727
- });
8728
- return (val) => formatter.format(val);
8729
- }),
8730
- datetime: cf((lng, opt) => {
8731
- const formatter = new Intl.DateTimeFormat(lng, {
8732
- ...opt
8733
- });
8734
- return (val) => formatter.format(val);
8735
- }),
8736
- relativetime: cf((lng, opt) => {
8737
- const formatter = new Intl.RelativeTimeFormat(lng, {
8738
- ...opt
8739
- });
8740
- return (val) => formatter.format(val, opt.range || "day");
8741
- }),
8742
- list: cf((lng, opt) => {
8743
- const formatter = new Intl.ListFormat(lng, {
8744
- ...opt
8745
- });
8746
- return (val) => formatter.format(val);
8747
- })
8748
- };
8749
- }
8750
- add(name, fc) {
8751
- this.formats[name.toLowerCase().trim()] = fc;
8752
- }
8753
- addCached(name, fc) {
8754
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
8755
- }
8756
- format(value, format2, lng, options = {}) {
8757
- const formats = format2.split(this.formatSeparator);
8758
- if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
8759
- const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
8760
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
8761
- }
8762
- const result = formats.reduce((mem, f) => {
8763
- var _a;
8764
- const {
8765
- formatName,
8766
- formatOptions
8767
- } = parseFormatStr(f);
8768
- if (this.formats[formatName]) {
8769
- let formatted = mem;
8770
- try {
8771
- const valOptions = ((_a = options == null ? void 0 : options.formatParams) == null ? void 0 : _a[options.interpolationkey]) || {};
8772
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
8773
- formatted = this.formats[formatName](mem, l, {
8774
- ...formatOptions,
8775
- ...options,
8776
- ...valOptions
8777
- });
8778
- } catch (error) {
8779
- this.logger.warn(error);
8780
- }
8781
- return formatted;
8782
- } else {
8783
- this.logger.warn(`there was no format function for ${formatName}`);
8784
- }
8785
- return mem;
8786
- }, value);
8787
- return result;
8788
- }
7580
+ async function getBaseTemplateText(data, options) {
7581
+ return await renderText(data, options);
8789
7582
  }
8790
- const removePending = (q, name) => {
8791
- if (q.pending[name] !== void 0) {
8792
- delete q.pending[name];
8793
- q.pendingCount--;
8794
- }
8795
- };
8796
- class Connector extends EventEmitter {
8797
- constructor(backend, store, services, options = {}) {
8798
- var _a, _b;
8799
- super();
8800
- this.backend = backend;
8801
- this.store = store;
8802
- this.services = services;
8803
- this.languageUtils = services.languageUtils;
8804
- this.options = options;
8805
- this.logger = baseLogger.create("backendConnector");
8806
- this.waitingReads = [];
8807
- this.maxParallelReads = options.maxParallelReads || 10;
8808
- this.readingCalls = 0;
8809
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
8810
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
8811
- this.state = {};
8812
- this.queue = [];
8813
- (_b = (_a = this.backend) == null ? void 0 : _a.init) == null ? void 0 : _b.call(_a, services, options.backend, options);
8814
- }
8815
- queueLoad(languages, namespaces, options, callback) {
8816
- const toLoad = {};
8817
- const pending = {};
8818
- const toLoadLanguages = {};
8819
- const toLoadNamespaces = {};
8820
- languages.forEach((lng) => {
8821
- let hasAllNamespaces = true;
8822
- namespaces.forEach((ns) => {
8823
- const name = `${lng}|${ns}`;
8824
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
8825
- this.state[name] = 2;
8826
- } else if (this.state[name] < 0) ;
8827
- else if (this.state[name] === 1) {
8828
- if (pending[name] === void 0) pending[name] = true;
8829
- } else {
8830
- this.state[name] = 1;
8831
- hasAllNamespaces = false;
8832
- if (pending[name] === void 0) pending[name] = true;
8833
- if (toLoad[name] === void 0) toLoad[name] = true;
8834
- if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
8835
- }
8836
- });
8837
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
8838
- });
8839
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
8840
- this.queue.push({
8841
- pending,
8842
- pendingCount: Object.keys(pending).length,
8843
- loaded: {},
8844
- errors: [],
8845
- callback
8846
- });
8847
- }
8848
- return {
8849
- toLoad: Object.keys(toLoad),
8850
- pending: Object.keys(pending),
8851
- toLoadLanguages: Object.keys(toLoadLanguages),
8852
- toLoadNamespaces: Object.keys(toLoadNamespaces)
8853
- };
8854
- }
8855
- loaded(name, err, data) {
8856
- const s = name.split("|");
8857
- const lng = s[0];
8858
- const ns = s[1];
8859
- if (err) this.emit("failedLoading", lng, ns, err);
8860
- if (!err && data) {
8861
- this.store.addResourceBundle(lng, ns, data, void 0, void 0, {
8862
- skipCopy: true
8863
- });
8864
- }
8865
- this.state[name] = err ? -1 : 2;
8866
- if (err && data) this.state[name] = 0;
8867
- const loaded = {};
8868
- this.queue.forEach((q) => {
8869
- pushPath(q.loaded, [lng], ns);
8870
- removePending(q, name);
8871
- if (err) q.errors.push(err);
8872
- if (q.pendingCount === 0 && !q.done) {
8873
- Object.keys(q.loaded).forEach((l) => {
8874
- if (!loaded[l]) loaded[l] = {};
8875
- const loadedKeys = q.loaded[l];
8876
- if (loadedKeys.length) {
8877
- loadedKeys.forEach((n) => {
8878
- if (loaded[l][n] === void 0) loaded[l][n] = true;
8879
- });
8880
- }
8881
- });
8882
- q.done = true;
8883
- if (q.errors.length) {
8884
- q.callback(q.errors);
8885
- } else {
8886
- q.callback();
8887
- }
8888
- }
8889
- });
8890
- this.emit("loaded", loaded);
8891
- this.queue = this.queue.filter((q) => !q.done);
8892
- }
8893
- read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
8894
- if (!lng.length) return callback(null, {});
8895
- if (this.readingCalls >= this.maxParallelReads) {
8896
- this.waitingReads.push({
8897
- lng,
8898
- ns,
8899
- fcName,
8900
- tried,
8901
- wait,
8902
- callback
8903
- });
8904
- return;
8905
- }
8906
- this.readingCalls++;
8907
- const resolver = (err, data) => {
8908
- this.readingCalls--;
8909
- if (this.waitingReads.length > 0) {
8910
- const next = this.waitingReads.shift();
8911
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
8912
- }
8913
- if (err && data && tried < this.maxRetries) {
8914
- setTimeout(() => {
8915
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
8916
- }, wait);
8917
- return;
8918
- }
8919
- callback(err, data);
8920
- };
8921
- const fc = this.backend[fcName].bind(this.backend);
8922
- if (fc.length === 2) {
8923
- try {
8924
- const r = fc(lng, ns);
8925
- if (r && typeof r.then === "function") {
8926
- r.then((data) => resolver(null, data)).catch(resolver);
8927
- } else {
8928
- resolver(null, r);
8929
- }
8930
- } catch (err) {
8931
- resolver(err);
8932
- }
8933
- return;
8934
- }
8935
- return fc(lng, ns, resolver);
8936
- }
8937
- prepareLoading(languages, namespaces, options = {}, callback) {
8938
- if (!this.backend) {
8939
- this.logger.warn("No backend was added via i18next.use. Will not load resources.");
8940
- return callback && callback();
8941
- }
8942
- if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
8943
- if (isString(namespaces)) namespaces = [namespaces];
8944
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
8945
- if (!toLoad.toLoad.length) {
8946
- if (!toLoad.pending.length) callback();
8947
- return null;
8948
- }
8949
- toLoad.toLoad.forEach((name) => {
8950
- this.loadOne(name);
8951
- });
8952
- }
8953
- load(languages, namespaces, callback) {
8954
- this.prepareLoading(languages, namespaces, {}, callback);
8955
- }
8956
- reload(languages, namespaces, callback) {
8957
- this.prepareLoading(languages, namespaces, {
8958
- reload: true
8959
- }, callback);
8960
- }
8961
- loadOne(name, prefix = "") {
8962
- const s = name.split("|");
8963
- const lng = s[0];
8964
- const ns = s[1];
8965
- this.read(lng, ns, "read", void 0, void 0, (err, data) => {
8966
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
8967
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
8968
- this.loaded(name, err, data);
8969
- });
8970
- }
8971
- saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {
8972
- }) {
8973
- var _a, _b, _c, _d, _e;
8974
- if (((_b = (_a = this.services) == null ? void 0 : _a.utils) == null ? void 0 : _b.hasLoadedNamespace) && !((_d = (_c = this.services) == null ? void 0 : _c.utils) == null ? void 0 : _d.hasLoadedNamespace(namespace))) {
8975
- this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
8976
- return;
8977
- }
8978
- if (key === void 0 || key === null || key === "") return;
8979
- if ((_e = this.backend) == null ? void 0 : _e.create) {
8980
- const opts = {
8981
- ...options,
8982
- isUpdate
8983
- };
8984
- const fc = this.backend.create.bind(this.backend);
8985
- if (fc.length < 6) {
8986
- try {
8987
- let r;
8988
- if (fc.length === 5) {
8989
- r = fc(languages, namespace, key, fallbackValue, opts);
8990
- } else {
8991
- r = fc(languages, namespace, key, fallbackValue);
8992
- }
8993
- if (r && typeof r.then === "function") {
8994
- r.then((data) => clb(null, data)).catch(clb);
8995
- } else {
8996
- clb(null, r);
8997
- }
8998
- } catch (err) {
8999
- clb(err);
9000
- }
9001
- } else {
9002
- fc(languages, namespace, key, fallbackValue, clb, opts);
9003
- }
9004
- }
9005
- if (!languages || !languages[0]) return;
9006
- this.store.addResource(languages[0], namespace, key, fallbackValue);
9007
- }
7583
+ function getBaseTemplateReactNode(data, options) {
7584
+ return renderHTMLReact(data, options);
9008
7585
  }
9009
- const get = () => ({
9010
- debug: false,
9011
- initAsync: true,
9012
- ns: ["translation"],
9013
- defaultNS: ["translation"],
9014
- fallbackLng: ["dev"],
9015
- fallbackNS: false,
9016
- supportedLngs: false,
9017
- nonExplicitSupportedLngs: false,
9018
- load: "all",
9019
- preload: false,
9020
- simplifyPluralSuffix: true,
9021
- keySeparator: ".",
9022
- nsSeparator: ":",
9023
- pluralSeparator: "_",
9024
- contextSeparator: "_",
9025
- partialBundledLanguages: false,
9026
- saveMissing: false,
9027
- updateMissing: false,
9028
- saveMissingTo: "fallback",
9029
- saveMissingPlurals: true,
9030
- missingKeyHandler: false,
9031
- missingInterpolationHandler: false,
9032
- postProcess: false,
9033
- postProcessPassResolved: false,
9034
- returnNull: false,
9035
- returnEmptyString: true,
9036
- returnObjects: false,
9037
- joinArrays: false,
9038
- returnedObjectHandler: false,
9039
- parseMissingKeyHandler: false,
9040
- appendNamespaceToMissingKey: false,
9041
- appendNamespaceToCIMode: false,
9042
- overloadTranslationOptionHandler: (args) => {
9043
- let ret = {};
9044
- if (typeof args[1] === "object") ret = args[1];
9045
- if (isString(args[1])) ret.defaultValue = args[1];
9046
- if (isString(args[2])) ret.tDescription = args[2];
9047
- if (typeof args[2] === "object" || typeof args[3] === "object") {
9048
- const options = args[3] || args[2];
9049
- Object.keys(options).forEach((key) => {
9050
- ret[key] = options[key];
9051
- });
9052
- }
9053
- return ret;
9054
- },
9055
- interpolation: {
9056
- escapeValue: true,
9057
- format: (value) => value,
9058
- prefix: "{{",
9059
- suffix: "}}",
9060
- formatSeparator: ",",
9061
- unescapePrefix: "-",
9062
- nestingPrefix: "$t(",
9063
- nestingSuffix: ")",
9064
- nestingOptionsSeparator: ",",
9065
- maxReplaces: 1e3,
9066
- skipOnVariables: true
9067
- },
9068
- cacheInBuiltFormats: true
9069
- });
9070
- const transformOptions = (options) => {
9071
- var _a, _b;
9072
- if (isString(options.ns)) options.ns = [options.ns];
9073
- if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
9074
- if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
9075
- if (((_b = (_a = options.supportedLngs) == null ? void 0 : _a.indexOf) == null ? void 0 : _b.call(_a, "cimode")) < 0) {
9076
- options.supportedLngs = options.supportedLngs.concat(["cimode"]);
9077
- }
9078
- if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
9079
- return options;
9080
- };
9081
- const noop = () => {
9082
- };
9083
- const bindMemberFunctions = (inst) => {
9084
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
9085
- mems.forEach((mem) => {
9086
- if (typeof inst[mem] === "function") {
9087
- inst[mem] = inst[mem].bind(inst);
9088
- }
9089
- });
7586
+ const TEMPLATES_NAMES = {
7587
+ BASE_TEMPLATE: "base-template",
7588
+ INVENTORY_LEVEL: "inventory-level",
7589
+ ORDER_PLACED: "order-placed",
7590
+ ORDER_COMPLETED: "order-completed",
7591
+ CONTACT_FORM: "contact-form"
9090
7592
  };
9091
- class I18n extends EventEmitter {
9092
- constructor(options = {}, callback) {
9093
- super();
9094
- this.options = transformOptions(options);
9095
- this.services = {};
9096
- this.logger = baseLogger;
9097
- this.modules = {
9098
- external: []
9099
- };
9100
- bindMemberFunctions(this);
9101
- if (callback && !this.isInitialized && !options.isClone) {
9102
- if (!this.options.initAsync) {
9103
- this.init(options, callback);
9104
- return this;
9105
- }
9106
- setTimeout(() => {
9107
- this.init(options, callback);
9108
- }, 0);
9109
- }
9110
- }
9111
- init(options = {}, callback) {
9112
- this.isInitializing = true;
9113
- if (typeof options === "function") {
9114
- callback = options;
9115
- options = {};
9116
- }
9117
- if (options.defaultNS == null && options.ns) {
9118
- if (isString(options.ns)) {
9119
- options.defaultNS = options.ns;
9120
- } else if (options.ns.indexOf("translation") < 0) {
9121
- options.defaultNS = options.ns[0];
9122
- }
9123
- }
9124
- const defOpts = get();
9125
- this.options = {
9126
- ...defOpts,
9127
- ...this.options,
9128
- ...transformOptions(options)
9129
- };
9130
- this.options.interpolation = {
9131
- ...defOpts.interpolation,
9132
- ...this.options.interpolation
9133
- };
9134
- if (options.keySeparator !== void 0) {
9135
- this.options.userDefinedKeySeparator = options.keySeparator;
9136
- }
9137
- if (options.nsSeparator !== void 0) {
9138
- this.options.userDefinedNsSeparator = options.nsSeparator;
9139
- }
9140
- const createClassOnDemand = (ClassOrObject) => {
9141
- if (!ClassOrObject) return null;
9142
- if (typeof ClassOrObject === "function") return new ClassOrObject();
9143
- return ClassOrObject;
9144
- };
9145
- if (!this.options.isClone) {
9146
- if (this.modules.logger) {
9147
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
9148
- } else {
9149
- baseLogger.init(null, this.options);
9150
- }
9151
- let formatter;
9152
- if (this.modules.formatter) {
9153
- formatter = this.modules.formatter;
9154
- } else {
9155
- formatter = Formatter;
9156
- }
9157
- const lu = new LanguageUtil(this.options);
9158
- this.store = new ResourceStore(this.options.resources, this.options);
9159
- const s = this.services;
9160
- s.logger = baseLogger;
9161
- s.resourceStore = this.store;
9162
- s.languageUtils = lu;
9163
- s.pluralResolver = new PluralResolver(lu, {
9164
- prepend: this.options.pluralSeparator,
9165
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
9166
- });
9167
- const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
9168
- if (usingLegacyFormatFunction) {
9169
- this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
9170
- }
9171
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
9172
- s.formatter = createClassOnDemand(formatter);
9173
- if (s.formatter.init) s.formatter.init(s, this.options);
9174
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
9175
- }
9176
- s.interpolator = new Interpolator(this.options);
9177
- s.utils = {
9178
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
9179
- };
9180
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
9181
- s.backendConnector.on("*", (event, ...args) => {
9182
- this.emit(event, ...args);
9183
- });
9184
- if (this.modules.languageDetector) {
9185
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
9186
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
9187
- }
9188
- if (this.modules.i18nFormat) {
9189
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
9190
- if (s.i18nFormat.init) s.i18nFormat.init(this);
9191
- }
9192
- this.translator = new Translator(this.services, this.options);
9193
- this.translator.on("*", (event, ...args) => {
9194
- this.emit(event, ...args);
9195
- });
9196
- this.modules.external.forEach((m) => {
9197
- if (m.init) m.init(this);
9198
- });
9199
- }
9200
- this.format = this.options.interpolation.format;
9201
- if (!callback) callback = noop;
9202
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
9203
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9204
- if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
9205
- }
9206
- if (!this.services.languageDetector && !this.options.lng) {
9207
- this.logger.warn("init: no languageDetector is used and no lng is defined");
9208
- }
9209
- const storeApi = ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"];
9210
- storeApi.forEach((fcName) => {
9211
- this[fcName] = (...args) => this.store[fcName](...args);
9212
- });
9213
- const storeApiChained = ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"];
9214
- storeApiChained.forEach((fcName) => {
9215
- this[fcName] = (...args) => {
9216
- this.store[fcName](...args);
9217
- return this;
9218
- };
9219
- });
9220
- const deferred = defer();
9221
- const load = () => {
9222
- const finish = (err, t) => {
9223
- this.isInitializing = false;
9224
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
9225
- this.isInitialized = true;
9226
- if (!this.options.isClone) this.logger.log("initialized", this.options);
9227
- this.emit("initialized", this.options);
9228
- deferred.resolve(t);
9229
- callback(err, t);
9230
- };
9231
- if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
9232
- this.changeLanguage(this.options.lng, finish);
9233
- };
9234
- if (this.options.resources || !this.options.initAsync) {
9235
- load();
9236
- } else {
9237
- setTimeout(load, 0);
9238
- }
9239
- return deferred;
9240
- }
9241
- loadResources(language, callback = noop) {
9242
- var _a, _b;
9243
- let usedCallback = callback;
9244
- const usedLng = isString(language) ? language : this.language;
9245
- if (typeof language === "function") usedCallback = language;
9246
- if (!this.options.resources || this.options.partialBundledLanguages) {
9247
- if ((usedLng == null ? void 0 : usedLng.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
9248
- const toLoad = [];
9249
- const append = (lng) => {
9250
- if (!lng) return;
9251
- if (lng === "cimode") return;
9252
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
9253
- lngs.forEach((l) => {
9254
- if (l === "cimode") return;
9255
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
9256
- });
9257
- };
9258
- if (!usedLng) {
9259
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
9260
- fallbacks.forEach((l) => append(l));
9261
- } else {
9262
- append(usedLng);
9263
- }
9264
- (_b = (_a = this.options.preload) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (l) => append(l));
9265
- this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
9266
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
9267
- usedCallback(e);
9268
- });
9269
- } else {
9270
- usedCallback(null);
9271
- }
9272
- }
9273
- reloadResources(lngs, ns, callback) {
9274
- const deferred = defer();
9275
- if (typeof lngs === "function") {
9276
- callback = lngs;
9277
- lngs = void 0;
9278
- }
9279
- if (typeof ns === "function") {
9280
- callback = ns;
9281
- ns = void 0;
9282
- }
9283
- if (!lngs) lngs = this.languages;
9284
- if (!ns) ns = this.options.ns;
9285
- if (!callback) callback = noop;
9286
- this.services.backendConnector.reload(lngs, ns, (err) => {
9287
- deferred.resolve();
9288
- callback(err);
9289
- });
9290
- return deferred;
9291
- }
9292
- use(module2) {
9293
- if (!module2) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
9294
- if (!module2.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
9295
- if (module2.type === "backend") {
9296
- this.modules.backend = module2;
9297
- }
9298
- if (module2.type === "logger" || module2.log && module2.warn && module2.error) {
9299
- this.modules.logger = module2;
9300
- }
9301
- if (module2.type === "languageDetector") {
9302
- this.modules.languageDetector = module2;
9303
- }
9304
- if (module2.type === "i18nFormat") {
9305
- this.modules.i18nFormat = module2;
9306
- }
9307
- if (module2.type === "postProcessor") {
9308
- postProcessor.addPostProcessor(module2);
9309
- }
9310
- if (module2.type === "formatter") {
9311
- this.modules.formatter = module2;
9312
- }
9313
- if (module2.type === "3rdParty") {
9314
- this.modules.external.push(module2);
9315
- }
9316
- return this;
9317
- }
9318
- setResolvedLanguage(l) {
9319
- if (!l || !this.languages) return;
9320
- if (["cimode", "dev"].indexOf(l) > -1) return;
9321
- for (let li = 0; li < this.languages.length; li++) {
9322
- const lngInLngs = this.languages[li];
9323
- if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
9324
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
9325
- this.resolvedLanguage = lngInLngs;
9326
- break;
9327
- }
9328
- }
9329
- if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
9330
- this.resolvedLanguage = l;
9331
- this.languages.unshift(l);
9332
- }
9333
- }
9334
- changeLanguage(lng, callback) {
9335
- this.isLanguageChangingTo = lng;
9336
- const deferred = defer();
9337
- this.emit("languageChanging", lng);
9338
- const setLngProps = (l) => {
9339
- this.language = l;
9340
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
9341
- this.resolvedLanguage = void 0;
9342
- this.setResolvedLanguage(l);
9343
- };
9344
- const done = (err, l) => {
9345
- if (l) {
9346
- if (this.isLanguageChangingTo === lng) {
9347
- setLngProps(l);
9348
- this.translator.changeLanguage(l);
9349
- this.isLanguageChangingTo = void 0;
9350
- this.emit("languageChanged", l);
9351
- this.logger.log("languageChanged", l);
9352
- }
9353
- } else {
9354
- this.isLanguageChangingTo = void 0;
9355
- }
9356
- deferred.resolve((...args) => this.t(...args));
9357
- if (callback) callback(err, (...args) => this.t(...args));
9358
- };
9359
- const setLng = (lngs) => {
9360
- var _a, _b;
9361
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
9362
- const fl = isString(lngs) ? lngs : lngs && lngs[0];
9363
- const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
9364
- if (l) {
9365
- if (!this.language) {
9366
- setLngProps(l);
9367
- }
9368
- if (!this.translator.language) this.translator.changeLanguage(l);
9369
- (_b = (_a = this.services.languageDetector) == null ? void 0 : _a.cacheUserLanguage) == null ? void 0 : _b.call(_a, l);
9370
- }
9371
- this.loadResources(l, (err) => {
9372
- done(err, l);
9373
- });
9374
- };
9375
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
9376
- setLng(this.services.languageDetector.detect());
9377
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
9378
- if (this.services.languageDetector.detect.length === 0) {
9379
- this.services.languageDetector.detect().then(setLng);
9380
- } else {
9381
- this.services.languageDetector.detect(setLng);
9382
- }
9383
- } else {
9384
- setLng(lng);
9385
- }
9386
- return deferred;
9387
- }
9388
- getFixedT(lng, ns, keyPrefix) {
9389
- const fixedT = (key, opts, ...rest) => {
9390
- let o;
9391
- if (typeof opts !== "object") {
9392
- o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
9393
- } else {
9394
- o = {
9395
- ...opts
9396
- };
9397
- }
9398
- o.lng = o.lng || fixedT.lng;
9399
- o.lngs = o.lngs || fixedT.lngs;
9400
- o.ns = o.ns || fixedT.ns;
9401
- if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
9402
- const keySeparator = this.options.keySeparator || ".";
9403
- let resultKey;
9404
- if (o.keyPrefix && Array.isArray(key)) {
9405
- resultKey = key.map((k) => {
9406
- if (typeof k === "function") k = keysFromSelector(k, {
9407
- ...this.options,
9408
- ...opts
9409
- });
9410
- return `${o.keyPrefix}${keySeparator}${k}`;
9411
- });
9412
- } else {
9413
- if (typeof key === "function") key = keysFromSelector(key, {
9414
- ...this.options,
9415
- ...opts
9416
- });
9417
- resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
9418
- }
9419
- return this.t(resultKey, o);
9420
- };
9421
- if (isString(lng)) {
9422
- fixedT.lng = lng;
9423
- } else {
9424
- fixedT.lngs = lng;
9425
- }
9426
- fixedT.ns = ns;
9427
- fixedT.keyPrefix = keyPrefix;
9428
- return fixedT;
9429
- }
9430
- t(...args) {
9431
- var _a;
9432
- return (_a = this.translator) == null ? void 0 : _a.translate(...args);
9433
- }
9434
- exists(...args) {
9435
- var _a;
9436
- return (_a = this.translator) == null ? void 0 : _a.exists(...args);
9437
- }
9438
- setDefaultNamespace(ns) {
9439
- this.options.defaultNS = ns;
9440
- }
9441
- hasLoadedNamespace(ns, options = {}) {
9442
- if (!this.isInitialized) {
9443
- this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
9444
- return false;
9445
- }
9446
- if (!this.languages || !this.languages.length) {
9447
- this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
9448
- return false;
9449
- }
9450
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
9451
- const fallbackLng = this.options ? this.options.fallbackLng : false;
9452
- const lastLng = this.languages[this.languages.length - 1];
9453
- if (lng.toLowerCase() === "cimode") return true;
9454
- const loadNotPending = (l, n) => {
9455
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
9456
- return loadState === -1 || loadState === 0 || loadState === 2;
9457
- };
9458
- if (options.precheck) {
9459
- const preResult = options.precheck(this, loadNotPending);
9460
- if (preResult !== void 0) return preResult;
9461
- }
9462
- if (this.hasResourceBundle(lng, ns)) return true;
9463
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
9464
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
9465
- return false;
9466
- }
9467
- loadNamespaces(ns, callback) {
9468
- const deferred = defer();
9469
- if (!this.options.ns) {
9470
- if (callback) callback();
9471
- return Promise.resolve();
9472
- }
9473
- if (isString(ns)) ns = [ns];
9474
- ns.forEach((n) => {
9475
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
9476
- });
9477
- this.loadResources((err) => {
9478
- deferred.resolve();
9479
- if (callback) callback(err);
9480
- });
9481
- return deferred;
9482
- }
9483
- loadLanguages(lngs, callback) {
9484
- const deferred = defer();
9485
- if (isString(lngs)) lngs = [lngs];
9486
- const preloaded = this.options.preload || [];
9487
- const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
9488
- if (!newLngs.length) {
9489
- if (callback) callback();
9490
- return Promise.resolve();
9491
- }
9492
- this.options.preload = preloaded.concat(newLngs);
9493
- this.loadResources((err) => {
9494
- deferred.resolve();
9495
- if (callback) callback(err);
9496
- });
9497
- return deferred;
9498
- }
9499
- dir(lng) {
9500
- var _a, _b;
9501
- if (!lng) lng = this.resolvedLanguage || (((_a = this.languages) == null ? void 0 : _a.length) > 0 ? this.languages[0] : this.language);
9502
- if (!lng) return "rtl";
9503
- try {
9504
- const l = new Intl.Locale(lng);
9505
- if (l && l.getTextInfo) {
9506
- const ti = l.getTextInfo();
9507
- if (ti && ti.direction) return ti.direction;
9508
- }
9509
- } catch (e) {
9510
- }
9511
- const rtlLngs = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"];
9512
- const languageUtils = ((_b = this.services) == null ? void 0 : _b.languageUtils) || new LanguageUtil(get());
9513
- if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
9514
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
9515
- }
9516
- static createInstance(options = {}, callback) {
9517
- const instance2 = new I18n(options, callback);
9518
- instance2.createInstance = I18n.createInstance;
9519
- return instance2;
9520
- }
9521
- cloneInstance(options = {}, callback = noop) {
9522
- const forkResourceStore = options.forkResourceStore;
9523
- if (forkResourceStore) delete options.forkResourceStore;
9524
- const mergedOptions = {
9525
- ...this.options,
9526
- ...options,
9527
- ...{
9528
- isClone: true
9529
- }
9530
- };
9531
- const clone = new I18n(mergedOptions);
9532
- if (options.debug !== void 0 || options.prefix !== void 0) {
9533
- clone.logger = clone.logger.clone(options);
9534
- }
9535
- const membersToCopy = ["store", "services", "language"];
9536
- membersToCopy.forEach((m) => {
9537
- clone[m] = this[m];
9538
- });
9539
- clone.services = {
9540
- ...this.services
9541
- };
9542
- clone.services.utils = {
9543
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9544
- };
9545
- if (forkResourceStore) {
9546
- const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
9547
- prev[l] = {
9548
- ...this.store.data[l]
9549
- };
9550
- prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
9551
- acc[n] = {
9552
- ...prev[l][n]
9553
- };
9554
- return acc;
9555
- }, prev[l]);
9556
- return prev;
9557
- }, {});
9558
- clone.store = new ResourceStore(clonedData, mergedOptions);
9559
- clone.services.resourceStore = clone.store;
7593
+ const baseTemplateConfig = {
7594
+ [TEMPLATES_NAMES.BASE_TEMPLATE]: {
7595
+ getHtml: async (data, options) => {
7596
+ return await getBaseTemplateHtml(data, options);
7597
+ },
7598
+ getText: async (data, options) => {
7599
+ return await getBaseTemplateText(data, options);
7600
+ },
7601
+ getReactNode: (data, options) => {
7602
+ return getBaseTemplateReactNode(data, options);
9560
7603
  }
9561
- clone.translator = new Translator(clone.services, mergedOptions);
9562
- clone.translator.on("*", (event, ...args) => {
9563
- clone.emit(event, ...args);
9564
- });
9565
- clone.init(mergedOptions, callback);
9566
- clone.translator.options = mergedOptions;
9567
- clone.translator.backendConnector.services.utils = {
9568
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
9569
- };
9570
- return clone;
9571
7604
  }
9572
- toJSON() {
9573
- return {
9574
- options: this.options,
9575
- store: this.store,
9576
- language: this.language,
9577
- languages: this.languages,
9578
- resolvedLanguage: this.resolvedLanguage
9579
- };
7605
+ };
7606
+ ({
7607
+ [TEMPLATES_NAMES.CONTACT_FORM]: {
7608
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7609
+ },
7610
+ [TEMPLATES_NAMES.ORDER_PLACED]: {
7611
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7612
+ },
7613
+ [TEMPLATES_NAMES.ORDER_COMPLETED]: {
7614
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
7615
+ },
7616
+ [TEMPLATES_NAMES.INVENTORY_LEVEL]: {
7617
+ ...baseTemplateConfig[TEMPLATES_NAMES.BASE_TEMPLATE]
9580
7618
  }
9581
- }
9582
- const instance = I18n.createInstance();
9583
- instance.createInstance;
9584
- instance.dir;
9585
- instance.init;
9586
- instance.loadResources;
9587
- instance.reloadResources;
9588
- instance.use;
9589
- instance.changeLanguage;
9590
- instance.getFixedT;
9591
- instance.t;
9592
- instance.exists;
9593
- instance.setDefaultNamespace;
9594
- instance.hasLoadedNamespace;
9595
- instance.loadNamespaces;
9596
- instance.loadLanguages;
7619
+ });
9597
7620
  const OrderPlacedTemplate = ({ orderId }) => {
9598
- const [templateData, setTemplateData] = React.useState(null);
9599
- const [previewData, setPreviewData] = React.useState(null);
7621
+ const [templateData, setTemplateData] = react.useState(null);
7622
+ const [previewData, setPreviewData] = react.useState(null);
9600
7623
  const { data: order, isLoading: isOrderLoading } = useOrder({
9601
7624
  order_id: orderId,
9602
7625
  enabled: !!orderId
9603
7626
  });
9604
- React.useEffect(() => {
7627
+ react.useEffect(() => {
9605
7628
  var _a, _b;
9606
7629
  if (order == null ? void 0 : order.display_id) {
9607
7630
  const shippingAddressText = getFormattedAddress({ address: order.shipping_address }).join("<br/>");
9608
7631
  const billingAddressText = getFormattedAddress({ address: order.billing_address }).join("<br/>");
9609
7632
  const templateData2 = {
9610
- // subject: `#${order.display_id} - Zamówienie zostało złożone`,
9611
7633
  orderNumber: `#${order.display_id}`,
9612
7634
  customerName: order.email,
9613
7635
  customerEmail: order.email,
@@ -9616,9 +7638,9 @@ const OrderPlacedTemplate = ({ orderId }) => {
9616
7638
  var _a2, _b2, _c;
9617
7639
  return acc + (((_c = (_b2 = (_a2 = item.variant) == null ? void 0 : _a2.prices) == null ? void 0 : _b2[0]) == null ? void 0 : _c.amount) || 0) * item.quantity;
9618
7640
  }, 0),
9619
- currency: order.currency_code,
7641
+ currency_code: order.currency_code,
9620
7642
  items: order.items.map((item) => ({
9621
- thumbnail: item.thumbnail,
7643
+ thumbnail: item.thumbnail == null ? "" : item.thumbnail,
9622
7644
  title: item.title,
9623
7645
  quantity: item.quantity,
9624
7646
  price: getLocaleAmount(item.unit_price, order.currency_code)
@@ -9629,8 +7651,7 @@ const OrderPlacedTemplate = ({ orderId }) => {
9629
7651
  total: getLocaleAmount(order.summary.original_order_total, order.currency_code),
9630
7652
  paid_total: getLocaleAmount(getTotalCaptured(order.payment_collections || []), order.currency_code),
9631
7653
  tax_total: getLocaleAmount(order.tax_total, order.currency_code),
9632
- discount_total: getLocaleAmount(order.discount_total, order.currency_code),
9633
- currency: order.currency_code
7654
+ discount_total: getLocaleAmount(order.discount_total, order.currency_code)
9634
7655
  },
9635
7656
  sales_channel: {
9636
7657
  name: (_a = order == null ? void 0 : order.sales_channel) == null ? void 0 : _a.name,
@@ -9648,12 +7669,12 @@ const OrderPlacedTemplate = ({ orderId }) => {
9648
7669
  enabled: !!templateData,
9649
7670
  extraKey: [templateData, orderId]
9650
7671
  });
9651
- React.useEffect(() => {
7672
+ react.useEffect(() => {
9652
7673
  if (isOrderLoading) {
9653
7674
  setPreviewData(null);
9654
7675
  }
9655
7676
  }, [isOrderLoading]);
9656
- React.useEffect(() => {
7677
+ react.useEffect(() => {
9657
7678
  if (preview) {
9658
7679
  setPreviewData(preview);
9659
7680
  }
@@ -9676,7 +7697,7 @@ const OrderPlacedTemplate = ({ orderId }) => {
9676
7697
  };
9677
7698
  const OrderTemplateGroup = () => {
9678
7699
  var _a;
9679
- const [selectedOrder, setSelectedOrder] = React.useState("");
7700
+ const [selectedOrder, setSelectedOrder] = react.useState("");
9680
7701
  const { data: orders, isLoading: isOrdersLoading } = useOrders({
9681
7702
  fields: "id,display_id",
9682
7703
  enabled: true
@@ -9710,9 +7731,9 @@ const contactFormMockData = {
9710
7731
  message: "Test messages"
9711
7732
  };
9712
7733
  const ContactFormTemplate = () => {
9713
- const [templateData, setTemplateData] = React.useState(null);
9714
- const [previewData, setPreviewData] = React.useState(null);
9715
- React.useEffect(() => {
7734
+ const [templateData, setTemplateData] = react.useState(null);
7735
+ const [previewData, setPreviewData] = react.useState(null);
7736
+ react.useEffect(() => {
9716
7737
  setTemplateData(contactFormMockData);
9717
7738
  }, []);
9718
7739
  const { data: preview, isLoading: isPreviewLoading } = usePreview({
@@ -9722,7 +7743,7 @@ const ContactFormTemplate = () => {
9722
7743
  enabled: !!templateData,
9723
7744
  extraKey: [templateData]
9724
7745
  });
9725
- React.useEffect(() => {
7746
+ react.useEffect(() => {
9726
7747
  if (preview) {
9727
7748
  setPreviewData(preview);
9728
7749
  }
@@ -9744,7 +7765,7 @@ const ContactFormTemplateGroup = () => {
9744
7765
  };
9745
7766
  const PreviewTemplatePage = () => {
9746
7767
  const templateName = "";
9747
- const [selectedTemplate, setSelectedTemplate] = React.useState(templateName);
7768
+ const [selectedTemplate, setSelectedTemplate] = react.useState(templateName);
9748
7769
  const templates = [
9749
7770
  { label: "Contact Form", value: TEMPLATES_NAMES.CONTACT_FORM },
9750
7771
  { label: "Order", value: "order" }