@telia-ace/ace-chat-flamingo 1.1.120-rc.6 → 1.1.120-rc.7
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/index.js +11 -6
- package/index.mjs +18 -14
- package/package.json +3 -3
- package/provider.d.ts +6 -6
- package/types.d.ts +5 -0
- package/ui/{tunnistus-link-button.d.ts → tunnistus-auth-card.d.ts} +3 -3
- package/ui/welcome-form.d.ts +3 -3
package/index.js
CHANGED
|
@@ -1274,7 +1274,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
1274
1274
|
clip: rect(0, 0, 0, 0);
|
|
1275
1275
|
border: 0;
|
|
1276
1276
|
}
|
|
1277
|
-
`];let le=Ns;Oe([O()],le.prototype,"message");Oe([O()],le.prototype,"disabledInput");Oe([O()],le.prototype,"disabledSkipToLatest");Oe([O()],le.prototype,"disabledSubmit");Oe([O()],le.prototype,"chatOverlayActive");Oe([O()],le.prototype,"textAreaLength");Oe([O()],le.prototype,"platform");Oe([O()],le.prototype,"entries");Oe([O()],le.prototype,"typing");const we=n=>n.objectType==="info",Od=n=>n.objectType==="chatEntry",Ld=n=>n.objectType==="pen",Rd=n=>n.objectType==="chatButtonClicked",Id=n=>n.objectType==="endVideoButtonClicked",Pd=n=>n.type==="queue-status",Md=n=>n.type==="established",Dd=n=>n.type==="pen-status",Ud=n=>n.type==="prepareVideo",Nd=n=>n.type==="videoPrepared",zd=n=>n.type==="chatButtonClicked",jd=n=>n.type==="endVideoButtonClicked",Hd=n=>n.type==="chat-ended";class Un extends Error{constructor(e){super(e),this.name="EngineException"}}class xs{constructor(e,t){this.endpoint=e,this.timeout=t,this.protocolVersion="A",this.penStatusJustSent=!1}async chatJoin(e){var i,s,r;const t=await this.sendRequest("chatJoin",{invitationUid:e.invitationUid,uid:e.uid,instance:e.instance,protocolVersion:this.protocolVersion,videoChatMode:e.videoChatMode,customerName:e.customerName});if(!t.dataObjects||!((i=t==null?void 0:t.dataObjects)!=null&&i.length)||((s=t==null?void 0:t.dataObjects[0])==null?void 0:s.infoType)==="error")throw t.dataObjects?new Error(`chatRequest - ${(r=t==null?void 0:t.dataObjects[0])==null?void 0:r.text}`):new Error("chatRequest - unknown error")}async chatRequest(e){var i,s,r,o,a;const t=await this.sendRequest("chatRequest",{...e.customData,uid:e.uid,instance:e.instance,queueMessageInterval:e.queueMessageInterval.toString(),protocolVersion:this.protocolVersion,entrance:e.entrance,errand:e.errand.length?e.errand:"997",videoChatMode:e.videoChatMode,customerName:e.customerName,customerEmailAddress:e.customerEmailAddress,visitorQuestion:e.visitorQuestion,visitorUserAgent:((i=window==null?void 0:window.navigator)==null?void 0:i.userAgent)||"",sourceUrl:((s=window==null?void 0:window.location)==null?void 0:s.href)||"",...e.authToken&&{authToken:e.authToken}});if(!t.dataObjects||!((r=t==null?void 0:t.dataObjects)!=null&&r.length)||((o=t==null?void 0:t.dataObjects[0])==null?void 0:o.infoType)==="error")throw t.dataObjects?new Error(`chatRequest - ${(a=t==null?void 0:t.dataObjects[0])==null?void 0:a.text}`):new Error("chatRequest - unknown error")}async videoPrepared(e){await this.sendRequest("videoPrepared",{uid:e.uid,instance:e.instance,result:e.result,protocolVersion:this.protocolVersion})}chatRead(e){return this.sendRequest("chatRead",{uid:e.uid,instance:e.instance,entrance:e.entrance,maxObjectId:`${e.maxObjectId}`,protocolVersion:this.protocolVersion})}sendPenStatusOn(e){if(this.penStatusTimer&&clearTimeout(this.penStatusTimer),e.key==="Enter"){this.penStatusJustSent=!1;return}this.penStatusJustSent||(this.sendRequest("chatPenStatus",{uid:e.uid,instance:e.instance,penStatus:"on",protocolVersion:this.protocolVersion}),this.penStatusJustSent=!0,setTimeout(()=>{this.penStatusJustSent=!1},5e3)),this.penStatusTimer=setTimeout(()=>this.sendPenStatusOff(e),5e3)}sendPenStatusOff(e){this.penStatusJustSent&&clearTimeout(this.penStatusTimer),this.sendRequest("chatPenStatus",{uid:e.uid,instance:e.instance,penStatus:"off",protocolVersion:this.protocolVersion})}chatWrite(e){return this.sendPenStatusOff(e),this.sendRequest("chatWrite",{uid:e.uid,instance:e.instance,clockstamp:e.clockstamp,message:e.message,protocolVersion:this.protocolVersion})}async chatQuit(e){this.sendPenStatusOff(e),await this.sendRequest("chatQuit",{uid:e.uid,instance:e.instance,protocolVersion:this.protocolVersion})}async chatCheckSession(e){var i;const t=await this.sendRequest("chatCheckSession",{uid:e.uid,instance:e.instance,protocolVersion:this.protocolVersion});return Object.keys(t).length===0?null:((i=t.dataObjects)==null||i.sort((s,r)=>s.objectId-r.objectId),t)}async chatEmailSession(e){return this.sendRequest("chatEmailSession",{uid:e.uid,instance:e.instance,emailAddress:e.emailAddress,protocolVersion:this.protocolVersion})}async sendRequest(e,t){const i=this.endpoint.includes("engine-simulator")?"include":void 0,s=`${xs.removeTrailingSlashes(this.endpoint)}/${e}`,r=await fetch(s,{body:new URLSearchParams(t),method:"POST",credentials:i,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"*/*"},signal:this.timeout?AbortSignal.timeout(this.timeout):void 0});return Number(r.headers.get("content-length"))>0?r.json():{}}static removeTrailingSlashes(e){return e.replace(/\/+$/,"")}}const Fd=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+n/4).toString(16)),Zi=()=>typeof crypto.randomUUID=="function"?crypto.randomUUID():Fd();function Yi(n){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)}function Wa(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}class Bd{constructor(e,t){this.config=e,this.messageSubject$=new P,this.actionsSubject$=new P,this.messages=()=>this.messageSubject$.asObservable(),this.actions=()=>this.actionsSubject$.asObservable(),this.sessionId="",this.lastObjectId=0,this.sessionId=t??Zi(),this.client=new xs(this.config.engineUrl,this.config.engineTimeout)}chatJoin(e){return Ve(this.client.chatJoin({invitationUid:e.invitationUid,uid:this.sessionId,customerName:e.customerName,instance:this.config.instance,videoChatMode:this.config.videoChatMode})).pipe(Li(t=>(console.error(t),this.messageSubject$.next({text:this.config.errorMessage??"An error occured",source:"system"}),new j)),_e(()=>this.poll().pipe(pi(()=>this.poll()),fi())))}chatRequest(e){return Ve(this.client.chatRequest({uid:this.sessionId,customerName:e.customerName,customerEmailAddress:e.customerEmailAddress,visitorQuestion:e.visitorQuestion,instance:this.config.instance,queueMessageInterval:this.config.queueMessageInterval,entrance:this.config.entrance,errand:e.errand,videoChatMode:this.config.videoChatMode,customData:e.customData,...e.authToken&&{authToken:e.authToken}})).pipe(Li(t=>(console.error(t),this.messageSubject$.next({text:this.config.errorMessage??"An error occured",source:"system"}),new j)),_e(()=>this.poll().pipe(pi(()=>this.poll()),fi())))}reconnect(){return this.poll().pipe(pi(()=>this.poll()),fi())}poll(){return ic(()=>Ve(this.client.chatRead({uid:this.sessionId,instance:this.config.instance,entrance:this.config.entrance,maxObjectId:this.lastObjectId})).pipe(hc(e=>{this.processMessages(e)})))}async chatWrite(e){const t=await this.client.chatWrite({uid:this.sessionId,instance:this.config.instance,clockstamp:Date.now().toString(),message:e}),i=((t==null?void 0:t.dataObjects)||[]).find(s=>we(s)&&s.infoType==="error");if(i)throw new Un(i.text||"Unable to send message")}sendPenStatusOn(e){this.client.sendPenStatusOn({uid:this.sessionId,instance:this.config.instance,key:e})}async videoPrepared(e){await this.client.videoPrepared({uid:this.sessionId,instance:this.config.instance,result:e})}async chatQuit(){await this.client.chatQuit({uid:this.sessionId,instance:this.config.instance})}async chatEmailSession(e){const t=await this.client.chatEmailSession({uid:this.sessionId,instance:this.config.instance,emailAddress:e});if(((t==null?void 0:t.dataObjects)||[]).find(s=>we(s)&&s.infoType==="error"))throw new Un("Unable to send email with conversation")}processMessages(e){e.dataObjects.forEach(t=>{Od(t)&&t.source&&t.objectId>=this.lastObjectId&&this.messageSubject$.next({text:t.message,source:t.source,invitationNo:t.invitationNo.toString(),alias:t.alias}),Ld(t)&&this.actionsSubject$.next({penStatus:t.penStatus,type:"pen-status"}),we(t)&&t.infoType==="queue"&&this.actionsSubject$.next({text:t.text,type:"queue-status"}),we(t)&&t.infoType==="established"&&this.actionsSubject$.next({text:t.text,agent:t.agent,type:"established",videoEnded:t.videoEnded,contactId:t.contactId,agentUsername:t.agentUsername,entrance:t.entrance,errand:t.errand}),we(t)&&t.infoType==="prepareVideo"&&this.actionsSubject$.next({type:"prepareVideo"}),we(t)&&t.infoType==="videoPrepared"&&this.actionsSubject$.next({text:t.text,agent:t.agent,type:"videoPrepared",userUrl:t.userUrl}),Rd(t)&&this.actionsSubject$.next({guestId:t.guestId,type:"chatButtonClicked"}),Id(t)&&this.actionsSubject$.next({guestId:t.guestId,type:"endVideoButtonClicked"}),we(t)&&["afterChat","finished"].includes(t.infoType)&&this.actionsSubject$.next({text:t.text,type:"chat-ended",showForm:t.infoType==="afterChat",contactId:t.contactId})}),this.lastObjectId=e.maxObjectId}async getChatStatus(){const e=await this.client.chatCheckSession({uid:this.sessionId,instance:this.config.instance});if(!e)return"noSession";const t=e.dataObjects;for(const i of t)if(we(i))switch(i.infoType){case"finished":case"afterChat":return"finished";case"noSession":return"noSession"}return"active"}async rehydrate(){const e=await this.client.chatCheckSession({uid:this.sessionId,instance:this.config.instance});return!e||(e.dataObjects||[]).find(t=>we(t)&&t.infoType==="noSession")?null:(this.processMessages(e),e)}}class Ie{constructor(e){this._email="",this._host=e,e.addController(this)}static getInstance(e){return Ie.instance?Ie.instance.updateHost(e):Ie.instance=new Ie(e),Ie.instance}updateHost(e){this._host=e,e.addController(this)}hostConnected(){}set email(e){this._email=e,this._host.requestUpdate()}get email(){return this._email}clearData(){this._email="",this._host.requestUpdate()}}var qd=Object.defineProperty,xt=(n,e,t,i)=>{for(var s=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(e,t,s)||s);return s&&qd(e,t,s),s},ft;let Je=(ft=class extends E{constructor(){super(),this.submitted=!1,this.customData=[],this.customerName="",this.validationErrors=[],this.showValidationWarning=!1,this.emailController=Ie.getInstance(this),this.emailController.clearData()}connectedCallback(){var r,o,a,l;super.connectedCallback();const e=this.application.settings.components.conversation,t=this.application.userData,i=((o=(r=e==null?void 0:e.properties)==null?void 0:r.chat)==null?void 0:o.customData)||[];this.customData=i.map(c=>{let u;switch(c.entryType){case"text":case"dropdown":u="";break;case"number":u=0;break;case"boolean":u=!1;break}return{...c,value:u}});const s=this.customData.find(c=>c.name==="customerName");s&&(this.customerName=((l=(a=t.completionData)==null?void 0:a.user)==null?void 0:l.name)||"",s.value=this.customerName)}_onStartChat(e){if(e.preventDefault(),this.showValidationWarning=!1,this.customData.forEach(c=>{this.validateCustomDataEntry(c)}),this.validationErrors.length>0){this.showValidationWarning=!0;return}this.submitted=!0;const t=this.customData.find(c=>c.name==="customerEmailAddress");t&&(this.emailController.email=t.value);const i=this.customData.reduce((c,u)=>(c[u.name]=u.value,c),{}),{customerName:s,customerEmailAddress:r,visitorQuestion:o,...a}=i,l=new CustomEvent("action",{bubbles:!0,composed:!0,detail:{key:"submitted",data:{name:s,email:r,question:o,customData:a}}});this.dispatchEvent(l)}_customDataValueChanged(e,t){this.customData=this.customData.map(i=>(i.name===t.name&&(i.value=e),i))}validateCustomDataEntry(e){e.required&&(e.name==="customerEmailAddress"&&!Yi(e.value)?this.validationErrors.includes(e.name)||this.validationErrors.push(e.name):e.value?this.validationErrors=this.validationErrors.filter(t=>t!==e.name):this.validationErrors.includes(e.name)||this.validationErrors.push(e.name))}render(){if(this.submitted)return w;const e=this.application.texts;return y`<div class="container">
|
|
1277
|
+
`];let le=Ns;Oe([O()],le.prototype,"message");Oe([O()],le.prototype,"disabledInput");Oe([O()],le.prototype,"disabledSkipToLatest");Oe([O()],le.prototype,"disabledSubmit");Oe([O()],le.prototype,"chatOverlayActive");Oe([O()],le.prototype,"textAreaLength");Oe([O()],le.prototype,"platform");Oe([O()],le.prototype,"entries");Oe([O()],le.prototype,"typing");const we=n=>n.objectType==="info",Od=n=>n.objectType==="chatEntry",Ld=n=>n.objectType==="pen",Rd=n=>n.objectType==="chatButtonClicked",Id=n=>n.objectType==="endVideoButtonClicked",Pd=n=>n.type==="queue-status",Md=n=>n.type==="established",Dd=n=>n.type==="pen-status",Ud=n=>n.type==="prepareVideo",Nd=n=>n.type==="videoPrepared",zd=n=>n.type==="chatButtonClicked",jd=n=>n.type==="endVideoButtonClicked",Hd=n=>n.type==="chat-ended";class Un extends Error{constructor(e){super(e),this.name="EngineException"}}class xs{constructor(e,t){this.endpoint=e,this.timeout=t,this.protocolVersion="A",this.penStatusJustSent=!1}async chatJoin(e){var i,s,r;const t=await this.sendRequest("chatJoin",{invitationUid:e.invitationUid,uid:e.uid,instance:e.instance,protocolVersion:this.protocolVersion,videoChatMode:e.videoChatMode,customerName:e.customerName});if(!t.dataObjects||!((i=t==null?void 0:t.dataObjects)!=null&&i.length)||((s=t==null?void 0:t.dataObjects[0])==null?void 0:s.infoType)==="error")throw t.dataObjects?new Error(`chatRequest - ${(r=t==null?void 0:t.dataObjects[0])==null?void 0:r.text}`):new Error("chatRequest - unknown error")}async chatRequest(e){var i,s,r,o,a;const t=await this.sendRequest("chatRequest",{...e.customData,uid:e.uid,instance:e.instance,queueMessageInterval:e.queueMessageInterval.toString(),protocolVersion:this.protocolVersion,entrance:e.entrance,errand:e.errand.length?e.errand:"997",videoChatMode:e.videoChatMode,customerName:e.customerName,customerEmailAddress:e.customerEmailAddress,visitorQuestion:e.visitorQuestion,visitorUserAgent:((i=window==null?void 0:window.navigator)==null?void 0:i.userAgent)||"",sourceUrl:((s=window==null?void 0:window.location)==null?void 0:s.href)||"",...e.authToken&&{authToken:e.authToken}});if(!t.dataObjects||!((r=t==null?void 0:t.dataObjects)!=null&&r.length)||((o=t==null?void 0:t.dataObjects[0])==null?void 0:o.infoType)==="error")throw t.dataObjects?new Error(`chatRequest - ${(a=t==null?void 0:t.dataObjects[0])==null?void 0:a.text}`):new Error("chatRequest - unknown error")}async videoPrepared(e){await this.sendRequest("videoPrepared",{uid:e.uid,instance:e.instance,result:e.result,protocolVersion:this.protocolVersion})}chatRead(e){return this.sendRequest("chatRead",{uid:e.uid,instance:e.instance,entrance:e.entrance,maxObjectId:`${e.maxObjectId}`,protocolVersion:this.protocolVersion})}sendPenStatusOn(e){if(this.penStatusTimer&&clearTimeout(this.penStatusTimer),e.key==="Enter"){this.penStatusJustSent=!1;return}this.penStatusJustSent||(this.sendRequest("chatPenStatus",{uid:e.uid,instance:e.instance,penStatus:"on",protocolVersion:this.protocolVersion}),this.penStatusJustSent=!0,setTimeout(()=>{this.penStatusJustSent=!1},5e3)),this.penStatusTimer=setTimeout(()=>this.sendPenStatusOff(e),5e3)}sendPenStatusOff(e){this.penStatusJustSent&&clearTimeout(this.penStatusTimer),this.sendRequest("chatPenStatus",{uid:e.uid,instance:e.instance,penStatus:"off",protocolVersion:this.protocolVersion})}chatWrite(e){return this.sendPenStatusOff(e),this.sendRequest("chatWrite",{uid:e.uid,instance:e.instance,clockstamp:e.clockstamp,message:e.message,protocolVersion:this.protocolVersion})}async chatQuit(e){this.sendPenStatusOff(e),await this.sendRequest("chatQuit",{uid:e.uid,instance:e.instance,protocolVersion:this.protocolVersion})}async chatCheckSession(e){var i;const t=await this.sendRequest("chatCheckSession",{uid:e.uid,instance:e.instance,protocolVersion:this.protocolVersion});return Object.keys(t).length===0?null:((i=t.dataObjects)==null||i.sort((s,r)=>s.objectId-r.objectId),t)}async chatEmailSession(e){return this.sendRequest("chatEmailSession",{uid:e.uid,instance:e.instance,emailAddress:e.emailAddress,protocolVersion:this.protocolVersion})}async sendRequest(e,t){const i=this.endpoint.includes("engine-simulator")?"include":void 0,s=`${xs.removeTrailingSlashes(this.endpoint)}/${e}`,r=await fetch(s,{body:new URLSearchParams(t),method:"POST",credentials:i,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"*/*"},signal:this.timeout?AbortSignal.timeout(this.timeout):void 0});return Number(r.headers.get("content-length"))>0?r.json():{}}static removeTrailingSlashes(e){return e.replace(/\/+$/,"")}}const Fd=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+n/4).toString(16)),Zi=()=>typeof crypto.randomUUID=="function"?crypto.randomUUID():Fd();function Yi(n){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)}function Wa(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}class Bd{constructor(e,t){this.config=e,this.messageSubject$=new P,this.actionsSubject$=new P,this.messages=()=>this.messageSubject$.asObservable(),this.actions=()=>this.actionsSubject$.asObservable(),this.sessionId="",this.lastObjectId=0,this.sessionId=t??Zi(),this.client=new xs(this.config.engineUrl,this.config.engineTimeout)}chatJoin(e){return Ve(this.client.chatJoin({invitationUid:e.invitationUid,uid:this.sessionId,customerName:e.customerName,instance:this.config.instance,videoChatMode:this.config.videoChatMode})).pipe(Li(t=>(console.error(t),this.messageSubject$.next({text:this.config.errorMessage??"An error occured",source:"system"}),new j)),_e(()=>this.poll().pipe(pi(()=>this.poll()),fi())))}chatRequest(e){return Ve(this.client.chatRequest({uid:this.sessionId,customerName:e.customerName,customerEmailAddress:e.customerEmailAddress,visitorQuestion:e.visitorQuestion,instance:this.config.instance,queueMessageInterval:this.config.queueMessageInterval,entrance:this.config.entrance,errand:e.errand,videoChatMode:this.config.videoChatMode,customData:e.customData,...e.authToken&&{authToken:e.authToken}})).pipe(Li(t=>(console.error(t),this.messageSubject$.next({text:this.config.errorMessage??"An error occured",source:"system"}),new j)),_e(()=>this.poll().pipe(pi(()=>this.poll()),fi())))}reconnect(){return this.poll().pipe(pi(()=>this.poll()),fi())}poll(){return ic(()=>Ve(this.client.chatRead({uid:this.sessionId,instance:this.config.instance,entrance:this.config.entrance,maxObjectId:this.lastObjectId})).pipe(hc(e=>{this.processMessages(e)})))}async chatWrite(e){const t=await this.client.chatWrite({uid:this.sessionId,instance:this.config.instance,clockstamp:Date.now().toString(),message:e}),i=((t==null?void 0:t.dataObjects)||[]).find(s=>we(s)&&s.infoType==="error");if(i)throw new Un(i.text||"Unable to send message")}sendPenStatusOn(e){this.client.sendPenStatusOn({uid:this.sessionId,instance:this.config.instance,key:e})}async videoPrepared(e){await this.client.videoPrepared({uid:this.sessionId,instance:this.config.instance,result:e})}async chatQuit(){await this.client.chatQuit({uid:this.sessionId,instance:this.config.instance})}async chatEmailSession(e){const t=await this.client.chatEmailSession({uid:this.sessionId,instance:this.config.instance,emailAddress:e});if(((t==null?void 0:t.dataObjects)||[]).find(s=>we(s)&&s.infoType==="error"))throw new Un("Unable to send email with conversation")}processMessages(e){e.dataObjects.forEach(t=>{Od(t)&&t.source&&t.objectId>=this.lastObjectId&&this.messageSubject$.next({text:t.message,source:t.source,invitationNo:t.invitationNo.toString(),alias:t.alias}),Ld(t)&&this.actionsSubject$.next({penStatus:t.penStatus,type:"pen-status"}),we(t)&&t.infoType==="queue"&&this.actionsSubject$.next({text:t.text,type:"queue-status"}),we(t)&&t.infoType==="established"&&this.actionsSubject$.next({text:t.text,agent:t.agent,type:"established",videoEnded:t.videoEnded,contactId:t.contactId,agentUsername:t.agentUsername,entrance:t.entrance,errand:t.errand}),we(t)&&t.infoType==="prepareVideo"&&this.actionsSubject$.next({type:"prepareVideo"}),we(t)&&t.infoType==="videoPrepared"&&this.actionsSubject$.next({text:t.text,agent:t.agent,type:"videoPrepared",userUrl:t.userUrl}),Rd(t)&&this.actionsSubject$.next({guestId:t.guestId,type:"chatButtonClicked"}),Id(t)&&this.actionsSubject$.next({guestId:t.guestId,type:"endVideoButtonClicked"}),we(t)&&["afterChat","finished"].includes(t.infoType)&&this.actionsSubject$.next({text:t.text,type:"chat-ended",showForm:t.infoType==="afterChat",contactId:t.contactId})}),this.lastObjectId=e.maxObjectId}async getChatStatus(){const e=await this.client.chatCheckSession({uid:this.sessionId,instance:this.config.instance});if(!e)return"noSession";const t=e.dataObjects;for(const i of t)if(we(i))switch(i.infoType){case"finished":case"afterChat":return"finished";case"noSession":return"noSession"}return"active"}async rehydrate(){const e=await this.client.chatCheckSession({uid:this.sessionId,instance:this.config.instance});return!e||(e.dataObjects||[]).find(t=>we(t)&&t.infoType==="noSession")?null:(this.processMessages(e),e)}}class Ie{constructor(e){this._email="",this._host=e,e.addController(this)}static getInstance(e){return Ie.instance?Ie.instance.updateHost(e):Ie.instance=new Ie(e),Ie.instance}updateHost(e){this._host=e,e.addController(this)}hostConnected(){}set email(e){this._email=e,this._host.requestUpdate()}get email(){return this._email}clearData(){this._email="",this._host.requestUpdate()}}var qd=Object.defineProperty,xt=(n,e,t,i)=>{for(var s=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(e,t,s)||s);return s&&qd(e,t,s),s},ft;let Je=(ft=class extends E{constructor(){super(),this.submitted=!1,this.customData=[],this.customerName="",this.validationErrors=[],this.showValidationWarning=!1,this.emailController=Ie.getInstance(this),this.emailController.clearData()}connectedCallback(){var r,o,a,l;super.connectedCallback();const e=this.application.settings.components.conversation,t=this.application.userData,i=((o=(r=e==null?void 0:e.properties)==null?void 0:r.chat)==null?void 0:o.customData)??[];this.customData=i.map(c=>{let u;switch(c.entryType){case"text":case"dropdown":u="";break;case"number":u=0;break;case"boolean":u=!1;break}return{...c,value:u}});const s=this.customData.find(c=>c.name==="customerName");s&&(this.customerName=((l=(a=t.completionData)==null?void 0:a.user)==null?void 0:l.name)??"",s.value=this.customerName)}_onStartChat(e){if(e.preventDefault(),this.showValidationWarning=!1,this.customData.forEach(c=>{this.validateCustomDataEntry(c)}),this.validationErrors.length>0){this.showValidationWarning=!0;return}this.submitted=!0;const t=this.customData.find(c=>c.name==="customerEmailAddress");t&&(this.emailController.email=t.value);const i=this.customData.reduce((c,u)=>(c[u.name]=u.value,c),{}),{customerName:s,customerEmailAddress:r,visitorQuestion:o,...a}=i,l=new CustomEvent("action",{bubbles:!0,composed:!0,detail:{key:"submitted",data:{name:s,email:r,question:o,customData:a}}});this.dispatchEvent(l)}_customDataValueChanged(e,t){this.customData=this.customData.map(i=>(i.name===t.name&&(i.value=e),i))}validateCustomDataEntry(e){e.required&&(e.name==="customerEmailAddress"&&!Yi(e.value)||!e.value?this.validationErrors.includes(e.name)||this.validationErrors.push(e.name):this.validationErrors=this.validationErrors.filter(t=>t!==e.name))}render(){if(this.submitted)return w;const e=this.application.texts;return y`<div class="container">
|
|
1278
1278
|
<form class="form" @submit=${this._onStartChat}>
|
|
1279
1279
|
<div class="header-row">
|
|
1280
1280
|
<telia-icon class="header-icon" svg=${Jo.svg}></telia-icon>
|
|
@@ -1730,14 +1730,18 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
1730
1730
|
align-items: center;
|
|
1731
1731
|
}
|
|
1732
1732
|
`];let zn=Fs;Qd([Te({context:ge}),k({attribute:!1})],zn.prototype,"application");window.customElements.get("ace-survey")||window.customElements.define("ace-survey",zn);var Xd=Object.defineProperty,Kd=(n,e,t,i)=>{for(var s=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(e,t,s)||s);return s&&Xd(e,t,s),s};const Bs=class Bs extends E{_onClose(){this.application.trigger&&this.application.trigger.toggleActive()}render(){const e=this.application.texts;return y`<div class="container">
|
|
1733
|
-
<h3>
|
|
1733
|
+
<h3 data-testid="entrance-closed-title">
|
|
1734
1734
|
${e.getOrFallback("entrance-closed.title","We're currently closed")}
|
|
1735
1735
|
</h3>
|
|
1736
|
-
<p>
|
|
1736
|
+
<p data-testid="entrance-closed-ingress">
|
|
1737
1737
|
${e.getOrFallback("entrance-closed.ingress","Our team is currently away, but we'll be back during our regular opening hours.")}
|
|
1738
1738
|
</p>
|
|
1739
1739
|
<div class="button-container">
|
|
1740
|
-
<button
|
|
1740
|
+
<button
|
|
1741
|
+
type="button"
|
|
1742
|
+
@click=${this._onClose}
|
|
1743
|
+
data-testid="entrance-closed-button"
|
|
1744
|
+
>
|
|
1741
1745
|
<telia-icon svg=${as.svg}></telia-icon>
|
|
1742
1746
|
${e.getOrFallback("entrance-closed.close-button","Close chat")}
|
|
1743
1747
|
</button>
|
|
@@ -2079,6 +2083,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
2079
2083
|
target="_blank"
|
|
2080
2084
|
href="${this.tunnistusURL}"
|
|
2081
2085
|
@click=${this._onStartAuth}
|
|
2086
|
+
data-testid="card-auth-link"
|
|
2082
2087
|
>
|
|
2083
2088
|
Authenticate with Tunnistus
|
|
2084
2089
|
<telia-icon svg=${ta.svg} size="sm"></telia-icon>
|
|
@@ -2152,7 +2157,7 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
2152
2157
|
justify-content: center;
|
|
2153
2158
|
align-items: center;
|
|
2154
2159
|
}
|
|
2155
|
-
`];let Qi=Gs;window.customElements.get("tunnistus-
|
|
2160
|
+
`];let Qi=Gs;window.customElements.get("ace-tunnistus-auth-card")||window.customElements.define("ace-tunnistus-auth-card",Qi);/**
|
|
2156
2161
|
* @license
|
|
2157
2162
|
* Copyright 2018 Google LLC
|
|
2158
2163
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -2194,4 +2199,4 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
2194
2199
|
"clientName": "idhub-web-1.0.0",
|
|
2195
2200
|
"orderRef": "${this.orderRef}",
|
|
2196
2201
|
"method": "auth"
|
|
2197
|
-
}`,method:"POST"})).json();return console.log("\x1B[31mID-Hub \x1B[32m - Collect result",t),t}}function up(n){return decodeURIComponent(atob(n).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))}class _s extends vc{constructor(e,t){var i,s;super(e,t),this.agent=this.createAgent(""),this.user=this.createUser(""),this.pendingMessages=[],this.texts=this.component.application.texts,this.isThirdPartyParticipant=this.component.properties.chat.isThirdPartyWidget,this.disconnected$=new P,this.agentUsername=null,this.conversationOption=null,this._conversationOptions={},this.sessionId=null,this.contactId=null,this.errand=null,this.entrance=null,this.guestId=null,this.chatOverlayActive=!1,this.inVideoCall=!1,this._onQueueStatusReceived=r=>{this._setQueueStatus(r.text||null)},this._onEstablished=r=>{this.contactId=r.contactId,this.errand=r.errand,this.entrance=r.entrance,this.agentUsername=r.agentUsername;const o={contactId:this.contactId,errand:this.errand,entrance:this.entrance,agentUsername:this.agentUsername};this.save({survey:o}),this._setQueueStatus(null),this.agent.name=r.agent,r.videoEnded&&this.removeVideo()},this._onPrepareVideo=()=>{this.prepareVideo()},this._onVideoPrepared=r=>{this.showVideo(r.userUrl)},this._onChatButtonClicked=r=>{this.showChatOverVideo(r.guestId)},this._onEndVideoButtonClicked=r=>{this.handleEndVideoConference(r.guestId)},this._onPenStatusChange=r=>{r.penStatus==="on"?this.setTypingState(!0):this.setTypingState(!1)},this._onChatEnded=async r=>{var a,l;this.setToastMessage(null),this.setTypingState(!1),this.videoConfirmDialogEntry&&this.videoConfirmDialogEntry.remove(),this.component.disableInput(),r.showForm&&this.showConversationEndedForm();const o=this.component.application.settings;(a=o==null?void 0:o.survey)!=null&&a.shouldUseSurvey&&((l=o==null?void 0:o.survey)!=null&&l.surveyBaseUrl)&&this.showSurvey(),this.isThirdPartyParticipant?this._removeHeaderOptions():this._setStartNewChatOption(),this.complete()},this.headerComponent=this.component.application.getComponent("widget-header"),this.params=new URLSearchParams(document.location.search),this.invitationUid=this.params.get("invitationUid"),this.customerName=this.params.get("customerName")||void 0,this.properties=t.properties,(i=this.component.application.settings)!=null&&i.auth&&(this.idHubClient=new cp((s=this.component.application.settings)==null?void 0:s.auth))}static getInstance(e,t){return t.providerInstance??(t.providerInstance=new _s(e,t)),t.providerInstance}connect(e={}){super.connect(),this._conversationOptions=e;const t={...this.properties.chat??{},...e},i=!!this.sessionId;if(!i){const r=Zi();this._setSessionId(r)}this.save({chatSessionId:this.sessionId}),this.engine=new Bd(t,this.sessionId),this.engine.messages().subscribe(r=>{switch(r.source){case"agent":this.printAgent(r.text);break;case"customer":this._clearPendingMessages(),this.isThirdPartyParticipant?r.source==="customer"&&r.invitationNo==="0"?this.printAgent(r.text,r.alias):this.printUser(r.text):r.source==="customer"&&Number(r.invitationNo)>0?this.printAgent(r.text,r.alias):this.printUser(r.text);break;case"system":this.printSystem(r.text);break}}),this.engine.actions().pipe(B(this.disconnected$),K(Pd)).subscribe(this._onQueueStatusReceived),this.engine.actions().pipe(B(this.disconnected$),K(Md)).subscribe(this._onEstablished),this.engine.actions().pipe(B(this.disconnected$),K(Ud)).subscribe(this._onPrepareVideo),this.engine.actions().pipe(B(this.disconnected$),K(Nd)).subscribe(this._onVideoPrepared),this.engine.actions().pipe(B(this.disconnected$),K(zd)).subscribe(this._onChatButtonClicked),this.engine.actions().pipe(B(this.disconnected$),K(jd)).subscribe(this._onEndVideoButtonClicked),this.engine.actions().pipe(B(this.disconnected$),K(Dd)).subscribe(this._onPenStatusChange),this.engine.actions().pipe(B(this.disconnected$),K(Hd)).subscribe(this._onChatEnded),this.setHeaderOption();const s=this.component.application.trigger;s&&s.widgetActive$.pipe(B(s.componentIsDestroyed$)).subscribe(r=>{r&&(this.conversationOption=null,this.setHeaderOption())}),this.component.userTyping$.pipe(B(this.disconnected$)).subscribe(r=>{var o;(o=this.engine)==null||o.sendPenStatusOn(r)}),i?this.engine.rehydrate().then(r=>{var o;r?(o=this.engine)==null||o.reconnect().pipe(B(this.disconnected$)).subscribe({error:a=>{console.error("Failed to reconnect to the engine:",a)}}):this.initializeChat(t).catch(a=>{console.error("Failed to initialize chat during rehydration:",a)})}):this.initializeChat(t).catch(r=>{console.error("Failed to initialize chat:",r)})}async setHeaderOption(){switch(await this.engine.getChatStatus()){case"finished":this.isThirdPartyParticipant?this._removeHeaderOptions():this._setStartNewChatOption();break;case"active":this._setEndConversationOption();break;case"noSession":this.conversationOption=null}}disconnected(){super.disconnected(),this.disconnected$.next()}_removeHeaderOptions(){const e=this.component.application.getComponent("widget-header");e&&e.removeOption(this.conversationOption)}_addHeaderOptions(e,t,i,s,r=!0){const o=this.component.application.getComponent("widget-header");if(o)return this.conversationOption?(this.conversationOption.label=e,this.conversationOption.key=t,this.conversationOption.icon=i,this.conversationOption.onClick=s,this.conversationOption.enabled=r,o.requestUpdate(),this.conversationOption):o.addOption({label:e,icon:i,closeOnClick:!0,key:t,onClick:s,enabled:r})}_startChat(e){var i,s;if(!this.engine)return;const t=e.customData.errand??this.engine.config.defaultErrand;if(!t)throw new Error("Errand is required but was not configured");if(this.isThirdPartyParticipant)this.component.application.root.style.visibility="visible",this.engine.chatJoin({invitationUid:this.invitationUid,customerName:this.customerName??e.customerName}).pipe(B(this.disconnected$)).subscribe();else{const r=(s=(i=this.component.application)==null?void 0:i.userData)==null?void 0:s.idhubEIDToken;this.engine.chatRequest({customerName:e.customerName,customerEmailAddress:e.customerEmailAddress??"",visitorQuestion:e.visitorQuestion??"",customData:e.customData,errand:t,...r&&{authToken:r}}).pipe(B(this.disconnected$)).subscribe()}this.component.enableInput(),this.component.enableSkipToLatestMessage(),this._setEndConversationOption()}_restartNewChat(){this.engine&&(this._setSessionId(null),this.component.clearMessages(),this._removeHeaderOptions(),this.connect(this._conversationOptions))}showSurvey(){const e=new J(z.System,{name:""},[{items:[["ace-survey",{content:""},{agentUsername:this.agentUsername??"",entrance:this.entrance??this.engine.config.entrance,errand:this.errand??this.engine.config.defaultErrand,contactId:this.contactId??""}]]}]);this.printEntry(e)}async startAuthenticationFlow(){var i;const e=await((i=this.idHubClient)==null?void 0:i.auth());let t;e&&(this.headerComponent.authUrl=e,this.headerComponent.provider=this,this.headerComponent.authState="non-authenticated",t=this.showTunnistusLinkButton(e),this.headerComponent.idref=t,t.actions$.pipe(K(s=>s.key==="start-auth"),he(1)).subscribe(()=>{this.handleAuthentication(t)}))}async handleAuthentication(e){var i,s,r,o;this.headerComponent.UserName="Authenticating...",this.headerComponent.authState="authenticating",this.headerComponent.requestUpdate();const t=await((i=this.idHubClient)==null?void 0:i.collectPolling());if(this.component.application.userData=t,(t==null?void 0:t.status)==="authenticated"){const a=up(((s=t==null?void 0:t.idhubEIDToken)==null?void 0:s.split(".")[1])||""),l=JSON.parse(a),c=((o=(r=l==null?void 0:l.completionData)==null?void 0:r.user)==null?void 0:o.name)||"";this.headerComponent.UserName=c,this.headerComponent.authState="authenticated",this.component.application.storage.set("auth",{name:c,authenticated:!0}),e==null||e.remove(),this.handleWelcomeForm(this.engine.config)}}async handleWelcomeForm(e){let t=!0;e.webApiUrl&&(t=await this.isEntranceOpen(e.webApiUrl,e.entrance)),t?this.customerName?this._startChat({customerName:this.customerName,customData:{}}):this.showWelcomeForm():this.showEntranceClosedDialog()}async initializeChat(e){var t,i;(i=(t=this.component.application.settings)==null?void 0:t.auth)!=null&&i.shouldUseAuth?await this.startAuthenticationFlow():this.handleWelcomeForm(e)}showTunnistusLinkButton(e){const t=new J(z.System,{name:""},[{items:[["tunnistus-link-button",{content:""},{tunnistusURL:e}]]}]);return this.printEntry(t),t}showWelcomeForm(){this.component.disableInput(),this.component.disableSkipToLatestMessage();let e;this.isThirdPartyParticipant?e=new J(z.System,{name:""},[{items:[["ace-welcome-form-third-party",{content:""}]]}]):e=new J(z.System,{name:""},[{items:[["ace-welcome-form",{content:""}]]}]),this.printEntry(e),e.actions$.pipe(K(t=>t.key==="submitted"),he(1)).subscribe(t=>{e.remove(),this._startChat({customerName:t.data.name,customerEmailAddress:t.data.email,visitorQuestion:t.data.question,customData:t.data.customData})})}showEntranceClosedDialog(){this.component.disableInput();const e=new J(z.System,{name:""},[{items:[["ace-entrance-closed-dialog",{content:""}]]}]);this.printEntry(e)}_setQueueStatus(e){this.setToastMessage(e)}showLogoutConfirmDialog(){var e;(e=this.logoutConfirmDialogEntry)==null||e.remove(),this.logoutConfirmDialogEntry=new J(z.System,{name:""},[{items:[["ace-logout-confirm-dialog",{content:""}]]}]),this.printEntry(this.logoutConfirmDialogEntry),this.logoutConfirmDialogEntry.actions$.pipe(K(t=>t.key==="logout-chat"),he(1)).subscribe(async t=>{var i;this.logoutConfirmDialogEntry&&this.logoutConfirmDialogEntry.remove(),((i=t.data)==null?void 0:i.result)==="logout"&&(await this.engine.getChatStatus()==="noSession"?(this.headerComponent._logout(),this._setSessionId(null),this.component.clearMessages(),this.startAuthenticationFlow()):this.endConversation())})}showQuitConfirmDialog(){var e;(e=this.quitConfirmDialogEntry)==null||e.remove(),this.quitConfirmDialogEntry=new J(z.System,{name:""},[{items:[["ace-quit-confirm-dialog",{content:""}]]}]),this.printEntry(this.quitConfirmDialogEntry),this.quitConfirmDialogEntry.actions$.pipe(K(t=>t.key==="quit-chat"),he(1)).subscribe(t=>{var i;this.quitConfirmDialogEntry&&this.quitConfirmDialogEntry.remove(),((i=t.data)==null?void 0:i.result)==="quit"&&this.endConversation()})}showConversationEndedForm(){const e=new J(z.System,{name:""},[{items:[["ace-conversation-ended-form",{content:""}]]}]);this.printEntry(e),e.actions$.pipe(K(t=>t.key==="submitted"),he(1)).subscribe(t=>{e.remove(),t.data.email&&this.sendConversationEmail(t.data.email)})}prepareVideo(){this.videoConfirmDialogEntry=new J(z.System,{name:""},[{items:[["ace-video-confirm-dialog",{content:""}]]}]),this.printEntry(this.videoConfirmDialogEntry),this.videoConfirmDialogEntry.actions$.pipe(K(e=>e.key==="video-confirm"),he(1)).subscribe(e=>{var t;this.videoConfirmDialogEntry&&this.videoConfirmDialogEntry.remove(),e.data.result==="declined"&&(this.guestId=null),(t=this.engine)==null||t.videoPrepared(e.data.result),this.printSystem(e.data.text)})}showVideo(e){var i;this.guestId=Zi(),this.videoIFrameElement=new Zt(e,this.guestId);const t=this.component.application.root;(i=t==null?void 0:t.shadowRoot)==null||i.prepend(this.videoIFrameElement),this.inVideoCall=!0,this.setHeaderOption()}showChatOverVideo(e){this.guestId&&e===this.guestId&&(this.chatOverlayActive=!0,this.showChatOverlay$.next(this.chatOverlayActive))}handleEndVideoConference(e){this.guestId&&e===this.guestId&&this.removeVideo()}printAgent(e,t=""){const i=t.length>0?this.agent.print(e,"markdown",t):this.agent.print(e,"markdown");return this.setTypingState(!1),i}printUser(e){const t=Ii(Er(e));return this.user.print(t)}printSystem(e){const t=Ii(Er(e));return this.system.print(t)}_setEndConversationOption(){this.conversationOption=this._addHeaderOptions(this.texts.getOrFallback("widget-header.end-conversation","End conversation"),"end-conversation-button",as.svg,()=>{this.showQuitConfirmDialog()},!this.inVideoCall)}_setStartNewChatOption(){this.conversationOption=this._addHeaderOptions(this.texts.getOrFallback("widget-header.start-new-chat","Start new chat"),"start-new-chat-button",na.svg,()=>{this._restartNewChat()})}removeVideo(){var e;(e=this.videoIFrameElement)==null||e.remove(),this.guestId=null,this.chatOverlayActive&&(this.chatOverlayActive=!1,this.showChatOverlay$.next(this.chatOverlayActive)),this.inVideoCall=!1,this.setHeaderOption()}async endConversation(){var e,t,i;(t=(e=this.component.application.settings)==null?void 0:e.auth)!=null&&t.shouldUseAuth&&this.headerComponent._logout("chat-ended"),await((i=this.engine)==null?void 0:i.chatQuit())}async sendConversationEmail(e){var t;try{await((t=this.engine)==null?void 0:t.chatEmailSession(e)),this.printSystem(this.texts.getOrFallback("email-form.email-sent-label","An email with the conversation was sent."))}catch(i){this.printSystem(this.texts.getOrFallback("email-form.error-message","Unable to send email with the conversation.")),i instanceof Un||console.warn("Unhandled error:",i)}}_clearPendingMessages(){this.pendingMessages.forEach(e=>{e.remove()})}_setSessionId(e){this.sessionId=e}onUserSubmit(e){const t=this.printUser(e.text);t.setStatus("pending"),this.pendingMessages.push(t),(async()=>{var i;try{await((i=this.engine)==null?void 0:i.chatWrite(e.text))}catch(s){s instanceof Un?t.setStatus("failed"):(t.setStatus("failed"),console.warn("Unhandled error:",s))}})()}async rehydrate(e){e.chatSessionId&&this._setSessionId(e.chatSessionId),e.survey&&(this.contactId=e.survey.contactId,this.errand=e.survey.errand,this.entrance=e.survey.entrance,this.agentUsername=e.survey.agentUsername)}save(e){this.component.stateMachine.session().pipe(_e(t=>(t==null?void 0:t.data$)||Xe),he(1)).subscribe(t=>{this.saveToCurrentSession$.next({...t,...e})})}async isEntranceOpen(e,t){var s;let i=!1;try{const r=await fetch(`${e}/1/entrances/${t}/is-open`),o=await r.json();r.ok?i=(s=o==null?void 0:o.resultData)==null?void 0:s.isOpen:console.log(`Problem when fetching open status for entrance ${t}:`,o==null?void 0:o.resultMessage)}catch(r){console.log(`Failed to fetch open status for ${t}:`,r)}return i}}const hp=async n=>{(await Xi.getInstance(n.container)).registerProvider("ace-chat",t=>_s.getInstance("ace-chat",t))};exports.ChatProviderPlugin=hp;
|
|
2202
|
+
}`,method:"POST"})).json();return console.log("\x1B[31mID-Hub \x1B[32m - Collect result",t),t}}function up(n){return decodeURIComponent(atob(n).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))}class _s extends vc{constructor(e,t){var i,s;super(e,t),this.agent=this.createAgent(""),this.user=this.createUser(""),this.pendingMessages=[],this.texts=this.component.application.texts,this.isThirdPartyParticipant=this.component.properties.chat.isThirdPartyWidget,this.disconnected$=new P,this.agentUsername=null,this.conversationOption=null,this._conversationOptions={},this.sessionId=null,this.contactId=null,this.errand=null,this.entrance=null,this.guestId=null,this.chatOverlayActive=!1,this.inVideoCall=!1,this._onQueueStatusReceived=r=>{this._setQueueStatus(r.text||null)},this._onEstablished=r=>{this.contactId=r.contactId,this.errand=r.errand,this.entrance=r.entrance,this.agentUsername=r.agentUsername;const o={contactId:this.contactId,errand:this.errand,entrance:this.entrance,agentUsername:this.agentUsername};this.save({survey:o}),this._setQueueStatus(null),this.agent.name=r.agent,r.videoEnded&&this.removeVideo()},this._onPrepareVideo=()=>{this.prepareVideo()},this._onVideoPrepared=r=>{this.showVideo(r.userUrl)},this._onChatButtonClicked=r=>{this.showChatOverVideo(r.guestId)},this._onEndVideoButtonClicked=r=>{this.handleEndVideoConference(r.guestId)},this._onPenStatusChange=r=>{r.penStatus==="on"?this.setTypingState(!0):this.setTypingState(!1)},this._onChatEnded=async r=>{var a,l;this.setToastMessage(null),this.setTypingState(!1),this.videoConfirmDialogEntry&&this.videoConfirmDialogEntry.remove(),this.component.disableInput(),r.showForm&&this.showConversationEndedForm();const o=this.component.application.settings;(a=o==null?void 0:o.survey)!=null&&a.shouldUseSurvey&&((l=o==null?void 0:o.survey)!=null&&l.surveyBaseUrl)&&this.showSurvey(),this.isThirdPartyParticipant?this._removeHeaderOptions():this._setStartNewChatOption(),this.complete()},this.headerComponent=this.component.application.getComponent("widget-header"),this.params=new URLSearchParams(document.location.search),this.invitationUid=this.params.get("invitationUid"),this.customerName=this.params.get("customerName")||void 0,this.properties=t.properties,(i=this.component.application.settings)!=null&&i.auth&&(this.idHubClient=new cp((s=this.component.application.settings)==null?void 0:s.auth))}static getInstance(e,t){return t.providerInstance??(t.providerInstance=new _s(e,t)),t.providerInstance}connect(e={}){super.connect(),this._conversationOptions=e;const t={...this.properties.chat??{},...e},i=!!this.sessionId;if(!i){const r=Zi();this._setSessionId(r)}this.save({chatSessionId:this.sessionId}),this.engine=new Bd(t,this.sessionId),this.engine.messages().subscribe(r=>{switch(r.source){case"agent":this.printAgent(r.text);break;case"customer":this._clearPendingMessages(),this.isThirdPartyParticipant?r.source==="customer"&&r.invitationNo==="0"?this.printAgent(r.text,r.alias):this.printUser(r.text):r.source==="customer"&&Number(r.invitationNo)>0?this.printAgent(r.text,r.alias):this.printUser(r.text);break;case"system":this.printSystem(r.text);break}}),this.engine.actions().pipe(B(this.disconnected$),K(Pd)).subscribe(this._onQueueStatusReceived),this.engine.actions().pipe(B(this.disconnected$),K(Md)).subscribe(this._onEstablished),this.engine.actions().pipe(B(this.disconnected$),K(Ud)).subscribe(this._onPrepareVideo),this.engine.actions().pipe(B(this.disconnected$),K(Nd)).subscribe(this._onVideoPrepared),this.engine.actions().pipe(B(this.disconnected$),K(zd)).subscribe(this._onChatButtonClicked),this.engine.actions().pipe(B(this.disconnected$),K(jd)).subscribe(this._onEndVideoButtonClicked),this.engine.actions().pipe(B(this.disconnected$),K(Dd)).subscribe(this._onPenStatusChange),this.engine.actions().pipe(B(this.disconnected$),K(Hd)).subscribe(this._onChatEnded),this.setHeaderOption();const s=this.component.application.trigger;s&&s.widgetActive$.pipe(B(s.componentIsDestroyed$)).subscribe(r=>{r&&(this.conversationOption=null,this.setHeaderOption())}),this.component.userTyping$.pipe(B(this.disconnected$)).subscribe(r=>{var o;(o=this.engine)==null||o.sendPenStatusOn(r)}),i?this.engine.rehydrate().then(r=>{var o;r?(o=this.engine)==null||o.reconnect().pipe(B(this.disconnected$)).subscribe({error:a=>{console.error("Failed to reconnect to the engine:",a)}}):this.initializeChat(t).catch(a=>{console.error("Failed to initialize chat during rehydration:",a)})}):this.initializeChat(t).catch(r=>{console.error("Failed to initialize chat:",r)})}async setHeaderOption(){switch(await this.engine.getChatStatus()){case"finished":this.isThirdPartyParticipant?this._removeHeaderOptions():this._setStartNewChatOption();break;case"active":this._setEndConversationOption();break;case"noSession":this.conversationOption=null}}disconnected(){super.disconnected(),this.disconnected$.next()}_removeHeaderOptions(){const e=this.component.application.getComponent("widget-header");e&&e.removeOption(this.conversationOption)}_addHeaderOptions(e,t,i,s,r=!0){const o=this.component.application.getComponent("widget-header");if(o)return this.conversationOption?(this.conversationOption.label=e,this.conversationOption.key=t,this.conversationOption.icon=i,this.conversationOption.onClick=s,this.conversationOption.enabled=r,o.requestUpdate(),this.conversationOption):o.addOption({label:e,icon:i,closeOnClick:!0,key:t,onClick:s,enabled:r})}_startChat(e){var i,s;if(!this.engine)return;const t=e.customData.errand??this.engine.config.defaultErrand;if(!t)throw new Error("Errand is required but was not configured");if(this.isThirdPartyParticipant)this.component.application.root.style.visibility="visible",this.engine.chatJoin({invitationUid:this.invitationUid,customerName:this.customerName??e.customerName}).pipe(B(this.disconnected$)).subscribe();else{const r=(s=(i=this.component.application)==null?void 0:i.userData)==null?void 0:s.idhubEIDToken;this.engine.chatRequest({customerName:e.customerName,customerEmailAddress:e.customerEmailAddress??"",visitorQuestion:e.visitorQuestion??"",customData:e.customData,errand:t,...r&&{authToken:r}}).pipe(B(this.disconnected$)).subscribe()}this.component.enableInput(),this.component.enableSkipToLatestMessage(),this._setEndConversationOption()}_restartNewChat(){this.engine&&(this._setSessionId(null),this.component.clearMessages(),this._removeHeaderOptions(),this.connect(this._conversationOptions))}showSurvey(){const e=new J(z.System,{name:""},[{items:[["ace-survey",{content:""},{agentUsername:this.agentUsername??"",entrance:this.entrance??this.engine.config.entrance,errand:this.errand??this.engine.config.defaultErrand,contactId:this.contactId??""}]]}]);this.printEntry(e)}async startAuthenticationFlow(){var i;const e=await((i=this.idHubClient)==null?void 0:i.auth());let t;e&&(this.headerComponent.authUrl=e,this.headerComponent.provider=this,this.headerComponent.authState="non-authenticated",t=this.showTunnistusAuthCard(e),this.headerComponent.idref=t,t.actions$.pipe(K(s=>s.key==="start-auth"),he(1)).subscribe(()=>{this.handleAuthentication(t)}))}async handleAuthentication(e){var i,s,r,o;this.headerComponent.UserName="Authenticating...",this.headerComponent.authState="authenticating",this.headerComponent.requestUpdate();const t=await((i=this.idHubClient)==null?void 0:i.collectPolling());if(this.component.application.userData=t,(t==null?void 0:t.status)==="authenticated"){const a=up(((s=t==null?void 0:t.idhubEIDToken)==null?void 0:s.split(".")[1])??""),l=JSON.parse(a),c=((o=(r=l==null?void 0:l.completionData)==null?void 0:r.user)==null?void 0:o.name)??"";this.headerComponent.UserName=c,this.headerComponent.authState="authenticated",this.component.application.storage.set("auth",{name:c,authenticated:!0}),e==null||e.remove(),this.handleWelcomeForm(this.engine.config)}}async handleWelcomeForm(e){let t=!0;e.webApiUrl&&(t=await this.isEntranceOpen(e.webApiUrl,e.entrance)),t?this.customerName?this._startChat({customerName:this.customerName,customData:{}}):this.showWelcomeForm():this.showEntranceClosedDialog()}async initializeChat(e){var t,i;(i=(t=this.component.application.settings)==null?void 0:t.auth)!=null&&i.shouldUseAuth?await this.startAuthenticationFlow():this.handleWelcomeForm(e)}showTunnistusAuthCard(e){const t=new J(z.System,{name:""},[{items:[["ace-tunnistus-auth-card",{content:""},{tunnistusURL:e}]]}]);return this.printEntry(t),t}showWelcomeForm(){this.component.disableInput(),this.component.disableSkipToLatestMessage();let e;this.isThirdPartyParticipant?e=new J(z.System,{name:""},[{items:[["ace-welcome-form-third-party",{content:""}]]}]):e=new J(z.System,{name:""},[{items:[["ace-welcome-form",{content:""}]]}]),this.printEntry(e),e.actions$.pipe(K(t=>t.key==="submitted"),he(1)).subscribe(t=>{e.remove(),this._startChat({customerName:t.data.name,customerEmailAddress:t.data.email,visitorQuestion:t.data.question,customData:t.data.customData})})}showEntranceClosedDialog(){this.component.disableInput();const e=new J(z.System,{name:""},[{items:[["ace-entrance-closed-dialog",{content:""}]]}]);this.printEntry(e)}_setQueueStatus(e){this.setToastMessage(e)}showLogoutConfirmDialog(){var e;(e=this.logoutConfirmDialogEntry)==null||e.remove(),this.logoutConfirmDialogEntry=new J(z.System,{name:""},[{items:[["ace-logout-confirm-dialog",{content:""}]]}]),this.printEntry(this.logoutConfirmDialogEntry),this.logoutConfirmDialogEntry.actions$.pipe(K(t=>t.key==="logout-chat"),he(1)).subscribe(async t=>{var i;this.logoutConfirmDialogEntry&&this.logoutConfirmDialogEntry.remove(),((i=t.data)==null?void 0:i.result)==="logout"&&(await this.engine.getChatStatus()==="noSession"?(this.headerComponent._logout(),this._setSessionId(null),this.component.clearMessages(),this.startAuthenticationFlow()):this.endConversation())})}showQuitConfirmDialog(){var e;(e=this.quitConfirmDialogEntry)==null||e.remove(),this.quitConfirmDialogEntry=new J(z.System,{name:""},[{items:[["ace-quit-confirm-dialog",{content:""}]]}]),this.printEntry(this.quitConfirmDialogEntry),this.quitConfirmDialogEntry.actions$.pipe(K(t=>t.key==="quit-chat"),he(1)).subscribe(t=>{var i;this.quitConfirmDialogEntry&&this.quitConfirmDialogEntry.remove(),((i=t.data)==null?void 0:i.result)==="quit"&&this.endConversation()})}showConversationEndedForm(){const e=new J(z.System,{name:""},[{items:[["ace-conversation-ended-form",{content:""}]]}]);this.printEntry(e),e.actions$.pipe(K(t=>t.key==="submitted"),he(1)).subscribe(t=>{e.remove(),t.data.email&&this.sendConversationEmail(t.data.email)})}prepareVideo(){this.videoConfirmDialogEntry=new J(z.System,{name:""},[{items:[["ace-video-confirm-dialog",{content:""}]]}]),this.printEntry(this.videoConfirmDialogEntry),this.videoConfirmDialogEntry.actions$.pipe(K(e=>e.key==="video-confirm"),he(1)).subscribe(e=>{var t;this.videoConfirmDialogEntry&&this.videoConfirmDialogEntry.remove(),e.data.result==="declined"&&(this.guestId=null),(t=this.engine)==null||t.videoPrepared(e.data.result),this.printSystem(e.data.text)})}showVideo(e){var i;this.guestId=Zi(),this.videoIFrameElement=new Zt(e,this.guestId);const t=this.component.application.root;(i=t==null?void 0:t.shadowRoot)==null||i.prepend(this.videoIFrameElement),this.inVideoCall=!0,this.setHeaderOption()}showChatOverVideo(e){this.guestId&&e===this.guestId&&(this.chatOverlayActive=!0,this.showChatOverlay$.next(this.chatOverlayActive))}handleEndVideoConference(e){this.guestId&&e===this.guestId&&this.removeVideo()}printAgent(e,t=""){const i=t.length>0?this.agent.print(e,"markdown",t):this.agent.print(e,"markdown");return this.setTypingState(!1),i}printUser(e){const t=Ii(Er(e));return this.user.print(t)}printSystem(e){const t=Ii(Er(e));return this.system.print(t)}_setEndConversationOption(){this.conversationOption=this._addHeaderOptions(this.texts.getOrFallback("widget-header.end-conversation","End conversation"),"end-conversation-button",as.svg,()=>{this.showQuitConfirmDialog()},!this.inVideoCall)}_setStartNewChatOption(){this.conversationOption=this._addHeaderOptions(this.texts.getOrFallback("widget-header.start-new-chat","Start new chat"),"start-new-chat-button",na.svg,()=>{this._restartNewChat()})}removeVideo(){var e;(e=this.videoIFrameElement)==null||e.remove(),this.guestId=null,this.chatOverlayActive&&(this.chatOverlayActive=!1,this.showChatOverlay$.next(this.chatOverlayActive)),this.inVideoCall=!1,this.setHeaderOption()}async endConversation(){var e,t,i;(t=(e=this.component.application.settings)==null?void 0:e.auth)!=null&&t.shouldUseAuth&&this.headerComponent._logout("chat-ended"),await((i=this.engine)==null?void 0:i.chatQuit())}async sendConversationEmail(e){var t;try{await((t=this.engine)==null?void 0:t.chatEmailSession(e)),this.printSystem(this.texts.getOrFallback("email-form.email-sent-label","An email with the conversation was sent."))}catch(i){this.printSystem(this.texts.getOrFallback("email-form.error-message","Unable to send email with the conversation.")),i instanceof Un||console.warn("Unhandled error:",i)}}_clearPendingMessages(){this.pendingMessages.forEach(e=>{e.remove()})}_setSessionId(e){this.sessionId=e}onUserSubmit(e){const t=this.printUser(e.text);t.setStatus("pending"),this.pendingMessages.push(t),(async()=>{var i;try{await((i=this.engine)==null?void 0:i.chatWrite(e.text))}catch(s){s instanceof Un?t.setStatus("failed"):(t.setStatus("failed"),console.warn("Unhandled error:",s))}})()}async rehydrate(e){e.chatSessionId&&this._setSessionId(e.chatSessionId),e.survey&&(this.contactId=e.survey.contactId,this.errand=e.survey.errand,this.entrance=e.survey.entrance,this.agentUsername=e.survey.agentUsername)}save(e){this.component.stateMachine.session().pipe(_e(t=>(t==null?void 0:t.data$)||Xe),he(1)).subscribe(t=>{this.saveToCurrentSession$.next({...t,...e})})}async isEntranceOpen(e,t){var s;let i=!1;try{const r=await fetch(`${e}/1/entrances/${t}/is-open`),o=await r.json();r.ok?i=(s=o==null?void 0:o.resultData)==null?void 0:s.isOpen:console.log(`Problem when fetching open status for entrance ${t}:`,o==null?void 0:o.resultMessage)}catch(r){console.log(`Failed to fetch open status for ${t}:`,r)}return i}}const hp=async n=>{(await Xi.getInstance(n.container)).registerProvider("ace-chat",t=>_s.getInstance("ace-chat",t))};exports.ChatProviderPlugin=hp;
|
package/index.mjs
CHANGED
|
@@ -8112,7 +8112,7 @@ let Je = (ft = class extends E {
|
|
|
8112
8112
|
connectedCallback() {
|
|
8113
8113
|
var r, o, a, l;
|
|
8114
8114
|
super.connectedCallback();
|
|
8115
|
-
const e = this.application.settings.components.conversation, t = this.application.userData, i = ((o = (r = e == null ? void 0 : e.properties) == null ? void 0 : r.chat) == null ? void 0 : o.customData)
|
|
8115
|
+
const e = this.application.settings.components.conversation, t = this.application.userData, i = ((o = (r = e == null ? void 0 : e.properties) == null ? void 0 : r.chat) == null ? void 0 : o.customData) ?? [];
|
|
8116
8116
|
this.customData = i.map((c) => {
|
|
8117
8117
|
let u;
|
|
8118
8118
|
switch (c.entryType) {
|
|
@@ -8132,7 +8132,7 @@ let Je = (ft = class extends E {
|
|
|
8132
8132
|
const s = this.customData.find(
|
|
8133
8133
|
(c) => c.name === "customerName"
|
|
8134
8134
|
);
|
|
8135
|
-
s && (this.customerName = ((l = (a = t.completionData) == null ? void 0 : a.user) == null ? void 0 : l.name)
|
|
8135
|
+
s && (this.customerName = ((l = (a = t.completionData) == null ? void 0 : a.user) == null ? void 0 : l.name) ?? "", s.value = this.customerName);
|
|
8136
8136
|
}
|
|
8137
8137
|
_onStartChat(e) {
|
|
8138
8138
|
if (e.preventDefault(), this.showValidationWarning = !1, this.customData.forEach((c) => {
|
|
@@ -8173,9 +8173,9 @@ let Je = (ft = class extends E {
|
|
|
8173
8173
|
this.customData = this.customData.map((i) => (i.name === t.name && (i.value = e), i));
|
|
8174
8174
|
}
|
|
8175
8175
|
validateCustomDataEntry(e) {
|
|
8176
|
-
e.required && (e.name === "customerEmailAddress" && !Yi(e.value) ? this.validationErrors.includes(e.name) || this.validationErrors.push(e.name) :
|
|
8176
|
+
e.required && (e.name === "customerEmailAddress" && !Yi(e.value) || !e.value ? this.validationErrors.includes(e.name) || this.validationErrors.push(e.name) : this.validationErrors = this.validationErrors.filter(
|
|
8177
8177
|
(t) => t !== e.name
|
|
8178
|
-
)
|
|
8178
|
+
));
|
|
8179
8179
|
}
|
|
8180
8180
|
render() {
|
|
8181
8181
|
if (this.submitted)
|
|
@@ -8903,20 +8903,24 @@ const Bs = class Bs extends E {
|
|
|
8903
8903
|
render() {
|
|
8904
8904
|
const e = this.application.texts;
|
|
8905
8905
|
return y`<div class="container">
|
|
8906
|
-
<h3>
|
|
8906
|
+
<h3 data-testid="entrance-closed-title">
|
|
8907
8907
|
${e.getOrFallback(
|
|
8908
8908
|
"entrance-closed.title",
|
|
8909
8909
|
"We're currently closed"
|
|
8910
8910
|
)}
|
|
8911
8911
|
</h3>
|
|
8912
|
-
<p>
|
|
8912
|
+
<p data-testid="entrance-closed-ingress">
|
|
8913
8913
|
${e.getOrFallback(
|
|
8914
8914
|
"entrance-closed.ingress",
|
|
8915
8915
|
"Our team is currently away, but we'll be back during our regular opening hours."
|
|
8916
8916
|
)}
|
|
8917
8917
|
</p>
|
|
8918
8918
|
<div class="button-container">
|
|
8919
|
-
<button
|
|
8919
|
+
<button
|
|
8920
|
+
type="button"
|
|
8921
|
+
@click=${this._onClose}
|
|
8922
|
+
data-testid="entrance-closed-button"
|
|
8923
|
+
>
|
|
8920
8924
|
<telia-icon svg=${as.svg}></telia-icon>
|
|
8921
8925
|
${e.getOrFallback("entrance-closed.close-button", "Close chat")}
|
|
8922
8926
|
</button>
|
|
@@ -9426,6 +9430,7 @@ const Gs = class Gs extends E {
|
|
|
9426
9430
|
target="_blank"
|
|
9427
9431
|
href="${this.tunnistusURL}"
|
|
9428
9432
|
@click=${this._onStartAuth}
|
|
9433
|
+
data-testid="card-auth-link"
|
|
9429
9434
|
>
|
|
9430
9435
|
Authenticate with Tunnistus
|
|
9431
9436
|
<telia-icon svg=${ta.svg} size="sm"></telia-icon>
|
|
@@ -9506,7 +9511,7 @@ Gs.styles = [
|
|
|
9506
9511
|
`
|
|
9507
9512
|
];
|
|
9508
9513
|
let Qi = Gs;
|
|
9509
|
-
window.customElements.get("tunnistus-
|
|
9514
|
+
window.customElements.get("ace-tunnistus-auth-card") || window.customElements.define("ace-tunnistus-auth-card", Qi);
|
|
9510
9515
|
/**
|
|
9511
9516
|
* @license
|
|
9512
9517
|
* Copyright 2018 Google LLC
|
|
@@ -9837,7 +9842,6 @@ class _s extends vc {
|
|
|
9837
9842
|
agentUsername: this.agentUsername ?? "",
|
|
9838
9843
|
entrance: this.entrance ?? this.engine.config.entrance,
|
|
9839
9844
|
errand: this.errand ?? this.engine.config.defaultErrand,
|
|
9840
|
-
// TODO: not always default errand
|
|
9841
9845
|
contactId: this.contactId ?? ""
|
|
9842
9846
|
}
|
|
9843
9847
|
]
|
|
@@ -9851,7 +9855,7 @@ class _s extends vc {
|
|
|
9851
9855
|
var i;
|
|
9852
9856
|
const e = await ((i = this.idHubClient) == null ? void 0 : i.auth());
|
|
9853
9857
|
let t;
|
|
9854
|
-
e && (this.headerComponent.authUrl = e, this.headerComponent.provider = this, this.headerComponent.authState = "non-authenticated", t = this.
|
|
9858
|
+
e && (this.headerComponent.authUrl = e, this.headerComponent.provider = this, this.headerComponent.authState = "non-authenticated", t = this.showTunnistusAuthCard(e), this.headerComponent.idref = t, t.actions$.pipe(
|
|
9855
9859
|
K((s) => s.key === "start-auth"),
|
|
9856
9860
|
he(1)
|
|
9857
9861
|
).subscribe(() => {
|
|
@@ -9864,8 +9868,8 @@ class _s extends vc {
|
|
|
9864
9868
|
const t = await ((i = this.idHubClient) == null ? void 0 : i.collectPolling());
|
|
9865
9869
|
if (this.component.application.userData = t, (t == null ? void 0 : t.status) === "authenticated") {
|
|
9866
9870
|
const a = up(
|
|
9867
|
-
((s = t == null ? void 0 : t.idhubEIDToken) == null ? void 0 : s.split(".")[1])
|
|
9868
|
-
), l = JSON.parse(a), c = ((o = (r = l == null ? void 0 : l.completionData) == null ? void 0 : r.user) == null ? void 0 : o.name)
|
|
9871
|
+
((s = t == null ? void 0 : t.idhubEIDToken) == null ? void 0 : s.split(".")[1]) ?? ""
|
|
9872
|
+
), l = JSON.parse(a), c = ((o = (r = l == null ? void 0 : l.completionData) == null ? void 0 : r.user) == null ? void 0 : o.name) ?? "";
|
|
9869
9873
|
this.headerComponent.UserName = c, this.headerComponent.authState = "authenticated", this.component.application.storage.set("auth", {
|
|
9870
9874
|
name: c,
|
|
9871
9875
|
authenticated: !0
|
|
@@ -9886,7 +9890,7 @@ class _s extends vc {
|
|
|
9886
9890
|
var t, i;
|
|
9887
9891
|
(i = (t = this.component.application.settings) == null ? void 0 : t.auth) != null && i.shouldUseAuth ? await this.startAuthenticationFlow() : this.handleWelcomeForm(e);
|
|
9888
9892
|
}
|
|
9889
|
-
|
|
9893
|
+
showTunnistusAuthCard(e) {
|
|
9890
9894
|
const t = new J(
|
|
9891
9895
|
z.System,
|
|
9892
9896
|
{
|
|
@@ -9896,7 +9900,7 @@ class _s extends vc {
|
|
|
9896
9900
|
{
|
|
9897
9901
|
items: [
|
|
9898
9902
|
[
|
|
9899
|
-
"tunnistus-
|
|
9903
|
+
"ace-tunnistus-auth-card",
|
|
9900
9904
|
{ content: "" },
|
|
9901
9905
|
{
|
|
9902
9906
|
tunnistusURL: e
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/ace-chat-flamingo",
|
|
3
|
-
"version": "1.1.120-rc.
|
|
3
|
+
"version": "1.1.120-rc.7",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@telia-ace/widget-core-flamingo": "1.1.120-rc.
|
|
6
|
-
"@telia-ace/widget-conversation-flamingo": "1.1.120-rc.
|
|
5
|
+
"@telia-ace/widget-core-flamingo": "1.1.120-rc.7",
|
|
6
|
+
"@telia-ace/widget-conversation-flamingo": "1.1.120-rc.7",
|
|
7
7
|
"rxjs": "^7.8.2",
|
|
8
8
|
"lit": "^3.0.2",
|
|
9
9
|
"@teliads/icons": "^8.4.0",
|
package/provider.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class ChatProvider extends ConversationProvider {
|
|
|
8
8
|
private readonly texts;
|
|
9
9
|
private readonly isThirdPartyParticipant;
|
|
10
10
|
private readonly disconnected$;
|
|
11
|
-
private idHubClient?;
|
|
11
|
+
private readonly idHubClient?;
|
|
12
12
|
private engine?;
|
|
13
13
|
private agentUsername;
|
|
14
14
|
private videoConfirmDialogEntry;
|
|
@@ -39,10 +39,10 @@ export declare class ChatProvider extends ConversationProvider {
|
|
|
39
39
|
private readonly _onChatEnded;
|
|
40
40
|
private _removeHeaderOptions;
|
|
41
41
|
private _addHeaderOptions;
|
|
42
|
-
private headerComponent;
|
|
43
|
-
private params;
|
|
44
|
-
private invitationUid;
|
|
45
|
-
private customerName;
|
|
42
|
+
private readonly headerComponent;
|
|
43
|
+
private readonly params;
|
|
44
|
+
private readonly invitationUid;
|
|
45
|
+
private readonly customerName;
|
|
46
46
|
private _startChat;
|
|
47
47
|
private _restartNewChat;
|
|
48
48
|
showSurvey(): void;
|
|
@@ -50,7 +50,7 @@ export declare class ChatProvider extends ConversationProvider {
|
|
|
50
50
|
handleAuthentication(idref: ConversationEntry | undefined): Promise<void>;
|
|
51
51
|
handleWelcomeForm(engineConfig: EngineConfig): Promise<void>;
|
|
52
52
|
initializeChat(engineConfig: EngineConfig): Promise<void>;
|
|
53
|
-
|
|
53
|
+
showTunnistusAuthCard(tunnistusURL: string): ConversationEntry;
|
|
54
54
|
showWelcomeForm(): void;
|
|
55
55
|
showEntranceClosedDialog(): void;
|
|
56
56
|
_setQueueStatus(status: string | null): void;
|
package/types.d.ts
CHANGED
|
@@ -114,3 +114,8 @@ export declare const isVideoPreparedAction: (action: EngineAction) => action is
|
|
|
114
114
|
export declare const isChatButtonClickedAction: (action: EngineAction) => action is ChatButtonClickedAction;
|
|
115
115
|
export declare const isEndVideoButtonClickedAction: (action: EngineAction) => action is EndVideoButtonClickedAction;
|
|
116
116
|
export declare const isChatEndedAction: (action: EngineAction) => action is ChatEndedAction;
|
|
117
|
+
export type AuthenticationInfo = {
|
|
118
|
+
authenticated: boolean;
|
|
119
|
+
name?: string;
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
export declare class
|
|
3
|
-
static styles: import('lit').CSSResult[];
|
|
4
|
-
private tunnistusURL;
|
|
2
|
+
export declare class TunnistusAuthCard extends LitElement {
|
|
3
|
+
static readonly styles: import('lit').CSSResult[];
|
|
4
|
+
private readonly tunnistusURL;
|
|
5
5
|
constructor(params?: {
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
});
|
package/ui/welcome-form.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { LitElement, nothing } from 'lit';
|
|
2
2
|
import { CustomDataEntry } from '../types';
|
|
3
3
|
export declare class StartChatForm extends LitElement {
|
|
4
|
-
static styles: import('lit').CSSResult[];
|
|
4
|
+
static readonly styles: import('lit').CSSResult[];
|
|
5
5
|
submitted: boolean;
|
|
6
6
|
customData: CustomDataEntry[];
|
|
7
7
|
customerName: string;
|
|
8
8
|
validationErrors: string[];
|
|
9
9
|
showValidationWarning: boolean;
|
|
10
|
-
private application;
|
|
11
|
-
private emailController;
|
|
10
|
+
private readonly application;
|
|
11
|
+
private readonly emailController;
|
|
12
12
|
constructor();
|
|
13
13
|
connectedCallback(): void;
|
|
14
14
|
_onStartChat(event: SubmitEvent): void;
|