@telia-ace/knowledge-widget-bot-provider 1.3.0-rc.4 → 1.3.0-rc.5

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.
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),A=require("@emotion/styled"),S=require("@telia-ace/knowledge-data-client"),R=require("@telia-ace/knowledge-widget-adapters"),p=require("@telia-ace/knowledge-widget-ui"),T=require("@telia-ace/widget-forms"),$=require("@telia-ace/widget-utilities"),c=require("react"),F=require("./index-cb940de4.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");const z=({contactMethodId:n,guideId:o,groupId:m,className:x})=>{var C,v,w;const[e,s]=c.useState(),d=p.useContainer(),D=p.useDispatch(),l=c.useRef(!0),b=p.useConversation();c.useEffect(()=>{const{events:u}=d.get("$widget"),q=u.subscribe("bot-provider:form-submitted",async(f,r)=>{var M;if(((M=r.form.meta)==null?void 0:M.groupId)!==m||r.id!==e.id)return;b&&(r.form.meta||(r.form.meta={}),r.form.meta.conversation=b);const y=await d.getAsync("contactMethods"),t={...e,body:{...e.body,form:r.form}},{errors:i,valid:h,errorTypes:N}=await y.validate(t);if(!h){const k=new T.FormBuilder(e.body.form);s(void 0),k.setValidationErrors(i),t.body={...t.body,form:k.get()},s({...t});return}const E=await y.submit(t);t.confirmation=E,s(t)}),a=u.subscribe("bot-provider:evaluate",async(f,r)=>{if(r.id!==n)return;const t=await(await d.getAsync("contactMethods")).evaluate(e);let i={...e,body:{...e.body,form:t}};const h=F.updateForm(i,{submit:"Skicka",errors:{},meta:{groupId:m}});i={...i,body:h},s(i)});return()=>{q(),a()}},[d,e,s,b]);const g=c.useCallback(async u=>{const a=await(await S.DataClient.getInstance(d)).fetch(S.DataType.ContactMethod,{contactMethodId:u,guideId:o},{noCache:!0}),f=F.updateForm(a,{submit:"Skicka",errors:{},meta:{groupId:m}});if(a.body=f,a.body.guideId=o,!l.current)return null;s(a)},[l]);return c.useEffect(()=>(g(n),()=>{l.current=!1}),[n,g]),e?j.jsx(B,{...e,body:{...e.body,form:e.body.form?{...e.body.form,data:(C=e.body.form)==null?void 0:C.data,layout:{...e.body.form.layout},meta:(v=e.body.form)==null?void 0:v.meta,schema:(w=e.body.form)==null?void 0:w.schema}:void 0,guideId:e.body.guideId},inline:!0,expanded:!0,dispatch:D,className:$.appendClassNames("humany-bot-contact-method",x)}):null},B=A(R.ContactMethod)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),A=require("@emotion/styled"),S=require("@telia-ace/knowledge-data-client"),R=require("@telia-ace/knowledge-widget-adapters"),p=require("@telia-ace/knowledge-widget-ui"),T=require("@telia-ace/widget-forms"),$=require("@telia-ace/widget-utilities"),c=require("react"),F=require("./index-af587a9e.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");const z=({contactMethodId:n,guideId:o,groupId:m,className:x})=>{var C,v,w;const[e,s]=c.useState(),d=p.useContainer(),D=p.useDispatch(),l=c.useRef(!0),b=p.useConversation();c.useEffect(()=>{const{events:u}=d.get("$widget"),q=u.subscribe("bot-provider:form-submitted",async(f,r)=>{var M;if(((M=r.form.meta)==null?void 0:M.groupId)!==m||r.id!==e.id)return;b&&(r.form.meta||(r.form.meta={}),r.form.meta.conversation=b);const y=await d.getAsync("contactMethods"),t={...e,body:{...e.body,form:r.form}},{errors:i,valid:h,errorTypes:N}=await y.validate(t);if(!h){const k=new T.FormBuilder(e.body.form);s(void 0),k.setValidationErrors(i),t.body={...t.body,form:k.get()},s({...t});return}const E=await y.submit(t);t.confirmation=E,s(t)}),a=u.subscribe("bot-provider:evaluate",async(f,r)=>{if(r.id!==n)return;const t=await(await d.getAsync("contactMethods")).evaluate(e);let i={...e,body:{...e.body,form:t}};const h=F.updateForm(i,{submit:"Skicka",errors:{},meta:{groupId:m}});i={...i,body:h},s(i)});return()=>{q(),a()}},[d,e,s,b]);const g=c.useCallback(async u=>{const a=await(await S.DataClient.getInstance(d)).fetch(S.DataType.ContactMethod,{contactMethodId:u,guideId:o},{noCache:!0}),f=F.updateForm(a,{submit:"Skicka",errors:{},meta:{groupId:m}});if(a.body=f,a.body.guideId=o,!l.current)return null;s(a)},[l]);return c.useEffect(()=>(g(n),()=>{l.current=!1}),[n,g]),e?j.jsx(B,{...e,body:{...e.body,form:e.body.form?{...e.body.form,data:(C=e.body.form)==null?void 0:C.data,layout:{...e.body.form.layout},meta:(v=e.body.form)==null?void 0:v.meta,schema:(w=e.body.form)==null?void 0:w.schema}:void 0,guideId:e.body.guideId},inline:!0,expanded:!0,dispatch:D,className:$.appendClassNames("humany-bot-contact-method",x)}):null},B=A(R.ContactMethod)`
2
2
  padding: ${n=>{var o;return(o=n.theme.sizes)==null?void 0:o.normal}} ${n=>{var o;return(o=n.theme.sizes)==null?void 0:o.medium}};
3
3
  `;exports.default=z;
@@ -6,7 +6,7 @@ import { useContainer as N, useDispatch as R, useConversation as T } from "@teli
6
6
  import { FormBuilder as _ } from "@telia-ace/widget-forms";
7
7
  import { appendClassNames as j } from "@telia-ace/widget-utilities";
8
8
  import { useState as G, useRef as I, useEffect as k, useCallback as V } from "react";
9
- import { u as S } from "./index-cc087f12.mjs";
9
+ import { u as S } from "./index-1e432d28.mjs";
10
10
  import "@telia-ace/widget-conversation";
11
11
  import "@telia-ace/widget-services";
12
12
  const tt = ({
@@ -3,11 +3,11 @@ import m from "@emotion/styled";
3
3
  import { ContactList as M, ContactMethod as $ } from "@telia-ace/knowledge-widget-adapters";
4
4
  import { useDispatch as b, useContainer as k } from "@telia-ace/knowledge-widget-ui";
5
5
  import { useState as f, useEffect as E } from "react";
6
- import S from "./contact-method-b5669c64.mjs";
6
+ import S from "./contact-method-ad8617ff.mjs";
7
7
  import "@telia-ace/knowledge-data-client";
8
8
  import "@telia-ace/widget-forms";
9
9
  import "@telia-ace/widget-utilities";
10
- import "./index-cc087f12.mjs";
10
+ import "./index-1e432d28.mjs";
11
11
  import "@telia-ace/widget-conversation";
12
12
  import "@telia-ace/widget-services";
13
13
  const F = ({ actions: t, entryId: e, groupId: y }) => {
@@ -53,7 +53,7 @@ const F = ({ actions: t, entryId: e, groupId: y }) => {
53
53
  className: "humany-bot-contact-list",
54
54
  contactMethods: l,
55
55
  dispatch: g,
56
- itemRenderer: (i, c) => (r.includes(i.id) || i.expanded) && i.inline ? /* @__PURE__ */ a(
56
+ itemRenderer: (i, c) => (r.includes(i.id) || i.expanded) && i.inline || i.clientName === "custom.link" ? /* @__PURE__ */ a(
57
57
  z,
58
58
  {
59
59
  contactMethodId: i.id,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),u=require("@emotion/styled"),y=require("@telia-ace/knowledge-widget-adapters"),g=require("@telia-ace/knowledge-widget-ui"),l=require("react"),b=require("./contact-method-d88ce2cc.js");require("@telia-ace/knowledge-data-client");require("@telia-ace/widget-forms");require("@telia-ace/widget-utilities");require("./index-cb940de4.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");const j=({actions:e,entryId:t,groupId:x})=>{const q=g.useDispatch(),d=g.useContainer(),[h,C]=l.useState([]),[o,M]=l.useState([]);return l.useEffect(()=>{d.getAsync("contactMethods").then(n=>{if(!n)return;const c=e.map(async i=>{var m;if(!((m=i.data)!=null&&m.clientName))return null;const s=await n.handleAdapters(i.data);return{...s,...i.data,description:i.data.description?i.data.description:s.description,onClick:(p,r)=>{if(typeof s.onClick=="function"&&s.onClick(p,r),!p.defaultPrevented)if(r.inline&&!r.expanded)M([...o,r.id]);else{const{events:f}=d.get("$widget");f.dispatch("provider:open-contact-method",{entryId:t,contactMethod:r,actionKey:i.actionKey}),f.dispatch("tracking:contact-method-list-item-clicked",r)}}}});Promise.all(c).then(i=>{C(i.filter(s=>!!s))})})},[e,d,t,o]),h.length?a.jsx(k,{className:"humany-bot-contact-list",contactMethods:h,dispatch:q,itemRenderer:(n,c)=>(o.includes(n.id)||n.expanded)&&n.inline?a.jsx(S,{contactMethodId:n.id,groupId:x,guideId:n.body.guideId}):a.jsx($,{...n,...c})}):null},k=u(y.ContactList)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),u=require("@emotion/styled"),y=require("@telia-ace/knowledge-widget-adapters"),g=require("@telia-ace/knowledge-widget-ui"),l=require("react"),b=require("./contact-method-59ca1264.js");require("@telia-ace/knowledge-data-client");require("@telia-ace/widget-forms");require("@telia-ace/widget-utilities");require("./index-af587a9e.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");const k=({actions:e,entryId:t,groupId:x})=>{const q=g.useDispatch(),d=g.useContainer(),[m,C]=l.useState([]),[o,M]=l.useState([]);return l.useEffect(()=>{d.getAsync("contactMethods").then(n=>{if(!n)return;const c=e.map(async i=>{var h;if(!((h=i.data)!=null&&h.clientName))return null;const s=await n.handleAdapters(i.data);return{...s,...i.data,description:i.data.description?i.data.description:s.description,onClick:(p,r)=>{if(typeof s.onClick=="function"&&s.onClick(p,r),!p.defaultPrevented)if(r.inline&&!r.expanded)M([...o,r.id]);else{const{events:f}=d.get("$widget");f.dispatch("provider:open-contact-method",{entryId:t,contactMethod:r,actionKey:i.actionKey}),f.dispatch("tracking:contact-method-list-item-clicked",r)}}}});Promise.all(c).then(i=>{C(i.filter(s=>!!s))})})},[e,d,t,o]),m.length?a.jsx(j,{className:"humany-bot-contact-list",contactMethods:m,dispatch:q,itemRenderer:(n,c)=>(o.includes(n.id)||n.expanded)&&n.inline||n.clientName==="custom.link"?a.jsx(S,{contactMethodId:n.id,groupId:x,guideId:n.body.guideId}):a.jsx($,{...n,...c})}):null},j=u(y.ContactList)`
2
2
  > ul > li {
3
3
  a {
4
4
  display: flex;
@@ -25,4 +25,4 @@
25
25
  justify-content: center;
26
26
  align-items: center;
27
27
  }
28
- `;exports.default=j;
28
+ `;exports.default=k;
@@ -769,11 +769,11 @@ const it = async (s) => {
769
769
  N(
770
770
  s,
771
771
  m.ContactList,
772
- import("./contact-method-list-dae09f9d.mjs")
772
+ import("./contact-method-list-5ab1c496.mjs")
773
773
  ), N(
774
774
  s,
775
775
  m.ContactMethod,
776
- import("./contact-method-b5669c64.mjs")
776
+ import("./contact-method-ad8617ff.mjs")
777
777
  ), N(
778
778
  s,
779
779
  m.NotificationList,
@@ -1 +1 @@
1
- "use strict";var H=Object.defineProperty;var R=(n,t,e)=>t in n?H(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var y=(n,t,e)=>(R(n,typeof t!="symbol"?t+"":t,e),e);const m=require("@telia-ace/widget-conversation"),N=require("@telia-ace/widget-services"),K=require("@telia-ace/widget-utilities"),P=require("@telia-ace/widget-forms");var f=(n=>(n.ContactMethod="ace-knowledge-bot-contact-method",n.ContactList="ace-knowledge-bot-contact-list",n.FeedbackList="ace-knowledge-bot-feedback-list",n.NotificationList="ace-knowledge-bot-notification-list",n.NoGoodAlternative="ace-knowledge-bot-no-good-alternative",n))(f||{});const $=n=>{if(n){const{type:t,content:e}=n;if(t&&e)return{type:t,content:e}}},A=({isUser:n,items:t=[],meta:e={}})=>{const s=K.uuid();return{id:s,isUser:n,items:t.map(a=>({id:a.id||K.uuid(),isUser:n,groupId:s,message:a.message||[]})),meta:e}},U=({id:n,title:t,defaultIcon:e,exits:[s],exitType:i,confirmationText:a,expandFormAutomatically:c,form:g,description:E},S={})=>{const{adapter:r}=s||{Adapter:{}},{clientName:o="",settings:h={},customClientName:v=""}=r,{validation:l}=S,d={id:n.toString(),title:t,description:E,symbol:$(e),clientName:o==="custom.adapter"?v:o,expanded:!0,inline:!0,body:{}};if(o.indexOf("phone")>-1||o.indexOf("freetext")>-1){const{displayTextBeforeClick:M,textBeforeClick:p}=h;M==="true"&&(d.expanded=!1,d.title=p),o.indexOf("phone.text")>-1?d.body.phoneNumber=h.phoneNumber:d.body.freetext=h.freetext}return(o.indexOf("chat.popup")>-1||o.indexOf("link")>-1||o==="custom.adapter"&&i==="custom")&&(d.body=h,d.body.confirmationFallback=a),o.indexOf("ace")>-1&&(d.body=h),g&&g.hasValueComponents&&(l?d.body.form=P.FormBuilder.fromLegacyForm(n.toString(),g,l).get():d.body.form=P.FormBuilder.fromLegacyForm(n.toString(),g).get(),c||(d.expanded=d.inline=!1),d.body=B(d,{submit:"Submit"})),S.guideId&&(d.body.guideId=S.guideId),d},G=n=>{const{localState:t}=n;return n.tags.includes("category")&&n.tags.includes("contact")?m.ConversationMessageListItemType.ItemList:n.tags.includes("suggestion")||(t==null?void 0:t.$type)==="Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching"?m.ConversationMessageListItemType.LinkList:(t==null?void 0:t.$type)==="Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching"?f.FeedbackList:(t==null?void 0:t.$type)==="Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching"?f.ContactList:m.ConversationMessageListItemType.ButtonList},q=(n,t)=>{const{knowledgeBotEndpoint:e}=t.properties();if(e)return`${e}/conversations`;const{data:s}=n.get("$settings");if(!s||!s.projection)throw new Error("Missing Knowledge Bot endpoint");return`${s.projection}/conversations`},B=(n,{submit:t,errors:e,meta:s})=>{var i;if((i=n==null?void 0:n.body)!=null&&i.form){const{body:a}=n,c=new P.FormBuilder(a.form);return a.form.layout.submit||c.createComponent(P.submitButton(t,"submit")),e&&c.setValidationErrors(e),s&&c.setMeta(s),{...a,form:c.get()}}return(n==null?void 0:n.body)||{}},O=async(n,t,e)=>{(await(await n.getAsync("dataClient")).getClient()).parameters.set(t,e)},b=({messageId:n,message:t,group:e})=>({id:n,message:t,groupId:e.id,isUser:e.isUser}),V=async(n,t,e)=>{const s=(r,o,h,v={actions:[],entryId:o.id,groupId:h})=>{const l=[];return v.actions=o.content.items.map(d=>{var p;const M={label:d.title,actionKey:d.actionKey,symbol:d.symbol?d.symbol:void 0,description:d.description||void 0};if(d.data){const w=o.actions[d.actionKey];r===f.ContactList?(l.push(d.data.id),M.data=U(d.data,{guideId:(p=w==null?void 0:w.guideId)==null?void 0:p.toString()})):M.data=d.data}return M}),r===f.ContactList&&(v.contactMethodIds=l),v},i=async(r,o,h=[],v)=>{var d,M;const l=K.uuid();switch(r.type!=="List"&&r.tags.includes("guide")&&((M=(d=r.content.hints)==null?void 0:d[0])!=null&&M.id)&&await O(n,"LastGuideId",r.content.hints[0].id),r.type){case"List":{const{header:p,items:w,html:x}=r.content,C=[];let I={actions:[],entryId:r.id,groupId:o.id};if(I.tags=r.tags||null,p&&(I.header=p),(w==null?void 0:w.length)>0){const u=G(r);if(I=s(u,r,o.id,I),h.length){const L=h.find(k=>k.tags.includes("paging")),T=h.find(k=>k.tags.includes("fallback"));if(L!=null&&L.content&&(o.meta.paging={actions:L.actions,items:L.content.items,localState:L.localState},L.content.items.forEach(k=>{I.actions.push({label:k.title,actionKey:k.actionKey,data:{groupId:v?v.id:o.id}})})),T){const k=T.content.items.find(F=>F.actionKey==="help");k&&(C.push(b({messageId:l,message:[m.ConversationMessageListItemType.Separator,void 0],group:o})),C.push(b({messageId:l,message:[f.NoGoodAlternative,{body:k.title}],group:o})))}}C.unshift(b({messageId:l,message:[u,I],group:o}))}return x&&C.unshift(b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:x}],group:o})),C}case"Text":{const p=[];if(p.push(b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:r.content.html}],group:o})),h.length){const w=h.find(u=>{var L;return u.type==="List"&&((L=u.localState)==null?void 0:L.$type)==="Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching"}),x=h.find(u=>u.tags.includes("dialog")),C=h.find(u=>u.tags.includes("feedback")),I=h.find(u=>u.tags.includes("contact")&&u.type==="Contact");if(I&&p.push(b({messageId:l,message:[f.ContactMethod,{contactMethodId:I.content.id,groupId:o.id,guideId:I.content.guideId}],group:o})),x&&p.push(b({messageId:l,message:[m.ConversationMessageListItemType.ButtonList,{actions:x.content.items.map(u=>({label:u.title,actionKey:u.actionKey,data:u.data}))}],group:o})),w){const u=s(f.ContactList,w,o.id);p.push(b({messageId:l,message:[m.ConversationMessageListItemType.Separator,void 0],group:o})),p.push(b({messageId:l,message:[f.ContactList,u],group:o}))}C&&(C.content.html&&p.push(b({messageId:l,group:o,message:[m.ConversationMessageListItemType.HTML,{body:C.content.html}]})),p.push(b({messageId:l,group:o,message:[f.FeedbackList,{actions:C.content.items.map(u=>({actionKey:u.actionKey,label:u.title}))}]})))}return p}case"Contact":return[b({messageId:l,message:[f.ContactMethod,{contactMethodId:r.content.id,groupId:o.id,guideId:r.content.guideId}],group:o})];case"CategorizedNoticeList":{const p=[b({messageId:l,message:[f.NotificationList,{id:r.content.item.id.toString(),header:r.content.item.title,items:r.content.item.listNotices,symbol:r.content.item.defaultIcon}],group:o})];return(r.content.notices||[]).forEach(w=>{p.push(b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:w.body}],group:o}))}),p}case"footerNotice":return[b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:r.content.item.body}],group:o})];case"Error":return[b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:r.content.message||"Something went wrong."}],group:o})];default:return[]}},a=r=>["CategorizedNoticeList","NoticeList"].includes(r.type)?(r.content.items||[]).reduce((o,h)=>(r.content.isInitialNotices&&o.push({...r,id:K.uuid(),type:h.type||r.type,content:{$type:r.content.$type,isInitialNotices:r.content.isInitialNotices,notices:h.notices,item:h}}),o),[]):r,c=new Map([["Text",1],["List",2],["Contact",3],["CategorizedNoticeList",10]]),g=[],E=t.sort((r,o)=>{const v=c.get(r.type)||20,l=c.get(o.type)||20;return v-l}).filter(r=>!r.relation).reduce((r,o)=>r.concat(a(o)),[]),S=r=>typeof r.actions.selector<"u";for(const r of E){const o=t.filter(l=>l.relation===r.id&&!S(l)),h=A({isUser:!1});(await i(r,h,o,e)).forEach(l=>{h.items.push(l)}),h.items.length&&g.push(h)}return g};class j{constructor(t,e,s,i){y(this,"globalState");y(this,"localState");y(this,"clientId");y(this,"entries");this.endpoint=t,this.events=e,this.store=s,this.container=i,this.clientId=K.uuid(),this.entries=[]}async start({silent:t}){const e=await this.store.read("globalState"),s=await this.store.read("localState"),i=await this.store.read("entries");if(this.globalState=e||this.globalState,this.localState=s||this.localState,this.entries=i||this.entries,t)return;const a=this.createInitialEnvelope();return await this.postEnvelope(a)}async sendMessage(t){const e={command:{phrase:t},globalState:this.globalState,clientId:this.clientId};return await this.postEnvelope(e)}async helpAction(){return this.postEnvelope({action:{key:"help",content:{$type:"Humany.Matching.Bots.Conversations.Actions.Help, Humany.Matching"}},globalState:this.globalState,clientId:this.clientId})}async nextAction(t){var s;const{paging:e}=t.meta;if((s=e.actions)!=null&&s.next)return this.postEnvelope({action:{key:"next",content:e.actions.next},localState:e.localState,globalState:this.globalState,clientId:this.clientId},t).then(i=>{const a=t.items.findIndex(c=>c.message[0]==="link-list");return a===-1||!i?t:{...t,meta:{...t.meta,...i[0].meta},items:[...t.items.slice(0,a),{...t.items[a],message:[i[0].items[0].message[0],{...t.items[a].message[1],...i[0].items[0].message[1]}]},...t.items.slice(a+1)]}})}async showContactMethodAction(t){const e=this.entries.find(i=>i.id===t.entryId),s=e==null?void 0:e.actions[t.actionKey];if(s)return this.postEnvelope({action:{key:t.actionKey,content:s},localState:e.localState,globalState:this.globalState,clientId:this.clientId})}async defaultAction(t){const e=this.getEntryOfAction(t);if(e)return this.postEnvelope({action:{key:t,content:e.actions[t]},localState:e.localState,globalState:this.globalState,clientId:this.clientId})}createInitialEnvelope(){return{command:{site:this.endpoint},clientId:this.clientId,globalState:{},funnel:this.container.get("$widget").name}}async postEnvelope(t,e){try{const s=await fetch(this.endpoint,this.getHttpOptions(t));if(!s.ok)throw s;const i=await s.json();return this.handleResponse(i,e)}catch(s){process.env.NODE_ENV!=="production"&&console.warn("Something went wrong when posting the envelope.");let i="Something went wrong";return(s.message==="Failed to fetch"||s.message==="NetworkError when attempting to fetch resource.")&&(i="Lost connection... Please try again."),this.events.dispatch("tracking:http-client-error",{message:i,error:s}),this.handleResponse({entries:[{id:K.uuid(),type:"Error",timestamp:new Date().toISOString(),content:{message:i},actions:{},tags:[]}]})}}async handleResponse(t,e){this.entries=this.entries.concat(t.entries),this.store.write(this.entries,"entries");const s=t.entries.find(a=>a.type==="Widget");return s&&this.events.dispatch("provider:widget-entry",s.content),t.globalState&&(this.globalState=t.globalState,this.store.write(t.globalState,"globalState")),this.localState=t.entries.reduce((a,c)=>c.localState?c.localState:a,void 0),this.store.write(this.localState,"localState"),await V(this.container,t.entries,e)}getHttpOptions(t){const e={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}};return t.funnel=this.container.get("$widget").name,t.localState=t.localState||this.localState,Object.assign({},e,{body:JSON.stringify(t),credentials:"same-origin"})}getEntryOfAction(t){return this.entries.find(e=>!!e.actions[t])}}class z{constructor(t){y(this,"enabled",!0);y(this,"botProviderGlobalStateKey","bot-provider-global-state");y(this,"botProviderLocalStateKey","bot-provider-local-state");y(this,"botProviderEntriesKey","bot-provider-entries");y(this,"botProviderMetaStateKey","bot-provider-conversation-meta");this.container=t}getKey(t){let e;switch(t){case"localState":e=this.botProviderLocalStateKey;break;case"globalState":e=this.botProviderGlobalStateKey;break;case"entries":e=this.botProviderEntriesKey;break;case"meta":e=this.botProviderMetaStateKey;break}return e}async read(t){const e=this.getKey(t);if(!(!this.enabled||!e))return N.readStorage(this.container,e)}async write(t,e){const s=this.getKey(e);if(!this.enabled||!s)return;(await N.createStorageWriter(this.container,s,N.StorageCategory.Necessary))(t)}}class W{constructor(t,e,s){y(this,"agent");y(this,"user");y(this,"httpClient");y(this,"events");y(this,"groups",[]);y(this,"store");this.container=t,this.conversation=e;const{events:i}=this.container.get("$widget");this.events=i,this.store=new z(t),this.agent=e.createAgent({id:"knowledge-bot-agent",name:"",avatar:void 0}),this.user=e.user;const a=q(t,s);this.httpClient=new j(a,i,this.store,this.container),this.events.subscribe("provider:widget-entry",(c,g)=>{this.onWidgetEntryReceived(g)}),this.events.subscribe("provider:open-contact-method",async(c,g)=>{const E=await this.httpClient.showContactMethodAction(g);E&&(g.contactMethod.title&&this.printUserMessage(g.contactMethod.title),this.onMessagesReceived(E))})}async initialize(){var a;const t=this.conversation.loading(),e=await this.store.read("meta");e!=null&&e.agent&&this.agent.update({name:e.agent.name,avatar:e.agent.avatar});const s=await this.conversation.isRehydrated(),i=await this.httpClient.start({silent:((a=this.conversation.options)==null?void 0:a.silent)||s});i&&this.onMessagesReceived(i),t()}async onMessagesReceived(t){this.groups=this.groups.concat(t),t.forEach(e=>{const s=e.items.map(i=>i.message);e.isUser?e.writer=this.user.print(s):e.writer=this.agent.print(s)})}async onInput(t){const e=typeof t=="string"?t:t.actionKey;switch(e){case"next":{if(typeof t=="string")return;const s=this.groups.find(i=>{var a;return i.id===((a=t.data)==null?void 0:a.groupId)});if(s){const i=await this.httpClient.nextAction(s);if(i){const a=i.items.map(c=>c.message);s.meta.paging=i==null?void 0:i.meta.paging,s.writer.update(a)}}}break;case"help":{const s=this.conversation.loading(),i=await this.httpClient.helpAction();s(),i&&this.onMessagesReceived(i)}break;default:{typeof t!="string"&&t.label&&this.printUserMessage(t.label);const s=this.conversation.loading(),i=await this.httpClient.defaultAction(e);i&&this.onMessagesReceived(i),s()}break}}printUserMessage(t){const e=A({isUser:!0,items:[{id:K.uuid(),isUser:!0,message:[m.ConversationMessageListItemType.HTML,{body:t}]}]});return this.onMessagesReceived([e]),e}async onMessageSend(t){const e=this.conversation.loading(),s=await this.httpClient.sendMessage(t);await O(this.container,"phrase",t),this.printUserMessage(t),s&&this.onMessagesReceived(s),e()}async onWidgetEntryReceived(t){var r,o,h,v,l;if(t.agent){const d={name:t.agent.name,avatar:t.agent.avatar};this.agent.update(d),(await N.createStorageWriter(this.container,"bot-provider-conversation-meta",N.StorageCategory.Necessary))({agent:d})}const s=(await this.container.getAsync("components")).components().ofType("widget-header").select();if(!s)return;const i=await this.container.get("settings"),a=i==null?void 0:i.components["widget-header"],c=(o=(r=a==null?void 0:a.properties)==null?void 0:r.actions)==null?void 0:o.avatar,g=(h=a==null?void 0:a.properties)==null?void 0:h.header,E=(v=a==null?void 0:a.properties)==null?void 0:v.tagline,S={};!g&&(t!=null&&t.heading)&&(S.header=t.heading),!E&&(t!=null&&t.tagline)&&(S.tagline=t.tagline),!c&&((l=t==null?void 0:t.agent)!=null&&l.avatar)&&(S.actions={avatar:{position:"left",symbol:{type:"Uri",content:t.agent.avatar}}}),Object.keys(S).length>0&&s.writeProperties(S)}}const _=async n=>{const t=await m.ConversationPlatform.getInstance(n);m.registerCustomMessageComponent(n,f.ContactList,Promise.resolve().then(()=>require("./contact-method-list-6b716469.js"))),m.registerCustomMessageComponent(n,f.ContactMethod,Promise.resolve().then(()=>require("./contact-method-d88ce2cc.js"))),m.registerCustomMessageComponent(n,f.NotificationList,Promise.resolve().then(()=>require("./notification-list-d4d9695d.js"))),m.registerCustomMessageComponent(n,f.NoGoodAlternative,Promise.resolve().then(()=>require("./no-good-alternative-0ced8ab9.js"))),m.registerCustomMessageComponent(n,f.FeedbackList,Promise.resolve().then(()=>require("./feedback-list-48c7bffb.js"))),t.registerProvider("ace-knowledge-bot",(e,s)=>{const i=new W(n,e,s);i.initialize();const a=[];return a.push(s.actions.watch("conversation.user-submit",(c,g)=>{i.onMessageSend(c.text)})),a.push(s.actions.watch("conversation.action",(c,g)=>(i.onInput(c),g(c)))),a.push(s.actions.create("evaluate",c=>{const{events:g}=n.get("$widget");g.dispatch("bot-provider:evaluate",c)})),a.push(s.actions.create("submit",c=>{const{events:g}=n.get("$widget");g.dispatch("bot-provider:form-submitted",c)})),()=>{a.forEach(c=>{c()})}})};exports.KnowledgeBotProviderPlugin=_;exports.updateForm=B;
1
+ "use strict";var H=Object.defineProperty;var R=(n,t,e)=>t in n?H(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var y=(n,t,e)=>(R(n,typeof t!="symbol"?t+"":t,e),e);const m=require("@telia-ace/widget-conversation"),N=require("@telia-ace/widget-services"),K=require("@telia-ace/widget-utilities"),P=require("@telia-ace/widget-forms");var f=(n=>(n.ContactMethod="ace-knowledge-bot-contact-method",n.ContactList="ace-knowledge-bot-contact-list",n.FeedbackList="ace-knowledge-bot-feedback-list",n.NotificationList="ace-knowledge-bot-notification-list",n.NoGoodAlternative="ace-knowledge-bot-no-good-alternative",n))(f||{});const $=n=>{if(n){const{type:t,content:e}=n;if(t&&e)return{type:t,content:e}}},A=({isUser:n,items:t=[],meta:e={}})=>{const s=K.uuid();return{id:s,isUser:n,items:t.map(a=>({id:a.id||K.uuid(),isUser:n,groupId:s,message:a.message||[]})),meta:e}},U=({id:n,title:t,defaultIcon:e,exits:[s],exitType:i,confirmationText:a,expandFormAutomatically:c,form:g,description:E},S={})=>{const{adapter:r}=s||{Adapter:{}},{clientName:o="",settings:h={},customClientName:v=""}=r,{validation:l}=S,d={id:n.toString(),title:t,description:E,symbol:$(e),clientName:o==="custom.adapter"?v:o,expanded:!0,inline:!0,body:{}};if(o.indexOf("phone")>-1||o.indexOf("freetext")>-1){const{displayTextBeforeClick:M,textBeforeClick:p}=h;M==="true"&&(d.expanded=!1,d.title=p),o.indexOf("phone.text")>-1?d.body.phoneNumber=h.phoneNumber:d.body.freetext=h.freetext}return(o.indexOf("chat.popup")>-1||o.indexOf("link")>-1||o==="custom.adapter"&&i==="custom")&&(d.body=h,d.body.confirmationFallback=a),o.indexOf("ace")>-1&&(d.body=h),g&&g.hasValueComponents&&(l?d.body.form=P.FormBuilder.fromLegacyForm(n.toString(),g,l).get():d.body.form=P.FormBuilder.fromLegacyForm(n.toString(),g).get(),c||(d.expanded=d.inline=!1),d.body=B(d,{submit:"Submit"})),S.guideId&&(d.body.guideId=S.guideId),d},G=n=>{const{localState:t}=n;return n.tags.includes("category")&&n.tags.includes("contact")?m.ConversationMessageListItemType.ItemList:n.tags.includes("suggestion")||(t==null?void 0:t.$type)==="Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching"?m.ConversationMessageListItemType.LinkList:(t==null?void 0:t.$type)==="Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching"?f.FeedbackList:(t==null?void 0:t.$type)==="Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching"?f.ContactList:m.ConversationMessageListItemType.ButtonList},q=(n,t)=>{const{knowledgeBotEndpoint:e}=t.properties();if(e)return`${e}/conversations`;const{data:s}=n.get("$settings");if(!s||!s.projection)throw new Error("Missing Knowledge Bot endpoint");return`${s.projection}/conversations`},B=(n,{submit:t,errors:e,meta:s})=>{var i;if((i=n==null?void 0:n.body)!=null&&i.form){const{body:a}=n,c=new P.FormBuilder(a.form);return a.form.layout.submit||c.createComponent(P.submitButton(t,"submit")),e&&c.setValidationErrors(e),s&&c.setMeta(s),{...a,form:c.get()}}return(n==null?void 0:n.body)||{}},O=async(n,t,e)=>{(await(await n.getAsync("dataClient")).getClient()).parameters.set(t,e)},b=({messageId:n,message:t,group:e})=>({id:n,message:t,groupId:e.id,isUser:e.isUser}),V=async(n,t,e)=>{const s=(r,o,h,v={actions:[],entryId:o.id,groupId:h})=>{const l=[];return v.actions=o.content.items.map(d=>{var p;const M={label:d.title,actionKey:d.actionKey,symbol:d.symbol?d.symbol:void 0,description:d.description||void 0};if(d.data){const w=o.actions[d.actionKey];r===f.ContactList?(l.push(d.data.id),M.data=U(d.data,{guideId:(p=w==null?void 0:w.guideId)==null?void 0:p.toString()})):M.data=d.data}return M}),r===f.ContactList&&(v.contactMethodIds=l),v},i=async(r,o,h=[],v)=>{var d,M;const l=K.uuid();switch(r.type!=="List"&&r.tags.includes("guide")&&((M=(d=r.content.hints)==null?void 0:d[0])!=null&&M.id)&&await O(n,"LastGuideId",r.content.hints[0].id),r.type){case"List":{const{header:p,items:w,html:x}=r.content,C=[];let I={actions:[],entryId:r.id,groupId:o.id};if(I.tags=r.tags||null,p&&(I.header=p),(w==null?void 0:w.length)>0){const u=G(r);if(I=s(u,r,o.id,I),h.length){const L=h.find(k=>k.tags.includes("paging")),T=h.find(k=>k.tags.includes("fallback"));if(L!=null&&L.content&&(o.meta.paging={actions:L.actions,items:L.content.items,localState:L.localState},L.content.items.forEach(k=>{I.actions.push({label:k.title,actionKey:k.actionKey,data:{groupId:v?v.id:o.id}})})),T){const k=T.content.items.find(F=>F.actionKey==="help");k&&(C.push(b({messageId:l,message:[m.ConversationMessageListItemType.Separator,void 0],group:o})),C.push(b({messageId:l,message:[f.NoGoodAlternative,{body:k.title}],group:o})))}}C.unshift(b({messageId:l,message:[u,I],group:o}))}return x&&C.unshift(b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:x}],group:o})),C}case"Text":{const p=[];if(p.push(b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:r.content.html}],group:o})),h.length){const w=h.find(u=>{var L;return u.type==="List"&&((L=u.localState)==null?void 0:L.$type)==="Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching"}),x=h.find(u=>u.tags.includes("dialog")),C=h.find(u=>u.tags.includes("feedback")),I=h.find(u=>u.tags.includes("contact")&&u.type==="Contact");if(I&&p.push(b({messageId:l,message:[f.ContactMethod,{contactMethodId:I.content.id,groupId:o.id,guideId:I.content.guideId}],group:o})),x&&p.push(b({messageId:l,message:[m.ConversationMessageListItemType.ButtonList,{actions:x.content.items.map(u=>({label:u.title,actionKey:u.actionKey,data:u.data}))}],group:o})),w){const u=s(f.ContactList,w,o.id);p.push(b({messageId:l,message:[m.ConversationMessageListItemType.Separator,void 0],group:o})),p.push(b({messageId:l,message:[f.ContactList,u],group:o}))}C&&(C.content.html&&p.push(b({messageId:l,group:o,message:[m.ConversationMessageListItemType.HTML,{body:C.content.html}]})),p.push(b({messageId:l,group:o,message:[f.FeedbackList,{actions:C.content.items.map(u=>({actionKey:u.actionKey,label:u.title}))}]})))}return p}case"Contact":return[b({messageId:l,message:[f.ContactMethod,{contactMethodId:r.content.id,groupId:o.id,guideId:r.content.guideId}],group:o})];case"CategorizedNoticeList":{const p=[b({messageId:l,message:[f.NotificationList,{id:r.content.item.id.toString(),header:r.content.item.title,items:r.content.item.listNotices,symbol:r.content.item.defaultIcon}],group:o})];return(r.content.notices||[]).forEach(w=>{p.push(b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:w.body}],group:o}))}),p}case"footerNotice":return[b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:r.content.item.body}],group:o})];case"Error":return[b({messageId:l,message:[m.ConversationMessageListItemType.HTML,{body:r.content.message||"Something went wrong."}],group:o})];default:return[]}},a=r=>["CategorizedNoticeList","NoticeList"].includes(r.type)?(r.content.items||[]).reduce((o,h)=>(r.content.isInitialNotices&&o.push({...r,id:K.uuid(),type:h.type||r.type,content:{$type:r.content.$type,isInitialNotices:r.content.isInitialNotices,notices:h.notices,item:h}}),o),[]):r,c=new Map([["Text",1],["List",2],["Contact",3],["CategorizedNoticeList",10]]),g=[],E=t.sort((r,o)=>{const v=c.get(r.type)||20,l=c.get(o.type)||20;return v-l}).filter(r=>!r.relation).reduce((r,o)=>r.concat(a(o)),[]),S=r=>typeof r.actions.selector<"u";for(const r of E){const o=t.filter(l=>l.relation===r.id&&!S(l)),h=A({isUser:!1});(await i(r,h,o,e)).forEach(l=>{h.items.push(l)}),h.items.length&&g.push(h)}return g};class j{constructor(t,e,s,i){y(this,"globalState");y(this,"localState");y(this,"clientId");y(this,"entries");this.endpoint=t,this.events=e,this.store=s,this.container=i,this.clientId=K.uuid(),this.entries=[]}async start({silent:t}){const e=await this.store.read("globalState"),s=await this.store.read("localState"),i=await this.store.read("entries");if(this.globalState=e||this.globalState,this.localState=s||this.localState,this.entries=i||this.entries,t)return;const a=this.createInitialEnvelope();return await this.postEnvelope(a)}async sendMessage(t){const e={command:{phrase:t},globalState:this.globalState,clientId:this.clientId};return await this.postEnvelope(e)}async helpAction(){return this.postEnvelope({action:{key:"help",content:{$type:"Humany.Matching.Bots.Conversations.Actions.Help, Humany.Matching"}},globalState:this.globalState,clientId:this.clientId})}async nextAction(t){var s;const{paging:e}=t.meta;if((s=e.actions)!=null&&s.next)return this.postEnvelope({action:{key:"next",content:e.actions.next},localState:e.localState,globalState:this.globalState,clientId:this.clientId},t).then(i=>{const a=t.items.findIndex(c=>c.message[0]==="link-list");return a===-1||!i?t:{...t,meta:{...t.meta,...i[0].meta},items:[...t.items.slice(0,a),{...t.items[a],message:[i[0].items[0].message[0],{...t.items[a].message[1],...i[0].items[0].message[1]}]},...t.items.slice(a+1)]}})}async showContactMethodAction(t){const e=this.entries.find(i=>i.id===t.entryId),s=e==null?void 0:e.actions[t.actionKey];if(s)return this.postEnvelope({action:{key:t.actionKey,content:s},localState:e.localState,globalState:this.globalState,clientId:this.clientId})}async defaultAction(t){const e=this.getEntryOfAction(t);if(e)return this.postEnvelope({action:{key:t,content:e.actions[t]},localState:e.localState,globalState:this.globalState,clientId:this.clientId})}createInitialEnvelope(){return{command:{site:this.endpoint},clientId:this.clientId,globalState:{},funnel:this.container.get("$widget").name}}async postEnvelope(t,e){try{const s=await fetch(this.endpoint,this.getHttpOptions(t));if(!s.ok)throw s;const i=await s.json();return this.handleResponse(i,e)}catch(s){process.env.NODE_ENV!=="production"&&console.warn("Something went wrong when posting the envelope.");let i="Something went wrong";return(s.message==="Failed to fetch"||s.message==="NetworkError when attempting to fetch resource.")&&(i="Lost connection... Please try again."),this.events.dispatch("tracking:http-client-error",{message:i,error:s}),this.handleResponse({entries:[{id:K.uuid(),type:"Error",timestamp:new Date().toISOString(),content:{message:i},actions:{},tags:[]}]})}}async handleResponse(t,e){this.entries=this.entries.concat(t.entries),this.store.write(this.entries,"entries");const s=t.entries.find(a=>a.type==="Widget");return s&&this.events.dispatch("provider:widget-entry",s.content),t.globalState&&(this.globalState=t.globalState,this.store.write(t.globalState,"globalState")),this.localState=t.entries.reduce((a,c)=>c.localState?c.localState:a,void 0),this.store.write(this.localState,"localState"),await V(this.container,t.entries,e)}getHttpOptions(t){const e={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}};return t.funnel=this.container.get("$widget").name,t.localState=t.localState||this.localState,Object.assign({},e,{body:JSON.stringify(t),credentials:"same-origin"})}getEntryOfAction(t){return this.entries.find(e=>!!e.actions[t])}}class z{constructor(t){y(this,"enabled",!0);y(this,"botProviderGlobalStateKey","bot-provider-global-state");y(this,"botProviderLocalStateKey","bot-provider-local-state");y(this,"botProviderEntriesKey","bot-provider-entries");y(this,"botProviderMetaStateKey","bot-provider-conversation-meta");this.container=t}getKey(t){let e;switch(t){case"localState":e=this.botProviderLocalStateKey;break;case"globalState":e=this.botProviderGlobalStateKey;break;case"entries":e=this.botProviderEntriesKey;break;case"meta":e=this.botProviderMetaStateKey;break}return e}async read(t){const e=this.getKey(t);if(!(!this.enabled||!e))return N.readStorage(this.container,e)}async write(t,e){const s=this.getKey(e);if(!this.enabled||!s)return;(await N.createStorageWriter(this.container,s,N.StorageCategory.Necessary))(t)}}class W{constructor(t,e,s){y(this,"agent");y(this,"user");y(this,"httpClient");y(this,"events");y(this,"groups",[]);y(this,"store");this.container=t,this.conversation=e;const{events:i}=this.container.get("$widget");this.events=i,this.store=new z(t),this.agent=e.createAgent({id:"knowledge-bot-agent",name:"",avatar:void 0}),this.user=e.user;const a=q(t,s);this.httpClient=new j(a,i,this.store,this.container),this.events.subscribe("provider:widget-entry",(c,g)=>{this.onWidgetEntryReceived(g)}),this.events.subscribe("provider:open-contact-method",async(c,g)=>{const E=await this.httpClient.showContactMethodAction(g);E&&(g.contactMethod.title&&this.printUserMessage(g.contactMethod.title),this.onMessagesReceived(E))})}async initialize(){var a;const t=this.conversation.loading(),e=await this.store.read("meta");e!=null&&e.agent&&this.agent.update({name:e.agent.name,avatar:e.agent.avatar});const s=await this.conversation.isRehydrated(),i=await this.httpClient.start({silent:((a=this.conversation.options)==null?void 0:a.silent)||s});i&&this.onMessagesReceived(i),t()}async onMessagesReceived(t){this.groups=this.groups.concat(t),t.forEach(e=>{const s=e.items.map(i=>i.message);e.isUser?e.writer=this.user.print(s):e.writer=this.agent.print(s)})}async onInput(t){const e=typeof t=="string"?t:t.actionKey;switch(e){case"next":{if(typeof t=="string")return;const s=this.groups.find(i=>{var a;return i.id===((a=t.data)==null?void 0:a.groupId)});if(s){const i=await this.httpClient.nextAction(s);if(i){const a=i.items.map(c=>c.message);s.meta.paging=i==null?void 0:i.meta.paging,s.writer.update(a)}}}break;case"help":{const s=this.conversation.loading(),i=await this.httpClient.helpAction();s(),i&&this.onMessagesReceived(i)}break;default:{typeof t!="string"&&t.label&&this.printUserMessage(t.label);const s=this.conversation.loading(),i=await this.httpClient.defaultAction(e);i&&this.onMessagesReceived(i),s()}break}}printUserMessage(t){const e=A({isUser:!0,items:[{id:K.uuid(),isUser:!0,message:[m.ConversationMessageListItemType.HTML,{body:t}]}]});return this.onMessagesReceived([e]),e}async onMessageSend(t){const e=this.conversation.loading(),s=await this.httpClient.sendMessage(t);await O(this.container,"phrase",t),this.printUserMessage(t),s&&this.onMessagesReceived(s),e()}async onWidgetEntryReceived(t){var r,o,h,v,l;if(t.agent){const d={name:t.agent.name,avatar:t.agent.avatar};this.agent.update(d),(await N.createStorageWriter(this.container,"bot-provider-conversation-meta",N.StorageCategory.Necessary))({agent:d})}const s=(await this.container.getAsync("components")).components().ofType("widget-header").select();if(!s)return;const i=await this.container.get("settings"),a=i==null?void 0:i.components["widget-header"],c=(o=(r=a==null?void 0:a.properties)==null?void 0:r.actions)==null?void 0:o.avatar,g=(h=a==null?void 0:a.properties)==null?void 0:h.header,E=(v=a==null?void 0:a.properties)==null?void 0:v.tagline,S={};!g&&(t!=null&&t.heading)&&(S.header=t.heading),!E&&(t!=null&&t.tagline)&&(S.tagline=t.tagline),!c&&((l=t==null?void 0:t.agent)!=null&&l.avatar)&&(S.actions={avatar:{position:"left",symbol:{type:"Uri",content:t.agent.avatar}}}),Object.keys(S).length>0&&s.writeProperties(S)}}const _=async n=>{const t=await m.ConversationPlatform.getInstance(n);m.registerCustomMessageComponent(n,f.ContactList,Promise.resolve().then(()=>require("./contact-method-list-d9fa9fcb.js"))),m.registerCustomMessageComponent(n,f.ContactMethod,Promise.resolve().then(()=>require("./contact-method-59ca1264.js"))),m.registerCustomMessageComponent(n,f.NotificationList,Promise.resolve().then(()=>require("./notification-list-d4d9695d.js"))),m.registerCustomMessageComponent(n,f.NoGoodAlternative,Promise.resolve().then(()=>require("./no-good-alternative-0ced8ab9.js"))),m.registerCustomMessageComponent(n,f.FeedbackList,Promise.resolve().then(()=>require("./feedback-list-48c7bffb.js"))),t.registerProvider("ace-knowledge-bot",(e,s)=>{const i=new W(n,e,s);i.initialize();const a=[];return a.push(s.actions.watch("conversation.user-submit",(c,g)=>{i.onMessageSend(c.text)})),a.push(s.actions.watch("conversation.action",(c,g)=>(i.onInput(c),g(c)))),a.push(s.actions.create("evaluate",c=>{const{events:g}=n.get("$widget");g.dispatch("bot-provider:evaluate",c)})),a.push(s.actions.create("submit",c=>{const{events:g}=n.get("$widget");g.dispatch("bot-provider:form-submitted",c)})),()=>{a.forEach(c=>{c()})}})};exports.KnowledgeBotProviderPlugin=_;exports.updateForm=B;
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-cb940de4.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");require("@telia-ace/widget-utilities");require("@telia-ace/widget-forms");exports.ConversationPlugin=e.KnowledgeBotProviderPlugin;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-af587a9e.js");require("@telia-ace/widget-conversation");require("@telia-ace/widget-services");require("@telia-ace/widget-utilities");require("@telia-ace/widget-forms");exports.ConversationPlugin=e.KnowledgeBotProviderPlugin;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { K as n } from "./index-cc087f12.mjs";
1
+ import { K as n } from "./index-1e432d28.mjs";
2
2
  import "@telia-ace/widget-conversation";
3
3
  import "@telia-ace/widget-services";
4
4
  import "@telia-ace/widget-utilities";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-bot-provider",
3
- "version": "1.3.0-rc.4",
3
+ "version": "1.3.0-rc.5",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -10,15 +10,15 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@telia-ace/knowledge-data-client": "^1.3.0-rc.4",
14
- "@telia-ace/knowledge-widget-adapters": "^1.3.0-rc.4",
15
- "@telia-ace/knowledge-widget-ui": "^1.3.0-rc.4",
16
- "@telia-ace/widget-conversation": "^1.3.0-rc.4",
17
- "@telia-ace/widget-forms": "^1.3.0-rc.4",
18
- "@telia-ace/widget-services": "^1.3.0-rc.4",
19
- "@telia-ace/widget-utilities": "^1.3.0-rc.4",
13
+ "@telia-ace/knowledge-data-client": "^1.3.0-rc.5",
14
+ "@telia-ace/knowledge-widget-adapters": "^1.3.0-rc.5",
15
+ "@telia-ace/knowledge-widget-ui": "^1.3.0-rc.5",
16
+ "@telia-ace/widget-conversation": "^1.3.0-rc.5",
17
+ "@telia-ace/widget-forms": "^1.3.0-rc.5",
18
+ "@telia-ace/widget-services": "^1.3.0-rc.5",
19
+ "@telia-ace/widget-utilities": "^1.3.0-rc.5",
20
20
  "@webprovisions/platform": "^1.1.4",
21
- "@telia-ace/knowledge-widget-core": "^1.3.0-rc.4"
21
+ "@telia-ace/knowledge-widget-core": "^1.3.0-rc.5"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@emotion/react": "11.11.1",