@opencx/widget-core 4.0.42 → 4.0.44

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.
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import N from "openapi-fetch";
1
+ import R from "openapi-fetch";
2
2
  import D from "lodash.isequal";
3
3
  import { v4 as E } from "uuid";
4
- const F = (_) => {
4
+ const V = (_) => {
5
5
  console.log(_.error);
6
- }, V = (_) => {
7
- const a = N({
6
+ }, F = (_) => {
7
+ const a = R({
8
8
  baseUrl: _.baseUrl
9
9
  }), n = {
10
10
  onRequest: _.onRequest,
11
11
  onResponse: _.onResponse,
12
- onError: _.onError || F
12
+ onError: _.onError || V
13
13
  };
14
14
  return a.use(n), a;
15
15
  };
16
- class j {
16
+ class A {
17
17
  constructor({ config: a }) {
18
18
  var h, s;
19
19
  this.userToken = null, this.constructClientOptions = (e) => {
@@ -27,7 +27,7 @@ class j {
27
27
  }, this.createOpenAPIClient = ({
28
28
  baseUrl: e,
29
29
  headers: t
30
- }) => V({
30
+ }) => F({
31
31
  baseUrl: e,
32
32
  onRequest: ({ request: o }) => {
33
33
  Object.entries(t).forEach(([i, l]) => {
@@ -143,7 +143,7 @@ class S {
143
143
  }), this.state = a, this.initialState = a;
144
144
  }
145
145
  }
146
- class U {
146
+ class L {
147
147
  constructor() {
148
148
  this.state = new S({
149
149
  isPolling: !1,
@@ -172,7 +172,7 @@ class U {
172
172
  };
173
173
  }
174
174
  }
175
- function L(_) {
175
+ function U(_) {
176
176
  try {
177
177
  const a = _();
178
178
  return a instanceof Promise ? a.then((n) => ({ data: n })).catch((n) => ({ error: n })) : { data: a };
@@ -188,7 +188,7 @@ class K {
188
188
  messageCtx: h,
189
189
  sessionPollingIntervalSeconds: s
190
190
  }) {
191
- this.poller = new U(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.registerPolling = () => {
191
+ this.poller = new L(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.registerPolling = () => {
192
192
  this.sessionCtx.sessionState.subscribe(({ session: e }) => {
193
193
  e != null && e.id ? this.poller.startPolling(async (t) => {
194
194
  this.fetchSessionAndHistory({ sessionId: e.id, abortSignal: t });
@@ -335,7 +335,7 @@ class K {
335
335
  const t = e.result;
336
336
  if (t === null || typeof t != "object") return t;
337
337
  if ("responseBodyText" in t && typeof t.responseBodyText == "string") {
338
- const o = t.responseBodyText, i = L(() => JSON.parse(o)).data;
338
+ const o = t.responseBodyText, i = U(() => JSON.parse(o)).data;
339
339
  if (i) return i;
340
340
  }
341
341
  return e.result;
@@ -406,7 +406,7 @@ class H {
406
406
  function C() {
407
407
  return E();
408
408
  }
409
- class q {
409
+ class J {
410
410
  constructor({
411
411
  config: a,
412
412
  api: n,
@@ -445,14 +445,14 @@ class q {
445
445
  }, this.config = a, this.api = n, this.sessionCtx = r, this.messageCtx = h;
446
446
  }
447
447
  }
448
- class J {
448
+ class q {
449
449
  constructor({
450
450
  config: a,
451
451
  api: n,
452
452
  contactCtx: r,
453
453
  sessionsPollingIntervalSeconds: h
454
454
  }) {
455
- this.sessionsRefresher = new U(), this.sessionState = new S({
455
+ this.sessionsRefresher = new L(), this.sessionState = new S({
456
456
  session: null,
457
457
  isCreatingSession: !1,
458
458
  isResolvingSession: !1
@@ -481,7 +481,7 @@ class J {
481
481
  Object.entries(this.config.sessionCustomData || {}).map(
482
482
  ([s, e]) => {
483
483
  var t;
484
- return typeof e == "string" ? [s, e] : typeof e == "boolean" ? [s, e] : typeof e == "number" ? [s, e] : [s, ((t = L(() => JSON.stringify(e))) == null ? void 0 : t.data) || ""];
484
+ return typeof e == "string" ? [s, e] : typeof e == "boolean" ? [s, e] : typeof e == "number" ? [s, e] : [s, ((t = U(() => JSON.stringify(e))) == null ? void 0 : t.data) || ""];
485
485
  }
486
486
  )
487
487
  ), this.createSession = async () => {
@@ -583,7 +583,7 @@ class Y {
583
583
  isSendingMessage: !0,
584
584
  isSendingMessageToAI: !!y || !d
585
585
  });
586
- const P = this.state.get().messages, z = !((e = this.sessionCtx.sessionState.get().session) != null && e.id) && P.length === 0 && ((t = this.config.advancedInitialMessages) == null ? void 0 : t.some((g) => g.persistent)), A = z ? (this.config.advancedInitialMessages || []).filter((g) => g.persistent).map(
586
+ const I = this.state.get().messages, P = !((e = this.sessionCtx.sessionState.get().session) != null && e.id) && I.length === 0 && ((t = this.config.advancedInitialMessages) == null ? void 0 : t.some((g) => g.persistent)), j = P ? (this.config.advancedInitialMessages || []).filter((g) => g.persistent).map(
587
587
  (g) => ({
588
588
  id: C(),
589
589
  component: "bot_message",
@@ -594,15 +594,15 @@ class Y {
594
594
  },
595
595
  agent: this.config.bot ? { ...this.config.bot, isAi: !0, id: null } : void 0
596
596
  })
597
- ) : [], I = this.toUserMessage(
597
+ ) : [], z = this.toUserMessage(
598
598
  s.content.trim(),
599
599
  s.attachments || void 0
600
600
  );
601
601
  if (this.state.setPartial({
602
602
  messages: [
603
- ...A,
604
- ...P,
605
- I
603
+ ...j,
604
+ ...I,
605
+ z
606
606
  ]
607
607
  }), !((o = this.sessionCtx.sessionState.get().session) != null && o.id)) {
608
608
  if (!await this.sessionCtx.createSession()) {
@@ -615,13 +615,13 @@ class Y {
615
615
  if (!T) return;
616
616
  const { data: m } = await this.api.sendMessage(
617
617
  {
618
- uuid: I.id,
618
+ uuid: z.id,
619
619
  bot_token: this.config.token,
620
620
  headers: this.config.headers,
621
621
  query_params: this.config.queryParams,
622
622
  body_properties: this.config.bodyProperties,
623
623
  session_id: T,
624
- content: I.content,
624
+ content: z.content,
625
625
  attachments: s.attachments,
626
626
  clientContext: this.config.context,
627
627
  custom_data: {
@@ -630,7 +630,7 @@ class Y {
630
630
  },
631
631
  language: this.config.language,
632
632
  exit_mode_prompt: s.exitModePrompt,
633
- initial_messages: z ? A.map((g) => ({
633
+ initial_messages: P ? j.map((g) => ({
634
634
  uuid: g.id,
635
635
  content: g.data.message
636
636
  })) : void 0
@@ -642,7 +642,7 @@ class Y {
642
642
  if (g) {
643
643
  const x = this.state.get().messages;
644
644
  if (!!x.some(
645
- (R) => R.id === g.id
645
+ (O) => O.id === g.id
646
646
  )) {
647
647
  this.state.setPartial({
648
648
  lastAIResMightSolveUserIssue: ((l = m.autopilotResponse) == null ? void 0 : l.mightSolveUserIssue) || ((c = m.uiResponse) == null ? void 0 : c.mightSolveUserIssue)
@@ -723,7 +723,7 @@ ${s}` : s;
723
723
  }), this.config = a, this.api = n, this.sessionCtx = r, this.contactCtx = h;
724
724
  }
725
725
  }
726
- class $ {
726
+ class G {
727
727
  constructor({
728
728
  config: a,
729
729
  contactCtx: n,
@@ -763,7 +763,7 @@ class $ {
763
763
  }), this.registerRoutingListener();
764
764
  }
765
765
  }
766
- class G {
766
+ class $ {
767
767
  constructor({
768
768
  storage: a,
769
769
  config: n
@@ -791,11 +791,11 @@ const f = class f {
791
791
  throw Error(
792
792
  "Widget polling values are not defined, did you call WidgetCtx.initialize()"
793
793
  );
794
- this.config = a, this.org = h, this.api = new j({ config: a }), this.storageCtx = n ? new G({ storage: n, config: a }) : void 0, this.modes = r, this.contactCtx = new H({
794
+ this.config = a, this.org = h, this.api = new A({ config: a }), this.storageCtx = n ? new $({ storage: n, config: a }) : void 0, this.modes = r, this.contactCtx = new H({
795
795
  api: this.api,
796
796
  config: this.config,
797
797
  storageCtx: this.storageCtx
798
- }), this.sessionCtx = new J({
798
+ }), this.sessionCtx = new q({
799
799
  config: this.config,
800
800
  api: this.api,
801
801
  contactCtx: this.contactCtx,
@@ -805,7 +805,7 @@ const f = class f {
805
805
  api: this.api,
806
806
  sessionCtx: this.sessionCtx,
807
807
  contactCtx: this.contactCtx
808
- }), this.csatCtx = new q({
808
+ }), this.csatCtx = new J({
809
809
  config: this.config,
810
810
  api: this.api,
811
811
  sessionCtx: this.sessionCtx,
@@ -816,7 +816,7 @@ const f = class f {
816
816
  sessionCtx: this.sessionCtx,
817
817
  messageCtx: this.messageCtx,
818
818
  sessionPollingIntervalSeconds: f.pollingIntervalsSeconds.session
819
- }), this.routerCtx = new $({
819
+ }), this.routerCtx = new G({
820
820
  config: this.config,
821
821
  contactCtx: this.contactCtx,
822
822
  sessionCtx: this.sessionCtx,
@@ -829,7 +829,7 @@ f.pollingIntervalsSeconds = null, f.initialize = async ({
829
829
  storage: n
830
830
  }) => {
831
831
  var h, s, e;
832
- const r = await new j({
832
+ const r = await new A({
833
833
  config: a
834
834
  }).getExternalWidgetConfig();
835
835
  if (!r.data)
@@ -1328,7 +1328,39 @@ const W = {
1328
1328
  no_conversations_yet: "Vestlusi pole veel",
1329
1329
  back_to_conversations: "Tagasi vestluste juurde",
1330
1330
  closed_conversations: "Suletud vestlused"
1331
+ }, ze = {
1332
+ write_a_message_placeholder: "Írjon üzenetet...",
1333
+ your_issue_has_been_resolved: "A problémája megoldódott!",
1334
+ new_conversation: "Új beszélgetés",
1335
+ welcome_screen_title: "Üdvözöljük az ügyfélszolgálati chatünkön",
1336
+ welcome_screen_description: "Azért vagyunk itt, hogy segítsünk! Kezdjen beszélgetést, és mihamarabb válaszolunk.",
1337
+ your_name_placeholder: "Az Ön neve",
1338
+ your_email_placeholder: "Az Ön e-mail címe",
1339
+ start_chat_button: "Beszélgetés az ügyfélszolgálattal",
1340
+ start_chat_button_loading: "Csatlakozás...",
1341
+ i_need_more_help: "További segítségre van szükségem",
1342
+ this_was_helpful: "Ez hasznos volt",
1343
+ optional: "Opcionális",
1344
+ no_conversations_yet: "Még nincsenek beszélgetések",
1345
+ back_to_conversations: "Vissza a beszélgetésekhez",
1346
+ closed_conversations: "Lezárt beszélgetések"
1331
1347
  }, Ie = {
1348
+ write_a_message_placeholder: "Skrifaðu skilaboð...",
1349
+ your_issue_has_been_resolved: "Málið þitt hefur verið leyst!",
1350
+ new_conversation: "Nýtt samtal",
1351
+ welcome_screen_title: "Velkomin í þjónustuverið okkar",
1352
+ welcome_screen_description: "Við erum hér til að hjálpa! Byrjaðu samtal og við munum svara eins fljótt og auðið er.",
1353
+ your_name_placeholder: "Nafnið þitt",
1354
+ your_email_placeholder: "Netfangið þitt",
1355
+ start_chat_button: "Tala við þjónustuver",
1356
+ start_chat_button_loading: "Tengist...",
1357
+ i_need_more_help: "Ég þarf meiri hjálp",
1358
+ this_was_helpful: "Þetta var gagnlegt",
1359
+ optional: "Valfrjálst",
1360
+ no_conversations_yet: "Engin samtöl ennþá",
1361
+ back_to_conversations: "Til baka í samtöl",
1362
+ closed_conversations: "Lokuð samtöl"
1363
+ }, Pe = {
1332
1364
  write_a_message_placeholder: "Rakstiet ziņojumu...",
1333
1365
  your_issue_has_been_resolved: "Jūsu problēma ir atrisināta!",
1334
1366
  new_conversation: "Jauna saruna",
@@ -1344,7 +1376,23 @@ const W = {
1344
1376
  no_conversations_yet: "Pagaidām nav sarunu",
1345
1377
  back_to_conversations: "Atpakaļ pie sarunām",
1346
1378
  closed_conversations: "Slēgtās sarunas"
1347
- }, Pe = {
1379
+ }, je = {
1380
+ write_a_message_placeholder: "Parašykite žinutę...",
1381
+ your_issue_has_been_resolved: "Jūsų problema išspręsta!",
1382
+ new_conversation: "Naujas pokalbis",
1383
+ welcome_screen_title: "Sveiki atvykę į mūsų pagalbos pokalbį",
1384
+ welcome_screen_description: "Mes čia, kad padėtume! Pradėkite pokalbį ir mes atsakysime kuo greičiau.",
1385
+ your_name_placeholder: "Jūsų vardas",
1386
+ your_email_placeholder: "Jūsų el. pašto adresas",
1387
+ start_chat_button: "Kalbėti su pagalba",
1388
+ start_chat_button_loading: "Jungiamasi...",
1389
+ i_need_more_help: "Man reikia daugiau pagalbos",
1390
+ this_was_helpful: "Tai buvo naudinga",
1391
+ optional: "Neprivaloma",
1392
+ no_conversations_yet: "Pokalbių dar nėra",
1393
+ back_to_conversations: "Grįžti į pokalbius",
1394
+ closed_conversations: "Uždaryti pokalbiai"
1395
+ }, Te = {
1348
1396
  write_a_message_placeholder: "Schreift eng Noriicht...",
1349
1397
  your_issue_has_been_resolved: "Äert Problem gouf geléist!",
1350
1398
  new_conversation: "Nei Konversatioun",
@@ -1360,7 +1408,7 @@ const W = {
1360
1408
  no_conversations_yet: "Nach keng Konversatiounen",
1361
1409
  back_to_conversations: "Zréck zu de Konversatiounen",
1362
1410
  closed_conversations: "Zougemaachte Konversatiounen"
1363
- }, ze = {
1411
+ }, Ae = {
1364
1412
  write_a_message_placeholder: "Ikteb messaġġ...",
1365
1413
  your_issue_has_been_resolved: "Il-problema tiegħek ġiet riżolta!",
1366
1414
  new_conversation: "Konversazzjoni ġdida",
@@ -1376,7 +1424,39 @@ const W = {
1376
1424
  no_conversations_yet: "Għad m'hemmx konversazzjonijiet",
1377
1425
  back_to_conversations: "Lura għall-konversazzjonijiet",
1378
1426
  closed_conversations: "Konversazzjonijiet magħluqa"
1379
- }, O = {
1427
+ }, Me = {
1428
+ write_a_message_placeholder: "Skriv en melding...",
1429
+ your_issue_has_been_resolved: "Saken din er løst!",
1430
+ new_conversation: "Ny samtale",
1431
+ welcome_screen_title: "Velkommen til vår kundestøtte",
1432
+ welcome_screen_description: "Vi er her for å hjelpe! Start en samtale, så svarer vi deg så snart som mulig.",
1433
+ your_name_placeholder: "Ditt navn",
1434
+ your_email_placeholder: "Din e-postadresse",
1435
+ start_chat_button: "Snakk med kundestøtte",
1436
+ start_chat_button_loading: "Kobler til...",
1437
+ i_need_more_help: "Jeg trenger mer hjelp",
1438
+ this_was_helpful: "Dette var nyttig",
1439
+ optional: "Valgfritt",
1440
+ no_conversations_yet: "Ingen samtaler ennå",
1441
+ back_to_conversations: "Tilbake til samtaler",
1442
+ closed_conversations: "Lukkede samtaler"
1443
+ }, Ee = {
1444
+ write_a_message_placeholder: "Napíšte správu...",
1445
+ your_issue_has_been_resolved: "Váš problém bol vyriešený!",
1446
+ new_conversation: "Nová konverzácia",
1447
+ welcome_screen_title: "Vitajte v našom zákazníckom chate",
1448
+ welcome_screen_description: "Sme tu, aby sme vám pomohli! Začnite konverzáciu a odpovieme vám čo najskôr.",
1449
+ your_name_placeholder: "Vaše meno",
1450
+ your_email_placeholder: "Vaša e-mailová adresa",
1451
+ start_chat_button: "Hovoriť s podporou",
1452
+ start_chat_button_loading: "Pripájanie...",
1453
+ i_need_more_help: "Potrebujem ďalšiu pomoc",
1454
+ this_was_helpful: "Toto bolo užitočné",
1455
+ optional: "Voliteľné",
1456
+ no_conversations_yet: "Zatiaľ žiadne konverzácie",
1457
+ back_to_conversations: "Späť na konverzácie",
1458
+ closed_conversations: "Uzavreté konverzácie"
1459
+ }, N = {
1380
1460
  ar: W,
1381
1461
  bn: Z,
1382
1462
  bg: X,
@@ -1392,37 +1472,42 @@ const W = {
1392
1472
  fr: re,
1393
1473
  hi: le,
1394
1474
  hr: Ce,
1475
+ hu: ze,
1476
+ is: Ie,
1395
1477
  it: ce,
1396
1478
  ja: _e,
1397
1479
  ko: he,
1398
- lb: Pe,
1399
- lv: Ie,
1400
- mt: ze,
1480
+ lb: Te,
1481
+ lt: je,
1482
+ lv: Pe,
1483
+ mt: Ae,
1484
+ nb: Me,
1401
1485
  nl: ue,
1402
1486
  no: de,
1403
1487
  pl: ge,
1404
1488
  pt: me,
1405
1489
  ro: pe,
1406
1490
  ru: be,
1491
+ sk: Ee,
1407
1492
  sv: ve,
1408
1493
  th: fe,
1409
1494
  tr: we,
1410
1495
  ur: ye,
1411
1496
  vi: ke,
1412
1497
  "zh-cn": Se
1413
- }, Ae = Object.keys(O);
1414
- function Ue(_) {
1415
- return Ae.includes(_);
1498
+ }, Le = Object.keys(N);
1499
+ function De(_) {
1500
+ return Le.includes(_);
1416
1501
  }
1417
- function Le(_, a, n) {
1502
+ function Ve(_, a, n) {
1418
1503
  var r;
1419
- return ((r = n == null ? void 0 : n[a]) == null ? void 0 : r[_]) || O[a][_] || "";
1504
+ return ((r = n == null ? void 0 : n[a]) == null ? void 0 : r[_]) || N[a][_] || "";
1420
1505
  }
1421
1506
  export {
1422
1507
  S as PrimitiveState,
1423
1508
  M as WidgetCtx,
1424
- Le as getTranslation,
1509
+ Ve as getTranslation,
1425
1510
  B as isExhaustive,
1426
- Ue as isSupportedLanguage
1511
+ De as isSupportedLanguage
1427
1512
  };
1428
1513
  //# sourceMappingURL=index.js.map