@aparte/n8n-chat 0.2.0 → 0.3.1

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 (69) hide show
  1. package/README.md +161 -18
  2. package/dist/cards.d.ts +25 -1
  3. package/dist/cdn/chunks/{chunk-CZ5742JA.js → chunk-37ODPEBD.js} +1 -1
  4. package/dist/cdn/chunks/{chunk-CZ5742JA.js.map → chunk-37ODPEBD.js.map} +1 -1
  5. package/dist/cdn/chunks/{chunk-7JR7KL6J.js → chunk-DEOOTEDD.js} +2 -2
  6. package/dist/cdn/chunks/{chunk-7JR7KL6J.js.map → chunk-DEOOTEDD.js.map} +1 -1
  7. package/dist/cdn/chunks/{chunk-VTTH7HGO.js → chunk-NKYV5B7Q.js} +2 -2
  8. package/dist/cdn/chunks/{chunk-VTTH7HGO.js.map → chunk-NKYV5B7Q.js.map} +3 -3
  9. package/dist/cdn/chunks/{chunk-OJFRNS5M.js → chunk-RDVTD2YO.js} +2 -2
  10. package/dist/cdn/chunks/{chunk-OJFRNS5M.js.map → chunk-RDVTD2YO.js.map} +1 -1
  11. package/dist/cdn/chunks/{chunk-IPWLCOPM.js → chunk-U6354LAY.js} +2 -2
  12. package/dist/cdn/chunks/{chunk-IPWLCOPM.js.map → chunk-U6354LAY.js.map} +1 -1
  13. package/dist/cdn/chunks/{chunk-IWAJFJNA.js → chunk-ZNUFBTZ7.js} +8 -5
  14. package/dist/cdn/chunks/chunk-ZNUFBTZ7.js.map +7 -0
  15. package/dist/cdn/chunks/{de-JS3CQEVR.js → de-BCWJVDW5.js} +1 -1
  16. package/dist/cdn/chunks/{de-JS3CQEVR.js.map → de-BCWJVDW5.js.map} +1 -1
  17. package/dist/cdn/chunks/{es-OHKGLFEF.js → es-72JNODLG.js} +1 -1
  18. package/dist/cdn/chunks/{es-OHKGLFEF.js.map → es-72JNODLG.js.map} +1 -1
  19. package/dist/cdn/chunks/{fr-6S44XMU5.js → fr-ZKACSOY5.js} +1 -1
  20. package/dist/cdn/chunks/{fr-6S44XMU5.js.map → fr-ZKACSOY5.js.map} +1 -1
  21. package/dist/cdn/chunks/{highlight-FGIKUPIF.js → highlight-DG2OVLBT.js} +2 -2
  22. package/dist/cdn/chunks/{highlight-FGIKUPIF.js.map → highlight-DG2OVLBT.js.map} +1 -1
  23. package/dist/cdn/chunks/{it-K4WYXXDJ.js → it-SSBBMSGX.js} +1 -1
  24. package/dist/cdn/chunks/{it-K4WYXXDJ.js.map → it-SSBBMSGX.js.map} +1 -1
  25. package/dist/cdn/chunks/{items-S4LF2DJA.js → items-MITCIPF3.js} +3 -3
  26. package/dist/cdn/chunks/{items-S4LF2DJA.js.map → items-MITCIPF3.js.map} +1 -1
  27. package/dist/cdn/chunks/{ja-BN7TZW62.js → ja-NCV4Z63H.js} +1 -1
  28. package/dist/cdn/chunks/{ja-BN7TZW62.js.map → ja-NCV4Z63H.js.map} +1 -1
  29. package/dist/cdn/chunks/{ko-ARHO7UI3.js → ko-VCNS24WV.js} +1 -1
  30. package/dist/cdn/chunks/{ko-ARHO7UI3.js.map → ko-VCNS24WV.js.map} +1 -1
  31. package/dist/cdn/chunks/{link-C46K5O7X.js → link-7JYKZK3A.js} +2 -2
  32. package/dist/cdn/chunks/{link-C46K5O7X.js.map → link-7JYKZK3A.js.map} +1 -1
  33. package/dist/cdn/chunks/{media-QI5BPERX.js → media-7CZBXNEK.js} +2 -2
  34. package/dist/cdn/chunks/{media-QI5BPERX.js.map → media-7CZBXNEK.js.map} +1 -1
  35. package/dist/cdn/chunks/{order-YISYH73K.js → order-CPY2L7MI.js} +2 -2
  36. package/dist/cdn/chunks/{order-YISYH73K.js.map → order-CPY2L7MI.js.map} +1 -1
  37. package/dist/cdn/chunks/{place-UFCH3NQE.js → place-KQ3IA5IV.js} +43 -4
  38. package/dist/cdn/chunks/place-KQ3IA5IV.js.map +7 -0
  39. package/dist/cdn/chunks/{plan-KQWF73QI.js → plan-OKXEPKPV.js} +2 -2
  40. package/dist/cdn/chunks/{plan-KQWF73QI.js.map → plan-OKXEPKPV.js.map} +1 -1
  41. package/dist/cdn/chunks/{product-7UBLOMZ7.js → product-ONQRJRDO.js} +24 -4
  42. package/dist/cdn/chunks/product-ONQRJRDO.js.map +7 -0
  43. package/dist/cdn/chunks/{pt-BR-R7ZRM3GG.js → pt-BR-73MNA3YX.js} +1 -1
  44. package/dist/cdn/chunks/{pt-BR-R7ZRM3GG.js.map → pt-BR-73MNA3YX.js.map} +1 -1
  45. package/dist/cdn/chunks/{ru-FJNIMGMU.js → ru-SCEGVTR4.js} +1 -1
  46. package/dist/cdn/chunks/{ru-FJNIMGMU.js.map → ru-SCEGVTR4.js.map} +1 -1
  47. package/dist/cdn/chunks/{score-O2KEAYDS.js → score-QF27XJUE.js} +2 -2
  48. package/dist/cdn/chunks/{score-O2KEAYDS.js.map → score-QF27XJUE.js.map} +1 -1
  49. package/dist/cdn/chunks/{stats-GSXFRGYZ.js → stats-2W3GFI4P.js} +2 -2
  50. package/dist/cdn/chunks/{stats-GSXFRGYZ.js.map → stats-2W3GFI4P.js.map} +1 -1
  51. package/dist/cdn/chunks/{stock-53NVFLC3.js → stock-RCVJOOH4.js} +2 -2
  52. package/dist/cdn/chunks/{stock-53NVFLC3.js.map → stock-RCVJOOH4.js.map} +1 -1
  53. package/dist/cdn/chunks/{weather-VI2RCU4X.js → weather-NQGN2JOS.js} +2 -2
  54. package/dist/cdn/chunks/{weather-VI2RCU4X.js.map → weather-NQGN2JOS.js.map} +1 -1
  55. package/dist/cdn/chunks/{zh-CN-DUCWBXJP.js → zh-CN-4K6QPBRT.js} +1 -1
  56. package/dist/cdn/chunks/{zh-CN-DUCWBXJP.js.map → zh-CN-4K6QPBRT.js.map} +1 -1
  57. package/dist/cdn/n8n-chat.js +57 -57
  58. package/dist/cdn/n8n-chat.js.map +4 -4
  59. package/dist/create-chat.d.ts +39 -6
  60. package/dist/index.d.ts +3 -0
  61. package/dist/index.js +74 -42
  62. package/dist/index.js.map +1 -1
  63. package/dist/strings.d.ts +1 -1
  64. package/dist/style.css +383 -370
  65. package/dist/theme.css +381 -368
  66. package/package.json +7 -7
  67. package/dist/cdn/chunks/chunk-IWAJFJNA.js.map +0 -7
  68. package/dist/cdn/chunks/place-UFCH3NQE.js.map +0 -7
  69. package/dist/cdn/chunks/product-7UBLOMZ7.js.map +0 -7
@@ -1,4 +1,16 @@
1
+ /**
2
+ * createChat — n8n's chat widget, drawn by aparté, from the same call.
3
+ *
4
+ * The options are `@n8n/chat`'s, under its names and with its defaults, so a page swaps
5
+ * the import and keeps its call: the same webhook, the same session key in the browser
6
+ * (a visitor keeps their conversation across the switch), the same `--chat--*` variables
7
+ * read by the n8n theme. What it adds is what the original lacks: a handle to open, close,
8
+ * send and reset; a real new conversation; French; history without the tool steps; errors
9
+ * that say what to change in n8n; and no style leaking into the page.
10
+ */
11
+ import { AparteConfig } from '@aparte/core';
1
12
  import type { AparteLocale } from '@aparte/core';
13
+ import { type CardOptions } from './cards.js';
2
14
  import type { ChatStrings } from './strings.js';
3
15
  /** `createChat`'s options: `@n8n/chat`'s, under its names and with its defaults. */
4
16
  export interface ChatOptions {
@@ -54,7 +66,7 @@ export interface ChatOptions {
54
66
  /**
55
67
  * The language, as a tag (`'de'`, `'pt-BR'`, `'fr-CA'`): the chrome's words come from
56
68
  * `i18n[defaultLanguage]` over the built-in ones, the chat's own from aparté's locale,
57
- * loaded for that language alone. Nine ship, all left to right: English, French, Spanish,
69
+ * loaded for that language alone. Ten ship, all left to right: English, French, Spanish,
58
70
  * Portuguese (Brazil), German, Italian, Russian, Japanese, Korean and Chinese
59
71
  * (Simplified); another tag reads in English, or in the `locale` you give.
60
72
  * @default 'en'
@@ -78,9 +90,13 @@ export interface ChatOptions {
78
90
  */
79
91
  locale?: AparteLocale;
80
92
  /** Let the person attach files; n8n receives them as `files`. @default false */
81
- allowFileUploads?: boolean;
93
+ allowFileUploads?: boolean | {
94
+ value: boolean;
95
+ };
82
96
  /** What the file picker offers, as an `accept` list (`'image/*,.pdf'`). @default any */
83
- allowedFilesMimeTypes?: string;
97
+ allowedFilesMimeTypes?: string | {
98
+ value: string;
99
+ };
84
100
  /** Accepted for compatibility: a streamed answer and a whole one are both read. */
85
101
  enableStreaming?: boolean;
86
102
  /** Called with the message before it is sent, and awaited. */
@@ -130,9 +146,26 @@ export interface ChatOptions {
130
146
  * Draw a ```card-<name> code block of JSON in an answer as that rich card (`true` by
131
147
  * default): weather, items, product, place, stats, order, stock, plan, score, media,
132
148
  * link. Each card's code is fetched the first time it appears. `false` shows the block as
133
- * code, as n8n's own widget does.
134
- */
135
- cards?: boolean;
149
+ * code, as n8n's own widget does. An object turns them on with each card's own options,
150
+ * handed to it when it loads.
151
+ *
152
+ * @example
153
+ * // The place card on real map tiles (the drawn map, and no request, without them).
154
+ * createChat({ webhookUrl, cards: { place: {
155
+ * mapTiles: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
156
+ * mapAttribution: '© OpenStreetMap contributors',
157
+ * } } });
158
+ */
159
+ cards?: boolean | CardOptions;
160
+ /**
161
+ * Extend the chat with aparté's plugins and your own cards: called once with the widget's
162
+ * config, before the first message. What it returns, if a function, runs on `destroy()`.
163
+ *
164
+ * @example
165
+ * import { setupKatex } from '@aparte/plugin-katex';
166
+ * createChat({ webhookUrl, setup: (config) => setupKatex({}, config) });
167
+ */
168
+ setup?: (config: AparteConfig) => void | (() => void);
136
169
  }
137
170
  /** A `messageHistory` entry: text, or a component drawn by `messageComponents`. */
138
171
  export type ChatHistoryMessage = {
package/dist/index.d.ts CHANGED
@@ -8,4 +8,7 @@
8
8
  */
9
9
  export { createChat } from './create-chat.js';
10
10
  export type { Chat, ChatOptions, ChatResponse } from './create-chat.js';
11
+ export type { CardOptions } from './cards.js';
11
12
  export type { ChatStrings } from './strings.js';
13
+ export { defineCard, el, glyph, safeUrl, webUrl, formatNumber, formatPrice, formatDay, formatWhen } from '@aparte/plugin-cards';
14
+ export type { CardDefinition, CardContext, AparteCardSegment } from '@aparte/plugin-cards';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { uuid, AparteConfig, AparteErrorCode, attachConfig, AparteClient, Aparte
2
2
  import { setupMarkedStreamingProvider } from "@aparte/plugin-marked/streaming";
3
3
  import { setupN8nButtons, createN8nRunner, loadN8nHistory } from "@aparte/runner-n8n";
4
4
  import { setupCardFences } from "@aparte/plugin-cards";
5
+ import { defineCard, el, formatDay, formatNumber, formatPrice, formatWhen, glyph, safeUrl, webUrl } from "@aparte/plugin-cards";
5
6
  const CARDS = {
6
7
  weather: () => import("@aparte/plugin-cards/weather"),
7
8
  items: () => import("@aparte/plugin-cards/items"),
@@ -15,7 +16,18 @@ const CARDS = {
15
16
  media: () => import("@aparte/plugin-cards/media"),
16
17
  link: () => import("@aparte/plugin-cards/link")
17
18
  };
18
- const setupCards = (config) => setupCardFences({ config, load: CARDS });
19
+ const setupName = (card) => `setup${card.charAt(0).toUpperCase()}${card.slice(1)}Card`;
20
+ function setupCards(config, options = {}) {
21
+ const load = Object.fromEntries(Object.entries(CARDS).map(([name, fetch2]) => {
22
+ const own = options[name];
23
+ if (!own) return [name, fetch2];
24
+ return [name, () => fetch2().then((module) => {
25
+ const setup = module[setupName(name)];
26
+ return typeof setup === "function" ? { ...module, [setupName(name)]: (o) => setup({ ...own, ...o }) } : module;
27
+ })];
28
+ }));
29
+ return setupCardFences({ config, load });
30
+ }
19
31
  const bubble = '<svg class="aparte-icon" viewBox="0 0 24 24" fill="currentColor"><path d="M5.5 3.5h13a3 3 0 0 1 3 3v8.5a3 3 0 0 1-3 3h-6.2l-4.8 3.6a.6.6 0 0 1-1-.5v-3.1H5.5a3 3 0 0 1-3-3V6.5a3 3 0 0 1 3-3Z"/></svg>';
20
32
  const chevron = '<svg class="aparte-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9.5 6 6 6-6"/></svg>';
21
33
  const plane = '<svg class="aparte-icon" viewBox="0 0 24 24" fill="currentColor"><path d="M3.4 20.2 21 12.6a.7.7 0 0 0 0-1.2L3.4 3.8a.6.6 0 0 0-.9.7L5 11l8 1-8 1-2.5 6.5a.6.6 0 0 0 .9.7Z"/></svg>';
@@ -181,8 +193,11 @@ function loadLocale(language) {
181
193
  return LANGUAGES[shippedLanguage(language)].locale?.();
182
194
  }
183
195
  function absoluteUrl(url) {
196
+ if (typeof url !== "string" || !url.trim()) {
197
+ throw new TypeError("[aparte] n8n: createChat needs webhookUrl, the Chat Trigger's production URL, the one that ends in /chat.");
198
+ }
184
199
  try {
185
- return new URL(url, typeof location === "undefined" ? void 0 : location.href).href;
200
+ return new URL(url, typeof document === "undefined" ? void 0 : document.baseURI).href;
186
201
  } catch {
187
202
  throw new TypeError(`[aparte] n8n: webhookUrl "${url}" is not a URL. Use the Chat Trigger's production URL, the one that ends in /chat.`);
188
203
  }
@@ -233,13 +248,13 @@ function resolveTarget(target) {
233
248
  if (typeof target !== "string") return target;
234
249
  const found = document.querySelector(target);
235
250
  if (found) return found;
236
- const el2 = document.createElement("div");
237
- if (target.startsWith("#")) el2.id = target.slice(1);
238
- else if (target.startsWith(".")) el2.className = target.slice(1);
239
- document.body.appendChild(el2);
240
- return el2;
251
+ const el22 = document.createElement("div");
252
+ if (target.startsWith("#")) el22.id = target.slice(1);
253
+ else if (target.startsWith(".")) el22.className = target.slice(1);
254
+ document.body.appendChild(el22);
255
+ return el22;
241
256
  }
242
- function el(tag, className, text) {
257
+ function el2(tag, className, text) {
243
258
  const node = document.createElement(tag);
244
259
  if (className) node.className = className;
245
260
  if (text !== void 0) node.textContent = text;
@@ -255,13 +270,15 @@ function createChat(options) {
255
270
  const initial = options.initialMessages ?? initialMessagesFor(language);
256
271
  const instance = ++instances;
257
272
  const titleId = `aparte-n8n-title-${instance}`;
273
+ const returning = loadPrevious && !options.sessionId && Boolean(read(STORAGE_KEY));
258
274
  let sessionId = options.sessionId ?? (loadPrevious ? read(STORAGE_KEY) : void 0) ?? uuid();
259
275
  if (loadPrevious && !options.sessionId) write(STORAGE_KEY, sessionId);
260
276
  const config = new AparteConfig();
261
277
  if (options.locale) config.setLocale(options.locale);
262
278
  let destroyed = false;
279
+ let beforeSetup = config.getLocale();
263
280
  void loadLocale(language)?.then((locale) => {
264
- if (!destroyed && !options.locale) config.setLocale(locale);
281
+ if (!destroyed && !options.locale && config.getLocale() === beforeSetup) config.setLocale(locale);
265
282
  }, (error) => console.warn("[aparte] n8n: the chat's language could not be loaded; it stays in English.", error));
266
283
  config.registerIcons(N8N_ICONS);
267
284
  if (options.enableMessageActions) {
@@ -270,19 +287,19 @@ function createChat(options) {
270
287
  }
271
288
  config.setHostHandlers({ attachmentPreview: true, filePreview: true });
272
289
  setupN8nButtons(config);
273
- const stopCards = options.cards === false ? void 0 : setupCards(config);
290
+ const stopCards = options.cards === false ? void 0 : setupCards(config, typeof options.cards === "object" ? options.cards : {});
274
291
  config.setErrorRenderer(({ message, sentence, code }) => {
275
292
  const workflow = code === WORKFLOW_ERROR;
276
- const card2 = el("div", "aparte-segment aparte-alert aparte-alert--danger aparte-segment-error");
293
+ const card2 = el2("div", "aparte-segment aparte-alert aparte-alert--danger aparte-segment-error");
277
294
  if (code) card2.setAttribute("data-error-code", workflow ? AparteErrorCode.PROVIDER_ERROR : code);
278
- const icon = el("span", "aparte-alert__icon");
295
+ const icon = el2("span", "aparte-alert__icon");
279
296
  icon.innerHTML = config.getIcon("error") || "⚠";
280
- const body = el("div", "aparte-alert__body");
297
+ const body = el2("div", "aparte-alert__body");
281
298
  body.append(
282
- el("div", "aparte-alert__title", config.t("error")),
283
- el("div", "aparte-alert__message", workflow ? config.t("errorNoAnswer") : sentence ?? message)
299
+ el2("div", "aparte-alert__title", config.t("error")),
300
+ el2("div", "aparte-alert__message", workflow ? config.t("errorNoAnswer") : sentence ?? message)
284
301
  );
285
- if (workflow && message) body.append(el("p", "aparte-n8n__error-detail", message));
302
+ if (workflow && message) body.append(el2("p", "aparte-n8n__error-detail", message));
286
303
  card2.append(icon, body);
287
304
  return card2;
288
305
  });
@@ -292,58 +309,62 @@ function createChat(options) {
292
309
  highlighter ??= import("./highlight-DDyMJYBk.js").then((m) => m.createHighlighter());
293
310
  return (await highlighter)(code, lang);
294
311
  });
295
- const card = el("section", "aparte-n8n__window");
312
+ beforeSetup = config.getLocale();
313
+ const stopSetup = options.setup?.(config);
314
+ const card = el2("section", "aparte-n8n__window");
296
315
  card.setAttribute("aria-labelledby", titleId);
297
- const header = el("header", "aparte-n8n__header");
298
- const heading = el("div", "aparte-n8n__heading");
299
- const title = el("p", "aparte-n8n__title", strings.title);
316
+ const header = el2("header", "aparte-n8n__header");
317
+ const heading = el2("div", "aparte-n8n__heading");
318
+ const title = el2("p", "aparte-n8n__title", strings.title);
300
319
  title.id = titleId;
301
320
  heading.append(title);
302
- if (strings.subtitle) heading.append(el("p", "aparte-n8n__subtitle", strings.subtitle));
321
+ if (strings.subtitle) heading.append(el2("p", "aparte-n8n__subtitle", strings.subtitle));
303
322
  header.append(heading);
304
323
  if (mode === "window" && options.showWindowCloseButton) {
305
- const close = el("button", "aparte-btn aparte-btn--icon aparte-btn--ghost aparte-n8n__close");
324
+ const close = el2("button", "aparte-btn aparte-btn--icon aparte-btn--ghost aparte-n8n__close");
306
325
  close.type = "button";
307
326
  close.setAttribute("aria-label", strings.closeButtonTooltip);
308
327
  close.setAttribute("data-aparte-launcher-close", "");
309
- const icon = el("aparte-icon");
328
+ const icon = el2("aparte-icon");
310
329
  icon.setAttribute("name", "close");
311
330
  close.append(icon);
312
331
  header.append(close);
313
332
  }
314
- const chat = el("aparte-chat", "aparte-n8n__chat");
333
+ const chat = el2("aparte-chat", "aparte-n8n__chat");
315
334
  chat.id = `aparte-n8n-chat-${instance}`;
316
335
  if (options.messageComponents) {
317
336
  registerComponentRenderer();
318
337
  componentsByChat.set(chat, options.messageComponents);
319
338
  }
320
- const composer = el("aparte-composer");
339
+ const composer = el2("aparte-composer");
321
340
  composer.setAttribute("placeholder", strings.inputPlaceholder);
322
341
  let suggestions;
323
342
  if (options.suggestions?.length) {
324
- suggestions = el("aparte-suggestions");
343
+ suggestions = el2("aparte-suggestions");
325
344
  suggestions.setAttribute("suggestions", JSON.stringify(options.suggestions.map((text) => ({ label: text, prompt: text }))));
326
345
  composer.append(suggestions);
327
346
  }
328
- const shell = el("div", "aparte-composer-shell");
329
- const row = el("div", "aparte-composer-row");
330
- row.append(el("aparte-composer-input"));
331
- if (options.allowFileUploads) {
332
- shell.append(el("aparte-composer-attachments"));
333
- const add = el("aparte-composer-add-attachment");
334
- if (options.allowedFilesMimeTypes) add.setAttribute("accept", options.allowedFilesMimeTypes);
347
+ const shell = el2("div", "aparte-composer-shell");
348
+ const row = el2("div", "aparte-composer-row");
349
+ row.append(el2("aparte-composer-input"));
350
+ const allowFiles = typeof options.allowFileUploads === "object" ? options.allowFileUploads?.value : options.allowFileUploads;
351
+ const acceptFiles = typeof options.allowedFilesMimeTypes === "object" ? options.allowedFilesMimeTypes?.value : options.allowedFilesMimeTypes;
352
+ if (allowFiles) {
353
+ shell.append(el2("aparte-composer-attachments"));
354
+ const add = el2("aparte-composer-add-attachment");
355
+ if (acceptFiles) add.setAttribute("accept", acceptFiles);
335
356
  row.append(add);
336
357
  }
337
- row.append(el("aparte-composer-send"));
358
+ row.append(el2("aparte-composer-send"));
338
359
  shell.append(row);
339
360
  composer.append(shell);
340
- chat.append(el("aparte-chat-viewport"), el("aparte-elicitation"), composer);
361
+ chat.append(el2("aparte-chat-viewport"), el2("aparte-elicitation"), composer);
341
362
  card.append(header, chat);
342
- if (strings.footer) card.append(el("p", "aparte-n8n__footer", strings.footer));
363
+ if (strings.footer) card.append(el2("p", "aparte-n8n__footer", strings.footer));
343
364
  let welcome;
344
- if (options.showWelcomeScreen) {
345
- welcome = el("div", "aparte-n8n__welcome");
346
- const start = el("button", "aparte-btn aparte-btn--primary aparte-btn--solid aparte-n8n__start", strings.getStarted);
365
+ if (options.showWelcomeScreen && !returning) {
366
+ welcome = el2("div", "aparte-n8n__welcome");
367
+ const start = el2("button", "aparte-btn aparte-btn--primary aparte-btn--solid aparte-n8n__start", strings.getStarted);
347
368
  start.type = "button";
348
369
  start.addEventListener("click", () => {
349
370
  welcome.hidden = true;
@@ -356,10 +377,10 @@ function createChat(options) {
356
377
  }
357
378
  let root;
358
379
  if (mode === "window") {
359
- root = el("aparte-launcher", "aparte-n8n aparte-n8n--window");
380
+ root = el2("aparte-launcher", "aparte-n8n aparte-n8n--window");
360
381
  root.append(card);
361
382
  } else {
362
- root = el("div", "aparte-n8n aparte-n8n--fullscreen");
383
+ root = el2("div", "aparte-n8n aparte-n8n--fullscreen");
363
384
  root.append(card);
364
385
  }
365
386
  const scheme = options.colorScheme ?? "light";
@@ -575,12 +596,14 @@ function createChat(options) {
575
596
  if (typeof options.disabled === "object" ? options.disabled?.value : options.disabled) setDisabled(true);
576
597
  const launcher = () => mode === "window" ? root : void 0;
577
598
  const destroy = () => {
599
+ if (destroyed) return;
578
600
  destroyed = true;
579
601
  historyRequest?.abort();
580
602
  queued.length = 0;
581
603
  window.removeEventListener("aparte-message-aborted", onStopped);
582
604
  client.stop();
583
605
  stopCards?.();
606
+ if (typeof stopSetup === "function") stopSetup();
584
607
  root.remove();
585
608
  };
586
609
  return {
@@ -613,6 +636,15 @@ function createChat(options) {
613
636
  };
614
637
  }
615
638
  export {
616
- createChat
639
+ createChat,
640
+ defineCard,
641
+ el,
642
+ formatDay,
643
+ formatNumber,
644
+ formatPrice,
645
+ formatWhen,
646
+ glyph,
647
+ safeUrl,
648
+ webUrl
617
649
  };
618
650
  //# sourceMappingURL=index.js.map