@grapesjs/studio-sdk-plugins 1.0.15 → 1.0.16

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 (66) hide show
  1. package/dist/accordionComponent/index.cjs.js +3 -3
  2. package/dist/accordionComponent/index.es.js +29 -30
  3. package/dist/accordionComponent/index.umd.js +4 -4
  4. package/dist/canvasEmptyState/index.cjs.js +1 -1
  5. package/dist/canvasEmptyState/index.es.js +14 -15
  6. package/dist/canvasEmptyState/index.umd.js +1 -1
  7. package/dist/canvasFullSize/index.cjs.d.ts +2 -2
  8. package/dist/canvasFullSize/index.cjs.js +1 -1
  9. package/dist/canvasFullSize/index.d.ts +2 -2
  10. package/dist/canvasFullSize/index.es.d.ts +2 -2
  11. package/dist/canvasFullSize/index.es.js +2 -3
  12. package/dist/canvasFullSize/index.umd.js +2 -2
  13. package/dist/canvasFullSize/types.d.ts +1 -1
  14. package/dist/dialogComponent/index.cjs.js +2 -2
  15. package/dist/dialogComponent/index.es.js +2 -3
  16. package/dist/dialogComponent/index.umd.js +2 -2
  17. package/dist/flexComponent/index.cjs.js +1 -1
  18. package/dist/flexComponent/index.es.js +2 -3
  19. package/dist/flexComponent/index.umd.js +1 -1
  20. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  21. package/dist/fsLightboxComponent/index.es.js +2 -3
  22. package/dist/fsLightboxComponent/index.umd.js +2 -2
  23. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  24. package/dist/googleFontsAssetProvider/index.es.js +39 -40
  25. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  26. package/dist/iconifyComponent/index.cjs.js +2 -2
  27. package/dist/iconifyComponent/index.es.js +31 -32
  28. package/dist/iconifyComponent/index.umd.js +2 -2
  29. package/dist/index.cjs.d.ts +1 -0
  30. package/dist/index.cjs.js +42 -42
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.es.d.ts +1 -0
  33. package/dist/index.es.js +3171 -2944
  34. package/dist/index.umd.js +36 -36
  35. package/dist/layoutSidebarButtons/index.cjs.d.ts +3 -0
  36. package/dist/layoutSidebarButtons/index.cjs.js +1 -0
  37. package/dist/layoutSidebarButtons/index.d.ts +3 -0
  38. package/dist/layoutSidebarButtons/index.es.d.ts +3 -0
  39. package/dist/layoutSidebarButtons/index.es.js +328 -0
  40. package/dist/layoutSidebarButtons/index.umd.js +1 -0
  41. package/dist/layoutSidebarButtons/layout.d.ts +8 -0
  42. package/dist/layoutSidebarButtons/types.d.ts +75 -0
  43. package/dist/layoutSidebarButtons/typesSchema.d.ts +49 -0
  44. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  45. package/dist/lightGalleryComponent/index.es.js +2 -3
  46. package/dist/lightGalleryComponent/index.umd.js +1 -1
  47. package/dist/listPagesComponent/index.cjs.js +3 -3
  48. package/dist/listPagesComponent/index.es.js +2 -3
  49. package/dist/listPagesComponent/index.umd.js +3 -3
  50. package/dist/prosemirror/index.cjs.js +2 -2
  51. package/dist/prosemirror/index.es.js +3 -4
  52. package/dist/prosemirror/index.umd.js +2 -2
  53. package/dist/rteTinyMce/index.cjs.js +1 -1
  54. package/dist/rteTinyMce/index.es.js +20 -21
  55. package/dist/rteTinyMce/index.umd.js +1 -1
  56. package/dist/swiperComponent/index.cjs.js +3 -3
  57. package/dist/swiperComponent/index.es.js +2 -3
  58. package/dist/swiperComponent/index.umd.js +3 -3
  59. package/dist/tableComponent/index.cjs.js +1 -1
  60. package/dist/tableComponent/index.es.js +13 -14
  61. package/dist/tableComponent/index.umd.js +1 -1
  62. package/dist/types.d.ts +4 -3
  63. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  64. package/dist/youtubeAssetProvider/index.es.js +7 -8
  65. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  66. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";require("grapesjs");const de="app.grapesjs.com",ue="app-stage.grapesjs.com",ie=[de,ue,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?ue:de}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(ie.includes(n)||ie.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const g=i?new URLSearchParams(i).toString():"",p=g?`?${g}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),he=(n=>(n.web="web",n.email="email",n))(he||{});const ae={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},g=(p={})=>{var S;const{error:u,sdkLicense:f}=p,v=(S=p.plan)==null?void 0:S.category;if(!(f||p.license)||u)c(u||"Invalid license");else if(v){const I=ae[e],R=ae[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{g(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&g(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const ge=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ne))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),fe="gjs-plg-",ne="data-type-role",j=class j{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):se(e.componentColumn,j.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[j.CSS_FLEX_BASIS]:i},{partial:a})}}};j.CSS_FLEX_BASIS="flex-basis";let K=j;const N=class N{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):se(e.componentRow,N.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[N.CSS_GAP]:i},{partial:a})}}};N.CSS_GAP="gap";let J=N;const Y=class Y{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=se(e.componentRow,Y.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Y.CSS_FLEX_DIRECTION="flex-direction";let q=Y;const _=class _{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(_.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(_.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};_.MJML_COLUMN_TYPE="mj-column";let Z=_;const U=class U{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(U.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};U.MJML_SECTION_TYPE="mj-section";let Q=U;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class H{constructor(){this.handlerCache=new Map}static getInstance(){return H.instance||(H.instance=new H),H.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(A(e)?this.handlerCache.set(t,{sizeHandler:new Z(e),gapHandler:new Q(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new K(e),gapHandler:new J(e),parentSizeHandler:new q(e)})),this.handlerCache.get(t)}}function G(n){return H.getInstance().getHandlers(n)}const oe=n=>{n.style.display="none"},re=n=>{n.style.display="block"},V=n=>+parseFloat(`${n}`).toFixed(2),A=n=>n.projectType===he.email,k=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],He=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ae=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},O=n=>n==="top"||n==="bottom",je=(n,e)=>!!(He(n)&&(e==="left"||e==="top")||Ae(n)&&(e==="right"||e==="bottom")),Ne=n=>{const e=n.parent();return e?e.components().models.length>1:!1},ce=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,se=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},le=(n,e,t)=>{const s=ee({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},F=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),B=(n,e)=>G(e).sizeHandler.getSize(n),ee=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},te=(n,e)=>G(e).parentSizeHandler.getParentSize(n),M=(n,e)=>{G(e).sizeHandler.setSize(n)},me=(n,e)=>{const t=B(n,e);M({...n,sizeValue:`${t}%`,partial:!1},e)},ye=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:F(n,e)};s.map(a=>me({...i,componentColumn:a},e)),ye({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||A(e))return;const o=u=>({type:i,components:u.map(f=>({type:s,style:{"flex-basis":`${f}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
1
+ "use strict";const de="app.grapesjs.com",ue="app-stage.grapesjs.com",ie=[de,ue,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?ue:de}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(ie.includes(n)||ie.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const g=i?new URLSearchParams(i).toString():"",p=g?`?${g}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),he=(n=>(n.web="web",n.email="email",n))(he||{});const ae={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},g=(p={})=>{var S;const{error:u,sdkLicense:f}=p,v=(S=p.plan)==null?void 0:S.category;if(!(f||p.license)||u)c(u||"Invalid license");else if(v){const I=ae[e],R=ae[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{g(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&g(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const ge=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ne))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),fe="gjs-plg-",ne="data-type-role",j=class j{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):se(e.componentColumn,j.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[j.CSS_FLEX_BASIS]:i},{partial:a})}}};j.CSS_FLEX_BASIS="flex-basis";let K=j;const N=class N{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):se(e.componentRow,N.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[N.CSS_GAP]:i},{partial:a})}}};N.CSS_GAP="gap";let J=N;const Y=class Y{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=se(e.componentRow,Y.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Y.CSS_FLEX_DIRECTION="flex-direction";let q=Y;const _=class _{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(_.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(_.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};_.MJML_COLUMN_TYPE="mj-column";let Z=_;const U=class U{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(U.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};U.MJML_SECTION_TYPE="mj-section";let Q=U;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class H{constructor(){this.handlerCache=new Map}static getInstance(){return H.instance||(H.instance=new H),H.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(A(e)?this.handlerCache.set(t,{sizeHandler:new Z(e),gapHandler:new Q(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new K(e),gapHandler:new J(e),parentSizeHandler:new q(e)})),this.handlerCache.get(t)}}function G(n){return H.getInstance().getHandlers(n)}const oe=n=>{n.style.display="none"},re=n=>{n.style.display="block"},V=n=>+parseFloat(`${n}`).toFixed(2),A=n=>n.projectType===he.email,k=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],He=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ae=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},O=n=>n==="top"||n==="bottom",je=(n,e)=>!!(He(n)&&(e==="left"||e==="top")||Ae(n)&&(e==="right"||e==="bottom")),Ne=n=>{const e=n.parent();return e?e.components().models.length>1:!1},ce=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,se=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},le=(n,e,t)=>{const s=ee({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},F=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),B=(n,e)=>G(e).sizeHandler.getSize(n),ee=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},te=(n,e)=>G(e).parentSizeHandler.getParentSize(n),M=(n,e)=>{G(e).sizeHandler.setSize(n)},me=(n,e)=>{const t=B(n,e);M({...n,sizeValue:`${t}%`,partial:!1},e)},ye=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:F(n,e)};s.map(a=>me({...i,componentColumn:a},e)),ye({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||A(e))return;const o=u=>({type:i,components:u.map(f=>({type:s,style:{"flex-basis":`${f}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
2
2
  ${u.map(f=>`<div style="flex-basis: ${f}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
3
3
  </div>`,c=(u,f)=>({id:`flex-row-${f.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(f),content:o(f)}),g=[c("1 Column",[100]),c("2 Columns 50/50",[50,50]),c("2 Columns 25/75",[25,75]),c("2 Columns 75/25",[75,25]),c("3 Columns",[33.33,33.33,33.33]),c("3 Columns 50/25/25",[50,25,25]),c("3 Columns 25/50/25",[25,50,25]),c("3 Columns 25/25/50",[25,25,50]),c("4 Columns",[25,25,25,25]),c("5 Columns",[20,20,20,20,20])],p=xe(a)?a({blocks:g}):g;return p.forEach(u=>t.add(u.id,u)),()=>{p.forEach(u=>t.remove(u.id))}}const Be=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=e,o=`${fe}${i}`,c=!!i&&!!t.getType(i)&&!a;if(!(!i||c||A(e)))return t.addType(i,{isComponent:ge(i),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Te(s),attributes:{[ne]:i},styles:`
4
4
  .${o} {
@@ -1,4 +1,3 @@
1
- import "grapesjs";
2
1
  const de = "app.grapesjs.com", ue = "app-stage.grapesjs.com", ie = [
3
2
  de,
4
3
  ue,
@@ -709,7 +708,7 @@ const Ke = "flexComponent", Je = function(n, e = {}) {
709
708
  s.forEach((o) => o == null ? void 0 : o()), i(), a == null || a();
710
709
  }
711
710
  });
712
- }, Ze = Ie(Je);
711
+ }, qe = Ie(Je);
713
712
  export {
714
- Ze as default
713
+ qe as default
715
714
  };
@@ -1,4 +1,4 @@
1
- (function(T,L){typeof exports=="object"&&typeof module<"u"?module.exports=L(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],L):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_flexComponent=L())})(this,function(){"use strict";const T="app.grapesjs.com",L="app-stage.grapesjs.com",oe=[T,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?L:T}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(oe.includes(n)||oe.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const f=i?new URLSearchParams(i).toString():"",p=f?`?${f}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),re=(n=>(n.web="web",n.email="email",n))(re||{});const ce={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},f=(p={})=>{var S;const{error:u,sdkLicense:g}=p,v=(S=p.plan)==null?void 0:S.category;if(!(g||p.license)||u)c(u||"Invalid license");else if(v){const I=ce[e],R=ce[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{f(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&f(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const le=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,J))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),pe="gjs-plg-",J="data-type-role",B=class B{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):ne(e.componentColumn,B.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[B.CSS_FLEX_BASIS]:i},{partial:a})}}};B.CSS_FLEX_BASIS="flex-basis";let q=B;const D=class D{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):ne(e.componentRow,D.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[D.CSS_GAP]:i},{partial:a})}}};D.CSS_GAP="gap";let Z=D;const U=class U{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=ne(e.componentRow,U.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};U.CSS_FLEX_DIRECTION="flex-direction";let Q=U;const k=class k{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(k.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(k.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};k.MJML_COLUMN_TYPE="mj-column";let ee=k;const W=class W{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(W.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};W.MJML_SECTION_TYPE="mj-section";let te=W;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class H{constructor(){this.handlerCache=new Map}static getInstance(){return H.instance||(H.instance=new H),H.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(A(e)?this.handlerCache.set(t,{sizeHandler:new ee(e),gapHandler:new te(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new q(e),gapHandler:new Z(e),parentSizeHandler:new Q(e)})),this.handlerCache.get(t)}}function G(n){return H.getInstance().getHandlers(n)}const de=n=>{n.style.display="none"},ue=n=>{n.style.display="block"},j=n=>+parseFloat(`${n}`).toFixed(2),A=n=>n.projectType===re.email,O=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],He=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ae=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},X=n=>n==="top"||n==="bottom",je=(n,e)=>!!(He(n)&&(e==="left"||e==="top")||Ae(n)&&(e==="right"||e==="bottom")),Ne=n=>{const e=n.parent();return e?e.components().models.length>1:!1},he=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,ne=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},fe=(n,e,t)=>{const s=se({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},N=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),_=(n,e)=>G(e).sizeHandler.getSize(n),se=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},ie=(n,e)=>G(e).parentSizeHandler.getParentSize(n),F=(n,e)=>{G(e).sizeHandler.setSize(n)},ge=(n,e)=>{const t=_(n,e);F({...n,sizeValue:`${t}%`,partial:!1},e)},me=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:N(n,e)};s.map(a=>ge({...i,componentColumn:a},e)),me({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||A(e))return;const o=u=>({type:i,components:u.map(g=>({type:s,style:{"flex-basis":`${g}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
1
+ (function(T,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_flexComponent=L())})(this,function(){"use strict";const T="app.grapesjs.com",L="app-stage.grapesjs.com",oe=[T,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?L:T}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(oe.includes(n)||oe.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const f=i?new URLSearchParams(i).toString():"",p=f?`?${f}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),re=(n=>(n.web="web",n.email="email",n))(re||{});const ce={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},f=(p={})=>{var S;const{error:u,sdkLicense:g}=p,v=(S=p.plan)==null?void 0:S.category;if(!(g||p.license)||u)c(u||"Invalid license");else if(v){const I=ce[e],R=ce[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{f(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&f(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const le=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,J))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),pe="gjs-plg-",J="data-type-role",B=class B{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):ne(e.componentColumn,B.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[B.CSS_FLEX_BASIS]:i},{partial:a})}}};B.CSS_FLEX_BASIS="flex-basis";let q=B;const D=class D{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):ne(e.componentRow,D.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[D.CSS_GAP]:i},{partial:a})}}};D.CSS_GAP="gap";let Z=D;const U=class U{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=ne(e.componentRow,U.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};U.CSS_FLEX_DIRECTION="flex-direction";let Q=U;const k=class k{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(k.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(k.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};k.MJML_COLUMN_TYPE="mj-column";let ee=k;const W=class W{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(W.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};W.MJML_SECTION_TYPE="mj-section";let te=W;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class H{constructor(){this.handlerCache=new Map}static getInstance(){return H.instance||(H.instance=new H),H.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(A(e)?this.handlerCache.set(t,{sizeHandler:new ee(e),gapHandler:new te(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new q(e),gapHandler:new Z(e),parentSizeHandler:new Q(e)})),this.handlerCache.get(t)}}function G(n){return H.getInstance().getHandlers(n)}const de=n=>{n.style.display="none"},ue=n=>{n.style.display="block"},j=n=>+parseFloat(`${n}`).toFixed(2),A=n=>n.projectType===re.email,O=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],He=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ae=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},X=n=>n==="top"||n==="bottom",je=(n,e)=>!!(He(n)&&(e==="left"||e==="top")||Ae(n)&&(e==="right"||e==="bottom")),Ne=n=>{const e=n.parent();return e?e.components().models.length>1:!1},he=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,ne=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},fe=(n,e,t)=>{const s=se({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},N=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),_=(n,e)=>G(e).sizeHandler.getSize(n),se=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},ie=(n,e)=>G(e).parentSizeHandler.getParentSize(n),F=(n,e)=>{G(e).sizeHandler.setSize(n)},ge=(n,e)=>{const t=_(n,e);F({...n,sizeValue:`${t}%`,partial:!1},e)},me=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:N(n,e)};s.map(a=>ge({...i,componentColumn:a},e)),me({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||A(e))return;const o=u=>({type:i,components:u.map(g=>({type:s,style:{"flex-basis":`${g}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
2
2
  ${u.map(g=>`<div style="flex-basis: ${g}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
3
3
  </div>`,c=(u,g)=>({id:`flex-row-${g.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(g),content:o(g)}),f=[c("1 Column",[100]),c("2 Columns 50/50",[50,50]),c("2 Columns 25/75",[25,75]),c("2 Columns 75/25",[75,25]),c("3 Columns",[33.33,33.33,33.33]),c("3 Columns 50/25/25",[50,25,25]),c("3 Columns 25/50/25",[25,50,25]),c("3 Columns 25/25/50",[25,25,50]),c("4 Columns",[25,25,25,25]),c("5 Columns",[20,20,20,20,20])],p=xe(a)?a({blocks:f}):f;return p.forEach(u=>t.add(u.id,u)),()=>{p.forEach(u=>t.remove(u.id))}}const Be=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=e,o=`${pe}${i}`,c=!!i&&!!t.getType(i)&&!a;if(!(!i||c||A(e)))return t.addType(i,{isComponent:le(i),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Te(s),attributes:{[J]:i},styles:`
4
4
  .${o} {
@@ -1,6 +1,6 @@
1
- "use strict";require("grapesjs");const P="app.grapesjs.com",B="app-stage.grapesjs.com",N=[P,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?B:P}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(N.includes(t)||N.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const w=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",n=m?`?${m}`:"",b=await fetch(`${w}${n}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var x=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(x||{});const O={[x.free]:0,[x.startup]:10,[x.business]:20,[x.enterprise]:30};function q(t){const a=t;return a.init=r=>c=>t(c,r),a}const G=t=>q(t);async function Z({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const w=F(),d=n=>{console.warn("Cleanup plugin:",r,"Reason:",n),p()},m=(n={})=>{var A;const{error:b,sdkLicense:l}=n,v=(A=n.plan)==null?void 0:A.category;if(!(l||n.license)||b)d(b||"Invalid license");else if(v){const E=O[a],$=O[v];E>$&&d({pluginRequiredPlan:a,licensePlan:v})}};t.on(D,n=>{h=n==null?void 0:n.baseApiUrl,g=!0}),t.on(U,n=>{m(n)}),setTimeout(async()=>{if(!g){if(w)return;if(c){const n=await z({licenseKey:c,pluginName:r,baseApiUrl:h});n&&m(n)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",C="data-type",Y="fslightbox-open",T="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Q=function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${T}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:w,toolbarIconOpen:d,defaultSrc:m}=g,n=function(s){const e=this,i="data-fslightbox",o=window,f=()=>{var H;const u=o.refreshFsLightbox;u==null||u();const j=e.getAttribute(i);if((H=o.fsLightboxInstances)==null||H[j],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(y=>{const L=y.onclick;y.onclick=function(I){I.preventDefault();const M=y;!M.__skipLb&&(L==null||L(I)),M.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=s.cdnScript,u.onload=f,document.head.appendChild(u)}},b=s=>({id:`${T}-open-lb`,label:d,command:()=>{const e=s.getView();e==null||e.toggleLightbox()}}),l="source-type",v={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},V={id:"href-image",name:"href",type:"file",label:"Source Image"},A={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},$={image:[V],video:[A],el:[E]};c.addType(T,{block:w&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:s=>{var e;return(e=s.hasAttribute)==null?void 0:e.call(s,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(s,e)=>!e.is(T),attributes:{[k]:"lightbox",[C]:"image",href:m},components:{type:"image",src:m},script:n,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[v,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(s,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
1
+ "use strict";const P="app.grapesjs.com",B="app-stage.grapesjs.com",N=[P,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?B:P}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(N.includes(t)||N.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const w=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",n=m?`?${m}`:"",b=await fetch(`${w}${n}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var x=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(x||{});const O={[x.free]:0,[x.startup]:10,[x.business]:20,[x.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const w=F(),d=n=>{console.warn("Cleanup plugin:",r,"Reason:",n),p()},m=(n={})=>{var A;const{error:b,sdkLicense:l}=n,v=(A=n.plan)==null?void 0:A.category;if(!(l||n.license)||b)d(b||"Invalid license");else if(v){const E=O[a],$=O[v];E>$&&d({pluginRequiredPlan:a,licensePlan:v})}};t.on(D,n=>{h=n==null?void 0:n.baseApiUrl,g=!0}),t.on(U,n=>{m(n)}),setTimeout(async()=>{if(!g){if(w)return;if(c){const n=await z({licenseKey:c,pluginName:r,baseApiUrl:h});n&&m(n)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",C="data-type",Y="fslightbox-open",T="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Q=function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${T}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:w,toolbarIconOpen:d,defaultSrc:m}=g,n=function(s){const e=this,i="data-fslightbox",o=window,f=()=>{var H;const u=o.refreshFsLightbox;u==null||u();const j=e.getAttribute(i);if((H=o.fsLightboxInstances)==null||H[j],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(y=>{const L=y.onclick;y.onclick=function(I){I.preventDefault();const M=y;!M.__skipLb&&(L==null||L(I)),M.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=s.cdnScript,u.onload=f,document.head.appendChild(u)}},b=s=>({id:`${T}-open-lb`,label:d,command:()=>{const e=s.getView();e==null||e.toggleLightbox()}}),l="source-type",v={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},V={id:"href-image",name:"href",type:"file",label:"Source Image"},A={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},$={image:[V],video:[A],el:[E]};c.addType(T,{block:w&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:s=>{var e;return(e=s.hasAttribute)==null?void 0:e.call(s,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(s,e)=>!e.is(T),attributes:{[k]:"lightbox",[C]:"image",href:m},components:{type:"image",src:m},script:n,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[v,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(s,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
2
  .${h} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const s=[l].map(e=>`change:${e}`).join(" ");this.on(s,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(s,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[C]:f,href:""})},adjustSourceType(){const s=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(s==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[C]:o},i)}else s!=="el"&&e.startsWith("#")?this.set(l,"el",i):s==="image"&&this.addAttributes({[C]:"image"},i)},updateTraits(s={}){const{changed:e}=this,{init:i}=s;if(e[v.name]||i){this.removeTrait([V.name,A.name,E.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait($[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:s}=this,e=b(this);!s.find(o=>o.id===e.id)&&(s==null||s.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var y;const{em:s,el:e,model:i}=this,{Canvas:o}=s,f=i.getAttributes()[k],{defaultView:u,documentElement:j}=e.ownerDocument,_=(y=u.fsLightboxInstances)==null?void 0:y[f];if(j.classList.contains(Y))_.close();else{e.__skipLb=!1;let L;_.props.onOpen=()=>{L=o.getSpots(),setTimeout(()=>o.removeSpots())},_.props.onClose=()=>{L.forEach(I=>o.addSpot(I.attributes))},e.click()}}}}),Z({editor:t,plan:x.startup,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(T),c.removeType(T)}})},ee=G(Q);module.exports=ee;
6
+ `},init(){const s=[l].map(e=>`change:${e}`).join(" ");this.on(s,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(s,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[C]:f,href:""})},adjustSourceType(){const s=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(s==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[C]:o},i)}else s!=="el"&&e.startsWith("#")?this.set(l,"el",i):s==="image"&&this.addAttributes({[C]:"image"},i)},updateTraits(s={}){const{changed:e}=this,{init:i}=s;if(e[v.name]||i){this.removeTrait([V.name,A.name,E.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait($[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:s}=this,e=b(this);!s.find(o=>o.id===e.id)&&(s==null||s.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var y;const{em:s,el:e,model:i}=this,{Canvas:o}=s,f=i.getAttributes()[k],{defaultView:u,documentElement:j}=e.ownerDocument,_=(y=u.fsLightboxInstances)==null?void 0:y[f];if(j.classList.contains(Y))_.close();else{e.__skipLb=!1;let L;_.props.onOpen=()=>{L=o.getSpots(),setTimeout(()=>o.removeSpots())},_.props.onClose=()=>{L.forEach(I=>o.addSpot(I.attributes))},e.click()}}}}),q({editor:t,plan:x.startup,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(T),c.removeType(T)}})},ee=Z(Q);module.exports=ee;
@@ -1,4 +1,3 @@
1
- import "grapesjs";
2
1
  const P = "app.grapesjs.com", B = "app-stage.grapesjs.com", N = [
3
2
  P,
4
3
  B,
@@ -284,7 +283,7 @@ const J = "gjs-plg-", X = "fsLightboxComponent", k = "data-fslightbox", C = "dat
284
283
  r.remove(T), c.removeType(T);
285
284
  }
286
285
  });
287
- }, te = Z(Q);
286
+ }, ee = Z(Q);
288
287
  export {
289
- te as default
288
+ ee as default
290
289
  };
@@ -1,6 +1,6 @@
1
- (function(v,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],y):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_fsLightboxComponent=y())})(this,function(){"use strict";const v="app.grapesjs.com",y="app-stage.grapesjs.com",O=[v,y,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?y:v}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(O.includes(t)||O.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const E=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",s=m?`?${m}`:"",b=await fetch(`${E}${s}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var T=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(T||{});const P={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function q(t){const a=t;return a.init=r=>c=>t(c,r),a}const G=t=>q(t);async function Z({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const E=F(),d=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),p()},m=(s={})=>{var _;const{error:b,sdkLicense:l}=s,x=(_=s.plan)==null?void 0:_.category;if(!(l||s.license)||b)d(b||"Invalid license");else if(x){const C=P[a],H=P[x];C>H&&d({pluginRequiredPlan:a,licensePlan:x})}};t.on(D,s=>{h=s==null?void 0:s.baseApiUrl,g=!0}),t.on(U,s=>{m(s)}),setTimeout(async()=>{if(!g){if(E)return;if(c){const s=await z({licenseKey:c,pluginName:r,baseApiUrl:h});s&&m(s)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",I="data-type",Y="fslightbox-open",L="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'};return G(function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${L}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:E,toolbarIconOpen:d,defaultSrc:m}=g,s=function(n){const e=this,i="data-fslightbox",o=window,f=()=>{var N;const u=o.refreshFsLightbox;u==null||u();const M=e.getAttribute(i);if((N=o.fsLightboxInstances)==null||N[M],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const A=w.onclick;w.onclick=function(V){V.preventDefault();const B=w;!B.__skipLb&&(A==null||A(V)),B.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=n.cdnScript,u.onload=f,document.head.appendChild(u)}},b=n=>({id:`${L}-open-lb`,label:d,command:()=>{const e=n.getView();e==null||e.toggleLightbox()}}),l="source-type",x={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},$={id:"href-image",name:"href",type:"file",label:"Source Image"},_={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},C={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},H={image:[$],video:[_],el:[C]};c.addType(L,{block:E&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:n=>{var e;return(e=n.hasAttribute)==null?void 0:e.call(n,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(n,e)=>!e.is(L),attributes:{[k]:"lightbox",[I]:"image",href:m},components:{type:"image",src:m},script:s,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[x,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(n,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
1
+ (function(v,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_fsLightboxComponent=y())})(this,function(){"use strict";const v="app.grapesjs.com",y="app-stage.grapesjs.com",O=[v,y,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?y:v}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(O.includes(t)||O.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:d,body:h}){const E=`${a||W({isDev:!1,isStage:!1})}${t}`,p={method:r,headers:{"Content-Type":"application/json",...c}};h&&(p.body=JSON.stringify(h));const m=d?new URLSearchParams(d).toString():"",s=m?`?${m}`:"",b=await fetch(`${E}${s}`,p);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var T=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(T||{});const P={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:d}){let h="",g=!1;const E=F(),p=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),d()},m=(s={})=>{var _;const{error:b,sdkLicense:l}=s,x=(_=s.plan)==null?void 0:_.category;if(!(l||s.license)||b)p(b||"Invalid license");else if(x){const C=P[a],H=P[x];C>H&&p({pluginRequiredPlan:a,licensePlan:x})}};t.on(D,s=>{h=s==null?void 0:s.baseApiUrl,g=!0}),t.on(U,s=>{m(s)}),setTimeout(async()=>{if(!g){if(E)return;if(c){const s=await z({licenseKey:c,pluginName:r,baseApiUrl:h});s&&m(s)}else p("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",I="data-type",Y="fslightbox-open",L="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'};return Z(function(t,a={}){const{Blocks:r,Components:c}=t,d="Lightbox",h=`${J}${L}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:E,toolbarIconOpen:p,defaultSrc:m}=g,s=function(n){const e=this,i="data-fslightbox",o=window,f=()=>{var N;const u=o.refreshFsLightbox;u==null||u();const M=e.getAttribute(i);if((N=o.fsLightboxInstances)==null||N[M],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const A=w.onclick;w.onclick=function($){$.preventDefault();const B=w;!B.__skipLb&&(A==null||A($)),B.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=n.cdnScript,u.onload=f,document.head.appendChild(u)}},b=n=>({id:`${L}-open-lb`,label:p,command:()=>{const e=n.getView();e==null||e.toggleLightbox()}}),l="source-type",x={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},j={id:"href-image",name:"href",type:"file",label:"Source Image"},_={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},C={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},H={image:[j],video:[_],el:[C]};c.addType(L,{block:E&&{label:d,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:n=>{var e;return(e=n.hasAttribute)==null?void 0:e.call(n,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:d,icon:S.imageLightbox,classes:h,draggable:(n,e)=>!e.is(L),attributes:{[k]:"lightbox",[I]:"image",href:m},components:{type:"image",src:m},script:s,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[x,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(n,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
2
  .${h} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const n=[l].map(e=>`change:${e}`).join(" ");this.on(n,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(n,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[I]:f,href:""})},adjustSourceType(){const n=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(n==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[I]:o},i)}else n!=="el"&&e.startsWith("#")?this.set(l,"el",i):n==="image"&&this.addAttributes({[I]:"image"},i)},updateTraits(n={}){const{changed:e}=this,{init:i}=n;if(e[x.name]||i){this.removeTrait([$.name,_.name,C.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait(H[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:n}=this,e=b(this);!n.find(o=>o.id===e.id)&&(n==null||n.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:n,el:e,model:i}=this,{Canvas:o}=n,f=i.getAttributes()[k],{defaultView:u,documentElement:M}=e.ownerDocument,j=(w=u.fsLightboxInstances)==null?void 0:w[f];if(M.classList.contains(Y))j.close();else{e.__skipLb=!1;let A;j.props.onOpen=()=>{A=o.getSpots(),setTimeout(()=>o.removeSpots())},j.props.onClose=()=>{A.forEach(V=>o.addSpot(V.attributes))},e.click()}}}}),Z({editor:t,plan:T.startup,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(L),c.removeType(L)}})})});
6
+ `},init(){const n=[l].map(e=>`change:${e}`).join(" ");this.on(n,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(n,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[I]:f,href:""})},adjustSourceType(){const n=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(n==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[I]:o},i)}else n!=="el"&&e.startsWith("#")?this.set(l,"el",i):n==="image"&&this.addAttributes({[I]:"image"},i)},updateTraits(n={}){const{changed:e}=this,{init:i}=n;if(e[x.name]||i){this.removeTrait([j.name,_.name,C.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait(H[o],{at:f})}},initToolbar(){if(!p)return;const{toolbar:n}=this,e=b(this);!n.find(o=>o.id===e.id)&&(n==null||n.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:n,el:e,model:i}=this,{Canvas:o}=n,f=i.getAttributes()[k],{defaultView:u,documentElement:M}=e.ownerDocument,V=(w=u.fsLightboxInstances)==null?void 0:w[f];if(M.classList.contains(Y))V.close();else{e.__skipLb=!1;let A;V.props.onOpen=()=>{A=o.getSpots(),setTimeout(()=>o.removeSpots())},V.props.onClose=()=>{A.forEach($=>o.addSpot($.attributes))},e.click()}}}}),q({editor:t,plan:T.startup,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(L),c.removeType(L)}})})});
@@ -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.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
+ "use strict";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.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",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"],G="license:check:start",$="license:check:end",k=()=>typeof window<"u",x=({isDev:e,isStage:t})=>`${e?"":`https://${t?T:A}`}/api`,D=()=>{const e=k()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function F({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:n,body:i}){const l=`${t||x({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const u=n?new URLSearchParams(n).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=o=>s=>e(s,o),t}const O=e=>U(e);async function M({editor:e,plan:t,pluginName:o,licenseKey:s,cleanup:n}){let i="",r=!1;const l=D(),c=a=>{console.warn("Cleanup plugin:",o,"Reason:",a),n()},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(G,a=>{i=a==null?void 0:a.baseApiUrl,r=!0}),e.on($,a=>{u(a)}),setTimeout(async()=>{if(!r){if(l)return;if(s){const a=await B({licenseKey:s,pluginName:o,baseApiUrl:i});a&&u(a)}else c("The `licenseKey` option not provided")}},2e3)}async function B(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await F({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const E=e=>{const{family:t,menu:o,axes:s}=e,n=!!s,i=Object.assign({},...e.variants.map(r=>{var a,d;let l,c;if(n){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:o,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:o,source:s,options:n}=t.menuVariant,i=new FontFace(o,`url("${s}")`,n);document.fonts.add(i),i.load().catch(()=>{})}};let h;const j=e=>{const t=[];for(const o of Object.keys(e)){let s=e[o];s&&(Array.isArray(s)?t.push(...s.map(n=>[o,n.toString()])):(s=s.toString(),t.push([o,s])))}return new URLSearchParams(t)},N=e=>{const{apiKey:t,searchParams:o}=e,s=(n={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=j(n);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:n})=>n.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const n={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=o==null?void 0:o(),r={...n,...i},c=await(await fetch(s(r))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(I),h):[]},itemLayout:n=>{const i=h.find(r=>r.id===n.assetProps.id);return W(i),{type:"column",onClick:()=>n.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",V=function(e,t){const{i18n:o={}}=t,s=N(t);e.runCommand(b.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:K,...o}),M({editor:e,licenseKey:t.licenseKey,plan:p.startup,pluginName:_,cleanup:()=>{e.runCommand(b.assetProviderRemove,{id:s.id})}})},H=O(V);module.exports=H;
@@ -1,5 +1,4 @@
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.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 || {});
1
+ 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.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", 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
2
  const A = "app.grapesjs.com", T = "app-stage.grapesjs.com", v = [
4
3
  A,
5
4
  T,
@@ -11,27 +10,27 @@ const A = "app.grapesjs.com", T = "app-stage.grapesjs.com", v = [
11
10
  // For stackblitz.com demos
12
11
  "-sandpack.codesandbox.io"
13
12
  // For Sandpack demos
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
- const e = x() && window.location.hostname;
13
+ ], G = "license:check:start", $ = "license:check:end", k = () => typeof window < "u", x = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? T : A}`}/api`, D = () => {
14
+ const e = k() && window.location.hostname;
16
15
  return !!e && (v.includes(e) || v.some((t) => e.endsWith(t)));
17
16
  };
18
17
  async function F({
19
18
  path: e,
20
19
  baseApiUrl: t,
21
- method: n = "GET",
20
+ method: o = "GET",
22
21
  headers: s = {},
23
- params: o,
22
+ params: n,
24
23
  body: i
25
24
  }) {
26
- const l = `${t || G({ isDev: !1, isStage: !1 })}${e}`, c = {
27
- method: n,
25
+ const l = `${t || x({ isDev: !1, isStage: !1 })}${e}`, c = {
26
+ method: o,
28
27
  headers: {
29
28
  "Content-Type": "application/json",
30
29
  ...s
31
30
  }
32
31
  };
33
32
  i && (c.body = JSON.stringify(i));
34
- const u = o ? new URLSearchParams(o).toString() : "", a = u ? `?${u}` : "", d = await fetch(`${l}${a}`, c);
33
+ const u = n ? new URLSearchParams(n).toString() : "", a = u ? `?${u}` : "", d = await fetch(`${l}${a}`, c);
35
34
  if (!d.ok)
36
35
  throw new Error(`HTTP error! status: ${d.status}`);
37
36
  return d.json();
@@ -44,19 +43,19 @@ const w = {
44
43
  };
45
44
  function U(e) {
46
45
  const t = e;
47
- return t.init = (n) => (s) => e(s, n), t;
46
+ return t.init = (o) => (s) => e(s, o), t;
48
47
  }
49
48
  const O = (e) => /* @__PURE__ */ U(e);
50
49
  async function M({
51
50
  editor: e,
52
51
  plan: t,
53
- pluginName: n,
52
+ pluginName: o,
54
53
  licenseKey: s,
55
- cleanup: o
54
+ cleanup: n
56
55
  }) {
57
56
  let i = "", r = !1;
58
57
  const l = D(), c = (a) => {
59
- console.warn("Cleanup plugin:", n, "Reason:", a), o();
58
+ console.warn("Cleanup plugin:", o, "Reason:", a), n();
60
59
  }, u = (a = {}) => {
61
60
  var P;
62
61
  const { error: d, sdkLicense: f } = a, g = (P = a.plan) == null ? void 0 : P.category;
@@ -67,15 +66,15 @@ async function M({
67
66
  L > R && c({ pluginRequiredPlan: t, licensePlan: g });
68
67
  }
69
68
  };
70
- e.on($, (a) => {
69
+ e.on(G, (a) => {
71
70
  i = a == null ? void 0 : a.baseApiUrl, r = !0;
72
- }), e.on(k, (a) => {
71
+ }), e.on($, (a) => {
73
72
  u(a);
74
73
  }), setTimeout(async () => {
75
74
  if (!r) {
76
75
  if (l) return;
77
76
  if (s) {
78
- const a = await B({ licenseKey: s, pluginName: n, baseApiUrl: i });
77
+ const a = await B({ licenseKey: s, pluginName: o, baseApiUrl: i });
79
78
  a && u(a);
80
79
  } else
81
80
  c("The `licenseKey` option not provided");
@@ -83,7 +82,7 @@ async function M({
83
82
  }, 2e3);
84
83
  }
85
84
  async function B(e) {
86
- const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
85
+ const { licenseKey: t, pluginName: o, baseApiUrl: s } = e;
87
86
  try {
88
87
  return (await F({
89
88
  baseApiUrl: s,
@@ -91,20 +90,20 @@ async function B(e) {
91
90
  method: "POST",
92
91
  params: {
93
92
  d: window.location.hostname,
94
- pn: n
93
+ pn: o
95
94
  }
96
95
  })).result || {};
97
- } catch (o) {
98
- return console.error("Error during SDK license check:", o), !1;
96
+ } catch (n) {
97
+ return console.error("Error during SDK license check:", n), !1;
99
98
  }
100
99
  }
101
100
  const E = (e) => {
102
- const { family: t, menu: n, axes: s } = e, o = !!s, i = Object.assign(
101
+ const { family: t, menu: o, axes: s } = e, n = !!s, i = Object.assign(
103
102
  {},
104
103
  ...e.variants.map((r) => {
105
104
  var a, d;
106
105
  let l, c;
107
- if (o) {
106
+ if (n) {
108
107
  const f = s.find((g) => g.tag === "wght");
109
108
  if (f) {
110
109
  const { start: g, end: y } = f;
@@ -128,7 +127,7 @@ const E = (e) => {
128
127
  family: t,
129
128
  menuVariant: {
130
129
  family: `assetManagerMenu-${t}`,
131
- source: n,
130
+ source: o,
132
131
  variant: "menu"
133
132
  },
134
133
  variants: i
@@ -142,7 +141,7 @@ const E = (e) => {
142
141
  }), W = (e) => {
143
142
  if (e.customData.needsLoading) {
144
143
  e.customData.needsLoading = !1;
145
- const { font: t } = e.customData, { family: n, source: s, options: o } = t.menuVariant, i = new FontFace(n, `url("${s}")`, o);
144
+ const { font: t } = e.customData, { family: o, source: s, options: n } = t.menuVariant, i = new FontFace(o, `url("${s}")`, n);
146
145
  document.fonts.add(i), i.load().catch(() => {
147
146
  });
148
147
  }
@@ -150,41 +149,41 @@ const E = (e) => {
150
149
  let h;
151
150
  const j = (e) => {
152
151
  const t = [];
153
- for (const n of Object.keys(e)) {
154
- let s = e[n];
155
- s && (Array.isArray(s) ? t.push(...s.map((o) => [n, o.toString()])) : (s = s.toString(), t.push([n, s])));
152
+ for (const o of Object.keys(e)) {
153
+ let s = e[o];
154
+ s && (Array.isArray(s) ? t.push(...s.map((n) => [o, n.toString()])) : (s = s.toString(), t.push([o, s])));
156
155
  }
157
156
  return new URLSearchParams(t);
158
157
  }, N = (e) => {
159
- const { apiKey: t, searchParams: n } = e, s = (o = {}) => {
160
- const i = "https://www.googleapis.com/webfonts/v1/webfonts", r = j(o);
158
+ const { apiKey: t, searchParams: o } = e, s = (n = {}) => {
159
+ const i = "https://www.googleapis.com/webfonts/v1/webfonts", r = j(n);
161
160
  return `${i}?${r}`;
162
161
  };
163
162
  return {
164
163
  id: "google-fonts",
165
164
  types: ["font"],
166
- label: ({ editor: o }) => o.I18n.t("googleFontsAssetProvider.providerLabel"),
165
+ label: ({ editor: n }) => n.I18n.t("googleFontsAssetProvider.providerLabel"),
167
166
  search: { reloadOnInput: !1 },
168
167
  async onLoad() {
169
168
  var u;
170
169
  if (h)
171
170
  return h;
172
- const o = {
171
+ const n = {
173
172
  key: t,
174
173
  sort: "alpha",
175
174
  subset: "latin",
176
175
  capability: ["WOFF2", "VF"]
177
- }, i = n == null ? void 0 : n(), r = {
178
- ...o,
176
+ }, i = o == null ? void 0 : o(), r = {
177
+ ...n,
179
178
  ...i
180
179
  }, c = await (await fetch(s(r))).json();
181
180
  return (u = c.items) != null && u.length ? (h = c.items.map(I), h) : [];
182
181
  },
183
- itemLayout: (o) => {
184
- const i = h.find((r) => r.id === o.assetProps.id);
182
+ itemLayout: (n) => {
183
+ const i = h.find((r) => r.id === n.assetProps.id);
185
184
  return W(i), {
186
185
  type: "column",
187
- onClick: () => o.onSelect(i),
186
+ onClick: () => n.onSelect(i),
188
187
  htmlAttrs: {
189
188
  title: i.name
190
189
  },
@@ -218,11 +217,11 @@ const j = (e) => {
218
217
  modalTitle: "Select Font",
219
218
  providerLabel: "Google Fonts"
220
219
  }
221
- }, _ = "googleFontsAssetProvider", m = function(e, t) {
222
- const { i18n: n = {} } = t, s = N(t);
220
+ }, _ = "googleFontsAssetProvider", V = function(e, t) {
221
+ const { i18n: o = {} } = t, s = N(t);
223
222
  e.runCommand(b.assetProviderAdd, { provider: s }), e.I18n.addMessages({
224
223
  en: K,
225
- ...n
224
+ ...o
226
225
  }), M({
227
226
  editor: e,
228
227
  licenseKey: t.licenseKey,
@@ -232,7 +231,7 @@ const j = (e) => {
232
231
  e.runCommand(b.assetProviderRemove, { id: s.id });
233
232
  }
234
233
  });
235
- }, H = O(m);
234
+ }, H = O(V);
236
235
  export {
237
236
  H as default
238
237
  };
@@ -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.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
+ (function(l,f){typeof exports=="object"&&typeof module<"u"?module.exports=f():typeof define=="function"&&define.amd?define(f):(l=typeof globalThis<"u"?globalThis:l||self,l.StudioSdkPlugins_googleFontsAssetProvider=f())})(this,function(){"use strict";var l=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(l||{}),f=(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.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",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||{});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`,G=()=>{const e=x()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function $({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 F(e){const t=e;return t.init=n=>s=>e(s,n),t}const D=e=>F(e);async function U({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:o}){let i="",r=!1;const u=G(),c=a=>{console.warn("Cleanup plugin:",n,"Reason:",a),o()},d=(a={})=>{var T;const{error:g,sdkLicense:b}=a,p=(T=a.plan)==null?void 0:T.category;if(!(b||a.license)||g)c(g||"Invalid license");else if(p){const _=w[t],K=w[p];_>K&&c({pluginRequiredPlan:t,licensePlan:p})}};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 $({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(p=>p.tag==="wght");if(b){const{start:p,end:A}=b;u=`${p} ${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}},B=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:M(e),needsLoading:!0}}),E=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 I=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)},j=e=>{const{apiKey:t,searchParams:n}=e,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=I(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(B),h):[]},itemLayout:o=>{const i=h.find(r=>r.id===o.assetProps.id);return E(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=j(t);e.runCommand(f.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:W,...n}),U({editor:e,licenseKey:t.licenseKey,plan:l.startup,pluginName:N,cleanup:()=>{e.runCommand(f.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||{}),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">
1
+ "use strict";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||{}),f=(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.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",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||{});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>`,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;
3
+ </svg>`,R="layout-icon-picker",H="icons-layout-",_="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 m({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(f.toastAdd,q());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(f.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(f.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:_,type:"column",grow:!0}]}});const r=await m({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:_}};o.runCommand(f.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(f.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 m({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:h}=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}=z(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(f.layoutRemove,{id:R})};return l.addEventListener("click",b),g(l),()=>{l.removeEventListener("click",b),h(l)}}}]}}}function z(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 q(){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:h}=i,l=(y=i.plan)==null?void 0:y.category;if(!(h||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",h={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:h}),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:h})}ne({editor:e,licenseKey:u,plan:L.startup,pluginName:ce,cleanup:()=>{n.remove(c),t.removeType(c)}})},le=oe(re);module.exports=le;