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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +161 -156
  3. package/dist/accordionComponent/index.umd.js +9 -9
  4. package/dist/aiChat/chatManager.d.ts +15 -0
  5. package/dist/aiChat/clientTools.d.ts +3 -3
  6. package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
  7. package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
  8. package/dist/aiChat/components/AiChatError.d.ts +2 -1
  9. package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
  10. package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
  11. package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
  12. package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
  13. package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
  14. package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
  15. package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
  16. package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
  17. package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
  18. package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
  19. package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
  20. package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
  21. package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
  22. package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
  23. package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
  24. package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
  25. package/dist/aiChat/components/index.d.ts +24 -25
  26. package/dist/aiChat/components/utils.d.ts +12 -4
  27. package/dist/aiChat/index.cjs.d.ts +5 -0
  28. package/dist/aiChat/index.cjs.js +453 -0
  29. package/dist/aiChat/index.d.ts +4 -3
  30. package/dist/aiChat/index.es.d.ts +5 -0
  31. package/dist/aiChat/index.es.js +30930 -0
  32. package/dist/aiChat/index.js +453 -0
  33. package/dist/aiChat/index.umd.js +453 -0
  34. package/dist/aiChat/locales/en.d.ts +64 -0
  35. package/dist/aiChat/server/index.cjs.d.ts +4 -0
  36. package/dist/aiChat/server/index.cjs.js +309 -0
  37. package/dist/aiChat/server/index.d.ts +0 -50
  38. package/dist/aiChat/server/index.es.d.ts +4 -0
  39. package/dist/aiChat/server/index.es.js +876 -0
  40. package/dist/aiChat/server/index.js +309 -0
  41. package/dist/aiChat/server/index.umd.js +309 -0
  42. package/dist/aiChat/server/stream.d.ts +0 -6
  43. package/dist/aiChat/server/tools.d.ts +157 -51
  44. package/dist/aiChat/server/types.d.ts +108 -64
  45. package/dist/aiChat/types.d.ts +148 -108
  46. package/dist/aiChat/typesSchema.d.ts +238 -25
  47. package/dist/animationComponent/index.cjs.js +3 -3
  48. package/dist/animationComponent/index.es.js +174 -169
  49. package/dist/animationComponent/index.umd.js +3 -3
  50. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  51. package/dist/canvasAbsoluteMode/index.es.js +161 -156
  52. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  53. package/dist/canvasEmptyState/index.cjs.js +1 -1
  54. package/dist/canvasEmptyState/index.es.js +113 -108
  55. package/dist/canvasEmptyState/index.umd.js +1 -1
  56. package/dist/canvasFullSize/index.cjs.js +9 -9
  57. package/dist/canvasFullSize/index.es.js +137 -132
  58. package/dist/canvasFullSize/index.umd.js +9 -9
  59. package/dist/canvasGridMode/index.cjs.js +4 -4
  60. package/dist/canvasGridMode/index.es.js +168 -163
  61. package/dist/canvasGridMode/index.umd.js +8 -8
  62. package/dist/canvasScreenshot/index.cjs.js +1 -1
  63. package/dist/canvasScreenshot/index.es.js +132 -127
  64. package/dist/canvasScreenshot/index.umd.js +1 -1
  65. package/dist/dataSourceEjs/index.cjs.js +5 -5
  66. package/dist/dataSourceEjs/index.es.js +151 -146
  67. package/dist/dataSourceEjs/index.umd.js +5 -5
  68. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  69. package/dist/dataSourceHandlebars/index.es.js +91 -86
  70. package/dist/dataSourceHandlebars/index.umd.js +5 -5
  71. package/dist/dialogComponent/index.cjs.js +16 -16
  72. package/dist/dialogComponent/index.es.js +117 -112
  73. package/dist/dialogComponent/index.umd.js +16 -16
  74. package/dist/flexComponent/index.cjs.js +11 -11
  75. package/dist/flexComponent/index.es.js +416 -411
  76. package/dist/flexComponent/index.umd.js +11 -11
  77. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  78. package/dist/fsLightboxComponent/index.es.js +152 -147
  79. package/dist/fsLightboxComponent/index.umd.js +3 -3
  80. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  81. package/dist/googleFontsAssetProvider/index.es.js +127 -122
  82. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  83. package/dist/iconifyComponent/index.cjs.js +2 -2
  84. package/dist/iconifyComponent/index.es.js +170 -165
  85. package/dist/iconifyComponent/index.umd.js +2 -2
  86. package/dist/index.cjs.js +1 -1
  87. package/dist/index.es.js +27 -22
  88. package/dist/index.umd.js +1 -1
  89. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  90. package/dist/layoutSidebarButtons/index.es.js +156 -151
  91. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  92. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  93. package/dist/lightGalleryComponent/index.es.js +197 -192
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/linkImageComponent/index.cjs.js +2 -2
  96. package/dist/linkImageComponent/index.es.js +86 -81
  97. package/dist/linkImageComponent/index.umd.js +2 -2
  98. package/dist/listPagesComponent/index.cjs.js +5 -5
  99. package/dist/listPagesComponent/index.es.js +121 -116
  100. package/dist/listPagesComponent/index.umd.js +5 -5
  101. package/dist/presetPrintable/index.cjs.js +4 -4
  102. package/dist/presetPrintable/index.es.js +180 -175
  103. package/dist/presetPrintable/index.umd.js +4 -4
  104. package/dist/prosemirror/index.cjs.js +6 -6
  105. package/dist/prosemirror/index.es.js +128 -123
  106. package/dist/prosemirror/index.umd.js +8 -8
  107. package/dist/rendererReact/index.cjs.js +1 -1
  108. package/dist/rendererReact/index.es.js +127 -122
  109. package/dist/rendererReact/index.js +1 -1
  110. package/dist/rendererReact/index.umd.js +1 -1
  111. package/dist/rteTinyMce/index.cjs.js +2 -2
  112. package/dist/rteTinyMce/index.es.js +160 -155
  113. package/dist/rteTinyMce/index.umd.js +2 -2
  114. package/dist/shapeDividerComponent/index.cjs.js +25 -25
  115. package/dist/shapeDividerComponent/index.es.js +127 -122
  116. package/dist/shapeDividerComponent/index.umd.js +25 -25
  117. package/dist/swiperComponent/index.cjs.js +9 -9
  118. package/dist/swiperComponent/index.es.js +197 -192
  119. package/dist/swiperComponent/index.umd.js +9 -9
  120. package/dist/tableComponent/index.cjs.js +1 -1
  121. package/dist/tableComponent/index.es.js +227 -222
  122. package/dist/tableComponent/index.umd.js +1 -1
  123. package/dist/types.d.ts +1 -1
  124. package/dist/utils.d.ts +12 -1
  125. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  126. package/dist/youtubeAssetProvider/index.es.js +124 -119
  127. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  128. package/package.json +5 -2
  129. package/dist/aiChat/components/AiChatInput.d.ts +0 -17
  130. package/dist/aiChat/server/stream-utils.d.ts +0 -16
@@ -1,41 +1,254 @@
1
- /**
2
- * Schema types for documentation generation
3
- * These are simplified types used for generating JSON schema
4
- */
5
- export interface AiChatOptions {
1
+ import { SDKPluginOptions } from '../utils';
2
+ import { CSSProperties } from 'react';
3
+ export interface AiChatOptions extends SDKPluginOptions {
6
4
  /**
7
- * The license key for the plugin.
8
- * This is optional, only required if the plugin is used outside of Studio SDK.
9
- * @example
10
- * 'your-license-key'
5
+ * Custom endpoint for the chat API
6
+ * @examples
7
+ * chatApi: '/my/ai/chat'
8
+ * chatApi: () => '/my/ai/chat'
11
9
  */
12
- licenseKey?: string;
10
+ chatApi?: string | '__fn__';
13
11
  /**
14
- * Custom endpoint for the chat API
15
- * @default '/api/ai/chat'
12
+ * Customize or extend the default client-side tools
13
+ * @examples
14
+ * tools: ({ defaultTools, editor }) => ({
15
+ * ...defaultTools,
16
+ * getUserLocation: {
17
+ * async execute() {
18
+ * const location = await getLocationViaBrowserAPI();
19
+ * return `User location: ${location.city}`;
20
+ * }
21
+ * }
22
+ * })
23
+ */
24
+ tools?: '__fn__';
25
+ /**
26
+ * Callback when a client tool call is made
27
+ * @examples
28
+ * onTool: ({ toolCall }) => {
29
+ * console.log('Tool call:', toolCall);
30
+ * }
31
+ */
32
+ onTool?: '__fn__';
33
+ /**
34
+ * Customize UI layout component props
35
+ * @examples
36
+ * layoutComponents: {
37
+ * aiChatInput: () => ({
38
+ * maxImages: 3,
39
+ * }),
40
+ * }
16
41
  */
17
- chatApi?: string;
42
+ layoutComponents?: object;
18
43
  /**
19
- * Show suggestions in empty state
20
- * @default true
44
+ * Initial messages or async function to load messages
45
+ * @examples
46
+ * // Static messages
47
+ * messages: [{ id: '1', role: 'user', ... }]
48
+ * // Dynamic loading
49
+ * messages: async () => {
50
+ * return await loadFromDatabase();
51
+ * }
21
52
  */
22
- showSuggestions?: boolean;
53
+ messages?: object | '__fn__';
23
54
  /**
24
- * Enable sending images in messages
25
- * @default true
55
+ * Callback when messages are updated (for persistence)
56
+ * @examples
57
+ * onMessagesUpdate: async ({ messages }) => {
58
+ * await saveToDatabase(messages);
59
+ * }
26
60
  */
27
- enableImages?: boolean;
61
+ onMessagesUpdate?: '__fn__';
28
62
  /**
29
- * Maximum number of images per message
63
+ * Request body for API calls (merged with default body)
64
+ * @examples
65
+ * body: ({ body }) => ({
66
+ * ...body,
67
+ * projectId: 'my-project'
68
+ * })
69
+ * body: { projectId: 'my-project' }
70
+ */
71
+ body?: object | '__fn__';
72
+ /**
73
+ * Function to get the access token
74
+ * @examples
75
+ * getAccessToken: async () => {
76
+ * const result = await fetch('/api/access-tokens', {
77
+ * method: 'POST',
78
+ * }).then(response => response.json());
79
+ * return result;
80
+ * }
81
+ */
82
+ getAccessToken?: '__fn__';
83
+ /**
84
+ * Additional [chat options](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat).
85
+ * @examples
86
+ * chatOptions: {
87
+ * onData: data => console.log('onData:', data),
88
+ * onError: error => console.log('onError:', error),
89
+ * onFinish: result => console.log('onFinish:', result)
90
+ * }
91
+ */
92
+ chatOptions?: object;
93
+ }
94
+ export interface CommonComponentPropsSchema {
95
+ /**
96
+ * Custom class name.
97
+ */
98
+ className?: string;
99
+ /**
100
+ * Custom styles.
101
+ */
102
+ style?: CSSProperties;
103
+ }
104
+ export interface AiChatPanelPropsSchema extends CommonComponentPropsSchema {
105
+ /**
106
+ * GrapesJS editor instance
107
+ */
108
+ editor: object;
109
+ /**
110
+ * AI Chat plugin options
111
+ */
112
+ pluginOptions: object;
113
+ }
114
+ export interface AiChatHeaderPropsSchema {
115
+ }
116
+ export interface AiChatErrorPropsSchema {
117
+ }
118
+ export interface AiChatLoadingStatePropsSchema {
119
+ }
120
+ export interface AiChatInputPropsSchema {
121
+ /**
122
+ * Maximum number of assets per message. Set to 0 to disable asset attachments.
30
123
  * @default 5
31
124
  */
32
- maxImages?: number;
125
+ maxAssets?: number;
126
+ /**
127
+ * Accepted file types for attachments.
128
+ * @default 'image/jpeg,image/png,image/gif,image/webp,application/pdf'
129
+ */
130
+ acceptAssetType?: string;
131
+ /**
132
+ * Custom upload function for assets.
133
+ * If not provided, the upload from AssetManager will be used.
134
+ * @examples
135
+ * uploadProjectAssets: async ({ files }) => {
136
+ * const uploaded = await uploadToServer(files);
137
+ * return uploaded.map(asset => ({ id: asset.id, src: asset.url, ... }));
138
+ * }
139
+ */
140
+ uploadProjectAssets?: '__fn__';
141
+ /**
142
+ * Custom layout rendered before the main input container.
143
+ */
144
+ layoutBefore?: '__fn__';
145
+ /**
146
+ * Custom layout rendered after the main input container.
147
+ */
148
+ layoutAfter?: '__fn__';
149
+ /**
150
+ * Custom submit handler. When provided, the default submit is skipped.
151
+ * Receives the form event, a `submit` callback to trigger the original submit, and the current input state.
152
+ */
153
+ onSubmit?: '__fn__';
154
+ /**
155
+ * Props forwarded to the context section (selected components indicator).
156
+ */
157
+ contextSectionProps?: object;
158
+ /**
159
+ * Props forwarded to the textarea element.
160
+ */
161
+ textareaProps?: object;
162
+ /**
163
+ * Props forwarded to the assets section.
164
+ */
165
+ assetsSectionProps?: object;
166
+ /**
167
+ * Props forwarded to the attach button.
168
+ */
169
+ attachButtonProps?: object;
170
+ /**
171
+ * Props forwarded to the dictate button.
172
+ */
173
+ dictateButtonProps?: object;
174
+ /**
175
+ * Props forwarded to the submit button.
176
+ */
177
+ submitButtonProps?: object;
178
+ /**
179
+ * Default value for the text input.
180
+ */
181
+ value?: string;
182
+ }
183
+ export interface AiChatEmptyStatePropsSchema {
184
+ /**
185
+ * Suggestions to show in the empty state.
186
+ * @examples
187
+ * suggestions: [{ id: 'webHero', label: 'Create hero', prompt: 'Create a hero section' }]
188
+ */
189
+ suggestions?: object[];
190
+ }
191
+ export interface AiChatMessagePropsSchema {
192
+ /**
193
+ * Chat message to render
194
+ */
195
+ message: object;
196
+ /**
197
+ * Indicates if the message is currently streaming
198
+ */
199
+ isStreaming?: boolean;
200
+ /**
201
+ * Custom layout before the message
202
+ */
203
+ layoutBeforeMessage?: '__fn__';
204
+ /**
205
+ * Custom layout after the message
206
+ */
207
+ layoutAfterMessage?: '__fn__';
208
+ /**
209
+ * Custom layout for message parts
210
+ */
211
+ layoutPart?: '__fn__';
212
+ /**
213
+ * Custom layout for tool label parts
214
+ */
215
+ layoutPartToolLabel?: '__fn__';
216
+ /**
217
+ * Custom layout for tool detail parts
218
+ */
219
+ layoutPartToolDetail?: '__fn__';
220
+ /**
221
+ * Custom layout for tool result parts
222
+ */
223
+ layoutPartToolResult?: '__fn__';
224
+ }
225
+ export interface AiChatMessagesPropsSchema {
226
+ /**
227
+ * GrapesJS editor instance
228
+ */
229
+ editor: object;
230
+ /**
231
+ * Chat context
232
+ */
233
+ chatContext: object;
234
+ /**
235
+ * Messages to render
236
+ */
237
+ messages: object[];
238
+ /**
239
+ * AI Chat plugin options
240
+ */
241
+ pluginOptions: object;
242
+ }
243
+ export interface AiChatMessagesStatusPropsSchema {
244
+ }
245
+ export interface AiChatProviderPropsSchema {
33
246
  /**
34
- * Custom tools configuration
247
+ * Chat manager instance
35
248
  */
36
- tools?: Record<string, unknown>;
249
+ chatManager: object;
37
250
  /**
38
- * Custom layout components
251
+ * Provider children
39
252
  */
40
- layoutComponents?: Record<string, unknown>;
253
+ children: object;
41
254
  }
@@ -1,5 +1,5 @@
1
- "use strict";const T="app.grapesjs.com",P="app-stage.grapesjs.com",G="app2.grapesjs.com",O="app-stage2.grapesjs.com",U=[T,G,P,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],V="license:check:start",B="license:check:end",F=()=>typeof window<"u",X=({isDev:t,isStage:n})=>`${t?"":`https://${n?P:T}`}/api`,M=()=>{const t=F()&&window.location.hostname;return!!t&&(U.includes(t)||U.some(n=>t.endsWith(n)))};async function j({path:t,baseApiUrl:n,method:e="GET",headers:r={},params:i,body:a}){const c=`${n||X({isDev:!1,isStage:!1})}${t}`,l={method:e,headers:{"Content-Type":"application/json",...r}};a&&(l.body=JSON.stringify(a));const f=i?new URLSearchParams(i).toString():"",s=f?`?${f}`:"",o=await fetch(`${c}${s}`,l);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var b=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(b||{});const A={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function _(t){const n=t;return n.init=e=>r=>t(r,e),n}const W=t=>_(t);async function Y({editor:t,plan:n,pluginName:e,licenseKey:r,cleanup:i}){let a="",m=!1;const c=M(),l=s=>{console.warn("Cleanup plugin:",e,"Reason:",s),i()},f=(s={})=>{var u;const{error:o,sdkLicense:p}=s,d=(u=s.plan)==null?void 0:u.category;if(!(p||s.license)||o)l(o||"Invalid license");else if(d){const C=A[n],E=A[d];C>E&&l({pluginRequiredPlan:n,licensePlan:d})}};t.on(V,s=>{a=s==null?void 0:s.baseApiUrl,m=!0}),t.on(B,s=>{f(s)}),setTimeout(async()=>{if(!m){if(c)return;if(r){const s=await $({licenseKey:r,pluginName:e,baseApiUrl:a});s&&f(s)}else l("The `licenseKey` option not provided")}},2e3)}async function $(t){const{licenseKey:n,pluginName:e,baseApiUrl:r}=t;try{return(await j({baseApiUrl:r,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const H=(...t)=>n=>t.some(e=>n.is(e));var y=(t=>(t.name="animation-name",t.duration="animation-duration",t.delay="animation-delay",t.iterationCount="animation-iteration-count",t.timingFunction="animation-timing-function",t.fillMode="animation-fill-mode",t))(y||{}),v=(t=>(t.onScroll="--animation-on-scroll",t.threshold="--animation-threshold",t.repeat="--animation-repeat",t))(v||{});const g="animation",I="animation-group",L="animation:update",x="animation-group:update",z={category:{id:"animations",label:"Animations"},select:!0},k=t=>(t==null?void 0:t.getType())===g,w=t=>(t==null?void 0:t.getType())===I,Z=t=>k(t)||w(t),S={isVisible:({component:t})=>k(t)},K={isVisible:({component:t})=>w(t)},q={isVisible:({component:t})=>k(t)&&w(t==null?void 0:t.parent())?!1:Z(t)},D={isVisible:({component:t,sector:n})=>{var e;return k(t)&&w(t==null?void 0:t.parent())?!1:Z(t)&&((e=n.getProperty(v.onScroll))==null?void 0:e.getValue())==="true"}},N={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},J=function(t){const n=this;let e=null;const r=()=>{e==null||e.disconnect(),e=null},i=()=>{r();const a=n.style;a.animationName="",requestAnimationFrame(()=>{const m=getComputedStyle(n),c=m.getPropertyValue("animation-name").trim(),l=m.getPropertyValue("--animation-on-scroll").trim()!=="false",f=parseFloat(m.getPropertyValue("--animation-threshold").trim())||.2,s=m.getPropertyValue("--animation-repeat").trim()==="true",o=()=>{a.animationName="none",n.offsetWidth,a.animationName=c,a.animationPlayState="running"};if(!c||c==="none"){a.animationName="none",a.animationPlayState="paused";return}if(!l){o();return}a.animationPlayState="paused",e=new IntersectionObserver(p=>{p.forEach(d=>{d.isIntersecting&&(o(),!s&&r())})},{threshold:f}),e.observe(n)})};n.addEventListener(t.animationUpdateEvent,i),i()},Q=(t,n)=>{const{Components:e,Blocks:r,Canvas:i}=t,{block:a={},animationList:m=[]}=n,c=t.Components.events,l="Animation",f=Object.values(v),s=Object.values(y);return e.addType(g,{block:a?{label:l,media:N.animation,content:{type:g},...z,...a}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:J,animationUpdateEvent:L,"script-props":["animationUpdateEvent"],styles:m.map(o=>o.css).join(`
2
- `)},init(){const{em:o}=this;this.addStyle({[y.name]:"fadeIn",[y.duration]:"1s",[y.fillMode]:"both",...n.animationStyle,...this.getStyle()}),this.listenTo(o,c.mount,p=>{var h;if(p!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==I||f.forEach(u=>this.removeStyle(u))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:o}=this;this.listenTo(o,c.styleUpdate,this.handleStyleChange)},onAnimationStart(){var p;if((p=this.cmpSpots)!=null&&p.length)return;const o=i.getSpots({component:this.model});this.cmpSpots=o,i.removeSpots(o),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const o=this.cmpSpots||[];i.spots.add(o),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(L))},handleStyleChange(o,p){Object.keys((p==null?void 0:p.style)||{}).some(u=>s.includes(u)||f.includes(u))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(g),e.removeType(g)}},tt=function(t){const n=this,e="--animation-on-scroll",r="--animation-threshold",i="--animation-repeat";let a=null;const m=()=>{a==null||a.disconnect(),a=null},c=()=>{m();const l=getComputedStyle(n),f=l.getPropertyValue(e).trim()!=="false",s=parseFloat(l.getPropertyValue(r).trim())||.2,o=l.getPropertyValue(i).trim()==="true",p=()=>{Array.from(n.children).forEach(d=>{d instanceof HTMLElement&&typeof d.dispatchEvent=="function"&&d.dispatchEvent(new CustomEvent(x,{bubbles:!1}))})};if(!f){p();return}a=new IntersectionObserver(d=>{d.forEach(h=>{h.isIntersecting?(p(),!o&&m()):o&&Array.from(n.children).forEach(u=>{u instanceof HTMLElement&&getComputedStyle(u).getPropertyValue(e).trim()!=="false"&&(u.style.opacity="0",u.style.animationPlayState="paused")})})},{threshold:s}),a.observe(n)};n.addEventListener(t.animationGroupUpdateEvent,c),c()},nt=(t,n)=>{const{Components:e,Blocks:r}=t,{blockGroup:i={}}=n,a="Animation Group";return e.addType(I,{block:i?{label:a,media:N.animationGroup,content:{type:I,components:[{type:g},{type:g},{type:g}]},...z,...i}:void 0,model:{defaults:{name:a,emptyState:!0,traits:[],script:tt,animationGroupUpdateEvent:x,"script-props":["animationGroupUpdateEvent"],droppable:H(g)},init(){this.addStyle({...n.animationGroupStyle,...this.getStyle()});const m=this.components();this.listenTo(m,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((m,c)=>{m.is(g)&&m.addStyle({"--stagger-index":c.toString(),[y.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:m}=this;this.listenTo(m,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(x))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(I),e.removeType(I)}},et="animationComponent",at=b.startup,R=[{id:"flash",name:"Flash",css:`@keyframes flash {
1
+ "use strict";const P="app.grapesjs.com",z="app-stage.grapesjs.com",O="app2.grapesjs.com",V="app-stage2.grapesjs.com",A=[P,O,z,V,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",F="license:check:end",X=()=>typeof window<"u",M=({isDev:t,isStage:n,isPlatform:a})=>`${t?"":`https://${n?z:P}`}/${a?"platform-api":"api"}`,j=()=>{const t=X()&&window.location.hostname;return!!t&&(A.includes(t)||A.some(n=>t.endsWith(n)))};async function _({path:t,baseApiUrl:n,method:a="GET",headers:s={},params:o,body:i}){const m=`${n||M({isDev:!1,isStage:!1})}${t}`,l={method:a,headers:{"Content-Type":"application/json",...s}};i&&(l.body=JSON.stringify(i));const p=o?new URLSearchParams(o).toString():"",u=p?`?${p}`:"",e=await fetch(`${m}${u}`,l);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}var b=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(b||{});const C={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function $(t){const n=t;return n.init=a=>s=>t(s,a),n}const W=t=>$(t);async function Y({editor:t,plan:n,pluginName:a,licenseKey:s,onLicenseCheckResponse:o,cleanup:i}){let r="",m=!1;const l=j(),p=e=>{console.warn("Cleanup plugin:",a,"Reason:",e),i()},u=(e={})=>{var k;const{error:c,sdkLicense:d}=e,h=(k=e.plan)==null?void 0:k.category;if(!(d||e.license)||c)p(c||"Invalid license");else if(h){const U=C[n],G=C[h];U>G&&p({pluginRequiredPlan:n,licensePlan:h})}};t.on(B,e=>{r=e==null?void 0:e.baseApiUrl,m=!0}),t.on(F,e=>{o==null||o(e),u(e)}),setTimeout(async()=>{if(!m){if(l)return;if(s){const e=await H({licenseKey:s,pluginName:a,baseApiUrl:r});o==null||o(e),e&&u(e)}else p("The `licenseKey` option not provided")}},2e3)}async function H(t){const{licenseKey:n,pluginName:a,baseApiUrl:s}=t;try{return(await _({baseApiUrl:s,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const K=(...t)=>n=>t.some(a=>n.is(a));var f=(t=>(t.name="animation-name",t.duration="animation-duration",t.delay="animation-delay",t.iterationCount="animation-iteration-count",t.timingFunction="animation-timing-function",t.fillMode="animation-fill-mode",t))(f||{}),v=(t=>(t.onScroll="--animation-on-scroll",t.threshold="--animation-threshold",t.repeat="--animation-repeat",t))(v||{});const g="animation",I="animation-group",D="animation:update",E="animation-group:update",Z={category:{id:"animations",label:"Animations"},select:!0},w=t=>(t==null?void 0:t.getType())===g,x=t=>(t==null?void 0:t.getType())===I,R=t=>w(t)||x(t),S={isVisible:({component:t})=>w(t)},q={isVisible:({component:t})=>x(t)},J={isVisible:({component:t})=>w(t)&&x(t==null?void 0:t.parent())?!1:R(t)},L={isVisible:({component:t,sector:n})=>{var a;return w(t)&&x(t==null?void 0:t.parent())?!1:R(t)&&((a=n.getProperty(v.onScroll))==null?void 0:a.getValue())==="true"}},N={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},Q=function(t){const n=this;let a=null;const s=()=>{a==null||a.disconnect(),a=null},o=()=>{s();const i=n.style;i.animationName="",requestAnimationFrame(()=>{const r=getComputedStyle(n),m=r.getPropertyValue("animation-name").trim(),l=r.getPropertyValue("--animation-on-scroll").trim()!=="false",p=parseFloat(r.getPropertyValue("--animation-threshold").trim())||.2,u=r.getPropertyValue("--animation-repeat").trim()==="true",e=()=>{i.animationName="none",n.offsetWidth,i.animationName=m,i.animationPlayState="running"};if(!m||m==="none"){i.animationName="none",i.animationPlayState="paused";return}if(!l){e();return}i.animationPlayState="paused",a=new IntersectionObserver(c=>{c.forEach(d=>{d.isIntersecting&&(e(),!u&&s())})},{threshold:p}),a.observe(n)})};n.addEventListener(t.animationUpdateEvent,o),o()},tt=(t,n)=>{const{Components:a,Blocks:s,Canvas:o}=t,{block:i={},animationList:r=[]}=n,m=t.Components.events,l="Animation",p=Object.values(v),u=Object.values(f);return a.addType(g,{block:i?{label:l,media:N.animation,content:{type:g},...Z,...i}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:Q,animationUpdateEvent:D,"script-props":["animationUpdateEvent"],styles:r.map(e=>e.css).join(`
2
+ `)},init(){const{em:e}=this;this.addStyle({[f.name]:"fadeIn",[f.duration]:"1s",[f.fillMode]:"both",...n.animationStyle,...this.getStyle()}),this.listenTo(e,m.mount,c=>{var h;if(c!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==I||p.forEach(y=>this.removeStyle(y))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:e}=this;this.listenTo(e,m.styleUpdate,this.handleStyleChange)},onAnimationStart(){var c;if((c=this.cmpSpots)!=null&&c.length)return;const e=o.getSpots({component:this.model});this.cmpSpots=e,o.removeSpots(e),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const e=this.cmpSpots||[];o.spots.add(e),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(D))},handleStyleChange(e,c){Object.keys((c==null?void 0:c.style)||{}).some(y=>u.includes(y)||p.includes(y))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{s.remove(g),a.removeType(g)}},nt=function(t){const n=this,a="--animation-on-scroll",s="--animation-threshold",o="--animation-repeat";let i=null;const r=()=>{i==null||i.disconnect(),i=null},m=()=>{r();const l=getComputedStyle(n),p=l.getPropertyValue(a).trim()!=="false",u=parseFloat(l.getPropertyValue(s).trim())||.2,e=l.getPropertyValue(o).trim()==="true",c=()=>{Array.from(n.children).forEach(d=>{d instanceof HTMLElement&&typeof d.dispatchEvent=="function"&&d.dispatchEvent(new CustomEvent(E,{bubbles:!1}))})};if(!p){c();return}i=new IntersectionObserver(d=>{d.forEach(h=>{h.isIntersecting?(c(),!e&&r()):e&&Array.from(n.children).forEach(y=>{y instanceof HTMLElement&&getComputedStyle(y).getPropertyValue(a).trim()!=="false"&&(y.style.opacity="0",y.style.animationPlayState="paused")})})},{threshold:u}),i.observe(n)};n.addEventListener(t.animationGroupUpdateEvent,m),m()},et=(t,n)=>{const{Components:a,Blocks:s}=t,{blockGroup:o={}}=n,i="Animation Group";return a.addType(I,{block:o?{label:i,media:N.animationGroup,content:{type:I,components:[{type:g},{type:g},{type:g}]},...Z,...o}:void 0,model:{defaults:{name:i,emptyState:!0,traits:[],script:nt,animationGroupUpdateEvent:E,"script-props":["animationGroupUpdateEvent"],droppable:K(g)},init(){this.addStyle({...n.animationGroupStyle,...this.getStyle()});const r=this.components();this.listenTo(r,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((r,m)=>{r.is(g)&&r.addStyle({"--stagger-index":m.toString(),[f.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:r}=this;this.listenTo(r,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(E))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{s.remove(I),a.removeType(I)}},at="animationComponent",ot=b.startup,T=[{id:"flash",name:"Flash",css:`@keyframes flash {
3
3
  0%, 50%, to {
4
4
  opacity:1
5
5
  }
@@ -516,4 +516,4 @@
516
516
  transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
517
517
  animation-timing-function:cubic-bezier(.175, .885, .32, 1)
518
518
  }
519
- }`}],ot=function(t,n={}){var i;const e=((i=n.animations)==null?void 0:i.call(n,{items:R}))||R,r=[Q(t,{...n,animationList:e}),nt(t,n)];t.Styles.addSector("animation",{name:"Animation",properties:[{...S,name:"Type",property:y.name,type:"select",full:!0,default:"fadeIn",options:e},{...S,name:"Duration",property:y.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...S,name:"Delay",property:y.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...S,name:"Iteration Count",property:y.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...S,name:"Timing",property:y.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...K,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...q,name:"Animate on Scroll",property:v.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...D,name:"Scroll Threshold",property:v.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...D,name:"Repeat on Scroll",property:v.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),Y({editor:t,licenseKey:n.licenseKey,plan:at,pluginName:et,cleanup:()=>{r.forEach(a=>a())}})},it=W(ot);module.exports=it;
519
+ }`}],it=function(t,n={}){var o;const a=((o=n.animations)==null?void 0:o.call(n,{items:T}))||T,s=[tt(t,{...n,animationList:a}),et(t,n)];t.Styles.addSector("animation",{name:"Animation",properties:[{...S,name:"Type",property:f.name,type:"select",full:!0,default:"fadeIn",options:a},{...S,name:"Duration",property:f.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...S,name:"Delay",property:f.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...S,name:"Iteration Count",property:f.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...S,name:"Timing",property:f.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...q,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...J,name:"Animate on Scroll",property:v.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...L,name:"Scroll Threshold",property:v.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...L,name:"Repeat on Scroll",property:v.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),Y({editor:t,licenseKey:n.licenseKey,plan:ot,pluginName:at,cleanup:()=>{s.forEach(i=>i())}})},st=W(it);module.exports=st;