@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +161 -156
  3. package/dist/accordionComponent/index.umd.js +9 -9
  4. package/dist/aiChat/chatManager.d.ts +15 -0
  5. package/dist/aiChat/clientTools.d.ts +3 -3
  6. package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
  7. package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
  8. package/dist/aiChat/components/AiChatError.d.ts +2 -1
  9. package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
  10. package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
  11. package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
  12. package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
  13. package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
  14. package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
  15. package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
  16. package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
  17. package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
  18. package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
  19. package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
  20. package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
  21. package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
  22. package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
  23. package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
  24. package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
  25. package/dist/aiChat/components/index.d.ts +24 -25
  26. package/dist/aiChat/components/utils.d.ts +12 -4
  27. package/dist/aiChat/index.cjs.d.ts +5 -0
  28. package/dist/aiChat/index.cjs.js +453 -0
  29. package/dist/aiChat/index.d.ts +4 -3
  30. package/dist/aiChat/index.es.d.ts +5 -0
  31. package/dist/aiChat/index.es.js +30930 -0
  32. package/dist/aiChat/index.js +453 -0
  33. package/dist/aiChat/index.umd.js +453 -0
  34. package/dist/aiChat/locales/en.d.ts +64 -0
  35. package/dist/aiChat/server/index.cjs.d.ts +4 -0
  36. package/dist/aiChat/server/index.cjs.js +309 -0
  37. package/dist/aiChat/server/index.d.ts +0 -50
  38. package/dist/aiChat/server/index.es.d.ts +4 -0
  39. package/dist/aiChat/server/index.es.js +876 -0
  40. package/dist/aiChat/server/index.js +309 -0
  41. package/dist/aiChat/server/index.umd.js +309 -0
  42. package/dist/aiChat/server/stream.d.ts +0 -6
  43. package/dist/aiChat/server/tools.d.ts +157 -51
  44. package/dist/aiChat/server/types.d.ts +108 -64
  45. package/dist/aiChat/types.d.ts +148 -108
  46. package/dist/aiChat/typesSchema.d.ts +238 -25
  47. package/dist/animationComponent/index.cjs.js +3 -3
  48. package/dist/animationComponent/index.es.js +174 -169
  49. package/dist/animationComponent/index.umd.js +3 -3
  50. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  51. package/dist/canvasAbsoluteMode/index.es.js +161 -156
  52. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  53. package/dist/canvasEmptyState/index.cjs.js +1 -1
  54. package/dist/canvasEmptyState/index.es.js +113 -108
  55. package/dist/canvasEmptyState/index.umd.js +1 -1
  56. package/dist/canvasFullSize/index.cjs.js +9 -9
  57. package/dist/canvasFullSize/index.es.js +137 -132
  58. package/dist/canvasFullSize/index.umd.js +9 -9
  59. package/dist/canvasGridMode/index.cjs.js +4 -4
  60. package/dist/canvasGridMode/index.es.js +168 -163
  61. package/dist/canvasGridMode/index.umd.js +8 -8
  62. package/dist/canvasScreenshot/index.cjs.js +1 -1
  63. package/dist/canvasScreenshot/index.es.js +132 -127
  64. package/dist/canvasScreenshot/index.umd.js +1 -1
  65. package/dist/dataSourceEjs/index.cjs.js +5 -5
  66. package/dist/dataSourceEjs/index.es.js +151 -146
  67. package/dist/dataSourceEjs/index.umd.js +5 -5
  68. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  69. package/dist/dataSourceHandlebars/index.es.js +91 -86
  70. package/dist/dataSourceHandlebars/index.umd.js +5 -5
  71. package/dist/dialogComponent/index.cjs.js +16 -16
  72. package/dist/dialogComponent/index.es.js +117 -112
  73. package/dist/dialogComponent/index.umd.js +16 -16
  74. package/dist/flexComponent/index.cjs.js +11 -11
  75. package/dist/flexComponent/index.es.js +416 -411
  76. package/dist/flexComponent/index.umd.js +11 -11
  77. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  78. package/dist/fsLightboxComponent/index.es.js +152 -147
  79. package/dist/fsLightboxComponent/index.umd.js +3 -3
  80. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  81. package/dist/googleFontsAssetProvider/index.es.js +127 -122
  82. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  83. package/dist/iconifyComponent/index.cjs.js +2 -2
  84. package/dist/iconifyComponent/index.es.js +170 -165
  85. package/dist/iconifyComponent/index.umd.js +2 -2
  86. package/dist/index.cjs.js +1 -1
  87. package/dist/index.es.js +27 -22
  88. package/dist/index.umd.js +1 -1
  89. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  90. package/dist/layoutSidebarButtons/index.es.js +156 -151
  91. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  92. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  93. package/dist/lightGalleryComponent/index.es.js +197 -192
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/linkImageComponent/index.cjs.js +2 -2
  96. package/dist/linkImageComponent/index.es.js +86 -81
  97. package/dist/linkImageComponent/index.umd.js +2 -2
  98. package/dist/listPagesComponent/index.cjs.js +5 -5
  99. package/dist/listPagesComponent/index.es.js +121 -116
  100. package/dist/listPagesComponent/index.umd.js +5 -5
  101. package/dist/presetPrintable/index.cjs.js +4 -4
  102. package/dist/presetPrintable/index.es.js +180 -175
  103. package/dist/presetPrintable/index.umd.js +4 -4
  104. package/dist/prosemirror/index.cjs.js +6 -6
  105. package/dist/prosemirror/index.es.js +128 -123
  106. package/dist/prosemirror/index.umd.js +8 -8
  107. package/dist/rendererReact/index.cjs.js +1 -1
  108. package/dist/rendererReact/index.es.js +127 -122
  109. package/dist/rendererReact/index.js +1 -1
  110. package/dist/rendererReact/index.umd.js +1 -1
  111. package/dist/rteTinyMce/index.cjs.js +2 -2
  112. package/dist/rteTinyMce/index.es.js +160 -155
  113. package/dist/rteTinyMce/index.umd.js +2 -2
  114. package/dist/shapeDividerComponent/index.cjs.js +25 -25
  115. package/dist/shapeDividerComponent/index.es.js +127 -122
  116. package/dist/shapeDividerComponent/index.umd.js +25 -25
  117. package/dist/swiperComponent/index.cjs.js +9 -9
  118. package/dist/swiperComponent/index.es.js +197 -192
  119. package/dist/swiperComponent/index.umd.js +9 -9
  120. package/dist/tableComponent/index.cjs.js +1 -1
  121. package/dist/tableComponent/index.es.js +227 -222
  122. package/dist/tableComponent/index.umd.js +1 -1
  123. package/dist/types.d.ts +1 -1
  124. package/dist/utils.d.ts +12 -1
  125. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  126. package/dist/youtubeAssetProvider/index.es.js +124 -119
  127. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  128. package/package.json +5 -2
  129. package/dist/aiChat/components/AiChatInput.d.ts +0 -17
  130. package/dist/aiChat/server/stream-utils.d.ts +0 -16
@@ -1,8 +1,8 @@
1
- const pe = "app.grapesjs.com", de = "app-stage.grapesjs.com", Se = "app2.grapesjs.com", ye = "app-stage2.grapesjs.com", se = [
2
- pe,
3
- Se,
4
- de,
5
- ye,
1
+ const pt = "app.grapesjs.com", dt = "app-stage.grapesjs.com", St = "app2.grapesjs.com", yt = "app-stage2.grapesjs.com", st = [
2
+ pt,
3
+ St,
4
+ dt,
5
+ yt,
6
6
  "localhost",
7
7
  "127.0.0.1",
8
8
  ".local-credentialless.webcontainer.io",
@@ -11,114 +11,119 @@ const pe = "app.grapesjs.com", de = "app-stage.grapesjs.com", Se = "app2.grapesj
11
11
  // For stackblitz.com demos
12
12
  "-sandpack.codesandbox.io"
13
13
  // For Sandpack demos
14
- ], be = "license:check:start", Ce = "license:check:end", Pe = () => typeof window < "u", ze = ({ isDev: n, isStage: e }) => `${n ? "" : `https://${e ? de : pe}`}/api`, xe = () => {
15
- const n = Pe() && window.location.hostname;
16
- return !!n && (se.includes(n) || se.some((e) => n.endsWith(e)));
14
+ ], bt = "license:check:start", Pt = "license:check:end", zt = () => typeof window < "u", Ct = ({
15
+ isDev: n,
16
+ isStage: t,
17
+ isPlatform: e
18
+ }) => `${n ? "" : `https://${t ? dt : pt}`}/${e ? "platform-api" : "api"}`, xt = () => {
19
+ const n = zt() && window.location.hostname;
20
+ return !!n && (st.includes(n) || st.some((t) => n.endsWith(t)));
17
21
  };
18
- function we(n) {
22
+ function wt(n) {
19
23
  return typeof n == "function";
20
24
  }
21
- async function Ie({
25
+ async function It({
22
26
  path: n,
23
- baseApiUrl: e,
24
- method: t = "GET",
27
+ baseApiUrl: t,
28
+ method: e = "GET",
25
29
  headers: s = {},
26
30
  params: i,
27
31
  body: a
28
32
  }) {
29
- const l = `${e || ze({ isDev: !1, isStage: !1 })}${n}`, c = {
30
- method: t,
33
+ const c = `${t || Ct({ isDev: !1, isStage: !1 })}${n}`, p = {
34
+ method: e,
31
35
  headers: {
32
36
  "Content-Type": "application/json",
33
37
  ...s
34
38
  }
35
39
  };
36
- a && (c.body = JSON.stringify(a));
37
- const g = i ? new URLSearchParams(i).toString() : "", p = g ? `?${g}` : "", u = await fetch(`${l}${p}`, c);
38
- if (!u.ok)
39
- throw new Error(`HTTP error! status: ${u.status}`);
40
- return u.json();
40
+ a && (p.body = JSON.stringify(a));
41
+ const u = i ? new URLSearchParams(i).toString() : "", f = u ? `?${u}` : "", r = await fetch(`${c}${f}`, p);
42
+ if (!r.ok)
43
+ throw new Error(`HTTP error! status: ${r.status}`);
44
+ return r.json();
41
45
  }
42
- var $ = /* @__PURE__ */ ((n) => (n.free = "free", n.startup = "startup", n.business = "business", n.enterprise = "enterprise", n))($ || {}), ue = /* @__PURE__ */ ((n) => (n.web = "web", n.email = "email", n.document = "document", n.react = "react", n))(ue || {});
43
- const ie = {
44
- [$.free]: 0,
45
- [$.startup]: 10,
46
- [$.business]: 20,
47
- [$.enterprise]: 30
46
+ var A = /* @__PURE__ */ ((n) => (n.free = "free", n.startup = "startup", n.business = "business", n.enterprise = "enterprise", n))(A || {}), ut = /* @__PURE__ */ ((n) => (n.web = "web", n.email = "email", n.document = "document", n.react = "react", n))(ut || {});
47
+ const it = {
48
+ [A.free]: 0,
49
+ [A.startup]: 10,
50
+ [A.business]: 20,
51
+ [A.enterprise]: 30
48
52
  };
49
- function ve(n) {
50
- const e = n;
51
- return e.init = (t) => (s) => n(s, t), e;
53
+ function vt(n) {
54
+ const t = n;
55
+ return t.init = (e) => (s) => n(s, e), t;
52
56
  }
53
- const Re = (n) => /* @__PURE__ */ ve(n);
54
- async function Ge({
57
+ const Gt = (n) => /* @__PURE__ */ vt(n);
58
+ async function Et({
55
59
  editor: n,
56
- plan: e,
57
- pluginName: t,
60
+ plan: t,
61
+ pluginName: e,
58
62
  licenseKey: s,
59
- cleanup: i
63
+ onLicenseCheckResponse: i,
64
+ cleanup: a
60
65
  }) {
61
- let a = "", o = !1;
62
- const l = xe(), c = (p) => {
63
- console.warn("Cleanup plugin:", t, "Reason:", p), i();
64
- }, g = (p = {}) => {
65
- var y;
66
- const { error: u, sdkLicense: f } = p, I = (y = p.plan) == null ? void 0 : y.category;
67
- if (!(f || p.license) || u)
68
- c(u || "Invalid license");
69
- else if (I) {
70
- const v = ie[e], R = ie[I];
71
- v > R && c({ pluginRequiredPlan: e, licensePlan: I });
66
+ let o = "", c = !1;
67
+ const p = xt(), u = (r) => {
68
+ console.warn("Cleanup plugin:", e, "Reason:", r), a();
69
+ }, f = (r = {}) => {
70
+ var x;
71
+ const { error: g, sdkLicense: E } = r, S = (x = r.plan) == null ? void 0 : x.category;
72
+ if (!(E || r.license) || g)
73
+ u(g || "Invalid license");
74
+ else if (S) {
75
+ const v = it[t], b = it[S];
76
+ v > b && u({ pluginRequiredPlan: t, licensePlan: S });
72
77
  }
73
78
  };
74
- n.on(be, (p) => {
75
- a = p == null ? void 0 : p.baseApiUrl, o = !0;
76
- }), n.on(Ce, (p) => {
77
- g(p);
79
+ n.on(bt, (r) => {
80
+ o = r == null ? void 0 : r.baseApiUrl, c = !0;
81
+ }), n.on(Pt, (r) => {
82
+ i == null || i(r), f(r);
78
83
  }), setTimeout(async () => {
79
- if (!o) {
80
- if (l) return;
84
+ if (!c) {
85
+ if (p) return;
81
86
  if (s) {
82
- const p = await Ee({ licenseKey: s, pluginName: t, baseApiUrl: a });
83
- p && g(p);
87
+ const r = await Rt({ licenseKey: s, pluginName: e, baseApiUrl: o });
88
+ i == null || i(r), r && f(r);
84
89
  } else
85
- c("The `licenseKey` option not provided");
90
+ u("The `licenseKey` option not provided");
86
91
  }
87
92
  }, 2e3);
88
93
  }
89
- async function Ee(n) {
90
- const { licenseKey: e, pluginName: t, baseApiUrl: s } = n;
94
+ async function Rt(n) {
95
+ const { licenseKey: t, pluginName: e, baseApiUrl: s } = n;
91
96
  try {
92
- return (await Ie({
97
+ return (await It({
93
98
  baseApiUrl: s,
94
- path: `/sdk/${e || "na"}`,
99
+ path: `/sdk/${t || "na"}`,
95
100
  method: "POST",
96
101
  params: {
97
102
  d: window.location.hostname,
98
- pn: t
103
+ pn: e
99
104
  }
100
105
  })).result || {};
101
106
  } catch (i) {
102
107
  return console.error("Error during SDK license check:", i), !1;
103
108
  }
104
109
  }
105
- const he = (n) => (e) => {
106
- var t;
107
- return ((t = e.getAttribute) == null ? void 0 : t.call(e, te)) === n;
108
- }, Te = (...n) => (e) => n.some((t) => e.is(t)), Le = (...n) => (e, t) => n.some((s) => t.is(s)), ge = "gjs-plg-", te = "data-type-role", N = class N {
109
- constructor(e) {
110
- this.config = e;
111
- }
112
- getSize(e) {
113
- var t;
114
- return (t = this.config) != null && t.getSize ? this.config.getSize(e) : ne(e.componentColumn, N.CSS_FLEX_BASIS);
115
- }
116
- setSize(e) {
117
- var t;
118
- if ((t = this.config) != null && t.setSize)
119
- this.config.setSize(e);
110
+ const ht = (n) => (t) => {
111
+ var e;
112
+ return ((e = t.getAttribute) == null ? void 0 : e.call(t, et)) === n;
113
+ }, Tt = (...n) => (t) => n.some((e) => t.is(e)), $t = (...n) => (t, e) => n.some((s) => e.is(s)), gt = "gjs-plg-", et = "data-type-role", N = class N {
114
+ constructor(t) {
115
+ this.config = t;
116
+ }
117
+ getSize(t) {
118
+ var e;
119
+ return (e = this.config) != null && e.getSize ? this.config.getSize(t) : nt(t.componentColumn, N.CSS_FLEX_BASIS);
120
+ }
121
+ setSize(t) {
122
+ var e;
123
+ if ((e = this.config) != null && e.setSize)
124
+ this.config.setSize(t);
120
125
  else {
121
- const { componentColumn: s, sizeValue: i, partial: a } = e;
126
+ const { componentColumn: s, sizeValue: i, partial: a } = t;
122
127
  s.addStyle({ [N.CSS_FLEX_BASIS]: i }, { partial: a });
123
128
  }
124
129
  }
@@ -126,243 +131,243 @@ const he = (n) => (e) => {
126
131
  N.CSS_FLEX_BASIS = "flex-basis";
127
132
  let W = N;
128
133
  const j = class j {
129
- constructor(e) {
130
- this.config = e;
134
+ constructor(t) {
135
+ this.config = t;
131
136
  }
132
137
  isGapSupported() {
133
138
  return !0;
134
139
  }
135
- getGap(e) {
136
- var t;
137
- return (t = this.config) != null && t.getGap ? this.config.getGap(e) : ne(e.componentRow, j.CSS_GAP);
140
+ getGap(t) {
141
+ var e;
142
+ return (e = this.config) != null && e.getGap ? this.config.getGap(t) : nt(t.componentRow, j.CSS_GAP);
138
143
  }
139
- setGap(e) {
140
- var t;
141
- if ((t = this.config) != null && t.setGap)
142
- this.config.setGap(e);
144
+ setGap(t) {
145
+ var e;
146
+ if ((e = this.config) != null && e.setGap)
147
+ this.config.setGap(t);
143
148
  else {
144
- const { componentRow: s, gapValue: i, partial: a } = e;
149
+ const { componentRow: s, gapValue: i, partial: a } = t;
145
150
  s.addStyle({ [j.CSS_GAP]: i }, { partial: a });
146
151
  }
147
152
  }
148
153
  };
149
154
  j.CSS_GAP = "gap";
150
155
  let K = j;
151
- const X = class X {
152
- constructor(e) {
153
- this.config = e;
156
+ const Y = class Y {
157
+ constructor(t) {
158
+ this.config = t;
154
159
  }
155
- getParentSize(e) {
160
+ getParentSize(t) {
156
161
  var a;
157
- if ((a = this.config) != null && a.getParentSize) return this.config.getParentSize(e);
158
- const { componentRow: t, isVertical: s } = e, i = t.getEl();
162
+ if ((a = this.config) != null && a.getParentSize) return this.config.getParentSize(t);
163
+ const { componentRow: e, isVertical: s } = t, i = e.getEl();
159
164
  return i ? s ? i.clientHeight : i.clientWidth : 0;
160
165
  }
161
- isLayoutVertical(e) {
166
+ isLayoutVertical(t) {
162
167
  var s;
163
- if ((s = this.config) != null && s.isParentVertical) return this.config.isParentVertical(e);
164
- const t = ne(e.componentRow, X.CSS_FLEX_DIRECTION, !0);
165
- return t === "column" || t === "column-reverse";
168
+ if ((s = this.config) != null && s.isParentVertical) return this.config.isParentVertical(t);
169
+ const e = nt(t.componentRow, Y.CSS_FLEX_DIRECTION, !0);
170
+ return e === "column" || e === "column-reverse";
166
171
  }
167
172
  };
168
- X.CSS_FLEX_DIRECTION = "flex-direction";
169
- let J = X;
173
+ Y.CSS_FLEX_DIRECTION = "flex-direction";
174
+ let J = Y;
170
175
  const _ = class _ {
171
- constructor(e) {
172
- this.config = e;
176
+ constructor(t) {
177
+ this.config = t;
173
178
  }
174
- getSize(e) {
179
+ getSize(t) {
175
180
  var s;
176
- if ((s = this.config) != null && s.getSize) return this.config.getSize(e);
177
- const t = e.componentColumn;
178
- if (t.is(_.MJML_COLUMN_TYPE)) {
179
- const a = t.getAttributes().width;
181
+ if ((s = this.config) != null && s.getSize) return this.config.getSize(t);
182
+ const e = t.componentColumn;
183
+ if (e.is(_.MJML_COLUMN_TYPE)) {
184
+ const a = e.getAttributes().width;
180
185
  if (a && (a.includes("%") || !isNaN(parseFloat(a))))
181
186
  return parseFloat(a);
182
- const o = t.parent();
187
+ const o = e.parent();
183
188
  return 100 / (o ? o.components().length : 1);
184
189
  }
185
190
  return 0;
186
191
  }
187
- setSize(e) {
188
- var t;
189
- if ((t = this.config) != null && t.setSize)
190
- this.config.setSize(e);
192
+ setSize(t) {
193
+ var e;
194
+ if ((e = this.config) != null && e.setSize)
195
+ this.config.setSize(t);
191
196
  else {
192
- const { componentColumn: s, sizeValue: i, partial: a } = e;
197
+ const { componentColumn: s, sizeValue: i, partial: a } = t;
193
198
  s.is(_.MJML_COLUMN_TYPE) && s.addAttributes({ width: `${parseFloat(i)}%` }, { partial: a });
194
199
  }
195
200
  }
196
201
  };
197
202
  _.MJML_COLUMN_TYPE = "mj-column";
198
203
  let q = _;
199
- const Y = class Y {
200
- constructor(e) {
201
- this.config = e;
204
+ const U = class U {
205
+ constructor(t) {
206
+ this.config = t;
202
207
  }
203
208
  isGapSupported() {
204
209
  return !1;
205
210
  }
206
- getGap(e) {
211
+ getGap(t) {
207
212
  var s;
208
- if ((s = this.config) != null && s.getGap) return this.config.getGap(e);
209
- const { componentRow: t } = e;
210
- if (t.is(Y.MJML_SECTION_TYPE)) {
211
- const i = t.getAttributes();
213
+ if ((s = this.config) != null && s.getGap) return this.config.getGap(t);
214
+ const { componentRow: e } = t;
215
+ if (e.is(U.MJML_SECTION_TYPE)) {
216
+ const i = e.getAttributes();
212
217
  if (i && i.padding)
213
218
  return parseInt(i.padding, 10) || 0;
214
219
  }
215
220
  return 0;
216
221
  }
217
- setGap(e) {
218
- var t, s;
219
- (s = (t = this.config) == null ? void 0 : t.setGap) == null || s.call(t, e);
222
+ setGap(t) {
223
+ var e, s;
224
+ (s = (e = this.config) == null ? void 0 : e.setGap) == null || s.call(e, t);
220
225
  }
221
226
  };
222
- Y.MJML_SECTION_TYPE = "mj-section";
223
- let Z = Y;
224
- class $e {
225
- constructor(e) {
226
- this.config = e;
227
+ U.MJML_SECTION_TYPE = "mj-section";
228
+ let Z = U;
229
+ class At {
230
+ constructor(t) {
231
+ this.config = t;
227
232
  }
228
- getParentSize(e) {
233
+ getParentSize(t) {
229
234
  var o;
230
- if ((o = this.config) != null && o.getParentSize) return this.config.getParentSize(e);
231
- const { componentRow: t, isVertical: s } = e, i = t.getEl();
235
+ if ((o = this.config) != null && o.getParentSize) return this.config.getParentSize(t);
236
+ const { componentRow: e, isVertical: s } = t, i = e.getEl();
232
237
  if (!i) return 0;
233
238
  let a = i;
234
239
  if (i.tagName !== "TABLE") {
235
- const l = i.querySelectorAll("table");
236
- l.length && (a = l[0]);
240
+ const c = i.querySelectorAll("table");
241
+ c.length && (a = c[0]);
237
242
  }
238
243
  return s ? a.clientHeight : a.clientWidth;
239
244
  }
240
- isLayoutVertical(e) {
241
- var t;
242
- return (t = this.config) != null && t.isParentVertical ? this.config.isParentVertical(e) : !1;
245
+ isLayoutVertical(t) {
246
+ var e;
247
+ return (e = this.config) != null && e.isParentVertical ? this.config.isParentVertical(t) : !1;
243
248
  }
244
249
  }
245
- class A {
250
+ class H {
246
251
  constructor() {
247
252
  this.handlerCache = /* @__PURE__ */ new Map();
248
253
  }
249
254
  static getInstance() {
250
- return A.instance || (A.instance = new A()), A.instance;
251
- }
252
- getHandlers(e) {
253
- const t = `${e.projectType}-${e.disableGapHandler ? "nogap" : "gap"}`;
254
- return this.handlerCache.has(t) || (H(e) ? this.handlerCache.set(t, {
255
- sizeHandler: new q(e),
256
- gapHandler: new Z(e),
257
- parentSizeHandler: new $e(e)
258
- }) : this.handlerCache.set(t, {
259
- sizeHandler: new W(e),
260
- gapHandler: new K(e),
261
- parentSizeHandler: new J(e)
262
- })), this.handlerCache.get(t);
255
+ return H.instance || (H.instance = new H()), H.instance;
256
+ }
257
+ getHandlers(t) {
258
+ const e = `${t.projectType}-${t.disableGapHandler ? "nogap" : "gap"}`;
259
+ return this.handlerCache.has(e) || (M(t) ? this.handlerCache.set(e, {
260
+ sizeHandler: new q(t),
261
+ gapHandler: new Z(t),
262
+ parentSizeHandler: new At(t)
263
+ }) : this.handlerCache.set(e, {
264
+ sizeHandler: new W(t),
265
+ gapHandler: new K(t),
266
+ parentSizeHandler: new J(t)
267
+ })), this.handlerCache.get(e);
263
268
  }
264
269
  }
265
- function E(n) {
266
- return A.getInstance().getHandlers(n);
270
+ function R(n) {
271
+ return H.getInstance().getHandlers(n);
267
272
  }
268
- const ae = (n) => {
273
+ const at = (n) => {
269
274
  n.style.display = "none";
270
- }, oe = (n) => {
275
+ }, ot = (n) => {
271
276
  n.style.display = "block";
272
- }, M = (n) => +parseFloat(`${n}`).toFixed(2), H = (n) => n.projectType === ue.email, Ae = (n) => n ? ["top", "bottom"] : ["left", "right"], He = (n) => {
273
- const e = n.parent();
274
- return e ? e.components().models.indexOf(n) === 0 : !1;
275
- }, Me = (n) => {
276
- const e = n.parent();
277
- if (!e) return !1;
278
- const t = e.components().models;
279
- return t.indexOf(n) === t.length - 1;
280
- }, Ve = (n) => {
281
- const e = n.parent();
282
- if (!e) return !1;
283
- const t = e.components().models;
284
- return t.length > 1 && n.index() === t.length - 1;
285
- }, Ne = (n, e, t, s) => {
286
- const a = n + (t ? e === "top" ? -1 : e === "bottom" ? 1 : 0 : e === "left" ? -1 : e === "right" ? 1 : 0);
277
+ }, L = (n) => +parseFloat(`${n}`).toFixed(2), M = (n) => n.projectType === ut.email, Ht = (n) => n ? ["top", "bottom"] : ["left", "right"], Mt = (n) => {
278
+ const t = n.parent();
279
+ return t ? t.components().models.indexOf(n) === 0 : !1;
280
+ }, Lt = (n) => {
281
+ const t = n.parent();
282
+ if (!t) return !1;
283
+ const e = t.components().models;
284
+ return e.indexOf(n) === e.length - 1;
285
+ }, Vt = (n) => {
286
+ const t = n.parent();
287
+ if (!t) return !1;
288
+ const e = t.components().models;
289
+ return e.length > 1 && n.index() === e.length - 1;
290
+ }, Nt = (n, t, e, s) => {
291
+ const a = n + (e ? t === "top" ? -1 : t === "bottom" ? 1 : 0 : t === "left" ? -1 : t === "right" ? 1 : 0);
287
292
  return a >= 0 && a < s ? a : -1;
288
- }, k = (n) => n === "top" || n === "bottom", je = (n, e) => !!(He(n) && (e === "left" || e === "top") || Me(n) && (e === "right" || e === "bottom")), _e = (n) => {
289
- const e = n.parent();
290
- return e ? e.components().models.length > 1 : !1;
291
- }, re = (n, e) => n === "right" || n === "bottom" ? e > 0 : e < 0, ne = (n, e, t = !1) => {
292
- const s = !t, i = n.getEl();
293
+ }, O = (n) => n === "top" || n === "bottom", jt = (n, t) => !!(Mt(n) && (t === "left" || t === "top") || Lt(n) && (t === "right" || t === "bottom")), _t = (n) => {
294
+ const t = n.parent();
295
+ return t ? t.components().models.length > 1 : !1;
296
+ }, rt = (n, t) => n === "right" || n === "bottom" ? t > 0 : t < 0, nt = (n, t, e = !1) => {
297
+ const s = !e, i = n.getEl();
293
298
  if (!i)
294
299
  return s ? 0 : "";
295
- const o = window.getComputedStyle(i)[e] || "";
300
+ const o = window.getComputedStyle(i)[t] || "";
296
301
  if (s) {
297
- let l;
298
- return typeof o == "string" ? (l = parseFloat(o.replace(/[^-\d.]/g, "")), isNaN(l) && (l = 0)) : l = Number(o) || 0, l;
302
+ let c;
303
+ return typeof o == "string" ? (c = parseFloat(o.replace(/[^-\d.]/g, "")), isNaN(c) && (c = 0)) : c = Number(o) || 0, c;
299
304
  }
300
305
  return o;
301
- }, ce = (n, e, t) => {
302
- const s = Q({ componentRow: n, isVertical: e }, t), i = n.components().models;
306
+ }, lt = (n, t, e) => {
307
+ const s = Q({ componentRow: n, isVertical: t }, e), i = n.components().models;
303
308
  return s * (i.length - 1);
304
- }, D = (n, e) => E(e).parentSizeHandler.isLayoutVertical({ componentRow: n }), B = (n, e) => E(e).sizeHandler.getSize(n), Q = (n, e) => {
305
- if (e != null && e.disableGapHandler) return 0;
306
- const { gapHandler: t, parentSizeHandler: s } = E(e);
307
- if (!t.isGapSupported()) return 0;
308
- const i = t.getGap(n), a = s.getParentSize(n);
309
+ }, D = (n, t) => R(t).parentSizeHandler.isLayoutVertical({ componentRow: n }), B = (n, t) => R(t).sizeHandler.getSize(n), Q = (n, t) => {
310
+ if (t != null && t.disableGapHandler) return 0;
311
+ const { gapHandler: e, parentSizeHandler: s } = R(t);
312
+ if (!e.isGapSupported()) return 0;
313
+ const i = e.getGap(n), a = s.getParentSize(n);
309
314
  return i / 100 * a;
310
- }, ee = (n, e) => E(e).parentSizeHandler.getParentSize(n), V = (n, e) => {
311
- E(e).sizeHandler.setSize(n);
312
- }, fe = (n, e) => {
313
- const t = B(n, e);
314
- V({ ...n, sizeValue: `${t}%`, partial: !1 }, e);
315
- }, me = (n, e) => {
316
- if (e != null && e.disableGapHandler) return;
317
- const { gapHandler: t } = E(e);
318
- t.isGapSupported() && t.setGap(n);
319
- }, De = (n, e) => {
320
- const t = n.getStyle().gap;
321
- if (!t) return;
322
- const s = n.components().models, i = { componentRow: n, isVertical: D(n, e) };
323
- s.map((a) => fe({ ...i, componentColumn: a }, e)), me({ ...i, gapValue: String(t), partial: !1 }, e);
315
+ }, tt = (n, t) => R(t).parentSizeHandler.getParentSize(n), V = (n, t) => {
316
+ R(t).sizeHandler.setSize(n);
317
+ }, ft = (n, t) => {
318
+ const e = B(n, t);
319
+ V({ ...n, sizeValue: `${e}%`, partial: !1 }, t);
320
+ }, mt = (n, t) => {
321
+ if (t != null && t.disableGapHandler) return;
322
+ const { gapHandler: e } = R(t);
323
+ e.isGapSupported() && e.setGap(n);
324
+ }, Dt = (n, t) => {
325
+ const e = n.getStyle().gap;
326
+ if (!e) return;
327
+ const s = n.components().models, i = { componentRow: n, isVertical: D(n, t) };
328
+ s.map((a) => ft({ ...i, componentColumn: a }, t)), mt({ ...i, gapValue: String(e), partial: !1 }, t);
324
329
  };
325
- function Be(n, e) {
326
- const { Blocks: t } = n, { typeColumn: s, typeRow: i, blocks: a } = e;
327
- if (a === !1 || H(e)) return;
328
- const o = (u) => ({
330
+ function Bt(n, t) {
331
+ const { Blocks: e } = n, { typeColumn: s, typeRow: i, blocks: a } = t;
332
+ if (a === !1 || M(t)) return;
333
+ const o = (r) => ({
329
334
  type: i,
330
- components: u.map((f) => ({
335
+ components: r.map((g) => ({
331
336
  type: s,
332
- style: { "flex-basis": `${f}%` }
337
+ style: { "flex-basis": `${g}%` }
333
338
  }))
334
- }), l = (u) => `<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
335
- ${u.map((f) => `<div style="flex-basis: ${f}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
336
- </div>`, c = (u, f) => ({
337
- id: `flex-row-${f.join("-")}`,
338
- label: u,
339
+ }), c = (r) => `<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
340
+ ${r.map((g) => `<div style="flex-basis: ${g}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
341
+ </div>`, p = (r, g) => ({
342
+ id: `flex-row-${g.join("-")}`,
343
+ label: r,
339
344
  category: "Layout",
340
345
  select: !0,
341
346
  full: !0,
342
347
  attributes: { class: "gs-block-item__flex gs-utl-w-full" },
343
- media: l(f),
344
- content: o(f)
345
- }), g = [
346
- c("1 Column", [100]),
347
- c("2 Columns 50/50", [50, 50]),
348
- c("2 Columns 25/75", [25, 75]),
349
- c("2 Columns 75/25", [75, 25]),
350
- c("3 Columns", [33.33, 33.33, 33.33]),
351
- c("3 Columns 50/25/25", [50, 25, 25]),
352
- c("3 Columns 25/50/25", [25, 50, 25]),
353
- c("3 Columns 25/25/50", [25, 25, 50]),
354
- c("4 Columns", [25, 25, 25, 25]),
355
- c("5 Columns", [20, 20, 20, 20, 20])
356
- ], p = we(a) ? a({ blocks: g }) : g;
357
- return p.forEach((u) => t.add(u.id, u)), () => {
358
- p.forEach((u) => t.remove(u.id));
348
+ media: c(g),
349
+ content: o(g)
350
+ }), u = [
351
+ p("1 Column", [100]),
352
+ p("2 Columns 50/50", [50, 50]),
353
+ p("2 Columns 25/75", [25, 75]),
354
+ p("2 Columns 75/25", [75, 25]),
355
+ p("3 Columns", [33.33, 33.33, 33.33]),
356
+ p("3 Columns 50/25/25", [50, 25, 25]),
357
+ p("3 Columns 25/50/25", [25, 50, 25]),
358
+ p("3 Columns 25/25/50", [25, 25, 50]),
359
+ p("4 Columns", [25, 25, 25, 25]),
360
+ p("5 Columns", [20, 20, 20, 20, 20])
361
+ ], f = wt(a) ? a({ blocks: u }) : u;
362
+ return f.forEach((r) => e.add(r.id, r)), () => {
363
+ f.forEach((r) => e.remove(r.id));
359
364
  };
360
365
  }
361
- const Fe = (n, e) => {
362
- const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = e, o = `${ge}${i}`, c = !!i && !!t.getType(i) && !a;
363
- if (!(!i || c || H(e)))
364
- return t.addType(i, {
365
- isComponent: he(i),
366
+ const Ft = (n, t) => {
367
+ const { Components: e } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = t, o = `${gt}${i}`, p = !!i && !!e.getType(i) && !a;
368
+ if (!(!i || p || M(t)))
369
+ return e.addType(i, {
370
+ isComponent: ht(i),
366
371
  model: {
367
372
  defaults: {
368
373
  name: "Column",
@@ -370,8 +375,8 @@ const Fe = (n, e) => {
370
375
  emptyState: !0,
371
376
  classes: o,
372
377
  icon: '<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',
373
- draggable: Le(s),
374
- attributes: { [te]: i },
378
+ draggable: $t(s),
379
+ attributes: { [et]: i },
375
380
  styles: `
376
381
  .${o} {
377
382
  flex-grow: 1;
@@ -380,21 +385,21 @@ const Fe = (n, e) => {
380
385
  }
381
386
  }
382
387
  }), () => {
383
- t.removeType(i);
388
+ e.removeType(i);
384
389
  };
385
- }, ke = (n, e) => {
386
- const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = e, o = `${ge}${s}`, c = !!s && !!t.getType(s) && !a;
387
- if (!(!s || c || H(e)))
388
- return t.addType(s, {
389
- isComponent: he(s),
390
+ }, Ot = (n, t) => {
391
+ const { Components: e } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = t, o = `${gt}${s}`, p = !!s && !!e.getType(s) && !a;
392
+ if (!(!s || p || M(t)))
393
+ return e.addType(s, {
394
+ isComponent: ht(s),
390
395
  model: {
391
396
  defaults: {
392
397
  name: "Row",
393
398
  classes: o,
394
399
  icon: '<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',
395
400
  emptyState: { styleIn: "width: 100%" },
396
- attributes: { [te]: s },
397
- droppable: Te(i),
401
+ attributes: { [et]: s },
402
+ droppable: Tt(i),
398
403
  traits: [
399
404
  // {
400
405
  // type: 'number',
@@ -418,7 +423,7 @@ const Fe = (n, e) => {
418
423
  type: "checkbox",
419
424
  name: "snap",
420
425
  label: "Enable Snap",
421
- default: e.snapEnabled,
426
+ default: t.snapEnabled,
422
427
  changeProp: !0
423
428
  },
424
429
  {
@@ -428,7 +433,7 @@ const Fe = (n, e) => {
428
433
  min: 1,
429
434
  max: 12,
430
435
  step: 1,
431
- default: e.snapDivisions,
436
+ default: t.snapDivisions,
432
437
  changeProp: !0
433
438
  }
434
439
  ],
@@ -450,163 +455,163 @@ const Fe = (n, e) => {
450
455
  }
451
456
  }
452
457
  }), () => {
453
- t.removeType(s);
458
+ e.removeType(s);
454
459
  };
455
- }, Oe = "flexComponent", Xe = $.startup;
456
- class Ye {
460
+ }, Xt = "flexComponent", Yt = A.startup;
461
+ class Ut {
457
462
  constructor() {
458
463
  this.resizableChildTypes = /* @__PURE__ */ new Set(), this.gapAdjustableParentTypes = /* @__PURE__ */ new Set(), this.typeRelationships = /* @__PURE__ */ new Map();
459
464
  }
460
- registerResizableChild(e) {
461
- this.resizableChildTypes.add(e);
465
+ registerResizableChild(t) {
466
+ this.resizableChildTypes.add(t);
462
467
  }
463
- registerGapAdjustableParent(e) {
464
- this.gapAdjustableParentTypes.add(e);
468
+ registerGapAdjustableParent(t) {
469
+ this.gapAdjustableParentTypes.add(t);
465
470
  }
466
- registerTypeRelationship(e, t) {
467
- this.typeRelationships.has(e) || this.typeRelationships.set(e, /* @__PURE__ */ new Set()), this.typeRelationships.get(e).add(t), this.registerResizableChild(t), this.registerGapAdjustableParent(e);
471
+ registerTypeRelationship(t, e) {
472
+ this.typeRelationships.has(t) || this.typeRelationships.set(t, /* @__PURE__ */ new Set()), this.typeRelationships.get(t).add(e), this.registerResizableChild(e), this.registerGapAdjustableParent(t);
468
473
  }
469
- isResizableChild(e) {
470
- return this.resizableChildTypes.has(e.get("type"));
474
+ isResizableChild(t) {
475
+ return this.resizableChildTypes.has(t.get("type"));
471
476
  }
472
- isGapAdjustableParent(e) {
473
- return this.gapAdjustableParentTypes.has(e.get("type"));
477
+ isGapAdjustableParent(t) {
478
+ return this.gapAdjustableParentTypes.has(t.get("type"));
474
479
  }
475
- isValidRelationship(e, t) {
476
- const s = e.get("type"), i = t.get("type");
480
+ isValidRelationship(t, e) {
481
+ const s = t.get("type"), i = e.get("type");
477
482
  return this.typeRelationships.has(s) ? this.typeRelationships.get(s).has(i) : !1;
478
483
  }
479
484
  }
480
- class Ue {
481
- constructor(e, t, s) {
482
- this.editor = e, this.registry = t, this.opts = s, this.resizeState = /* @__PURE__ */ new WeakMap();
485
+ class kt {
486
+ constructor(t, e, s) {
487
+ this.editor = t, this.registry = e, this.opts = s, this.resizeState = /* @__PURE__ */ new WeakMap();
483
488
  }
484
- getState(e) {
485
- return this.resizeState.has(e) || this.resizeState.set(e, {}), this.resizeState.get(e);
489
+ getState(t) {
490
+ return this.resizeState.has(t) || this.resizeState.set(t, {}), this.resizeState.get(t);
486
491
  }
487
- clearState(e) {
488
- return this.resizeState.delete(e);
492
+ clearState(t) {
493
+ return this.resizeState.delete(t);
489
494
  }
490
- startResize(e, t, s) {
491
- const { opts: i } = this, a = this.getState(e);
492
- a.direction = t, a.startX = s.clientX, a.startY = s.clientY, a.resizing = !0, a.lastSnappedPercent = void 0;
493
- const o = e.parent();
494
- if (!o || !this.registry.isValidRelationship(o, e)) return;
495
+ startResize(t, e, s) {
496
+ const { opts: i } = this, a = this.getState(t);
497
+ a.direction = e, a.startX = s.clientX, a.startY = s.clientY, a.resizing = !0, a.lastSnappedPercent = void 0;
498
+ const o = t.parent();
499
+ if (!o || !this.registry.isValidRelationship(o, t)) return;
495
500
  a.snapEnabled = o.get("snap") ?? i.snapEnabled, a.snapDivisions = o.get("snap-divisions") ?? i.snapDivisions ?? 12;
496
- const l = o.components().models, c = l.findIndex((f) => f.cid === e.cid), g = D(o, i), p = Ne(c, t, g, l.length);
497
- p !== -1 && (a.adjacentIdx = p);
498
- const u = { componentColumn: e, componentRow: o, isVertical: g };
499
- if (a.startPercent = B(u, i), typeof a.adjacentIdx < "u") {
500
- const f = l[a.adjacentIdx];
501
- a.neighborStartPercent = B({ ...u, componentColumn: f }, i);
501
+ const c = o.components().models, p = c.findIndex((g) => g.cid === t.cid), u = D(o, i), f = Nt(p, e, u, c.length);
502
+ f !== -1 && (a.adjacentIdx = f);
503
+ const r = { componentColumn: t, componentRow: o, isVertical: u };
504
+ if (a.startPercent = B(r, i), typeof a.adjacentIdx < "u") {
505
+ const g = c[a.adjacentIdx];
506
+ a.neighborStartPercent = B({ ...r, componentColumn: g }, i);
502
507
  }
503
508
  }
504
- updateResizeByDelta(e, t, s) {
505
- const i = this.getState(e), a = e.parent();
506
- !i.resizing || !a || (i.snapEnabled ? this.updateSnapResize(e, t, s) : this.updateContinuesResize(e, t, s));
509
+ updateResizeByDelta(t, e, s) {
510
+ const i = this.getState(t), a = t.parent();
511
+ !i.resizing || !a || (i.snapEnabled ? this.updateSnapResize(t, e, s) : this.updateContinuesResize(t, e, s));
507
512
  }
508
- finishResize(e) {
509
- const t = e.parent(), s = t == null ? void 0 : t.components().models, i = { componentRow: t, isVertical: !!t && D(t, this.opts) };
510
- s == null || s.forEach((a) => fe({ ...i, componentColumn: a }, this.opts)), this.clearState(e);
513
+ finishResize(t) {
514
+ const e = t.parent(), s = e == null ? void 0 : e.components().models, i = { componentRow: e, isVertical: !!e && D(e, this.opts) };
515
+ s == null || s.forEach((a) => ft({ ...i, componentColumn: a }, this.opts)), this.clearState(t);
511
516
  }
512
- updateContinuesResize(e, t, s) {
513
- const i = this.getState(e), a = e.parent(), { opts: o } = this;
517
+ updateContinuesResize(t, e, s) {
518
+ const i = this.getState(t), a = t.parent(), { opts: o } = this;
514
519
  if (!a) return;
515
- const l = o.minItemPercent ?? 0, c = k(t), g = ee({ componentRow: a, isVertical: c }, o), p = ce(a, c, this.opts), f = 100 - p / g * 100, I = s / (g - p) * f, { startPercent: P = 0, neighborStartPercent: y = 0 } = i, v = { componentRow: a, isVertical: c, componentColumn: e, partial: !0 }, R = re(t, s) ? P + Math.abs(I) : P - Math.abs(I);
520
+ const c = o.minItemPercent ?? 0, p = O(e), u = tt({ componentRow: a, isVertical: p }, o), f = lt(a, p, this.opts), g = 100 - f / u * 100, E = s / (u - f) * g, { startPercent: S = 0, neighborStartPercent: C = 0 } = i, x = { componentRow: a, isVertical: p, componentColumn: t, partial: !0 }, v = rt(e, s) ? S + Math.abs(E) : S - Math.abs(E);
516
521
  if (typeof i.adjacentIdx < "u") {
517
- const z = a.components().models[i.adjacentIdx], x = P + y, b = x - l, r = Math.min(b, Math.max(l, R)), d = x - r;
518
- V({ ...v, sizeValue: `${M(r)}%` }, o), V(
519
- { ...v, componentColumn: z, sizeValue: `${M(d)}%` },
522
+ const b = a.components().models[i.adjacentIdx], w = S + C, P = w - c, l = Math.min(P, Math.max(c, v)), d = w - l;
523
+ V({ ...x, sizeValue: `${L(l)}%` }, o), V(
524
+ { ...x, componentColumn: b, sizeValue: `${L(d)}%` },
520
525
  o
521
526
  );
522
527
  } else {
523
- const z = Math.max(l, Math.min(f, R));
524
- V({ ...v, sizeValue: `${M(z)}%` }, o);
528
+ const b = Math.max(c, Math.min(g, v));
529
+ V({ ...x, sizeValue: `${L(b)}%` }, o);
525
530
  }
526
531
  }
527
- updateSnapResize(e, t, s) {
528
- const i = this.getState(e), a = e.parent(), o = k(t), l = ee({ componentRow: a, isVertical: o }, this.opts), c = ce(a, o, this.opts), g = l - c, p = s / g * 100, u = re(t, s), { startPercent: f = 0, snapDivisions: I = 12 } = i, P = u ? f + Math.abs(p) : f - Math.abs(p), y = 100 / I, v = Math.floor(P / y) * y, R = Math.ceil(P / y) * y, z = Math.abs(R - P), x = Math.abs(P - v), b = y * 0.2, C = z < x ? R : v;
529
- if (C > 0 && C < 100 && (z < b || x < b) && i.lastSnappedPercent !== C) {
530
- i.lastSnappedPercent = C;
531
- let m = Math.abs(C - f) / 100 * g;
532
- (u && (t === "left" || t === "top") || !u && (t === "right" || t === "bottom")) && (m = -m), this.updateContinuesResize(e, t, m);
533
- } else z >= b && x >= b && (i.lastSnappedPercent = void 0);
532
+ updateSnapResize(t, e, s) {
533
+ const i = this.getState(t), a = t.parent(), o = O(e), c = tt({ componentRow: a, isVertical: o }, this.opts), p = lt(a, o, this.opts), u = c - p, f = s / u * 100, r = rt(e, s), { startPercent: g = 0, snapDivisions: E = 12 } = i, S = r ? g + Math.abs(f) : g - Math.abs(f), C = 100 / E, x = Math.floor(S / C) * C, v = Math.ceil(S / C) * C, b = Math.abs(v - S), w = Math.abs(S - x), P = C * 0.2, z = b < w ? v : x;
534
+ if (z > 0 && z < 100 && (b < P || w < P) && i.lastSnappedPercent !== z) {
535
+ i.lastSnappedPercent = z;
536
+ let m = Math.abs(z - g) / 100 * u;
537
+ (r && (e === "left" || e === "top") || !r && (e === "right" || e === "bottom")) && (m = -m), this.updateContinuesResize(t, e, m);
538
+ } else b >= P && w >= P && (i.lastSnappedPercent = void 0);
534
539
  }
535
540
  }
536
- class We {
537
- constructor(e, t, s) {
538
- this.editor = e, this.registry = t, this.opts = s;
539
- }
540
- updateGapByDelta(e, t, s, i) {
541
- if (!this.registry.isGapAdjustableParent(e)) return;
542
- const { opts: a } = this, o = Math.max(0, s + t), l = ee({ componentRow: e, isVertical: i }, a), c = o / l * 100, g = e.components().models, p = g.length - 1, u = { componentRow: e, isVertical: i }, f = g.reduce(
543
- (b, C) => b + B({ ...u, componentColumn: C }, a),
541
+ class Wt {
542
+ constructor(t, e, s) {
543
+ this.editor = t, this.registry = e, this.opts = s;
544
+ }
545
+ updateGapByDelta(t, e, s, i) {
546
+ if (!this.registry.isGapAdjustableParent(t)) return;
547
+ const { opts: a } = this, o = Math.max(0, s + e), c = tt({ componentRow: t, isVertical: i }, a), p = o / c * 100, u = t.components().models, f = u.length - 1, r = { componentRow: t, isVertical: i }, g = u.reduce(
548
+ (P, z) => P + B({ ...r, componentColumn: z }, a),
544
549
  0
545
- ), P = 100 - c * p, y = a.minItemPercent || 5;
546
- if (P < y * g.length)
550
+ ), S = 100 - p * f, C = a.minItemPercent || 5;
551
+ if (S < C * u.length)
547
552
  return;
548
- const R = 100 - p * c, z = f - R, x = { componentRow: e, isVertical: i, partial: !0 };
549
- g.map((b) => {
550
- const C = B({ ...u, componentColumn: b }, a), r = C - C / f * z;
551
- V({ ...x, componentColumn: b, sizeValue: `${M(r)}%` }, a);
552
- }), me({ ...x, gapValue: `${M(c)}%` }, a);
553
+ const v = 100 - f * p, b = g - v, w = { componentRow: t, isVertical: i, partial: !0 };
554
+ u.map((P) => {
555
+ const z = B({ ...r, componentColumn: P }, a), l = z - z / g * b;
556
+ V({ ...w, componentColumn: P, sizeValue: `${L(l)}%` }, a);
557
+ }), mt({ ...w, gapValue: `${L(p)}%` }, a);
553
558
  }
554
- finishGapAdjust(e) {
555
- De(e, this.opts);
559
+ finishGapAdjust(t) {
560
+ Dt(t, this.opts);
556
561
  }
557
562
  }
558
- class Ke {
559
- constructor(e, t, s) {
560
- this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new Ue(e, t, s), this.gapHandler = new We(e, t, s);
563
+ class Kt {
564
+ constructor(t, e, s) {
565
+ this.editor = t, this.registry = e, this.opts = s, this.resizeHandler = new kt(t, e, s), this.gapHandler = new Wt(t, e, s);
561
566
  }
562
- startResize(e, t, s) {
563
- this.resizeHandler.startResize(e, t, s);
567
+ startResize(t, e, s) {
568
+ this.resizeHandler.startResize(t, e, s);
564
569
  }
565
- updateResizeByDelta(e, t, s) {
566
- this.resizeHandler.updateResizeByDelta(e, t, s);
570
+ updateResizeByDelta(t, e, s) {
571
+ this.resizeHandler.updateResizeByDelta(t, e, s);
567
572
  }
568
- finishResize(e) {
569
- this.resizeHandler.finishResize(e);
573
+ finishResize(t) {
574
+ this.resizeHandler.finishResize(t);
570
575
  }
571
- updateGapByDelta(e, t, s, i) {
572
- this.gapHandler.updateGapByDelta(e, t, s, i);
576
+ updateGapByDelta(t, e, s, i) {
577
+ this.gapHandler.updateGapByDelta(t, e, s, i);
573
578
  }
574
- finishGapAdjust(e) {
575
- this.gapHandler.finishGapAdjust(e);
579
+ finishGapAdjust(t) {
580
+ this.gapHandler.finishGapAdjust(t);
576
581
  }
577
- canResize(e) {
578
- const t = e.parent();
579
- return t ? this.registry.isValidRelationship(t, e) : !1;
582
+ canResize(t) {
583
+ const e = t.parent();
584
+ return e ? this.registry.isValidRelationship(e, t) : !1;
580
585
  }
581
- canAdjustGap(e) {
582
- return this.registry.isGapAdjustableParent(e);
586
+ canAdjustGap(t) {
587
+ return this.registry.isGapAdjustableParent(t);
583
588
  }
584
589
  }
585
- const O = "gs-flex-spots", le = `${O}__handle-size`, Je = `${O}__handle-gap`;
586
- function qe(n, e) {
587
- const { Canvas: t } = n, s = "flex-resize-spot";
588
- let i, a, o, l, c = null, g = null;
589
- const p = new Ye(), u = new Ke(n, p, e), f = () => {
590
- var r;
591
- i = document.createElement("div"), i.className = O, i.style.display = "none", a = document.createElement("div"), a.className = `${O}__handles`, a.style.position = "absolute", a.style.pointerEvents = "none", a.style.zIndex = "21", o = {
590
+ const X = "gs-flex-spots", ct = `${X}__handle-size`, Jt = `${X}__handle-gap`;
591
+ function qt(n, t) {
592
+ const { Canvas: e } = n, s = "flex-resize-spot";
593
+ let i, a, o, c, p = null, u = null;
594
+ const f = new Ut(), r = new Kt(n, f, t), g = () => {
595
+ var l;
596
+ i = document.createElement("div"), i.className = X, i.style.display = "none", a = document.createElement("div"), a.className = `${X}__handles`, a.style.position = "absolute", a.style.pointerEvents = "none", a.style.zIndex = "21", o = {
592
597
  left: document.createElement("div"),
593
598
  right: document.createElement("div"),
594
599
  top: document.createElement("div"),
595
600
  bottom: document.createElement("div")
596
601
  }, Object.entries(o).forEach(([d, m]) => {
597
- const S = d, h = k(S);
598
- m.className = `${le} ${le}-${S} gjs-resizer-h gjs-cv-unscale`, m.style.cssText = `
602
+ const y = d, h = O(y);
603
+ m.className = `${ct} ${ct}-${y} gjs-resizer-h gjs-cv-unscale`, m.style.cssText = `
599
604
  pointer-events: all;
600
605
  position: absolute;
601
606
  z-index: 1;
602
607
  cursor: ${h ? "ns-resize" : "ew-resize"};
603
608
  ${h ? "left: 50%;" : "top: 50%;"}
604
- ${S === "left" ? "left: 0px;" : ""}
605
- ${S === "right" ? "right: 0px;" : ""}
606
- ${S === "top" ? "top: 0px;" : ""}
607
- ${S === "bottom" ? "bottom: 0px;" : ""}
608
- `, m.addEventListener("pointerdown", I(S)), a.appendChild(m);
609
- }), !e.disableGapHandler && !H(e) && (l = document.createElement("div"), l.className = Je, l.style.cssText = `
609
+ ${y === "left" ? "left: 0px;" : ""}
610
+ ${y === "right" ? "right: 0px;" : ""}
611
+ ${y === "top" ? "top: 0px;" : ""}
612
+ ${y === "bottom" ? "bottom: 0px;" : ""}
613
+ `, m.addEventListener("pointerdown", E(y)), a.appendChild(m);
614
+ }), !t.disableGapHandler && !M(t) && (c = document.createElement("div"), c.className = Jt, c.style.cssText = `
610
615
  position: absolute;
611
616
  background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
612
617
  border-width: 2px;
@@ -616,98 +621,98 @@ function qe(n, e) {
616
621
  pointer-events: all;
617
622
  max-width: 3rem;
618
623
  max-height: 3rem;
619
- `, l.addEventListener("pointerdown", P()), a.appendChild(l)), i.append(a), (r = t.getSpotsEl()) == null || r.appendChild(i);
620
- }, I = (r) => (d) => {
621
- if (!c) return;
622
- d.stopPropagation(), d.preventDefault(), u.startResize(c, r, d);
623
- const m = d.clientX, S = d.clientY;
624
+ `, c.addEventListener("pointerdown", S()), a.appendChild(c)), i.append(a), (l = e.getSpotsEl()) == null || l.appendChild(i);
625
+ }, E = (l) => (d) => {
626
+ if (!p) return;
627
+ d.stopPropagation(), d.preventDefault(), r.startResize(p, l, d);
628
+ const m = d.clientX, y = d.clientY;
624
629
  d.target.setPointerCapture(d.pointerId);
625
630
  const h = (T) => {
626
- const G = n.Canvas.getZoomMultiplier(), L = (T.clientX - m) * G, F = (T.clientY - S) * G, U = k(r) ? F : L;
627
- u.updateResizeByDelta(c, r, U);
628
- }, w = () => {
629
- u.finishResize(c), d.target.releasePointerCapture(d.pointerId), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", w);
631
+ const G = n.Canvas.getZoomMultiplier(), $ = (T.clientX - m) * G, F = (T.clientY - y) * G, k = O(l) ? F : $;
632
+ r.updateResizeByDelta(p, l, k);
633
+ }, I = () => {
634
+ r.finishResize(p), d.target.releasePointerCapture(d.pointerId), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", I);
630
635
  };
631
- document.addEventListener("pointermove", h), document.addEventListener("pointerup", w);
632
- }, P = () => (r) => {
633
- if (!g) return;
634
- const d = g;
635
- r.stopPropagation(), r.preventDefault();
636
- const m = D(d, e), S = Q({ componentRow: d, isVertical: m }, e), h = r.clientX, w = r.clientY;
637
- r.target.setPointerCapture(r.pointerId);
638
- const T = (L) => {
639
- const F = n.Canvas.getZoomMultiplier(), U = m ? (L.clientY - w) * F : (L.clientX - h) * F;
640
- u.updateGapByDelta(d, U, S, m);
636
+ document.addEventListener("pointermove", h), document.addEventListener("pointerup", I);
637
+ }, S = () => (l) => {
638
+ if (!u) return;
639
+ const d = u;
640
+ l.stopPropagation(), l.preventDefault();
641
+ const m = D(d, t), y = Q({ componentRow: d, isVertical: m }, t), h = l.clientX, I = l.clientY;
642
+ l.target.setPointerCapture(l.pointerId);
643
+ const T = ($) => {
644
+ const F = n.Canvas.getZoomMultiplier(), k = m ? ($.clientY - I) * F : ($.clientX - h) * F;
645
+ r.updateGapByDelta(d, k, y, m);
641
646
  }, G = () => {
642
- u.finishGapAdjust(d), r.target.releasePointerCapture(r.pointerId), document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", G);
647
+ r.finishGapAdjust(d), l.target.releasePointerCapture(l.pointerId), document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", G);
643
648
  };
644
649
  document.addEventListener("pointermove", T), document.addEventListener("pointerup", G);
645
- }, y = (r) => {
646
- const d = r.component;
647
- if (!d || !i || (c = d, g = d.parent(), !g)) return;
648
- const m = g;
649
- oe(i);
650
- const S = r.getStyle();
651
- a && Object.assign(a.style, S);
652
- const h = D(m, e), w = Ae(h);
653
- if (Object.values(o).forEach(ae), w.forEach((G) => {
654
- if (je(d, G)) return;
655
- const L = o[G];
656
- oe(L);
657
- }), E(e).gapHandler.isGapSupported() && l && _e(d)) {
658
- const G = Q({ componentRow: m, isVertical: h }, e);
659
- v(G, h, Ve(d));
650
+ }, C = (l) => {
651
+ const d = l.component;
652
+ if (!d || !i || (p = d, u = d.parent(), !u)) return;
653
+ const m = u;
654
+ ot(i);
655
+ const y = l.getStyle();
656
+ a && Object.assign(a.style, y);
657
+ const h = D(m, t), I = Ht(h);
658
+ if (Object.values(o).forEach(at), I.forEach((G) => {
659
+ if (jt(d, G)) return;
660
+ const $ = o[G];
661
+ ot($);
662
+ }), R(t).gapHandler.isGapSupported() && c && _t(d)) {
663
+ const G = Q({ componentRow: m, isVertical: h }, t);
664
+ x(G, h, Vt(d));
660
665
  }
661
- }, v = (r, d, m = !1) => {
662
- const S = e.gapHandleSize, h = l.style;
666
+ }, x = (l, d, m = !1) => {
667
+ const y = t.gapHandleSize, h = c.style;
663
668
  if (d) {
664
- h.height = `${S}px`;
665
- const w = l.offsetHeight;
666
- m ? (h.top = `-${(r + w) / 2}px`, h.bottom = "") : (h.bottom = `-${(r + w) / 2}px`, h.top = ""), h.width = "50%", h.left = "50%", h.transform = "translateX(-50%)", h.cursor = "row-resize";
669
+ h.height = `${y}px`;
670
+ const I = c.offsetHeight;
671
+ m ? (h.top = `-${(l + I) / 2}px`, h.bottom = "") : (h.bottom = `-${(l + I) / 2}px`, h.top = ""), h.width = "50%", h.left = "50%", h.transform = "translateX(-50%)", h.cursor = "row-resize";
667
672
  } else {
668
- h.width = `${S}px`;
669
- const w = l.offsetWidth;
670
- m ? (h.left = `-${(r + w) / 2}px`, h.right = "") : (h.right = `-${(r + w) / 2}px`, h.left = ""), h.height = "50%", h.top = "50%", h.transform = "translateY(-50%)", h.cursor = "col-resize";
673
+ h.width = `${y}px`;
674
+ const I = c.offsetWidth;
675
+ m ? (h.left = `-${(l + I) / 2}px`, h.right = "") : (h.right = `-${(l + I) / 2}px`, h.left = ""), h.height = "50%", h.top = "50%", h.transform = "translateY(-50%)", h.cursor = "col-resize";
671
676
  }
672
- }, R = () => {
673
- i && (ae(i), c = null, g = null);
674
- }, z = () => {
675
- t.removeSpots({ type: s });
676
- const r = n.getSelected(), d = r == null ? void 0 : r.parent();
677
- r && d && p.isValidRelationship(d, r) ? t.addSpot({ type: s, component: r }) : R();
678
- }, x = () => {
679
- const r = t.getSpots().filter((d) => d.type === s)[0];
680
- r && y(r);
681
- }, b = (r, d) => {
682
- p.registerTypeRelationship(r, d);
677
+ }, v = () => {
678
+ i && (at(i), p = null, u = null);
679
+ }, b = () => {
680
+ e.removeSpots({ type: s });
681
+ const l = n.getSelected(), d = l == null ? void 0 : l.parent();
682
+ l && d && f.isValidRelationship(d, l) ? e.addSpot({ type: s, component: l }) : v();
683
+ }, w = () => {
684
+ const l = e.getSpots().filter((d) => d.type === s)[0];
685
+ l && C(l);
686
+ }, P = (l, d) => {
687
+ f.registerTypeRelationship(l, d);
683
688
  };
684
689
  n.onReady(() => {
685
- f(), H(e) ? b("mj-section", "mj-column") : b(e.typeRow, e.typeColumn);
690
+ g(), M(t) ? P("mj-section", "mj-column") : P(t.typeRow, t.typeColumn);
686
691
  });
687
- const C = "component:toggled";
688
- return n.on(t.events.spot, x), n.on(C, z), () => {
689
- n.off(t.events.spot, x), n.off(C, z);
692
+ const z = "component:toggled";
693
+ return n.on(e.events.spot, w), n.on(z, b), () => {
694
+ n.off(e.events.spot, w), n.off(z, b);
690
695
  };
691
696
  }
692
- const Ze = function(n, e = {}) {
693
- const t = {
697
+ const Zt = function(n, t = {}) {
698
+ const e = {
694
699
  typeRow: "flex-row",
695
700
  typeColumn: "flex-column",
696
701
  gapHandleSize: 3,
697
702
  snapDivisions: 12,
698
703
  minItemPercent: 5,
699
- ...e
700
- }, s = [ke(n, t), Fe(n, t)], i = qe(n, t), a = Be(n, t);
701
- Ge({
704
+ ...t
705
+ }, s = [Ot(n, e), Ft(n, e)], i = qt(n, e), a = Bt(n, e);
706
+ Et({
702
707
  editor: n,
703
- licenseKey: t.licenseKey,
704
- plan: Xe,
705
- pluginName: Oe,
708
+ licenseKey: e.licenseKey,
709
+ plan: Yt,
710
+ pluginName: Xt,
706
711
  cleanup: () => {
707
712
  s.forEach((o) => o == null ? void 0 : o()), i(), a == null || a();
708
713
  }
709
714
  });
710
- }, Qe = Re(Ze);
715
+ }, Qt = Gt(Zt);
711
716
  export {
712
- Qe as default
717
+ Qt as default
713
718
  };