@botonic/webchat-core 2.23.0

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 (88) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/PR-LOCALE-SUPPORT.md +156 -0
  3. package/README.md +11 -0
  4. package/package.json +29 -0
  5. package/src/index.d.ts +11 -0
  6. package/src/index.js +15 -0
  7. package/src/index.js.map +1 -0
  8. package/src/lib/controllers/index.d.ts +2 -0
  9. package/src/lib/controllers/index.js +3 -0
  10. package/src/lib/controllers/index.js.map +1 -0
  11. package/src/lib/controllers/public.d.ts +383 -0
  12. package/src/lib/controllers/public.js +194 -0
  13. package/src/lib/controllers/public.js.map +1 -0
  14. package/src/lib/controllers/webchat.d.ts +414 -0
  15. package/src/lib/controllers/webchat.js +255 -0
  16. package/src/lib/controllers/webchat.js.map +1 -0
  17. package/src/lib/domain/index.d.ts +50 -0
  18. package/src/lib/domain/index.js +11 -0
  19. package/src/lib/domain/index.js.map +1 -0
  20. package/src/lib/infra/clients/hubtype-api.d.ts +53 -0
  21. package/src/lib/infra/clients/hubtype-api.js +189 -0
  22. package/src/lib/infra/clients/hubtype-api.js.map +1 -0
  23. package/src/lib/infra/clients/index.d.ts +3 -0
  24. package/src/lib/infra/clients/index.js +4 -0
  25. package/src/lib/infra/clients/index.js.map +1 -0
  26. package/src/lib/infra/clients/realtime.d.ts +92 -0
  27. package/src/lib/infra/clients/realtime.js +277 -0
  28. package/src/lib/infra/clients/realtime.js.map +1 -0
  29. package/src/lib/infra/clients/types.d.ts +21 -0
  30. package/src/lib/infra/clients/types.js +2 -0
  31. package/src/lib/infra/clients/types.js.map +1 -0
  32. package/src/lib/infra/repositories/index.d.ts +1 -0
  33. package/src/lib/infra/repositories/index.js +2 -0
  34. package/src/lib/infra/repositories/index.js.map +1 -0
  35. package/src/lib/infra/repositories/storage/base-storage.d.ts +23 -0
  36. package/src/lib/infra/repositories/storage/base-storage.js +102 -0
  37. package/src/lib/infra/repositories/storage/base-storage.js.map +1 -0
  38. package/src/lib/infra/repositories/storage/browser-storage.d.ts +9 -0
  39. package/src/lib/infra/repositories/storage/browser-storage.js +46 -0
  40. package/src/lib/infra/repositories/storage/browser-storage.js.map +1 -0
  41. package/src/lib/infra/repositories/storage/factory.d.ts +2 -0
  42. package/src/lib/infra/repositories/storage/factory.js +20 -0
  43. package/src/lib/infra/repositories/storage/factory.js.map +1 -0
  44. package/src/lib/infra/repositories/storage/in-memory.d.ts +9 -0
  45. package/src/lib/infra/repositories/storage/in-memory.js +21 -0
  46. package/src/lib/infra/repositories/storage/in-memory.js.map +1 -0
  47. package/src/lib/infra/repositories/storage/index.d.ts +7 -0
  48. package/src/lib/infra/repositories/storage/index.js +7 -0
  49. package/src/lib/infra/repositories/storage/index.js.map +1 -0
  50. package/src/lib/infra/repositories/storage/local-storage.d.ts +4 -0
  51. package/src/lib/infra/repositories/storage/local-storage.js +7 -0
  52. package/src/lib/infra/repositories/storage/local-storage.js.map +1 -0
  53. package/src/lib/infra/repositories/storage/session-storage.d.ts +4 -0
  54. package/src/lib/infra/repositories/storage/session-storage.js +7 -0
  55. package/src/lib/infra/repositories/storage/session-storage.js.map +1 -0
  56. package/src/lib/infra/repositories/storage/types.d.ts +30 -0
  57. package/src/lib/infra/repositories/storage/types.js +2 -0
  58. package/src/lib/infra/repositories/storage/types.js.map +1 -0
  59. package/src/lib/machines/message.d.ts +200 -0
  60. package/src/lib/machines/message.js +210 -0
  61. package/src/lib/machines/message.js.map +1 -0
  62. package/src/lib/machines/overlay.d.ts +299 -0
  63. package/src/lib/machines/overlay.js +217 -0
  64. package/src/lib/machines/overlay.js.map +1 -0
  65. package/src/lib/machines/webchat.d.ts +641 -0
  66. package/src/lib/machines/webchat.js +768 -0
  67. package/src/lib/machines/webchat.js.map +1 -0
  68. package/src/lib/services/webchat-service.d.ts +125 -0
  69. package/src/lib/services/webchat-service.js +339 -0
  70. package/src/lib/services/webchat-service.js.map +1 -0
  71. package/src/lib/utils/locale-detection.d.ts +2 -0
  72. package/src/lib/utils/locale-detection.js +20 -0
  73. package/src/lib/utils/locale-detection.js.map +1 -0
  74. package/src/lib/utils/timezone-to-country.d.ts +1 -0
  75. package/src/lib/utils/timezone-to-country.js +105 -0
  76. package/src/lib/utils/timezone-to-country.js.map +1 -0
  77. package/src/lib/webview/constants.d.ts +10 -0
  78. package/src/lib/webview/constants.js +10 -0
  79. package/src/lib/webview/constants.js.map +1 -0
  80. package/src/lib/webview/index.d.ts +3 -0
  81. package/src/lib/webview/index.js +4 -0
  82. package/src/lib/webview/index.js.map +1 -0
  83. package/src/lib/webview/types.d.ts +35 -0
  84. package/src/lib/webview/types.js +16 -0
  85. package/src/lib/webview/types.js.map +1 -0
  86. package/src/lib/webview/utils.d.ts +9 -0
  87. package/src/lib/webview/utils.js +33 -0
  88. package/src/lib/webview/utils.js.map +1 -0
@@ -0,0 +1,299 @@
1
+ import { ActorRefFrom } from 'xstate';
2
+ import { ConfirmCloseOption, OverlayState } from '../domain';
3
+ export interface OverlayMachineTypes {
4
+ context: {
5
+ overlayState: OverlayState | null;
6
+ };
7
+ input: {
8
+ initialState?: OverlayState | null;
9
+ };
10
+ events: {
11
+ type: 'OPEN_WEBVIEW';
12
+ url: string;
13
+ title?: string;
14
+ icon?: string;
15
+ allowClose?: boolean;
16
+ } | {
17
+ type: 'OPEN_COVER';
18
+ componentId: string;
19
+ title?: string;
20
+ icon?: string;
21
+ props?: Record<string, unknown>;
22
+ allowClose?: boolean;
23
+ } | {
24
+ type: 'CLOSE';
25
+ } | {
26
+ type: 'SET_TITLE';
27
+ title: string;
28
+ } | {
29
+ type: 'SET_ICON';
30
+ icon: string;
31
+ } | {
32
+ type: 'SET_ALLOW_CLOSE';
33
+ allow: boolean;
34
+ } | {
35
+ type: 'SET_CONFIRM_CLOSE';
36
+ config: ConfirmCloseOption;
37
+ } | {
38
+ type: 'NAVIGATE';
39
+ url: string;
40
+ } | {
41
+ type: 'SEND_PAYLOAD';
42
+ payload: unknown;
43
+ };
44
+ emitted: {
45
+ type: 'WEBVIEW_OPENED';
46
+ url: string;
47
+ title: string;
48
+ } | {
49
+ type: 'WEBVIEW_CLOSED';
50
+ } | {
51
+ type: 'WEBVIEW_PAYLOAD';
52
+ payload: unknown;
53
+ } | {
54
+ type: 'COVER_OPENED';
55
+ componentId: string;
56
+ title: string;
57
+ } | {
58
+ type: 'COVER_CLOSED';
59
+ } | {
60
+ type: 'OVERLAY_CLOSED';
61
+ };
62
+ }
63
+ export declare const OverlayMachine: import("xstate").StateMachine<{
64
+ overlayState: OverlayState | null;
65
+ }, {
66
+ type: "OPEN_WEBVIEW";
67
+ url: string;
68
+ title?: string;
69
+ icon?: string;
70
+ allowClose?: boolean;
71
+ } | {
72
+ type: "OPEN_COVER";
73
+ componentId: string;
74
+ title?: string;
75
+ icon?: string;
76
+ props?: Record<string, unknown>;
77
+ allowClose?: boolean;
78
+ } | {
79
+ type: "CLOSE";
80
+ } | {
81
+ type: "SET_TITLE";
82
+ title: string;
83
+ } | {
84
+ type: "SET_ICON";
85
+ icon: string;
86
+ } | {
87
+ type: "SET_ALLOW_CLOSE";
88
+ allow: boolean;
89
+ } | {
90
+ type: "SET_CONFIRM_CLOSE";
91
+ config: ConfirmCloseOption;
92
+ } | {
93
+ type: "NAVIGATE";
94
+ url: string;
95
+ } | {
96
+ type: "SEND_PAYLOAD";
97
+ payload: unknown;
98
+ }, {}, never, {
99
+ type: "setWebviewState";
100
+ params: import("xstate").NonReducibleUnknown;
101
+ } | {
102
+ type: "emitWebviewOpened";
103
+ params: import("xstate").NonReducibleUnknown;
104
+ } | {
105
+ type: "navigateWebview";
106
+ params: import("xstate").NonReducibleUnknown;
107
+ } | {
108
+ type: "emitWebviewPayload";
109
+ params: import("xstate").NonReducibleUnknown;
110
+ } | {
111
+ type: "emitWebviewClosed";
112
+ params: import("xstate").NonReducibleUnknown;
113
+ } | {
114
+ type: "setCoverState";
115
+ params: import("xstate").NonReducibleUnknown;
116
+ } | {
117
+ type: "emitCoverOpened";
118
+ params: import("xstate").NonReducibleUnknown;
119
+ } | {
120
+ type: "emitCoverClosed";
121
+ params: import("xstate").NonReducibleUnknown;
122
+ } | {
123
+ type: "closeOverlay";
124
+ params: import("xstate").NonReducibleUnknown;
125
+ } | {
126
+ type: "emitOverlayClosed";
127
+ params: import("xstate").NonReducibleUnknown;
128
+ } | {
129
+ type: "emitTypeSpecificClosed";
130
+ params: import("xstate").NonReducibleUnknown;
131
+ } | {
132
+ type: "updateOverlayTitle";
133
+ params: import("xstate").NonReducibleUnknown;
134
+ } | {
135
+ type: "updateOverlayIcon";
136
+ params: import("xstate").NonReducibleUnknown;
137
+ } | {
138
+ type: "setOverlayAllowClose";
139
+ params: import("xstate").NonReducibleUnknown;
140
+ } | {
141
+ type: "setOverlayConfirmClose";
142
+ params: import("xstate").NonReducibleUnknown;
143
+ }, {
144
+ type: "isWebview";
145
+ params: unknown;
146
+ } | {
147
+ type: "isCover";
148
+ params: unknown;
149
+ } | {
150
+ type: "hasOverlay";
151
+ params: unknown;
152
+ }, never, "idle" | "open", string, {
153
+ initialState?: OverlayState | null;
154
+ }, import("xstate").NonReducibleUnknown, {
155
+ type: "WEBVIEW_OPENED";
156
+ url: string;
157
+ title: string;
158
+ } | {
159
+ type: "WEBVIEW_CLOSED";
160
+ } | {
161
+ type: "WEBVIEW_PAYLOAD";
162
+ payload: unknown;
163
+ } | {
164
+ type: "COVER_OPENED";
165
+ componentId: string;
166
+ title: string;
167
+ } | {
168
+ type: "COVER_CLOSED";
169
+ } | {
170
+ type: "OVERLAY_CLOSED";
171
+ }, import("xstate").MetaObject, {
172
+ id: "overlay";
173
+ states: {
174
+ readonly idle: {};
175
+ readonly open: {};
176
+ };
177
+ }>;
178
+ /**
179
+ * Factory function to create overlay machine logic
180
+ * Returns machine logic suitable for spawning within another machine
181
+ */
182
+ export declare function createOverlayMachine(): import("xstate").StateMachine<{
183
+ overlayState: OverlayState | null;
184
+ }, {
185
+ type: "OPEN_WEBVIEW";
186
+ url: string;
187
+ title?: string;
188
+ icon?: string;
189
+ allowClose?: boolean;
190
+ } | {
191
+ type: "OPEN_COVER";
192
+ componentId: string;
193
+ title?: string;
194
+ icon?: string;
195
+ props?: Record<string, unknown>;
196
+ allowClose?: boolean;
197
+ } | {
198
+ type: "CLOSE";
199
+ } | {
200
+ type: "SET_TITLE";
201
+ title: string;
202
+ } | {
203
+ type: "SET_ICON";
204
+ icon: string;
205
+ } | {
206
+ type: "SET_ALLOW_CLOSE";
207
+ allow: boolean;
208
+ } | {
209
+ type: "SET_CONFIRM_CLOSE";
210
+ config: ConfirmCloseOption;
211
+ } | {
212
+ type: "NAVIGATE";
213
+ url: string;
214
+ } | {
215
+ type: "SEND_PAYLOAD";
216
+ payload: unknown;
217
+ }, {}, never, {
218
+ type: "setWebviewState";
219
+ params: import("xstate").NonReducibleUnknown;
220
+ } | {
221
+ type: "emitWebviewOpened";
222
+ params: import("xstate").NonReducibleUnknown;
223
+ } | {
224
+ type: "navigateWebview";
225
+ params: import("xstate").NonReducibleUnknown;
226
+ } | {
227
+ type: "emitWebviewPayload";
228
+ params: import("xstate").NonReducibleUnknown;
229
+ } | {
230
+ type: "emitWebviewClosed";
231
+ params: import("xstate").NonReducibleUnknown;
232
+ } | {
233
+ type: "setCoverState";
234
+ params: import("xstate").NonReducibleUnknown;
235
+ } | {
236
+ type: "emitCoverOpened";
237
+ params: import("xstate").NonReducibleUnknown;
238
+ } | {
239
+ type: "emitCoverClosed";
240
+ params: import("xstate").NonReducibleUnknown;
241
+ } | {
242
+ type: "closeOverlay";
243
+ params: import("xstate").NonReducibleUnknown;
244
+ } | {
245
+ type: "emitOverlayClosed";
246
+ params: import("xstate").NonReducibleUnknown;
247
+ } | {
248
+ type: "emitTypeSpecificClosed";
249
+ params: import("xstate").NonReducibleUnknown;
250
+ } | {
251
+ type: "updateOverlayTitle";
252
+ params: import("xstate").NonReducibleUnknown;
253
+ } | {
254
+ type: "updateOverlayIcon";
255
+ params: import("xstate").NonReducibleUnknown;
256
+ } | {
257
+ type: "setOverlayAllowClose";
258
+ params: import("xstate").NonReducibleUnknown;
259
+ } | {
260
+ type: "setOverlayConfirmClose";
261
+ params: import("xstate").NonReducibleUnknown;
262
+ }, {
263
+ type: "isWebview";
264
+ params: unknown;
265
+ } | {
266
+ type: "isCover";
267
+ params: unknown;
268
+ } | {
269
+ type: "hasOverlay";
270
+ params: unknown;
271
+ }, never, "idle" | "open", string, {
272
+ initialState?: OverlayState | null;
273
+ }, import("xstate").NonReducibleUnknown, {
274
+ type: "WEBVIEW_OPENED";
275
+ url: string;
276
+ title: string;
277
+ } | {
278
+ type: "WEBVIEW_CLOSED";
279
+ } | {
280
+ type: "WEBVIEW_PAYLOAD";
281
+ payload: unknown;
282
+ } | {
283
+ type: "COVER_OPENED";
284
+ componentId: string;
285
+ title: string;
286
+ } | {
287
+ type: "COVER_CLOSED";
288
+ } | {
289
+ type: "OVERLAY_CLOSED";
290
+ }, import("xstate").MetaObject, {
291
+ id: "overlay";
292
+ states: {
293
+ readonly idle: {};
294
+ readonly open: {};
295
+ };
296
+ }>;
297
+ export type OverlayMachineActor = ActorRefFrom<typeof OverlayMachine>;
298
+ export type OverlayEmittedEvent = OverlayMachineTypes['emitted'];
299
+ export type OverlayEvent = OverlayMachineTypes['events'];
@@ -0,0 +1,217 @@
1
+ import { assertEvent, assign, emit, setup } from 'xstate';
2
+ // ============================================================================
3
+ // Overlay Machine
4
+ // ============================================================================
5
+ export const OverlayMachine = setup({
6
+ types: {},
7
+ guards: {
8
+ isWebview: ({ context }) => { var _a; return ((_a = context.overlayState) === null || _a === void 0 ? void 0 : _a.type) === 'webview'; },
9
+ isCover: ({ context }) => { var _a; return ((_a = context.overlayState) === null || _a === void 0 ? void 0 : _a.type) === 'cover'; },
10
+ hasOverlay: ({ context }) => context.overlayState !== null,
11
+ },
12
+ actions: {
13
+ // ========================================================================
14
+ // Webview Actions
15
+ // ========================================================================
16
+ setWebviewState: assign({
17
+ overlayState: ({ event }) => {
18
+ var _a;
19
+ assertEvent(event, 'OPEN_WEBVIEW');
20
+ return {
21
+ type: 'webview',
22
+ isOpen: true,
23
+ url: event.url,
24
+ title: event.title || '',
25
+ icon: event.icon,
26
+ allowClose: (_a = event.allowClose) !== null && _a !== void 0 ? _a : true,
27
+ };
28
+ },
29
+ }),
30
+ emitWebviewOpened: emit(({ event }) => {
31
+ assertEvent(event, 'OPEN_WEBVIEW');
32
+ return {
33
+ type: 'WEBVIEW_OPENED',
34
+ url: event.url,
35
+ title: event.title || '',
36
+ };
37
+ }),
38
+ navigateWebview: assign({
39
+ overlayState: ({ context, event }) => {
40
+ assertEvent(event, 'NAVIGATE');
41
+ // If no overlay or not a webview, return current state unchanged (no-op)
42
+ if (!context.overlayState || context.overlayState.type !== 'webview') {
43
+ return context.overlayState;
44
+ }
45
+ return Object.assign(Object.assign({}, context.overlayState), { url: event.url });
46
+ },
47
+ }),
48
+ emitWebviewPayload: emit(({ event }) => {
49
+ assertEvent(event, 'SEND_PAYLOAD');
50
+ return {
51
+ type: 'WEBVIEW_PAYLOAD',
52
+ payload: event.payload,
53
+ };
54
+ }),
55
+ emitWebviewClosed: emit(() => ({
56
+ type: 'WEBVIEW_CLOSED',
57
+ })),
58
+ // ========================================================================
59
+ // Cover Actions
60
+ // ========================================================================
61
+ setCoverState: assign({
62
+ overlayState: ({ event }) => {
63
+ var _a;
64
+ assertEvent(event, 'OPEN_COVER');
65
+ return {
66
+ type: 'cover',
67
+ isOpen: true,
68
+ componentId: event.componentId,
69
+ title: event.title || '',
70
+ icon: event.icon,
71
+ props: event.props,
72
+ allowClose: (_a = event.allowClose) !== null && _a !== void 0 ? _a : true,
73
+ };
74
+ },
75
+ }),
76
+ emitCoverOpened: emit(({ event }) => {
77
+ assertEvent(event, 'OPEN_COVER');
78
+ return {
79
+ type: 'COVER_OPENED',
80
+ componentId: event.componentId,
81
+ title: event.title || '',
82
+ };
83
+ }),
84
+ emitCoverClosed: emit(() => ({
85
+ type: 'COVER_CLOSED',
86
+ })),
87
+ // ========================================================================
88
+ // Generic Overlay Actions
89
+ // ========================================================================
90
+ closeOverlay: assign({
91
+ overlayState: () => null,
92
+ }),
93
+ emitOverlayClosed: emit(() => ({
94
+ type: 'OVERLAY_CLOSED',
95
+ })),
96
+ // Emit type-specific closed event based on current overlay type
97
+ emitTypeSpecificClosed: emit(({ context }) => {
98
+ var _a, _b;
99
+ if (((_a = context.overlayState) === null || _a === void 0 ? void 0 : _a.type) === 'webview') {
100
+ return { type: 'WEBVIEW_CLOSED' };
101
+ }
102
+ if (((_b = context.overlayState) === null || _b === void 0 ? void 0 : _b.type) === 'cover') {
103
+ return { type: 'COVER_CLOSED' };
104
+ }
105
+ // Fallback to generic event if no overlay is open
106
+ return { type: 'OVERLAY_CLOSED' };
107
+ }),
108
+ updateOverlayTitle: assign({
109
+ overlayState: ({ context, event }) => {
110
+ assertEvent(event, 'SET_TITLE');
111
+ if (!context.overlayState)
112
+ return null;
113
+ return Object.assign(Object.assign({}, context.overlayState), { title: event.title });
114
+ },
115
+ }),
116
+ updateOverlayIcon: assign({
117
+ overlayState: ({ context, event }) => {
118
+ assertEvent(event, 'SET_ICON');
119
+ if (!context.overlayState)
120
+ return null;
121
+ return Object.assign(Object.assign({}, context.overlayState), { icon: event.icon });
122
+ },
123
+ }),
124
+ setOverlayAllowClose: assign({
125
+ overlayState: ({ context, event }) => {
126
+ assertEvent(event, 'SET_ALLOW_CLOSE');
127
+ if (!context.overlayState)
128
+ return null;
129
+ return Object.assign(Object.assign({}, context.overlayState), { allowClose: event.allow });
130
+ },
131
+ }),
132
+ setOverlayConfirmClose: assign({
133
+ overlayState: ({ context, event }) => {
134
+ assertEvent(event, 'SET_CONFIRM_CLOSE');
135
+ if (!context.overlayState)
136
+ return null;
137
+ return Object.assign(Object.assign({}, context.overlayState), { confirmClose: event.config });
138
+ },
139
+ }),
140
+ },
141
+ }).createMachine({
142
+ /** @xstate-layout N4IgpgJg5mDOIC5QHsBuYBOAbAhgTwDoBLCLMAYgHkAFAUQDkB9AdVoCEA1ASVuYG0ADAF1EoAA7JYRAC5FkAO1EgAHogCMAZjUENADgDsAFgCcAJg0D9G4wDYNAGhB5EV3QUsH9u4ye+6NAL4BjmiYuIQkZFR0TADClBy0AEqCIkggElKyCkqqCJraekZmFla2Dk6IugCsbmpqNqbG1Rq1NtX6QSHo2PgEyGJg8uSxADKUAMq0qUqZMnKK6XkFOgYm5pbWdo7OCNVm7i361aamavoCGqddIKG9hAND5FMAKowvXC+j08KzkvM5JaIDT6fQ6QwCGy6ATVGyGIyGDQVXb6A4CdEwxoCUx2Wo3O7hfqDYavRhceL0GbpObZRagPIgsF2NRNXSmWHGY7GHaIGycgjNdHVAT1VG6RH4nqEx4k2hvACCo3GzEYY0mPzS4n+tNywKhBHhajMhhZ1XOlh5CBslwFGMMEKRjslYT6MuectVlHoADEuEkALKq8ZTKlarILXUIDTWnT6I2Gcy6NT7fzIxDC4wEGrokE+XRQ5PO+5Ep70eXcADi8peGr+4cB9OB1UMAsaLVMAmMVwEhl0lpN1SzGK0+YdIqL0uJ7voABFGNR5QBNcbymehjLaiNAqMXAi1FnNI1qTumPuVKNnAjHdHs0FdrydYK3KWuqc0BgsdjcXjrmlbxs7gIBDtI0xj5jYri1JaHbaHG7KdiCkJGrYE6vk875xAkyS-puDYqMCqLAbCFiGI0ugGMeNiWkmwHFGYthqPmLKGEET7yMgEBwEoBL4HWAJ0vhCAALRUeeInuBiliXI0rQ9o+3QuhEpBgHxOrbgmlqgkB+Y5hovbiuKNioQ8xKqf+gkJhoWbCnJkI2Go8J6dRxjaDC6KNKe+ieaYrEBEAA */
143
+ id: 'overlay',
144
+ context: ({ input }) => {
145
+ var _a;
146
+ return ({
147
+ overlayState: (_a = input === null || input === void 0 ? void 0 : input.initialState) !== null && _a !== void 0 ? _a : null,
148
+ });
149
+ },
150
+ initial: 'idle',
151
+ states: {
152
+ idle: {
153
+ on: {
154
+ OPEN_WEBVIEW: {
155
+ target: 'open',
156
+ actions: ['setWebviewState', 'emitWebviewOpened'],
157
+ },
158
+ OPEN_COVER: {
159
+ target: 'open',
160
+ actions: ['setCoverState', 'emitCoverOpened'],
161
+ },
162
+ },
163
+ },
164
+ open: {
165
+ on: {
166
+ // Close the overlay
167
+ CLOSE: {
168
+ target: 'idle',
169
+ actions: [
170
+ 'emitTypeSpecificClosed',
171
+ 'closeOverlay',
172
+ 'emitOverlayClosed',
173
+ ],
174
+ },
175
+ // Update overlay properties
176
+ SET_TITLE: {
177
+ actions: ['updateOverlayTitle'],
178
+ },
179
+ SET_ICON: {
180
+ actions: ['updateOverlayIcon'],
181
+ },
182
+ SET_ALLOW_CLOSE: {
183
+ actions: ['setOverlayAllowClose'],
184
+ },
185
+ SET_CONFIRM_CLOSE: {
186
+ actions: ['setOverlayConfirmClose'],
187
+ },
188
+ // Webview-specific actions (only work when webview is open)
189
+ NAVIGATE: {
190
+ guard: 'isWebview',
191
+ actions: ['navigateWebview'],
192
+ },
193
+ SEND_PAYLOAD: {
194
+ actions: ['emitWebviewPayload'],
195
+ },
196
+ // Allow opening a new overlay while one is already open (replaces current)
197
+ OPEN_WEBVIEW: {
198
+ actions: ['setWebviewState', 'emitWebviewOpened'],
199
+ },
200
+ OPEN_COVER: {
201
+ actions: ['setCoverState', 'emitCoverOpened'],
202
+ },
203
+ },
204
+ },
205
+ },
206
+ });
207
+ // ============================================================================
208
+ // Factory Functions
209
+ // ============================================================================
210
+ /**
211
+ * Factory function to create overlay machine logic
212
+ * Returns machine logic suitable for spawning within another machine
213
+ */
214
+ export function createOverlayMachine() {
215
+ return OverlayMachine;
216
+ }
217
+ //# sourceMappingURL=overlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/webchat-core/src/lib/machines/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAoDv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