@telia-ace/ace-chat-flamingo 1.1.122-rc.2 → 1.1.122-rc.4
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 +19 -9
- package/index.mjs +37 -17
- package/package.json +3 -3
- package/ui/logout-confirm-dialog.d.ts +4 -3
- package/ui/quit-confirm-dialog.d.ts +4 -3
package/index.js
CHANGED
|
@@ -950,6 +950,8 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
950
950
|
class="conversation-bottom"
|
|
951
951
|
@submit=${this._onSendMessage}
|
|
952
952
|
${me(this.formRef)}
|
|
953
|
+
?inert=${this.disabledInput}
|
|
954
|
+
data-testid="conversation-bottom"
|
|
953
955
|
>
|
|
954
956
|
<label for="chat-message-input" class="visually-hidden">
|
|
955
957
|
Chat message
|
|
@@ -960,7 +962,6 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
960
962
|
placeholder=${e.getOrFallback("conversation.input-placeholder","Aa")}
|
|
961
963
|
data-testid="message-input"
|
|
962
964
|
.value=${this.message}
|
|
963
|
-
?disabled=${this.disabledInput}
|
|
964
965
|
@input=${this._inputHandler}
|
|
965
966
|
@keydown=${this._keyDownHandler}
|
|
966
967
|
${me(this.inputRef)}
|
|
@@ -976,7 +977,6 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
976
977
|
type="submit"
|
|
977
978
|
data-testid="send-message-button"
|
|
978
979
|
title=${e.getOrFallback("conversation.send-alt","Send")}
|
|
979
|
-
?disabled=${this.disabledSubmit}
|
|
980
980
|
>
|
|
981
981
|
<telia-icon svg=${ra.svg}></telia-icon>
|
|
982
982
|
</button>
|
|
@@ -1935,7 +1935,12 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
1935
1935
|
clip: rect(0, 0, 0, 0);
|
|
1936
1936
|
border: 0;
|
|
1937
1937
|
}
|
|
1938
|
-
`];let Kt=Ys;Qa([k({attribute:!1})],Kt.prototype,"entry");Qa([he({context:re}),k({attribute:!1})],Kt.prototype,"application");window.customElements.get("ace-contact-data-field")||window.customElements.define("ace-contact-data-field",Kt);var op=Object.defineProperty,ap=(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&&op(e,t,s),s};const Qs=class Qs extends _{
|
|
1938
|
+
`];let Kt=Ys;Qa([k({attribute:!1})],Kt.prototype,"entry");Qa([he({context:re}),k({attribute:!1})],Kt.prototype,"application");window.customElements.get("ace-contact-data-field")||window.customElements.define("ace-contact-data-field",Kt);var op=Object.defineProperty,ap=(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&&op(e,t,s),s};const Qs=class Qs extends _{firstUpdated(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".container");e&&e.focus()}onQuit(){this.dispatchResult("quit")}onCancel(){this.dispatchResult("cancel")}dispatchResult(e){const t=new CustomEvent("action",{composed:!0,detail:{key:"quit-chat",data:{result:e}}});this.dispatchEvent(t)}render(){const e=this.application.texts;return y`<div
|
|
1939
|
+
class="container"
|
|
1940
|
+
role="dialog"
|
|
1941
|
+
aria-modal="true"
|
|
1942
|
+
tabindex="-1"
|
|
1943
|
+
>
|
|
1939
1944
|
<h3>
|
|
1940
1945
|
${e.getOrFallback("quit-confirm.title","Do you want to end the chat?")}
|
|
1941
1946
|
</h3>
|
|
@@ -1943,10 +1948,10 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
1943
1948
|
${e.getOrFallback("quit-confirm.ingress","Please reach out to us again if you need help with anything else.")}
|
|
1944
1949
|
</p>
|
|
1945
1950
|
<div class="button-container">
|
|
1946
|
-
<button class="cancel" @click=${this.
|
|
1951
|
+
<button class="cancel" @click=${this.onCancel}>
|
|
1947
1952
|
${e.getOrFallback("quit-confirm.cancel-button","Cancel")}
|
|
1948
1953
|
</button>
|
|
1949
|
-
<button class="quit" @click=${this.
|
|
1954
|
+
<button class="quit" @click=${this.onQuit}>
|
|
1950
1955
|
${e.getOrFallback("quit-confirm.end-chat-button","End chat")}
|
|
1951
1956
|
</button>
|
|
1952
1957
|
</div>
|
|
@@ -2012,7 +2017,12 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
2012
2017
|
button:hover {
|
|
2013
2018
|
filter: brightness(150%);
|
|
2014
2019
|
}
|
|
2015
|
-
`];let Wn=Qs;ap([he({context:re}),k({attribute:!1})],Wn.prototype,"application");window.customElements.get("ace-quit-confirm-dialog")||window.customElements.define("ace-quit-confirm-dialog",Wn);var lp=Object.defineProperty,cp=(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&&lp(e,t,s),s};const Xs=class Xs extends _{
|
|
2020
|
+
`];let Wn=Qs;ap([he({context:re}),k({attribute:!1})],Wn.prototype,"application");window.customElements.get("ace-quit-confirm-dialog")||window.customElements.define("ace-quit-confirm-dialog",Wn);var lp=Object.defineProperty,cp=(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&&lp(e,t,s),s};const Xs=class Xs extends _{firstUpdated(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".container");e&&e.focus()}onQuit(){this.dispatchResult("logout")}onCancel(){this.dispatchResult("cancel")}dispatchResult(e){const t=new CustomEvent("action",{composed:!0,detail:{key:"logout-chat",data:{result:e}}});this.dispatchEvent(t)}render(){const e=this.application.texts;return y`<div
|
|
2021
|
+
class="container"
|
|
2022
|
+
role="dialog"
|
|
2023
|
+
aria-modal="true"
|
|
2024
|
+
tabindex="-1"
|
|
2025
|
+
>
|
|
2016
2026
|
<h3>
|
|
2017
2027
|
${e.getOrFallback("logout-confirm.title","Do you want to log out?")}
|
|
2018
2028
|
</h3>
|
|
@@ -2020,10 +2030,10 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
2020
2030
|
${e.getOrFallback("logout-confirm.ingress","Logging out will end an active chat session")}
|
|
2021
2031
|
</p>
|
|
2022
2032
|
<div class="button-container">
|
|
2023
|
-
<button class="cancel" @click=${this.
|
|
2033
|
+
<button class="cancel" @click=${this.onCancel}>
|
|
2024
2034
|
${e.getOrFallback("logout-confirm.cancel-button","Cancel")}
|
|
2025
2035
|
</button>
|
|
2026
|
-
<button class="quit" @click=${this.
|
|
2036
|
+
<button class="quit" @click=${this.onQuit}>
|
|
2027
2037
|
${e.getOrFallback("logout-confirm.end-chat-button","Log out")}
|
|
2028
2038
|
</button>
|
|
2029
2039
|
</div>
|
|
@@ -2235,4 +2245,4 @@ Please report this to https://github.com/markedjs/marked.`,n){const i="<p>An err
|
|
|
2235
2245
|
border: 1px solid var(--border-color-medium);
|
|
2236
2246
|
box-sizing: border-box;
|
|
2237
2247
|
}
|
|
2238
|
-
`];let Jt=Js;gp([he({context:re}),k({attribute:!1})],Jt.prototype,"application");window.customElements.get("ace-video-iframe")||window.customElements.define("ace-video-iframe",Jt);class Os extends wc{constructor(e,t){var i,s,r,o;super(e,t),this.pendingMessages=[],this.texts=this.component.application.texts,this.headerComponent=this.component.application.getComponent("widget-header"),this.isThirdPartyParticipant=this.component.properties.chat.isThirdPartyWidget,this.agent=this.createAgent(""),this.user=this.createUser(""),this.params=new URLSearchParams(document.location.search),this.invitationUid=this.params.get("invitationUid"),this.customerName=this.params.get("customerName")||void 0,this.idHubUrl="https://idhub.dev-se.telia-ck8s.com/idhub-gateway/public",this.logoutTimer=null,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=a=>{this.setQueueStatus(a.text||null)},this.onEstablished=a=>{this.contactId=a.contactId,this.errand=a.errand,this.entrance=a.entrance,this.agentUsername=a.agentUsername;const l={contactId:this.contactId,errand:this.errand,entrance:this.entrance,agentUsername:this.agentUsername};this.save({survey:l}),this.setQueueStatus(null),this.agent.name=a.agent,a.videoEnded&&this.removeVideo()},this.onPrepareVideo=()=>{this.showVideoConfirmDialog()},this.onVideoPrepared=a=>{this.showVideoIFrame(a.userUrl)},this.onChatButtonClicked=a=>{this.showChatOverVideo(a.guestId)},this.onEndVideoButtonClicked=a=>{this.guestId&&(a==null?void 0:a.guestId)===this.guestId&&this.removeVideo()},this.onPenStatusChange=a=>{a.penStatus==="on"?this.setTypingState(!0):this.setTypingState(!1)},this.onChatEnded=async a=>{var c,u;this.shouldUseAuth&&this.logoutUser(),this.setToastMessage(null),this.setTypingState(!1),this.videoConfirmDialogEntry&&this.videoConfirmDialogEntry.remove(),this.component.disableInput(),a.showForm&&this.showConversationEndedForm();const l=this.component.application.settings;(c=l==null?void 0:l.survey)!=null&&c.shouldUseSurvey&&((u=l==null?void 0:l.survey)!=null&&u.surveyBaseUrl)&&this.showSurvey(),this.isThirdPartyParticipant?this.removeHeaderOptions():this.setStartNewChatOption(),this.complete()},this.properties=t.properties,this.shouldUseAuth=(s=(i=this.component.application.settings)==null?void 0:i.auth)==null?void 0:s.shouldUseAuth,this.idHubEidType=(o=(r=this.component.application.settings)==null?void 0:r.auth)==null?void 0:o.idHubEidType.toLowerCase()}connect(e={}){super.connect(),this.setupAuthenticationListeners(),this._conversationOptions=e;const t={...this.properties.chat??{},...e},i=!!this.sessionId;if(!i){const r=Ji();this.setSessionId(r)}this.save({chatSessionId:this.sessionId}),this.engine=new Yd(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(z(this.disconnected$),W(zd)).subscribe(this.onQueueStatusReceived),this.engine.actions().pipe(z(this.disconnected$),W(Hd)).subscribe(this.onEstablished),this.engine.actions().pipe(z(this.disconnected$),W(Fd)).subscribe(this.onPrepareVideo),this.engine.actions().pipe(z(this.disconnected$),W(Bd)).subscribe(this.onVideoPrepared),this.engine.actions().pipe(z(this.disconnected$),W(qd)).subscribe(this.onChatButtonClicked),this.engine.actions().pipe(z(this.disconnected$),W(Vd)).subscribe(this.onEndVideoButtonClicked),this.engine.actions().pipe(z(this.disconnected$),W(jd)).subscribe(this.onPenStatusChange),this.engine.actions().pipe(z(this.disconnected$),W(Wd)).subscribe(this.onChatEnded),this.setHeaderOption();const s=this.component.application.trigger;s&&s.widgetActive$.pipe(z(s.componentIsDestroyed$)).subscribe(r=>{r&&(this.conversationOption=null,this.setHeaderOption())}),this.component.userTyping$.pipe(z(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(z(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)})}disconnected(){super.disconnected(),this.logoutTimer&&(clearTimeout(this.logoutTimer),this.logoutTimer=null),this.disconnected$.next()}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 Fn?t.setStatus("failed"):(t.setStatus("failed"),console.warn("Unhandled error:",s))}})()}save(e){this.component.stateMachine.session().pipe(Te(t=>(t==null?void 0:t.data$)||tt),fe(1)).subscribe(t=>{this.saveToCurrentSession$.next({...t,...e})})}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)}static getInstance(e,t){return t.providerInstance??(t.providerInstance=new Os(e,t)),t.providerInstance}async initializeChat(e){this.shouldUseAuth&&this.idHubEidType?(this.setupIDHubAuth(),this.idHubClient&&await this.startAuthenticationFlow()):this.handleWelcomeForm(e)}setupAuthenticationListeners(){var e;this.shouldUseAuth&&this.headerComponent&&this.headerComponent.actions$&&((e=this.headerComponent)==null||e.actions$.pipe(W(t=>t.key==="start-auth"||t.key==="logout-auth"),z(this.disconnected$)).subscribe(t=>{t.key==="start-auth"?this.handleAuthentication():t.key==="logout-auth"&&this.showLogoutConfirmDialog()}))}setupIDHubAuth(){var e;this.idHubClient=new Bt({...(e=this.component.application.settings)==null?void 0:e.auth,idHubUrl:this.idHubUrl})}async startAuthenticationFlow(){this.resetAuthState(Pe.NonAuthenticated);const e=await this.idHubClient.auth();if(e.status===H.Error){this.printSystem(this.texts.getOrFallback("auth.setup.error-message","An error occurred while setting up authentication.")),this.headerComponent.showAuthOptions=!1;return}switch(this.idHubEidType){case _e.Tunnistus:if(!e.tunnistusURL){this.printSystem(this.texts.getOrFallback("auth.setup.tunnistus.url-error-message","Unable to retrieve the Tunnistus authentication URL.")),this.headerComponent.showAuthOptions=!1;return}this.authURL=e.tunnistusURL,this.headerComponent.authUrl=e.tunnistusURL,this.headerComponent.authState=Pe.NonAuthenticated,this.authenticationCardEntry=this.showTunnistusAuthCard(Ze.Initial,e.tunnistusURL),this.authenticationCardEntry.actions$.pipe(W(t=>t.key==="start-auth"),fe(1)).subscribe(()=>{this.handleAuthentication()});break;case _e.BankId:break}}async handleWelcomeForm(e,t){let i=!0;e.webApiUrl&&(i=await this.isEntranceOpen(e.webApiUrl,e.entrance)),i?this.customerName?this.startChat({customerName:this.customerName,customData:{}},t):this.showWelcomeForm():this.showEntranceClosedDialog()}startChat(e,t){if(!this.engine)return;const i=e.customData.errand??this.engine.config.defaultErrand;if(!i)throw new Error("Errand is required but was not configured");this.isThirdPartyParticipant?(this.component.application.root.style.visibility="visible",this.engine.chatJoin({invitationUid:this.invitationUid,customerName:this.customerName??e.customerName}).pipe(z(this.disconnected$)).subscribe()):this.engine.chatRequest({customerName:e.customerName,customerEmailAddress:e.customerEmailAddress??"",visitorQuestion:e.visitorQuestion??"",customData:e.customData,errand:i,...t&&{idhubEIDToken:t}}).pipe(z(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))}setQueueStatus(e){this.setToastMessage(e)}async endConversation(){var e;this.shouldUseAuth&&this.resetAuthState(Pe.ChatEnded),await((e=this.engine)==null?void 0:e.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 Fn||console.warn("Unhandled error:",i)}}clearPendingMessages(){this.pendingMessages.forEach(e=>{e.remove()})}setSessionId(e){this.sessionId=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}resetAuthState(e){this.headerComponent.authState=e,this.headerComponent.userName="",this.headerComponent.authUrl="",this.authURL="",this.component.application.storage.removeItem("auth")}async handleAuthentication(){var t,i,s,r;this.headerComponent.userName=this.texts.getOrFallback("widget-header.authenticating","Authenticating..."),this.headerComponent.authState=Pe.Authenticating;const e=await this.idHubClient.collect();switch(this.authenticationCardEntry&&this.authenticationCardEntry.remove(),this.idHubEidType){case _e.Tunnistus:if(e.status===H.Error){this.headerComponent.userName=this.texts.getOrFallback("widget-header.not-authenticated","Not authenticated"),this.headerComponent.authState=Pe.NonAuthenticated,this.authenticationCardEntry=this.showTunnistusAuthCard(Ze.Error,this.authURL);return}else if(e.status===H.Authenticated){const o=Zd(((t=e==null?void 0:e.idhubEIDToken)==null?void 0:t.split(".")[1])??""),a=JSON.parse(o),l=((s=(i=a==null?void 0:a.completionData)==null?void 0:i.user)==null?void 0:s.name)??"",c=a==null?void 0:a.exp;if(typeof c=="number"&&c>0){const u=c*1e3-Date.now();u<=0?this.logoutUser():(this.logoutTimer&&clearTimeout(this.logoutTimer),this.logoutTimer=setTimeout(()=>{this.logoutUser()},u))}this.headerComponent.userName=l,this.headerComponent.authState=Pe.Authenticated,this.component.application.storage.set("auth",{name:l,authenticated:!0}),(r=this.authenticationCardEntry)==null||r.remove(),this.handleWelcomeForm(this.engine.config,e.idhubEIDToken)}break;case _e.BankId:break}}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=Ni(Rr(e));return this.user.print(t)}printSystem(e){const t=Ni(Rr(e));return this.system.print(t)}showSurvey(){const e=new ee(j.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)}showTunnistusAuthCard(e,t,i){const s=new ee(j.System,{name:""},[{items:[["ace-tunnistus-auth-card",{content:""},{state:e,tunnistusURL:t??"",errorMessage:i??""}]]}]);return this.printEntry(s),s}showWelcomeForm(){this.component.disableInput(),this.component.disableSkipToLatestMessage();let e;this.isThirdPartyParticipant?e=new ee(j.System,{name:""},[{items:[["ace-welcome-form-third-party",{content:""}]]}]):e=new ee(j.System,{name:""},[{items:[["ace-welcome-form",{content:""}]]}]),this.printEntry(e),e.actions$.pipe(W(t=>t.key==="submitted"),fe(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 ee(j.System,{name:""},[{items:[["ace-entrance-closed-dialog",{content:""}]]}]);this.printEntry(e)}showQuitConfirmDialog(){var e;(e=this.quitConfirmDialogEntry)==null||e.remove(),this.quitConfirmDialogEntry=new ee(j.System,{name:""},[{items:[["ace-quit-confirm-dialog",{content:""}]]}]),this.printEntry(this.quitConfirmDialogEntry),this.quitConfirmDialogEntry.actions$.pipe(W(t=>t.key==="quit-chat"),fe(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 ee(j.System,{name:""},[{items:[["ace-conversation-ended-form",{content:""}]]}]);this.printEntry(e),e.actions$.pipe(W(t=>t.key==="submitted"),fe(1)).subscribe(t=>{e.remove(),t.data.email&&this.sendConversationEmail(t.data.email)})}showVideoConfirmDialog(){this.videoConfirmDialogEntry=new ee(j.System,{name:""},[{items:[["ace-video-confirm-dialog",{content:""}]]}]),this.printEntry(this.videoConfirmDialogEntry),this.videoConfirmDialogEntry.actions$.pipe(W(e=>e.key==="video-confirm"),fe(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)})}showVideoIFrame(e){var i;this.guestId=Ji(),this.videoIFrameElement=new Jt(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))}async logoutUser(){this.logoutConfirmDialogEntry&&this.logoutConfirmDialogEntry.remove(),await this.engine.getChatStatus()==="noSession"?(this.resetAuthState(Pe.NonAuthenticated),this.setSessionId(null),this.component.clearMessages(),this.shouldUseAuth&&this.startAuthenticationFlow()):this.endConversation()}showLogoutConfirmDialog(){var e;(e=this.logoutConfirmDialogEntry)==null||e.remove(),this.logoutConfirmDialogEntry=new ee(j.System,{name:""},[{items:[["ace-logout-confirm-dialog",{content:""}]]}]),this.printEntry(this.logoutConfirmDialogEntry),this.logoutConfirmDialogEntry.actions$.pipe(W(t=>t.key==="logout-chat"),fe(1)).subscribe(async t=>{var i;((i=t.data)==null?void 0:i.result)==="logout"&&this.logoutUser()})}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()}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})}removeHeaderOptions(){const e=this.component.application.getComponent("widget-header");e&&e.removeOption(this.conversationOption)}setStartNewChatOption(){this.conversationOption=this.addHeaderOptions(this.texts.getOrFallback("widget-header.start-new-chat","Start new chat"),"start-new-chat-button",ra.svg,()=>{this.restartNewChat()})}setEndConversationOption(){this.conversationOption=this.addHeaderOptions(this.texts.getOrFallback("widget-header.end-conversation","End conversation"),"end-conversation-button",hs.svg,()=>{this.showQuitConfirmDialog()},!this.inVideoCall)}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}}}const mp=async n=>{(await os.getInstance(n.container)).registerProvider("ace-chat",t=>Os.getInstance("ace-chat",t))};exports.ChatProviderPlugin=mp;
|
|
2248
|
+
`];let Jt=Js;gp([he({context:re}),k({attribute:!1})],Jt.prototype,"application");window.customElements.get("ace-video-iframe")||window.customElements.define("ace-video-iframe",Jt);class Os extends wc{constructor(e,t){var i,s,r,o;super(e,t),this.pendingMessages=[],this.texts=this.component.application.texts,this.headerComponent=this.component.application.getComponent("widget-header"),this.isThirdPartyParticipant=this.component.properties.chat.isThirdPartyWidget,this.agent=this.createAgent(""),this.user=this.createUser(""),this.params=new URLSearchParams(document.location.search),this.invitationUid=this.params.get("invitationUid"),this.customerName=this.params.get("customerName")||void 0,this.idHubUrl="https://idhub.dev-se.telia-ck8s.com/idhub-gateway/public",this.logoutTimer=null,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=a=>{this.setQueueStatus(a.text||null)},this.onEstablished=a=>{this.contactId=a.contactId,this.errand=a.errand,this.entrance=a.entrance,this.agentUsername=a.agentUsername;const l={contactId:this.contactId,errand:this.errand,entrance:this.entrance,agentUsername:this.agentUsername};this.save({survey:l}),this.setQueueStatus(null),this.agent.name=a.agent,a.videoEnded&&this.removeVideo()},this.onPrepareVideo=()=>{this.showVideoConfirmDialog()},this.onVideoPrepared=a=>{this.showVideoIFrame(a.userUrl)},this.onChatButtonClicked=a=>{this.showChatOverVideo(a.guestId)},this.onEndVideoButtonClicked=a=>{this.guestId&&(a==null?void 0:a.guestId)===this.guestId&&this.removeVideo()},this.onPenStatusChange=a=>{a.penStatus==="on"?this.setTypingState(!0):this.setTypingState(!1)},this.onChatEnded=async a=>{var c,u;this.shouldUseAuth&&this.logoutUser(),this.setToastMessage(null),this.setTypingState(!1),this.videoConfirmDialogEntry&&this.videoConfirmDialogEntry.remove(),this.component.disableInput(),a.showForm&&this.showConversationEndedForm();const l=this.component.application.settings;(c=l==null?void 0:l.survey)!=null&&c.shouldUseSurvey&&((u=l==null?void 0:l.survey)!=null&&u.surveyBaseUrl)&&this.showSurvey(),this.isThirdPartyParticipant?this.removeHeaderOptions():this.setStartNewChatOption(),this.complete()},this.properties=t.properties,this.shouldUseAuth=(s=(i=this.component.application.settings)==null?void 0:i.auth)==null?void 0:s.shouldUseAuth,this.idHubEidType=(o=(r=this.component.application.settings)==null?void 0:r.auth)==null?void 0:o.idHubEidType.toLowerCase()}connect(e={}){super.connect(),this.setupAuthenticationListeners(),this._conversationOptions=e;const t={...this.properties.chat??{},...e},i=!!this.sessionId;if(!i){const r=Ji();this.setSessionId(r)}this.save({chatSessionId:this.sessionId}),this.engine=new Yd(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(z(this.disconnected$),W(zd)).subscribe(this.onQueueStatusReceived),this.engine.actions().pipe(z(this.disconnected$),W(Hd)).subscribe(this.onEstablished),this.engine.actions().pipe(z(this.disconnected$),W(Fd)).subscribe(this.onPrepareVideo),this.engine.actions().pipe(z(this.disconnected$),W(Bd)).subscribe(this.onVideoPrepared),this.engine.actions().pipe(z(this.disconnected$),W(qd)).subscribe(this.onChatButtonClicked),this.engine.actions().pipe(z(this.disconnected$),W(Vd)).subscribe(this.onEndVideoButtonClicked),this.engine.actions().pipe(z(this.disconnected$),W(jd)).subscribe(this.onPenStatusChange),this.engine.actions().pipe(z(this.disconnected$),W(Wd)).subscribe(this.onChatEnded),this.setHeaderOption();const s=this.component.application.trigger;s&&s.widgetActive$.pipe(z(s.componentIsDestroyed$)).subscribe(r=>{r&&(this.conversationOption=null,this.setHeaderOption())}),this.component.userTyping$.pipe(z(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(z(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)})}disconnected(){super.disconnected(),this.logoutTimer&&(clearTimeout(this.logoutTimer),this.logoutTimer=null),this.disconnected$.next()}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 Fn?t.setStatus("failed"):(t.setStatus("failed"),console.warn("Unhandled error:",s))}})()}save(e){this.component.stateMachine.session().pipe(Te(t=>(t==null?void 0:t.data$)||tt),fe(1)).subscribe(t=>{this.saveToCurrentSession$.next({...t,...e})})}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)}static getInstance(e,t){return t.providerInstance??(t.providerInstance=new Os(e,t)),t.providerInstance}async initializeChat(e){this.shouldUseAuth&&this.idHubEidType?(this.setupIDHubAuth(),this.idHubClient&&await this.startAuthenticationFlow()):this.handleWelcomeForm(e)}setupAuthenticationListeners(){var e;this.shouldUseAuth&&this.headerComponent&&this.headerComponent.actions$&&((e=this.headerComponent)==null||e.actions$.pipe(W(t=>t.key==="start-auth"||t.key==="logout-auth"),z(this.disconnected$)).subscribe(t=>{t.key==="start-auth"?this.handleAuthentication():t.key==="logout-auth"&&this.showLogoutConfirmDialog()}))}setupIDHubAuth(){var e;this.idHubClient=new Bt({...(e=this.component.application.settings)==null?void 0:e.auth,idHubUrl:this.idHubUrl})}async startAuthenticationFlow(){this.component.disableInput(),this.resetAuthState(Pe.NonAuthenticated);const e=await this.idHubClient.auth();if(e.status===H.Error){this.printSystem(this.texts.getOrFallback("auth.setup.error-message","An error occurred while setting up authentication.")),this.headerComponent.showAuthOptions=!1;return}switch(this.idHubEidType){case _e.Tunnistus:if(!e.tunnistusURL){this.printSystem(this.texts.getOrFallback("auth.setup.tunnistus.url-error-message","Unable to retrieve the Tunnistus authentication URL.")),this.headerComponent.showAuthOptions=!1;return}this.authURL=e.tunnistusURL,this.headerComponent.authUrl=e.tunnistusURL,this.headerComponent.authState=Pe.NonAuthenticated,this.authenticationCardEntry=this.showTunnistusAuthCard(Ze.Initial,e.tunnistusURL),this.authenticationCardEntry.actions$.pipe(W(t=>t.key==="start-auth"),fe(1)).subscribe(()=>{this.handleAuthentication()});break;case _e.BankId:break}}async handleWelcomeForm(e,t){let i=!0;e.webApiUrl&&(i=await this.isEntranceOpen(e.webApiUrl,e.entrance)),i?this.customerName?this.startChat({customerName:this.customerName,customData:{}},t):this.showWelcomeForm():this.showEntranceClosedDialog()}startChat(e,t){if(!this.engine)return;const i=e.customData.errand??this.engine.config.defaultErrand;if(!i)throw new Error("Errand is required but was not configured");this.isThirdPartyParticipant?(this.component.application.root.style.visibility="visible",this.engine.chatJoin({invitationUid:this.invitationUid,customerName:this.customerName??e.customerName}).pipe(z(this.disconnected$)).subscribe()):this.engine.chatRequest({customerName:e.customerName,customerEmailAddress:e.customerEmailAddress??"",visitorQuestion:e.visitorQuestion??"",customData:e.customData,errand:i,...t&&{idhubEIDToken:t}}).pipe(z(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))}setQueueStatus(e){this.setToastMessage(e)}async endConversation(){var e;this.shouldUseAuth&&this.resetAuthState(Pe.ChatEnded),await((e=this.engine)==null?void 0:e.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 Fn||console.warn("Unhandled error:",i)}}clearPendingMessages(){this.pendingMessages.forEach(e=>{e.remove()})}setSessionId(e){this.sessionId=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}resetAuthState(e){this.headerComponent.authState=e,this.headerComponent.userName="",this.headerComponent.authUrl="",this.authURL="",this.component.application.storage.removeItem("auth")}async handleAuthentication(){var t,i,s,r;this.headerComponent.userName=this.texts.getOrFallback("widget-header.authenticating","Authenticating..."),this.headerComponent.authState=Pe.Authenticating;const e=await this.idHubClient.collect();switch(this.authenticationCardEntry&&this.authenticationCardEntry.remove(),this.idHubEidType){case _e.Tunnistus:if(e.status===H.Error){this.headerComponent.userName=this.texts.getOrFallback("widget-header.not-authenticated","Not authenticated"),this.headerComponent.authState=Pe.NonAuthenticated,this.authenticationCardEntry=this.showTunnistusAuthCard(Ze.Error,this.authURL);return}else if(e.status===H.Authenticated){const o=Zd(((t=e==null?void 0:e.idhubEIDToken)==null?void 0:t.split(".")[1])??""),a=JSON.parse(o),l=((s=(i=a==null?void 0:a.completionData)==null?void 0:i.user)==null?void 0:s.name)??"",c=a==null?void 0:a.exp;if(typeof c=="number"&&c>0){const u=c*1e3-Date.now();u<=0?this.logoutUser():(this.logoutTimer&&clearTimeout(this.logoutTimer),this.logoutTimer=setTimeout(()=>{this.logoutUser()},u))}this.headerComponent.userName=l,this.headerComponent.authState=Pe.Authenticated,this.component.application.storage.set("auth",{name:l,authenticated:!0}),(r=this.authenticationCardEntry)==null||r.remove(),this.handleWelcomeForm(this.engine.config,e.idhubEIDToken)}break;case _e.BankId:break}}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=Ni(Rr(e));return this.user.print(t)}printSystem(e){const t=Ni(Rr(e));return this.system.print(t)}showSurvey(){const e=new ee(j.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)}showTunnistusAuthCard(e,t,i){const s=new ee(j.System,{name:""},[{items:[["ace-tunnistus-auth-card",{content:""},{state:e,tunnistusURL:t??"",errorMessage:i??""}]]}]);return this.printEntry(s),s}showWelcomeForm(){this.component.disableInput(),this.component.disableSkipToLatestMessage();let e;this.isThirdPartyParticipant?e=new ee(j.System,{name:""},[{items:[["ace-welcome-form-third-party",{content:""}]]}]):e=new ee(j.System,{name:""},[{items:[["ace-welcome-form",{content:""}]]}]),this.printEntry(e),e.actions$.pipe(W(t=>t.key==="submitted"),fe(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 ee(j.System,{name:""},[{items:[["ace-entrance-closed-dialog",{content:""}]]}]);this.printEntry(e)}showQuitConfirmDialog(){var e;(e=this.quitConfirmDialogEntry)==null||e.remove(),this.quitConfirmDialogEntry=new ee(j.System,{name:""},[{items:[["ace-quit-confirm-dialog",{content:""}]]}]),this.printEntry(this.quitConfirmDialogEntry),this.quitConfirmDialogEntry.actions$.pipe(W(t=>t.key==="quit-chat"),fe(1)).subscribe(t=>{var i,s,r,o;((i=t.data)==null?void 0:i.result)==="quit"?(this.endConversation(),(s=this.quitConfirmDialogEntry)==null||s.remove()):((r=t.data)==null?void 0:r.result)==="cancel"&&((o=this.quitConfirmDialogEntry)==null||o.remove())})}showConversationEndedForm(){const e=new ee(j.System,{name:""},[{items:[["ace-conversation-ended-form",{content:""}]]}]);this.printEntry(e),e.actions$.pipe(W(t=>t.key==="submitted"),fe(1)).subscribe(t=>{e.remove(),t.data.email&&this.sendConversationEmail(t.data.email)})}showVideoConfirmDialog(){this.videoConfirmDialogEntry=new ee(j.System,{name:""},[{items:[["ace-video-confirm-dialog",{content:""}]]}]),this.printEntry(this.videoConfirmDialogEntry),this.videoConfirmDialogEntry.actions$.pipe(W(e=>e.key==="video-confirm"),fe(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)})}showVideoIFrame(e){var i;this.guestId=Ji(),this.videoIFrameElement=new Jt(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))}async logoutUser(){this.logoutConfirmDialogEntry&&this.logoutConfirmDialogEntry.remove(),await this.engine.getChatStatus()==="noSession"?(this.resetAuthState(Pe.NonAuthenticated),this.setSessionId(null),this.component.clearMessages(),this.shouldUseAuth&&this.startAuthenticationFlow()):this.endConversation()}showLogoutConfirmDialog(){var e;(e=this.logoutConfirmDialogEntry)==null||e.remove(),this.logoutConfirmDialogEntry=new ee(j.System,{name:""},[{items:[["ace-logout-confirm-dialog",{content:""}]]}]),this.printEntry(this.logoutConfirmDialogEntry),this.logoutConfirmDialogEntry.actions$.pipe(W(t=>t.key==="logout-chat"),fe(1)).subscribe(async t=>{var i,s,r,o;((i=t.data)==null?void 0:i.result)==="logout"?(this.logoutUser(),(s=this.logoutConfirmDialogEntry)==null||s.remove()):((r=t.data)==null?void 0:r.result)==="cancel"&&((o=this.logoutConfirmDialogEntry)==null||o.remove())})}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()}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})}removeHeaderOptions(){const e=this.component.application.getComponent("widget-header");e&&e.removeOption(this.conversationOption)}setStartNewChatOption(){this.conversationOption=this.addHeaderOptions(this.texts.getOrFallback("widget-header.start-new-chat","Start new chat"),"start-new-chat-button",ra.svg,()=>{this.restartNewChat()})}setEndConversationOption(){this.conversationOption=this.addHeaderOptions(this.texts.getOrFallback("widget-header.end-conversation","End conversation"),"end-conversation-button",hs.svg,()=>{this.showQuitConfirmDialog()},!this.inVideoCall)}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}}}const mp=async n=>{(await os.getInstance(n.container)).registerProvider("ace-chat",t=>Os.getInstance("ace-chat",t))};exports.ChatProviderPlugin=mp;
|
package/index.mjs
CHANGED
|
@@ -7311,6 +7311,8 @@ const To = Ea(_), Bs = class Bs extends To {
|
|
|
7311
7311
|
class="conversation-bottom"
|
|
7312
7312
|
@submit=${this._onSendMessage}
|
|
7313
7313
|
${me(this.formRef)}
|
|
7314
|
+
?inert=${this.disabledInput}
|
|
7315
|
+
data-testid="conversation-bottom"
|
|
7314
7316
|
>
|
|
7315
7317
|
<label for="chat-message-input" class="visually-hidden">
|
|
7316
7318
|
Chat message
|
|
@@ -7324,7 +7326,6 @@ const To = Ea(_), Bs = class Bs extends To {
|
|
|
7324
7326
|
)}
|
|
7325
7327
|
data-testid="message-input"
|
|
7326
7328
|
.value=${this.message}
|
|
7327
|
-
?disabled=${this.disabledInput}
|
|
7328
7329
|
@input=${this._inputHandler}
|
|
7329
7330
|
@keydown=${this._keyDownHandler}
|
|
7330
7331
|
${me(this.inputRef)}
|
|
@@ -7340,7 +7341,6 @@ const To = Ea(_), Bs = class Bs extends To {
|
|
|
7340
7341
|
type="submit"
|
|
7341
7342
|
data-testid="send-message-button"
|
|
7342
7343
|
title=${e.getOrFallback("conversation.send-alt", "Send")}
|
|
7343
|
-
?disabled=${this.disabledSubmit}
|
|
7344
7344
|
>
|
|
7345
7345
|
<telia-icon svg=${ra.svg}></telia-icon>
|
|
7346
7346
|
</button>
|
|
@@ -9288,10 +9288,15 @@ var op = Object.defineProperty, ap = (n, e, t, i) => {
|
|
|
9288
9288
|
return s && op(e, t, s), s;
|
|
9289
9289
|
};
|
|
9290
9290
|
const Qs = class Qs extends _ {
|
|
9291
|
-
|
|
9291
|
+
firstUpdated() {
|
|
9292
|
+
var t;
|
|
9293
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".container");
|
|
9294
|
+
e && e.focus();
|
|
9295
|
+
}
|
|
9296
|
+
onQuit() {
|
|
9292
9297
|
this.dispatchResult("quit");
|
|
9293
9298
|
}
|
|
9294
|
-
|
|
9299
|
+
onCancel() {
|
|
9295
9300
|
this.dispatchResult("cancel");
|
|
9296
9301
|
}
|
|
9297
9302
|
dispatchResult(e) {
|
|
@@ -9308,7 +9313,12 @@ const Qs = class Qs extends _ {
|
|
|
9308
9313
|
}
|
|
9309
9314
|
render() {
|
|
9310
9315
|
const e = this.application.texts;
|
|
9311
|
-
return y`<div
|
|
9316
|
+
return y`<div
|
|
9317
|
+
class="container"
|
|
9318
|
+
role="dialog"
|
|
9319
|
+
aria-modal="true"
|
|
9320
|
+
tabindex="-1"
|
|
9321
|
+
>
|
|
9312
9322
|
<h3>
|
|
9313
9323
|
${e.getOrFallback(
|
|
9314
9324
|
"quit-confirm.title",
|
|
@@ -9322,10 +9332,10 @@ const Qs = class Qs extends _ {
|
|
|
9322
9332
|
)}
|
|
9323
9333
|
</p>
|
|
9324
9334
|
<div class="button-container">
|
|
9325
|
-
<button class="cancel" @click=${this.
|
|
9335
|
+
<button class="cancel" @click=${this.onCancel}>
|
|
9326
9336
|
${e.getOrFallback("quit-confirm.cancel-button", "Cancel")}
|
|
9327
9337
|
</button>
|
|
9328
|
-
<button class="quit" @click=${this.
|
|
9338
|
+
<button class="quit" @click=${this.onQuit}>
|
|
9329
9339
|
${e.getOrFallback("quit-confirm.end-chat-button", "End chat")}
|
|
9330
9340
|
</button>
|
|
9331
9341
|
</div>
|
|
@@ -9409,10 +9419,15 @@ var lp = Object.defineProperty, cp = (n, e, t, i) => {
|
|
|
9409
9419
|
return s && lp(e, t, s), s;
|
|
9410
9420
|
};
|
|
9411
9421
|
const Xs = class Xs extends _ {
|
|
9412
|
-
|
|
9422
|
+
firstUpdated() {
|
|
9423
|
+
var t;
|
|
9424
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".container");
|
|
9425
|
+
e && e.focus();
|
|
9426
|
+
}
|
|
9427
|
+
onQuit() {
|
|
9413
9428
|
this.dispatchResult("logout");
|
|
9414
9429
|
}
|
|
9415
|
-
|
|
9430
|
+
onCancel() {
|
|
9416
9431
|
this.dispatchResult("cancel");
|
|
9417
9432
|
}
|
|
9418
9433
|
dispatchResult(e) {
|
|
@@ -9429,7 +9444,12 @@ const Xs = class Xs extends _ {
|
|
|
9429
9444
|
}
|
|
9430
9445
|
render() {
|
|
9431
9446
|
const e = this.application.texts;
|
|
9432
|
-
return y`<div
|
|
9447
|
+
return y`<div
|
|
9448
|
+
class="container"
|
|
9449
|
+
role="dialog"
|
|
9450
|
+
aria-modal="true"
|
|
9451
|
+
tabindex="-1"
|
|
9452
|
+
>
|
|
9433
9453
|
<h3>
|
|
9434
9454
|
${e.getOrFallback(
|
|
9435
9455
|
"logout-confirm.title",
|
|
@@ -9443,10 +9463,10 @@ const Xs = class Xs extends _ {
|
|
|
9443
9463
|
)}
|
|
9444
9464
|
</p>
|
|
9445
9465
|
<div class="button-container">
|
|
9446
|
-
<button class="cancel" @click=${this.
|
|
9466
|
+
<button class="cancel" @click=${this.onCancel}>
|
|
9447
9467
|
${e.getOrFallback("logout-confirm.cancel-button", "Cancel")}
|
|
9448
9468
|
</button>
|
|
9449
|
-
<button class="quit" @click=${this.
|
|
9469
|
+
<button class="quit" @click=${this.onQuit}>
|
|
9450
9470
|
${e.getOrFallback("logout-confirm.end-chat-button", "Log out")}
|
|
9451
9471
|
</button>
|
|
9452
9472
|
</div>
|
|
@@ -9947,7 +9967,7 @@ class Os extends wc {
|
|
|
9947
9967
|
});
|
|
9948
9968
|
}
|
|
9949
9969
|
async startAuthenticationFlow() {
|
|
9950
|
-
this.resetAuthState(Pe.NonAuthenticated);
|
|
9970
|
+
this.component.disableInput(), this.resetAuthState(Pe.NonAuthenticated);
|
|
9951
9971
|
const e = await this.idHubClient.auth();
|
|
9952
9972
|
if (e.status === H.Error) {
|
|
9953
9973
|
this.printSystem(
|
|
@@ -10249,8 +10269,8 @@ class Os extends wc {
|
|
|
10249
10269
|
W((t) => t.key === "quit-chat"),
|
|
10250
10270
|
fe(1)
|
|
10251
10271
|
).subscribe((t) => {
|
|
10252
|
-
var i;
|
|
10253
|
-
this.
|
|
10272
|
+
var i, s, r, o;
|
|
10273
|
+
((i = t.data) == null ? void 0 : i.result) === "quit" ? (this.endConversation(), (s = this.quitConfirmDialogEntry) == null || s.remove()) : ((r = t.data) == null ? void 0 : r.result) === "cancel" && ((o = this.quitConfirmDialogEntry) == null || o.remove());
|
|
10254
10274
|
});
|
|
10255
10275
|
}
|
|
10256
10276
|
showConversationEndedForm() {
|
|
@@ -10320,8 +10340,8 @@ class Os extends wc {
|
|
|
10320
10340
|
W((t) => t.key === "logout-chat"),
|
|
10321
10341
|
fe(1)
|
|
10322
10342
|
).subscribe(async (t) => {
|
|
10323
|
-
var i;
|
|
10324
|
-
((i = t.data) == null ? void 0 : i.result) === "logout"
|
|
10343
|
+
var i, s, r, o;
|
|
10344
|
+
((i = t.data) == null ? void 0 : i.result) === "logout" ? (this.logoutUser(), (s = this.logoutConfirmDialogEntry) == null || s.remove()) : ((r = t.data) == null ? void 0 : r.result) === "cancel" && ((o = this.logoutConfirmDialogEntry) == null || o.remove());
|
|
10325
10345
|
});
|
|
10326
10346
|
}
|
|
10327
10347
|
// ===========
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/ace-chat-flamingo",
|
|
3
|
-
"version": "1.1.122-rc.
|
|
3
|
+
"version": "1.1.122-rc.4",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@telia-ace/widget-core-flamingo": "1.1.122-rc.
|
|
6
|
-
"@telia-ace/widget-conversation-flamingo": "1.1.122-rc.
|
|
5
|
+
"@telia-ace/widget-core-flamingo": "1.1.122-rc.4",
|
|
6
|
+
"@telia-ace/widget-conversation-flamingo": "1.1.122-rc.4",
|
|
7
7
|
"rxjs": "^7.8.2",
|
|
8
8
|
"lit": "^3.0.2",
|
|
9
9
|
"@teliads/icons": "^8.4.0",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
export declare class LogoutConfirmDialog extends LitElement {
|
|
3
3
|
static styles: import('lit').CSSResult[];
|
|
4
|
-
_onQuit(): void;
|
|
5
|
-
_onCancel(): void;
|
|
6
|
-
dispatchResult(result?: string): void;
|
|
7
4
|
private application;
|
|
5
|
+
firstUpdated(): void;
|
|
6
|
+
private onQuit;
|
|
7
|
+
private onCancel;
|
|
8
|
+
private dispatchResult;
|
|
8
9
|
render(): import('lit-html').TemplateResult<1>;
|
|
9
10
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
export declare class QuitConfirmDialog extends LitElement {
|
|
3
3
|
static readonly styles: import('lit').CSSResult[];
|
|
4
|
-
_onQuit(): void;
|
|
5
|
-
_onCancel(): void;
|
|
6
|
-
dispatchResult(result?: string): void;
|
|
7
4
|
private readonly application;
|
|
5
|
+
firstUpdated(): void;
|
|
6
|
+
private onQuit;
|
|
7
|
+
private onCancel;
|
|
8
|
+
private dispatchResult;
|
|
8
9
|
render(): import('lit-html').TemplateResult<1>;
|
|
9
10
|
}
|