@enerex/template-studio 1.1.40 → 1.1.43

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.
@@ -1,123 +1,123 @@
1
- import { jsx as t, jsxs as d, Fragment as pe } from "react/jsx-runtime";
2
- import W, { useContext as Se, useEffect as P, useState as N, useRef as Z, useCallback as Ee, createContext as Fe, memo as je, useMemo as se } from "react";
3
- import { QueryClient as qe, QueryClientProvider as Ue, useQuery as fe, useMutation as oe, useQueryClient as Ve } from "@tanstack/react-query";
4
- import be from "axios";
5
- import { Spinner as He } from "react-bootstrap";
6
- import { Controller as Ke, useForm as Ge } from "react-hook-form";
7
- import Ie, { components as Le } from "react-select";
8
- const De = W.createContext(
1
+ import { jsx as t, jsxs as d, Fragment as ye } from "react/jsx-runtime";
2
+ import G, { useContext as ke, useEffect as L, useState as C, useRef as te, useCallback as Se, createContext as He, memo as ze, useMemo as ae } from "react";
3
+ import { QueryClient as Ge, QueryClientProvider as We, useQuery as ge, useMutation as ce, useQueryClient as Ye } from "@tanstack/react-query";
4
+ import we from "axios";
5
+ import { Spinner as Qe } from "react-bootstrap";
6
+ import { Controller as Xe, useForm as Je } from "react-hook-form";
7
+ import $e, { components as Ae } from "react-select";
8
+ const Fe = G.createContext(
9
9
  void 0
10
- ), We = ({
10
+ ), Ze = ({
11
11
  children: e,
12
12
  configs: n
13
13
  }) => {
14
- const [s, a] = W.useState(n.clientId), [i, r] = W.useState(n.apiKey), [l, c] = W.useState(
14
+ const [r, a] = G.useState(n.clientId), [i, s] = G.useState(n.apiKey), [l, o] = G.useState(
15
15
  n.enerexIdentifier
16
- ), [o, w] = W.useState(n.projectId), [f, C] = W.useState(n.userEmail), [g, S] = W.useState(n.isAdmin), [A, h] = W.useState(n.meBaseUrl), [y, b] = W.useState(
16
+ ), [c, v] = G.useState(n.projectId), [E, I] = G.useState(n.userEmail), [b, x] = G.useState(n.isAdmin), [u, p] = G.useState(n.meBaseUrl), [w, h] = G.useState(
17
17
  n.defaultSelector
18
- ), m = (v) => {
19
- r(v.apiKey), a(v.clientId), w(v.projectId), c(v.enerexIdentifier), C(v.userEmail), S(v.isAdmin), b(v.defaultSelector), h(v.meBaseUrl);
18
+ ), y = (g) => {
19
+ s(g.apiKey), a(g.clientId), v(g.projectId), o(g.enerexIdentifier), I(g.userEmail), x(g.isAdmin), h(g.defaultSelector), p(g.meBaseUrl);
20
20
  };
21
21
  return /* @__PURE__ */ t(
22
- De.Provider,
22
+ Fe.Provider,
23
23
  {
24
24
  value: {
25
- clientId: s,
25
+ clientId: r,
26
26
  apiKey: i,
27
- setConfiguration: m,
27
+ setConfiguration: y,
28
28
  enerexIdentifier: l,
29
- projectId: o,
30
- userEmail: f,
31
- isAdmin: g,
32
- defaultSelector: y,
33
- meBaseUrl: A
29
+ projectId: c,
30
+ userEmail: E,
31
+ isAdmin: b,
32
+ defaultSelector: w,
33
+ meBaseUrl: u
34
34
  },
35
35
  children: e
36
36
  }
37
37
  );
38
- }, H = () => {
39
- const e = Se(De);
38
+ }, V = () => {
39
+ const e = ke(Fe);
40
40
  if (!e)
41
41
  throw new Error("widgetConfig must be used within a ConfigProvider");
42
42
  return e;
43
- }, ze = ({
43
+ }, et = ({
44
44
  message: e,
45
45
  type: n = "info",
46
- duration: s = 3e3,
46
+ duration: r = 3e3,
47
47
  onClose: a
48
- }) => (P(() => {
49
- const i = setTimeout(a, s);
48
+ }) => (L(() => {
49
+ const i = setTimeout(a, r);
50
50
  return () => clearTimeout(i);
51
- }, [s, a]), /* @__PURE__ */ d("div", { className: `ts-toast ts-toast-${n}`, children: [
51
+ }, [r, a]), /* @__PURE__ */ d("div", { className: `ts-toast ts-toast-${n}`, children: [
52
52
  /* @__PURE__ */ t("span", { className: "ts-toast-message", children: e }),
53
53
  /* @__PURE__ */ t("button", { className: "ts-toast-close", onClick: a, children: "×" })
54
- ] })), Qe = () => {
55
- const [e, n] = N(null), s = Z(null);
56
- return { showNotification: Ee(
57
- (r, l = "info") => {
58
- s.current !== r && (s.current = r, n({ message: r, type: l }));
54
+ ] })), tt = () => {
55
+ const [e, n] = C(null), r = te(null);
56
+ return { showNotification: Se(
57
+ (s, l = "info") => {
58
+ r.current !== s && (r.current = s, n({ message: s, type: l }));
59
59
  },
60
60
  []
61
61
  ), NotificationRenderer: () => e ? /* @__PURE__ */ t(
62
- ze,
62
+ et,
63
63
  {
64
64
  message: e.message,
65
65
  type: e.type,
66
66
  onClose: () => {
67
- s.current = null, n(null);
67
+ r.current = null, n(null);
68
68
  }
69
69
  }
70
70
  ) : null };
71
- }, Me = Fe(null), Xe = ({
71
+ }, Oe = He(null), nt = ({
72
72
  children: e
73
73
  }) => {
74
- const n = Qe();
75
- return /* @__PURE__ */ d(Me.Provider, { value: n, children: [
74
+ const n = tt();
75
+ return /* @__PURE__ */ d(Oe.Provider, { value: n, children: [
76
76
  e,
77
77
  /* @__PURE__ */ t(n.NotificationRenderer, {})
78
78
  ] });
79
- }, Re = () => {
80
- const e = Se(Me);
79
+ }, ve = () => {
80
+ const e = ke(Oe);
81
81
  if (!e)
82
82
  throw new Error(
83
83
  "useGlobalNotification must be used within NotificationProvider"
84
84
  );
85
85
  return e;
86
- }, Oe = (e = "", n) => ({ get: async (r, l) => {
86
+ }, je = (e = "", n) => ({ get: async (s, l) => {
87
87
  try {
88
- const c = await be.get(
89
- `${e}${r}`,
88
+ const o = await we.get(
89
+ `${e}${s}`,
90
90
  l ?? n
91
91
  );
92
- if (c.status === 200)
93
- return c.data;
94
- } catch (c) {
95
- throw c;
96
- }
97
- }, post: async (r, l, c) => {
98
- try {
99
- const o = await be.post(
100
- `${e}${r}`,
101
- l,
102
- c ?? n
103
- );
104
92
  if (o.status === 200)
105
93
  return o.data;
106
94
  } catch (o) {
107
95
  throw o;
108
96
  }
109
- }, delete: async (r, l) => {
97
+ }, post: async (s, l, o) => {
110
98
  try {
111
- const c = await be.delete(
112
- `${e}${r}`,
113
- l ?? n
99
+ const c = await we.post(
100
+ `${e}${s}`,
101
+ l,
102
+ o ?? n
114
103
  );
115
- if (c.status === 200 || c.status === 204)
104
+ if (c.status === 200)
116
105
  return c.data;
117
106
  } catch (c) {
118
107
  throw c;
119
108
  }
120
- } }), Be = W.createContext({
109
+ }, delete: async (s, l) => {
110
+ try {
111
+ const o = await we.delete(
112
+ `${e}${s}`,
113
+ l ?? n
114
+ );
115
+ if (o.status === 200 || o.status === 204)
116
+ return o.data;
117
+ } catch (o) {
118
+ throw o;
119
+ }
120
+ } }), qe = G.createContext({
121
121
  get: () => {
122
122
  throw new Error("HttpClientContext.get not implemented");
123
123
  },
@@ -127,20 +127,20 @@ const De = W.createContext(
127
127
  delete: () => {
128
128
  throw new Error("HttpClientContext.delete not implemented");
129
129
  }
130
- }), Ye = ({ children: e }) => {
131
- const { clientId: n, apiKey: s, isAdmin: a, meBaseUrl: i } = H(), r = {
130
+ }), rt = ({ children: e }) => {
131
+ const { clientId: n, apiKey: r, isAdmin: a, meBaseUrl: i } = V(), s = {
132
132
  headers: {
133
133
  client_id: n,
134
- "x-api-key": s,
134
+ "x-api-key": r,
135
135
  "Security-Context": a ? "admin" : "viewer"
136
136
  }
137
- }, { get: l, post: c, delete: o } = Oe(i, r);
138
- return /* @__PURE__ */ t(Be.Provider, { value: { get: l, post: c, delete: o }, children: e });
139
- }, Je = ({ children: e }) => {
140
- const n = new qe();
141
- return /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(Ue, { client: n, children: e }) });
142
- }, z = () => {
143
- const e = Se(Be);
137
+ }, { get: l, post: o, delete: c } = je(i, s);
138
+ return /* @__PURE__ */ t(qe.Provider, { value: { get: l, post: o, delete: c }, children: e });
139
+ }, st = ({ children: e }) => {
140
+ const n = new Ge();
141
+ return /* @__PURE__ */ t(rt, { children: /* @__PURE__ */ t(We, { client: n, children: e }) });
142
+ }, Y = () => {
143
+ const e = ke(qe);
144
144
  if (e)
145
145
  return e;
146
146
  throw new Error("useHttpClient must be used within a HttpClientProvider");
@@ -154,111 +154,257 @@ const De = W.createContext(
154
154
  markFavourite: "/Template/MarkFavourite/",
155
155
  deleteTemplate: "/Template/DeleteTemplate/",
156
156
  duplicateTemplate: "/Template/DuplicateTemplate/"
157
- }, Ze = () => {
158
- const e = z(), { enerexIdentifier: n, projectId: s } = H();
159
- return fe({
157
+ }, at = () => {
158
+ const e = Y(), { enerexIdentifier: n, projectId: r } = V();
159
+ return ge({
160
160
  queryKey: ["getTemplatesList"],
161
161
  queryFn: async (i) => await e.get(
162
- `${Q.Template_list}${s}/${n}`
162
+ `${Q.Template_list}${r}/${n}`
163
163
  ),
164
164
  refetchOnWindowFocus: !1,
165
165
  refetchOnReconnect: !1,
166
166
  refetchOnMount: !1
167
167
  });
168
- }, et = () => {
169
- const e = z(), { enerexIdentifier: n, projectId: s } = H();
170
- return fe({
168
+ }, it = () => {
169
+ const e = Y(), { enerexIdentifier: n, projectId: r } = V();
170
+ return ge({
171
171
  queryKey: ["getTemplateTypes"],
172
172
  queryFn: async (i) => await e.get(
173
- `${Q.TemplateTypes}${n}/${s}`
173
+ `${Q.TemplateTypes}${n}/${r}`
174
174
  ),
175
175
  refetchOnWindowFocus: !1,
176
176
  refetchOnReconnect: !1,
177
177
  refetchOnMount: !1
178
178
  });
179
- }, tt = () => {
180
- const e = z(), { enerexIdentifier: n, projectId: s } = H();
181
- return oe({
179
+ }, lt = () => {
180
+ const e = Y(), { enerexIdentifier: n, projectId: r } = V();
181
+ return ce({
182
182
  mutationKey: ["getTemplate"],
183
183
  mutationFn: async ({ id: i }) => {
184
184
  if (i)
185
185
  return await e.get(
186
- `${Q.Template}${n}/${i}/${s}`
186
+ `${Q.Template}${n}/${i}/${r}`
187
187
  );
188
188
  }
189
189
  });
190
- }, ae = ({
190
+ }, ie = ({
191
191
  size: e = "md",
192
192
  center: n = !1,
193
- overlay: s = !1
193
+ overlay: r = !1
194
194
  }) => {
195
195
  const a = /* @__PURE__ */ t("div", { className: `ts-loader ts-loader-${e}` });
196
- return s ? /* @__PURE__ */ t("div", { className: "ts-loader-overlay", children: a }) : n ? /* @__PURE__ */ t("div", { className: "ts-loader-center", children: a }) : a;
196
+ return r ? /* @__PURE__ */ t("div", { className: "ts-loader-overlay", children: a }) : n ? /* @__PURE__ */ t("div", { className: "ts-loader-center", children: a }) : a;
197
+ }, Ue = () => {
198
+ const e = Y(), { enerexIdentifier: n, projectId: r } = V();
199
+ return ce({
200
+ mutationKey: ["markFavourite"],
201
+ mutationFn: async (i) => await e.post(
202
+ `${Q.markFavourite}${r}/${n}`,
203
+ i
204
+ )
205
+ });
206
+ }, Le = (e) => {
207
+ let n = /* @__PURE__ */ t(
208
+ "span",
209
+ {
210
+ style: { width: "20px", height: "20px", display: "inline-block" }
211
+ }
212
+ );
213
+ return e.variant === "filled" ? n = /* @__PURE__ */ t(
214
+ "svg",
215
+ {
216
+ version: "1.0",
217
+ id: "Layer_1",
218
+ xmlns: "http://www.w3.org/2000/svg",
219
+ width: "18px",
220
+ height: "18px",
221
+ viewBox: "0 0 64 64",
222
+ "enable-background": "new 0 0 64 64",
223
+ children: /* @__PURE__ */ t(
224
+ "path",
225
+ {
226
+ fill: "#2196F3",
227
+ d: `M63.893,24.277c-0.238-0.711-0.854-1.229-1.595-1.343l-19.674-3.006L33.809,1.15\r
228
+ C33.479,0.448,32.773,0,31.998,0s-1.48,0.448-1.811,1.15l-8.815,18.778L1.698,22.935c-0.741,0.113-1.356,0.632-1.595,1.343\r
229
+ c-0.238,0.71-0.059,1.494,0.465,2.031l14.294,14.657L11.484,61.67c-0.124,0.756,0.195,1.517,0.822,1.957\r
230
+ c0.344,0.243,0.747,0.366,1.151,0.366c0.332,0,0.666-0.084,0.968-0.25l17.572-9.719l17.572,9.719c0.302,0.166,0.636,0.25,0.968,0.25\r
231
+ c0.404,0,0.808-0.123,1.151-0.366c0.627-0.44,0.946-1.201,0.822-1.957l-3.378-20.704l14.294-14.657\r
232
+ C63.951,25.771,64.131,24.987,63.893,24.277z`
233
+ }
234
+ )
235
+ }
236
+ ) : e.variant === "outlined" && (n = /* @__PURE__ */ t(
237
+ "svg",
238
+ {
239
+ version: "1.0",
240
+ id: "Layer_1",
241
+ xmlns: "http://www.w3.org/2000/svg",
242
+ width: "18px",
243
+ height: "18px",
244
+ viewBox: "0 0 64 64",
245
+ enableBackground: "new 0 0 64 64",
246
+ children: /* @__PURE__ */ t(
247
+ "path",
248
+ {
249
+ fill: e.fill || "rgba(247, 216, 40, 0)",
250
+ stroke: e.stroke || "#000000",
251
+ strokeWidth: e.strokeWidth || "2",
252
+ d: `M63.893,24.277c-0.238-0.711-0.854-1.229-1.595-1.343l-19.674-3.006L33.809,1.15\r
253
+ C33.479,0.448,32.773,0,31.998,0s-1.48,0.448-1.811,1.15l-8.815,18.778L1.698,22.935c-0.741,0.113-1.356,0.632-1.595,1.343\r
254
+ c-0.238,0.71-0.059,1.494,0.465,2.031l14.294,14.657L11.484,61.67c-0.124,0.756,0.195,1.517,0.822,1.957\r
255
+ c0.344,0.243,0.747,0.366,1.151,0.366c0.332,0,0.666-0.084,0.968-0.25l17.572-9.719l17.572,9.719c0.302,0.166,0.636,0.25,0.968,0.25\r
256
+ c0.404,0,0.808-0.123,1.151-0.366c0.627-0.44,0.946-1.201,0.822-1.957l-3.378-20.704l14.294-14.657\r
257
+ C63.951,25.771,64.131,24.987,63.893,24.277z`
258
+ }
259
+ )
260
+ }
261
+ )), n;
197
262
  };
198
- function nt({
263
+ function Te(e) {
264
+ return e.sort((n, r) => n.name.localeCompare(r.name));
265
+ }
266
+ function ot(e) {
267
+ const n = /* @__PURE__ */ new Map(), r = [];
268
+ e.forEach((s) => n.set(s.id, s));
269
+ let a = e.filter((s) => s.parent_id === 0), i = 0;
270
+ for (; a.length > 0; ) {
271
+ r.push({ level: i, data: a });
272
+ const s = a.map((o) => o.id);
273
+ a = e.filter(
274
+ (o) => s.includes(o.parent_id)
275
+ ), i++;
276
+ }
277
+ return r;
278
+ }
279
+ function Ne(e, n) {
280
+ const a = ot(e).find((i) => i.level === n);
281
+ return a ? a.data : [];
282
+ }
283
+ const ct = (e) => {
284
+ if (!e) return "";
285
+ const n = new Date(e);
286
+ if (isNaN(n.getTime())) return "";
287
+ const r = String(n.getMonth() + 1).padStart(2, "0"), a = String(n.getDate()).padStart(2, "0"), i = String(n.getFullYear()).slice(-2);
288
+ return `${r}/${a}/${i}`;
289
+ }, dt = (e) => /* @__PURE__ */ t(
290
+ "svg",
291
+ {
292
+ "aria-hidden": "true",
293
+ focusable: "false",
294
+ role: "img",
295
+ xmlns: "http://www.w3.org/2000/svg",
296
+ viewBox: "0 0 128 512",
297
+ height: "11px",
298
+ width: "14px",
299
+ ...e,
300
+ children: /* @__PURE__ */ t(
301
+ "path",
302
+ {
303
+ fill: "#6c757d",
304
+ d: "M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"
305
+ }
306
+ )
307
+ }
308
+ );
309
+ function ut({
199
310
  template: e,
200
311
  openActionId: n,
201
- setOpenActionId: s,
312
+ setOpenActionId: r,
202
313
  onEdit: a,
203
314
  onDuplicate: i,
204
- onRemove: r,
205
- onPreview: l
315
+ onRemove: s,
316
+ onPreview: l,
317
+ onRefresh: o
206
318
  }) {
207
- const { isAdmin: c } = H(), o = n === e.id, w = Z(null), f = Z(null), [C, g, S] = e.categoryChain, A = C?.key, h = g?.key, y = S?.key, b = A === 28 || h === 9 && y === 3 || y === 2, m = c || h === 9 && y === 3, v = c || h === 9 && y === 3;
208
- return P(() => {
209
- function x(T) {
210
- o && w.current && !w.current.contains(T.target) && !f.current?.contains(T.target) && s(null);
319
+ const { isAdmin: c } = V(), v = n === e.id, E = te(null), I = te(null), [b, x, u] = e.categoryChain, { mutateAsync: p, isPending: w } = Ue(), { showNotification: h } = ve(), y = x?.key, g = u?.key, R = !c && y === 9, B = c || g !== 2, _ = c || g !== 2;
320
+ L(() => {
321
+ function S(D) {
322
+ v && E.current && !E.current.contains(D.target) && !I.current?.contains(D.target) && r(null);
211
323
  }
212
- return document.addEventListener("mousedown", x), () => document.removeEventListener("mousedown", x);
213
- }, [o, s]), P(() => {
214
- function x(T) {
215
- T.key === "Escape" && s(null);
324
+ return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
325
+ }, [v, r]), L(() => {
326
+ function S(D) {
327
+ D.key === "Escape" && r(null);
216
328
  }
217
- return o && document.addEventListener("keydown", x), () => document.removeEventListener("keydown", x);
218
- }, [o, s]), P(() => {
219
- if (!o || !w.current) return;
220
- const x = Array.from(
221
- w.current.querySelectorAll('[role="menuitem"]')
329
+ return v && document.addEventListener("keydown", S), () => document.removeEventListener("keydown", S);
330
+ }, [v, r]), L(() => {
331
+ if (!v || !E.current) return;
332
+ const S = Array.from(
333
+ E.current.querySelectorAll('[role="menuitem"]')
222
334
  );
223
- if (!x.length) return;
224
- let T = 0;
225
- x[0].focus();
226
- function k(O) {
227
- O.key === "ArrowDown" && (T = (T + 1) % x.length, x[T].focus(), O.preventDefault()), O.key === "ArrowUp" && (T = (T - 1 + x.length) % x.length, x[T].focus(), O.preventDefault());
335
+ if (!S.length) return;
336
+ let D = 0;
337
+ S[0].focus();
338
+ function M(T) {
339
+ T.key === "ArrowDown" && (D = (D + 1) % S.length, S[D].focus(), T.preventDefault()), T.key === "ArrowUp" && (D = (D - 1 + S.length) % S.length, S[D].focus(), T.preventDefault());
228
340
  }
229
- return document.addEventListener("keydown", k), () => document.removeEventListener("keydown", k);
230
- }, [o]), /* @__PURE__ */ t(pe, { children: /* @__PURE__ */ d("tr", { className: "ts-table-row", children: [
231
- /* @__PURE__ */ t("td", { children: /* @__PURE__ */ d("div", { className: "ts-name-cell", children: [
232
- /* @__PURE__ */ t(
233
- "span",
234
- {
235
- className: e.readonly ? "ts-badge default" : "ts-badge custom",
236
- children: e.readonly ? "Default" : "Custom"
237
- }
238
- ),
239
- /* @__PURE__ */ t("span", { children: e.name })
240
- ] }) }),
241
- /* @__PURE__ */ t("td", { children: C?.name ?? "" }),
242
- /* @__PURE__ */ t("td", { children: g?.name ?? "" }),
243
- /* @__PURE__ */ t("td", { children: S?.name ?? "" }),
341
+ return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
342
+ }, [v]);
343
+ const A = async () => {
344
+ try {
345
+ await p({
346
+ categoryId: g?.toString() ?? "",
347
+ templateId: e.id ?? ""
348
+ }), o(), h(
349
+ `Template "${e?.name}" marked as favourite`,
350
+ "success"
351
+ );
352
+ } catch (S) {
353
+ console.error(S), h(
354
+ "Unable to mark template as favourite. Please try again.",
355
+ "error"
356
+ );
357
+ }
358
+ };
359
+ return /* @__PURE__ */ t(ye, { children: /* @__PURE__ */ d("tr", { className: "ts-table-row", children: [
360
+ /* @__PURE__ */ d("td", { children: [
361
+ " ",
362
+ /* @__PURE__ */ d("div", { className: "ts-name-cell", children: [
363
+ R && /* @__PURE__ */ t(
364
+ "button",
365
+ {
366
+ type: "button",
367
+ className: "ts-fav-btn ts-btn-light",
368
+ disabled: e.is_favourite,
369
+ onClick: A,
370
+ title: "Mark as favourite",
371
+ children: w ? /* @__PURE__ */ t(ie, { size: "sm" }) : e.is_favourite ? /* @__PURE__ */ t(Le, { variant: "filled" }) : /* @__PURE__ */ t(Le, { variant: "outlined" })
372
+ }
373
+ ),
374
+ /* @__PURE__ */ t(
375
+ "span",
376
+ {
377
+ className: e.readonly ? "ts-badge default" : "ts-badge custom",
378
+ children: e.readonly ? "Default" : "Custom"
379
+ }
380
+ )
381
+ ] })
382
+ ] }),
383
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t("span", { className: "ts-template-name", children: e.name }) }) }),
384
+ c && /* @__PURE__ */ t("td", { children: e?.id ?? "" }),
385
+ /* @__PURE__ */ t("td", { children: b?.name ?? "" }),
386
+ /* @__PURE__ */ t("td", { children: x?.name ?? "" }),
387
+ /* @__PURE__ */ t("td", { children: u?.name ?? "" }),
388
+ c && /* @__PURE__ */ t("td", { children: e?.companyName ?? "" }),
244
389
  /* @__PURE__ */ t("td", { children: e?.updatedByName ?? "" }),
390
+ /* @__PURE__ */ t("td", { children: ct(e.updatedDateTime) }),
245
391
  /* @__PURE__ */ t("td", { className: "ts-actions-cell", children: /* @__PURE__ */ d("div", { className: "ts-actions-wrapper", children: [
246
392
  /* @__PURE__ */ t(
247
393
  "button",
248
394
  {
249
- ref: f,
395
+ ref: I,
250
396
  className: "ts-actions-btn",
251
397
  "aria-haspopup": "true",
252
- "aria-expanded": o,
253
- onClick: () => s(o ? null : e.id),
254
- children: "⋯"
398
+ "aria-expanded": v,
399
+ onClick: () => r(v ? null : e.id),
400
+ children: /* @__PURE__ */ t(dt, {})
255
401
  }
256
402
  ),
257
403
  /* @__PURE__ */ d(
258
404
  "div",
259
405
  {
260
- ref: w,
261
- className: `ts-actions-menu ${o ? "open" : ""}`,
406
+ ref: E,
407
+ className: `ts-actions-menu ${v ? "open" : ""}`,
262
408
  role: "menu",
263
409
  children: [
264
410
  /* @__PURE__ */ t(
@@ -268,43 +414,43 @@ function nt({
268
414
  role: "menuitem",
269
415
  className: "ts-menu-item",
270
416
  onClick: () => {
271
- s(null), l(e);
417
+ r(null), l(e);
272
418
  },
273
419
  children: "Preview"
274
420
  }
275
421
  ),
276
- m && /* @__PURE__ */ t(
422
+ B && /* @__PURE__ */ t(
277
423
  "button",
278
424
  {
279
425
  type: "button",
280
426
  role: "menuitem",
281
427
  className: "ts-menu-item",
282
428
  onClick: () => {
283
- s(null), a(e);
429
+ r(null), a(e);
284
430
  },
285
431
  children: "Edit"
286
432
  }
287
433
  ),
288
- b && /* @__PURE__ */ t(
434
+ /* @__PURE__ */ t(
289
435
  "button",
290
436
  {
291
437
  type: "button",
292
438
  role: "menuitem",
293
439
  className: "ts-menu-item",
294
440
  onClick: () => {
295
- s(null), i(e);
441
+ r(null), i(e);
296
442
  },
297
443
  children: "Duplicate"
298
444
  }
299
445
  ),
300
- v && /* @__PURE__ */ t(
446
+ _ && /* @__PURE__ */ t(
301
447
  "button",
302
448
  {
303
449
  type: "button",
304
450
  role: "menuitem",
305
451
  className: "ts-menu-item danger",
306
452
  onClick: () => {
307
- s(null), r(e);
453
+ r(null), s(e);
308
454
  },
309
455
  children: "Remove"
310
456
  }
@@ -315,139 +461,209 @@ function nt({
315
461
  ] }) })
316
462
  ] }) });
317
463
  }
318
- const rt = je(nt), ve = 5, st = ({
464
+ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
465
+ "svg",
466
+ {
467
+ xmlns: "http://www.w3.org/2000/svg",
468
+ viewBox: "0 0 320 512",
469
+ width: "6.01px",
470
+ height: "9.63px",
471
+ ...e,
472
+ children: /* @__PURE__ */ t(
473
+ "path",
474
+ {
475
+ fill: e.fill || "#6c757d",
476
+ d: "M182.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-128 128c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8H288c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-128-128z"
477
+ }
478
+ )
479
+ }
480
+ ), ft = (e) => /* @__PURE__ */ t(
481
+ "svg",
482
+ {
483
+ xmlns: "http://www.w3.org/2000/svg",
484
+ viewBox: "0 0 320 512",
485
+ width: "6.01px",
486
+ height: "9.63px",
487
+ ...e,
488
+ children: /* @__PURE__ */ t(
489
+ "path",
490
+ {
491
+ fill: e.fill || "#6c757d",
492
+ d: "M182.6 470.6c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-9.2-9.2-11.9-22.9-6.9-34.9s16.6-19.8 29.6-19.8H288c12.9 0 24.6 7.8 29.6 19.8s2.2 25.7-6.9 34.9l-128 128z"
493
+ }
494
+ )
495
+ }
496
+ ), J = ({
497
+ label: e,
498
+ sortKey: n,
499
+ sortBy: r,
500
+ sortOrder: a,
501
+ onSort: i
502
+ }) => /* @__PURE__ */ t("th", { onClick: () => i(n), className: "ts-sortable", children: /* @__PURE__ */ d("div", { className: "ts-th-sort", children: [
503
+ e,
504
+ /* @__PURE__ */ d("div", { className: "ts-sort-icons", children: [
505
+ /* @__PURE__ */ t(
506
+ pt,
507
+ {
508
+ fill: r === n && a === "asc" ? "#007bff" : "#6c757d",
509
+ className: r === n && a === "asc" ? "active" : ""
510
+ }
511
+ ),
512
+ /* @__PURE__ */ t(
513
+ ft,
514
+ {
515
+ style: { marginTop: -9.6 },
516
+ fill: r === n && a === "desc" ? "#007bff" : "#6c757d",
517
+ className: r === n && a === "desc" ? "active" : ""
518
+ }
519
+ )
520
+ ] })
521
+ ] }) }), Ce = 5, ht = ({
319
522
  page: e,
320
523
  pageSize: n,
321
- totalRecords: s,
524
+ totalRecords: r,
322
525
  onPageChange: a,
323
526
  onPageSizeChange: i
324
527
  }) => {
325
- const r = Math.ceil(s / n), c = r <= ve ? Array.from({ length: r }, (f, C) => C + 1) : Array.from({ length: ve }, (f, C) => C + 1), o = r > ve, w = r;
528
+ const s = Math.ceil(r / n), o = s <= Ce ? Array.from({ length: s }, (u, p) => p + 1) : Array.from({ length: Ce }, (u, p) => p + 1), c = s > Ce, v = s, { showNotification: E } = ve(), [I, b] = C(String(e));
529
+ L(() => {
530
+ b(String(e));
531
+ }, [e]);
532
+ const x = () => {
533
+ const u = Number(I);
534
+ if (!u || u < 1 || u > s) {
535
+ E("Page out of range", "error"), b(String(e));
536
+ return;
537
+ }
538
+ a(u);
539
+ };
326
540
  return /* @__PURE__ */ d("div", { className: "ts-pagination-bar", children: [
327
541
  /* @__PURE__ */ d("div", { className: "ts-page-container", children: [
328
542
  /* @__PURE__ */ d("div", { className: "ts-page-size", children: [
329
- "Display:",
543
+ /* @__PURE__ */ t("label", { children: "Display:" }),
330
544
  /* @__PURE__ */ t(
331
545
  "select",
332
546
  {
333
547
  value: n,
334
- onChange: (f) => {
335
- i(Number(f.target.value)), a(1);
548
+ onChange: (u) => {
549
+ i(Number(u.target.value)), a(1);
336
550
  },
337
- children: [10, 25, 50, 100].map((f) => /* @__PURE__ */ t("option", { value: f, children: f }, f))
551
+ children: [10, 25, 50, 100].map((u) => /* @__PURE__ */ t("option", { value: u, children: u }, u))
338
552
  }
339
553
  )
340
554
  ] }),
341
555
  /* @__PURE__ */ d("div", { className: "ts-page-info", children: [
342
556
  "Page ",
343
- e,
344
- " of ",
345
- r
557
+ /* @__PURE__ */ d("span", { children: [
558
+ e,
559
+ " of ",
560
+ s
561
+ ] })
346
562
  ] }),
347
563
  /* @__PURE__ */ d("div", { className: "ts-go-to", children: [
348
- "Go to page:",
564
+ /* @__PURE__ */ t("span", { children: "Go to page:" }),
349
565
  /* @__PURE__ */ t(
350
566
  "input",
351
567
  {
352
568
  type: "number",
353
- min: 1,
354
- max: r,
355
- value: e,
356
- onChange: (f) => {
357
- const C = Number(f.target.value);
358
- C >= 1 && C <= r && a(C);
569
+ value: I,
570
+ onChange: (u) => b(u.target.value),
571
+ onBlur: x,
572
+ onKeyDown: (u) => {
573
+ u.key === "Enter" && x();
359
574
  }
360
575
  }
361
576
  )
362
577
  ] })
363
578
  ] }),
364
579
  /* @__PURE__ */ d("div", { className: "ts-total", children: [
365
- "Total: ",
366
- s
580
+ /* @__PURE__ */ t("span", { children: "Total:" }),
581
+ " ",
582
+ r
367
583
  ] }),
368
584
  /* @__PURE__ */ d("div", { className: "ts-page-buttons", children: [
369
585
  /* @__PURE__ */ t("button", { disabled: e === 1, onClick: () => a(e - 1), children: "‹" }),
370
- c.map((f) => /* @__PURE__ */ t(
586
+ o.map((u) => /* @__PURE__ */ t(
371
587
  "button",
372
588
  {
373
- className: f === e ? "active" : "",
374
- onClick: () => a(f),
375
- children: f
589
+ className: u === e ? "active" : "",
590
+ onClick: () => a(u),
591
+ children: u
376
592
  },
377
- f
593
+ u
378
594
  )),
379
- o && /* @__PURE__ */ t("span", { style: { padding: "0 6px" }, children: "…" }),
380
- o && /* @__PURE__ */ t(
595
+ c && /* @__PURE__ */ t("span", { style: { padding: "0 6px" }, children: "…" }),
596
+ c && /* @__PURE__ */ t(
381
597
  "button",
382
598
  {
383
- className: e === w ? "active" : "",
384
- onClick: () => a(w),
385
- children: w
599
+ className: e === v ? "active" : "",
600
+ onClick: () => a(v),
601
+ children: v
386
602
  }
387
603
  ),
388
604
  /* @__PURE__ */ t(
389
605
  "button",
390
606
  {
391
- disabled: e === r,
607
+ disabled: e === s,
392
608
  onClick: () => a(e + 1),
393
609
  children: "›"
394
610
  }
395
611
  )
396
612
  ] })
397
613
  ] });
398
- }, at = ({
614
+ }, yt = ({
399
615
  show: e,
400
616
  variant: n,
401
- title: s = "Are you sure?",
617
+ title: r = "Are you sure?",
402
618
  message: a,
403
619
  label: i = "Name",
404
- value: r = "",
620
+ value: s = "",
405
621
  placeholder: l = "",
406
- requiredMessage: c = "This field is required",
407
- externalError: o = !1,
408
- externalErrorMessage: w = "",
409
- confirmText: f = "Ok",
410
- cancelText: C = "Cancel",
411
- confirmButtonVariant: g = "danger",
412
- disableConfirm: S = !1,
413
- onConfirm: A,
414
- onCancel: h,
415
- onInputChange: y
622
+ requiredMessage: o = "This field is required",
623
+ externalError: c = !1,
624
+ externalErrorMessage: v = "",
625
+ confirmText: E = "Ok",
626
+ cancelText: I = "Cancel",
627
+ confirmButtonVariant: b = "danger",
628
+ disableConfirm: x = !1,
629
+ onConfirm: u,
630
+ onCancel: p,
631
+ onInputChange: w
416
632
  }) => {
417
- const [b, m] = N(r), [v, x] = N(!1), T = Z(null);
418
- if (P(() => {
633
+ const [h, y] = C(s), [g, R] = C(!1), B = te(null);
634
+ if (L(() => {
419
635
  if (!e) return;
420
- const I = (D) => {
421
- D.key === "Escape" && h();
636
+ const M = (T) => {
637
+ T.key === "Escape" && p();
422
638
  };
423
- return document.addEventListener("keydown", I), () => document.removeEventListener("keydown", I);
424
- }, [e, h]), P(() => {
639
+ return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
640
+ }, [e, p]), L(() => {
425
641
  if (!e) return;
426
- const I = (D) => {
427
- T.current && !T.current.contains(D.target) && h();
642
+ const M = (T) => {
643
+ B.current && !B.current.contains(T.target) && p();
428
644
  };
429
- return document.addEventListener("mousedown", I), () => document.removeEventListener("mousedown", I);
430
- }, [e, h]), P(() => {
645
+ return document.addEventListener("mousedown", M), () => document.removeEventListener("mousedown", M);
646
+ }, [e, p]), L(() => {
431
647
  if (e)
432
648
  return document.body.style.overflow = "hidden", () => {
433
649
  document.body.style.overflow = "";
434
650
  };
435
- }, [e]), P(() => {
436
- e && (m(r), x(!1));
437
- }, [e, r]), P(() => {
438
- o && x(!0);
439
- }, [o]), !e) return null;
440
- const k = n === "input" && !b.trim(), O = n === "input" && (k || o), M = k ? c : o ? w : "", F = () => {
441
- if (O || S) {
442
- x(!0);
651
+ }, [e]), L(() => {
652
+ e && (y(s), R(!1));
653
+ }, [e, s]), L(() => {
654
+ c && R(!0);
655
+ }, [c]), !e) return null;
656
+ const _ = n === "input" && !h.trim(), A = n === "input" && (_ || c), S = _ ? o : c ? v : "", D = () => {
657
+ if (A || x) {
658
+ R(!0);
443
659
  return;
444
660
  }
445
- A(b.trim());
661
+ u(h.trim());
446
662
  };
447
- return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */ d("div", { ref: T, className: "ts-modal", children: [
663
+ return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */ d("div", { ref: B, className: "ts-modal", children: [
448
664
  /* @__PURE__ */ d("div", { className: "ts-modal-header", children: [
449
- /* @__PURE__ */ t("h4", { className: "ts-modal-title ", children: s }),
450
- /* @__PURE__ */ t("button", { className: "ts-modal-close", onClick: h, children: "✕" })
665
+ /* @__PURE__ */ t("h4", { className: "ts-modal-title ", children: r }),
666
+ /* @__PURE__ */ t("button", { className: "ts-modal-close", onClick: p, children: "✕" })
451
667
  ] }),
452
668
  /* @__PURE__ */ d("div", { className: "ts-modal-body", children: [
453
669
  a && /* @__PURE__ */ t("p", { className: "ts-modal-message", children: a }),
@@ -460,17 +676,17 @@ const rt = je(nt), ve = 5, st = ({
460
676
  "input",
461
677
  {
462
678
  type: "text",
463
- className: `ts-input ${v && O ? "ts-input-error" : ""}`,
679
+ className: `ts-input ${g && A ? "ts-input-error" : ""}`,
464
680
  placeholder: l,
465
- value: b,
466
- onChange: (I) => {
467
- m(I.target.value), v && x(!1), y?.(I.target.value);
681
+ value: h,
682
+ onChange: (M) => {
683
+ y(M.target.value), g && R(!1), w?.(M.target.value);
468
684
  },
469
685
  autoFocus: !0,
470
686
  style: { paddingBlock: "0", paddingInline: "0" }
471
687
  }
472
688
  ),
473
- v && O && /* @__PURE__ */ t("div", { className: "ts-error-text", children: M })
689
+ g && A && /* @__PURE__ */ t("div", { className: "ts-error-text", children: S })
474
690
  ] })
475
691
  ] }),
476
692
  /* @__PURE__ */ d("div", { className: "ts-modal-footer", children: [
@@ -479,43 +695,43 @@ const rt = je(nt), ve = 5, st = ({
479
695
  {
480
696
  type: "button",
481
697
  className: "ts-btn ts-btn-secondary",
482
- onClick: h,
483
- children: C
698
+ onClick: p,
699
+ children: I
484
700
  }
485
701
  ),
486
702
  /* @__PURE__ */ t(
487
703
  "button",
488
704
  {
489
705
  type: "button",
490
- className: `ts-btn ts-btn-${g}`,
491
- onClick: F,
492
- disabled: S,
493
- children: f
706
+ className: `ts-btn ts-btn-${b}`,
707
+ onClick: D,
708
+ disabled: x,
709
+ children: E
494
710
  }
495
711
  )
496
712
  ] })
497
713
  ] }) });
498
- }, it = () => /* @__PURE__ */ t(
714
+ }, gt = () => /* @__PURE__ */ t(
499
715
  "svg",
500
716
  {
501
717
  xmlns: "http://www.w3.org/2000/svg",
502
718
  viewBox: "0 0 512 512",
503
- width: "16px",
504
- height: "16px",
719
+ width: "11px",
720
+ height: "11px",
505
721
  children: /* @__PURE__ */ t("path", { fill: "#ffffff", d: "M368 208A160 160 0 1 0 48 208a160 160 0 1 0 320 0zM337.1 371.1C301.7 399.2 256.8 416 208 416C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208c0 48.8-16.8 93.7-44.9 129.1L505 471c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L337.1 371.1z" })
506
722
  }
507
- ), lt = () => {
508
- const e = z(), { enerexIdentifier: n, projectId: s, userEmail: a } = H();
509
- return oe({
723
+ ), vt = () => {
724
+ const e = Y(), { enerexIdentifier: n, projectId: r, userEmail: a } = V();
725
+ return ce({
510
726
  mutationKey: ["duplicateTemplate"],
511
- mutationFn: async ({ templateId: r, request: l }) => (l.enerexIdentifier = n ?? "", l.projectId = s ?? "", l.updatedBy = a ?? "", await e.post(
512
- `${Q.duplicateTemplate}${r}`,
727
+ mutationFn: async ({ templateId: s, request: l }) => (l.enerexIdentifier = n ?? "", l.projectId = r ?? "", l.updatedBy = a ?? "", await e.post(
728
+ `${Q.duplicateTemplate}${s}`,
513
729
  l
514
730
  ))
515
731
  });
516
- }, ot = () => {
517
- const e = z();
518
- return oe({
732
+ }, bt = () => {
733
+ const e = Y();
734
+ return ce({
519
735
  mutationKey: ["deleteTemplate"],
520
736
  mutationFn: async (n) => {
521
737
  await e.delete(
@@ -523,306 +739,305 @@ const rt = je(nt), ve = 5, st = ({
523
739
  );
524
740
  }
525
741
  });
526
- }, ct = ({
742
+ }, wt = ({
527
743
  data: e,
528
744
  page: n,
529
- pageSize: s
745
+ pageSize: r
530
746
  }) => {
531
- const a = se(() => Math.ceil(e.length / s), [e.length, s]);
532
- return { pagedData: se(() => {
533
- const r = (n - 1) * s, l = n * s;
534
- return e.slice(r, l);
535
- }, [e, n, s]), totalPages: a };
536
- }, dt = ({
747
+ const a = ae(() => Math.ceil(e.length / r), [e.length, r]);
748
+ return { pagedData: ae(() => {
749
+ const s = (n - 1) * r, l = n * r;
750
+ return e.slice(s, l);
751
+ }, [e, n, r]), totalPages: a };
752
+ }, Tt = ({
537
753
  templates: e,
538
754
  templateTypes: n,
539
- onRefresh: s,
755
+ onRefresh: r,
540
756
  onAdd: a,
541
757
  onEdit: i,
542
- onPreview: r
758
+ onPreview: s
543
759
  }) => {
544
- const { mutateAsync: l, isPending: c } = lt(), { mutateAsync: o, isPending: w } = ot(), [f, C] = N(""), [g, S] = N(""), [A, h] = N(null), [y, b] = N(e), [m, v] = N(n), [x, T] = N(!1), [k, O] = N("input"), [M, F] = N(!1), [I, D] = N(null), [B, ce] = N("asc"), j = (p) => {
545
- I === p ? ce((L) => L === "asc" ? "desc" : "asc") : (D(p), ce("asc")), ie(1);
546
- }, [G, V] = N(null);
547
- P(() => {
548
- const p = [...e].sort((L, R) => {
549
- const $ = new Date(R.updatedDateTime).getTime() - new Date(L.updatedDateTime).getTime();
550
- return $ !== 0 ? $ : L.readonly !== R.readonly ? Number(L.readonly) - Number(R.readonly) : L.name.localeCompare(R.name);
760
+ const { isAdmin: l } = V(), { mutateAsync: o, isPending: c } = vt(), { mutateAsync: v, isPending: E } = bt(), [I, b] = C(""), [x, u] = C(""), [p, w] = C(null), [h, y] = C(e), [g, R] = C(n), [B, _] = C(!1), [A, S] = C("input"), [D, M] = C(!1), [T, ne] = C(null), [U, W] = C("asc"), K = (m) => {
761
+ T === m ? W((N) => N === "asc" ? "desc" : "asc") : (ne(m), W("asc")), ee(1);
762
+ }, [O, re] = C(null);
763
+ L(() => {
764
+ const m = [...e].sort((N, $) => {
765
+ if (!l && N.is_favourite !== $.is_favourite)
766
+ return Number($.is_favourite) - Number(N.is_favourite);
767
+ const P = new Date($.updatedDateTime).getTime() - new Date(N.updatedDateTime).getTime();
768
+ return P !== 0 ? P : N.readonly !== $.readonly ? Number(N.readonly) - Number($.readonly) : N.name.localeCompare($.name);
551
769
  });
552
- b(p), D(null);
553
- }, [e]), P(() => {
554
- v(n.filter((p) => p.id != null));
770
+ y(m), ne(null);
771
+ }, [e]), L(() => {
772
+ R(n.filter((m) => m.id != null));
555
773
  }, [n]);
556
- const ee = se(() => {
557
- const p = /* @__PURE__ */ new Map();
558
- return m.forEach((L) => p.set(L.id, L)), p;
559
- }, [m]), he = Ee(
560
- (p) => {
561
- const L = [], R = /* @__PURE__ */ new Set();
562
- let $ = ee.get(p);
563
- for (; $ && !(R.has($.id) || (R.add($.id), L.push({ id: $.id, name: $.name, key: $.key }), !$.parent_id)); )
564
- $ = ee.get($.parent_id);
565
- return L.reverse();
774
+ const le = ae(() => {
775
+ const m = /* @__PURE__ */ new Map();
776
+ return g.forEach((N) => m.set(N.id, N)), m;
777
+ }, [g]), de = Se(
778
+ (m) => {
779
+ const N = [], $ = /* @__PURE__ */ new Set();
780
+ let P = le.get(m);
781
+ for (; P && !($.has(P.id) || ($.add(P.id), N.push({ id: P.id, name: P.name, key: P.key }), !P.parent_id)); )
782
+ P = le.get(P.parent_id);
783
+ return N.reverse();
566
784
  },
567
- [ee]
568
- ), te = se(() => !y.length || !m.length ? [] : y.map((p) => ({
569
- ...p,
570
- categoryChain: he(p.type)
571
- })), [y, m]);
572
- P(() => {
573
- const p = setTimeout(() => {
574
- S(f), ie(1);
785
+ [le]
786
+ ), Z = ae(() => !h.length || !g.length ? [] : h.map((m) => ({
787
+ ...m,
788
+ categoryChain: de(m.type)
789
+ })), [h, g]);
790
+ L(() => {
791
+ const m = setTimeout(() => {
792
+ u(I), ee(1);
575
793
  }, 300);
576
- return () => clearTimeout(p);
577
- }, [f]);
578
- const [ne, Y] = N(10), [K, ie] = N(1), re = se(() => {
579
- const p = g.trim().toLowerCase();
580
- return p ? te.filter((L) => {
581
- const R = L.name.toLowerCase().includes(p), $ = L.categoryChain?.some(
582
- (J) => J.name.toLowerCase().includes(p)
794
+ return () => clearTimeout(m);
795
+ }, [I]);
796
+ const [se, H] = C(25), [ue, ee] = C(1), me = ae(() => {
797
+ const m = x.trim().toLowerCase();
798
+ return m ? Z.filter((N) => {
799
+ const $ = N.name.toLowerCase().includes(m), P = N.categoryChain?.some(
800
+ (z) => z.name.toLowerCase().includes(m)
583
801
  );
584
- return R || $;
585
- }) : te;
586
- }, [te, g]), de = se(() => {
587
- const p = [...re];
588
- return p.sort((L, R) => {
589
- let $ = "", J = "";
590
- switch (I) {
802
+ return $ || P;
803
+ }) : Z;
804
+ }, [Z, x]), pe = ae(() => {
805
+ const m = [...me];
806
+ return m.sort((N, $) => {
807
+ if (T === "lastUpdatedOn") {
808
+ const Ve = new Date(N.updatedDateTime).getTime(), Ke = new Date($.updatedDateTime).getTime(), Pe = Ve - Ke;
809
+ return U === "asc" ? Pe : -Pe;
810
+ }
811
+ let P = "", z = "";
812
+ switch (T) {
591
813
  case "name":
592
- $ = L.name, J = R.name;
814
+ P = N.name, z = $.name;
593
815
  break;
594
816
  case "category":
595
- $ = L.categoryChain?.[0]?.name ?? "", J = R.categoryChain?.[0]?.name ?? "";
817
+ P = N.categoryChain?.[0]?.name ?? "", z = $.categoryChain?.[0]?.name ?? "";
596
818
  break;
597
819
  case "type":
598
- $ = L.categoryChain?.[1]?.name ?? "", J = R.categoryChain?.[1]?.name ?? "";
820
+ P = N.categoryChain?.[1]?.name ?? "", z = $.categoryChain?.[1]?.name ?? "";
599
821
  break;
600
822
  case "subtype":
601
- $ = L.categoryChain?.[2]?.name ?? "", J = R.categoryChain?.[2]?.name ?? "";
823
+ P = N.categoryChain?.[2]?.name ?? "", z = $.categoryChain?.[2]?.name ?? "";
824
+ break;
825
+ case "templateId":
826
+ P = N.id ?? "", z = $.id ?? "";
827
+ break;
828
+ case "companyName":
829
+ P = N.companyName ?? "", z = $.companyName ?? "";
830
+ break;
831
+ case "lastUpdatedBy":
832
+ P = N.updatedByName ?? "", z = $.updatedByName ?? "";
602
833
  break;
603
834
  }
604
- const ke = $.localeCompare(J, void 0, {
835
+ const De = P.localeCompare(z, void 0, {
605
836
  sensitivity: "base"
606
837
  });
607
- return B === "asc" ? ke : -ke;
608
- }), p;
609
- }, [re, I, B]), { pagedData: ye } = ct({
610
- data: de,
611
- page: K,
612
- pageSize: ne
613
- }), le = Ee(
614
- (p) => y.some(
615
- (L) => L.name.trim().toLowerCase() === p.trim().toLowerCase()
838
+ return U === "asc" ? De : -De;
839
+ }), m;
840
+ }, [me, T, U]), { pagedData: be } = wt({
841
+ data: pe,
842
+ page: ue,
843
+ pageSize: se
844
+ }), f = Se(
845
+ (m) => h.some(
846
+ (N) => N.name.trim().toLowerCase() === m.trim().toLowerCase()
616
847
  ),
617
- [y]
618
- ), ge = (p) => {
619
- V(p), F(!1), O("input"), T(!0);
620
- }, u = (p) => {
621
- V(p), O("confirm"), T(!0);
622
- }, { showNotification: E } = Re(), _ = async (p) => {
623
- if (G)
848
+ [h]
849
+ ), k = (m) => {
850
+ re(m), M(!1), S("input"), _(!0);
851
+ }, F = (m) => {
852
+ re(m), S("confirm"), _(!0);
853
+ }, { showNotification: j } = ve(), X = async (m) => {
854
+ if (O)
624
855
  try {
625
- if (k === "input") {
626
- if (!p) return;
627
- if (le(p)) {
628
- F(!0);
856
+ if (A === "input") {
857
+ if (!m) return;
858
+ if (f(m)) {
859
+ M(!0);
629
860
  return;
630
861
  }
631
- await l({
632
- templateId: G.id,
862
+ await o({
863
+ templateId: O.id,
633
864
  request: {
634
865
  projectId: "",
635
866
  enerexIdentifier: "",
636
- newName: p,
637
- parent_id: G.id ?? null
867
+ newName: m,
868
+ parent_id: O.id ?? null
638
869
  }
639
- }), E(
640
- `Template "${p}" duplicated successfully`,
870
+ }), j(
871
+ `Template "${m}" duplicated successfully`,
641
872
  "success"
642
873
  );
643
874
  }
644
- k === "confirm" && (await o(G.id), E(
645
- `Template "${G.name}" deleted successfully`,
875
+ A === "confirm" && (await v(O.id), j(
876
+ `Template "${O.name}" deleted successfully`,
646
877
  "success"
647
- )), T(!1), V(null), s();
878
+ )), _(!1), re(null), r();
648
879
  } catch {
649
- E(
650
- k === "confirm" ? "Failed to delete template. Please try again." : "Failed to duplicate template. Please try again.",
880
+ j(
881
+ A === "confirm" ? "Failed to delete template. Please try again." : "Failed to duplicate template. Please try again.",
651
882
  "error"
652
883
  );
653
884
  }
654
- }, q = G?.categoryChain?.[2]?.name?.toLowerCase() ?? "this", X = G?.name?.toLowerCase() ?? "";
655
- return /* @__PURE__ */ d(pe, { children: [
656
- (c || w) && /* @__PURE__ */ t(ae, { overlay: !0 }),
885
+ }, q = O?.categoryChain?.[2]?.name?.toLowerCase() ?? "this", oe = O?.name?.toLowerCase() ?? "";
886
+ return /* @__PURE__ */ d(ye, { children: [
887
+ (c || E) && /* @__PURE__ */ t(ie, { overlay: !0 }),
657
888
  /* @__PURE__ */ d("div", { className: "ts-page", children: [
658
889
  /* @__PURE__ */ d("div", { className: "ts-header", children: [
659
890
  /* @__PURE__ */ t("h1", { className: "ts-title", children: "Templates" }),
660
891
  /* @__PURE__ */ t("button", { className: "ts-btn ts-btn-primary", onClick: a, children: "+ Add Template" })
661
892
  ] }),
662
- /* @__PURE__ */ t("div", { className: "ts-search", children: /* @__PURE__ */ d("div", { className: "ts-search-box", children: [
663
- /* @__PURE__ */ t(
664
- "input",
665
- {
666
- type: "text",
667
- placeholder: "Search...",
668
- value: f,
669
- onChange: (p) => C(p.target.value)
670
- }
671
- ),
672
- f && /* @__PURE__ */ t(
673
- "button",
674
- {
675
- className: "ts-clear-btn",
676
- "aria-label": "Clear search",
677
- onClick: () => C(""),
678
- children: "×"
679
- }
680
- ),
681
- /* @__PURE__ */ t("button", { className: "ts-search-btn", "aria-label": "Search", children: /* @__PURE__ */ t(it, {}) })
682
- ] }) }),
683
- /* @__PURE__ */ d("div", { className: "ts-table-wrapper", children: [
684
- /* @__PURE__ */ d("table", { className: "ts-table", children: [
685
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ d("tr", { children: [
686
- /* @__PURE__ */ t("th", { onClick: () => j("name"), className: "ts-sortable", children: /* @__PURE__ */ d("div", { className: "ts-th-sort", children: [
687
- "Name",
688
- /* @__PURE__ */ d("span", { className: "ts-sort-icons", children: [
689
- /* @__PURE__ */ t(
690
- "span",
691
- {
692
- className: I === "name" && B === "asc" ? "active" : "",
693
- children: ""
694
- }
695
- ),
696
- /* @__PURE__ */ t(
697
- "span",
698
- {
699
- className: I === "name" && B === "desc" ? "active" : "",
700
- children: "▼"
701
- }
702
- )
703
- ] })
704
- ] }) }),
705
- /* @__PURE__ */ t(
706
- "th",
707
- {
708
- onClick: () => j("category"),
709
- className: "ts-sortable",
710
- children: /* @__PURE__ */ d("div", { className: "ts-th-sort", children: [
711
- "Category",
712
- /* @__PURE__ */ d("span", { className: "ts-sort-icons", children: [
713
- /* @__PURE__ */ t(
714
- "span",
715
- {
716
- className: I === "category" && B === "asc" ? "active" : "",
717
- children: "▲"
718
- }
719
- ),
720
- /* @__PURE__ */ t(
721
- "span",
722
- {
723
- className: I === "category" && B === "desc" ? "active" : "",
724
- children: "▼"
725
- }
726
- )
727
- ] })
728
- ] })
729
- }
730
- ),
731
- /* @__PURE__ */ t("th", { onClick: () => j("type"), className: "ts-sortable", children: /* @__PURE__ */ d("div", { className: "ts-th-sort", children: [
732
- "Type",
733
- /* @__PURE__ */ d("span", { className: "ts-sort-icons", children: [
734
- /* @__PURE__ */ t(
735
- "span",
736
- {
737
- className: I === "type" && B === "asc" ? "active" : "",
738
- children: "▲"
739
- }
740
- ),
741
- /* @__PURE__ */ t(
742
- "span",
743
- {
744
- className: I === "type" && B === "desc" ? "active" : "",
745
- children: "▼"
746
- }
747
- )
748
- ] })
893
+ /* @__PURE__ */ t("div", { className: "ts-search-container", children: /* @__PURE__ */ d("div", { className: "ts-search-container-inner", children: [
894
+ /* @__PURE__ */ t("div", { className: "ts-search", children: /* @__PURE__ */ d("div", { className: "ts-search-box", children: [
895
+ /* @__PURE__ */ t(
896
+ "input",
897
+ {
898
+ type: "text",
899
+ placeholder: "Search...",
900
+ value: I,
901
+ onChange: (m) => b(m.target.value)
902
+ }
903
+ ),
904
+ /* @__PURE__ */ t("button", { className: "ts-search-btn", "aria-label": "Search", children: /* @__PURE__ */ t(gt, {}) })
905
+ ] }) }),
906
+ /* @__PURE__ */ d("div", { className: "ts-table-wrapper", children: [
907
+ /* @__PURE__ */ d("table", { className: "ts-table", children: [
908
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ d("tr", { children: [
909
+ /* @__PURE__ */ t("th", { className: "ts-cursor-default" }),
910
+ /* @__PURE__ */ t(
911
+ J,
912
+ {
913
+ label: "Name",
914
+ sortKey: "name",
915
+ sortBy: T,
916
+ sortOrder: U,
917
+ onSort: K
918
+ }
919
+ ),
920
+ l && /* @__PURE__ */ t(
921
+ J,
922
+ {
923
+ label: "Template Id",
924
+ sortKey: "templateId",
925
+ sortBy: T,
926
+ sortOrder: U,
927
+ onSort: K
928
+ }
929
+ ),
930
+ /* @__PURE__ */ t(
931
+ J,
932
+ {
933
+ label: "Category",
934
+ sortKey: "category",
935
+ sortBy: T,
936
+ sortOrder: U,
937
+ onSort: K
938
+ }
939
+ ),
940
+ /* @__PURE__ */ t(
941
+ J,
942
+ {
943
+ label: "Type",
944
+ sortKey: "type",
945
+ sortBy: T,
946
+ sortOrder: U,
947
+ onSort: K
948
+ }
949
+ ),
950
+ /* @__PURE__ */ t(
951
+ J,
952
+ {
953
+ label: "Subtype",
954
+ sortKey: "subtype",
955
+ sortBy: T,
956
+ sortOrder: U,
957
+ onSort: K
958
+ }
959
+ ),
960
+ l && /* @__PURE__ */ t(
961
+ J,
962
+ {
963
+ label: "Company Name",
964
+ sortKey: "companyName",
965
+ sortBy: T,
966
+ sortOrder: U,
967
+ onSort: K
968
+ }
969
+ ),
970
+ /* @__PURE__ */ t(
971
+ J,
972
+ {
973
+ label: "Last Updated by",
974
+ sortKey: "lastUpdatedBy",
975
+ sortBy: T,
976
+ sortOrder: U,
977
+ onSort: K
978
+ }
979
+ ),
980
+ /* @__PURE__ */ t(
981
+ J,
982
+ {
983
+ label: "Last Updated on",
984
+ sortKey: "lastUpdatedOn",
985
+ sortBy: T,
986
+ sortOrder: U,
987
+ onSort: K
988
+ }
989
+ ),
990
+ /* @__PURE__ */ t("th", { className: "ts-cursor-default", children: "Actions" })
749
991
  ] }) }),
750
- /* @__PURE__ */ t(
751
- "th",
992
+ /* @__PURE__ */ t("tbody", { children: be.map((m) => /* @__PURE__ */ t(
993
+ mt,
752
994
  {
753
- onClick: () => j("subtype"),
754
- className: "ts-sortable",
755
- children: /* @__PURE__ */ d("div", { className: "ts-th-sort", children: [
756
- "Subtype",
757
- /* @__PURE__ */ d("span", { className: "ts-sort-icons", children: [
758
- /* @__PURE__ */ t(
759
- "span",
760
- {
761
- className: I === "subtype" && B === "asc" ? "active" : "",
762
- children: "▲"
763
- }
764
- ),
765
- /* @__PURE__ */ t(
766
- "span",
767
- {
768
- className: I === "subtype" && B === "desc" ? "active" : "",
769
- children: "▼"
770
- }
771
- )
772
- ] })
773
- ] })
774
- }
775
- ),
776
- /* @__PURE__ */ t("th", { children: "Updated by" }),
777
- /* @__PURE__ */ t("th", { className: "align-right", children: "Actions" })
778
- ] }) }),
779
- /* @__PURE__ */ t("tbody", { children: ye.map((p) => /* @__PURE__ */ t(
780
- rt,
995
+ template: m,
996
+ openActionId: p,
997
+ setOpenActionId: w,
998
+ onDuplicate: k,
999
+ onEdit: i,
1000
+ onRemove: F,
1001
+ onPreview: s,
1002
+ onRefresh: r
1003
+ },
1004
+ m.id
1005
+ )) })
1006
+ ] }),
1007
+ /* @__PURE__ */ t(
1008
+ ht,
781
1009
  {
782
- template: p,
783
- openActionId: A,
784
- setOpenActionId: h,
785
- onDuplicate: ge,
786
- onEdit: i,
787
- onRemove: u,
788
- onPreview: r
789
- },
790
- p.id
791
- )) })
792
- ] }),
793
- /* @__PURE__ */ t(
794
- st,
795
- {
796
- page: K,
797
- pageSize: ne,
798
- totalRecords: de.length,
799
- onPageChange: ie,
800
- onPageSizeChange: Y
801
- }
802
- )
803
- ] })
1010
+ page: ue,
1011
+ pageSize: se,
1012
+ totalRecords: pe.length,
1013
+ onPageChange: ee,
1014
+ onPageSizeChange: H
1015
+ }
1016
+ )
1017
+ ] })
1018
+ ] }) })
804
1019
  ] }),
805
1020
  /* @__PURE__ */ t(
806
- at,
1021
+ yt,
807
1022
  {
808
- show: x,
809
- variant: k,
810
- title: k === "confirm" ? "Are you sure?" : "Save Template As",
811
- message: k === "confirm" ? `Are you sure you want to remove ${q} template "${X}"?` : "",
812
- placeholder: k === "input" ? "New name" : "",
1023
+ show: B,
1024
+ variant: A,
1025
+ title: A === "confirm" ? "Are you sure?" : "Save Template As",
1026
+ message: A === "confirm" ? `Are you sure you want to remove ${q} template "${oe}"?` : "",
1027
+ placeholder: A === "input" ? "New name" : "",
813
1028
  label: "New Name",
814
1029
  requiredMessage: "Enter a new name",
815
- externalError: M,
1030
+ externalError: D,
816
1031
  externalErrorMessage: "Template name already exists. Please choose a different name",
817
- confirmText: k === "confirm" ? "Ok" : "Save as",
818
- confirmButtonVariant: k === "confirm" ? "danger" : "primary",
819
- onConfirm: _,
820
- onCancel: () => T(!1),
821
- onInputChange: k === "input" ? () => F(!1) : void 0
1032
+ confirmText: A === "confirm" ? "Ok" : "Save as",
1033
+ confirmButtonVariant: A === "confirm" ? "danger" : "primary",
1034
+ onConfirm: X,
1035
+ onCancel: () => _(!1),
1036
+ onInputChange: A === "input" ? () => M(!1) : void 0
822
1037
  }
823
1038
  )
824
1039
  ] });
825
- }, ue = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
1040
+ }, he = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
826
1041
  <html\r
827
1042
  dir="ltr"\r
828
1043
  xmlns:o="urn:schemas-microsoft-com:office:office"\r
@@ -1178,70 +1393,70 @@ const rt = je(nt), ve = 5, st = ({
1178
1393
  </div>\r
1179
1394
  </body>\r
1180
1395
  </html>\r
1181
- `, we = {
1396
+ `, xe = {
1182
1397
  EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
1183
1398
  EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
1184
1399
  EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da"
1185
- }, mt = (e) => {
1186
- const n = Array.from(new Set(e.map((a) => a.category))), s = [];
1400
+ }, Nt = (e) => {
1401
+ const n = Array.from(new Set(e.map((a) => a.category))), r = [];
1187
1402
  return n.forEach((a) => {
1188
- const i = e.filter((r) => r.category === a).map((r) => ({
1189
- label: r.label,
1190
- value: r.value,
1191
- hint: r.hint,
1192
- hidden: r.hidden
1403
+ const i = e.filter((s) => s.category === a).map((s) => ({
1404
+ label: s.label,
1405
+ value: s.value,
1406
+ hint: s.hint,
1407
+ hidden: s.hidden
1193
1408
  }));
1194
- s.push({ category: a, entries: i });
1195
- }), s;
1196
- }, ut = () => {
1197
- const e = z(), { enerexIdentifier: n, projectId: s } = H();
1198
- return fe({
1409
+ r.push({ category: a, entries: i });
1410
+ }), r;
1411
+ }, Ct = () => {
1412
+ const e = Y(), { enerexIdentifier: n, projectId: r } = V();
1413
+ return ge({
1199
1414
  queryKey: ["getTemplateTags"],
1200
1415
  queryFn: async (i) => await e.get(
1201
- `${Q.MergeTags}${s}/${n}`
1416
+ `${Q.MergeTags}${r}/${n}`
1202
1417
  )
1203
1418
  });
1204
- }, pt = () => {
1205
- const e = z(), { enerexIdentifier: n, projectId: s } = H();
1206
- return fe({
1419
+ }, xt = () => {
1420
+ const e = Y(), { enerexIdentifier: n, projectId: r } = V();
1421
+ return ge({
1207
1422
  queryKey: ["getExcludeCategory"],
1208
1423
  queryFn: async (i) => await e.get(
1209
- `${Q.ExcludeCategory}${s}/${n}`
1424
+ `${Q.ExcludeCategory}${r}/${n}`
1210
1425
  )
1211
1426
  });
1212
- }, ft = ({
1427
+ }, Et = ({
1213
1428
  templateHTML: e,
1214
1429
  className: n = "",
1215
- loading: s = !1,
1430
+ loading: r = !1,
1216
1431
  onEditorInitialized: a
1217
1432
  }) => {
1218
- const { post: i } = Oe(), { data: r } = ut(), { data: l } = pt(), [c, o] = N(
1219
- e ?? { html: ue, css: "" }
1220
- ), { userEmail: w } = H(), f = Z(null), C = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", g = "https://plugins.stripo.email/api/v1/auth";
1221
- P(() => {
1222
- (async () => (await S(), r && l && await A(we.EDITOR_SCRIPT_URL)))();
1223
- }, [r, l]);
1224
- async function S() {
1225
- window.Zone || await new Promise((y, b) => {
1226
- const m = document.createElement("script");
1227
- m.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
1228
- const v = document.querySelector("script[nonce]")?.nonce;
1229
- v && m.setAttribute("nonce", v), m.onload = () => y(), m.onerror = () => b(new Error("Failed to load zone.js")), document.head.appendChild(m);
1433
+ const { post: i } = je(), { data: s } = Ct(), { data: l } = xt(), [o, c] = C(
1434
+ e ?? { html: he, css: "" }
1435
+ ), { userEmail: v } = V(), E = te(null), I = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", b = "https://plugins.stripo.email/api/v1/auth";
1436
+ L(() => {
1437
+ (async () => (await x(), s && l && await u(xe.EDITOR_SCRIPT_URL)))();
1438
+ }, [s, l]);
1439
+ async function x() {
1440
+ window.Zone || await new Promise((w, h) => {
1441
+ const y = document.createElement("script");
1442
+ y.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
1443
+ const g = document.querySelector("script[nonce]")?.nonce;
1444
+ g && y.setAttribute("nonce", g), y.onload = () => w(), y.onerror = () => h(new Error("Failed to load zone.js")), document.head.appendChild(y);
1230
1445
  });
1231
1446
  }
1232
- async function A(y) {
1233
- let b = document.getElementById(
1447
+ async function u(w) {
1448
+ let h = document.getElementById(
1234
1449
  "UiEditorScript"
1235
1450
  );
1236
- b || (b = document.createElement("script"), b.id = "UiEditorScript", b.src = y, b.onload = async () => {
1237
- await h();
1238
- }, document.body.appendChild(b)), await new Promise(
1239
- (m) => b.addEventListener("load", () => m(), { once: !0 })
1451
+ h || (h = document.createElement("script"), h.id = "UiEditorScript", h.src = w, h.onload = async () => {
1452
+ await p();
1453
+ }, document.body.appendChild(h)), await new Promise(
1454
+ (y) => h.addEventListener("load", () => y(), { once: !0 })
1240
1455
  );
1241
1456
  }
1242
- const h = async () => {
1243
- const y = f.current;
1244
- if (!y) {
1457
+ const p = async () => {
1458
+ const w = E.current;
1459
+ if (!w) {
1245
1460
  console.error("Missing #stripoEditorContainer in DOM");
1246
1461
  return;
1247
1462
  }
@@ -1249,48 +1464,48 @@ const rt = je(nt), ve = 5, st = ({
1249
1464
  console.error("UIEditor script not loaded or not exposing initEditor");
1250
1465
  return;
1251
1466
  }
1252
- const b = {
1253
- html: c.html,
1254
- css: c.css,
1467
+ const h = {
1468
+ html: o.html,
1469
+ css: o.css,
1255
1470
  modulesExcludedCategories: l ?? [],
1256
1471
  forceRecreate: !0,
1257
1472
  metadata: {
1258
- emailId: w,
1473
+ emailId: v,
1259
1474
  userId: "1",
1260
1475
  // username: userName,
1261
- avatarUrl: C
1476
+ avatarUrl: I
1262
1477
  },
1263
1478
  locale: "en",
1264
- onTokenRefreshRequest: async (m) => {
1265
- const v = {
1266
- pluginId: we.EDITOR_PLUGIN_ID,
1267
- secretKey: we.EDITOR_SECRET_KEY,
1268
- userId: w,
1479
+ onTokenRefreshRequest: async (y) => {
1480
+ const g = {
1481
+ pluginId: xe.EDITOR_PLUGIN_ID,
1482
+ secretKey: xe.EDITOR_SECRET_KEY,
1483
+ userId: v,
1269
1484
  role: "user"
1270
- }, x = await i(
1271
- g,
1272
- v
1485
+ }, R = await i(
1486
+ b,
1487
+ g
1273
1488
  );
1274
- x?.token && m(x.token);
1489
+ R?.token && y(R.token);
1275
1490
  },
1276
1491
  onTemplateLoaded: () => {
1277
1492
  a && a(!0);
1278
1493
  },
1279
- mergeTags: mt(r ?? [])
1494
+ mergeTags: Nt(s ?? [])
1280
1495
  };
1281
- for (const [m, v] of Object.entries({
1496
+ for (const [y, g] of Object.entries({
1282
1497
  codeEditorButtonSelector: "#codeEditor",
1283
1498
  undoButtonSelector: "#undoButton",
1284
1499
  redoButtonSelector: "#redoButton",
1285
1500
  mobileViewButtonSelector: "#mobileViewButton",
1286
1501
  desktopViewButtonSelector: "#desktopViewButton"
1287
1502
  }))
1288
- y.ownerDocument && y.getRootNode() instanceof ShadowRoot && y.getRootNode().querySelector(v) && (b[m] = v);
1289
- await window.UIEditor.initEditor(y, b);
1503
+ w.ownerDocument && w.getRootNode() instanceof ShadowRoot && w.getRootNode().querySelector(g) && (h[y] = g);
1504
+ await window.UIEditor.initEditor(w, h);
1290
1505
  };
1291
1506
  return /* @__PURE__ */ t("div", { className: "position-relative", children: /* @__PURE__ */ d("div", { className: `editor-container ${n}`, children: [
1292
- s && /* @__PURE__ */ t("div", { className: "loading-overlay", children: /* @__PURE__ */ t(
1293
- He,
1507
+ r && /* @__PURE__ */ t("div", { className: "loading-overlay", children: /* @__PURE__ */ t(
1508
+ Qe,
1294
1509
  {
1295
1510
  animation: "border",
1296
1511
  style: { width: "11px", height: "11px" },
@@ -1301,19 +1516,19 @@ const rt = je(nt), ve = 5, st = ({
1301
1516
  }
1302
1517
  ) }),
1303
1518
  /* @__PURE__ */ t("div", { id: "externalSystemContainer" }),
1304
- /* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref: f })
1519
+ /* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref: E })
1305
1520
  ] }) });
1306
- }, Pe = ({
1521
+ }, Me = ({
1307
1522
  label: e,
1308
1523
  register: n,
1309
- validation: s,
1524
+ validation: r,
1310
1525
  required: a = !1,
1311
1526
  name: i,
1312
- error: r,
1527
+ error: s,
1313
1528
  className: l = "",
1314
- ...c
1529
+ ...o
1315
1530
  }) => {
1316
- const o = !!(r && r[i]);
1531
+ const c = !!(s && s[i]);
1317
1532
  return /* @__PURE__ */ d("div", { className: `ts-form-group ${l}`, children: [
1318
1533
  e && /* @__PURE__ */ d("label", { className: "ts-form-label", children: [
1319
1534
  e,
@@ -1324,91 +1539,61 @@ const rt = je(nt), ve = 5, st = ({
1324
1539
  {
1325
1540
  name: i,
1326
1541
  type: "text",
1327
- ...c,
1542
+ ...o,
1328
1543
  ...n ? n(i, {
1329
- ...s
1544
+ ...r
1330
1545
  }) : {},
1331
- className: `ts-input ${o ? "ts-input-error" : ""}`,
1332
- "aria-invalid": o
1546
+ className: `ts-input ${c ? "ts-input-error" : ""}`,
1547
+ "aria-invalid": c
1333
1548
  }
1334
1549
  ),
1335
- o && /* @__PURE__ */ t("div", { className: "ts-error-text", children: r?.[i]?.message })
1550
+ c && /* @__PURE__ */ t("div", { className: "ts-error-text", children: s?.[i]?.message })
1336
1551
  ] });
1337
1552
  };
1338
- function Te(e) {
1339
- return e.sort((n, s) => n.name.localeCompare(s.name));
1340
- }
1341
- function ht(e) {
1342
- const n = /* @__PURE__ */ new Map(), s = [];
1343
- e.forEach((r) => n.set(r.id, r));
1344
- let a = e.filter((r) => r.parent_id === 0), i = 0;
1345
- for (; a.length > 0; ) {
1346
- s.push({ level: i, data: a });
1347
- const r = a.map((c) => c.id);
1348
- a = e.filter(
1349
- (c) => r.includes(c.parent_id)
1350
- ), i++;
1351
- }
1352
- return s;
1353
- }
1354
- function Ne(e, n) {
1355
- const a = ht(e).find((i) => i.level === n);
1356
- return a ? a.data : [];
1357
- }
1358
- const yt = () => {
1359
- const e = z(), { enerexIdentifier: n, projectId: s } = H();
1360
- return oe({
1361
- mutationKey: ["markFavourite"],
1362
- mutationFn: async (i) => await e.post(
1363
- `${Q.markFavourite}${s}/${n}`,
1364
- i
1365
- )
1366
- });
1367
- };
1368
- function gt(e) {
1553
+ function St(e) {
1369
1554
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
1370
1555
  }
1371
- var Ce = { exports: {} };
1556
+ var Ee = { exports: {} };
1372
1557
  /*!
1373
1558
  Copyright (c) 2018 Jed Watson.
1374
1559
  Licensed under the MIT License (MIT), see
1375
1560
  http://jedwatson.github.io/classnames
1376
1561
  */
1377
- var $e;
1378
- function bt() {
1379
- return $e || ($e = 1, function(e) {
1562
+ var _e;
1563
+ function Lt() {
1564
+ return _e || (_e = 1, function(e) {
1380
1565
  (function() {
1381
1566
  var n = {}.hasOwnProperty;
1382
- function s() {
1383
- for (var r = "", l = 0; l < arguments.length; l++) {
1384
- var c = arguments[l];
1385
- c && (r = i(r, a(c)));
1567
+ function r() {
1568
+ for (var s = "", l = 0; l < arguments.length; l++) {
1569
+ var o = arguments[l];
1570
+ o && (s = i(s, a(o)));
1386
1571
  }
1387
- return r;
1572
+ return s;
1388
1573
  }
1389
- function a(r) {
1390
- if (typeof r == "string" || typeof r == "number")
1391
- return r;
1392
- if (typeof r != "object")
1574
+ function a(s) {
1575
+ if (typeof s == "string" || typeof s == "number")
1576
+ return s;
1577
+ if (typeof s != "object")
1393
1578
  return "";
1394
- if (Array.isArray(r))
1395
- return s.apply(null, r);
1396
- if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
1397
- return r.toString();
1579
+ if (Array.isArray(s))
1580
+ return r.apply(null, s);
1581
+ if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]"))
1582
+ return s.toString();
1398
1583
  var l = "";
1399
- for (var c in r)
1400
- n.call(r, c) && r[c] && (l = i(l, c));
1584
+ for (var o in s)
1585
+ n.call(s, o) && s[o] && (l = i(l, o));
1401
1586
  return l;
1402
1587
  }
1403
- function i(r, l) {
1404
- return l ? r ? r + " " + l : r + l : r;
1588
+ function i(s, l) {
1589
+ return l ? s ? s + " " + l : s + l : s;
1405
1590
  }
1406
- e.exports ? (s.default = s, e.exports = s) : window.classNames = s;
1591
+ e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
1407
1592
  })();
1408
- }(Ce)), Ce.exports;
1593
+ }(Ee)), Ee.exports;
1409
1594
  }
1410
- var vt = bt();
1411
- const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__ */ t("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ t(
1595
+ var kt = Lt();
1596
+ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__ */ t("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ t(
1412
1597
  "hr",
1413
1598
  {
1414
1599
  style: {
@@ -1419,36 +1604,36 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
1419
1604
  }
1420
1605
  }
1421
1606
  ) }) : e.data.icon ? /* @__PURE__ */ d("div", { className: "d-flex align-items-center", children: [
1422
- /* @__PURE__ */ t(Le.Option, { ...e }),
1607
+ /* @__PURE__ */ t(Ae.Option, { ...e }),
1423
1608
  /* @__PURE__ */ t("span", { className: "px-1 template-studio-dropdown-postfix-icon", children: e.data.icon })
1424
- ] }) : /* @__PURE__ */ t(Le.Option, { ...e }), wt = ({
1609
+ ] }) : /* @__PURE__ */ t(Ae.Option, { ...e }), It = ({
1425
1610
  name: e = "",
1426
1611
  control: n,
1427
- options: s,
1612
+ options: r,
1428
1613
  multiple: a = !1,
1429
1614
  placeholder: i,
1430
- validation: r,
1615
+ validation: s,
1431
1616
  labelKey: l = "name",
1432
- disabled: c,
1433
- isInvalid: o,
1434
- value: w,
1435
- onChange: f,
1436
- uncontrolled: C,
1437
- menuPlacement: g = "auto",
1438
- closeOnSelect: S = !0
1617
+ disabled: o,
1618
+ isInvalid: c,
1619
+ value: v,
1620
+ onChange: E,
1621
+ uncontrolled: I,
1622
+ menuPlacement: b = "auto",
1623
+ closeOnSelect: x = !0
1439
1624
  }) => {
1440
- const A = {
1441
- control: (h) => ({
1442
- ...h,
1625
+ const u = {
1626
+ control: (p) => ({
1627
+ ...p,
1443
1628
  minHeight: "33px",
1444
1629
  // state.isFocused can display different borderColor if you need it
1445
- borderColor: o ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
1446
- backgroundImage: o ? 'url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27 width=%2712%27 height=%2712%27 fill=%27none%27 stroke=%27%23fa5c7c%27%3e%3ccircle cx=%276%27 cy=%276%27 r=%274.5%27/%3e%3cpath stroke-linejoin=%27round%27 d=%27M5.8 3.6h.4L6 6.5z%27/%3e%3ccircle cx=%276%27 cy=%278.2%27 r=%27.6%27 fill=%27%23fa5c7c%27 stroke=%27none%27/%3e%3c/svg%3e")' : "none",
1630
+ borderColor: c ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
1631
+ backgroundImage: c ? 'url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27 width=%2712%27 height=%2712%27 fill=%27none%27 stroke=%27%23fa5c7c%27%3e%3ccircle cx=%276%27 cy=%276%27 r=%274.5%27/%3e%3cpath stroke-linejoin=%27round%27 d=%27M5.8 3.6h.4L6 6.5z%27/%3e%3ccircle cx=%276%27 cy=%278.2%27 r=%27.6%27 fill=%27%23fa5c7c%27 stroke=%27none%27/%3e%3c/svg%3e")' : "none",
1447
1632
  backgroundRepeat: "no-repeat",
1448
1633
  backgroundPosition: "right calc(0.375em + 0.225rem) center",
1449
1634
  backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
1450
1635
  "&:hover": {
1451
- borderColor: o ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
1636
+ borderColor: c ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
1452
1637
  },
1453
1638
  "& .react-select__single-value": {
1454
1639
  color: "var(--ct-input-color) !important"
@@ -1460,416 +1645,342 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
1460
1645
  display: "none"
1461
1646
  }
1462
1647
  }),
1463
- menu: (h) => ({
1464
- ...h,
1648
+ menu: (p) => ({
1649
+ ...p,
1465
1650
  marginTop: 0,
1466
1651
  width: "max-content",
1467
1652
  minWidth: "100%"
1468
1653
  }),
1469
- menuPortal: (h) => ({
1470
- ...h,
1654
+ menuPortal: (p) => ({
1655
+ ...p,
1471
1656
  zIndex: 1e4
1472
1657
  }),
1473
- multiValueRemove: (h) => ({
1474
- ...h,
1475
- display: c ? "none" : "block"
1658
+ multiValueRemove: (p) => ({
1659
+ ...p,
1660
+ display: o ? "none" : "block"
1476
1661
  })
1477
1662
  };
1478
- return C ? /* @__PURE__ */ t(
1479
- Ie,
1663
+ return I ? /* @__PURE__ */ t(
1664
+ $e,
1480
1665
  {
1481
- components: { Option: _e },
1482
- isOptionDisabled: (h) => !!h.isSeparator,
1483
- className: Ae({
1484
- "is-invalid": o
1666
+ components: { Option: Be },
1667
+ isOptionDisabled: (p) => !!p.isSeparator,
1668
+ className: Re({
1669
+ "is-invalid": c
1485
1670
  }),
1486
- styles: A,
1671
+ styles: u,
1487
1672
  classNamePrefix: "react-select",
1488
1673
  isMulti: a,
1489
- options: s,
1490
- onChange: f,
1674
+ options: r,
1675
+ onChange: E,
1491
1676
  placeholder: i,
1492
1677
  menuPortalTarget: document.body,
1493
- value: w,
1494
- getOptionLabel: typeof l == "string" ? (h) => h[l] : l,
1495
- getOptionValue: (h) => h.id,
1496
- isDisabled: c,
1497
- menuPlacement: g,
1498
- closeMenuOnSelect: S
1678
+ value: v,
1679
+ getOptionLabel: typeof l == "string" ? (p) => p[l] : l,
1680
+ getOptionValue: (p) => p.id,
1681
+ isDisabled: o,
1682
+ menuPlacement: b,
1683
+ closeMenuOnSelect: x
1499
1684
  }
1500
1685
  ) : /* @__PURE__ */ t(
1501
- Ke,
1686
+ Xe,
1502
1687
  {
1503
1688
  control: n,
1504
1689
  name: e,
1505
- rules: r,
1506
- render: ({ field: { onChange: h, value: y, onBlur: b } }) => /* @__PURE__ */ t(
1507
- Ie,
1690
+ rules: s,
1691
+ render: ({ field: { onChange: p, value: w, onBlur: h } }) => /* @__PURE__ */ t(
1692
+ $e,
1508
1693
  {
1509
- components: { Option: _e },
1510
- isOptionDisabled: (m) => !!m.isSeparator,
1511
- className: Ae({
1512
- "is-invalid": o
1694
+ components: { Option: Be },
1695
+ isOptionDisabled: (y) => !!y.isSeparator,
1696
+ className: Re({
1697
+ "is-invalid": c
1513
1698
  }),
1514
- styles: A,
1699
+ styles: u,
1515
1700
  classNamePrefix: "react-select",
1516
1701
  isMulti: a,
1517
- options: s,
1518
- onBlur: b,
1519
- onChange: h,
1702
+ options: r,
1703
+ onBlur: h,
1704
+ onChange: p,
1520
1705
  placeholder: i,
1521
1706
  menuPortalTarget: document.body,
1522
- value: y,
1523
- getOptionLabel: typeof l == "string" ? (m) => m[l] : l,
1524
- getOptionValue: (m) => m.id,
1525
- isDisabled: c,
1526
- menuPlacement: g,
1527
- closeMenuOnSelect: S
1707
+ value: w,
1708
+ getOptionLabel: typeof l == "string" ? (y) => y[l] : l,
1709
+ getOptionValue: (y) => y.id,
1710
+ isDisabled: o,
1711
+ menuPlacement: b,
1712
+ closeMenuOnSelect: x
1528
1713
  },
1529
- y ? y.id || y.value || JSON.stringify(y) : "reset"
1714
+ w ? w.id || w.value || JSON.stringify(w) : "reset"
1530
1715
  )
1531
1716
  }
1532
1717
  );
1533
- }, me = ({
1718
+ }, fe = ({
1534
1719
  label: e,
1535
1720
  name: n,
1536
- validation: s,
1721
+ validation: r,
1537
1722
  control: a,
1538
1723
  error: i,
1539
- options: r = [],
1724
+ options: s = [],
1540
1725
  required: l = !1,
1541
- disabled: c = !1,
1542
- className: o = ""
1726
+ disabled: o = !1,
1727
+ className: c = ""
1543
1728
  }) => {
1544
- const w = !!(i && i[n]);
1545
- return /* @__PURE__ */ d("div", { className: `ts-form-group ${o}`, children: [
1729
+ const v = !!(i && i[n]);
1730
+ return /* @__PURE__ */ d("div", { className: `ts-form-group ${c}`, children: [
1546
1731
  e && /* @__PURE__ */ d("label", { className: "ts-form-label", children: [
1547
1732
  e,
1548
1733
  l && /* @__PURE__ */ t("span", { className: "ts-required", children: "*" })
1549
1734
  ] }),
1550
1735
  /* @__PURE__ */ t(
1551
- wt,
1736
+ It,
1552
1737
  {
1553
1738
  name: n,
1554
1739
  control: a,
1555
- options: r,
1556
- validation: s,
1557
- disabled: c,
1558
- isInvalid: w
1740
+ options: s,
1741
+ validation: r,
1742
+ disabled: o,
1743
+ isInvalid: v
1559
1744
  }
1560
1745
  ),
1561
- w && /* @__PURE__ */ t("div", { className: "ts-error-text", children: i?.[n]?.message })
1746
+ v && /* @__PURE__ */ t("div", { className: "ts-error-text", children: i?.[n]?.message })
1562
1747
  ] });
1563
- }, Tt = () => {
1564
- const e = z();
1565
- Ve();
1566
- const { enerexIdentifier: n, projectId: s } = H();
1567
- return oe({
1748
+ }, Dt = () => {
1749
+ const e = Y();
1750
+ Ye();
1751
+ const { enerexIdentifier: n, projectId: r } = V();
1752
+ return ce({
1568
1753
  mutationKey: ["saveTemplate"],
1569
- mutationFn: async (i) => (i.enerexIdentifier = n ?? "", i.projectId = s ?? "", await e.post(
1754
+ mutationFn: async (i) => (i.enerexIdentifier = n ?? "", i.projectId = r ?? "", await e.post(
1570
1755
  `${Q.SaveTemplate}`,
1571
1756
  i
1572
1757
  ))
1573
1758
  });
1574
- }, xe = (e) => {
1575
- let n = /* @__PURE__ */ t(
1576
- "span",
1577
- {
1578
- style: { width: "20px", height: "20px", display: "inline-block" }
1579
- }
1580
- );
1581
- return e.variant === "filled" ? n = /* @__PURE__ */ t(
1582
- "svg",
1583
- {
1584
- version: "1.0",
1585
- id: "Layer_1",
1586
- xmlns: "http://www.w3.org/2000/svg",
1587
- width: "20px",
1588
- height: "20px",
1589
- viewBox: "0 0 64 64",
1590
- "enable-background": "new 0 0 64 64",
1591
- children: /* @__PURE__ */ t(
1592
- "path",
1593
- {
1594
- fill: "#2196F3",
1595
- d: `M63.893,24.277c-0.238-0.711-0.854-1.229-1.595-1.343l-19.674-3.006L33.809,1.15\r
1596
- C33.479,0.448,32.773,0,31.998,0s-1.48,0.448-1.811,1.15l-8.815,18.778L1.698,22.935c-0.741,0.113-1.356,0.632-1.595,1.343\r
1597
- c-0.238,0.71-0.059,1.494,0.465,2.031l14.294,14.657L11.484,61.67c-0.124,0.756,0.195,1.517,0.822,1.957\r
1598
- c0.344,0.243,0.747,0.366,1.151,0.366c0.332,0,0.666-0.084,0.968-0.25l17.572-9.719l17.572,9.719c0.302,0.166,0.636,0.25,0.968,0.25\r
1599
- c0.404,0,0.808-0.123,1.151-0.366c0.627-0.44,0.946-1.201,0.822-1.957l-3.378-20.704l14.294-14.657\r
1600
- C63.951,25.771,64.131,24.987,63.893,24.277z`
1601
- }
1602
- )
1603
- }
1604
- ) : e.variant === "outlined" && (n = /* @__PURE__ */ t(
1605
- "svg",
1606
- {
1607
- version: "1.0",
1608
- id: "Layer_1",
1609
- xmlns: "http://www.w3.org/2000/svg",
1610
- width: "20px",
1611
- height: "20px",
1612
- viewBox: "0 0 64 64",
1613
- enableBackground: "new 0 0 64 64",
1614
- children: /* @__PURE__ */ t(
1615
- "path",
1616
- {
1617
- fill: e.fill || "rgba(247, 216, 40, 0)",
1618
- stroke: e.stroke || "#000000",
1619
- strokeWidth: e.strokeWidth || "2",
1620
- d: `M63.893,24.277c-0.238-0.711-0.854-1.229-1.595-1.343l-19.674-3.006L33.809,1.15\r
1621
- C33.479,0.448,32.773,0,31.998,0s-1.48,0.448-1.811,1.15l-8.815,18.778L1.698,22.935c-0.741,0.113-1.356,0.632-1.595,1.343\r
1622
- c-0.238,0.71-0.059,1.494,0.465,2.031l14.294,14.657L11.484,61.67c-0.124,0.756,0.195,1.517,0.822,1.957\r
1623
- c0.344,0.243,0.747,0.366,1.151,0.366c0.332,0,0.666-0.084,0.968-0.25l17.572-9.719l17.572,9.719c0.302,0.166,0.636,0.25,0.968,0.25\r
1624
- c0.404,0,0.808-0.123,1.151-0.366c0.627-0.44,0.946-1.201,0.822-1.957l-3.378-20.704l14.294-14.657\r
1625
- C63.951,25.771,64.131,24.987,63.893,24.277z`
1626
- }
1627
- )
1628
- }
1629
- )), n;
1630
- }, Nt = {
1759
+ }, Pt = {
1631
1760
  id: "",
1632
1761
  name: "New (Blank)"
1633
- }, Ct = ({
1762
+ }, $t = ({
1634
1763
  onReset: e,
1635
1764
  editorInitialized: n,
1636
- mode: s,
1765
+ mode: r,
1637
1766
  templateTypes: a,
1638
1767
  templateList: i,
1639
- template: r,
1768
+ template: s,
1640
1769
  onRefresh: l,
1641
- closeEditorModal: c
1770
+ closeEditorModal: o
1642
1771
  }) => {
1643
- const { defaultSelector: o, isAdmin: w, userEmail: f } = H(), { mutateAsync: C, isPending: g } = yt(), {
1644
- register: S,
1645
- handleSubmit: A,
1646
- clearErrors: h,
1647
- setValue: y,
1648
- control: b,
1649
- watch: m,
1650
- reset: v,
1651
- setError: x,
1652
- formState: { errors: T }
1653
- } = Ge({
1772
+ const { defaultSelector: c, isAdmin: v, userEmail: E } = V(), { mutateAsync: I, isPending: b } = Ue(), {
1773
+ register: x,
1774
+ handleSubmit: u,
1775
+ clearErrors: p,
1776
+ setValue: w,
1777
+ control: h,
1778
+ watch: y,
1779
+ reset: g,
1780
+ setError: R,
1781
+ formState: { errors: B }
1782
+ } = Je({
1654
1783
  defaultValues: {
1655
1784
  templateName: "",
1656
1785
  subTemplateType: void 0,
1657
1786
  subTemplateType2: void 0,
1658
1787
  subject: "",
1659
1788
  templateType: void 0,
1660
- template: Nt
1789
+ template: Pt
1661
1790
  },
1662
1791
  mode: "onChange"
1663
- }), [k, O] = N([]), [M, F] = N(), { mutateAsync: I, isPending: D } = Tt(), [B, ce] = N([]), [j, G] = N([]), [V, ee] = N([]), [he, te] = N(!1), ne = Z(!1), { showNotification: Y } = Re(), K = s === "edit", ie = he || D || g || !n;
1664
- P(() => {
1792
+ }), [_, A] = C([]), [S, D] = C(), { mutateAsync: M, isPending: T } = Dt(), [ne, U] = C([]), [W, K] = C([]), [O, re] = C([]), [le, de] = C(!1), Z = te(!1), { showNotification: se } = ve(), H = r === "edit", ue = le || T || b || !n;
1793
+ L(() => {
1665
1794
  if (a) {
1666
- let u = a.filter((_) => _.id != null), E = Ne(u, 0);
1667
- ce(Te(E));
1795
+ let f = a.filter((F) => F.id != null), k = Ne(f, 0);
1796
+ U(Te(k));
1668
1797
  }
1669
- }, [a]), P(() => {
1670
- s === "edit" && !ne.current && te(!0);
1671
- }, [s]), P(() => {
1672
- if (s !== "edit" || !r || !n || !a.length || !k.length || ne.current) return;
1673
- const u = k.find((U) => U.id === r.templateID);
1674
- if (!u) return;
1675
- const E = a.filter((U) => U.id != null), _ = E.find((U) => `${U.id}` == `${u.type}`), q = _ ? E.find((U) => `${U.id}` == `${_.parent_id}`) : void 0, X = q ? E.find((U) => `${U.id}` == `${q.parent_id}`) : void 0;
1676
- v({
1677
- templateType: X ? re(X) : void 0,
1678
- subTemplateType: q ? re(q) : void 0,
1679
- subTemplateType2: _ ? re(_) : void 0,
1680
- template: u,
1681
- templateName: r.name ?? "",
1682
- subject: r.subject ?? ""
1683
- }), F(u), ne.current = !0, te(!1);
1684
- }, [s, r, n, a, k, v]);
1685
- const re = (u) => ({
1686
- id: String(u.id),
1687
- name: u.name,
1688
- key: u.key
1798
+ }, [a]), L(() => {
1799
+ r === "edit" && !Z.current && de(!0);
1800
+ }, [r]), L(() => {
1801
+ if (r !== "edit" || !s || !n || !a.length || !_.length || Z.current) return;
1802
+ const f = _.find((q) => q.id === s.templateID);
1803
+ if (!f) return;
1804
+ const k = a.filter((q) => q.id != null), F = k.find((q) => `${q.id}` == `${f.type}`), j = F ? k.find((q) => `${q.id}` == `${F.parent_id}`) : void 0, X = j ? k.find((q) => `${q.id}` == `${j.parent_id}`) : void 0;
1805
+ g({
1806
+ templateType: X ? ee(X) : void 0,
1807
+ subTemplateType: j ? ee(j) : void 0,
1808
+ subTemplateType2: F ? ee(F) : void 0,
1809
+ template: f,
1810
+ templateName: s.name ?? "",
1811
+ subject: s.subject ?? ""
1812
+ }), D(f), Z.current = !0, de(!1);
1813
+ }, [r, s, n, a, _, g]);
1814
+ const ee = (f) => ({
1815
+ id: String(f.id),
1816
+ name: f.name,
1817
+ key: f.key
1689
1818
  });
1690
- P(() => {
1691
- i?.sort((u, E) => u.readonly !== E.readonly ? (u.readonly ? 0 : 1) - (E.readonly ? 0 : 1) : u.name.localeCompare(E.name)), O(i ?? []);
1692
- }, [i]), P(() => {
1693
- if (!m("templateType")) return;
1694
- const u = Ne(a, 1);
1695
- G(
1819
+ L(() => {
1820
+ i?.sort((f, k) => f.readonly !== k.readonly ? (f.readonly ? 0 : 1) - (k.readonly ? 0 : 1) : f.name.localeCompare(k.name)), A(i ?? []);
1821
+ }, [i]), L(() => {
1822
+ if (!y("templateType")) return;
1823
+ const f = Ne(a, 1);
1824
+ K(
1696
1825
  Te(
1697
- u.filter((E) => `${E.parent_id}` == `${m("templateType")?.id}`)
1826
+ f.filter((k) => `${k.parent_id}` == `${y("templateType")?.id}`)
1698
1827
  )
1828
+ ), w("subTemplateType", void 0), w("subTemplateType2", void 0);
1829
+ }, [y("templateType"), a]), L(() => {
1830
+ const f = y("subTemplateType");
1831
+ if (!f) return;
1832
+ const k = Ne(a, 2);
1833
+ let F = Te(
1834
+ k.filter((j) => `${j.parent_id}` == `${f.id}`)
1699
1835
  );
1700
- }, [m("templateType"), a]), P(() => {
1701
- const u = m("subTemplateType");
1702
- if (!u) return;
1703
- const E = Ne(a, 2);
1704
- let _ = Te(
1705
- E.filter((q) => `${q.parent_id}` == `${u.id}`)
1706
- );
1707
- s !== "edit" && !w && (_ = _.filter((q) => q.key !== 2)), console.log(_), ee(_);
1708
- }, [m("subTemplateType"), a, s]), P(() => {
1709
- if (o && o.type1) {
1710
- const u = B?.find(
1711
- (E) => `${E.id}` === o.type1
1836
+ r !== "edit" && !v && (F = F.filter((j) => j.key !== 2)), re(F), w("subTemplateType2", void 0);
1837
+ }, [y("subTemplateType"), a, r]), L(() => {
1838
+ if (c && c.type1) {
1839
+ const f = ne?.find(
1840
+ (k) => `${k.id}` === c.type1
1712
1841
  );
1713
- y("templateType", u);
1842
+ w("templateType", f);
1714
1843
  }
1715
- }, [a, B]), P(() => {
1716
- if (o && o.type2) {
1717
- const u = j?.find(
1718
- (E) => `${E.id}` === o.type2
1844
+ }, [a, ne]), L(() => {
1845
+ if (c && c.type2) {
1846
+ const f = W?.find(
1847
+ (k) => `${k.id}` === c.type2
1719
1848
  );
1720
- y("subTemplateType", u);
1849
+ w("subTemplateType", f);
1721
1850
  }
1722
- }, [a, j]), P(() => {
1723
- if (o && o.type3) {
1724
- const u = V?.find(
1725
- (E) => `${E.id}` === o.type3
1851
+ }, [a, W]), L(() => {
1852
+ if (c && c.type3) {
1853
+ const f = O?.find(
1854
+ (k) => `${k.id}` === c.type3
1726
1855
  );
1727
- y("subTemplateType2", u);
1856
+ w("subTemplateType2", f);
1728
1857
  }
1729
- }, [a, V]);
1730
- const de = (u) => {
1858
+ }, [a, O]);
1859
+ const me = (f) => {
1731
1860
  window.StripoEditorApi.actionsApi.getTemplateData(
1732
- async (E) => {
1861
+ async (k) => {
1733
1862
  try {
1734
- let _ = u.template.id, q = "";
1735
- const X = u.templateName.trim();
1736
- M?.readonly && (_ = "", q = u.template.id);
1737
- const U = k.find(
1738
- ($) => $.name === u.templateName.trim()
1863
+ let F = f.template.id, j = "";
1864
+ const X = f.templateName.trim(), q = _.find(
1865
+ (N) => N.name === f.templateName.trim()
1739
1866
  );
1740
- if (U && U.id !== _) {
1741
- x("templateName", {
1867
+ if (q && q?.id !== f.template.id) {
1868
+ R("templateName", {
1742
1869
  type: "validate",
1743
1870
  message: "Template name already exists. Please choose a different name."
1744
1871
  });
1745
1872
  return;
1746
1873
  }
1747
- let p = u.templateType.id;
1748
- V?.length > 0 ? p = u.subTemplateType2.id : j?.length > 0 && (p = u.subTemplateType.id);
1749
- const L = {
1874
+ let oe = f.templateType.id;
1875
+ O?.length > 0 ? oe = f.subTemplateType2.id : W?.length > 0 && (oe = f.subTemplateType.id);
1876
+ const Ie = {
1750
1877
  enerexIdentifier: "",
1751
1878
  projectId: "",
1752
- templateId: _,
1753
- templateType: p,
1879
+ templateId: F,
1880
+ templateType: oe,
1754
1881
  name: X,
1755
- html: E.html,
1756
- css: E.css,
1757
- subject: u.templateType.id === "2" ? u?.subject ?? "" : "",
1758
- parent_id: q,
1759
- updatedBy: f ?? ""
1882
+ html: k.html,
1883
+ css: k.css,
1884
+ subject: f.templateType.id === "2" ? f?.subject ?? "" : "",
1885
+ parent_id: j,
1886
+ updatedBy: E ?? ""
1760
1887
  };
1761
- if (!await I(L)) {
1762
- Y(
1888
+ if (!await M(Ie)) {
1889
+ se(
1763
1890
  "Failed to save template. Please try again.",
1764
1891
  "error"
1765
1892
  );
1766
1893
  return;
1767
1894
  }
1768
- Y(
1769
- K ? `Template "${X}" updated successfully.` : `Template "${X}" created successfully.`,
1895
+ se(
1896
+ H ? `Template "${X}" updated successfully.` : `Template "${X}" created successfully.`,
1770
1897
  "success"
1771
- ), h(), l(), c();
1772
- } catch (_) {
1773
- console.error(_), Y(
1898
+ ), p(), l(), o();
1899
+ } catch (F) {
1900
+ console.error(F), se(
1774
1901
  "Something went wrong while saving the template.",
1775
1902
  "error"
1776
1903
  );
1777
1904
  }
1778
1905
  }
1779
1906
  );
1780
- }, ye = async () => {
1781
- try {
1782
- let u = m("templateType")?.id;
1783
- V && V.length > 0 ? u = m("subTemplateType2")?.id : j && j.length > 0 && (u = m("subTemplateType")?.id), await C({
1784
- categoryId: u ?? "",
1785
- templateId: m("template")?.id ?? ""
1786
- }), M && F({
1787
- ...M,
1788
- is_favourite: !0
1789
- }), Y("Template marked as favourite", "success"), l();
1790
- } catch (u) {
1791
- console.error("Mark favourite failed", u), Y(
1792
- "Unable to mark template as favourite. Please try again.",
1793
- "error"
1794
- );
1795
- }
1796
- }, le = m("templateType"), ge = m("subTemplateType");
1797
- return /* @__PURE__ */ d(pe, { children: [
1798
- ie && /* @__PURE__ */ t(ae, { overlay: !0 }),
1907
+ }, pe = y("templateType"), be = y("subTemplateType");
1908
+ return /* @__PURE__ */ d(ye, { children: [
1909
+ ue && /* @__PURE__ */ t(ie, { overlay: !0 }),
1799
1910
  /* @__PURE__ */ t("div", { className: "ts-card", children: /* @__PURE__ */ t("div", { className: "ts-card-body", children: /* @__PURE__ */ t("form", { children: /* @__PURE__ */ t("div", { className: "template-list-container", children: /* @__PURE__ */ d("div", { className: "ts-row", children: [
1800
1911
  /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1801
- me,
1912
+ fe,
1802
1913
  {
1803
1914
  label: "Category",
1804
- control: b,
1805
- error: T,
1806
- options: B,
1915
+ control: h,
1916
+ error: B,
1917
+ options: ne,
1807
1918
  required: !0,
1808
- disabled: K || D || g || !n,
1919
+ disabled: H || T || b || !n,
1809
1920
  validation: {
1810
1921
  required: {
1811
1922
  value: !0,
1812
1923
  message: "Select a category"
1813
1924
  }
1814
1925
  },
1815
- ...S("templateType")
1926
+ ...x("templateType")
1816
1927
  }
1817
1928
  ) }),
1818
- j && j.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1819
- me,
1929
+ W && W.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1930
+ fe,
1820
1931
  {
1821
1932
  label: "Type",
1822
- control: b,
1823
- error: T,
1824
- options: j,
1933
+ control: h,
1934
+ error: B,
1935
+ options: W,
1825
1936
  required: !0,
1826
- disabled: K || D || g || !n,
1937
+ disabled: H || T || b || !n,
1827
1938
  validation: {
1828
1939
  required: {
1829
1940
  value: !0,
1830
1941
  message: "Select a type"
1831
1942
  }
1832
1943
  },
1833
- ...S("subTemplateType")
1944
+ ...x("subTemplateType")
1834
1945
  }
1835
1946
  ) }),
1836
- V && V.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1837
- me,
1947
+ O && O.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1948
+ fe,
1838
1949
  {
1839
1950
  label: "Sub Type",
1840
- control: b,
1841
- error: T,
1842
- options: V,
1951
+ control: h,
1952
+ error: B,
1953
+ options: O,
1843
1954
  required: !0,
1844
- disabled: K || D || g || !n,
1955
+ disabled: H || T || b || !n,
1845
1956
  validation: {
1846
1957
  required: {
1847
1958
  value: !0,
1848
1959
  message: "Select a subtype"
1849
1960
  }
1850
1961
  },
1851
- ...S("subTemplateType2")
1962
+ ...x("subTemplateType2")
1852
1963
  }
1853
1964
  ) }),
1854
1965
  /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1855
- me,
1966
+ fe,
1856
1967
  {
1857
1968
  label: "Template",
1858
- control: b,
1859
- error: T,
1860
- disabled: K || !K || D || g || !n,
1969
+ control: h,
1970
+ error: B,
1971
+ disabled: H || !H || T || b || !n,
1861
1972
  options: [],
1862
1973
  required: !1,
1863
- ...S("template")
1974
+ ...x("template")
1864
1975
  }
1865
1976
  ) }),
1866
1977
  /* @__PURE__ */ d("div", { className: "ts-col ts-template-name-col", children: [
1867
1978
  /* @__PURE__ */ t(
1868
- Pe,
1979
+ Me,
1869
1980
  {
1870
1981
  label: "Name",
1871
- register: S,
1872
- error: T,
1982
+ register: x,
1983
+ error: B,
1873
1984
  required: !0,
1874
1985
  name: "templateName",
1875
1986
  validation: {
@@ -1880,86 +1991,77 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
1880
1991
  }
1881
1992
  }
1882
1993
  ),
1883
- ge?.key?.toString() === "9" && K && /* @__PURE__ */ t(
1884
- "button",
1885
- {
1886
- type: "button",
1887
- className: "template-favourite-btn ts-btn-light",
1888
- disabled: D || g || (M ? M?.is_favourite : !1),
1889
- onClick: ye,
1890
- children: D || g ? /* @__PURE__ */ t(ae, { size: "sm" }) : M ? M?.is_favourite ? /* @__PURE__ */ t(xe, { variant: "filled" }) : /* @__PURE__ */ t(xe, { variant: "outlined" }) : /* @__PURE__ */ t(xe, { variant: "outlined" })
1891
- }
1892
- )
1994
+ be?.key?.toString() === "9" && H && !v && S?.is_favourite && /* @__PURE__ */ t("span", { className: "ts-favourite-icon", children: /* @__PURE__ */ t(Le, { variant: "filled" }) })
1893
1995
  ] }),
1894
- le?.key?.toString() === "12" && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1895
- Pe,
1996
+ pe?.key?.toString() === "12" && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1997
+ Me,
1896
1998
  {
1897
1999
  label: "Subject",
1898
- register: S,
1899
- error: T,
2000
+ register: x,
2001
+ error: B,
1900
2002
  required: !1,
1901
2003
  name: "subject"
1902
2004
  }
1903
2005
  ) }),
1904
2006
  /* @__PURE__ */ d("div", { className: "ts-col ts-actions btn-padding", children: [
1905
- !K && /* @__PURE__ */ t(
2007
+ !H && /* @__PURE__ */ t(
1906
2008
  "button",
1907
2009
  {
1908
2010
  type: "button",
1909
2011
  className: "ts-btn ts-btn-primary",
1910
- disabled: D || g || !n,
2012
+ disabled: T || b || !n,
1911
2013
  onClick: () => {
1912
- F(void 0), v(), G([]), ee([]), e();
2014
+ D(void 0), g(), K([]), re([]), e();
1913
2015
  },
1914
- children: D || g ? /* @__PURE__ */ t(ae, { size: "sm" }) : "Clear"
2016
+ children: T || b ? /* @__PURE__ */ t(ie, { size: "sm" }) : "Clear"
1915
2017
  }
1916
2018
  ),
1917
- (le?.key?.toString() !== "12" || (le?.key?.toString() === "12" && (M?.id ?? "")) !== "") && /* @__PURE__ */ t(
2019
+ /* @__PURE__ */ t(
1918
2020
  "button",
1919
2021
  {
1920
2022
  type: "button",
1921
2023
  className: "ts-btn ts-btn-primary",
1922
- disabled: D || g || !n,
1923
- onClick: A(de),
1924
- children: D || g ? (
2024
+ disabled: T || b || !n,
2025
+ onClick: u(me),
2026
+ children: T || b ? (
1925
2027
  // <span className="ts-spinner" />
1926
- /* @__PURE__ */ t(ae, { size: "sm" })
2028
+ /* @__PURE__ */ t(ie, { size: "sm" })
1927
2029
  ) : "Save"
1928
2030
  }
1929
2031
  )
1930
2032
  ] })
1931
2033
  ] }) }) }) }) })
1932
2034
  ] });
1933
- }, xt = ({
2035
+ }, At = (e) => /* @__PURE__ */ t("svg", { xmlns: "http://www.w3.org/2000/svg", height: "20px", width: "20px", viewBox: "0 0 640 640", ...e, children: /* @__PURE__ */ t("path", { fill: "#6c757d", d: "M560 144L240 144L240 176L192 176L192 96L608 96L608 416L496 416L496 368L560 368L560 144zM80 352L80 496L400 496L400 352L80 352zM80 224L448 224L448 544L32 544L32 224L80 224z" }) }), Mt = (e) => /* @__PURE__ */ t("svg", { xmlns: "http://www.w3.org/2000/svg", height: "20px", width: "20px", viewBox: "0 0 640 640", ...e, children: /* @__PURE__ */ t("path", { fill: "#6c757d", d: "M112 288L112 464L528 464L528 288L112 288zM64 128L576 128L576 512L64 512L64 128z" }) }), _t = ({
1934
2036
  show: e,
1935
2037
  mode: n,
1936
- template: s,
2038
+ template: r,
1937
2039
  templateTypes: a,
1938
2040
  templateList: i,
1939
- editorInitialized: r,
2041
+ editorInitialized: s,
1940
2042
  previewHtml: l,
1941
- onEditorInitialized: c,
1942
- onClose: o,
1943
- onRefresh: w
2043
+ onEditorInitialized: o,
2044
+ onClose: c,
2045
+ onRefresh: v
1944
2046
  }) => {
1945
- const f = Z(null), [C, g] = N(!1);
1946
- P(() => {
1947
- e && r && window.StripoEditorApi?.actionsApi && (n === "add" ? window.StripoEditorApi.actionsApi.updateHtmlAndCss(ue, "", "") : n === "edit" && s && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
1948
- s.html ?? ue,
1949
- s.css ?? "",
2047
+ const E = te(null), [I, b] = C(!1);
2048
+ L(() => {
2049
+ e && s && window.StripoEditorApi?.actionsApi && (n === "add" ? window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "") : n === "edit" && r && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
2050
+ r.html ?? he,
2051
+ r.css ?? "",
1950
2052
  ""
1951
2053
  ));
1952
- }, [e, r, n, s]), P(() => {
1953
- e || g(!1);
2054
+ }, [e, s, n, r]), L(() => {
2055
+ e || b(!1);
1954
2056
  }, [e]);
1955
- const S = () => {
1956
- window.StripoEditorApi.actionsApi.updateHtmlAndCss(ue, "", "");
2057
+ const x = () => {
2058
+ window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "");
1957
2059
  };
1958
2060
  return e ? /* @__PURE__ */ t("div", { className: "ts-editor-modal-overlay", children: /* @__PURE__ */ d(
1959
2061
  "div",
1960
2062
  {
1961
- className: `ts-editor-modal ${C ? "ts-editor-modal--fullscreen" : ""}`,
1962
- ref: f,
2063
+ className: `ts-editor-modal ${I ? "ts-editor-modal--fullscreen" : ""}`,
2064
+ ref: E,
1963
2065
  children: [
1964
2066
  /* @__PURE__ */ d("div", { className: "ts-editor-modal-header", children: [
1965
2067
  /* @__PURE__ */ d("h3", { className: "ts-modal-title", children: [
@@ -1972,16 +2074,16 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
1972
2074
  "button",
1973
2075
  {
1974
2076
  className: "ts-editor-fullscreen-btn",
1975
- onClick: () => g((A) => !A),
2077
+ onClick: () => b((u) => !u),
1976
2078
  "aria-label": "Toggle fullscreen",
1977
- children: C ? "🗗" : "🗖"
2079
+ children: I ? /* @__PURE__ */ t(At, { style: { display: "block" } }) : /* @__PURE__ */ t(Mt, { style: { display: "block" } })
1978
2080
  }
1979
2081
  ),
1980
2082
  /* @__PURE__ */ t(
1981
2083
  "button",
1982
2084
  {
1983
2085
  className: "ts-editor-close-btn",
1984
- onClick: o,
2086
+ onClick: c,
1985
2087
  "aria-label": "Close editor",
1986
2088
  children: "✕"
1987
2089
  }
@@ -1990,16 +2092,16 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
1990
2092
  ] }),
1991
2093
  /* @__PURE__ */ d("div", { className: "ts-editor-modal-body", children: [
1992
2094
  n !== "preview" && /* @__PURE__ */ t(
1993
- Ct,
2095
+ $t,
1994
2096
  {
1995
2097
  mode: n,
1996
- template: s,
2098
+ template: r,
1997
2099
  templateTypes: a,
1998
2100
  templateList: i,
1999
- editorInitialized: r,
2000
- onReset: S,
2001
- onRefresh: w,
2002
- closeEditorModal: o
2101
+ editorInitialized: s,
2102
+ onReset: x,
2103
+ onRefresh: v,
2104
+ closeEditorModal: c
2003
2105
  }
2004
2106
  ),
2005
2107
  n === "preview" ? /* @__PURE__ */ t("div", { className: "ts-template-preview", children: /* @__PURE__ */ t(
@@ -2010,9 +2112,9 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
2010
2112
  srcDoc: l ?? ""
2011
2113
  }
2012
2114
  ) }) : /* @__PURE__ */ t(
2013
- ft,
2115
+ Et,
2014
2116
  {
2015
- onEditorInitialized: c,
2117
+ onEditorInitialized: o,
2016
2118
  loading: !1,
2017
2119
  className: "editor-container"
2018
2120
  }
@@ -2021,61 +2123,61 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
2021
2123
  ]
2022
2124
  }
2023
2125
  ) }) : null;
2024
- }, Et = () => {
2126
+ }, Rt = () => {
2025
2127
  const {
2026
2128
  data: e,
2027
2129
  isLoading: n,
2028
- isFetching: s,
2130
+ isFetching: r,
2029
2131
  refetch: a
2030
- } = Ze(), {
2132
+ } = at(), {
2031
2133
  data: i,
2032
- isLoading: r,
2134
+ isLoading: s,
2033
2135
  isFetching: l
2034
- } = et(), { mutateAsync: c, isPending: o } = tt(), [w, f] = N(!1), [C, g] = N("add"), [S, A] = N(!1), [h, y] = N(""), [b, m] = N(), v = () => {
2035
- g("add"), f(!0);
2036
- }, x = async (M) => {
2037
- const F = await c({ id: M.id });
2038
- m({ ...F }), g("edit"), f(!0);
2039
- }, T = (M) => {
2136
+ } = it(), { mutateAsync: o, isPending: c } = lt(), [v, E] = C(!1), [I, b] = C("add"), [x, u] = C(!1), [p, w] = C(""), [h, y] = C(), g = () => {
2137
+ b("add"), E(!0);
2138
+ }, R = async (S) => {
2139
+ const D = await o({ id: S.id });
2140
+ y({ ...D }), b("edit"), E(!0);
2141
+ }, B = (S) => {
2040
2142
  if (!e || e.length === 0) return;
2041
- const F = e.find((I) => I.id === M.id);
2042
- y(F?.html ?? ""), g("preview"), f(!0);
2043
- }, k = () => {
2044
- f(!1), A(!1), document.getElementById("UiEditorScript")?.remove();
2143
+ const D = e.find((M) => M.id === S.id);
2144
+ w(D?.html + "<style>" + D?.css + "</style>"), b("preview"), E(!0);
2145
+ }, _ = () => {
2146
+ E(!1), u(!1), document.getElementById("UiEditorScript")?.remove();
2045
2147
  };
2046
- return /* @__PURE__ */ d(pe, { children: [
2047
- (n || r || s || l || o) && /* @__PURE__ */ t(ae, { overlay: !0 }),
2148
+ return /* @__PURE__ */ d(ye, { children: [
2149
+ (n || s || r || l || c) && /* @__PURE__ */ t(ie, { overlay: !0 }),
2048
2150
  /* @__PURE__ */ t(
2049
- dt,
2151
+ Tt,
2050
2152
  {
2051
2153
  templates: e ?? [],
2052
2154
  templateTypes: i ?? [],
2053
2155
  onRefresh: a,
2054
- onAdd: v,
2055
- onEdit: x,
2056
- onPreview: T
2156
+ onAdd: g,
2157
+ onEdit: R,
2158
+ onPreview: B
2057
2159
  }
2058
2160
  ),
2059
2161
  /* @__PURE__ */ t(
2060
- xt,
2162
+ _t,
2061
2163
  {
2062
- show: w,
2063
- mode: C,
2064
- template: b,
2164
+ show: v,
2165
+ mode: I,
2166
+ template: h,
2065
2167
  templateTypes: i ?? [],
2066
2168
  templateList: e ?? [],
2067
- editorInitialized: S,
2068
- onEditorInitialized: A,
2069
- onClose: k,
2169
+ editorInitialized: x,
2170
+ onEditorInitialized: u,
2171
+ onClose: _,
2070
2172
  onSaved: () => {
2071
- k(), a();
2173
+ _(), a();
2072
2174
  },
2073
2175
  onRefresh: a,
2074
- previewHtml: h
2176
+ previewHtml: p
2075
2177
  }
2076
2178
  )
2077
2179
  ] });
2078
- }, _t = ({ config: e }) => /* @__PURE__ */ t(We, { configs: e, children: /* @__PURE__ */ t(Je, { children: /* @__PURE__ */ t(Xe, { children: /* @__PURE__ */ t("div", { className: "root-widget", children: /* @__PURE__ */ t(Et, {}) }) }) }) });
2180
+ }, Kt = ({ config: e }) => /* @__PURE__ */ t(Ze, { configs: e, children: /* @__PURE__ */ t(st, { children: /* @__PURE__ */ t(nt, { children: /* @__PURE__ */ t("div", { className: "root-widget", children: /* @__PURE__ */ t(Rt, {}) }) }) }) });
2079
2181
  export {
2080
- _t as EditorWidget
2182
+ Kt as EditorWidget
2081
2183
  };