@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 R = "app.grapesjs.com", _ = "app-stage.grapesjs.com", B = "app2.grapesjs.com", C = "app-stage2.grapesjs.com", O = [
2
- R,
1
+ const D = "app.grapesjs.com", $ = "app-stage.grapesjs.com", B = "app2.grapesjs.com", H = "app-stage2.grapesjs.com", O = [
2
+ D,
3
3
  B,
4
- _,
5
- C,
4
+ $,
5
+ H,
6
6
  "localhost",
7
7
  "127.0.0.1",
8
8
  ".local-credentialless.webcontainer.io",
@@ -11,19 +11,23 @@ const R = "app.grapesjs.com", _ = "app-stage.grapesjs.com", B = "app2.grapesjs.c
11
11
  // For stackblitz.com demos
12
12
  "-sandpack.codesandbox.io"
13
13
  // For Sandpack demos
14
- ], H = "license:check:start", F = "license:check:end", W = () => typeof window < "u", K = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? _ : R}`}/api`, V = () => {
15
- const e = W() && window.location.hostname;
16
- return !!e && (O.includes(e) || O.some((t) => e.endsWith(t)));
14
+ ], F = "license:check:start", W = "license:check:end", K = () => typeof window < "u", C = ({
15
+ isDev: t,
16
+ isStage: e,
17
+ isPlatform: o
18
+ }) => `${t ? "" : `https://${e ? $ : D}`}/${o ? "platform-api" : "api"}`, V = () => {
19
+ const t = K() && window.location.hostname;
20
+ return !!t && (O.includes(t) || O.some((e) => t.endsWith(e)));
17
21
  };
18
22
  async function Y({
19
- path: e,
20
- baseApiUrl: t,
23
+ path: t,
24
+ baseApiUrl: e,
21
25
  method: o = "GET",
22
26
  headers: s = {},
23
- params: u,
27
+ params: a,
24
28
  body: p
25
29
  }) {
26
- const r = `${t || K({ isDev: !1, isStage: !1 })}${e}`, n = {
30
+ const c = `${e || C({ isDev: !1, isStage: !1 })}${t}`, n = {
27
31
  method: o,
28
32
  headers: {
29
33
  "Content-Type": "application/json",
@@ -31,184 +35,185 @@ async function Y({
31
35
  }
32
36
  };
33
37
  p && (n.body = JSON.stringify(p));
34
- const c = u ? new URLSearchParams(u).toString() : "", i = c ? `?${c}` : "", g = await fetch(`${r}${i}`, n);
35
- if (!g.ok)
36
- throw new Error(`HTTP error! status: ${g.status}`);
37
- return g.json();
38
+ const r = a ? new URLSearchParams(a).toString() : "", g = r ? `?${r}` : "", i = await fetch(`${c}${g}`, n);
39
+ if (!i.ok)
40
+ throw new Error(`HTTP error! status: ${i.status}`);
41
+ return i.json();
38
42
  }
39
- var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}), D = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(D || {}), L = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(L || {});
40
- const k = {
43
+ var v = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(v || {}), k = /* @__PURE__ */ ((t) => (t.Info = "info", t.Error = "error", t.Success = "success", t.Warning = "warning", t))(k || {}), w = /* @__PURE__ */ ((t) => (t.toastAdd = "studio:toastAdd", t.toastRemove = "studio:toastRemove", t.dialogOpen = "studio:dialogOpen", t.dialogClose = "studio:dialogClose", t.dialogExportCode = "studio:dialogExportCode", t.sidebarLeftSet = "studio:sidebarLeft:set", t.sidebarLeftGet = "studio:sidebarLeft:get", t.sidebarLeftToggle = "studio:sidebarLeft:toggle", t.sidebarRightSet = "studio:sidebarRight:set", t.sidebarRightGet = "studio:sidebarRight:get", t.sidebarRightToggle = "studio:sidebarRight:toggle", t.sidebarTopSet = "studio:sidebarTop:set", t.sidebarTopGet = "studio:sidebarTop:get", t.sidebarTopToggle = "studio:sidebarTop:toggle", t.sidebarBottomSet = "studio:sidebarBottom:set", t.sidebarBottomGet = "studio:sidebarBottom:get", t.sidebarBottomToggle = "studio:sidebarBottom:toggle", t.symbolAdd = "studio:symbolAdd", t.symbolDetach = "studio:symbolDetach", t.symbolOverride = "studio:symbolOverride", t.symbolPropagateStyles = "studio:propagateStyles", t.getPagesConfig = "studio:getPagesConfig", t.setPagesConfig = "studio:setPagesConfig", t.getPageSettings = "studio:getPageSettings", t.setPageSettings = "studio:setPageSettings", t.clearPage = "studio:clearPage", t.projectFiles = "studio:projectFiles", t.validateCode = "studio:validateCode", t.canvasReload = "studio:canvasReload", t.getBlocksPanel = "studio:getBlocksPanel", t.setBlocksPanel = "studio:setBlocksPanel", t.getStateContextMenu = "studio:getStateContextMenu", t.setStateContextMenu = "studio:setStateContextMenu", t.contextMenuComponent = "studio:contextMenuComponent", t.layoutAdd = "studio:layoutAdd", t.layoutRemove = "studio:layoutRemove", t.layoutToggle = "studio:layoutToggle", t.layoutUpdate = "studio:layoutUpdate", t.layoutGet = "studio:layoutGet", t.layoutConfigGet = "studio:layoutConfigGet", t.layoutConfigSet = "studio:layoutConfigSet", t.layoutComponentAdd = "studio:layoutComponentAdd", t.layoutComponentGet = "studio:layoutComponentGet", t.layoutComponentRemove = "studio:layoutComponentRemove", t.layoutComponentRender = "studio:layoutComponentRender", t.getStateTheme = "studio:getStateTheme", t.setStateTheme = "studio:setStateTheme", t.assetProviderGet = "studio:assetProviderGet", t.assetProviderAdd = "studio:assetProviderAdd", t.assetProviderRemove = "studio:assetProviderRemove", t.fontGet = "studio:fontGet", t.fontAdd = "studio:fontAdd", t.fontRemove = "studio:fontRemove", t.fontManagerOpen = "studio:fontManagerOpen", t.menuFontLoad = "studio:menuFontLoad", t.toggleStateDataSource = "studio:toggleStateDataSource", t.getStateDataSource = "studio:getStateDataSource", t.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", t.dataSourceSetImporter = "studio:dataSourceSetImporter", t.dataSourceSetExporter = "studio:dataSourceSetExporter", t.setDragAbsolute = "studio:setDragAbsolute", t))(w || {});
44
+ const x = {
41
45
  [v.free]: 0,
42
46
  [v.startup]: 10,
43
47
  [v.business]: 20,
44
48
  [v.enterprise]: 30
45
49
  };
46
- function z(e) {
47
- const t = e;
48
- return t.init = (o) => (s) => e(s, o), t;
50
+ function z(t) {
51
+ const e = t;
52
+ return e.init = (o) => (s) => t(s, o), e;
49
53
  }
50
- const q = (e) => /* @__PURE__ */ z(e);
54
+ const q = (t) => /* @__PURE__ */ z(t);
51
55
  async function J({
52
- editor: e,
53
- plan: t,
56
+ editor: t,
57
+ plan: e,
54
58
  pluginName: o,
55
59
  licenseKey: s,
56
- cleanup: u
60
+ onLicenseCheckResponse: a,
61
+ cleanup: p
57
62
  }) {
58
- let p = "", a = !1;
59
- const r = V(), n = (i) => {
60
- console.warn("Cleanup plugin:", o, "Reason:", i), u();
61
- }, c = (i = {}) => {
63
+ let l = "", c = !1;
64
+ const n = V(), r = (i) => {
65
+ console.warn("Cleanup plugin:", o, "Reason:", i), p();
66
+ }, g = (i = {}) => {
62
67
  var h;
63
- const { error: g, sdkLicense: f } = i, l = (h = i.plan) == null ? void 0 : h.category;
64
- if (!(f || i.license) || g)
65
- n(g || "Invalid license");
66
- else if (l) {
67
- const b = k[t], d = k[l];
68
- b > d && n({ pluginRequiredPlan: t, licensePlan: l });
68
+ const { error: y, sdkLicense: u } = i, d = (h = i.plan) == null ? void 0 : h.category;
69
+ if (!(u || i.license) || y)
70
+ r(y || "Invalid license");
71
+ else if (d) {
72
+ const f = x[e], b = x[d];
73
+ f > b && r({ pluginRequiredPlan: e, licensePlan: d });
69
74
  }
70
75
  };
71
- e.on(H, (i) => {
72
- p = i == null ? void 0 : i.baseApiUrl, a = !0;
73
- }), e.on(F, (i) => {
74
- c(i);
76
+ t.on(F, (i) => {
77
+ l = i == null ? void 0 : i.baseApiUrl, c = !0;
78
+ }), t.on(W, (i) => {
79
+ a == null || a(i), g(i);
75
80
  }), setTimeout(async () => {
76
- if (!a) {
77
- if (r) return;
81
+ if (!c) {
82
+ if (n) return;
78
83
  if (s) {
79
- const i = await X({ licenseKey: s, pluginName: o, baseApiUrl: p });
80
- i && c(i);
84
+ const i = await X({ licenseKey: s, pluginName: o, baseApiUrl: l });
85
+ a == null || a(i), i && g(i);
81
86
  } else
82
- n("The `licenseKey` option not provided");
87
+ r("The `licenseKey` option not provided");
83
88
  }
84
89
  }, 2e3);
85
90
  }
86
- async function X(e) {
87
- const { licenseKey: t, pluginName: o, baseApiUrl: s } = e;
91
+ async function X(t) {
92
+ const { licenseKey: e, pluginName: o, baseApiUrl: s } = t;
88
93
  try {
89
94
  return (await Y({
90
95
  baseApiUrl: s,
91
- path: `/sdk/${t || "na"}`,
96
+ path: `/sdk/${e || "na"}`,
92
97
  method: "POST",
93
98
  params: {
94
99
  d: window.location.hostname,
95
100
  pn: o
96
101
  }
97
102
  })).result || {};
98
- } catch (u) {
99
- return console.error("Error during SDK license check:", u), !1;
103
+ } catch (a) {
104
+ return console.error("Error during SDK license check:", a), !1;
100
105
  }
101
106
  }
102
- const Z = (e, t) => {
107
+ const Z = (t, e) => {
103
108
  var o;
104
- return !!((o = e == null ? void 0 : e.hasAttribute) != null && o.call(e, t));
105
- }, Q = "iconifyComponent", S = v.startup, m = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, I = `<svg viewBox="0 0 24 24">
109
+ return !!((o = t == null ? void 0 : t.hasAttribute) != null && o.call(t, e));
110
+ }, m = "iconifyComponent", Q = v.startup, S = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, E = `<svg viewBox="0 0 24 24">
106
111
  <path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
107
- </svg>`, $ = "layout-icon-picker", ee = "icons-layout-", G = "icons-list-layout", M = "gs-iconify-picker", P = "__iconify_collection", te = "https://api.iconify.design", E = /* @__PURE__ */ new Map();
108
- let T;
109
- const oe = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
110
- async function N({ collectionId: e, editor: t }) {
112
+ </svg>`, G = "layout-icon-picker", tt = "icons-layout-", M = "icons-list-layout", N = "gs-iconify-picker", P = "__iconify_collection", et = "https://api.iconify.design", A = /* @__PURE__ */ new Map();
113
+ let I;
114
+ const ot = ({ collectionId: t }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${t}@latest/icons.json`;
115
+ async function R({ collectionId: t, editor: e }) {
111
116
  try {
112
- if (E.has(e)) return E.get(e);
113
- const o = await fetch(oe({ collectionId: e }));
117
+ if (A.has(t)) return A.get(t);
118
+ const o = await fetch(ot({ collectionId: t }));
114
119
  if (!o.ok) throw new Error(`Failed to fetch collection: ${o.statusText}`);
115
120
  const s = await o.json();
116
- return E.set(e, s), s;
121
+ return A.set(t, s), s;
117
122
  } catch (o) {
118
- console.error("Error fetching collection", o), t.runCommand(L.toastAdd, ae());
123
+ console.error("Error fetching collection", o), e.runCommand(w.toastAdd, at());
119
124
  return;
120
125
  }
121
126
  }
122
- async function ne({ collectionIds: e, editor: t }) {
127
+ async function nt({ collectionIds: t, editor: e }) {
123
128
  try {
124
- if (T) return T;
125
- const o = e ? `?prefixes=${e.join(",")}` : "", s = await fetch(`${te}/collections${o}`);
129
+ if (I) return I;
130
+ const o = t ? `?prefixes=${t.join(",")}` : "", s = await fetch(`${et}/collections${o}`);
126
131
  if (!s.ok) throw new Error(`Failed to fetch collections: ${s.statusText}`);
127
- return T = await s.json(), T;
132
+ return I = await s.json(), I;
128
133
  } catch (o) {
129
- console.error("Error fetching collections", o), t.runCommand(L.toastAdd, j());
134
+ console.error("Error fetching collections", o), e.runCommand(w.toastAdd, j());
130
135
  return;
131
136
  }
132
137
  }
133
- function x() {
138
+ function _() {
134
139
  return {
135
140
  type: "button",
136
141
  label: "Open Icon Picker",
137
142
  name: "onActive",
138
143
  changeProp: !0,
139
- command(e) {
140
- var t;
141
- (t = e.getSelected()) == null || t.trigger("active");
144
+ command(t) {
145
+ var e;
146
+ (e = t.getSelected()) == null || e.trigger("active");
142
147
  }
143
148
  };
144
149
  }
145
- async function se({ collectionIds: e, editor: t, component: o }) {
146
- const s = await ne({ collectionIds: e, editor: t });
150
+ async function st({ collectionIds: t, editor: e, component: o }) {
151
+ const s = await nt({ collectionIds: t, editor: e });
147
152
  if (!s) return;
148
- const u = ({ icon: n, collectionId: c, iconId: i }) => {
149
- o.components(n), o.set({ collectionId: c, iconId: i });
150
- }, p = Object.entries(s).map(([n, c]) => ({ id: n, ...c })).sort((n, c) => n.name.localeCompare(c.name)), a = o.get("collectionId") ?? p[0].id;
151
- t.runCommand(L.layoutToggle, {
152
- id: $,
153
+ const a = ({ icon: n, collectionId: r, iconId: g }) => {
154
+ o.components(n), o.set({ collectionId: r, iconId: g });
155
+ }, p = Object.entries(s).map(([n, r]) => ({ id: n, ...r })).sort((n, r) => n.name.localeCompare(r.name)), l = o.get("collectionId") ?? p[0].id;
156
+ e.runCommand(w.layoutToggle, {
157
+ id: G,
153
158
  placer: { type: "dialog", size: "l", title: "Select Icon" },
154
159
  header: !1,
155
160
  layout: {
156
161
  type: "column",
157
162
  style: { height: 500, gap: 10 },
158
163
  children: [
159
- ce({
164
+ rt({
160
165
  collectionsList: p,
161
- collectionId: a,
162
- editor: t,
163
- handleClick: u
166
+ collectionId: l,
167
+ editor: e,
168
+ handleClick: a
164
169
  }),
165
- { id: G, type: "column", grow: !0 }
170
+ { id: M, type: "column", grow: !0 }
166
171
  ]
167
172
  }
168
173
  });
169
- const r = await N({ collectionId: a, editor: t });
170
- r && (U({ editor: t, collection: r }), A({
171
- editor: t,
172
- collection: r,
173
- handleClick: u,
174
- collectionId: a
174
+ const c = await R({ collectionId: l, editor: e });
175
+ c && (U({ editor: e, collection: c }), L({
176
+ editor: e,
177
+ collection: c,
178
+ handleClick: a,
179
+ collectionId: l
175
180
  }));
176
181
  }
177
- function U({ editor: e, collection: t }) {
178
- e.em.set(P, t);
182
+ function U({ editor: t, collection: e }) {
183
+ t.em.set(P, e);
179
184
  }
180
- function ie(e) {
181
- return e.em.get(P);
185
+ function it(t) {
186
+ return t.em.get(P);
182
187
  }
183
- function A(e) {
184
- const { editor: t } = e;
185
- t.runCommand(L.layoutUpdate, {
186
- id: ee,
187
- layout: re(e),
188
+ function L(t) {
189
+ const { editor: e } = t;
190
+ e.runCommand(w.layoutUpdate, {
191
+ id: tt,
192
+ layout: ct(t),
188
193
  header: !1,
189
194
  style: { height: "100%" },
190
- placer: { type: "static", layoutId: G }
195
+ placer: { type: "static", layoutId: M }
191
196
  });
192
197
  }
193
- function ce(e) {
194
- const { collectionsList: t, collectionId: o, editor: s, handleClick: u } = e, p = t.map(({ id: a, name: r, total: n }) => ({ id: a, label: `${r} (${n})` })).sort((a, r) => a.label.localeCompare(r.label));
198
+ function rt(t) {
199
+ const { collectionsList: e, collectionId: o, editor: s, handleClick: a } = t, p = e.map(({ id: l, name: c, total: n }) => ({ id: l, label: `${c} (${n})` })).sort((l, c) => l.label.localeCompare(c.label));
195
200
  return {
196
201
  type: "column",
197
202
  style: { gap: 10 },
198
- className: `${M}__header`,
203
+ className: `${N}__header`,
199
204
  children: [
200
205
  {
201
206
  type: "selectField",
202
207
  value: o,
203
208
  options: p,
204
209
  emptyState: "Select an icon collection",
205
- onChange: async ({ setState: a, value: r }) => {
206
- const n = await N({ collectionId: r, editor: s });
207
- n && (a({ value: r }), U({ editor: s, collection: n }), A({
210
+ onChange: async ({ setState: l, value: c }) => {
211
+ const n = await R({ collectionId: c, editor: s });
212
+ n && (l({ value: c }), U({ editor: s, collection: n }), L({
208
213
  editor: s,
209
214
  collection: n,
210
- handleClick: u,
211
- collectionId: r
215
+ handleClick: a,
216
+ collectionId: c
212
217
  }));
213
218
  }
214
219
  },
@@ -217,71 +222,71 @@ function ce(e) {
217
222
  value: "",
218
223
  placeholder: "Search icons inside collection...",
219
224
  editorEvents: {
220
- [`change:${P}`]: ({ setState: a }) => a({ value: "" })
225
+ [`change:${P}`]: ({ setState: l }) => l({ value: "" })
221
226
  },
222
- onInput: ({ setState: a, value: r, editor: n }) => {
223
- const c = ie(n);
224
- if (!c) return;
225
- const i = Object.fromEntries(
226
- Object.entries(c.icons).filter(([g]) => g.includes(r))
227
+ onInput: ({ setState: l, value: c, editor: n }) => {
228
+ const r = it(n);
229
+ if (!r) return;
230
+ const g = Object.fromEntries(
231
+ Object.entries(r.icons).filter(([i]) => i.includes(c))
227
232
  );
228
- a({ value: r }), A({
233
+ l({ value: c }), L({
229
234
  editor: n,
230
- collection: c,
231
- handleClick: u,
235
+ collection: r,
236
+ handleClick: a,
232
237
  collectionId: o,
233
- collectionFiltered: { ...c, icons: i }
238
+ collectionFiltered: { ...r, icons: g }
234
239
  });
235
240
  }
236
241
  }
237
242
  ]
238
243
  };
239
244
  }
240
- function re({
241
- collection: e,
242
- collectionFiltered: t,
245
+ function ct({
246
+ collection: t,
247
+ collectionFiltered: e,
243
248
  handleClick: o
244
249
  }) {
245
- const { height: s = 24, width: u = 24, icons: p, prefix: a } = t || e, r = Object.entries(p).map(([n, c]) => ({ name: n, ...c }), {});
250
+ const { height: s = 24, width: a = 24, icons: p, prefix: l } = e || t, c = Object.entries(p).map(([n, r]) => ({ name: n, ...r }), {});
246
251
  return {
247
252
  type: "column",
248
- className: `${M}__content`,
253
+ className: `${N}__content`,
249
254
  style: { height: "100%" },
250
255
  children: {
251
256
  type: "virtualList",
252
- items: r,
257
+ items: c,
253
258
  itemLayout: ({ item: n }) => ({
254
259
  type: "custom",
255
- render: (c) => {
256
- const { editor: i, addEl: g, removeEl: f } = c, l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
257
- l.setAttribute("xmlns", "http://www.w3.org/2000/svg"), l.innerHTML = n.body;
258
- const y = n.width || u, h = n.height || s;
259
- l.setAttribute("viewBox", `0 0 ${y} ${h}`), l.style.cssText = "width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";
260
- const b = [
260
+ render: (r) => {
261
+ const { editor: g, addEl: i, removeEl: y } = r, u = document.createElementNS("http://www.w3.org/2000/svg", "svg");
262
+ u.setAttribute("xmlns", "http://www.w3.org/2000/svg"), u.innerHTML = n.body;
263
+ const d = n.width || a, T = n.height || s;
264
+ u.setAttribute("viewBox", `0 0 ${d} ${T}`), u.style.cssText = "width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";
265
+ const h = [
261
266
  [
262
267
  "click",
263
268
  () => {
264
- const d = l.cloneNode(!0);
265
- d.removeAttribute("style");
266
- const w = d.outerHTML;
267
- o({ icon: w, collectionId: a, iconId: n.name }), i == null || i.runCommand(L.layoutRemove, { id: $ });
269
+ const f = u.cloneNode(!0);
270
+ f.removeAttribute("style");
271
+ const b = f.outerHTML;
272
+ o({ icon: b, collectionId: l, iconId: n.name }), g == null || g.runCommand(w.layoutRemove, { id: G });
268
273
  }
269
274
  ],
270
275
  [
271
276
  "pointerover",
272
277
  () => {
273
- l.style.border = "2px solid currentColor", l.style.padding = "4px";
278
+ u.style.border = "2px solid currentColor", u.style.padding = "4px";
274
279
  }
275
280
  ],
276
281
  [
277
282
  "pointerout",
278
283
  () => {
279
- l.style.border = "", l.style.padding = "";
284
+ u.style.border = "", u.style.padding = "";
280
285
  }
281
286
  ]
282
287
  ];
283
- return b.forEach(([d, w]) => l.addEventListener(d, w)), g(l), () => {
284
- b.forEach(([d, w]) => l.removeEventListener(d, w)), f(l);
288
+ return h.forEach(([f, b]) => u.addEventListener(f, b)), i(u), () => {
289
+ h.forEach(([f, b]) => u.removeEventListener(f, b)), y(u);
285
290
  };
286
291
  }
287
292
  })
@@ -293,76 +298,76 @@ function j() {
293
298
  id: "toast-error-getCollections",
294
299
  header: "Error",
295
300
  content: "Error fetching collections",
296
- variant: D.Error
301
+ variant: k.Error
297
302
  };
298
303
  }
299
- function ae() {
304
+ function at() {
300
305
  return {
301
306
  ...j(),
302
307
  id: "toast-error-getCollection",
303
308
  content: "Error fetching collection"
304
309
  };
305
310
  }
306
- const le = function(e, t = {}) {
307
- var l;
308
- const { Components: o, Blocks: s } = e, { collections: u, extendIconComponent: p = !0, licenseKey: a, block: r = {} } = t, n = "icon", c = "iconify", i = "Iconify", g = "data-type-iconify", f = {
311
+ const lt = function(t, e = {}) {
312
+ var u;
313
+ const { Components: o, Blocks: s } = t, { collections: a, extendIconComponent: p = !0, licenseKey: l, block: c = {} } = e, n = "icon", r = "iconify", g = "Iconify", i = "data-type-iconify", y = {
309
314
  events: () => ({
310
315
  dblclick: "onActive"
311
316
  }),
312
317
  onActive() {
313
- se({ collectionIds: u, editor: e, component: this.model });
318
+ st({ collectionIds: a, editor: t, component: this.model });
314
319
  }
315
320
  };
316
- if (o.addType(c, {
317
- block: r && {
318
- label: i,
319
- media: I,
320
- content: { type: c },
321
+ if (o.addType(r, {
322
+ block: c && {
323
+ label: g,
324
+ media: E,
325
+ content: { type: r },
321
326
  category: "Extra",
322
327
  activate: !0,
323
- ...r
328
+ ...c
324
329
  },
325
- isComponent: (y) => Z(y, g),
330
+ isComponent: (d) => Z(d, i),
326
331
  model: {
327
332
  defaults: {
328
- name: i,
329
- icon: I,
333
+ name: g,
334
+ icon: E,
330
335
  droppable: !1,
331
- attributes: { [g]: !0 },
332
- resizable: m,
333
- components: I,
336
+ attributes: { [i]: !0 },
337
+ resizable: S,
338
+ components: E,
334
339
  style: { width: "50px", height: "50px" },
335
- traits: [x()]
340
+ traits: [_()]
336
341
  },
337
342
  init() {
338
343
  this.listenTo(this.components(), "change add", this.disableLayers), this.disableLayers();
339
344
  },
340
345
  disableLayers() {
341
- this.components().forEach((y) => y.set({ layerable: !1, locked: !0 }));
346
+ this.components().forEach((d) => d.set({ layerable: !1, locked: !0 }));
342
347
  }
343
348
  },
344
- view: f
349
+ view: y
345
350
  }), p) {
346
- const y = (l = o.getType(n)) == null ? void 0 : l.model, [h, b, ...d] = y.getDefaults().traits;
351
+ const d = (u = o.getType(n)) == null ? void 0 : u.model, [T, h, ...f] = d.getDefaults().traits;
347
352
  o.addType(n, {
348
353
  model: {
349
354
  defaults: {
350
- traits: [h, b, x(), ...d]
355
+ traits: [T, h, _(), ...f]
351
356
  }
352
357
  },
353
- view: f
358
+ view: y
354
359
  });
355
360
  }
356
361
  J({
357
- editor: e,
358
- licenseKey: a,
359
- plan: S,
360
- pluginName: Q,
362
+ editor: t,
363
+ licenseKey: l,
364
+ plan: Q,
365
+ pluginName: m,
361
366
  cleanup: () => {
362
- s.remove(c), o.removeType(c);
367
+ s.remove(r), o.removeType(r);
363
368
  }
364
369
  });
365
- }, ue = q(le);
370
+ }, ut = q(lt);
366
371
  export {
367
- ue as default
372
+ ut as default
368
373
  };
@@ -1,3 +1,3 @@
1
- (function(y,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_iconifyComponent=h())})(this,function(){"use strict";const y="app.grapesjs.com",h="app-stage.grapesjs.com",x=[y,"app2.grapesjs.com",h,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],C="license:check:start",B="license:check:end",H=()=>typeof window<"u",F=({isDev:e,isStage:t})=>`${e?"":`https://${t?h:y}`}/api`,W=()=>{const e=H()&&window.location.hostname;return!!e&&(x.includes(e)||x.some(t=>e.endsWith(t)))};async function K({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:u,body:p}){const r=`${t||F({isDev:!1,isStage:!1})}${e}`,n={method:o,headers:{"Content-Type":"application/json",...s}};p&&(n.body=JSON.stringify(p));const c=u?new URLSearchParams(u).toString():"",i=c?`?${c}`:"",g=await fetch(`${r}${i}`,n);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),R=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(R||{}),v=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(v||{});const _={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function V(e){const t=e;return t.init=o=>s=>e(s,o),t}const Y=e=>V(e);async function m({editor:e,plan:t,pluginName:o,licenseKey:s,cleanup:u}){let p="",a=!1;const r=W(),n=i=>{console.warn("Cleanup plugin:",o,"Reason:",i),u()},c=(i={})=>{var L;const{error:g,sdkLicense:T}=i,l=(L=i.plan)==null?void 0:L.category;if(!(T||i.license)||g)n(g||"Invalid license");else if(l){const w=_[t],d=_[l];w>d&&n({pluginRequiredPlan:t,licensePlan:l})}};e.on(C,i=>{p=i==null?void 0:i.baseApiUrl,a=!0}),e.on(B,i=>{c(i)}),setTimeout(async()=>{if(!a){if(r)return;if(s){const i=await z({licenseKey:s,pluginName:o,baseApiUrl:p});i&&c(i)}else n("The `licenseKey` option not provided")}},2e3)}async function z(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await K({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(u){return console.error("Error during SDK license check:",u),!1}}const S=(e,t)=>{var o;return!!((o=e==null?void 0:e.hasAttribute)!=null&&o.call(e,t))},q="iconifyComponent",J=b.startup,X={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},A=`<svg viewBox="0 0 24 24">
1
+ (function(v,T){typeof exports=="object"&&typeof module<"u"?module.exports=T():typeof define=="function"&&define.amd?define(T):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_iconifyComponent=T())})(this,function(){"use strict";const v="app.grapesjs.com",T="app-stage.grapesjs.com",_=[v,"app2.grapesjs.com",T,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",H="license:check:end",F=()=>typeof window<"u",W=({isDev:t,isStage:e,isPlatform:o})=>`${t?"":`https://${e?T:v}`}/${o?"platform-api":"api"}`,C=()=>{const t=F()&&window.location.hostname;return!!t&&(_.includes(t)||_.some(e=>t.endsWith(e)))};async function K({path:t,baseApiUrl:e,method:o="GET",headers:s={},params:a,body:g}){const c=`${e||W({isDev:!1,isStage:!1})}${t}`,n={method:o,headers:{"Content-Type":"application/json",...s}};g&&(n.body=JSON.stringify(g));const r=a?new URLSearchParams(a).toString():"",p=r?`?${r}`:"",i=await fetch(`${c}${p}`,n);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return i.json()}var w=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(w||{}),D=(t=>(t.Info="info",t.Error="error",t.Success="success",t.Warning="warning",t))(D||{}),I=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(I||{});const k={[w.free]:0,[w.startup]:10,[w.business]:20,[w.enterprise]:30};function V(t){const e=t;return e.init=o=>s=>t(s,o),e}const m=t=>V(t);async function Y({editor:t,plan:e,pluginName:o,licenseKey:s,onLicenseCheckResponse:a,cleanup:g}){let l="",c=!1;const n=C(),r=i=>{console.warn("Cleanup plugin:",o,"Reason:",i),g()},p=(i={})=>{var h;const{error:y,sdkLicense:u}=i,d=(h=i.plan)==null?void 0:h.category;if(!(u||i.license)||y)r(y||"Invalid license");else if(d){const f=k[e],b=k[d];f>b&&r({pluginRequiredPlan:e,licensePlan:d})}};t.on(B,i=>{l=i==null?void 0:i.baseApiUrl,c=!0}),t.on(H,i=>{a==null||a(i),p(i)}),setTimeout(async()=>{if(!c){if(n)return;if(s){const i=await z({licenseKey:s,pluginName:o,baseApiUrl:l});a==null||a(i),i&&p(i)}else r("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:e,pluginName:o,baseApiUrl:s}=t;try{return(await K({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const S=(t,e)=>{var o;return!!((o=t==null?void 0:t.hasAttribute)!=null&&o.call(t,e))},q="iconifyComponent",J=w.startup,X={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},P=`<svg viewBox="0 0 24 24">
2
2
  <path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
3
- </svg>`,D="layout-icon-picker",Z="icons-layout-",M="icons-list-layout",N="gs-iconify-picker",P="__iconify_collection",Q="https://api.iconify.design",O=new Map;let E;const ee=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function G({collectionId:e,editor:t}){try{if(O.has(e))return O.get(e);const o=await fetch(ee({collectionId:e}));if(!o.ok)throw new Error(`Failed to fetch collection: ${o.statusText}`);const s=await o.json();return O.set(e,s),s}catch(o){console.error("Error fetching collection",o),t.runCommand(v.toastAdd,ce());return}}async function te({collectionIds:e,editor:t}){try{if(E)return E;const o=e?`?prefixes=${e.join(",")}`:"",s=await fetch(`${Q}/collections${o}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return E=await s.json(),E}catch(o){console.error("Error fetching collections",o),t.runCommand(v.toastAdd,j());return}}function $(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var t;(t=e.getSelected())==null||t.trigger("active")}}}async function oe({collectionIds:e,editor:t,component:o}){const s=await te({collectionIds:e,editor:t});if(!s)return;const u=({icon:n,collectionId:c,iconId:i})=>{o.components(n),o.set({collectionId:c,iconId:i})},p=Object.entries(s).map(([n,c])=>({id:n,...c})).sort((n,c)=>n.name.localeCompare(c.name)),a=o.get("collectionId")??p[0].id;t.runCommand(v.layoutToggle,{id:D,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[se({collectionsList:p,collectionId:a,editor:t,handleClick:u}),{id:M,type:"column",grow:!0}]}});const r=await G({collectionId:a,editor:t});r&&(U({editor:t,collection:r}),k({editor:t,collection:r,handleClick:u,collectionId:a}))}function U({editor:e,collection:t}){e.em.set(P,t)}function ne(e){return e.em.get(P)}function k(e){const{editor:t}=e;t.runCommand(v.layoutUpdate,{id:Z,layout:ie(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:M}})}function se(e){const{collectionsList:t,collectionId:o,editor:s,handleClick:u}=e,p=t.map(({id:a,name:r,total:n})=>({id:a,label:`${r} (${n})`})).sort((a,r)=>a.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${N}__header`,children:[{type:"selectField",value:o,options:p,emptyState:"Select an icon collection",onChange:async({setState:a,value:r})=>{const n=await G({collectionId:r,editor:s});n&&(a({value:r}),U({editor:s,collection:n}),k({editor:s,collection:n,handleClick:u,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${P}`]:({setState:a})=>a({value:""})},onInput:({setState:a,value:r,editor:n})=>{const c=ne(n);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([g])=>g.includes(r)));a({value:r}),k({editor:n,collection:c,handleClick:u,collectionId:o,collectionFiltered:{...c,icons:i}})}}]}}function ie({collection:e,collectionFiltered:t,handleClick:o}){const{height:s=24,width:u=24,icons:p,prefix:a}=t||e,r=Object.entries(p).map(([n,c])=>({name:n,...c}),{});return{type:"column",className:`${N}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:n})=>({type:"custom",render:c=>{const{editor:i,addEl:g,removeEl:T}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=n.body;const f=n.width||u,L=n.height||s;l.setAttribute("viewBox",`0 0 ${f} ${L}`),l.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const w=[["click",()=>{const d=l.cloneNode(!0);d.removeAttribute("style");const I=d.outerHTML;o({icon:I,collectionId:a,iconId:n.name}),i==null||i.runCommand(v.layoutRemove,{id:D})}],["pointerover",()=>{l.style.border="2px solid currentColor",l.style.padding="4px"}],["pointerout",()=>{l.style.border="",l.style.padding=""}]];return w.forEach(([d,I])=>l.addEventListener(d,I)),g(l),()=>{w.forEach(([d,I])=>l.removeEventListener(d,I)),T(l)}}})}}}function j(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:R.Error}}function ce(){return{...j(),id:"toast-error-getCollection",content:"Error fetching collection"}}return Y(function(e,t={}){var l;const{Components:o,Blocks:s}=e,{collections:u,extendIconComponent:p=!0,licenseKey:a,block:r={}}=t,n="icon",c="iconify",i="Iconify",g="data-type-iconify",T={events:()=>({dblclick:"onActive"}),onActive(){oe({collectionIds:u,editor:e,component:this.model})}};if(o.addType(c,{block:r&&{label:i,media:A,content:{type:c},category:"Extra",activate:!0,...r},isComponent:f=>S(f,g),model:{defaults:{name:i,icon:A,droppable:!1,attributes:{[g]:!0},resizable:X,components:A,style:{width:"50px",height:"50px"},traits:[$()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:T}),p){const f=(l=o.getType(n))==null?void 0:l.model,[L,w,...d]=f.getDefaults().traits;o.addType(n,{model:{defaults:{traits:[L,w,$(),...d]}},view:T})}m({editor:e,licenseKey:a,plan:J,pluginName:q,cleanup:()=>{s.remove(c),o.removeType(c)}})})});
3
+ </svg>`,M="layout-icon-picker",Z="icons-layout-",N="icons-list-layout",$="gs-iconify-picker",L="__iconify_collection",Q="https://api.iconify.design",O=new Map;let E;const tt=({collectionId:t})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${t}@latest/icons.json`;async function G({collectionId:t,editor:e}){try{if(O.has(t))return O.get(t);const o=await fetch(tt({collectionId:t}));if(!o.ok)throw new Error(`Failed to fetch collection: ${o.statusText}`);const s=await o.json();return O.set(t,s),s}catch(o){console.error("Error fetching collection",o),e.runCommand(I.toastAdd,rt());return}}async function et({collectionIds:t,editor:e}){try{if(E)return E;const o=t?`?prefixes=${t.join(",")}`:"",s=await fetch(`${Q}/collections${o}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return E=await s.json(),E}catch(o){console.error("Error fetching collections",o),e.runCommand(I.toastAdd,j());return}}function R(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(t){var e;(e=t.getSelected())==null||e.trigger("active")}}}async function ot({collectionIds:t,editor:e,component:o}){const s=await et({collectionIds:t,editor:e});if(!s)return;const a=({icon:n,collectionId:r,iconId:p})=>{o.components(n),o.set({collectionId:r,iconId:p})},g=Object.entries(s).map(([n,r])=>({id:n,...r})).sort((n,r)=>n.name.localeCompare(r.name)),l=o.get("collectionId")??g[0].id;e.runCommand(I.layoutToggle,{id:M,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[st({collectionsList:g,collectionId:l,editor:e,handleClick:a}),{id:N,type:"column",grow:!0}]}});const c=await G({collectionId:l,editor:e});c&&(U({editor:e,collection:c}),x({editor:e,collection:c,handleClick:a,collectionId:l}))}function U({editor:t,collection:e}){t.em.set(L,e)}function nt(t){return t.em.get(L)}function x(t){const{editor:e}=t;e.runCommand(I.layoutUpdate,{id:Z,layout:it(t),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:N}})}function st(t){const{collectionsList:e,collectionId:o,editor:s,handleClick:a}=t,g=e.map(({id:l,name:c,total:n})=>({id:l,label:`${c} (${n})`})).sort((l,c)=>l.label.localeCompare(c.label));return{type:"column",style:{gap:10},className:`${$}__header`,children:[{type:"selectField",value:o,options:g,emptyState:"Select an icon collection",onChange:async({setState:l,value:c})=>{const n=await G({collectionId:c,editor:s});n&&(l({value:c}),U({editor:s,collection:n}),x({editor:s,collection:n,handleClick:a,collectionId:c}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${L}`]:({setState:l})=>l({value:""})},onInput:({setState:l,value:c,editor:n})=>{const r=nt(n);if(!r)return;const p=Object.fromEntries(Object.entries(r.icons).filter(([i])=>i.includes(c)));l({value:c}),x({editor:n,collection:r,handleClick:a,collectionId:o,collectionFiltered:{...r,icons:p}})}}]}}function it({collection:t,collectionFiltered:e,handleClick:o}){const{height:s=24,width:a=24,icons:g,prefix:l}=e||t,c=Object.entries(g).map(([n,r])=>({name:n,...r}),{});return{type:"column",className:`${$}__content`,style:{height:"100%"},children:{type:"virtualList",items:c,itemLayout:({item:n})=>({type:"custom",render:r=>{const{editor:p,addEl:i,removeEl:y}=r,u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("xmlns","http://www.w3.org/2000/svg"),u.innerHTML=n.body;const d=n.width||a,A=n.height||s;u.setAttribute("viewBox",`0 0 ${d} ${A}`),u.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const h=[["click",()=>{const f=u.cloneNode(!0);f.removeAttribute("style");const b=f.outerHTML;o({icon:b,collectionId:l,iconId:n.name}),p==null||p.runCommand(I.layoutRemove,{id:M})}],["pointerover",()=>{u.style.border="2px solid currentColor",u.style.padding="4px"}],["pointerout",()=>{u.style.border="",u.style.padding=""}]];return h.forEach(([f,b])=>u.addEventListener(f,b)),i(u),()=>{h.forEach(([f,b])=>u.removeEventListener(f,b)),y(u)}}})}}}function j(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:D.Error}}function rt(){return{...j(),id:"toast-error-getCollection",content:"Error fetching collection"}}return m(function(t,e={}){var u;const{Components:o,Blocks:s}=t,{collections:a,extendIconComponent:g=!0,licenseKey:l,block:c={}}=e,n="icon",r="iconify",p="Iconify",i="data-type-iconify",y={events:()=>({dblclick:"onActive"}),onActive(){ot({collectionIds:a,editor:t,component:this.model})}};if(o.addType(r,{block:c&&{label:p,media:P,content:{type:r},category:"Extra",activate:!0,...c},isComponent:d=>S(d,i),model:{defaults:{name:p,icon:P,droppable:!1,attributes:{[i]:!0},resizable:X,components:P,style:{width:"50px",height:"50px"},traits:[R()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(d=>d.set({layerable:!1,locked:!0}))}},view:y}),g){const d=(u=o.getType(n))==null?void 0:u.model,[A,h,...f]=d.getDefaults().traits;o.addType(n,{model:{defaults:{traits:[A,h,R(),...f]}},view:y})}Y({editor:t,licenseKey:l,plan:J,pluginName:q,cleanup:()=>{s.remove(r),o.removeType(r)}})})});