@enerex/template-studio 1.1.38 → 1.1.39

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,11 +1,11 @@
1
- import { jsx as r, jsxs as S, Fragment as we } from "react/jsx-runtime";
2
- import k, { useContext as je, useState as v, useRef as We, useEffect as x } from "react";
3
- import { QueryClient as Ye, QueryClientProvider as ze, useQuery as le, useMutation as Le, useQueryClient as Je } from "@tanstack/react-query";
4
- import xe from "axios";
5
- import { Spinner as J, Form as F, Card as Se, Row as Xe, Col as H, Button as re } from "react-bootstrap";
6
- import { Controller as Ze, useForm as et } from "react-hook-form";
7
- import Ce, { components as tt } from "react-select";
8
- const ie = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
1
+ import { jsx as n, jsxs as S, Fragment as Ee } from "react/jsx-runtime";
2
+ import M, { useContext as qe, useState as w, useRef as st, useEffect as E } from "react";
3
+ import { QueryClient as it, QueryClientProvider as at, useQuery as ce, useMutation as Te, useQueryClient as lt } from "@tanstack/react-query";
4
+ import _e from "axios";
5
+ import { Spinner as z, Form as H, Card as ke, Row as ot, Col as U, Button as J } from "react-bootstrap";
6
+ import { Controller as dt, useForm as ct } from "react-hook-form";
7
+ import Ae, { components as Le } from "react-select";
8
+ const de = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
9
9
  <html\r
10
10
  dir="ltr"\r
11
11
  xmlns:o="urn:schemas-microsoft-com:office:office"\r
@@ -361,159 +361,160 @@ const ie = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http
361
361
  </div>\r
362
362
  </body>\r
363
363
  </html>\r
364
- `, Pe = k.createContext(
364
+ `, Re = M.createContext(
365
365
  void 0
366
- ), nt = ({
366
+ ), pt = ({
367
367
  children: t,
368
368
  configs: s
369
369
  }) => {
370
- const [o, l] = k.useState(s.clientId), [i, e] = k.useState(s.apiKey), [a, c] = k.useState(
370
+ const [l, a] = M.useState(s.clientId), [i, e] = M.useState(s.apiKey), [d, o] = M.useState(
371
371
  s.enerexIdentifier
372
- ), [T, g] = k.useState(s.projectId), [N, f] = k.useState(s.userEmail), [I, j] = k.useState(s.isAdmin), [L, y] = k.useState(s.meBaseUrl), [h, b] = k.useState(
372
+ ), [b, D] = M.useState(s.projectId), [A, m] = M.useState(s.userEmail), [_, u] = M.useState(s.isAdmin), [j, h] = M.useState(s.meBaseUrl), [v, y] = M.useState(
373
373
  s.defaultSelector
374
- ), p = (u) => {
375
- e(u.apiKey), l(u.clientId), g(u.projectId), c(u.enerexIdentifier), f(u.userEmail), j(u.isAdmin), b(u.defaultSelector), y(u.meBaseUrl);
374
+ ), f = (g) => {
375
+ e(g.apiKey), a(g.clientId), D(g.projectId), o(g.enerexIdentifier), m(g.userEmail), u(g.isAdmin), y(g.defaultSelector), h(g.meBaseUrl);
376
376
  };
377
- return /* @__PURE__ */ r(
378
- Pe.Provider,
377
+ return /* @__PURE__ */ n(
378
+ Re.Provider,
379
379
  {
380
380
  value: {
381
- clientId: o,
381
+ clientId: l,
382
382
  apiKey: i,
383
- setConfiguration: p,
384
- enerexIdentifier: a,
385
- projectId: T,
386
- userEmail: N,
387
- isAdmin: I,
388
- defaultSelector: h,
389
- meBaseUrl: L
383
+ setConfiguration: f,
384
+ enerexIdentifier: d,
385
+ projectId: b,
386
+ userEmail: A,
387
+ isAdmin: _,
388
+ defaultSelector: v,
389
+ meBaseUrl: j
390
390
  },
391
391
  children: t
392
392
  }
393
393
  );
394
- }, R = () => {
395
- const t = je(Pe);
394
+ }, B = () => {
395
+ const t = qe(Re);
396
396
  if (!t)
397
397
  throw new Error("widgetConfig must be used within a ConfigProvider");
398
398
  return t;
399
- }, Oe = (t = "", s) => ({ get: async (i, e) => {
399
+ }, Me = (t = "", s) => ({ get: async (i, e) => {
400
400
  try {
401
- const a = await xe.get(
401
+ const d = await _e.get(
402
402
  `${t}${i}`,
403
403
  e ?? s
404
404
  );
405
- if (a.status === 200)
406
- return a.data;
407
- } catch (a) {
408
- throw a;
405
+ if (d.status === 200)
406
+ return d.data;
407
+ } catch (d) {
408
+ throw d;
409
409
  }
410
- }, post: async (i, e, a) => {
410
+ }, post: async (i, e, d) => {
411
411
  try {
412
- const c = await xe.post(
412
+ const o = await _e.post(
413
413
  `${t}${i}`,
414
414
  e,
415
- a ?? s
415
+ d ?? s
416
416
  );
417
- if (c.status === 200)
418
- return c.data;
419
- } catch (c) {
420
- throw c;
417
+ if (o.status === 200)
418
+ return o.data;
419
+ } catch (o) {
420
+ throw o;
421
421
  }
422
- } }), De = k.createContext({
422
+ } }), Be = M.createContext({
423
423
  get: () => {
424
424
  throw new Error("HttpClientContext.get not implemented");
425
425
  },
426
426
  post: () => {
427
427
  throw new Error("HttpClientContext.post not implemented");
428
428
  }
429
- }), rt = ({ children: t }) => {
430
- const { clientId: s, apiKey: o, isAdmin: l, meBaseUrl: i } = R(), e = {
429
+ }), mt = ({ children: t }) => {
430
+ const { clientId: s, apiKey: l, isAdmin: a, meBaseUrl: i } = B(), e = {
431
431
  headers: {
432
432
  client_id: s,
433
- "x-api-key": o,
434
- "Security-Context": l ? "admin" : "viewer"
433
+ "x-api-key": l,
434
+ "Security-Context": a ? "admin" : "viewer"
435
435
  }
436
- }, { get: a, post: c } = Oe(i, e);
437
- return /* @__PURE__ */ r(De.Provider, { value: { get: a, post: c }, children: t });
438
- }, st = ({ children: t }) => {
439
- const s = new Ye();
440
- return /* @__PURE__ */ r(rt, { children: /* @__PURE__ */ r(ze, { client: s, children: t }) });
441
- }, ue = {
436
+ }, { get: d, post: o } = Me(i, e);
437
+ return /* @__PURE__ */ n(Be.Provider, { value: { get: d, post: o }, children: t });
438
+ }, ut = ({ children: t }) => {
439
+ const s = new it();
440
+ return /* @__PURE__ */ n(mt, { children: /* @__PURE__ */ n(at, { client: s, children: t }) });
441
+ }, he = {
442
442
  EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
443
443
  EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
444
444
  EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da"
445
- }, it = (t) => {
446
- const s = Array.from(new Set(t.map((l) => l.category))), o = [];
447
- return s.forEach((l) => {
448
- const i = t.filter((e) => e.category === l).map((e) => ({
445
+ }, ft = (t) => {
446
+ const s = Array.from(new Set(t.map((a) => a.category))), l = [];
447
+ return s.forEach((a) => {
448
+ const i = t.filter((e) => e.category === a).map((e) => ({
449
449
  label: e.label,
450
450
  value: e.value,
451
451
  hint: e.hint,
452
452
  hidden: e.hidden
453
453
  }));
454
- o.push({ category: l, entries: i });
455
- }), o;
456
- }, K = () => {
457
- const t = je(De);
454
+ l.push({ category: a, entries: i });
455
+ }), l;
456
+ }, V = () => {
457
+ const t = qe(Be);
458
458
  if (t)
459
459
  return t;
460
460
  throw new Error("useHttpClient must be used within a HttpClientProvider");
461
- }, Q = {
461
+ }, G = {
462
462
  Template_list: "/Template/list/",
463
463
  Template: "/Template/GetTemplate/",
464
464
  MergeTags: "/Template/TemplateMergeTags/",
465
465
  ExcludeCategory: "/Template/GetExcludeCategories/",
466
466
  SaveTemplate: "/Template/save-update/",
467
- TemplateTypes: "/Template/TemplateTypes/"
468
- }, lt = () => {
469
- const t = K(), { enerexIdentifier: s, projectId: o } = R();
470
- return le({
467
+ TemplateTypes: "/Template/TemplateTypes/",
468
+ markFavourite: "/Template/MarkFavourite/"
469
+ }, yt = () => {
470
+ const t = V(), { enerexIdentifier: s, projectId: l } = B();
471
+ return ce({
471
472
  queryKey: ["getTemplateTags"],
472
473
  queryFn: async (i) => await t.get(
473
- `${Q.MergeTags}${o}/${s}`
474
+ `${G.MergeTags}${l}/${s}`
474
475
  )
475
476
  });
476
- }, at = () => {
477
- const t = K(), { enerexIdentifier: s, projectId: o } = R();
478
- return le({
477
+ }, gt = () => {
478
+ const t = V(), { enerexIdentifier: s, projectId: l } = B();
479
+ return ce({
479
480
  queryKey: ["getExcludeCategory"],
480
481
  queryFn: async (i) => await t.get(
481
- `${Q.ExcludeCategory}${o}/${s}`
482
+ `${G.ExcludeCategory}${l}/${s}`
482
483
  )
483
484
  });
484
- }, ot = ({
485
+ }, ht = ({
485
486
  templateHTML: t,
486
487
  className: s = "",
487
- loading: o = !1,
488
- onEditorInitialized: l
488
+ loading: l = !1,
489
+ onEditorInitialized: a
489
490
  }) => {
490
- const { post: i } = Oe(), { data: e } = lt(), { data: a } = at(), [c, T] = v(
491
- t ?? { html: ie, css: "" }
492
- ), { userEmail: g } = R(), N = We(null), f = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", I = "https://plugins.stripo.email/api/v1/auth";
493
- x(() => {
494
- (async () => (await j(), e && a && await L(ue.EDITOR_SCRIPT_URL)))();
495
- }, [e, a]);
496
- async function j() {
497
- window.Zone || await new Promise((h, b) => {
498
- const p = document.createElement("script");
499
- p.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
500
- const u = document.querySelector("script[nonce]")?.nonce;
501
- u && p.setAttribute("nonce", u), p.onload = () => h(), p.onerror = () => b(new Error("Failed to load zone.js")), document.head.appendChild(p);
491
+ const { post: i } = Me(), { data: e } = yt(), { data: d } = gt(), [o, b] = w(
492
+ t ?? { html: de, css: "" }
493
+ ), { userEmail: D } = B(), A = st(null), m = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", _ = "https://plugins.stripo.email/api/v1/auth";
494
+ E(() => {
495
+ (async () => (await u(), e && d && await j(he.EDITOR_SCRIPT_URL)))();
496
+ }, [e, d]);
497
+ async function u() {
498
+ window.Zone || await new Promise((v, y) => {
499
+ const f = document.createElement("script");
500
+ f.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
501
+ const g = document.querySelector("script[nonce]")?.nonce;
502
+ g && f.setAttribute("nonce", g), f.onload = () => v(), f.onerror = () => y(new Error("Failed to load zone.js")), document.head.appendChild(f);
502
503
  });
503
504
  }
504
- async function L(h) {
505
- let b = document.getElementById(
505
+ async function j(v) {
506
+ let y = document.getElementById(
506
507
  "UiEditorScript"
507
508
  );
508
- b || (b = document.createElement("script"), b.id = "UiEditorScript", b.src = h, b.onload = async () => {
509
- await y();
510
- }, document.body.appendChild(b)), await new Promise(
511
- (p) => b.addEventListener("load", () => p(), { once: !0 })
509
+ y || (y = document.createElement("script"), y.id = "UiEditorScript", y.src = v, y.onload = async () => {
510
+ await h();
511
+ }, document.body.appendChild(y)), await new Promise(
512
+ (f) => y.addEventListener("load", () => f(), { once: !0 })
512
513
  );
513
514
  }
514
- const y = async () => {
515
- const h = N.current;
516
- if (!h) {
515
+ const h = async () => {
516
+ const v = A.current;
517
+ if (!v) {
517
518
  console.error("Missing #stripoEditorContainer in DOM");
518
519
  return;
519
520
  }
@@ -521,252 +522,261 @@ const ie = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http
521
522
  console.error("UIEditor script not loaded or not exposing initEditor");
522
523
  return;
523
524
  }
524
- const b = {
525
- html: c.html,
526
- css: c.css,
527
- modulesExcludedCategories: a ?? [],
525
+ const y = {
526
+ html: o.html,
527
+ css: o.css,
528
+ modulesExcludedCategories: d ?? [],
528
529
  forceRecreate: !0,
529
530
  metadata: {
530
- emailId: g,
531
+ emailId: D,
531
532
  userId: "1",
532
533
  // username: userName,
533
- avatarUrl: f
534
+ avatarUrl: m
534
535
  },
535
536
  locale: "en",
536
- onTokenRefreshRequest: async (p) => {
537
- const u = {
538
- pluginId: ue.EDITOR_PLUGIN_ID,
539
- secretKey: ue.EDITOR_SECRET_KEY,
540
- userId: g,
537
+ onTokenRefreshRequest: async (f) => {
538
+ const g = {
539
+ pluginId: he.EDITOR_PLUGIN_ID,
540
+ secretKey: he.EDITOR_SECRET_KEY,
541
+ userId: D,
541
542
  role: "user"
542
- }, B = await i(
543
- I,
544
- u
543
+ }, T = await i(
544
+ _,
545
+ g
545
546
  );
546
- B?.token && p(B.token);
547
+ T?.token && f(T.token);
547
548
  },
548
549
  onTemplateLoaded: () => {
549
- l && l(!0);
550
+ a && a(!0);
550
551
  },
551
- mergeTags: it(e ?? [])
552
+ mergeTags: ft(e ?? [])
552
553
  };
553
- for (const [p, u] of Object.entries({
554
+ for (const [f, g] of Object.entries({
554
555
  codeEditorButtonSelector: "#codeEditor",
555
556
  undoButtonSelector: "#undoButton",
556
557
  redoButtonSelector: "#redoButton",
557
558
  mobileViewButtonSelector: "#mobileViewButton",
558
559
  desktopViewButtonSelector: "#desktopViewButton"
559
560
  }))
560
- h.ownerDocument && h.getRootNode() instanceof ShadowRoot && h.getRootNode().querySelector(u) && (b[p] = u);
561
- await window.UIEditor.initEditor(h, b);
561
+ v.ownerDocument && v.getRootNode() instanceof ShadowRoot && v.getRootNode().querySelector(g) && (y[f] = g);
562
+ await window.UIEditor.initEditor(v, y);
562
563
  };
563
- return /* @__PURE__ */ r("div", { className: "position-relative", children: /* @__PURE__ */ S("div", { className: `editor-container ${s}`, children: [
564
- o && /* @__PURE__ */ r("div", { className: "loading-overlay", children: /* @__PURE__ */ r(
565
- J,
564
+ return /* @__PURE__ */ n("div", { className: "position-relative", children: /* @__PURE__ */ S("div", { className: `editor-container ${s}`, children: [
565
+ l && /* @__PURE__ */ n("div", { className: "loading-overlay", children: /* @__PURE__ */ n(
566
+ z,
566
567
  {
567
568
  animation: "border",
568
569
  style: { width: "11px", height: "11px" },
569
570
  size: "sm",
570
571
  role: "status",
571
572
  className: "me-1",
572
- children: /* @__PURE__ */ r("span", { className: "visually-hidden", children: "Loading..." })
573
+ children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
573
574
  }
574
575
  ) }),
575
- /* @__PURE__ */ r("div", { id: "externalSystemContainer" }),
576
- /* @__PURE__ */ r("div", { id: "stripoEditorContainer", ref: N })
576
+ /* @__PURE__ */ n("div", { id: "externalSystemContainer" }),
577
+ /* @__PURE__ */ n("div", { id: "stripoEditorContainer", ref: A })
577
578
  ] }) });
578
- }, Ee = ({
579
+ }, je = ({
579
580
  label: t,
580
581
  register: s,
581
- validation: o,
582
- required: l = !1,
582
+ validation: l,
583
+ required: a = !1,
583
584
  name: i,
584
585
  error: e,
585
- className: a = "",
586
- ...c
587
- }) => /* @__PURE__ */ S(F.Group, { className: a + " mb-1", children: [
588
- t ? /* @__PURE__ */ S(F.Label, { className: "mb-3 d-block form-label ts-label-height", children: [
586
+ className: d = "",
587
+ ...o
588
+ }) => /* @__PURE__ */ S(H.Group, { className: d + " mb-1", style: { width: "100%" }, children: [
589
+ t ? /* @__PURE__ */ S(H.Label, { className: "mb-3 d-block form-label ts-label-height", children: [
589
590
  t,
590
- l && /* @__PURE__ */ r("label", { className: "text-danger", children: "*" })
591
+ a && /* @__PURE__ */ n("label", { className: "text-danger", children: "*" })
591
592
  ] }) : null,
592
- /* @__PURE__ */ r(
593
- F.Control,
593
+ /* @__PURE__ */ n(
594
+ H.Control,
594
595
  {
595
596
  name: i,
596
597
  type: "text",
597
- ...c,
598
+ ...o,
598
599
  isInvalid: !!(e && e[i]),
599
600
  ...s ? s(i, {
600
- ...o
601
+ ...l
601
602
  }) : {},
602
603
  className: `react-select__control ${e && e[i] && "border border-danger"}`
603
604
  }
604
605
  ),
605
- e && e[i] ? /* @__PURE__ */ r(F.Control.Feedback, { type: "invalid", children: e[i].message }) : null
606
- ] }), dt = ({
606
+ e && e[i] ? /* @__PURE__ */ n(H.Control.Feedback, { type: "invalid", children: e[i].message }) : null
607
+ ] }), bt = ({
607
608
  show: t,
608
609
  variant: s,
609
- title: o = "Are you sure?",
610
- message: l,
610
+ title: l = "Are you sure?",
611
+ message: a,
611
612
  label: i = "Name",
612
613
  value: e = "",
613
- placeholder: a = "",
614
- requiredMessage: c = "This field is required",
615
- externalError: T = !1,
616
- externalErrorMessage: g = "",
617
- confirmText: N = "Ok",
618
- cancelText: f = "Cancel",
619
- confirmButtonVariant: I = "danger",
620
- onConfirm: j,
621
- onCancel: L,
622
- onInputChange: y
614
+ placeholder: d = "",
615
+ requiredMessage: o = "This field is required",
616
+ externalError: b = !1,
617
+ externalErrorMessage: D = "",
618
+ confirmText: A = "Ok",
619
+ cancelText: m = "Cancel",
620
+ confirmButtonVariant: _ = "danger",
621
+ onConfirm: u,
622
+ onCancel: j,
623
+ onInputChange: h
623
624
  }) => {
624
- const [h, b] = v(e), [p, u] = v(!1);
625
- if (x(() => {
626
- t && (b(e), u(!1));
627
- }, [t, e]), x(() => {
628
- T && u(!0);
629
- }, [T]), !t) return null;
630
- const B = s === "input" && !h.trim(), M = s === "input" && (B || T), ae = B ? c : T ? g : "", q = () => {
631
- if (M) {
632
- u(!0);
625
+ const [v, y] = w(e), [f, g] = w(!1);
626
+ if (E(() => {
627
+ t && (y(e), g(!1));
628
+ }, [t, e]), E(() => {
629
+ b && g(!0);
630
+ }, [b]), !t) return null;
631
+ const T = s === "input" && !v.trim(), P = s === "input" && (T || b), pe = T ? o : b ? D : "", K = () => {
632
+ if (P) {
633
+ g(!0);
633
634
  return;
634
635
  }
635
- j(h.trim());
636
+ u(v.trim());
636
637
  };
637
- return /* @__PURE__ */ r("div", { className: "template-studio-modal-overlay", children: /* @__PURE__ */ S("div", { className: "template-studio-modal", children: [
638
+ return /* @__PURE__ */ n("div", { className: "template-studio-modal-overlay", children: /* @__PURE__ */ S("div", { className: "template-studio-modal", children: [
638
639
  /* @__PURE__ */ S("div", { className: "template-studio-modal-header", children: [
639
- /* @__PURE__ */ r("h4", { children: o }),
640
- /* @__PURE__ */ r("button", { className: "template-studio-modal-close", onClick: L, children: "✕" })
640
+ /* @__PURE__ */ n("h4", { children: l }),
641
+ /* @__PURE__ */ n("button", { className: "template-studio-modal-close", onClick: j, children: "✕" })
641
642
  ] }),
642
643
  /* @__PURE__ */ S("div", { className: "template-studio-modal-body", children: [
643
- l && /* @__PURE__ */ r("p", { children: l }),
644
+ a && /* @__PURE__ */ n("p", { children: a }),
644
645
  s === "input" && /* @__PURE__ */ S("div", { className: "mb-3", children: [
645
646
  /* @__PURE__ */ S("label", { className: "form-label", children: [
646
647
  i,
647
- /* @__PURE__ */ r("span", { className: "text-danger", children: "*" })
648
+ /* @__PURE__ */ n("span", { className: "text-danger", children: "*" })
648
649
  ] }),
649
- /* @__PURE__ */ r(
650
+ /* @__PURE__ */ n(
650
651
  "input",
651
652
  {
652
653
  type: "text",
653
- className: `form-control ${p && M ? "is-invalid" : ""}`,
654
- placeholder: a,
655
- value: h,
656
- onChange: (V) => {
657
- b(V.target.value), p && u(!1), y?.(V.target.value);
654
+ className: `form-control ${f && P ? "is-invalid" : ""}`,
655
+ placeholder: d,
656
+ value: v,
657
+ onChange: (ee) => {
658
+ y(ee.target.value), f && g(!1), h?.(ee.target.value);
658
659
  },
659
660
  autoFocus: !0
660
661
  }
661
662
  ),
662
- p && M && /* @__PURE__ */ r("div", { className: "invalid-feedback d-block", children: ae })
663
+ f && P && /* @__PURE__ */ n("div", { className: "invalid-feedback d-block", children: pe })
663
664
  ] })
664
665
  ] }),
665
666
  /* @__PURE__ */ S("div", { className: "template-studio-modal-footer", children: [
666
- /* @__PURE__ */ r("button", { className: "btn btn-secondary", onClick: L, children: f }),
667
- /* @__PURE__ */ r(
667
+ /* @__PURE__ */ n("button", { className: "btn btn-secondary", onClick: j, children: m }),
668
+ /* @__PURE__ */ n(
668
669
  "button",
669
670
  {
670
- className: `btn btn-${I}`,
671
- onClick: q,
672
- children: N
671
+ className: `btn btn-${_}`,
672
+ onClick: K,
673
+ children: A
673
674
  }
674
675
  )
675
676
  ] })
676
677
  ] }) });
677
- }, ct = () => {
678
- const t = K(), { enerexIdentifier: s, projectId: o } = R();
679
- return le({
678
+ }, vt = () => {
679
+ const t = V(), { enerexIdentifier: s, projectId: l } = B();
680
+ return ce({
680
681
  queryKey: ["getTemplatesList"],
681
682
  queryFn: async (i) => await t.get(
682
- `${Q.Template_list}${o}/${s}`
683
+ `${G.Template_list}${l}/${s}`
683
684
  )
684
685
  });
685
686
  };
686
- function fe(t) {
687
- return t.sort((s, o) => s.name.localeCompare(o.name));
687
+ function be(t) {
688
+ return t.sort((s, l) => s.name.localeCompare(l.name));
688
689
  }
689
- function pt(t) {
690
- const s = /* @__PURE__ */ new Map(), o = [];
690
+ function wt(t) {
691
+ const s = /* @__PURE__ */ new Map(), l = [];
691
692
  t.forEach((e) => s.set(e.id, e));
692
- let l = t.filter((e) => e.parent_id === 0), i = 0;
693
- for (; l.length > 0; ) {
694
- o.push({ level: i, data: l });
695
- const e = l.map((c) => c.id);
696
- l = t.filter(
697
- (c) => e.includes(c.parent_id)
693
+ let a = t.filter((e) => e.parent_id === 0), i = 0;
694
+ for (; a.length > 0; ) {
695
+ l.push({ level: i, data: a });
696
+ const e = a.map((o) => o.id);
697
+ a = t.filter(
698
+ (o) => e.includes(o.parent_id)
698
699
  ), i++;
699
700
  }
700
- return o;
701
+ return l;
701
702
  }
702
- function ye(t, s) {
703
- const l = pt(t).find((i) => i.level === s);
704
- return l ? l.data : [];
703
+ function ve(t, s) {
704
+ const a = wt(t).find((i) => i.level === s);
705
+ return a ? a.data : [];
705
706
  }
706
- const mt = () => {
707
- const t = K(), { enerexIdentifier: s, projectId: o } = R();
708
- return Le({
707
+ const Tt = () => {
708
+ const t = V(), { enerexIdentifier: s, projectId: l } = B();
709
+ return Te({
710
+ mutationKey: ["markFavourite"],
711
+ mutationFn: async (i) => await t.post(
712
+ `${G.markFavourite}${l}/${s}`,
713
+ i
714
+ )
715
+ });
716
+ }, xt = () => {
717
+ const t = V(), { enerexIdentifier: s, projectId: l } = B();
718
+ return Te({
709
719
  mutationKey: ["getTemplate"],
710
720
  mutationFn: async ({ id: i }) => {
711
721
  if (i)
712
722
  return await t.get(
713
- `${Q.Template}${s}/${i}/${o}`
723
+ `${G.Template}${s}/${i}/${l}`
714
724
  );
715
725
  }
716
726
  });
717
- }, ut = () => {
718
- const t = K(), { enerexIdentifier: s, projectId: o } = R();
719
- return le({
727
+ }, St = () => {
728
+ const t = V(), { enerexIdentifier: s, projectId: l } = B();
729
+ return ce({
720
730
  queryKey: ["getTemplateTypes"],
721
731
  queryFn: async (i) => await t.get(
722
- `${Q.TemplateTypes}${s}/${o}`
732
+ `${G.TemplateTypes}${s}/${l}`
723
733
  )
724
734
  });
725
735
  };
726
- function ft(t) {
736
+ function Ct(t) {
727
737
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
728
738
  }
729
- var ge = { exports: {} };
739
+ var we = { exports: {} };
730
740
  /*!
731
741
  Copyright (c) 2018 Jed Watson.
732
742
  Licensed under the MIT License (MIT), see
733
743
  http://jedwatson.github.io/classnames
734
744
  */
735
- var Ne;
736
- function yt() {
737
- return Ne || (Ne = 1, function(t) {
745
+ var Pe;
746
+ function Nt() {
747
+ return Pe || (Pe = 1, function(t) {
738
748
  (function() {
739
749
  var s = {}.hasOwnProperty;
740
- function o() {
741
- for (var e = "", a = 0; a < arguments.length; a++) {
742
- var c = arguments[a];
743
- c && (e = i(e, l(c)));
750
+ function l() {
751
+ for (var e = "", d = 0; d < arguments.length; d++) {
752
+ var o = arguments[d];
753
+ o && (e = i(e, a(o)));
744
754
  }
745
755
  return e;
746
756
  }
747
- function l(e) {
757
+ function a(e) {
748
758
  if (typeof e == "string" || typeof e == "number")
749
759
  return e;
750
760
  if (typeof e != "object")
751
761
  return "";
752
762
  if (Array.isArray(e))
753
- return o.apply(null, e);
763
+ return l.apply(null, e);
754
764
  if (e.toString !== Object.prototype.toString && !e.toString.toString().includes("[native code]"))
755
765
  return e.toString();
756
- var a = "";
757
- for (var c in e)
758
- s.call(e, c) && e[c] && (a = i(a, c));
759
- return a;
766
+ var d = "";
767
+ for (var o in e)
768
+ s.call(e, o) && e[o] && (d = i(d, o));
769
+ return d;
760
770
  }
761
- function i(e, a) {
762
- return a ? e ? e + " " + a : e + a : e;
771
+ function i(e, d) {
772
+ return d ? e ? e + " " + d : e + d : e;
763
773
  }
764
- t.exports ? (o.default = o, t.exports = o) : window.classNames = o;
774
+ t.exports ? (l.default = l, t.exports = l) : window.classNames = l;
765
775
  })();
766
- }(ge)), ge.exports;
776
+ }(we)), we.exports;
767
777
  }
768
- var gt = yt();
769
- const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__ */ r("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ r(
778
+ var It = Nt();
779
+ const Oe = /* @__PURE__ */ Ct(It), $e = (t) => t.data.isSeparator ? /* @__PURE__ */ n("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ n(
770
780
  "hr",
771
781
  {
772
782
  style: {
@@ -776,34 +786,37 @@ const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__
776
786
  margin: 0
777
787
  }
778
788
  }
779
- ) }) : /* @__PURE__ */ r(tt.Option, { ...t }), ht = ({
789
+ ) }) : t.data.icon ? /* @__PURE__ */ S("div", { className: "d-flex align-items-center", children: [
790
+ /* @__PURE__ */ n(Le.Option, { ...t }),
791
+ /* @__PURE__ */ n("span", { className: "px-1 template-studio-dropdown-postfix-icon", children: t.data.icon })
792
+ ] }) : /* @__PURE__ */ n(Le.Option, { ...t }), Et = ({
780
793
  name: t = "",
781
794
  control: s,
782
- options: o,
783
- multiple: l = !1,
795
+ options: l,
796
+ multiple: a = !1,
784
797
  placeholder: i,
785
798
  validation: e,
786
- labelKey: a = "name",
787
- disabled: c,
788
- isInvalid: T,
789
- value: g,
790
- onChange: N,
791
- uncontrolled: f,
792
- menuPlacement: I = "auto",
793
- closeOnSelect: j = !0
799
+ labelKey: d = "name",
800
+ disabled: o,
801
+ isInvalid: b,
802
+ value: D,
803
+ onChange: A,
804
+ uncontrolled: m,
805
+ menuPlacement: _ = "auto",
806
+ closeOnSelect: u = !0
794
807
  }) => {
795
- const L = {
796
- control: (y) => ({
797
- ...y,
808
+ const j = {
809
+ control: (h) => ({
810
+ ...h,
798
811
  minHeight: "33px",
799
812
  // state.isFocused can display different borderColor if you need it
800
- borderColor: T ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
801
- backgroundImage: T ? '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",
813
+ borderColor: b ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
814
+ backgroundImage: b ? '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",
802
815
  backgroundRepeat: "no-repeat",
803
816
  backgroundPosition: "right calc(0.375em + 0.225rem) center",
804
817
  backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
805
818
  "&:hover": {
806
- borderColor: T ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
819
+ borderColor: b ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
807
820
  },
808
821
  "& .react-select__single-value": {
809
822
  color: "var(--ct-input-color) !important"
@@ -815,544 +828,637 @@ const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__
815
828
  display: "none"
816
829
  }
817
830
  }),
818
- menu: (y) => ({
819
- ...y,
831
+ menu: (h) => ({
832
+ ...h,
820
833
  marginTop: 0,
821
834
  width: "max-content",
822
835
  minWidth: "100%"
823
836
  }),
824
- menuPortal: (y) => ({
825
- ...y,
837
+ menuPortal: (h) => ({
838
+ ...h,
826
839
  zIndex: 9999
827
840
  }),
828
- multiValueRemove: (y) => ({
829
- ...y,
830
- display: c ? "none" : "block"
841
+ multiValueRemove: (h) => ({
842
+ ...h,
843
+ display: o ? "none" : "block"
831
844
  })
832
845
  };
833
- return f ? /* @__PURE__ */ r(
834
- Ce,
846
+ return m ? /* @__PURE__ */ n(
847
+ Ae,
835
848
  {
836
- components: { Option: _e },
837
- isOptionDisabled: (y) => !!y.isSeparator,
838
- className: Ie({
839
- "is-invalid": T
849
+ components: { Option: $e },
850
+ isOptionDisabled: (h) => !!h.isSeparator,
851
+ className: Oe({
852
+ "is-invalid": b
840
853
  }),
841
- styles: L,
854
+ styles: j,
842
855
  classNamePrefix: "react-select",
843
- isMulti: l,
844
- options: o,
845
- onChange: N,
856
+ isMulti: a,
857
+ options: l,
858
+ onChange: A,
846
859
  placeholder: i,
847
860
  menuPortalTarget: document.body,
848
- value: g,
849
- getOptionLabel: typeof a == "string" ? (y) => y[a] : a,
850
- getOptionValue: (y) => y.id,
851
- isDisabled: c,
852
- menuPlacement: I,
853
- closeMenuOnSelect: j
861
+ value: D,
862
+ getOptionLabel: typeof d == "string" ? (h) => h[d] : d,
863
+ getOptionValue: (h) => h.id,
864
+ isDisabled: o,
865
+ menuPlacement: _,
866
+ closeMenuOnSelect: u
854
867
  }
855
- ) : /* @__PURE__ */ r(
856
- Ze,
868
+ ) : /* @__PURE__ */ n(
869
+ dt,
857
870
  {
858
871
  control: s,
859
872
  name: t,
860
873
  rules: e,
861
- render: ({ field: { onChange: y, value: h, onBlur: b } }) => /* @__PURE__ */ r(
862
- Ce,
874
+ render: ({ field: { onChange: h, value: v, onBlur: y } }) => /* @__PURE__ */ n(
875
+ Ae,
863
876
  {
864
- components: { Option: _e },
865
- isOptionDisabled: (p) => !!p.isSeparator,
866
- className: Ie({
867
- "is-invalid": T
877
+ components: { Option: $e },
878
+ isOptionDisabled: (f) => !!f.isSeparator,
879
+ className: Oe({
880
+ "is-invalid": b
868
881
  }),
869
- styles: L,
882
+ styles: j,
870
883
  classNamePrefix: "react-select",
871
- isMulti: l,
872
- options: o,
873
- onBlur: b,
874
- onChange: y,
884
+ isMulti: a,
885
+ options: l,
886
+ onBlur: y,
887
+ onChange: h,
875
888
  placeholder: i,
876
889
  menuPortalTarget: document.body,
877
- value: h,
878
- getOptionLabel: typeof a == "string" ? (p) => p[a] : a,
879
- getOptionValue: (p) => p.id,
880
- isDisabled: c,
881
- menuPlacement: I,
882
- closeMenuOnSelect: j
890
+ value: v,
891
+ getOptionLabel: typeof d == "string" ? (f) => f[d] : d,
892
+ getOptionValue: (f) => f.id,
893
+ isDisabled: o,
894
+ menuPlacement: _,
895
+ closeMenuOnSelect: u
883
896
  },
884
- h ? JSON.stringify(h) : "reset"
897
+ v ? v.id || v.value || JSON.stringify(v) : "reset"
885
898
  )
886
899
  }
887
900
  );
888
- }, se = ({
901
+ }, oe = ({
889
902
  label: t,
890
903
  name: s,
891
- validation: o,
892
- control: l,
904
+ validation: l,
905
+ control: a,
893
906
  error: i,
894
907
  ...e
895
- }) => /* @__PURE__ */ S(F.Group, { className: "mb-1", children: [
896
- t && /* @__PURE__ */ S(F.Label, { className: "mb-3 d-block form-label ts-label-height", children: [
908
+ }) => /* @__PURE__ */ S(H.Group, { className: "mb-1", children: [
909
+ t && /* @__PURE__ */ S(H.Label, { className: "mb-3 d-block form-label ts-label-height", children: [
897
910
  t,
898
911
  " ",
899
- e.required && /* @__PURE__ */ r("span", { className: "text-danger", children: "*" })
912
+ e.required && /* @__PURE__ */ n("span", { className: "text-danger", children: "*" })
900
913
  ] }),
901
- /* @__PURE__ */ r(
902
- ht,
914
+ /* @__PURE__ */ n(
915
+ Et,
903
916
  {
904
- control: l,
917
+ control: a,
905
918
  disabled: e.disabled,
906
919
  options: e.options ?? [],
907
- validation: o,
920
+ validation: l,
908
921
  isInvalid: i && !!i[s],
909
922
  name: s
910
923
  }
911
924
  ),
912
- i && i[s] ? /* @__PURE__ */ r(F.Control.Feedback, { type: "invalid", children: i[s].message }) : null
913
- ] }), bt = () => {
914
- const t = K();
915
- Je();
916
- const { enerexIdentifier: s, projectId: o } = R();
917
- return Le({
925
+ i && i[s] ? /* @__PURE__ */ n(H.Control.Feedback, { type: "invalid", children: i[s].message }) : null
926
+ ] }), _t = () => {
927
+ const t = V();
928
+ lt();
929
+ const { enerexIdentifier: s, projectId: l } = B();
930
+ return Te({
918
931
  mutationKey: ["saveTemplate"],
919
- mutationFn: async (i) => (i.enerexIdentifier = s ?? "", i.projectId = o ?? "", await t.post(
920
- `${Q.SaveTemplate}`,
932
+ mutationFn: async (i) => (i.enerexIdentifier = s ?? "", i.projectId = l ?? "", await t.post(
933
+ `${G.SaveTemplate}`,
921
934
  i
922
935
  ))
923
936
  });
924
- }, z = {
937
+ }, X = (t) => {
938
+ let s = /* @__PURE__ */ n(
939
+ "span",
940
+ {
941
+ style: { width: "20px", height: "20px", display: "inline-block" }
942
+ }
943
+ );
944
+ return t.variant === "filled" ? s = /* @__PURE__ */ n(
945
+ "svg",
946
+ {
947
+ version: "1.0",
948
+ id: "Layer_1",
949
+ xmlns: "http://www.w3.org/2000/svg",
950
+ width: "20px",
951
+ height: "20px",
952
+ viewBox: "0 0 64 64",
953
+ "enable-background": "new 0 0 64 64",
954
+ children: /* @__PURE__ */ n(
955
+ "path",
956
+ {
957
+ fill: "#2196F3",
958
+ 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
959
+ 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
960
+ 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
961
+ 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
962
+ 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
963
+ C63.951,25.771,64.131,24.987,63.893,24.277z`
964
+ }
965
+ )
966
+ }
967
+ ) : t.variant === "outlined" && (s = /* @__PURE__ */ n(
968
+ "svg",
969
+ {
970
+ version: "1.0",
971
+ id: "Layer_1",
972
+ xmlns: "http://www.w3.org/2000/svg",
973
+ width: "20px",
974
+ height: "20px",
975
+ viewBox: "0 0 64 64",
976
+ enableBackground: "new 0 0 64 64",
977
+ children: /* @__PURE__ */ n(
978
+ "path",
979
+ {
980
+ fill: t.fill || "rgba(247, 216, 40, 0)",
981
+ stroke: t.stroke || "#000000",
982
+ strokeWidth: t.strokeWidth || "2",
983
+ 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
984
+ 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
985
+ 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
986
+ 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
987
+ 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
988
+ C63.951,25.771,64.131,24.987,63.893,24.277z`
989
+ }
990
+ )
991
+ }
992
+ )), s;
993
+ }, Z = {
925
994
  id: "",
926
995
  name: "New (Blank)"
927
- }, Ae = {
996
+ }, De = {
928
997
  id: "",
929
998
  name: "Separator",
930
999
  isSeparator: !0
931
- }, Tt = ({
1000
+ }, kt = ({
932
1001
  onSelectItem: t,
933
1002
  templateLoading: s,
934
- onReset: o,
935
- editorInitialized: l
1003
+ onReset: l,
1004
+ editorInitialized: a
936
1005
  }) => {
937
- const { isAdmin: i, defaultSelector: e } = R(), {
938
- register: a,
939
- handleSubmit: c,
940
- clearErrors: T,
941
- setValue: g,
942
- control: N,
943
- watch: f,
944
- reset: I,
945
- setError: j,
946
- getValues: L,
1006
+ const { isAdmin: i, defaultSelector: e } = B(), { mutateAsync: d, isPending: o } = Tt(), {
1007
+ register: b,
1008
+ handleSubmit: D,
1009
+ clearErrors: A,
1010
+ setValue: m,
1011
+ control: _,
1012
+ watch: u,
1013
+ reset: j,
1014
+ setError: h,
1015
+ getValues: v,
947
1016
  formState: { errors: y }
948
- } = et({
1017
+ } = ct({
949
1018
  defaultValues: {
950
1019
  templateName: "",
951
1020
  subTemplateType: void 0,
952
1021
  subTemplateType2: void 0,
953
1022
  subject: "",
954
1023
  templateType: void 0,
955
- template: z
1024
+ template: Z
956
1025
  },
957
1026
  mode: "onChange"
958
1027
  }), {
959
- data: h,
960
- refetch: b,
961
- isLoading: p
962
- } = ct(), [u, B] = v([]), [M, ae] = v(!1), [q, V] = v(), [X, Z] = v(), { mutateAsync: oe, isPending: _ } = mt(), { mutateAsync: de, isPending: A } = bt(), { data: U, isLoading: $ } = ut(), [ce, qe] = v([]), [P, ee] = v([]), [O, te] = v([]), [$e, pe] = v(!1), [G, ke] = v("confirm"), [Re, me] = v(!1), [he, be] = v(!1);
963
- x(() => {
964
- if (U) {
965
- let n = U.filter((m) => m.id != null), d = ye(n, 0);
966
- qe(fe(d));
1028
+ data: f,
1029
+ refetch: g,
1030
+ isLoading: T
1031
+ } = vt(), [P, pe] = w([]), [K, ee] = w(!1), [L, te] = w(), [ne, re] = w(), { mutateAsync: me, isPending: N } = xt(), { mutateAsync: ue, isPending: I } = _t(), { data: F, isLoading: q } = St(), [fe, Fe] = w([]), [O, se] = w([]), [$, ie] = w([]), [Ue, ye] = w(!1), [W, He] = w("confirm"), [Ve, ge] = w(!1), [xe, Se] = w(!1);
1032
+ E(() => {
1033
+ if (F) {
1034
+ let r = F.filter((p) => p.id != null), c = ve(r, 0);
1035
+ Fe(be(c));
967
1036
  }
968
- }, [U]);
969
- const Be = (n, d) => {
970
- let m = [];
971
- return n.forEach((C, E) => {
972
- d.includes(E) && E !== 0 && m.push(Ae), m.push(C);
973
- }), m;
1037
+ }, [F]);
1038
+ const Ge = (r, c) => {
1039
+ let p = [];
1040
+ return r.forEach((C, k) => {
1041
+ c.includes(k) && k !== 0 && p.push(De), p.push(C);
1042
+ }), p;
974
1043
  };
975
- x(() => {
976
- s(!!(p || _ || A || $ || !l));
977
- }, [p, _, A, $, l]), x(() => {
978
- h?.sort((n, d) => n.readonly !== d.readonly ? (n.readonly ? 0 : 1) - (d.readonly ? 0 : 1) : n.name.localeCompare(d.name)), B(h ?? []);
979
- }, [h]);
980
- const Me = async (n) => {
981
- V(n), n && (i || !n.readonly) ? (g("templateName", n?.name), T()) : (g("templateName", ""), g("subject", ""));
982
- const d = await oe({ id: n?.id });
983
- d ? Z(d) : ne();
1044
+ E(() => {
1045
+ s(!!(T || N || I || q || !a));
1046
+ }, [T, N, I, q, a]), E(() => {
1047
+ f?.sort((r, c) => r.readonly !== c.readonly ? (r.readonly ? 0 : 1) - (c.readonly ? 0 : 1) : r.name.localeCompare(c.name)), pe(f ?? []);
1048
+ }, [f]);
1049
+ const Ke = async (r) => {
1050
+ te(r), r && (i || !r.readonly) ? (m("templateName", r?.name), A()) : (m("templateName", ""), m("subject", ""));
1051
+ const c = await me({ id: r?.id });
1052
+ c ? re(c) : ae();
984
1053
  };
985
- x(() => {
986
- if ((e === void 0 || e.templateId === void 0 || M) && g("template", z), f("templateType")) {
987
- let n = U?.filter((m) => m.id !== void 0) ?? [], d = ye(n, 1);
988
- ee(
989
- fe(
990
- d.filter(
991
- (m) => m.parent_id.toString() === `${f("templateType")?.id}`
1054
+ E(() => {
1055
+ if ((e === void 0 || e.templateId === void 0 || K) && m("template", Z), u("templateType")) {
1056
+ let r = F?.filter((p) => p.id !== void 0) ?? [], c = ve(r, 1);
1057
+ se(
1058
+ be(
1059
+ c.filter(
1060
+ (p) => p.parent_id.toString() === `${u("templateType")?.id}`
992
1061
  )
993
1062
  )
994
- ), g("subTemplateType", void 0), g("subTemplateType2", void 0);
1063
+ ), m("subTemplateType", void 0), m("subTemplateType2", void 0);
995
1064
  }
996
- }, [f("templateType")]), x(() => {
997
- if ((e === void 0 || e.templateId === void 0) && g("template", z), f("subTemplateType")) {
998
- let n = U?.filter((m) => m.id !== void 0) ?? [], d = ye(n, 2);
999
- te(
1000
- fe(
1001
- d.filter(
1002
- (m) => m.parent_id.toString() === `${f("subTemplateType")?.id}`
1065
+ }, [u("templateType")]), E(() => {
1066
+ if ((e === void 0 || e.templateId === void 0) && m("template", Z), u("subTemplateType")) {
1067
+ let r = F?.filter((p) => p.id !== void 0) ?? [], c = ve(r, 2);
1068
+ ie(
1069
+ be(
1070
+ c.filter(
1071
+ (p) => p.parent_id.toString() === `${u("subTemplateType")?.id}`
1003
1072
  )
1004
1073
  )
1005
- ), g("subTemplateType2", void 0);
1074
+ ), m("subTemplateType2", void 0);
1006
1075
  }
1007
- }, [f("subTemplateType")]), x(() => {
1008
- const n = ve();
1009
- n.length > 0 && n[0].id !== "" ? (e === void 0 || e.templateId === void 0 || M) && g("template", n[0]) : (e === void 0 || e.templateId === void 0 || M) && g("template", z);
1010
- }, [f("subTemplateType2")]), x(() => {
1011
- let n = u.find((d) => d.id === f("template")?.id);
1012
- Me(n);
1013
- }, [f("template")]);
1014
- const [Ue, Te] = v(!1);
1015
- x(() => {
1016
- he || Ue || X && q && l && (Te(!0), t(X), g("subject", X.subject ?? ""), setTimeout(() => {
1017
- Te(!1);
1076
+ }, [u("subTemplateType")]), E(() => {
1077
+ const r = Ne();
1078
+ r.length > 0 && r[0].id !== "" ? (e === void 0 || e.templateId === void 0 || K) && m("template", r[0]) : (e === void 0 || e.templateId === void 0 || K) && m("template", Z);
1079
+ }, [u("subTemplateType2")]), E(() => {
1080
+ let r = P.find((c) => c.id === u("template")?.id);
1081
+ Ke(r);
1082
+ }, [u("template")]);
1083
+ const [We, Ce] = w(!1);
1084
+ E(() => {
1085
+ xe || We || ne && L && a && (Ce(!0), t(ne), m("subject", ne.subject ?? ""), setTimeout(() => {
1086
+ Ce(!1);
1018
1087
  }, 1e3));
1019
- }, [X, q, l, he]);
1020
- const ve = () => {
1021
- let n = [z], d = "templateType";
1022
- O.length > 0 ? d = "subTemplateType2" : P.length > 0 && (d = "subTemplateType");
1023
- let m = u.filter(
1024
- (E) => (E.type?.toString() === f(d)?.id.toString() || E.type === null) && f(d)?.id != null
1025
- ), C = Be(m, [m.findIndex((E) => !E.readonly)]);
1026
- return C.length > 0 && (C[0].readonly === !0 && !i ? n = [] : n.push(Ae), n = [
1027
- ...n,
1028
- ...C.map((w) => ({
1029
- id: w.id,
1030
- name: He(m, w.id),
1031
- isSeparator: w.isSeparator
1088
+ }, [ne, L, a, xe]);
1089
+ const Ne = () => {
1090
+ let r = [Z], c = "templateType";
1091
+ $.length > 0 ? c = "subTemplateType2" : O.length > 0 && (c = "subTemplateType");
1092
+ let p = P.filter(
1093
+ (k) => (k.type?.toString() === u(c)?.id.toString() || k.type === null) && u(c)?.id != null
1094
+ ), C = Ge(p, [p.findIndex((k) => !k.readonly)]);
1095
+ return C.length > 0 && (C[0].readonly === !0 && !i ? r = [] : r.push(De), r = [
1096
+ ...r,
1097
+ ...C.map((x) => ({
1098
+ id: x.id,
1099
+ name: ze(p, x.id),
1100
+ icon: et(p, x.id) ? /* @__PURE__ */ n(X, { variant: "filled" }) : /* @__PURE__ */ n(X, { variant: "empty" }),
1101
+ isSeparator: x.isSeparator
1032
1102
  }))
1033
- ]), n.length ? n : [];
1103
+ ]), r.length ? r : [];
1034
1104
  };
1035
- x(() => {
1105
+ E(() => {
1036
1106
  if (e && e.type1) {
1037
- const n = ce?.find(
1038
- (d) => `${d.id}` === e.type1
1107
+ const r = fe?.find(
1108
+ (c) => `${c.id}` === e.type1
1039
1109
  );
1040
- g("templateType", n);
1110
+ m("templateType", r);
1041
1111
  }
1042
- }, [U, ce]), x(() => {
1112
+ }, [F, fe]), E(() => {
1043
1113
  if (e && e.type2) {
1044
- const n = P?.find(
1045
- (d) => `${d.id}` === e.type2
1114
+ const r = O?.find(
1115
+ (c) => `${c.id}` === e.type2
1046
1116
  );
1047
- g("subTemplateType", n);
1117
+ m("subTemplateType", r);
1048
1118
  }
1049
- }, [U, P]), x(() => {
1119
+ }, [F, O]), E(() => {
1050
1120
  if (e && e.type3) {
1051
- const n = O?.find(
1052
- (d) => `${d.id}` === e.type3
1121
+ const r = $?.find(
1122
+ (c) => `${c.id}` === e.type3
1053
1123
  );
1054
- g("subTemplateType2", n);
1124
+ m("subTemplateType2", r);
1055
1125
  }
1056
- }, [U, O]), x(() => {
1057
- if (e && e.templateId && u && u.length > 0 && !M && l) {
1058
- const n = u?.find(
1059
- (d) => `${d.id}` === e.templateId
1126
+ }, [F, $]), E(() => {
1127
+ if (e && e.templateId && P && P.length > 0 && !K && a) {
1128
+ const r = P?.find(
1129
+ (c) => `${c.id}` === e.templateId
1060
1130
  );
1061
- ae(!0), n && (V(n), g("template", n));
1131
+ ee(!0), r && (te(r), m("template", r));
1062
1132
  }
1063
- }, [u, l]);
1064
- const He = (n, d) => {
1065
- let m = n.find((C) => C.id === d);
1066
- return m ? `${m.displayName}` : "";
1067
- }, Fe = (n) => {
1133
+ }, [P, a]);
1134
+ const ze = (r, c) => {
1135
+ let p = r.find((C) => C.id === c);
1136
+ return p ? `${p.displayName}` : "";
1137
+ }, Qe = (r) => {
1068
1138
  window.StripoEditorApi.actionsApi.getTemplateData(
1069
- async (d) => {
1070
- let m = n.template.id, C = "";
1071
- q?.readonly && (m = "", C = n.template.id);
1072
- let E = u.find(
1073
- (D) => D.name === n.templateName.trim()
1139
+ async (c) => {
1140
+ let p = r.template.id, C = "";
1141
+ L?.readonly && (p = "", C = r.template.id);
1142
+ let k = P.find(
1143
+ (R) => R.name === r.templateName.trim()
1074
1144
  );
1075
- if (E && E.id !== m) {
1076
- j("templateName", {
1145
+ if (k && k.id !== p) {
1146
+ h("templateName", {
1077
1147
  type: "validate",
1078
1148
  message: "Template name already exists. Please choose a different name."
1079
1149
  });
1080
1150
  return;
1081
1151
  }
1082
- let w = n.templateType.id;
1083
- O && O.length > 0 ? w = n.subTemplateType2.id : P && P.length > 0 && (w = n.subTemplateType.id);
1084
- const W = {
1152
+ let x = r.templateType.id;
1153
+ $ && $.length > 0 ? x = r.subTemplateType2.id : O && O.length > 0 && (x = r.subTemplateType.id);
1154
+ const Q = {
1085
1155
  enerexIdentifier: "",
1086
1156
  projectId: "",
1087
- templateId: m,
1088
- templateType: w,
1089
- name: n.templateName.trim(),
1090
- html: d.html,
1091
- css: d.css,
1092
- subject: n.templateType.id === "2" ? n?.subject ?? "" : "",
1157
+ templateId: p,
1158
+ templateType: x,
1159
+ name: r.templateName.trim(),
1160
+ html: c.html,
1161
+ css: c.css,
1162
+ subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
1093
1163
  parent_id: C
1094
1164
  };
1095
- if (await de(W)) {
1096
- if (T(), q?.readonly && !i)
1097
- I(), ee([]), te([]);
1165
+ if (await ue(Q)) {
1166
+ if (A(), L?.readonly && !i)
1167
+ j(), se([]), ie([]);
1098
1168
  else {
1099
- const D = await oe({ id: m });
1100
- D ? Z(D) : ne();
1169
+ const R = await me({ id: p });
1170
+ R ? re(R) : ae();
1101
1171
  }
1102
- b();
1172
+ await g();
1103
1173
  }
1104
1174
  }
1105
1175
  );
1106
- }, ne = () => {
1107
- be(!0), s(!1), Z(void 0), t(void 0), setTimeout(() => {
1108
- be(!1);
1176
+ }, ae = () => {
1177
+ Se(!0), s(!1), re(void 0), t(void 0), setTimeout(() => {
1178
+ Se(!1);
1109
1179
  }, 0);
1110
- }, Ve = (n, d) => {
1111
- const m = d.trim(), C = "";
1112
- if (u.find(
1113
- (w) => w.name === m && w.id !== C
1180
+ }, Ye = (r, c) => {
1181
+ const p = c.trim(), C = "";
1182
+ if (P.find(
1183
+ (x) => x.name === p && x.id !== C
1114
1184
  )) {
1115
- me(!0);
1185
+ ge(!0);
1116
1186
  return;
1117
1187
  }
1118
- pe(!1), window.StripoEditorApi.actionsApi.getTemplateData(
1119
- async (w) => {
1120
- const W = n.template.id;
1121
- let Y = n.templateType.id;
1122
- O?.length ? Y = n.subTemplateType2.id : P?.length && (Y = n.subTemplateType.id);
1123
- const D = {
1188
+ ye(!1), window.StripoEditorApi.actionsApi.getTemplateData(
1189
+ async (x) => {
1190
+ const Q = r.template.id;
1191
+ let Y = r.templateType.id;
1192
+ $?.length ? Y = r.subTemplateType2.id : O?.length && (Y = r.subTemplateType.id);
1193
+ const R = {
1124
1194
  enerexIdentifier: "",
1125
1195
  projectId: "",
1126
1196
  templateId: C,
1127
1197
  templateType: Y,
1128
- name: m,
1129
- html: w.html,
1130
- css: w.css,
1131
- subject: n.templateType.id === "2" ? n?.subject ?? "" : "",
1132
- parent_id: W
1198
+ name: p,
1199
+ html: x.html,
1200
+ css: x.css,
1201
+ subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
1202
+ parent_id: Q
1133
1203
  };
1134
- await de(D) && (T(), ne(), I(), ee([]), te([]), b());
1204
+ await ue(R) && (A(), ae(), j(), se([]), ie([]), await g(), m("template", void 0));
1135
1205
  }
1136
1206
  );
1137
- }, Ge = (n) => {
1207
+ }, Je = (r) => {
1138
1208
  window.StripoEditorApi.actionsApi.getTemplateData(
1139
- async (d) => {
1140
- let m = n.template.id, C = "", E = u.find(
1141
- (D) => D.name === n.templateName.trim()
1209
+ async (c) => {
1210
+ let p = r.template.id, C = "", k = P.find(
1211
+ (R) => R.name === r.templateName.trim()
1142
1212
  );
1143
- if (E && E.id !== m) {
1144
- j("templateName", {
1213
+ if (k && k.id !== p) {
1214
+ h("templateName", {
1145
1215
  type: "validate",
1146
1216
  message: "Template name already exists. Please choose a different name."
1147
1217
  });
1148
1218
  return;
1149
1219
  }
1150
- let w = n.templateType.id;
1151
- O && O.length > 0 ? w = n.subTemplateType2.id : P && P.length > 0 && (w = n.subTemplateType.id);
1152
- const W = {
1220
+ let x = r.templateType.id;
1221
+ $ && $.length > 0 ? x = r.subTemplateType2.id : O && O.length > 0 && (x = r.subTemplateType.id);
1222
+ const Q = {
1153
1223
  enerexIdentifier: "",
1154
1224
  projectId: "",
1155
- templateId: m,
1156
- templateType: w,
1157
- name: n.templateName.trim(),
1158
- html: d.html,
1159
- css: d.css,
1160
- subject: n.templateType.id === "2" ? n?.subject ?? "" : "",
1225
+ templateId: p,
1226
+ templateType: x,
1227
+ name: r.templateName.trim(),
1228
+ html: c.html,
1229
+ css: c.css,
1230
+ subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
1161
1231
  parent_id: C
1162
1232
  };
1163
- if (await de(W)) {
1164
- T();
1165
- const D = await oe({ id: m });
1166
- D ? Z(D) : ne(), b();
1233
+ if (await ue(Q)) {
1234
+ A();
1235
+ const R = await me({ id: p });
1236
+ R ? re(R) : ae(), await g();
1167
1237
  }
1168
1238
  }
1169
1239
  );
1170
- }, Ke = () => {
1171
- ke("input"), pe(!0), me(!1);
1172
- }, Qe = (n) => {
1173
- if (G === "input") {
1174
- const d = L();
1175
- Ve(d, n || "");
1240
+ }, Xe = () => {
1241
+ He("input"), ye(!0), ge(!1);
1242
+ }, Ze = (r) => {
1243
+ if (W === "input") {
1244
+ const c = v();
1245
+ Ye(c, r || "");
1176
1246
  return;
1177
1247
  }
1178
- };
1179
- return /* @__PURE__ */ S(we, { children: [
1180
- /* @__PURE__ */ r(Se, { className: "border border-0 text-start", children: /* @__PURE__ */ r(Se.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ r("form", { children: /* @__PURE__ */ r("div", { className: "template-list-container gap-3", children: /* @__PURE__ */ S(Xe, { children: [
1181
- /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(
1182
- se,
1248
+ }, et = (r, c) => {
1249
+ let p = r.find((C) => C.id === c);
1250
+ if (p)
1251
+ return p.is_favourite;
1252
+ }, tt = async () => {
1253
+ let r = u("templateType")?.id;
1254
+ $ && $.length > 0 ? r = u("subTemplateType2")?.id : O && O.length > 0 && (r = u("subTemplateType")?.id), await d({
1255
+ categoryId: r ?? "",
1256
+ templateId: u("template")?.id ?? ""
1257
+ }), L && te({
1258
+ ...L,
1259
+ is_favourite: !0
1260
+ }), await g();
1261
+ }, le = u("templateType"), Ie = u("subTemplateType"), nt = u("subTemplateType2"), rt = u("template");
1262
+ return /* @__PURE__ */ S(Ee, { children: [
1263
+ /* @__PURE__ */ n(ke, { className: "border border-0 text-start", children: /* @__PURE__ */ n(ke.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ n("form", { children: /* @__PURE__ */ n("div", { className: "template-list-container gap-3", children: /* @__PURE__ */ S(ot, { children: [
1264
+ /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
1265
+ oe,
1183
1266
  {
1184
1267
  label: "Category",
1185
- control: N,
1268
+ control: _,
1186
1269
  error: y,
1187
- options: ce,
1270
+ options: fe,
1188
1271
  required: !0,
1189
- disabled: p || _ || A || $ || !l,
1272
+ disabled: T || N || I || q || o || !a,
1190
1273
  validation: {
1191
1274
  required: {
1192
1275
  value: !0,
1193
1276
  message: "Select a category"
1194
1277
  }
1195
1278
  },
1196
- ...a("templateType")
1279
+ ...b("templateType")
1197
1280
  }
1198
1281
  ) }),
1199
- P && P.length > 0 && /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(
1200
- se,
1282
+ O && O.length > 0 && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
1283
+ oe,
1201
1284
  {
1202
1285
  label: "Type",
1203
- control: N,
1286
+ control: _,
1204
1287
  error: y,
1205
- options: P,
1288
+ options: O,
1206
1289
  required: !0,
1207
- disabled: p || _ || A || $ || !l,
1290
+ disabled: T || N || I || q || o || !a,
1208
1291
  validation: {
1209
1292
  required: {
1210
1293
  value: !0,
1211
1294
  message: "Select a type"
1212
1295
  }
1213
1296
  },
1214
- ...a("subTemplateType")
1297
+ ...b("subTemplateType")
1215
1298
  }
1216
1299
  ) }),
1217
- O && O.length > 0 && /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(
1218
- se,
1300
+ $ && $.length > 0 && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
1301
+ oe,
1219
1302
  {
1220
1303
  label: "Sub Type",
1221
- control: N,
1304
+ control: _,
1222
1305
  error: y,
1223
- options: O,
1306
+ options: $,
1224
1307
  required: !0,
1225
- disabled: p || _ || A || $ || !l,
1308
+ disabled: T || N || I || q || o || !a,
1226
1309
  validation: {
1227
1310
  required: {
1228
1311
  value: !0,
1229
1312
  message: "Select a subtype"
1230
1313
  }
1231
1314
  },
1232
- ...a("subTemplateType2")
1315
+ ...b("subTemplateType2")
1233
1316
  }
1234
1317
  ) }),
1235
- /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(
1236
- se,
1318
+ /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
1319
+ oe,
1237
1320
  {
1238
1321
  label: "Template",
1239
- control: N,
1322
+ control: _,
1240
1323
  error: y,
1241
- disabled: p || _ || A || $ || !l,
1242
- options: ve(),
1324
+ disabled: T || N || I || q || o || !a,
1325
+ options: Ne(),
1243
1326
  required: !1,
1244
- ...a("template")
1327
+ ...b("template")
1245
1328
  }
1246
1329
  ) }),
1247
- /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(
1248
- Ee,
1249
- {
1250
- label: "Name",
1251
- register: a,
1252
- error: y,
1253
- required: !0,
1254
- name: "templateName",
1255
- validation: {
1256
- required: {
1257
- value: !0,
1258
- message: "Enter a name"
1330
+ /* @__PURE__ */ S(U, { className: "d-flex align-self-start", children: [
1331
+ /* @__PURE__ */ n(
1332
+ je,
1333
+ {
1334
+ label: "Name",
1335
+ register: b,
1336
+ error: y,
1337
+ required: !0,
1338
+ name: "templateName",
1339
+ validation: {
1340
+ required: {
1341
+ value: !0,
1342
+ message: "Enter a name"
1343
+ }
1259
1344
  }
1260
1345
  }
1261
- }
1262
- ) }),
1263
- f("templateType")?.id === "2" && /* @__PURE__ */ r(H, { children: /* @__PURE__ */ r(
1264
- Ee,
1346
+ ),
1347
+ Ie?.key?.toString() === "9" && /* @__PURE__ */ n(
1348
+ J,
1349
+ {
1350
+ className: "template-favourite-btn",
1351
+ style: { width: "26px", marginTop: "25px" },
1352
+ variant: "light",
1353
+ disabled: T || N || I || q || o || (L ? L?.is_favourite : !1),
1354
+ onClick: tt,
1355
+ children: N || I || o ? /* @__PURE__ */ n(
1356
+ z,
1357
+ {
1358
+ animation: "border",
1359
+ style: { width: "11px", height: "11px" },
1360
+ size: "sm",
1361
+ role: "status",
1362
+ className: "me-1",
1363
+ children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
1364
+ }
1365
+ ) : L ? L?.is_favourite ? /* @__PURE__ */ n(X, { variant: "filled" }) : /* @__PURE__ */ n(X, { variant: "outlined" }) : /* @__PURE__ */ n(X, { variant: "outlined" })
1366
+ }
1367
+ )
1368
+ ] }),
1369
+ le?.key?.toString() === "12" && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
1370
+ je,
1265
1371
  {
1266
1372
  label: "Subject",
1267
- register: a,
1373
+ register: b,
1268
1374
  error: y,
1269
1375
  required: !1,
1270
1376
  name: "subject"
1271
1377
  }
1272
1378
  ) }),
1273
- /* @__PURE__ */ S(H, { className: "d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding", children: [
1274
- /* @__PURE__ */ r(
1275
- re,
1379
+ /* @__PURE__ */ S(U, { className: "d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding", children: [
1380
+ /* @__PURE__ */ n(
1381
+ J,
1276
1382
  {
1277
1383
  style: { width: "70px" },
1278
1384
  variant: "primary",
1279
- disabled: p || _ || A || $ || !l,
1385
+ disabled: T || N || I || q || o || !a,
1280
1386
  onClick: () => {
1281
- V(void 0), I(), ee([]), te([]), o();
1387
+ te(void 0), j(), se([]), ie([]), l();
1282
1388
  },
1283
- children: _ || A ? /* @__PURE__ */ r(
1284
- J,
1389
+ children: N || I || o ? /* @__PURE__ */ n(
1390
+ z,
1285
1391
  {
1286
1392
  animation: "border",
1287
1393
  style: { width: "11px", height: "11px" },
1288
1394
  size: "sm",
1289
1395
  role: "status",
1290
1396
  className: "me-1",
1291
- children: /* @__PURE__ */ r("span", { className: "visually-hidden", children: "Loading..." })
1397
+ children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
1292
1398
  }
1293
1399
  ) : "Clear"
1294
1400
  }
1295
1401
  ),
1296
- (f("templateType")?.id.toString() !== "2" || (f("templateType")?.id.toString() === "2" && (q?.id ?? "")) !== "") && /* @__PURE__ */ S(we, { children: [
1297
- !(q?.readonly && i) && /* @__PURE__ */ r(
1298
- re,
1402
+ (le?.key?.toString() !== "12" || (le?.key?.toString() === "12" && (L?.id ?? "")) !== "") && /* @__PURE__ */ S(Ee, { children: [
1403
+ !(L?.readonly && i) && /* @__PURE__ */ n(
1404
+ J,
1299
1405
  {
1300
1406
  type: "button",
1301
- onClick: c(Fe),
1407
+ onClick: D(Qe),
1302
1408
  variant: "primary",
1303
1409
  style: { width: "80px" },
1304
- disabled: p || _ || A || $ || !l,
1305
- children: _ || A ? /* @__PURE__ */ r(
1306
- J,
1410
+ disabled: T || N || I || q || o || !a,
1411
+ children: N || I || o ? /* @__PURE__ */ n(
1412
+ z,
1307
1413
  {
1308
1414
  animation: "border",
1309
1415
  style: { width: "11px", height: "11px" },
1310
1416
  size: "sm",
1311
1417
  role: "status",
1312
1418
  className: "me-1",
1313
- children: /* @__PURE__ */ r("span", { className: "visually-hidden", children: "Loading..." })
1419
+ children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
1314
1420
  }
1315
- ) : q?.readonly ? "Save as" : "Save"
1421
+ ) : L?.readonly ? "Save as" : "Save"
1316
1422
  }
1317
1423
  ),
1318
- (f("templateType")?.id.toString() === "28" || f("subTemplateType")?.id.toString() === "9" && f("subTemplateType2")?.id.toString() === "12") && !!f("templateName")?.trim() && /* @__PURE__ */ r(
1319
- re,
1424
+ (le?.key?.toString() === "28" || Ie?.key?.toString() === "9" && nt?.key?.toString() === "3" && (rt?.id ?? "") !== "") && /* @__PURE__ */ n(
1425
+ J,
1320
1426
  {
1321
1427
  type: "button",
1322
1428
  variant: "primary",
1323
1429
  style: { width: "80px" },
1324
- onClick: () => Ke(),
1325
- disabled: p || _ || A || $ || !l,
1326
- children: _ || A ? /* @__PURE__ */ r(
1327
- J,
1430
+ onClick: () => Xe(),
1431
+ disabled: T || N || I || q || o || !a,
1432
+ children: N || I || o ? /* @__PURE__ */ n(
1433
+ z,
1328
1434
  {
1329
1435
  animation: "border",
1330
1436
  style: { width: "11px", height: "11px" },
1331
1437
  size: "sm",
1332
1438
  role: "status",
1333
1439
  className: "me-1",
1334
- children: /* @__PURE__ */ r("span", { className: "visually-hidden", children: "Loading..." })
1440
+ children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
1335
1441
  }
1336
1442
  ) : "Save as"
1337
1443
  }
1338
1444
  ),
1339
- q?.readonly && i && /* @__PURE__ */ r(
1340
- re,
1445
+ L?.readonly && i && /* @__PURE__ */ n(
1446
+ J,
1341
1447
  {
1342
1448
  type: "button",
1343
- onClick: c(Ge),
1449
+ onClick: D(Je),
1344
1450
  variant: "primary",
1345
1451
  style: { width: "80px" },
1346
- disabled: p || _ || A || $ || !l,
1347
- children: _ || A ? /* @__PURE__ */ r(
1348
- J,
1452
+ disabled: T || N || I || q || o || !a,
1453
+ children: N || I || o ? /* @__PURE__ */ n(
1454
+ z,
1349
1455
  {
1350
1456
  animation: "border",
1351
1457
  style: { width: "11px", height: "11px" },
1352
1458
  size: "sm",
1353
1459
  role: "status",
1354
1460
  className: "me-1",
1355
- children: /* @__PURE__ */ r("span", { className: "visually-hidden", children: "Loading..." })
1461
+ children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
1356
1462
  }
1357
1463
  ) : "Save"
1358
1464
  }
@@ -1360,70 +1466,70 @@ const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__
1360
1466
  ] })
1361
1467
  ] })
1362
1468
  ] }) }) }) }) }),
1363
- /* @__PURE__ */ r(
1364
- dt,
1469
+ /* @__PURE__ */ n(
1470
+ bt,
1365
1471
  {
1366
- show: $e,
1367
- variant: G,
1368
- title: G === "confirm" ? "Are you sure?" : "Save Template As",
1369
- message: G === "confirm" ? 'Are you sure you want to remove custom template ""?' : "",
1472
+ show: Ue,
1473
+ variant: W,
1474
+ title: W === "confirm" ? "Are you sure?" : "Save Template As",
1475
+ message: W === "confirm" ? 'Are you sure you want to remove custom template ""?' : "",
1370
1476
  label: "New Name",
1371
1477
  requiredMessage: "Enter a new name",
1372
- externalError: Re,
1478
+ externalError: Ve,
1373
1479
  externalErrorMessage: "Template name already exists. Please choose a different name",
1374
- confirmText: G === "confirm" ? "Ok" : "Save as",
1375
- confirmButtonVariant: G === "confirm" ? "danger" : "primary",
1376
- onConfirm: Qe,
1377
- onCancel: () => pe(!1),
1378
- onInputChange: () => me(!1)
1480
+ confirmText: W === "confirm" ? "Ok" : "Save as",
1481
+ confirmButtonVariant: W === "confirm" ? "danger" : "primary",
1482
+ onConfirm: Ze,
1483
+ onCancel: () => ye(!1),
1484
+ onInputChange: () => ge(!1)
1379
1485
  }
1380
1486
  )
1381
1487
  ] });
1382
- }, _t = ({ config: t }) => {
1383
- const [s, o] = v(!1), [l, i] = v(), [e, a] = v(!1);
1384
- x(() => {
1385
- t.isAdmin || a(!0);
1488
+ }, Rt = ({ config: t }) => {
1489
+ const [s, l] = w(!1), [a, i] = w(), [e, d] = w(!1);
1490
+ E(() => {
1491
+ t.isAdmin || d(!0);
1386
1492
  }, []);
1387
- const [c, T] = v(!1);
1388
- return /* @__PURE__ */ r(nt, { configs: t, children: /* @__PURE__ */ r(st, { children: /* @__PURE__ */ S("div", { className: "root-widget", children: [
1389
- /* @__PURE__ */ r(
1390
- Tt,
1493
+ const [o, b] = w(!1);
1494
+ return /* @__PURE__ */ n(pt, { configs: t, children: /* @__PURE__ */ n(ut, { children: /* @__PURE__ */ S("div", { className: "root-widget", children: [
1495
+ /* @__PURE__ */ n(
1496
+ kt,
1391
1497
  {
1392
- templateLoading: T,
1393
- onSelectItem: (f) => {
1394
- if (i(f), t.isAdmin && a(!0), window.StripoEditorApi && window.StripoEditorApi.actionsApi) {
1395
- let I = ie;
1498
+ templateLoading: b,
1499
+ onSelectItem: (m) => {
1500
+ if (i(m), t.isAdmin && d(!0), window.StripoEditorApi && window.StripoEditorApi.actionsApi) {
1501
+ let _ = de;
1396
1502
  console.log("selected template:"), window.StripoEditorApi.actionsApi.updateHtmlAndCss(
1397
- f?.html ?? I,
1398
- f?.css ?? "",
1503
+ m?.html ?? _,
1504
+ m?.css ?? "",
1399
1505
  ""
1400
1506
  );
1401
1507
  }
1402
1508
  },
1403
1509
  editorInitialized: s,
1404
1510
  onReset: () => {
1405
- T(!1), i(void 0), window.StripoEditorApi && window.StripoEditorApi.actionsApi && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
1406
- ie,
1511
+ b(!1), i(void 0), window.StripoEditorApi && window.StripoEditorApi.actionsApi && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
1512
+ de,
1407
1513
  "",
1408
1514
  ""
1409
1515
  );
1410
1516
  }
1411
1517
  }
1412
1518
  ),
1413
- e && /* @__PURE__ */ r(
1414
- ot,
1519
+ e && /* @__PURE__ */ n(
1520
+ ht,
1415
1521
  {
1416
- onEditorInitialized: o,
1522
+ onEditorInitialized: l,
1417
1523
  templateHTML: {
1418
- css: l?.css ?? "",
1419
- html: l?.html ?? ie
1524
+ css: a?.css ?? "",
1525
+ html: a?.html ?? de
1420
1526
  },
1421
- loading: c,
1527
+ loading: o,
1422
1528
  className: "col-span-5"
1423
1529
  }
1424
1530
  )
1425
1531
  ] }) }) });
1426
1532
  };
1427
1533
  export {
1428
- _t as EditorWidget
1534
+ Rt as EditorWidget
1429
1535
  };