@useinsider/guido 3.12.0-beta.4e0547f → 3.12.0-beta.66af948

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -161,6 +161,7 @@ const config: GuidoConfigInput = {
161
161
  modulesDisabled?: boolean, // Default: false - Disable modules panel
162
162
  liquidSyntax?: boolean, // Default: false - Enable Liquid template syntax
163
163
  autosave?: boolean, // Default: false - Show the Auto Save toggle in the header. See wiki/AUTOSAVE.md.
164
+ allowlistEnabled?: boolean, // Default: false - Pre-save domain-allowlist check (opt-in). Guido self-serves the block toaster (role lookup, deep-link, copy from window.trans).
164
165
  },
165
166
 
166
167
  // Optional: Callbacks
@@ -1,11 +1,11 @@
1
1
  import { ModuleFolderDefaults as y } from "../../enums/defaults.js";
2
- import { object as a, number as n, optional as e, string as t, picklist as l, pipe as p, minLength as b, custom as f, boolean as o, array as c, record as k, fallback as C, literal as i, looseObject as g, variant as R, union as h, unknown as s, lazy as T } from "../../node_modules/valibot/dist/index.js";
2
+ import { object as a, number as n, optional as e, string as t, picklist as r, pipe as p, minLength as b, custom as h, boolean as o, array as c, record as k, fallback as C, literal as i, looseObject as g, variant as R, union as f, unknown as s, lazy as T } from "../../node_modules/valibot/dist/index.js";
3
3
  const d = {
4
4
  /** Promotional/marketing emails */
5
5
  PROMOTIONAL: 1,
6
6
  /** Transactional/system emails */
7
7
  TRANSACTIONAL: 2
8
- }, r = {
8
+ }, l = {
9
9
  /** Standard email campaigns */
10
10
  EMAIL: 60,
11
11
  /** Architect journey builder */
@@ -38,16 +38,16 @@ const d = {
38
38
  ),
39
39
  /** Product type identifier */
40
40
  productType: e(
41
- l([
42
- r.EMAIL,
43
- r.ARCHITECT,
44
- r.UNSUBSCRIBE_PAGES
41
+ r([
42
+ l.EMAIL,
43
+ l.ARCHITECT,
44
+ l.UNSUBSCRIBE_PAGES
45
45
  ]),
46
- r.EMAIL
46
+ l.EMAIL
47
47
  ),
48
48
  /** Message type (promotional or transactional) */
49
49
  messageType: e(
50
- l([d.PROMOTIONAL, d.TRANSACTIONAL]),
50
+ r([d.PROMOTIONAL, d.TRANSACTIONAL]),
51
51
  d.PROMOTIONAL
52
52
  ),
53
53
  /** Display name for the current user */
@@ -76,14 +76,14 @@ const d = {
76
76
  children: e(c(S)),
77
77
  // eslint-disable-next-line camelcase -- backend field name
78
78
  select_items: e(c(S))
79
- })), P = k(
79
+ })), E = k(
80
80
  t(),
81
81
  C(c(S), [])
82
- ), D = g({
82
+ ), P = g({
83
83
  /** Block ID (matches the dictionary key and the legacy HTML element id) */
84
84
  id: e(n()),
85
85
  /** Decimal places for price display (legacy data may use string or number) */
86
- decimalCount: e(h([t(), n()])),
86
+ decimalCount: e(f([t(), n()])),
87
87
  /** Pinned product IDs (empty array when filter-driven) */
88
88
  productIds: e(c(s())),
89
89
  /** Whether the block requested live products at send time */
@@ -117,14 +117,14 @@ const d = {
117
117
  /** Block type marker used by some legacy variants */
118
118
  blockType: e(t()),
119
119
  /** Size variant marker (legacy data may use string or number) */
120
- size: e(h([t(), n()])),
120
+ size: e(f([t(), n()])),
121
121
  /** Vertical responsiveness flag (legacy size=1 variants) */
122
122
  verticalResponsiveness: e(o()),
123
123
  /** Legacy "Move to next line" price placement toggle (cardPricePlacement.js) */
124
124
  isPriceMovedToNextLine: e(o()),
125
125
  /** Legacy "Hide if same as discounted" / delete-price-for-zero-sale toggle */
126
126
  isPriceDeletedForZeroSale: e(o())
127
- }), E = a({
127
+ }), D = a({
128
128
  /**
129
129
  * Legacy recommendation block configs keyed by block ID.
130
130
  * Pass this when loading a template authored with the v1
@@ -132,7 +132,7 @@ const d = {
132
132
  * strategy, currency, locale, and layout data.
133
133
  */
134
134
  recommendationConfigs: e(
135
- k(t(), D),
135
+ k(t(), P),
136
136
  {}
137
137
  )
138
138
  }), M = a({
@@ -151,7 +151,7 @@ const d = {
151
151
  * (first) partner's leaf attributes into the label→token map that repairs
152
152
  * label-form placeholders (`{{ Phone Number }}`) in dropped saved modules.
153
153
  */
154
- dynamicContentList: e(P, {}),
154
+ dynamicContentList: e(E, {}),
155
155
  /** Valid custom field attribute names from the partner's categorized fields */
156
156
  customFieldAttributes: e(c(t()), []),
157
157
  /** Selected unsubscribe page IDs */
@@ -159,7 +159,7 @@ const d = {
159
159
  /** Force recreate template in Stripo storage (use true when updating externally modified templates) */
160
160
  forceRecreate: e(o(), !1),
161
161
  /** Migration-only inputs (legacy block configs) */
162
- migration: e(E, {})
162
+ migration: e(D, {})
163
163
  }), N = a({
164
164
  /** Sender display name */
165
165
  senderName: e(t(), ""),
@@ -201,8 +201,10 @@ const d = {
201
201
  /** Enable Liquid template syntax */
202
202
  liquidSyntax: e(o(), !1),
203
203
  /** Enable autosave (3-min interval + tab-hide). User toggles on/off from the header. */
204
- autosave: e(o(), !1)
205
- }), U = l([
204
+ autosave: e(o(), !1),
205
+ /** Enable pre-save domain-allowlist validation (opt-in; Guido self-serves the block toaster) */
206
+ allowlistEnabled: e(o(), !1)
207
+ }), U = r([
206
208
  "amp-accordion",
207
209
  "amp-carousel",
208
210
  "amp-form-controls",
@@ -216,7 +218,7 @@ const d = {
216
218
  "text-block",
217
219
  "timer-block",
218
220
  "video-block"
219
- ]), B = l([
221
+ ]), B = r([
220
222
  "dynamic-content",
221
223
  "checkbox-block",
222
224
  "radio-button-block",
@@ -269,7 +271,7 @@ const d = {
269
271
  ...m.entries,
270
272
  type: i("custom"),
271
273
  /** Custom processor function */
272
- processor: f(
274
+ processor: h(
273
275
  (u) => typeof u == "function",
274
276
  "processor must be a function"
275
277
  )
@@ -289,7 +291,7 @@ const d = {
289
291
  * Return false to cancel the save operation.
290
292
  */
291
293
  externalValidation: e(
292
- f(
294
+ h(
293
295
  (u) => typeof u == "function",
294
296
  "externalValidation must be a function"
295
297
  )
@@ -324,7 +326,7 @@ export {
324
326
  B as CustomBlockTypeSchema,
325
327
  q as CustomRuleSchema,
326
328
  U as DefaultBlockTypeSchema,
327
- P as DynamicContentListSchema,
329
+ E as DynamicContentListSchema,
328
330
  S as DynamicContentNodeSchema,
329
331
  v as DynamicContentSchema,
330
332
  O as EditorSchema,
@@ -333,14 +335,14 @@ export {
333
335
  F as FeaturesSchema,
334
336
  K as GuidoConfigSchema,
335
337
  A as IdentitySchema,
336
- D as LegacyRecommendationConfigSchema,
338
+ P as LegacyRecommendationConfigSchema,
337
339
  d as MessageType,
338
340
  L as PartnerSchema,
339
- r as ProductType,
341
+ l as ProductType,
340
342
  _ as RegexRuleSchema,
341
343
  j as RemoveRuleSchema,
342
344
  H as ReplaceRuleSchema,
343
- E as TemplateMigrationSchema,
345
+ D as TemplateMigrationSchema,
344
346
  M as TemplateSchema,
345
347
  x as UISchema
346
348
  };
@@ -12,7 +12,7 @@ var t = function() {
12
12
  n,
13
13
  !1,
14
14
  null,
15
- "daf7d5f8"
15
+ "50dac6de"
16
16
  );
17
17
  const l = s.exports;
18
18
  export {
@@ -1,149 +1,140 @@
1
- import { defineComponent as q, defineAsyncComponent as M, ref as U, computed as _, watch as B, onMounted as K, onUnmounted as V } from "vue";
2
- import { useCortexBlueprintBridge as j } from "../composables/useCortexBlueprintBridge.js";
3
- import { provideGuidoActions as J } from "../composables/useGuidoActions.js";
4
- import { useGuidoStateBridge as Q } from "../composables/useGuidoStateBridge.js";
5
- import { usePartner as X } from "../composables/usePartner.js";
6
- import { useStripo as Y } from "../composables/useStripo.js";
7
- import { useTimerClone as Z } from "../composables/useTimerClone.js";
8
- import { migrate as I } from "../config/migrator/index.js";
9
- import { ModuleFolderDefaults as N } from "../enums/defaults.js";
10
- import { RIBBON_SELECTOR as ee } from "../enums/onboarding.js";
11
- import { useRecommendationExtensionStore as te } from "../extensions/Blocks/Recommendation/store/recommendation.js";
12
- import oe from "./organisms/AutoSaveController.vue.js";
13
- import ne from "./organisms/base/Toaster.vue.js";
14
- import re from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
15
- import se from "./organisms/header/HeaderWrapper.vue.js";
16
- import ie from "./organisms/LoadingWrapper.vue.js";
17
- import ae from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
18
- import ce from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
19
- import { useStripoApi as de } from "../services/stripoApi.js";
20
- import { useConfigStore as me } from "../stores/config.js";
21
- import { useDynamicContentStore as le } from "../stores/dynamic-content.js";
22
- import { useEditorStore as O } from "../stores/editor.js";
23
- import { usePreviewStore as ue } from "../stores/preview.js";
24
- import { useTemplateStore as pe } from "../stores/template.js";
25
- import { useUnsubscribeStore as fe } from "../stores/unsubscribe.js";
26
- const xe = /* @__PURE__ */ q({
1
+ import { defineComponent as X, defineAsyncComponent as I, ref as W, computed as x, watch as Y, onMounted as Z, onUnmounted as ee } from "vue";
2
+ import { useCortexBlueprintBridge as oe } from "../composables/useCortexBlueprintBridge.js";
3
+ import { provideGuidoActions as te } from "../composables/useGuidoActions.js";
4
+ import { useGuidoStateBridge as ne } from "../composables/useGuidoStateBridge.js";
5
+ import { usePartner as re } from "../composables/usePartner.js";
6
+ import { useStripo as se } from "../composables/useStripo.js";
7
+ import { useTimerClone as ae } from "../composables/useTimerClone.js";
8
+ import { migrate as G } from "../config/migrator/index.js";
9
+ import { ModuleFolderDefaults as H } from "../enums/defaults.js";
10
+ import { RIBBON_SELECTOR as ce } from "../enums/onboarding.js";
11
+ import { useRecommendationExtensionStore as ie } from "../extensions/Blocks/Recommendation/store/recommendation.js";
12
+ import me from "./organisms/AutoSaveController.vue.js";
13
+ import de from "./organisms/base/Toaster.vue.js";
14
+ import le from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
15
+ import ue from "./organisms/header/HeaderWrapper.vue.js";
16
+ import pe from "./organisms/LoadingWrapper.vue.js";
17
+ import fe from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
18
+ import ve from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
19
+ import { useStripoApi as Se } from "../services/stripoApi.js";
20
+ import { useConfigStore as ye } from "../stores/config.js";
21
+ import { useDynamicContentStore as he } from "../stores/dynamic-content.js";
22
+ import { useEditorStore as $ } from "../stores/editor.js";
23
+ import { usePreviewStore as ge } from "../stores/preview.js";
24
+ import { useTemplateStore as be } from "../stores/template.js";
25
+ import { useUnsubscribeStore as Ee } from "../stores/unsubscribe.js";
26
+ const Ve = /* @__PURE__ */ X({
27
27
  __name: "Guido",
28
28
  props: {
29
- config: null,
30
- ready: { type: Boolean, default: !0 }
29
+ config: null
31
30
  },
32
31
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
33
- setup(P, { expose: A, emit: n }) {
34
- const i = P, W = M(
32
+ setup(z, { expose: q, emit: n }) {
33
+ const b = z, K = I(
35
34
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
36
- ), x = M(
35
+ ), V = I(
37
36
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
38
- ), g = U(), l = U(), u = le(), S = fe(), o = me();
39
- i.ready && o.init(i.config);
40
- const d = O(), G = ue(), m = _(() => d.hasChanges), { isTestPartner: H } = X(), h = () => {
41
- var t;
42
- return (t = g.value) == null ? void 0 : t.handleSave(!0);
43
- }, b = (t) => {
44
- d.loadingStatus = t;
45
- };
46
- j(), Q();
47
- const p = () => {
48
- var t, e;
49
- return {
50
- emailId: o.templateId,
51
- userId: o.userId,
52
- username: o.username,
53
- partnerName: o.partnerName,
54
- savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || N.SAVED_MODULES,
55
- defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || N.DEFAULT_MODULES
56
- };
57
- }, { initPlugin: E, preloadRuntime: w } = Y(), { getDefaultTemplate: C } = de(), { cloneTimersOnSave: D, hasTimerBlocks: T } = Z(), $ = _(() => {
58
- var t;
59
- return !((t = o.ui) != null && t.showHeader);
37
+ ), E = W(), p = W(), f = he(), w = Ee(), i = ye();
38
+ i.init(b.config);
39
+ const m = $(), j = ge(), d = x(() => m.hasChanges), { isTestPartner: J } = re(), D = () => {
40
+ var e;
41
+ return (e = E.value) == null ? void 0 : e.handleSave(!0);
42
+ }, C = (e) => {
43
+ m.loadingStatus = e;
44
+ }, {
45
+ templateId: v,
46
+ userId: T,
47
+ partnerName: L,
48
+ username: k,
49
+ template: o,
50
+ editor: s
51
+ } = i, l = (o == null ? void 0 : o.html) || "", F = (o == null ? void 0 : o.css) || "", S = (o == null ? void 0 : o.preselectedDynamicContent) || [], U = (s == null ? void 0 : s.savedModulesFolderName) || H.SAVED_MODULES, _ = (s == null ? void 0 : s.defaultModulesFolderName) || H.DEFAULT_MODULES;
52
+ oe(), ne();
53
+ const y = {
54
+ emailId: v,
55
+ userId: T,
56
+ username: k,
57
+ partnerName: L,
58
+ savedModulesFolderName: U,
59
+ defaultModulesFolderName: _
60
+ }, M = {
61
+ preselectedDynamicContentList: S,
62
+ onReady: () => {
63
+ console.debug("guido:ready"), n("ready");
64
+ }
65
+ }, { initPlugin: O } = se(y, M), { getDefaultTemplate: P } = Se(), { cloneTimersOnSave: R, hasTimerBlocks: A } = ae(), Q = x(() => {
66
+ var e;
67
+ return !((e = i.ui) != null && e.showHeader);
60
68
  });
61
- J({
69
+ te({
62
70
  onBack: () => {
63
71
  console.debug("guido:back"), n("back");
64
72
  },
65
73
  onSaveStart: () => {
66
74
  console.debug("guido:save:start"), n("save:start");
67
75
  },
68
- onSaveComplete: (t) => {
69
- const e = { ...t, metadata: p() };
70
- console.debug("guido:save:complete", e), n("save:complete", e);
76
+ onSaveComplete: (e) => {
77
+ const t = { ...e, metadata: y };
78
+ console.debug("guido:save:complete", t), n("save:complete", t);
71
79
  },
72
80
  onTestEmailClick: () => {
73
81
  console.debug("guido:test-email:click"), n("test-email:click");
74
82
  }
75
83
  });
76
- const L = (t) => {
77
- console.debug("dynamic-content:close", t), u.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
78
- }, R = () => {
84
+ const B = (e) => {
85
+ console.debug("dynamic-content:close", e), f.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
86
+ }, N = () => {
79
87
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
80
88
  };
81
- B(() => m.value, () => {
82
- n("on-change", m.value);
89
+ Y(() => d.value, () => {
90
+ n("on-change", d.value);
83
91
  });
84
- const f = (t) => {
85
- const e = t, { attribute: s, position: c } = e.detail;
86
- console.debug("dynamic-content:open", e.detail), n("dynamic-content:open", s, c);
92
+ const h = (e) => {
93
+ const t = e, { attribute: u, position: c } = t.detail;
94
+ console.debug("dynamic-content:open", t.detail), n("dynamic-content:open", u, c);
87
95
  };
88
96
  let a = null;
89
- const y = () => {
90
- var e;
91
- const t = document.querySelector(ee);
92
- (e = l.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
93
- }, v = async () => {
97
+ const g = () => {
94
98
  var t;
99
+ const e = document.querySelector(ce);
100
+ (t = p.value) == null || t.style.setProperty("--ribbon-offset", `${(e == null ? void 0 : e.offsetHeight) ?? 0}px`);
101
+ };
102
+ return Z(async () => {
103
+ var t, u;
104
+ console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), ie().$reset(), $().$reset(), m.templateId = v, be().$reset(), g();
105
+ const e = (t = p.value) == null ? void 0 : t.parentElement;
106
+ e && (a = new ResizeObserver(g), a.observe(e));
95
107
  try {
96
- o.initialized || o.init(i.config), d.templateId = o.templateId;
97
- const e = o.template, s = (e == null ? void 0 : e.html) || "", c = (e == null ? void 0 : e.css) || "", k = (e == null ? void 0 : e.preselectedDynamicContent) || [];
98
- S.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
99
- const F = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {};
108
+ w.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
109
+ const c = ((u = o == null ? void 0 : o.migration) == null ? void 0 : u.recommendationConfigs) ?? {};
100
110
  let r = {
101
- html: s && await I(s, F),
102
- css: c
103
- };
104
- r.html || (r = await C(), r.html = await I(r.html, F)), T(r.html) && (r.html = await D(r.html));
105
- const z = {
106
- preselectedDynamicContentList: k,
107
- onReady: () => {
108
- console.debug("guido:ready"), n("ready");
109
- }
111
+ html: l && await G(l, c),
112
+ css: F
110
113
  };
111
- await E(r, p(), z), u.selectedDynamicContentList = k;
112
- } catch (e) {
113
- console.error("Failed to initialize Stripo editor:", e);
114
- }
115
- };
116
- return K(async () => {
117
- var e;
118
- console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), te().$reset(), O().$reset(), pe().$reset(), y();
119
- const t = (e = l.value) == null ? void 0 : e.parentElement;
120
- if (t && (a = new ResizeObserver(y), a.observe(t)), w(), i.ready)
121
- await v();
122
- else {
123
- const s = B(() => i.ready, (c) => {
124
- c && (s(), v());
125
- });
114
+ r.html || (r = await P(), r.html = await G(r.html, c)), A(r.html) && (r.html = await R(r.html)), await O(r), f.selectedDynamicContentList = S;
115
+ } catch (c) {
116
+ console.error("Failed to initialize Stripo editor:", c);
126
117
  }
127
- document.addEventListener("dynamic-content:open", f);
128
- }), V(() => {
129
- a == null || a.disconnect(), document.removeEventListener("dynamic-content:open", f);
118
+ document.addEventListener("dynamic-content:open", h);
119
+ }), ee(() => {
120
+ a == null || a.disconnect(), document.removeEventListener("dynamic-content:open", h);
130
121
  try {
131
122
  window.UIEditor.removeEditor();
132
123
  } catch {
133
124
  console.debug("Failed to remove Stripo editor: No editor found");
134
125
  }
135
- o.reset();
136
- }), A({
126
+ i.reset();
127
+ }), q({
137
128
  dynamicContent: {
138
- insert: L,
139
- close: R
129
+ insert: B,
130
+ close: N
140
131
  },
141
- hasChanges: m,
142
- saveSilent: h,
143
- setLoading: b
144
- }), { __sfc: !0, PreviewContainer: W, OnboardingWrapper: x, headerWrapperRef: g, wrapperRef: l, dynamicContentStore: u, unsubscribeStore: S, props: i, configStore: o, editorStore: d, previewStore: G, hasChanges: m, isTestPartner: H, saveSilent: h, setLoading: b, emit: n, buildMetadata: p, initPlugin: E, preloadRuntime: w, getDefaultTemplate: C, cloneTimersOnSave: D, hasTimerBlocks: T, noHeader: $, insertDynamicContent: L, closeDynamicContent: R, handleDynamicContentOpen: f, ribbonObserver: a, updateRibbonOffset: y, startEditor: v, AutoSaveController: oe, Toaster: ne, FilterSelectionDrawer: re, HeaderWrapper: se, LoadingWrapper: ie, SaveAsTemplateDrawer: ae, UnsubscribeWrapper: ce };
132
+ hasChanges: d,
133
+ saveSilent: D,
134
+ setLoading: C
135
+ }), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: V, headerWrapperRef: E, wrapperRef: p, dynamicContentStore: f, unsubscribeStore: w, props: b, configStore: i, editorStore: m, previewStore: j, hasChanges: d, isTestPartner: J, saveSilent: D, setLoading: C, templateId: v, userId: T, partnerName: L, username: k, templateConfig: o, editorConfig: s, html: l, css: F, preselectedDynamicContentList: S, savedModulesFolderName: U, defaultModulesFolderName: _, emit: n, metadata: y, options: M, initPlugin: O, getDefaultTemplate: P, cloneTimersOnSave: R, hasTimerBlocks: A, noHeader: Q, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: h, ribbonObserver: a, updateRibbonOffset: g, AutoSaveController: me, Toaster: de, FilterSelectionDrawer: le, HeaderWrapper: ue, LoadingWrapper: pe, SaveAsTemplateDrawer: fe, UnsubscribeWrapper: ve };
145
136
  }
146
137
  });
147
138
  export {
148
- xe as default
139
+ Ve as default
149
140
  };
@@ -0,0 +1,50 @@
1
+ import { useAllowlistApi as A } from "../services/allowlistApi.js";
2
+ import { base64EncodeWithSpecialChars as p } from "../utils/base64.js";
3
+ import { useTranslations as h } from "./useTranslations.js";
4
+ import { useUserRole as D } from "./useUserRole.js";
5
+ const f = /(?:https?:\/\/|www\.)[^\s"'<>()]+/gi, E = /&quot;\/\//gi, i = {
6
+ MANAGE: "journey-builder.domain-allowlist-warning",
7
+ NON_MANAGE: "settings.allow-list-warning-not-admin-architect",
8
+ ADD_BUTTON: "settings.allow-list-warning-add-button"
9
+ }, w = /* @__PURE__ */ new Set(), O = (n) => `/settings?openAddModal=true&type=domain&values=${p(n)}#security`, M = () => {
10
+ const { checkDomain: n } = A(), { getIsManageUser: l } = D(), a = h(), d = (t, s) => {
11
+ const c = `${t || ""} ${s || ""}`.replace(E, "https://").match(f) || [], e = /* @__PURE__ */ new Set();
12
+ return c.forEach((r) => {
13
+ const g = /^https?:\/\//i.test(r) ? r : `https://${r}`;
14
+ try {
15
+ const { hostname: u } = new URL(g);
16
+ u && e.add(u.replace(/^www\./i, "").toLowerCase());
17
+ } catch {
18
+ }
19
+ }), [...e];
20
+ }, m = async (t) => {
21
+ if (w.has(t))
22
+ return !0;
23
+ try {
24
+ const s = await n(t);
25
+ return s && w.add(t), s;
26
+ } catch (s) {
27
+ return console.error("[GUIDO_ALLOWLIST] isDomainAllowlisted failed", t, s), !0;
28
+ }
29
+ };
30
+ return { getBlockedDomains: async (t, s) => {
31
+ try {
32
+ const o = d(t, s);
33
+ return o.length ? (await Promise.all(
34
+ o.map(async (e) => ({ domain: e, allowlisted: await m(e) }))
35
+ )).filter((e) => !e.allowlisted).map((e) => e.domain) : [];
36
+ } catch (o) {
37
+ return console.error("[GUIDO_ALLOWLIST] getBlockedDomains failed", o), [];
38
+ }
39
+ }, resolveToast: async (t) => await l() ? {
40
+ message: a(i.MANAGE),
41
+ actionButton: {
42
+ text: a(i.ADD_BUTTON),
43
+ onClick: () => window.open(O(t.join(",")), "_blank")
44
+ }
45
+ } : { message: a(i.NON_MANAGE) } };
46
+ };
47
+ export {
48
+ O as buildAllowlistSettingsUrl,
49
+ M as useAllowlist
50
+ };
@@ -1,32 +1,51 @@
1
- import { useActionsApi as H } from "./useActionsApi.js";
2
- import { useConfig as y } from "./useConfig.js";
3
- import { useSaveStart as w, useSaveComplete as k } from "./useGuidoActions.js";
1
+ import { useActionsApi as T } from "./useActionsApi.js";
2
+ import { useConfig as k } from "./useConfig.js";
3
+ import { useSaveStart as B, useSaveComplete as E } from "./useGuidoActions.js";
4
4
  import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
5
- import { useStripoApi as C } from "../services/stripoApi.js";
6
- import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
7
- import { useHtmlValidator as B } from "./useHtmlValidator.js";
8
- import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
9
- import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
10
- import { useUnsubscribeBlockValidator as U } from "./validators/useUnsubscribeBlockValidator.js";
11
- const K = () => {
12
- const o = w(), s = k(), { validateHtml: r } = B(), { validateLiquidSyntax: l } = P(), { validateCouponBlockTags: n } = L(), { validateUnsubscribeBlockUniqueness: d, validateUnsubscribeBlockHasTemplate: c } = U(), { callbacks: i, isFeatureEnabled: u } = y(), { extractSyncModuleData: m } = q(), { setSyncModuleUnsubscriptionPages: p } = C(), { editorSave: v } = H();
13
- return { save: async (f = !1, S = !1) => {
14
- var a;
15
- o();
16
- const { prepareTemplateDetails: V } = E(), t = await V();
17
- if (!n(t.compiledHtml) || !d(t.compiledHtml) || !c(t.compiledHtml))
5
+ import { ToasterTypeOptions as C } from "../enums/toaster.js";
6
+ import { useStripoApi as D } from "../services/stripoApi.js";
7
+ import { useTemplatePreparation as L } from "../utils/templatePreparation.js";
8
+ import { useAllowlist as P } from "./useAllowlist.js";
9
+ import { useHtmlValidator as U } from "./useHtmlValidator.js";
10
+ import { useToaster as A } from "./useToaster.js";
11
+ import { useCouponBlockValidator as M } from "./validators/useCouponBlockValidator.js";
12
+ import { useLiquidValidator as h } from "./validators/useLiquidValidator.js";
13
+ import { useUnsubscribeBlockValidator as F } from "./validators/useUnsubscribeBlockValidator.js";
14
+ const $ = () => {
15
+ const n = B(), l = E(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = h(), { validateCouponBlockTags: m } = M(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = F(), { callbacks: e, isFeatureEnabled: a } = k(), { extractSyncModuleData: f } = q(), { setSyncModuleUnsubscriptionPages: v } = D(), { editorSave: S } = T(), { showToaster: b } = A(), { getBlockedDomains: w, resolveToast: V } = P();
16
+ return { save: async (y = !1, s = !1) => {
17
+ var r;
18
+ n();
19
+ const { prepareTemplateDetails: H } = L(), t = await H();
20
+ if (!m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
18
21
  return;
19
- if (u("liquidSyntax")) {
20
- if (!await l(t.compiledHtml))
22
+ if (a("liquidSyntax")) {
23
+ if (!await d(t.compiledHtml))
21
24
  return;
22
- } else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
25
+ } else if (!await c(t.compiledHtml, t.dynamicContentList, !0))
23
26
  return;
24
- if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await v())
27
+ if ((r = e.value) != null && r.externalValidation && !await e.value.externalValidation(t))
25
28
  return;
26
- const { unsubscribePayload: b, stripoModules: x } = m(t.rawHtml);
27
- return await p(b), t.modules = x, f || s({ ...t, silent: S }), t;
29
+ if (a("allowlistEnabled")) {
30
+ const i = await w(t.compiledHtml, t.css);
31
+ if (i.length) {
32
+ if (!s) {
33
+ const o = await V(i);
34
+ o != null && o.message && b({
35
+ type: C.Warning,
36
+ message: o.message,
37
+ actionButton: o.actionButton
38
+ });
39
+ }
40
+ return;
41
+ }
42
+ }
43
+ if (!await S())
44
+ return;
45
+ const { unsubscribePayload: g, stripoModules: x } = f(t.rawHtml);
46
+ return await v(g), t.modules = x, y || l({ ...t, silent: s }), t;
28
47
  } };
29
48
  };
30
49
  export {
31
- K as useSave
50
+ $ as useSave
32
51
  };