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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";require("grapesjs");var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{}),b=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(b||{});const A="app.grapesjs.com",T="app-stage.grapesjs.com",v=[A,T,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",k="license:check:end",x=()=>typeof window<"u",D=({isDev:e,isStage:t})=>`${e?"":`https://${t?T:A}`}/api`,F=()=>{const e=x()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function G({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:o,body:i}){const l=`${t||D({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const d=o?new URLSearchParams(o).toString():"",a=d?`?${d}`:"",u=await fetch(`${l}${a}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}const w={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function O(e){const t=e;return t.init=n=>s=>e(s,n),t}const M=e=>O(e);async function U({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:o}){let i="",r=!1;const l=F(),c=a=>{console.warn("Cleanup plugin:",n,"Reason:",a),o()},d=(a={})=>{var P;const{error:u,sdkLicense:f}=a,g=(P=a.plan)==null?void 0:P.category;if(!(f||a.license)||u)c(u||"Invalid license");else if(g){const L=w[t],R=w[g];L>R&&c({pluginRequiredPlan:t,licensePlan:g})}};e.on($,a=>{i=a==null?void 0:a.baseApiUrl,r=!0}),e.on(k,a=>{d(a)}),setTimeout(async()=>{if(!r){if(l)return;if(s){const a=await B({licenseKey:s,pluginName:n,baseApiUrl:i});a&&d(a)}else c("The `licenseKey` option not provided")}},2e3)}async function B(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await G({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const E=e=>{const{family:t,menu:n,axes:s}=e,o=!!s,i=Object.assign({},...e.variants.map(r=>{var a,u;let l,c;if(o){const f=s.find(g=>g.tag==="wght");if(f){const{start:g,end:y}=f;l=`${g} ${y}`}}return l||(l=((a=r.match(/\d+/))==null?void 0:a[0])??"400"),c=((u=r.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[r]:{family:t,source:e.files[r],variant:r,options:{style:c,weight:l}}}}));return{family:t,menuVariant:{family:`assetManagerMenu-${t}`,source:n,variant:"menu"},variants:i}},I=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:E(e),needsLoading:!0}}),W=e=>{if(e.customData.needsLoading){e.customData.needsLoading=!1;const{font:t}=e.customData,{family:n,source:s,options:o}=t.menuVariant,i=new FontFace(n,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let h;const j=e=>{const t=[];for(const n of Object.keys(e)){let s=e[n];s&&(Array.isArray(s)?t.push(...s.map(o=>[n,o.toString()])):(s=s.toString(),t.push([n,s])))}return new URLSearchParams(t)},m=e=>{const{apiKey:t,searchParams:n}=e,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=j(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var d;if(h)return h;const o={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=n==null?void 0:n(),r={...o,...i},c=await(await fetch(s(r))).json();return(d=c.items)!=null&&d.length?(h=c.items.map(I),h):[]},itemLayout:o=>{const i=h.find(r=>r.id===o.assetProps.id);return W(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},N={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},K="googleFontsAssetProvider",_=function(e,t){const{i18n:n={}}=t,s=m(t);e.runCommand(b.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:N,...n}),U({editor:e,licenseKey:t.licenseKey,plan:p.startup,pluginName:K,cleanup:()=>{e.runCommand(b.assetProviderRemove,{id:s.id})}})},V=M(_);module.exports=V;
1
+ "use strict";require("grapesjs");var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{}),b=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(b||{});const A="app.grapesjs.com",T="app-stage.grapesjs.com",v=[A,T,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",k="license:check:end",x=()=>typeof window<"u",G=({isDev:e,isStage:t})=>`${e?"":`https://${t?T:A}`}/api`,D=()=>{const e=x()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function F({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:o,body:i}){const l=`${t||G({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const u=o?new URLSearchParams(o).toString():"",a=u?`?${u}`:"",d=await fetch(`${l}${a}`,c);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}const w={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function U(e){const t=e;return t.init=n=>s=>e(s,n),t}const O=e=>U(e);async function M({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:o}){let i="",r=!1;const l=D(),c=a=>{console.warn("Cleanup plugin:",n,"Reason:",a),o()},u=(a={})=>{var P;const{error:d,sdkLicense:f}=a,g=(P=a.plan)==null?void 0:P.category;if(!(f||a.license)||d)c(d||"Invalid license");else if(g){const L=w[t],R=w[g];L>R&&c({pluginRequiredPlan:t,licensePlan:g})}};e.on($,a=>{i=a==null?void 0:a.baseApiUrl,r=!0}),e.on(k,a=>{u(a)}),setTimeout(async()=>{if(!r){if(l)return;if(s){const a=await B({licenseKey:s,pluginName:n,baseApiUrl:i});a&&u(a)}else c("The `licenseKey` option not provided")}},2e3)}async function B(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await F({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const E=e=>{const{family:t,menu:n,axes:s}=e,o=!!s,i=Object.assign({},...e.variants.map(r=>{var a,d;let l,c;if(o){const f=s.find(g=>g.tag==="wght");if(f){const{start:g,end:y}=f;l=`${g} ${y}`}}return l||(l=((a=r.match(/\d+/))==null?void 0:a[0])??"400"),c=((d=r.match(/[a-zA-Z]+/))==null?void 0:d[0])==="italic"?"italic":void 0,{[r]:{family:t,source:e.files[r],variant:r,options:{style:c,weight:l}}}}));return{family:t,menuVariant:{family:`assetManagerMenu-${t}`,source:n,variant:"menu"},variants:i}},I=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:E(e),needsLoading:!0}}),W=e=>{if(e.customData.needsLoading){e.customData.needsLoading=!1;const{font:t}=e.customData,{family:n,source:s,options:o}=t.menuVariant,i=new FontFace(n,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let h;const j=e=>{const t=[];for(const n of Object.keys(e)){let s=e[n];s&&(Array.isArray(s)?t.push(...s.map(o=>[n,o.toString()])):(s=s.toString(),t.push([n,s])))}return new URLSearchParams(t)},N=e=>{const{apiKey:t,searchParams:n}=e,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=j(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const o={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=n==null?void 0:n(),r={...o,...i},c=await(await fetch(s(r))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(I),h):[]},itemLayout:o=>{const i=h.find(r=>r.id===o.assetProps.id);return W(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},K={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},_="googleFontsAssetProvider",m=function(e,t){const{i18n:n={}}=t,s=N(t);e.runCommand(b.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:K,...n}),M({editor:e,licenseKey:t.licenseKey,plan:p.startup,pluginName:_,cleanup:()=>{e.runCommand(b.assetProviderRemove,{id:s.id})}})},V=O(m);module.exports=V;
@@ -1,5 +1,5 @@
1
1
  import "grapesjs";
2
- var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), b = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.projectFiles = "studio:projectFiles", 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.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))(b || {});
2
+ var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), b = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.projectFiles = "studio:projectFiles", 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.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))(b || {});
3
3
  const A = "app.grapesjs.com", T = "app-stage.grapesjs.com", v = [
4
4
  A,
5
5
  T,
@@ -11,11 +11,11 @@ const A = "app.grapesjs.com", T = "app-stage.grapesjs.com", v = [
11
11
  // For stackblitz.com demos
12
12
  "-sandpack.codesandbox.io"
13
13
  // For Sandpack demos
14
- ], $ = "license:check:start", k = "license:check:end", x = () => typeof window < "u", D = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? T : A}`}/api`, F = () => {
14
+ ], $ = "license:check:start", k = "license:check:end", x = () => typeof window < "u", G = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? T : A}`}/api`, D = () => {
15
15
  const e = x() && window.location.hostname;
16
16
  return !!e && (v.includes(e) || v.some((t) => e.endsWith(t)));
17
17
  };
18
- async function G({
18
+ async function F({
19
19
  path: e,
20
20
  baseApiUrl: t,
21
21
  method: n = "GET",
@@ -23,7 +23,7 @@ async function G({
23
23
  params: o,
24
24
  body: i
25
25
  }) {
26
- const l = `${t || D({ isDev: !1, isStage: !1 })}${e}`, c = {
26
+ const l = `${t || G({ isDev: !1, isStage: !1 })}${e}`, c = {
27
27
  method: n,
28
28
  headers: {
29
29
  "Content-Type": "application/json",
@@ -31,10 +31,10 @@ async function G({
31
31
  }
32
32
  };
33
33
  i && (c.body = JSON.stringify(i));
34
- const d = o ? new URLSearchParams(o).toString() : "", a = d ? `?${d}` : "", u = await fetch(`${l}${a}`, c);
35
- if (!u.ok)
36
- throw new Error(`HTTP error! status: ${u.status}`);
37
- return u.json();
34
+ const u = o ? new URLSearchParams(o).toString() : "", a = u ? `?${u}` : "", d = await fetch(`${l}${a}`, c);
35
+ if (!d.ok)
36
+ throw new Error(`HTTP error! status: ${d.status}`);
37
+ return d.json();
38
38
  }
39
39
  const w = {
40
40
  [p.free]: 0,
@@ -42,12 +42,12 @@ const w = {
42
42
  [p.business]: 20,
43
43
  [p.enterprise]: 30
44
44
  };
45
- function O(e) {
45
+ function U(e) {
46
46
  const t = e;
47
47
  return t.init = (n) => (s) => e(s, n), t;
48
48
  }
49
- const M = (e) => /* @__PURE__ */ O(e);
50
- async function U({
49
+ const O = (e) => /* @__PURE__ */ U(e);
50
+ async function M({
51
51
  editor: e,
52
52
  plan: t,
53
53
  pluginName: n,
@@ -55,13 +55,13 @@ async function U({
55
55
  cleanup: o
56
56
  }) {
57
57
  let i = "", r = !1;
58
- const l = F(), c = (a) => {
58
+ const l = D(), c = (a) => {
59
59
  console.warn("Cleanup plugin:", n, "Reason:", a), o();
60
- }, d = (a = {}) => {
60
+ }, u = (a = {}) => {
61
61
  var P;
62
- const { error: u, sdkLicense: f } = a, g = (P = a.plan) == null ? void 0 : P.category;
63
- if (!(f || a.license) || u)
64
- c(u || "Invalid license");
62
+ const { error: d, sdkLicense: f } = a, g = (P = a.plan) == null ? void 0 : P.category;
63
+ if (!(f || a.license) || d)
64
+ c(d || "Invalid license");
65
65
  else if (g) {
66
66
  const L = w[t], R = w[g];
67
67
  L > R && c({ pluginRequiredPlan: t, licensePlan: g });
@@ -70,13 +70,13 @@ async function U({
70
70
  e.on($, (a) => {
71
71
  i = a == null ? void 0 : a.baseApiUrl, r = !0;
72
72
  }), e.on(k, (a) => {
73
- d(a);
73
+ u(a);
74
74
  }), setTimeout(async () => {
75
75
  if (!r) {
76
76
  if (l) return;
77
77
  if (s) {
78
78
  const a = await B({ licenseKey: s, pluginName: n, baseApiUrl: i });
79
- a && d(a);
79
+ a && u(a);
80
80
  } else
81
81
  c("The `licenseKey` option not provided");
82
82
  }
@@ -85,7 +85,7 @@ async function U({
85
85
  async function B(e) {
86
86
  const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
87
87
  try {
88
- return (await G({
88
+ return (await F({
89
89
  baseApiUrl: s,
90
90
  path: `/sdk/${t || "na"}`,
91
91
  method: "POST",
@@ -102,7 +102,7 @@ const E = (e) => {
102
102
  const { family: t, menu: n, axes: s } = e, o = !!s, i = Object.assign(
103
103
  {},
104
104
  ...e.variants.map((r) => {
105
- var a, u;
105
+ var a, d;
106
106
  let l, c;
107
107
  if (o) {
108
108
  const f = s.find((g) => g.tag === "wght");
@@ -111,7 +111,7 @@ const E = (e) => {
111
111
  l = `${g} ${y}`;
112
112
  }
113
113
  }
114
- return l || (l = ((a = r.match(/\d+/)) == null ? void 0 : a[0]) ?? "400"), c = ((u = r.match(/[a-zA-Z]+/)) == null ? void 0 : u[0]) === "italic" ? "italic" : void 0, {
114
+ return l || (l = ((a = r.match(/\d+/)) == null ? void 0 : a[0]) ?? "400"), c = ((d = r.match(/[a-zA-Z]+/)) == null ? void 0 : d[0]) === "italic" ? "italic" : void 0, {
115
115
  [r]: {
116
116
  family: t,
117
117
  source: e.files[r],
@@ -139,7 +139,7 @@ const E = (e) => {
139
139
  src: e.menu,
140
140
  name: e.family,
141
141
  customData: { font: E(e), needsLoading: !0 }
142
- }), m = (e) => {
142
+ }), W = (e) => {
143
143
  if (e.customData.needsLoading) {
144
144
  e.customData.needsLoading = !1;
145
145
  const { font: t } = e.customData, { family: n, source: s, options: o } = t.menuVariant, i = new FontFace(n, `url("${s}")`, o);
@@ -148,16 +148,16 @@ const E = (e) => {
148
148
  }
149
149
  };
150
150
  let h;
151
- const W = (e) => {
151
+ const j = (e) => {
152
152
  const t = [];
153
153
  for (const n of Object.keys(e)) {
154
154
  let s = e[n];
155
155
  s && (Array.isArray(s) ? t.push(...s.map((o) => [n, o.toString()])) : (s = s.toString(), t.push([n, s])));
156
156
  }
157
157
  return new URLSearchParams(t);
158
- }, j = (e) => {
158
+ }, N = (e) => {
159
159
  const { apiKey: t, searchParams: n } = e, s = (o = {}) => {
160
- const i = "https://www.googleapis.com/webfonts/v1/webfonts", r = W(o);
160
+ const i = "https://www.googleapis.com/webfonts/v1/webfonts", r = j(o);
161
161
  return `${i}?${r}`;
162
162
  };
163
163
  return {
@@ -166,7 +166,7 @@ const W = (e) => {
166
166
  label: ({ editor: o }) => o.I18n.t("googleFontsAssetProvider.providerLabel"),
167
167
  search: { reloadOnInput: !1 },
168
168
  async onLoad() {
169
- var d;
169
+ var u;
170
170
  if (h)
171
171
  return h;
172
172
  const o = {
@@ -178,11 +178,11 @@ const W = (e) => {
178
178
  ...o,
179
179
  ...i
180
180
  }, c = await (await fetch(s(r))).json();
181
- return (d = c.items) != null && d.length ? (h = c.items.map(I), h) : [];
181
+ return (u = c.items) != null && u.length ? (h = c.items.map(I), h) : [];
182
182
  },
183
183
  itemLayout: (o) => {
184
184
  const i = h.find((r) => r.id === o.assetProps.id);
185
- return m(i), {
185
+ return W(i), {
186
186
  type: "column",
187
187
  onClick: () => o.onSelect(i),
188
188
  htmlAttrs: {
@@ -212,27 +212,27 @@ const W = (e) => {
212
212
  };
213
213
  }
214
214
  };
215
- }, N = {
215
+ }, K = {
216
216
  googleFontsAssetProvider: {
217
217
  searchBtn: "Search on Google Fonts",
218
218
  modalTitle: "Select Font",
219
219
  providerLabel: "Google Fonts"
220
220
  }
221
- }, K = "googleFontsAssetProvider", _ = function(e, t) {
222
- const { i18n: n = {} } = t, s = j(t);
221
+ }, _ = "googleFontsAssetProvider", m = function(e, t) {
222
+ const { i18n: n = {} } = t, s = N(t);
223
223
  e.runCommand(b.assetProviderAdd, { provider: s }), e.I18n.addMessages({
224
- en: N,
224
+ en: K,
225
225
  ...n
226
- }), U({
226
+ }), M({
227
227
  editor: e,
228
228
  licenseKey: t.licenseKey,
229
229
  plan: p.startup,
230
- pluginName: K,
230
+ pluginName: _,
231
231
  cleanup: () => {
232
232
  e.runCommand(b.assetProviderRemove, { id: s.id });
233
233
  }
234
234
  });
235
- }, H = M(_);
235
+ }, H = O(m);
236
236
  export {
237
237
  H as default
238
238
  };
@@ -1 +1 @@
1
- (function(l,p){typeof exports=="object"&&typeof module<"u"?module.exports=p(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],p):(l=typeof globalThis<"u"?globalThis:l||self,l.StudioSdkPlugins_googleFontsAssetProvider=p())})(this,function(){"use strict";var l=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(l||{}),p=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(p||{});const y="app.grapesjs.com",P="app-stage.grapesjs.com",v=[y,P,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:start",R="license:check:end",x=()=>typeof window<"u",k=({isDev:e,isStage:t})=>`${e?"":`https://${t?P:y}`}/api`,$=()=>{const e=x()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function F({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:o,body:i}){const d=`${t||k({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const u=o?new URLSearchParams(o).toString():"",r=u?`?${u}`:"",g=await fetch(`${d}${r}`,c);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const w={[l.free]:0,[l.startup]:10,[l.business]:20,[l.enterprise]:30};function D(e){const t=e;return t.init=n=>s=>e(s,n),t}const G=e=>D(e);async function O({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:o}){let i="",a=!1;const d=$(),c=r=>{console.warn("Cleanup plugin:",n,"Reason:",r),o()},u=(r={})=>{var T;const{error:g,sdkLicense:b}=r,f=(T=r.plan)==null?void 0:T.category;if(!(b||r.license)||g)c(g||"Invalid license");else if(f){const N=w[t],_=w[f];N>_&&c({pluginRequiredPlan:t,licensePlan:f})}};e.on(L,r=>{i=r==null?void 0:r.baseApiUrl,a=!0}),e.on(R,r=>{u(r)}),setTimeout(async()=>{if(!a){if(d)return;if(s){const r=await M({licenseKey:s,pluginName:n,baseApiUrl:i});r&&u(r)}else c("The `licenseKey` option not provided")}},2e3)}async function M(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await F({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const U=e=>{const{family:t,menu:n,axes:s}=e,o=!!s,i=Object.assign({},...e.variants.map(a=>{var r,g;let d,c;if(o){const b=s.find(f=>f.tag==="wght");if(b){const{start:f,end:A}=b;d=`${f} ${A}`}}return d||(d=((r=a.match(/\d+/))==null?void 0:r[0])??"400"),c=((g=a.match(/[a-zA-Z]+/))==null?void 0:g[0])==="italic"?"italic":void 0,{[a]:{family:t,source:e.files[a],variant:a,options:{style:c,weight:d}}}}));return{family:t,menuVariant:{family:`assetManagerMenu-${t}`,source:n,variant:"menu"},variants:i}},j=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:U(e),needsLoading:!0}}),m=e=>{if(e.customData.needsLoading){e.customData.needsLoading=!1;const{font:t}=e.customData,{family:n,source:s,options:o}=t.menuVariant,i=new FontFace(n,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let h;const B=e=>{const t=[];for(const n of Object.keys(e)){let s=e[n];s&&(Array.isArray(s)?t.push(...s.map(o=>[n,o.toString()])):(s=s.toString(),t.push([n,s])))}return new URLSearchParams(t)},E=e=>{const{apiKey:t,searchParams:n}=e,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",a=B(o);return`${i}?${a}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const o={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=n==null?void 0:n(),a={...o,...i},c=await(await fetch(s(a))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(j),h):[]},itemLayout:o=>{const i=h.find(a=>a.id===o.assetProps.id);return m(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},I={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},W="googleFontsAssetProvider";return G(function(e,t){const{i18n:n={}}=t,s=E(t);e.runCommand(p.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:I,...n}),O({editor:e,licenseKey:t.licenseKey,plan:l.startup,pluginName:W,cleanup:()=>{e.runCommand(p.assetProviderRemove,{id:s.id})}})})});
1
+ (function(l,p){typeof exports=="object"&&typeof module<"u"?module.exports=p(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],p):(l=typeof globalThis<"u"?globalThis:l||self,l.StudioSdkPlugins_googleFontsAssetProvider=p())})(this,function(){"use strict";var l=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(l||{}),p=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(p||{});const y="app.grapesjs.com",P="app-stage.grapesjs.com",v=[y,P,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:start",R="license:check:end",x=()=>typeof window<"u",k=({isDev:e,isStage:t})=>`${e?"":`https://${t?P:y}`}/api`,$=()=>{const e=x()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function F({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:o,body:i}){const u=`${t||k({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const d=o?new URLSearchParams(o).toString():"",a=d?`?${d}`:"",g=await fetch(`${u}${a}`,c);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const w={[l.free]:0,[l.startup]:10,[l.business]:20,[l.enterprise]:30};function G(e){const t=e;return t.init=n=>s=>e(s,n),t}const D=e=>G(e);async function U({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:o}){let i="",r=!1;const u=$(),c=a=>{console.warn("Cleanup plugin:",n,"Reason:",a),o()},d=(a={})=>{var T;const{error:g,sdkLicense:b}=a,f=(T=a.plan)==null?void 0:T.category;if(!(b||a.license)||g)c(g||"Invalid license");else if(f){const m=w[t],_=w[f];m>_&&c({pluginRequiredPlan:t,licensePlan:f})}};e.on(L,a=>{i=a==null?void 0:a.baseApiUrl,r=!0}),e.on(R,a=>{d(a)}),setTimeout(async()=>{if(!r){if(u)return;if(s){const a=await O({licenseKey:s,pluginName:n,baseApiUrl:i});a&&d(a)}else c("The `licenseKey` option not provided")}},2e3)}async function O(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await F({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const M=e=>{const{family:t,menu:n,axes:s}=e,o=!!s,i=Object.assign({},...e.variants.map(r=>{var a,g;let u,c;if(o){const b=s.find(f=>f.tag==="wght");if(b){const{start:f,end:A}=b;u=`${f} ${A}`}}return u||(u=((a=r.match(/\d+/))==null?void 0:a[0])??"400"),c=((g=r.match(/[a-zA-Z]+/))==null?void 0:g[0])==="italic"?"italic":void 0,{[r]:{family:t,source:e.files[r],variant:r,options:{style:c,weight:u}}}}));return{family:t,menuVariant:{family:`assetManagerMenu-${t}`,source:n,variant:"menu"},variants:i}},j=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:M(e),needsLoading:!0}}),B=e=>{if(e.customData.needsLoading){e.customData.needsLoading=!1;const{font:t}=e.customData,{family:n,source:s,options:o}=t.menuVariant,i=new FontFace(n,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let h;const E=e=>{const t=[];for(const n of Object.keys(e)){let s=e[n];s&&(Array.isArray(s)?t.push(...s.map(o=>[n,o.toString()])):(s=s.toString(),t.push([n,s])))}return new URLSearchParams(t)},I=e=>{const{apiKey:t,searchParams:n}=e,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=E(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var d;if(h)return h;const o={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=n==null?void 0:n(),r={...o,...i},c=await(await fetch(s(r))).json();return(d=c.items)!=null&&d.length?(h=c.items.map(j),h):[]},itemLayout:o=>{const i=h.find(r=>r.id===o.assetProps.id);return B(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},W={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},N="googleFontsAssetProvider";return D(function(e,t){const{i18n:n={}}=t,s=I(t);e.runCommand(p.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:W,...n}),U({editor:e,licenseKey:t.licenseKey,plan:l.startup,pluginName:N,cleanup:()=>{e.runCommand(p.assetProviderRemove,{id:s.id})}})})});
@@ -1,3 +1,3 @@
1
- "use strict";require("grapesjs");var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{}),O=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(O||{}),h=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(h||{});const H={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},w=`<svg viewBox="0 0 24 24">
1
+ "use strict";require("grapesjs");var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{}),x=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(x||{}),h=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(h||{});const j={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},w=`<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>`,x="layout-icon-picker",U="icons-layout-",R="icons-list-layout",_="gs-iconify-picker",A="__iconify_collection",B="https://api.iconify.design",I=new Map;let T;const D=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function $({collectionId:e,editor:o}){try{if(I.has(e))return I.get(e);const t=await fetch(D({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return I.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(h.toastAdd,z());return}}async function G({collectionIds:e,editor:o}){try{if(T)return T;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${B}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return T=await n.json(),T}catch(t){console.error("Error fetching collections",t),o.runCommand(h.toastAdd,C());return}}function P(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function W({collectionIds:e,editor:o,component:t}){const n=await G({collectionIds:e,editor:o});if(!n)return;const a=({icon:s,collectionId:c,iconId:i})=>{t.components(s),t.set({collectionId:c,iconId:i})},d=Object.entries(n).map(([s,c])=>({id:s,...c})).sort((s,c)=>s.name.localeCompare(c.name)),u=t.get("collectionId")??d[0].id;o.runCommand(h.layoutToggle,{id:x,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[V({collectionsList:d,collectionId:u,editor:o,handleClick:a}),{id:R,type:"column",grow:!0}]}});const r=await $({collectionId:u,editor:o});r&&E({editor:o,collection:r,handleClick:a,collectionId:u})}function F({editor:e,collection:o}){e.em.set(A,o)}function K(e){return e.em.get(A)}function E(e){const{editor:o}=e,t={id:U,layout:Y(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:R}};o.runCommand(h.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(h.layoutAdd,t),10)}function V(e){const{collectionsList:o,collectionId:t,editor:n,handleClick:a}=e,d=o.map(({id:u,name:r,total:s})=>({id:u,label:`${r} (${s})`})).sort((u,r)=>u.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${_}__header`,children:[{type:"selectField",value:t,options:d,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await $({collectionId:r,editor:n});s&&(u({value:r}),F({editor:n,collection:s}),E({editor:n,collection:s,handleClick:a,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${A}`]:({setState:u})=>u({value:""})},onInput:({setState:u,value:r,editor:s})=>{const c=K(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([g])=>g.includes(r)));u({value:r}),E({editor:s,collection:c,handleClick:a,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function Y({collection:e,collectionFiltered:o,handleClick:t}){const{height:n=24,width:a=24,icons:d,prefix:u}=o||e,r=Object.entries(d).map(([s,{body:c}])=>({name:s,body:c}),{});return{type:"column",className:`${_}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:g,removeEl:f}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=s.body,l.setAttribute("viewBox",`0 0 ${a} ${n}`);const{cssWidth:p,cssHeight:y}=q(a,n);l.style.cssText=`width: ${p}px; height: ${y}px; cursor: pointer;`,l.addEventListener("mouseover",()=>{l.style.border="2px solid currentColor",l.style.borderRadius="4px",l.style.padding="4px"}),l.addEventListener("mouseout",()=>{l.style.border="none"});const b=()=>{const v=l.cloneNode(!0);v.removeAttribute("style");const j=v.outerHTML;t({icon:j,collectionId:u,iconId:s.name}),i==null||i.runCommand(h.layoutRemove,{id:x})};return l.addEventListener("click",b),g(l),()=>{l.removeEventListener("click",b),f(l)}}}]}}}function q(e,o){const t=e/o;let n=48,a=48;return t>1?a=48/t:t<1&&(n=48*t),{cssWidth:n,cssHeight:a}}function C(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:O.Error}}function z(){return{...C(),id:"toast-error-getCollection",content:"Error fetching collection"}}const M="app.grapesjs.com",N="app-stage.grapesjs.com",k=[M,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],J="license:check:start",X="license:check:end",Z=()=>typeof window<"u",Q=({isDev:e,isStage:o})=>`${e?"":`https://${o?N:M}`}/api`,S=()=>{const e=Z()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(o=>e.endsWith(o)))};async function ee({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:a,body:d}){const r=`${o||Q({isDev:!1,isStage:!1})}${e}`,s={method:t,headers:{"Content-Type":"application/json",...n}};d&&(s.body=JSON.stringify(d));const c=a?new URLSearchParams(a).toString():"",i=c?`?${c}`:"",g=await fetch(`${r}${i}`,s);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const m={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function te(e){const o=e;return o.init=t=>n=>e(n,t),o}const oe=e=>te(e);async function ne({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:a}){let d="",u=!1;const r=S(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),a()},c=(i={})=>{var y;const{error:g,sdkLicense:f}=i,l=(y=i.plan)==null?void 0:y.category;if(!(f||i.license)||g)s(g||"Invalid license");else if(l){const b=m[o],v=m[l];b>v&&s({pluginRequiredPlan:o,licensePlan:l})}};e.on(J,i=>{d=i==null?void 0:i.baseApiUrl,u=!0}),e.on(X,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await se({licenseKey:n,pluginName:t,baseApiUrl:d});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function se(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await ee({baseApiUrl:n,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const ie=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},ce="iconifyComponent",re=function(e,o={}){var l;const{Components:t,Blocks:n}=e,{collections:a,extendIconComponent:d=!0,licenseKey:u,block:r={}}=o,s="icon",c="iconify",i="Iconify",g="data-type-iconify",f={events:()=>({dblclick:"onActive"}),onActive(){W({collectionIds:a,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:w,content:{type:c},category:"Extra",activate:!0,...r},isComponent:p=>ie(p,g),model:{defaults:{name:i,icon:w,droppable:!1,attributes:{[g]:!0},resizable:H,components:w,style:{width:"50px",height:"50px"},traits:[P()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:f}),d){const p=(l=t.getType(s))==null?void 0:l.model,[y,b,...v]=p.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[y,b,P(),...v]}},view:f})}ne({editor:e,licenseKey:u,plan:L.startup,pluginName:ce,cleanup:()=>{n.remove(c),t.removeType(c)}})},le=oe(re);module.exports=le;
3
+ </svg>`,R="layout-icon-picker",H="icons-layout-",m="icons-list-layout",_="gs-iconify-picker",A="__iconify_collection",B="https://api.iconify.design",I=new Map;let T;const D=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function $({collectionId:e,editor:o}){try{if(I.has(e))return I.get(e);const t=await fetch(D({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return I.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(h.toastAdd,z());return}}async function G({collectionIds:e,editor:o}){try{if(T)return T;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${B}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return T=await n.json(),T}catch(t){console.error("Error fetching collections",t),o.runCommand(h.toastAdd,C());return}}function P(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function W({collectionIds:e,editor:o,component:t}){const n=await G({collectionIds:e,editor:o});if(!n)return;const a=({icon:s,collectionId:c,iconId:i})=>{t.components(s),t.set({collectionId:c,iconId:i})},d=Object.entries(n).map(([s,c])=>({id:s,...c})).sort((s,c)=>s.name.localeCompare(c.name)),u=t.get("collectionId")??d[0].id;o.runCommand(h.layoutToggle,{id:R,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[V({collectionsList:d,collectionId:u,editor:o,handleClick:a}),{id:m,type:"column",grow:!0}]}});const r=await $({collectionId:u,editor:o});r&&E({editor:o,collection:r,handleClick:a,collectionId:u})}function F({editor:e,collection:o}){e.em.set(A,o)}function K(e){return e.em.get(A)}function E(e){const{editor:o}=e,t={id:H,layout:Y(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:m}};o.runCommand(h.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(h.layoutAdd,t),10)}function V(e){const{collectionsList:o,collectionId:t,editor:n,handleClick:a}=e,d=o.map(({id:u,name:r,total:s})=>({id:u,label:`${r} (${s})`})).sort((u,r)=>u.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${_}__header`,children:[{type:"selectField",value:t,options:d,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await $({collectionId:r,editor:n});s&&(u({value:r}),F({editor:n,collection:s}),E({editor:n,collection:s,handleClick:a,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${A}`]:({setState:u})=>u({value:""})},onInput:({setState:u,value:r,editor:s})=>{const c=K(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([g])=>g.includes(r)));u({value:r}),E({editor:s,collection:c,handleClick:a,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function Y({collection:e,collectionFiltered:o,handleClick:t}){const{height:n=24,width:a=24,icons:d,prefix:u}=o||e,r=Object.entries(d).map(([s,{body:c}])=>({name:s,body:c}),{});return{type:"column",className:`${_}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:g,removeEl:f}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=s.body,l.setAttribute("viewBox",`0 0 ${a} ${n}`);const{cssWidth:p,cssHeight:y}=q(a,n);l.style.cssText=`width: ${p}px; height: ${y}px; cursor: pointer;`,l.addEventListener("mouseover",()=>{l.style.border="2px solid currentColor",l.style.borderRadius="4px",l.style.padding="4px"}),l.addEventListener("mouseout",()=>{l.style.border="none"});const b=()=>{const v=l.cloneNode(!0);v.removeAttribute("style");const N=v.outerHTML;t({icon:N,collectionId:u,iconId:s.name}),i==null||i.runCommand(h.layoutRemove,{id:R})};return l.addEventListener("click",b),g(l),()=>{l.removeEventListener("click",b),f(l)}}}]}}}function q(e,o){const t=e/o;let n=48,a=48;return t>1?a=48/t:t<1&&(n=48*t),{cssWidth:n,cssHeight:a}}function C(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:x.Error}}function z(){return{...C(),id:"toast-error-getCollection",content:"Error fetching collection"}}const U="app.grapesjs.com",M="app-stage.grapesjs.com",k=[U,M,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],J="license:check:start",X="license:check:end",Z=()=>typeof window<"u",Q=({isDev:e,isStage:o})=>`${e?"":`https://${o?M:U}`}/api`,S=()=>{const e=Z()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(o=>e.endsWith(o)))};async function ee({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:a,body:d}){const r=`${o||Q({isDev:!1,isStage:!1})}${e}`,s={method:t,headers:{"Content-Type":"application/json",...n}};d&&(s.body=JSON.stringify(d));const c=a?new URLSearchParams(a).toString():"",i=c?`?${c}`:"",g=await fetch(`${r}${i}`,s);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const O={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function te(e){const o=e;return o.init=t=>n=>e(n,t),o}const oe=e=>te(e);async function ne({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:a}){let d="",u=!1;const r=S(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),a()},c=(i={})=>{var y;const{error:g,sdkLicense:f}=i,l=(y=i.plan)==null?void 0:y.category;if(!(f||i.license)||g)s(g||"Invalid license");else if(l){const b=O[o],v=O[l];b>v&&s({pluginRequiredPlan:o,licensePlan:l})}};e.on(J,i=>{d=i==null?void 0:i.baseApiUrl,u=!0}),e.on(X,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await se({licenseKey:n,pluginName:t,baseApiUrl:d});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function se(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await ee({baseApiUrl:n,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const ie=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},ce="iconifyComponent",re=function(e,o={}){var l;const{Components:t,Blocks:n}=e,{collections:a,extendIconComponent:d=!0,licenseKey:u,block:r={}}=o,s="icon",c="iconify",i="Iconify",g="data-type-iconify",f={events:()=>({dblclick:"onActive"}),onActive(){W({collectionIds:a,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:w,content:{type:c},category:"Extra",activate:!0,...r},isComponent:p=>ie(p,g),model:{defaults:{name:i,icon:w,droppable:!1,attributes:{[g]:!0},resizable:j,components:w,style:{width:"50px",height:"50px"},traits:[P()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:f}),d){const p=(l=t.getType(s))==null?void 0:l.model,[y,b,...v]=p.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[y,b,P(),...v]}},view:f})}ne({editor:e,licenseKey:u,plan:L.startup,pluginName:ce,cleanup:()=>{n.remove(c),t.removeType(c)}})},le=oe(re);module.exports=le;
@@ -1,8 +1,8 @@
1
1
  import "grapesjs";
2
- var L = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(L || {}), O = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(O || {}), f = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.projectFiles = "studio:projectFiles", 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.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))(f || {});
3
- const H = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, w = `<svg viewBox="0 0 24 24">
2
+ var L = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(L || {}), m = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(m || {}), f = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.projectFiles = "studio:projectFiles", 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.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))(f || {});
3
+ const j = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, w = `<svg viewBox="0 0 24 24">
4
4
  <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" />
5
- </svg>`, x = "layout-icon-picker", U = "icons-layout-", R = "icons-list-layout", _ = "gs-iconify-picker", A = "__iconify_collection", B = "https://api.iconify.design", I = /* @__PURE__ */ new Map();
5
+ </svg>`, x = "layout-icon-picker", H = "icons-layout-", R = "icons-list-layout", _ = "gs-iconify-picker", A = "__iconify_collection", B = "https://api.iconify.design", I = /* @__PURE__ */ new Map();
6
6
  let T;
7
7
  const D = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
8
8
  async function $({ collectionId: e, editor: o }) {
@@ -80,7 +80,7 @@ function K(e) {
80
80
  }
81
81
  function E(e) {
82
82
  const { editor: o } = e, t = {
83
- id: U,
83
+ id: H,
84
84
  layout: Y(e),
85
85
  header: !1,
86
86
  style: { height: "100%" },
@@ -121,7 +121,7 @@ function V(e) {
121
121
  const c = K(s);
122
122
  if (!c) return;
123
123
  const i = Object.fromEntries(
124
- Object.entries(c.icons).filter(([g]) => g.includes(r))
124
+ Object.entries(c.icons).filter(([p]) => p.includes(r))
125
125
  );
126
126
  u({ value: r }), E({
127
127
  editor: s,
@@ -152,10 +152,10 @@ function Y({
152
152
  {
153
153
  type: "custom",
154
154
  render: (c) => {
155
- const { editor: i, addEl: g, removeEl: h } = c, l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
155
+ const { editor: i, addEl: p, removeEl: h } = c, l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
156
156
  l.setAttribute("xmlns", "http://www.w3.org/2000/svg"), l.innerHTML = s.body, l.setAttribute("viewBox", `0 0 ${a} ${n}`);
157
- const { cssWidth: p, cssHeight: y } = z(a, n);
158
- l.style.cssText = `width: ${p}px; height: ${y}px; cursor: pointer;`, l.addEventListener("mouseover", () => {
157
+ const { cssWidth: g, cssHeight: y } = z(a, n);
158
+ l.style.cssText = `width: ${g}px; height: ${y}px; cursor: pointer;`, l.addEventListener("mouseover", () => {
159
159
  l.style.border = "2px solid currentColor", l.style.borderRadius = "4px", l.style.padding = "4px";
160
160
  }), l.addEventListener("mouseout", () => {
161
161
  l.style.border = "none";
@@ -163,10 +163,10 @@ function Y({
163
163
  const b = () => {
164
164
  const v = l.cloneNode(!0);
165
165
  v.removeAttribute("style");
166
- const j = v.outerHTML;
167
- t({ icon: j, collectionId: u, iconId: s.name }), i == null || i.runCommand(f.layoutRemove, { id: x });
166
+ const N = v.outerHTML;
167
+ t({ icon: N, collectionId: u, iconId: s.name }), i == null || i.runCommand(f.layoutRemove, { id: x });
168
168
  };
169
- return l.addEventListener("click", b), g(l), () => {
169
+ return l.addEventListener("click", b), p(l), () => {
170
170
  l.removeEventListener("click", b), h(l);
171
171
  };
172
172
  }
@@ -185,7 +185,7 @@ function C() {
185
185
  id: "toast-error-getCollections",
186
186
  header: "Error",
187
187
  content: "Error fetching collections",
188
- variant: O.Error
188
+ variant: m.Error
189
189
  };
190
190
  }
191
191
  function q() {
@@ -195,9 +195,9 @@ function q() {
195
195
  content: "Error fetching collection"
196
196
  };
197
197
  }
198
- const M = "app.grapesjs.com", N = "app-stage.grapesjs.com", k = [
198
+ const U = "app.grapesjs.com", M = "app-stage.grapesjs.com", k = [
199
+ U,
199
200
  M,
200
- N,
201
201
  "localhost",
202
202
  "127.0.0.1",
203
203
  ".local-credentialless.webcontainer.io",
@@ -206,7 +206,7 @@ const M = "app.grapesjs.com", N = "app-stage.grapesjs.com", k = [
206
206
  // For stackblitz.com demos
207
207
  "-sandpack.codesandbox.io"
208
208
  // For Sandpack demos
209
- ], J = "license:check:start", X = "license:check:end", Z = () => typeof window < "u", Q = ({ isDev: e, isStage: o }) => `${e ? "" : `https://${o ? N : M}`}/api`, S = () => {
209
+ ], J = "license:check:start", X = "license:check:end", Z = () => typeof window < "u", Q = ({ isDev: e, isStage: o }) => `${e ? "" : `https://${o ? M : U}`}/api`, S = () => {
210
210
  const e = Z() && window.location.hostname;
211
211
  return !!e && (k.includes(e) || k.some((o) => e.endsWith(o)));
212
212
  };
@@ -226,12 +226,12 @@ async function ee({
226
226
  }
227
227
  };
228
228
  d && (s.body = JSON.stringify(d));
229
- const c = a ? new URLSearchParams(a).toString() : "", i = c ? `?${c}` : "", g = await fetch(`${r}${i}`, s);
230
- if (!g.ok)
231
- throw new Error(`HTTP error! status: ${g.status}`);
232
- return g.json();
229
+ const c = a ? new URLSearchParams(a).toString() : "", i = c ? `?${c}` : "", p = await fetch(`${r}${i}`, s);
230
+ if (!p.ok)
231
+ throw new Error(`HTTP error! status: ${p.status}`);
232
+ return p.json();
233
233
  }
234
- const m = {
234
+ const O = {
235
235
  [L.free]: 0,
236
236
  [L.startup]: 10,
237
237
  [L.business]: 20,
@@ -254,11 +254,11 @@ async function ne({
254
254
  console.warn("Cleanup plugin:", t, "Reason:", i), a();
255
255
  }, c = (i = {}) => {
256
256
  var y;
257
- const { error: g, sdkLicense: h } = i, l = (y = i.plan) == null ? void 0 : y.category;
258
- if (!(h || i.license) || g)
259
- s(g || "Invalid license");
257
+ const { error: p, sdkLicense: h } = i, l = (y = i.plan) == null ? void 0 : y.category;
258
+ if (!(h || i.license) || p)
259
+ s(p || "Invalid license");
260
260
  else if (l) {
261
- const b = m[o], v = m[l];
261
+ const b = O[o], v = O[l];
262
262
  b > v && s({ pluginRequiredPlan: o, licensePlan: l });
263
263
  }
264
264
  };
@@ -298,7 +298,7 @@ const ie = (e, o) => {
298
298
  return !!((t = e == null ? void 0 : e.hasAttribute) != null && t.call(e, o));
299
299
  }, ce = "iconifyComponent", re = function(e, o = {}) {
300
300
  var l;
301
- const { Components: t, Blocks: n } = e, { collections: a, extendIconComponent: d = !0, licenseKey: u, block: r = {} } = o, s = "icon", c = "iconify", i = "Iconify", g = "data-type-iconify", h = {
301
+ const { Components: t, Blocks: n } = e, { collections: a, extendIconComponent: d = !0, licenseKey: u, block: r = {} } = o, s = "icon", c = "iconify", i = "Iconify", p = "data-type-iconify", h = {
302
302
  events: () => ({
303
303
  dblclick: "onActive"
304
304
  }),
@@ -315,14 +315,14 @@ const ie = (e, o) => {
315
315
  activate: !0,
316
316
  ...r
317
317
  },
318
- isComponent: (p) => ie(p, g),
318
+ isComponent: (g) => ie(g, p),
319
319
  model: {
320
320
  defaults: {
321
321
  name: i,
322
322
  icon: w,
323
323
  droppable: !1,
324
- attributes: { [g]: !0 },
325
- resizable: H,
324
+ attributes: { [p]: !0 },
325
+ resizable: j,
326
326
  components: w,
327
327
  style: { width: "50px", height: "50px" },
328
328
  traits: [P()]
@@ -331,12 +331,12 @@ const ie = (e, o) => {
331
331
  this.listenTo(this.components(), "change add", this.disableLayers), this.disableLayers();
332
332
  },
333
333
  disableLayers() {
334
- this.components().forEach((p) => p.set({ layerable: !1, locked: !0 }));
334
+ this.components().forEach((g) => g.set({ layerable: !1, locked: !0 }));
335
335
  }
336
336
  },
337
337
  view: h
338
338
  }), d) {
339
- const p = (l = t.getType(s)) == null ? void 0 : l.model, [y, b, ...v] = p.getDefaults().traits;
339
+ const g = (l = t.getType(s)) == null ? void 0 : l.model, [y, b, ...v] = g.getDefaults().traits;
340
340
  t.addType(s, {
341
341
  model: {
342
342
  defaults: {
@@ -1,3 +1,3 @@
1
- (function(g,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],y):(g=typeof globalThis<"u"?globalThis:g||self,g.StudioSdkPlugins_iconifyComponent=y())})(this,function(){"use strict";var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{}),y=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(y||{}),h=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(h||{});const N={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},I=`<svg viewBox="0 0 24 24">
1
+ (function(g,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],y):(g=typeof globalThis<"u"?globalThis:g||self,g.StudioSdkPlugins_iconifyComponent=y())})(this,function(){"use strict";var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{}),y=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(y||{}),h=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",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.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))(h||{});const M={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},I=`<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>`,k="layout-icon-picker",H="icons-layout-",m="icons-list-layout",x="gs-iconify-picker",E="__iconify_collection",U="https://api.iconify.design",A=new Map;let w;const B=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function O({collectionId:e,editor:o}){try{if(A.has(e))return A.get(e);const t=await fetch(B({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return A.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(h.toastAdd,q());return}}async function D({collectionIds:e,editor:o}){try{if(w)return w;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${U}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return w=await n.json(),w}catch(t){console.error("Error fetching collections",t),o.runCommand(h.toastAdd,_());return}}function R(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function G({collectionIds:e,editor:o,component:t}){const n=await D({collectionIds:e,editor:o});if(!n)return;const a=({icon:s,collectionId:c,iconId:i})=>{t.components(s),t.set({collectionId:c,iconId:i})},d=Object.entries(n).map(([s,c])=>({id:s,...c})).sort((s,c)=>s.name.localeCompare(c.name)),u=t.get("collectionId")??d[0].id;o.runCommand(h.layoutToggle,{id:k,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[K({collectionsList:d,collectionId:u,editor:o,handleClick:a}),{id:m,type:"column",grow:!0}]}});const r=await O({collectionId:u,editor:o});r&&P({editor:o,collection:r,handleClick:a,collectionId:u})}function W({editor:e,collection:o}){e.em.set(E,o)}function F(e){return e.em.get(E)}function P(e){const{editor:o}=e,t={id:H,layout:V(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:m}};o.runCommand(h.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(h.layoutAdd,t),10)}function K(e){const{collectionsList:o,collectionId:t,editor:n,handleClick:a}=e,d=o.map(({id:u,name:r,total:s})=>({id:u,label:`${r} (${s})`})).sort((u,r)=>u.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${x}__header`,children:[{type:"selectField",value:t,options:d,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await O({collectionId:r,editor:n});s&&(u({value:r}),W({editor:n,collection:s}),P({editor:n,collection:s,handleClick:a,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${E}`]:({setState:u})=>u({value:""})},onInput:({setState:u,value:r,editor:s})=>{const c=F(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(r)));u({value:r}),P({editor:s,collection:c,handleClick:a,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function V({collection:e,collectionFiltered:o,handleClick:t}){const{height:n=24,width:a=24,icons:d,prefix:u}=o||e,r=Object.entries(d).map(([s,{body:c}])=>({name:s,body:c}),{});return{type:"column",className:`${x}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:p,removeEl:b}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=s.body,l.setAttribute("viewBox",`0 0 ${a} ${n}`);const{cssWidth:f,cssHeight:v}=Y(a,n);l.style.cssText=`width: ${f}px; height: ${v}px; cursor: pointer;`,l.addEventListener("mouseover",()=>{l.style.border="2px solid currentColor",l.style.borderRadius="4px",l.style.padding="4px"}),l.addEventListener("mouseout",()=>{l.style.border="none"});const T=()=>{const L=l.cloneNode(!0);L.removeAttribute("style");const ce=L.outerHTML;t({icon:ce,collectionId:u,iconId:s.name}),i==null||i.runCommand(h.layoutRemove,{id:k})};return l.addEventListener("click",T),p(l),()=>{l.removeEventListener("click",T),b(l)}}}]}}}function Y(e,o){const t=e/o;let n=48,a=48;return t>1?a=48/t:t<1&&(n=48*t),{cssWidth:n,cssHeight:a}}function _(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:y.Error}}function q(){return{..._(),id:"toast-error-getCollection",content:"Error fetching collection"}}const $="app.grapesjs.com",C="app-stage.grapesjs.com",j=[$,C,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],z="license:check:start",J="license:check:end",X=()=>typeof window<"u",Z=({isDev:e,isStage:o})=>`${e?"":`https://${o?C:$}`}/api`,Q=()=>{const e=X()&&window.location.hostname;return!!e&&(j.includes(e)||j.some(o=>e.endsWith(o)))};async function S({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:a,body:d}){const r=`${o||Z({isDev:!1,isStage:!1})}${e}`,s={method:t,headers:{"Content-Type":"application/json",...n}};d&&(s.body=JSON.stringify(d));const c=a?new URLSearchParams(a).toString():"",i=c?`?${c}`:"",p=await fetch(`${r}${i}`,s);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}const M={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function ee(e){const o=e;return o.init=t=>n=>e(n,t),o}const te=e=>ee(e);async function oe({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:a}){let d="",u=!1;const r=Q(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),a()},c=(i={})=>{var v;const{error:p,sdkLicense:b}=i,l=(v=i.plan)==null?void 0:v.category;if(!(b||i.license)||p)s(p||"Invalid license");else if(l){const T=M[o],L=M[l];T>L&&s({pluginRequiredPlan:o,licensePlan:l})}};e.on(z,i=>{d=i==null?void 0:i.baseApiUrl,u=!0}),e.on(J,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await ne({licenseKey:n,pluginName:t,baseApiUrl:d});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function ne(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await S({baseApiUrl:n,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const se=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},ie="iconifyComponent";return te(function(e,o={}){var l;const{Components:t,Blocks:n}=e,{collections:a,extendIconComponent:d=!0,licenseKey:u,block:r={}}=o,s="icon",c="iconify",i="Iconify",p="data-type-iconify",b={events:()=>({dblclick:"onActive"}),onActive(){G({collectionIds:a,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:I,content:{type:c},category:"Extra",activate:!0,...r},isComponent:f=>se(f,p),model:{defaults:{name:i,icon:I,droppable:!1,attributes:{[p]:!0},resizable:N,components:I,style:{width:"50px",height:"50px"},traits:[R()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:b}),d){const f=(l=t.getType(s))==null?void 0:l.model,[v,T,...L]=f.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[v,T,R(),...L]}},view:b})}oe({editor:e,licenseKey:u,plan:g.startup,pluginName:ie,cleanup:()=>{n.remove(c),t.removeType(c)}})})});
3
+ </svg>`,k="layout-icon-picker",N="icons-layout-",m="icons-list-layout",x="gs-iconify-picker",E="__iconify_collection",H="https://api.iconify.design",A=new Map;let w;const B=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function O({collectionId:e,editor:o}){try{if(A.has(e))return A.get(e);const t=await fetch(B({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return A.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(h.toastAdd,q());return}}async function D({collectionIds:e,editor:o}){try{if(w)return w;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${H}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return w=await n.json(),w}catch(t){console.error("Error fetching collections",t),o.runCommand(h.toastAdd,_());return}}function R(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function G({collectionIds:e,editor:o,component:t}){const n=await D({collectionIds:e,editor:o});if(!n)return;const a=({icon:s,collectionId:c,iconId:i})=>{t.components(s),t.set({collectionId:c,iconId:i})},d=Object.entries(n).map(([s,c])=>({id:s,...c})).sort((s,c)=>s.name.localeCompare(c.name)),u=t.get("collectionId")??d[0].id;o.runCommand(h.layoutToggle,{id:k,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[K({collectionsList:d,collectionId:u,editor:o,handleClick:a}),{id:m,type:"column",grow:!0}]}});const r=await O({collectionId:u,editor:o});r&&P({editor:o,collection:r,handleClick:a,collectionId:u})}function W({editor:e,collection:o}){e.em.set(E,o)}function F(e){return e.em.get(E)}function P(e){const{editor:o}=e,t={id:N,layout:V(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:m}};o.runCommand(h.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(h.layoutAdd,t),10)}function K(e){const{collectionsList:o,collectionId:t,editor:n,handleClick:a}=e,d=o.map(({id:u,name:r,total:s})=>({id:u,label:`${r} (${s})`})).sort((u,r)=>u.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${x}__header`,children:[{type:"selectField",value:t,options:d,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await O({collectionId:r,editor:n});s&&(u({value:r}),W({editor:n,collection:s}),P({editor:n,collection:s,handleClick:a,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${E}`]:({setState:u})=>u({value:""})},onInput:({setState:u,value:r,editor:s})=>{const c=F(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(r)));u({value:r}),P({editor:s,collection:c,handleClick:a,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function V({collection:e,collectionFiltered:o,handleClick:t}){const{height:n=24,width:a=24,icons:d,prefix:u}=o||e,r=Object.entries(d).map(([s,{body:c}])=>({name:s,body:c}),{});return{type:"column",className:`${x}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:p,removeEl:b}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=s.body,l.setAttribute("viewBox",`0 0 ${a} ${n}`);const{cssWidth:f,cssHeight:v}=Y(a,n);l.style.cssText=`width: ${f}px; height: ${v}px; cursor: pointer;`,l.addEventListener("mouseover",()=>{l.style.border="2px solid currentColor",l.style.borderRadius="4px",l.style.padding="4px"}),l.addEventListener("mouseout",()=>{l.style.border="none"});const T=()=>{const L=l.cloneNode(!0);L.removeAttribute("style");const ce=L.outerHTML;t({icon:ce,collectionId:u,iconId:s.name}),i==null||i.runCommand(h.layoutRemove,{id:k})};return l.addEventListener("click",T),p(l),()=>{l.removeEventListener("click",T),b(l)}}}]}}}function Y(e,o){const t=e/o;let n=48,a=48;return t>1?a=48/t:t<1&&(n=48*t),{cssWidth:n,cssHeight:a}}function _(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:y.Error}}function q(){return{..._(),id:"toast-error-getCollection",content:"Error fetching collection"}}const $="app.grapesjs.com",C="app-stage.grapesjs.com",j=[$,C,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],z="license:check:start",J="license:check:end",X=()=>typeof window<"u",Z=({isDev:e,isStage:o})=>`${e?"":`https://${o?C:$}`}/api`,Q=()=>{const e=X()&&window.location.hostname;return!!e&&(j.includes(e)||j.some(o=>e.endsWith(o)))};async function S({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:a,body:d}){const r=`${o||Z({isDev:!1,isStage:!1})}${e}`,s={method:t,headers:{"Content-Type":"application/json",...n}};d&&(s.body=JSON.stringify(d));const c=a?new URLSearchParams(a).toString():"",i=c?`?${c}`:"",p=await fetch(`${r}${i}`,s);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}const U={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function ee(e){const o=e;return o.init=t=>n=>e(n,t),o}const te=e=>ee(e);async function oe({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:a}){let d="",u=!1;const r=Q(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),a()},c=(i={})=>{var v;const{error:p,sdkLicense:b}=i,l=(v=i.plan)==null?void 0:v.category;if(!(b||i.license)||p)s(p||"Invalid license");else if(l){const T=U[o],L=U[l];T>L&&s({pluginRequiredPlan:o,licensePlan:l})}};e.on(z,i=>{d=i==null?void 0:i.baseApiUrl,u=!0}),e.on(J,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await ne({licenseKey:n,pluginName:t,baseApiUrl:d});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function ne(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await S({baseApiUrl:n,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const se=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},ie="iconifyComponent";return te(function(e,o={}){var l;const{Components:t,Blocks:n}=e,{collections:a,extendIconComponent:d=!0,licenseKey:u,block:r={}}=o,s="icon",c="iconify",i="Iconify",p="data-type-iconify",b={events:()=>({dblclick:"onActive"}),onActive(){G({collectionIds:a,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:I,content:{type:c},category:"Extra",activate:!0,...r},isComponent:f=>se(f,p),model:{defaults:{name:i,icon:I,droppable:!1,attributes:{[p]:!0},resizable:M,components:I,style:{width:"50px",height:"50px"},traits:[R()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:b}),d){const f=(l=t.getType(s))==null?void 0:l.model,[v,T,...L]=f.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[v,T,R(),...L]}},view:b})}oe({editor:e,licenseKey:u,plan:g.startup,pluginName:ie,cleanup:()=>{n.remove(c),t.removeType(c)}})})});