@useinsider/guido 3.26.0-beta.d0b09c0 → 3.26.0-beta.df8736b

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,160 +1,146 @@
1
- var _ = Object.defineProperty;
2
- var $ = (f, e, t) => e in f ? _(f, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : f[e] = t;
3
- var k = (f, e, t) => $(f, typeof e != "symbol" ? e + "" : e, t);
4
- import { MERGE_TAGS as c, PAGE_TYPES as T } from "../../enums/unsubscribe.js";
5
- import { UNSUBSCRIBE_BLOCK_SELECTOR as y, DATA_ATTRIBUTES as d, UNSUBSCRIBE_MERGE_TAG_REGEX as h } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { swapMergeTagInHref as B } from "../../extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js";
7
- import { parsePageList as P } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { useUnsubscribeStore as M } from "../../stores/unsubscribe.js";
9
- import { escapeHtml as A } from "../../utils/htmlEscape.js";
10
- const S = "unsubscribe", N = "You can ", R = " from our emails, if you need to.", C = "{-{-UNSUBSCRIBE-LINK-}-}";
11
- class H {
1
+ var x = Object.defineProperty;
2
+ var B = (c, e, r) => e in c ? x(c, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : c[e] = r;
3
+ var A = (c, e, r) => B(c, typeof e != "symbol" ? e + "" : e, r);
4
+ import { MERGE_TAGS as f, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
5
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as h, DATA_ATTRIBUTES as k } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
7
+ class $ {
12
8
  constructor() {
13
- k(this, "parser");
9
+ A(this, "parser");
14
10
  this.parser = new DOMParser();
15
11
  }
16
12
  async migrate(e) {
17
13
  try {
18
- const t = this.parser.parseFromString(e, "text/html"), r = t.querySelectorAll("td.unsubscribe-block");
19
- if (r.length) {
20
- const i = M();
21
- await i.fetchTemplates(), this.migrateLegacyBlocks(r, i, this.collectBlockTags(t, i));
14
+ const r = this.parser.parseFromString(e, "text/html"), t = r.querySelectorAll("td.unsubscribe-block");
15
+ if (t.length) {
16
+ const s = C();
17
+ await s.fetchTemplates(), this.migrateLegacyBlocks(t, s);
22
18
  }
23
- const s = this.repairUnsubscribeLinks(t);
24
- return !r.length && !s ? e : t.documentElement.outerHTML;
25
- } catch (t) {
26
- return console.error("UnsubscribeMigrator failed:", t), e;
19
+ const n = this.repairUnsubscribeLinks(r);
20
+ return !t.length && !n ? e : r.documentElement.outerHTML;
21
+ } catch (r) {
22
+ return console.error("UnsubscribeMigrator failed:", r), e;
27
23
  }
28
24
  }
29
- migrateLegacyBlocks(e, t, r) {
30
- e.forEach((s) => {
31
- const i = s.getAttribute("id"), n = this.extractPaddingClass(s), o = s.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(s, r), b = this.getCollectionTypeFromMergeTag(a.linkHref), u = t.getSelectedUnsubscribePagesByCollection(b);
25
+ migrateLegacyBlocks(e, r) {
26
+ e.forEach((t) => {
27
+ const n = t.getAttribute("id"), s = this.extractPaddingClass(t), l = t.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(t), o = this.getCollectionTypeFromMergeTag(a.linkHref), b = r.getSelectedUnsubscribePagesByCollection(o);
32
28
  console.debug("[UnsubscribeMigrator]", {
33
29
  mergeTag: a.linkHref,
34
- collectionType: b,
35
- pageIds: u,
36
- paddingClass: n,
37
- bgColor: o
30
+ collectionType: o,
31
+ pageIds: b,
32
+ paddingClass: s,
33
+ bgColor: l
38
34
  });
39
- const l = this.buildUnsubscribeBlock(
35
+ const u = this.buildUnsubscribeBlock(
40
36
  a,
37
+ o,
41
38
  b,
42
- u,
43
- n,
44
- o
45
- ), g = this.parser.parseFromString(
46
- `<table id="tempDoc"><tbody><tr>${l}</tr></tbody></table>`,
39
+ s,
40
+ l
41
+ ), i = this.parser.parseFromString(
42
+ `<table id="tempDoc"><tbody><tr>${u}</tr></tbody></table>`,
47
43
  "text/html"
48
- ).querySelector(y);
49
- g && s.parentNode && (g.setAttribute("id", i || ""), s.parentNode.replaceChild(g, s));
44
+ ).querySelector(h);
45
+ i && t.parentNode && (i.setAttribute("id", n || ""), t.parentNode.replaceChild(i, t));
50
46
  });
51
47
  }
52
- // The compiler resolves a typed tag only through a block that lists pages, so a page-less block carries no tag.
53
- collectBlockTags(e, t) {
54
- const r = /* @__PURE__ */ new Set();
55
- return e.querySelectorAll(y).forEach((s) => {
56
- var a, b, u;
57
- if (!P(s.getAttribute(d.PAGE_LIST) || "").length)
58
- return;
59
- const i = Number(s.getAttribute(d.PAGE_TYPE)), n = c[i];
60
- if (n) {
61
- r.add(n);
62
- return;
63
- }
64
- const o = (u = (b = (a = this.findLinkCandidates(s).primary) == null ? void 0 : a.getAttribute("href")) == null ? void 0 : b.match(h)) == null ? void 0 : u[0];
65
- o && r.add(c[this.getCollectionTypeFromMergeTag(o)]);
66
- }), e.querySelectorAll("td.unsubscribe-block").forEach((s) => {
67
- const i = this.getCollectionTypeFromMergeTag(this.getLegacyLinkTag(s));
68
- t.getSelectedUnsubscribePagesByCollection(i).length && r.add(c[i]);
69
- }), r;
70
- }
71
- // Mirrors extractUnsubscribeContent: without a <p> the block migrates on the default tag.
72
- getLegacyLinkTag(e) {
73
- var r, s;
74
- const { primary: t } = this.findLinkCandidates(e);
75
- return !t || !(t.closest("p") || e.querySelector("p")) ? c.default : ((s = (r = t.getAttribute("href")) == null ? void 0 : r.match(h)) == null ? void 0 : s[0]) ?? c.default;
76
- }
77
48
  // Re-derives the typed merge tag from data-unsubscribe-page-type for any v2
78
49
  // block whose anchor href is missing or the legacy default. Returns true when
79
50
  // at least one href was rewritten. Typed tags and custom URLs are left intact.
80
51
  repairUnsubscribeLinks(e) {
81
- const t = e.querySelectorAll(`${y}[${d.PAGE_TYPE}]`);
82
- let r = !1;
83
- return t.forEach((s) => {
84
- const i = s.querySelector('a[data-unsubscribe-link="true"], a.unsubscribe-link');
85
- if (!i)
52
+ const r = e.querySelectorAll(`${h}[${k.PAGE_TYPE}]`);
53
+ let t = !1;
54
+ return r.forEach((n) => {
55
+ const s = n.querySelector('a[data-unsubscribe-link="true"], a.unsubscribe-link');
56
+ if (!s)
86
57
  return;
87
- const n = i.getAttribute("href") || "";
88
- if (n && n !== c.default)
58
+ const l = s.getAttribute("href") || "";
59
+ if (l && l !== f.default)
89
60
  return;
90
- const o = Number(s.getAttribute(d.PAGE_TYPE)), a = c[o];
91
- a && (i.setAttribute("href", a), r = !0);
92
- }), r;
61
+ const a = Number(n.getAttribute(k.PAGE_TYPE)), o = f[a];
62
+ o && (s.setAttribute("href", o), t = !0);
63
+ }), t;
93
64
  }
94
65
  extractPaddingClass(e) {
95
- const r = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
96
- return r ? r[0] : "";
97
- }
98
- hasVisibleContent(e) {
99
- var t;
100
- return !!((t = e.textContent) != null && t.trim() || e.querySelector("img"));
66
+ const t = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
67
+ return t ? t[0] : "";
101
68
  }
102
- findLinkCandidates(e) {
103
- const t = Array.from(/* @__PURE__ */ new Set([
104
- ...Array.from(e.querySelectorAll("a.unsubscribe-link")),
105
- ...Array.from(e.querySelectorAll('a[href*="unsubscribe"]'))
106
- ])), r = (n) => h.test(n.getAttribute("href") || ""), s = (n) => this.hasVisibleContent(n), i = t.find((n) => s(n) && r(n)) ?? t.find((n) => s(n) && n.classList.contains("unsubscribe-link")) ?? t.find(r) ?? t.find(s) ?? t[0];
107
- return { candidates: t, primary: i };
108
- }
109
- extractUnsubscribeContent(e, t) {
110
- const r = e.cloneNode(!0), { candidates: s, primary: i } = this.findLinkCandidates(r), n = (i == null ? void 0 : i.closest("p")) ?? null, o = n || r.querySelector("p"), a = {
111
- footerHtml: "",
112
- linkText: S,
113
- linkHref: c.default,
114
- linkStyle: "",
115
- align: "center",
116
- paragraphStyle: ""
69
+ extractUnsubscribeContent(e) {
70
+ var d;
71
+ const r = e.querySelector("a.unsubscribe-link") || e.querySelector('a[href*="unsubscribe"]'), t = (r == null ? void 0 : r.closest("p")) || e.querySelector("p");
72
+ if (!t)
73
+ return {
74
+ textBefore: "You can ",
75
+ linkText: "unsubscribe",
76
+ linkHref: "{{ins-unsubscribe-link}}",
77
+ linkStyle: "",
78
+ textAfter: " from our emails, if you need to.",
79
+ isBold: !1,
80
+ isItalic: !1,
81
+ align: "center",
82
+ paragraphStyle: ""
83
+ };
84
+ const n = e.getAttribute("align") || t.getAttribute("align") || "center", s = t.getAttribute("style") || "";
85
+ if (!r)
86
+ return {
87
+ textBefore: "You can ",
88
+ linkText: "unsubscribe",
89
+ linkHref: "{{ins-unsubscribe-link}}",
90
+ linkStyle: "",
91
+ textAfter: " from our emails, if you need to.",
92
+ isBold: !1,
93
+ isItalic: !1,
94
+ align: n,
95
+ paragraphStyle: s
96
+ };
97
+ const l = ((d = r.textContent) == null ? void 0 : d.trim()) || "unsubscribe", a = r.getAttribute("href") || "{{ins-unsubscribe-link}}", o = r.getAttribute("style") || "", b = t.textContent || "", u = b.indexOf(l), g = u >= 0 ? b.substring(0, u).trim() : "You can ", i = u >= 0 ? b.substring(u + l.length).trim() : " from our emails, if you need to.", m = !!t.querySelector("b, strong"), y = !!t.querySelector("i, em");
98
+ return {
99
+ textBefore: g,
100
+ linkText: l,
101
+ linkHref: this.normalizeUnsubscribeHref(a),
102
+ linkStyle: o,
103
+ textAfter: i,
104
+ isBold: m,
105
+ isItalic: y,
106
+ align: n,
107
+ paragraphStyle: s
117
108
  };
118
- if (!o || (a.align = e.getAttribute("align") || o.getAttribute("align") || "center", n || (a.paragraphStyle = o.getAttribute("style") || ""), !i))
119
- return a;
120
- if (a.linkText = this.hasVisibleContent(i) ? i.innerHTML.trim() : S, a.linkHref = this.normalizeUnsubscribeHref(i.getAttribute("href") || c.default), a.linkStyle = i.getAttribute("style") || "", n) {
121
- const b = this.getCollectionTypeFromMergeTag(a.linkHref), u = c[b];
122
- r.querySelectorAll("a[href]").forEach((l) => {
123
- var m;
124
- const p = l.getAttribute("href") || "", g = (m = p.match(h)) == null ? void 0 : m[0];
125
- g && l.setAttribute("href", B(p, t.has(g) ? g : u));
126
- }), s.filter((l) => l !== i && !this.hasVisibleContent(l)).forEach((l) => l.replaceWith(...Array.from(l.childNodes))), i.replaceWith(r.ownerDocument.createTextNode(C)), a.footerHtml = r.innerHTML.trim();
127
- }
128
- return a;
129
109
  }
130
- buildUnsubscribeBlock(e, t, r, s, i) {
131
- const n = e.linkStyle ? ` style="${A(e.linkStyle)}"` : "", a = Object.values(c).includes(e.linkHref) ? c[t] : e.linkHref, u = `<a ${`href="${A(a)}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${n}>${e.linkText}</a>`, l = e.paragraphStyle ? ` style="${A(e.paragraphStyle)}"` : "", p = e.footerHtml ? e.footerHtml.replace(C, () => u) : `<p path="1"${l}>${N}${u}${R}</p>`, g = e.align ? ` align="${e.align}"` : "", m = i ? ` bgcolor="${i}"` : "", L = r.length > 0 ? ` ${d.PAGE_LIST}="${r.join(",")}"` : "", U = ` ${d.PAGE_TYPE}="${t}"`, E = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
110
+ buildUnsubscribeBlock(e, r, t, n, s) {
111
+ const l = e.linkStyle ? ` style="${e.linkStyle}"` : "", u = `<a ${`href="${Object.values(f).includes(e.linkHref) ? f[r] : e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${l}>${e.linkText}</a>`, g = [];
112
+ e.textBefore && g.push(e.textBefore), g.push(u), e.textAfter && g.push(e.textAfter);
113
+ let i = g.join(" ");
114
+ e.isBold && e.isItalic ? i = `<strong path="1,0"><em path="1,0,0">${i}</em></strong>` : e.isBold ? i = `<strong path="1,0">${i}</strong>` : e.isItalic && (i = `<em path="1,0">${i}</em>`);
115
+ const m = e.align ? ` align="${e.align}"` : "", y = s ? ` bgcolor="${s}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", T = t.length > 0 ? ` ${k.PAGE_LIST}="${t.join(",")}"` : "", E = ` ${k.PAGE_TYPE}="${r}"`, S = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
132
116
  return `
133
117
  <td
134
118
  data-migration="true"
135
119
  esd-extension-block-id="unsubscribe-block"
136
- class="${s ? `${E} ${s}` : E}"
137
- ${g}${m}${U}${L}
120
+ class="${n ? `${S} ${n}` : S}"
121
+ ${m}${y}${E}${T}
138
122
  >
139
- ${p}
123
+ <p path="1"${d}>
124
+ ${i}
125
+ </p>
140
126
  </td>
141
127
  `;
142
128
  }
143
129
  getCollectionTypeFromMergeTag(e) {
144
- return e === c[T.SUBSCRIPTION_PREFERENCE_CENTER] ? T.SUBSCRIPTION_PREFERENCE_CENTER : e === c[T.GLOBAL_UNSUBSCRIBE] ? T.GLOBAL_UNSUBSCRIBE : T.GLOBAL_UNSUBSCRIBE;
130
+ return e === f[p.SUBSCRIPTION_PREFERENCE_CENTER] ? p.SUBSCRIPTION_PREFERENCE_CENTER : e === f[p.GLOBAL_UNSUBSCRIBE] ? p.GLOBAL_UNSUBSCRIBE : p.GLOBAL_UNSUBSCRIBE;
145
131
  }
146
132
  normalizeUnsubscribeHref(e) {
147
- if (Object.values(c).includes(e))
133
+ if (Object.values(f).includes(e))
148
134
  return e;
149
- const r = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
150
- return r ? r[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
135
+ const t = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
136
+ return t ? t[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
151
137
  `[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
152
138
  ), "{{ins-unsubscribe-link}}") : e;
153
139
  }
154
140
  }
155
- async function Y(f) {
156
- return new H().migrate(f);
141
+ async function M(c) {
142
+ return new $().migrate(c);
157
143
  }
158
144
  export {
159
- Y as migrateUnsubscribe
145
+ M as migrateUnsubscribe
160
146
  };
@@ -1,49 +1,48 @@
1
- var R = Object.defineProperty;
2
- var v = (l, c, e) => c in l ? R(l, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[c] = e;
3
- var h = (l, c, e) => v(l, typeof c != "symbol" ? c + "" : c, e);
4
- import { useToaster as D } from "../../../composables/useToaster.js";
5
- import { ToasterTypeOptions as w } from "../../../enums/toaster.js";
6
- import { PAGE_TYPES as B } from "../../../enums/unsubscribe.js";
7
- import { useEditorStore as G } from "../../../stores/editor.js";
8
- import { useUnsubscribeStore as u } from "../../../stores/unsubscribe.js";
9
- import { Block as P, BlockCompositionType as x, ContextActionType as y, ModificationDescription as k, BlockType as M } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
10
- import { getDefaultTemplate as O } from "./template.js";
11
- import { UNSUBSCRIBE_BLOCK_SELECTOR as f, DATA_ATTRIBUTES as o, UNSUBSCRIBE_EVENTS as E, UNSUBSCRIBE_MERGE_TAG_REGEX as I } from "./utils/constants.js";
12
- import { swapMergeTagInHref as q } from "./utils/swapMergeTagInHref.js";
13
- import { parsePageList as L } from "./utils/utils.js";
14
- const F = "unsubscribe-block", _ = 'a[data-unsubscribe-link="true"]', C = "{{ins-unsubscribe-link}}", K = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", H = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", Y = {
15
- [B.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
16
- [B.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
17
- }, V = 3;
18
- let d = null, b = null;
19
- const N = () => {
20
- d && (document.removeEventListener(E.SELECT, d), d = null);
21
- }, U = () => {
22
- b && (document.removeEventListener(E.CANCEL, b), b = null);
23
- }, W = () => {
24
- N(), U();
1
+ var y = Object.defineProperty;
2
+ var I = (c, o, e) => o in c ? y(c, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[o] = e;
3
+ var g = (c, o, e) => I(c, typeof o != "symbol" ? o + "" : o, e);
4
+ import { useToaster as L } from "../../../composables/useToaster.js";
5
+ import { ToasterTypeOptions as C } from "../../../enums/toaster.js";
6
+ import { PAGE_TYPES as m } from "../../../enums/unsubscribe.js";
7
+ import { useEditorStore as N } from "../../../stores/editor.js";
8
+ import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
9
+ import { Block as U, BlockCompositionType as R, ContextActionType as f, ModificationDescription as u, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
10
+ import { getDefaultTemplate as D } from "./template.js";
11
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as B, DATA_ATTRIBUTES as n, UNSUBSCRIBE_EVENTS as h } from "./utils/constants.js";
12
+ import { parsePageList as S } from "./utils/utils.js";
13
+ const w = "unsubscribe-block", E = 'a[data-unsubscribe-link="true"]', P = "{{ins-unsubscribe-link}}", x = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", G = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", M = {
14
+ [m.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
15
+ [m.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
16
+ }, O = 3;
17
+ let d = null, p = null;
18
+ const A = () => {
19
+ d && (document.removeEventListener(h.SELECT, d), d = null);
20
+ }, T = () => {
21
+ p && (document.removeEventListener(h.CANCEL, p), p = null);
22
+ }, q = () => {
23
+ A(), T();
25
24
  };
26
- class se extends P {
25
+ class J extends U {
27
26
  constructor() {
28
27
  super();
29
- h(this, "currentNode");
28
+ g(this, "currentNode");
30
29
  // Per-block "did this instance have a link last time we saw it?" tracking.
31
30
  // Keyed by the stable `data-unsubscribe-block-id` we assign, because
32
31
  // ImmutableHtmlNode instances are recreated on every document mutation and
33
32
  // can't be used as Map keys directly. A singleton boolean here would be
34
33
  // polluted across blocks since Stripo fires onDocumentChanged per-instance.
35
- h(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
34
+ g(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
36
35
  // Per-block prepend retry counter for the leading text guard (SD-143097).
37
- h(this, "guardAttemptsByBlockId", /* @__PURE__ */ new Map());
36
+ g(this, "guardAttemptsByBlockId", /* @__PURE__ */ new Map());
38
37
  }
39
38
  getId() {
40
- return F;
39
+ return w;
41
40
  }
42
41
  getIcon() {
43
42
  return "unsubscribe-icon";
44
43
  }
45
44
  getBlockCompositionType() {
46
- return x.BLOCK;
45
+ return R.BLOCK;
47
46
  }
48
47
  getName() {
49
48
  return this.api.translate("Unsubscribe Block");
@@ -52,16 +51,16 @@ class se extends P {
52
51
  return this.api.translate("Unsubscribe Block Description");
53
52
  }
54
53
  getTemplate() {
55
- return O();
54
+ return D();
56
55
  }
57
56
  getContextActionsIds() {
58
- return [y.MOVE, y.REMOVE];
57
+ return [f.MOVE, f.REMOVE];
59
58
  }
60
59
  onSelect(e) {
61
- if (this.currentNode = e, G().isPreviewModeOpen)
60
+ if (this.currentNode = e, N().isPreviewModeOpen)
62
61
  return;
63
62
  const t = this._getOrAssignBlockId(e);
64
- t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(t), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), t && (u().pendingBlockId = t), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
63
+ t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(t), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), t && (a().pendingBlockId = t), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
65
64
  }
66
65
  onCreated(e) {
67
66
  this._ensureLeadingTextGuard(e);
@@ -69,7 +68,7 @@ class se extends P {
69
68
  onDocumentInit() {
70
69
  try {
71
70
  const e = this.api.getDocumentRoot();
72
- e && "querySelectorAll" in e && e.querySelectorAll(f).forEach((t) => {
71
+ e && "querySelectorAll" in e && e.querySelectorAll(B).forEach((t) => {
73
72
  this._ensureLeadingTextGuard(t);
74
73
  });
75
74
  } catch {
@@ -80,11 +79,11 @@ class se extends P {
80
79
  const t = this._getOrAssignBlockId(e);
81
80
  if (!t)
82
81
  return;
83
- const i = this._hasUnsubscribeLink(e);
84
- this.linkStateByBlockId.get(t) === !0 && !i && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, i);
82
+ const s = this._hasUnsubscribeLink(e);
83
+ this.linkStateByBlockId.get(t) === !0 && !s && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, s);
85
84
  }
86
85
  onDelete(e) {
87
- W(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
86
+ q(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
88
87
  const t = this._readBlockId(e);
89
88
  t && (this.linkStateByBlockId.delete(t), this.guardAttemptsByBlockId.delete(t));
90
89
  }
@@ -96,38 +95,38 @@ class se extends P {
96
95
  _ensureLeadingTextGuard(e) {
97
96
  if (!("querySelector" in e))
98
97
  return;
99
- const t = e.querySelector(_);
98
+ const t = e.querySelector(E);
100
99
  if (!t)
101
100
  return;
102
- let i = t, r = i.parent();
101
+ let s = t, r = s.parent();
103
102
  for (; r && "getTagName" in r && r.getTagName().toLowerCase() !== "p"; )
104
- i = r, r = r.parent();
103
+ s = r, r = r.parent();
105
104
  if (!r || !("getTagName" in r) || r.getTagName().toLowerCase() !== "p")
106
105
  return;
107
- const s = i.previousSibling();
108
- if (!!(s && s.getType() === "text" && s.getTextContent())) {
109
- const a = this._readBlockId(e);
110
- a && this.guardAttemptsByBlockId.delete(a);
106
+ const i = s.previousSibling();
107
+ if (!!(i && i.getType() === "text" && i.getTextContent())) {
108
+ const b = this._readBlockId(e);
109
+ b && this.guardAttemptsByBlockId.delete(b);
111
110
  return;
112
111
  }
113
- const g = this._getOrAssignBlockId(e);
114
- if (!g)
112
+ const k = this._getOrAssignBlockId(e);
113
+ if (!k)
115
114
  return;
116
- const p = this.guardAttemptsByBlockId.get(g) ?? 0;
117
- if (!(p >= V)) {
118
- this.guardAttemptsByBlockId.set(g, p + 1);
115
+ const _ = this.guardAttemptsByBlockId.get(k) ?? 0;
116
+ if (!(_ >= O)) {
117
+ this.guardAttemptsByBlockId.set(k, _ + 1);
119
118
  try {
120
- this.api.getDocumentModifier().modifyHtml(r).prepend("&nbsp;").apply(new k("Ensure unsubscribe link text guard"));
121
- } catch (a) {
122
- console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", a);
119
+ this.api.getDocumentModifier().modifyHtml(r).prepend("&nbsp;").apply(new u("Ensure unsubscribe link text guard"));
120
+ } catch (b) {
121
+ console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", b);
123
122
  }
124
123
  }
125
124
  }
126
125
  _hasUnsubscribeLink(e) {
127
- return "querySelector" in e ? !!e.querySelector(_) : !1;
126
+ return "querySelector" in e ? !!e.querySelector(E) : !1;
128
127
  }
129
128
  _readBlockId(e) {
130
- return "getAttribute" in e ? e.getAttribute(o.BLOCK_ID) : null;
129
+ return "getAttribute" in e ? e.getAttribute(n.BLOCK_ID) : null;
131
130
  }
132
131
  /**
133
132
  * Returns the block's stable id, assigning one via the document modifier if
@@ -141,13 +140,13 @@ class se extends P {
141
140
  return t;
142
141
  if (!("getAttribute" in e))
143
142
  return null;
144
- const i = this._generateNextBlockId();
143
+ const s = this._generateNextBlockId();
145
144
  try {
146
- this.api.getDocumentModifier().modifyHtml(e).setAttribute(o.BLOCK_ID, i).apply(new k(`Assign unsubscribe block id ${i}`));
145
+ this.api.getDocumentModifier().modifyHtml(e).setAttribute(n.BLOCK_ID, s).apply(new u(`Assign unsubscribe block id ${s}`));
147
146
  } catch (r) {
148
147
  return console.warn("[UnsubscribeBlock] Failed to assign block id:", r), null;
149
148
  }
150
- return i;
149
+ return s;
151
150
  }
152
151
  /**
153
152
  * Generates a unique id by scanning the document for the highest existing
@@ -158,10 +157,10 @@ class se extends P {
158
157
  let e = 0;
159
158
  try {
160
159
  const t = this.api.getDocumentRoot();
161
- t && "querySelectorAll" in t && t.querySelectorAll(f).forEach((r) => {
160
+ t && "querySelectorAll" in t && t.querySelectorAll(B).forEach((r) => {
162
161
  if ("getAttribute" in r) {
163
- const s = r.getAttribute(o.BLOCK_ID), n = s ? parseInt(s) : 0;
164
- n > e && (e = n);
162
+ const i = r.getAttribute(n.BLOCK_ID), l = i ? parseInt(i) : 0;
163
+ l > e && (e = l);
165
164
  }
166
165
  });
167
166
  } catch {
@@ -170,14 +169,14 @@ class se extends P {
170
169
  }
171
170
  _warnLinkRemoved() {
172
171
  try {
173
- const { showToaster: e } = D();
172
+ const { showToaster: e } = L();
174
173
  e({
175
- type: w.Warning,
176
- message: this.api.translate(H),
174
+ type: C.Warning,
175
+ message: this.api.translate(G),
177
176
  actionButton: {
178
177
  text: this.api.translate("Visit Academy"),
179
178
  onClick: () => {
180
- window.open(K, "_blank", "noopener,noreferrer");
179
+ window.open(x, "_blank", "noopener,noreferrer");
181
180
  }
182
181
  }
183
182
  });
@@ -186,62 +185,55 @@ class se extends P {
186
185
  }
187
186
  }
188
187
  _setupSelectEventListener() {
189
- N(), d = (e) => {
190
- const t = e, { collectionType: i, selectedPages: r } = t.detail;
191
- this._updateBlock(i, r.join(","));
192
- }, document.addEventListener(E.SELECT, d);
188
+ A(), d = (e) => {
189
+ const t = e, { collectionType: s, selectedPages: r } = t.detail;
190
+ this._updateBlock(s, r.join(","));
191
+ }, document.addEventListener(h.SELECT, d);
193
192
  }
194
193
  _setupCancelEventListener(e) {
195
- U(), b = (t) => {
196
- const { detail: i } = t;
197
- ((i == null ? void 0 : i.blockId) ?? null) === e && this._handleCancel();
198
- }, document.addEventListener(E.CANCEL, b);
194
+ T(), p = (t) => {
195
+ const { detail: s } = t;
196
+ ((s == null ? void 0 : s.blockId) ?? null) === e && this._handleCancel();
197
+ }, document.addEventListener(h.CANCEL, p);
199
198
  }
200
199
  _handleCancel() {
201
200
  try {
202
201
  if (!this.currentNode)
203
202
  return;
204
- this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${M.EMPTY_CONTAINER}/>`).apply(new k("Removed unsubscribe block due to cancel"));
203
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${v.EMPTY_CONTAINER}/>`).apply(new u("Removed unsubscribe block due to cancel"));
205
204
  } catch (e) {
206
205
  console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
207
206
  }
208
207
  }
209
208
  _updateBlock(e, t) {
210
- var a;
211
209
  if (!this.currentNode || !("querySelector" in this.currentNode))
212
210
  return;
213
- const i = this.currentNode.querySelector(_);
214
- if (!i)
211
+ const s = this.currentNode.querySelector(E);
212
+ if (!s)
215
213
  return;
216
- const r = this._getMergeTag(e), s = this.api.getDocumentModifier(), n = "getAttribute" in i ? i.getAttribute("href") : null, p = [(a = n == null ? void 0 : n.match(I)) == null ? void 0 : a[0], C];
217
- s.modifyHtml(i).setAttribute("href", r), this.currentNode.querySelectorAll("a[href]").forEach((m) => {
218
- var T;
219
- if (!("getAttribute" in m) || m.getAttribute("data-unsubscribe-link") === "true")
220
- return;
221
- const S = m.getAttribute("href") ?? "", A = (T = S.match(I)) == null ? void 0 : T[0];
222
- A && p.includes(A) && s.modifyHtml(m).setAttribute("href", q(S, r));
223
- }), s.modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, t), s.apply(new k(`Updated unsubscribe link to ${r}`));
214
+ const r = this._getMergeTag(e);
215
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", r).apply(new u(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(n.PAGE_TYPE, e.toString()).setAttribute(n.PAGE_LIST, t).apply(new u("Updated unsubscribe block metadata"));
224
216
  }
225
217
  _getMergeTag(e) {
226
- return Y[e] ?? C;
218
+ return M[e] ?? P;
227
219
  }
228
220
  _openDrawer() {
229
221
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
230
222
  try {
231
- const e = u();
223
+ const e = a();
232
224
  e.typeSelectionDrawerStatus = !0;
233
225
  } catch (e) {
234
226
  console.error("[UnsubscribeBlock] Failed to open drawer:", e);
235
227
  }
236
228
  }
237
229
  _checkExistingBlocks() {
238
- const e = u();
239
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((i) => {
240
- if ("getAttribute" in i) {
241
- const r = i.getAttribute(o.PAGE_TYPE);
230
+ const e = a();
231
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(B).forEach((s) => {
232
+ if ("getAttribute" in s) {
233
+ const r = s.getAttribute(n.PAGE_TYPE);
242
234
  if (r) {
243
- const s = Number(r);
244
- s === B.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : s === B.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
235
+ const i = Number(r);
236
+ i === m.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : i === m.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
245
237
  }
246
238
  }
247
239
  });
@@ -249,27 +241,27 @@ class se extends P {
249
241
  async _loadBlockState(e) {
250
242
  if (!("getAttribute" in e))
251
243
  return;
252
- const t = e.getAttribute(o.PAGE_TYPE), i = e.getAttribute(o.PAGE_LIST);
253
- if (!t || !i)
244
+ const t = e.getAttribute(n.PAGE_TYPE), s = e.getAttribute(n.PAGE_LIST);
245
+ if (!t || !s)
254
246
  return;
255
- const r = u(), s = Number(t), n = L(i);
256
- await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(s), r.loadSelectedTemplates(n);
247
+ const r = a(), i = Number(t), l = S(s);
248
+ await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(i), r.loadSelectedTemplates(l);
257
249
  }
258
250
  _resetStoreState() {
259
- u().$reset();
251
+ a().$reset();
260
252
  }
261
253
  _removeBlockTemplatesFromStore(e) {
262
254
  if (!("getAttribute" in e))
263
255
  return;
264
- const t = e.getAttribute(o.PAGE_LIST);
256
+ const t = e.getAttribute(n.PAGE_LIST);
265
257
  if (!t)
266
258
  return;
267
- const i = u(), r = L(t);
268
- i.removeUnsubscribePages(r);
259
+ const s = a(), r = S(t);
260
+ s.removeUnsubscribePages(r);
269
261
  }
270
262
  }
271
263
  export {
272
- F as UNSUBSCRIBE_BLOCK_ID,
273
- se as UnsubscribeBlock,
274
- W as disposeUnsubscribeListeners
264
+ w as UNSUBSCRIBE_BLOCK_ID,
265
+ J as UnsubscribeBlock,
266
+ q as disposeUnsubscribeListeners
275
267
  };
@@ -5,11 +5,10 @@ const s = {
5
5
  PAGE_TYPE: "data-unsubscribe-page-type",
6
6
  PAGE_LIST: "data-unsubscribe-page-list",
7
7
  BLOCK_ID: "data-unsubscribe-block-id"
8
- }, e = ".unsubscribe-block-v2", E = /{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/, c = 'a[data-unsubscribe-link="true"], a.unsubscribe-link';
8
+ }, c = ".unsubscribe-block-v2", u = 'a[data-unsubscribe-link="true"], a.unsubscribe-link';
9
9
  export {
10
10
  b as DATA_ATTRIBUTES,
11
- e as UNSUBSCRIBE_BLOCK_SELECTOR,
11
+ c as UNSUBSCRIBE_BLOCK_SELECTOR,
12
12
  s as UNSUBSCRIBE_EVENTS,
13
- c as UNSUBSCRIBE_LINK_SELECTOR,
14
- E as UNSUBSCRIBE_MERGE_TAG_REGEX
13
+ u as UNSUBSCRIBE_LINK_SELECTOR
15
14
  };
@@ -1,4 +1,4 @@
1
- const o = "3.26.0-beta.d0b09c0", s = { stripo: { version: "2.83.1" } }, t = {
1
+ const o = "3.26.0-beta.df8736b", s = { stripo: { version: "2.85.1" } }, t = {
2
2
  version: o,
3
3
  guido: s
4
4
  };
@@ -9,5 +9,4 @@ export declare const DATA_ATTRIBUTES: {
9
9
  readonly BLOCK_ID: "data-unsubscribe-block-id";
10
10
  };
11
11
  export declare const UNSUBSCRIBE_BLOCK_SELECTOR = ".unsubscribe-block-v2";
12
- export declare const UNSUBSCRIBE_MERGE_TAG_REGEX: RegExp;
13
12
  export declare const UNSUBSCRIBE_LINK_SELECTOR = "a[data-unsubscribe-link=\"true\"], a.unsubscribe-link";
@@ -1,9 +1,9 @@
1
- const s = "2.83.1", n = ["UIEditor.js", "zone.js", "styles-BWH3PMR4.css", "polyfills-FF3RLU5F.js", "main-OTN2PYRT.js", "chunk-62K3AMOD.js", "chunk-6RGJBGUG.js", "chunk-6W43DTQG.js", "chunk-EC4WGEOZ.js", "chunk-GLBBUJ54.js", "chunk-GPJLJCMF.js", "chunk-MDCDEJUH.js", "chunk-P7HQTFJV.js", "chunk-PA4WGBC4.js", "chunk-QMDAV6OU.js", "chunk-R2F3ADM2.js", "chunk-YSKQ2TWF.js", "chunk-ZU5ASRKR.js", "assets/css/uiEditor.css", "assets/i18n/en.json", "assets/icons/ui-editor-icons.sprite.svg", "assets/icons/ui-editor-icons.map.json", "assets/imageeditor/scripts.min.js", "assets/imageeditor/assets/icons/merged.svg"], i = {
1
+ const s = "2.85.1", n = ["UIEditor.js", "zone.js", "styles-BWH3PMR4.css", "polyfills-FF3RLU5F.js", "main-OBP2Z7MC.js", "chunk-4XWYRHPW.js", "chunk-5FWAYXEU.js", "chunk-62K3AMOD.js", "chunk-6KRER6RV.js", "chunk-7NDQP2S2.js", "chunk-ECLEIO5F.js", "chunk-EGVZCU2I.js", "chunk-HAASEXSM.js", "chunk-HC6URDFK.js", "chunk-HHAM65V3.js", "chunk-IS2ESPY3.js", "chunk-OKMQ5PFC.js", "chunk-PLJHV7FP.js", "chunk-TXFBR64G.js", "chunk-Z3225DSC.js", "assets/css/uiEditor.css", "assets/i18n/en.json", "assets/icons/ui-editor-icons.sprite.svg", "assets/icons/ui-editor-icons.map.json", "assets/imageeditor/scripts.min.js", "assets/imageeditor/assets/icons/merged.svg"], c = {
2
2
  version: s,
3
3
  files: n
4
4
  };
5
5
  export {
6
- i as default,
6
+ c as default,
7
7
  n as files,
8
8
  s as version
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.26.0-beta.d0b09c0",
3
+ "version": "3.26.0-beta.df8736b",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -128,7 +128,7 @@
128
128
  },
129
129
  "guido": {
130
130
  "stripo": {
131
- "version": "2.83.1"
131
+ "version": "2.85.1"
132
132
  }
133
133
  }
134
134
  }
@@ -1,5 +0,0 @@
1
- import { UNSUBSCRIBE_MERGE_TAG_REGEX as E } from "./constants.js";
2
- const o = (r, p) => r.replace(E, () => p).replace(`${p}?`, () => `${p}&`);
3
- export {
4
- o as swapMergeTagInHref
5
- };
@@ -1 +0,0 @@
1
- export declare const swapMergeTagInHref: (href: string, mergeTag: string) => string;