@sendbird/ai-agent-messenger-react 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/81mv3yQ8.cjs +1 -0
- package/dist/cjs/B7oY12Rz.cjs +1 -0
- package/dist/cjs/{BPd5Xgh2.cjs → BOQuxK8W.cjs} +1 -1
- package/dist/cjs/Bi8XVGE0.cjs +305 -0
- package/dist/cjs/CZsIrgdx.cjs +1 -0
- package/dist/cjs/Cvx76YWg.cjs +1 -0
- package/dist/cjs/CxmJLyVQ.cjs +1 -0
- package/dist/cjs/DUZCYMwi.cjs +1 -0
- package/dist/cjs/GyKP4khq.cjs +1 -0
- package/dist/cjs/UnL5ebrx.cjs +1 -0
- package/dist/cjs/Vc_kaVVy.cjs +1 -0
- package/dist/es/{B2BLVBOu.js → BDRrsdhG.js} +10 -8
- package/dist/es/{B4IxuaeZ.js → BRbygcMm.js} +2112 -1984
- package/dist/es/{DYA2aRBL.js → BoikxJUJ.js} +4 -2
- package/dist/es/{Di0vLDuX.js → By_mXjKX.js} +10 -8
- package/dist/es/{CDxVc2wB.js → CjiYaXB3.js} +10 -8
- package/dist/es/{DXo_Wt73.js → CwLgdNGh.js} +6 -4
- package/dist/es/{ClScP-VE.js → D4G3q1WL.js} +4 -2
- package/dist/es/{Cp212yQF.js → D9rtgPyE.js} +4 -2
- package/dist/es/{DaCxkQ65.js → DSLWWi3o.js} +1 -1
- package/dist/es/{BCpSbr_e.js → DbEkY11E.js} +8 -6
- package/dist/es/{rSoYm2MO.js → DlPxWJIs.js} +7 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +49 -6
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/B1gSGciq.cjs +0 -1
- package/dist/cjs/BDH-LU3h.cjs +0 -1
- package/dist/cjs/C3AB5XZJ.cjs +0 -1
- package/dist/cjs/D0f7_4hh.cjs +0 -1
- package/dist/cjs/DcYDdCqg.cjs +0 -1
- package/dist/cjs/Dkqya79F.cjs +0 -1
- package/dist/cjs/Dlu2l-v0.cjs +0 -1
- package/dist/cjs/T-Efq4pf.cjs +0 -1
- package/dist/cjs/cNF0qswg.cjs +0 -305
- package/dist/cjs/dhwTCJfW.cjs +0 -1
package/dist/cjs/cNF0qswg.cjs
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
"use strict";var eo=Object.defineProperty;var to=(e,t,n)=>t in e?eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>to(e,typeof t!="symbol"?t+"":t,n);const d=require("react"),X=require("@sendbird/chat"),T=require("styled-components"),he=require("date-fns"),no=require("date-fns/locale/en-US"),G=require("@sendbird/chat/aiAgent"),Me=require("@sendbird/uikit-tools"),ve=require("@sendbird/chat/message"),Ze=require("@sendbird/chat/groupChannel"),ro=require("react-dom"),yt=require("@sendbird/react-uikit-message-template-view"),oo=require("@sendbird/uikit-message-template"),so=require("dompurify"),ao=require("date-fns/isSameDay"),io=require("@emotion/is-prop-valid"),tt=e=>e&&e.__esModule?e:{default:e};function lo(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=lo(d),co=tt(X),g=tt(T),Bn=tt(so),uo=tt(io),Q=(e,t)=>{const n=d.createContext(null),o=({children:i,value:l})=>r.createElement(n.Provider,{value:l},typeof i=="function"?i(l):i),s=({children:i})=>r.createElement(n.Consumer,null,l=>l?typeof i=="function"?i(l):i:null),a=()=>{const i=d.useContext(n);if(!i)throw new Error(`use${e}Context must be used within a ${e}Provider`);return i};return n.displayName=`${e}Context`,o.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,a.displayName=`use${e}Context`,{Context:n,Provider:o,Consumer:s,useContext:a}};function _e(e){const t=d.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=d.useState(()=>e.template),[c,m]=d.useState(e.components),f={Template:i,updateTemplate:p=>l(()=>p),components:c,updateComponent:(p,x)=>m(y=>({...y,[p]:x}))};return r.createElement(t.Provider,{value:f},a)}function o({template:a,children:i}){const{updateTemplate:l}=d.useContext(t);return d.useLayoutEffect(()=>{a&&l(a)},[a]),r.createElement(r.Fragment,null,i)}function s({children:a}){return r.createElement(n,null,a)}return s.defaults=e,s.useContext=()=>d.useContext(t),s.Context=t,s.Template=o,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:c}=d.useContext(t);return d.useLayoutEffect(()=>{l&&c(a,l)},[l]),null}}),s}function mo(...e){return function({children:n}){return e.reduce((o,s)=>r.createElement(s,null,o),n)}}const fe=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===G.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},Ct=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===G.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function De(e){var n,o,s;return typeof(((n=e==null?void 0:e.conversation)==null?void 0:n.handedOverAt)??((s=(o=e==null?void 0:e.conversation)==null?void 0:o.handoff)==null?void 0:s.timestamp))=="number"}function go(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}function on(e){return!!e&&e<Date.now()}function ho(e){return!e.title}function fo(e,t){if(e)return ho(e)?{...e,title:t.title,csat_question:t.question,csat_scores:[{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/angry-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/suspicious-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/neutral-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/smile-active.png"},{label:"",image_url:"https://static.dashboard.sendbird.com/assets/ai-agent/happy-active.png"}],cre:{question:t.cre.question,positive_label:t.cre.positive_label,negative_label:t.cre.negative_label},follow_up:[{response_type:"free_text",scores:[1,2,3,4,5],question:t.followUp.question}],csat_submit_label:t.submit_label,csat_submitted_label:t.submitted_label}:e}function po(e){const t=e.lastMessage;return t!=null&&t.isUserMessage()||t!=null&&t.isAdminMessage()?t.message||"":t!=null&&t.isFileMessage()?t.message||t.name||"FILE":e.name}function bo(e,t,n){var i;const o=new Date,s=new Date(((i=e.lastMessage)==null?void 0:i.createdAt)||e.createdAt),a=he.differenceInMinutes(o,s);return a<1?n.justNow:a<60?n.minutesAgo(a):he.isToday(s)?n.hoursAgo(he.differenceInHours(o,s)):t(s,n.dateShortFormat)}const Eo="1.8.0",Ae="sb-agent",xo=Eo,Fn="KEY_IMG_ASPECT_RATIO",R={BODY_MAX_WIDTH:244,WIDE_BODY_MAX_WIDTH:640,AVATAR_SIZE:26,BODY_TIME_GAP:4,HORIZONTAL_PADDING:12,GAP_GROUPED:2,GAP_UNGROUPED:16},ue=e=>!!e&&"sender"in e,vo=e=>ue(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),yo=(e,t,n,o=!0)=>{if(!o||!ue(e))return"single";const s=()=>{if(!t||!ue(t))return!1;const c=t.sender.userId===e.sender.userId,m=he.isSameMinute(t.createdAt,e.createdAt);return c&&m},a=()=>{if(!n||!ue(n))return!1;const c=n.sender.userId===e.sender.userId,m=he.isSameMinute(n.createdAt,e.createdAt);return c&&m},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},Ie=(e,t)=>(()=>{var o;return ue(e)?e.sender.userId:((o=e==null?void 0:e.sender)==null?void 0:o.userId)??void 0})()===t,we={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>ue(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>ue(e)&&(e.sender.userId===t||e.sendingStatus===ve.SendingStatus.PENDING)},Hn=e=>e.startsWith("image/"),Un=e=>e.startsWith("video/"),Pt=(e,t)=>{if(e&&!e.startsWith(".")){const n=e.split(".").pop();if(n&&n!==e)return n.toUpperCase()}if(t){const[,n]=t.split("/");if(n)return n.toUpperCase()}return"FILE"},Vn=e=>e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0,Bt=e=>{switch(e){case"top":case"middle":return R.GAP_GROUPED;default:return R.GAP_UNGROUPED}},Co=(e,t)=>{const n=/```(\w+)?\n([\s\S]*?)```/g,o=[];let s=0;return e.replace(n,(a,...i)=>{const[l,c,m]=i;return s<m&&o.push({type:"text",value:e.slice(s,m).trim()}),o.push({type:"code",value:c.trim(),language:l?l.trim():"plaintext"}),s=m+a.length,a}),s<e.length&&o.push({type:"text",value:e.slice(s).trim()}),t?o.map(a=>a.type!=="text"?a:{...a,value:t(a.value)}):o},_o=e=>e.replace(/\[([^\]]+)\](?!\()/g,"\\[$1\\]"),So=e=>{const t=/\b[A-Za-z0-9._+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;return e.replace(t,n=>n.replace(/_/g,"\\_"))},To=e=>e.replace(/~~/g,"\\~\\~"),wo=e=>{let t=e;return t=_o(t),t=So(t),t=To(t),t},Ao=typeof navigator<"u"&&navigator.product==="ReactNative",sn=(e,t)=>{const n=o=>!t||t.length===0?!0:ue(o)&&t.includes(o.sendingStatus);return Ao?e.find(n):e.findLast(n)};function pe(){}function ko(){const e=typeof navigator<"u"?navigator.userAgent:"",t=/iPad|iPhone|iPod/.test(e),n=/Android/.test(e);return t||n}function Io(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t.toString(16)}const _t=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},be={isStreaming(e){const t=_t(e.data);return typeof t=="object"&&!!t.stream},isWelcomeMessage(e,t){var n;if(((n=e.extendedMessagePayload)==null?void 0:n.bot_message_type)==="welcome")return!0;if(Ie(e,t)){const o=_t(e.data);return!(o!=null&&o.respond_mesg_id)&&!(o!=null&&o.stream)}return!1},isGeneratedMessage(e){var t;return((t=e.extendedMessagePayload)==null?void 0:t.bot_message_type)==="generated"},hasFeedback(e){var t;return!!((t=e.extendedMessagePayload)!=null&&t.feedback)},checkExtendedFieldPresence(e){const t=e.extendedMessagePayload||{},n=i=>i.some(l=>typeof t[l]<"u"),o=n(ht.ui),s=n(ht.trail),a=n(ht.marking);return{ui:o,trail:s,marking:a}},shouldScrollToBottom(e,t,n=!1){if(Ie(e,t)){if(this.isGeneratedMessage(e)&&this.isStreaming(e))return!0;const{ui:o,trail:s,marking:a}=this.checkExtendedFieldPresence(e);return o?!(!n&&a):!!(n&&(s||a))}return!0}},ht={ui:["suggested_replies","cta_button","message_template","csat"],trail:["groundedness","manual","function_calls"],marking:["is_hallucination","is_moderated","flagged_types"]},ft=`@${Ae}`,an=({appId:e,aiAgentId:t,storage:n})=>{const o={templateBase:`${ft}-template`,template:s=>`${o.templateBase}/templates/${s}`,templateToken:()=>`${o.templateBase}-template/message-template/tokens`,messengerSession:s=>{const a=Io(`${e}/${t}/${s}`);return`${ft}-udata/${a}`},anonUserSession:()=>`${ft}-session/${e}/${t}`};return{template:{set:(s,a)=>n.set(o.template(s),a),get:s=>n.get(o.template(s)),setCachedToken:s=>n.set(o.templateToken(),s),getCachedToken:()=>n.get(o.templateToken()),clear:()=>{n.getKeys(o.templateBase).forEach(n.delete)}},messenger:{getSettings:s=>{try{const a=n.get(o.messengerSession(s));return a?JSON.parse(a):null}catch{return null}},setSettings:(s,a)=>{try{delete a.auto_created_user;const i=JSON.stringify(a);n.set(o.messengerSession(s),i)}catch{return}},getAnonUser:()=>{try{const s=n.get(o.anonUserSession());return s?JSON.parse(s):null}catch{return null}},setAnonUser:s=>{try{const a=JSON.stringify(s);n.set(o.anonUserSession(),a)}catch{return}},clear:s=>{try{s&&n.delete(o.messengerSession(s)),n.delete(o.anonUserSession())}catch{return}}}}};class zn{constructor(t){B(this,"subscribers",{});this.logger=t}async send(t){const n=$o(),o=this.subscribers[t.type];if(o){this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`,t.payload);const s=o.map(a=>a(t.payload));await Promise.all(s).catch(a=>{this.logger.error(`messenger.dispatcher: error in callback for command: ${t.type}`,a)})}return n.resolve(),n.promise}subscribe(t,n){this.subscribers[t]||(this.subscribers[t]=[]),this.subscribers[t].push(n)}unsubscribe(t,n){this.subscribers[t]&&(this.subscribers[t]=this.subscribers[t].filter(o=>o!==n))}}const $o=()=>{let e=pe,t=pe;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}};var Ft=(e=>(e[e.VERBOSE=0]="VERBOSE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(Ft||{});class Gn{constructor(t){B(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${Ae}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${Ae}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${Ae}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${Ae}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${Ae}/error]`,...t)}}function ln(e,t,n){const o=co.default.init({appId:e,modules:[new Ze.GroupChannelModule,new G.AIAgentModule],localCacheEnabled:!0,options:new X.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...n});return o.addSendbirdExtensions([{version:xo,product:X.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),o}function Mo(e){const t=n=>{throw new Error(`Please initialize chat sdk with ${n}`)};typeof e.groupChannel!="object"&&t("GroupChannelModule"),typeof e.aiAgent!="object"&&t("AIAgentModule")}const pt={conversation:{isTalkToAgentViewEnabled:!0}},cn=e=>e?{...pt,...e,conversation:{...pt.conversation,...e==null?void 0:e.conversation}}:pt,{Provider:Oo,useContext:q}=Q("AIAgent");function Lo({appId:e,aiAgentId:t,keyValueStorage:n,language:o,countryCode:s,context:a,queryParams:i,config:l,chatSDK:c,chatParams:m,children:f,logger:p,dispatcher:x,extensions:y={platform:X.SendbirdPlatform.JS,deviceOSPlatform:ko()?X.DeviceOsPlatform.MOBILE_WEB:X.DeviceOsPlatform.WEB}}){const[v,E]=d.useState(()=>{const b=p??new Gn(Ft.WARN),h=x??new zn(b);return{appId:e,aiAgentId:t,language:o,countryCode:s,context:a,queryParams:i,config:cn(l),keyValueStorage:n,logger:b,dispatcher:h,chatSDK:c??ln(e,y,m),cache:an({appId:e,aiAgentId:t,storage:n})}});return d.useEffect(()=>{E(b=>{let h=b.logger,C=b.dispatcher,S=b.chatSDK;return p&&p!==b.logger&&(h=p),x&&x!==b.dispatcher&&(C=x),c&&c!==b.chatSDK?S=c:!c&&b.chatSDK.appId!==e&&(S=ln(e,y,{newInstance:!0,...m})),{...b,appId:e,aiAgentId:t,keyValueStorage:n,language:o,countryCode:s,context:a,queryParams:i,config:cn(l),logger:h,dispatcher:C,chatSDK:S,cache:an({appId:e,aiAgentId:t,storage:n})}})},[e,t,o,s,a,l,p,x,c]),d.useEffect(()=>()=>{v.chatSDK.disconnectWebSocket()},[v.chatSDK]),Mo(v.chatSDK),r.createElement(Oo,{value:v},f)}const Do=(e,t,n)=>Me.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var St=(e=>(e.ConversationClose="conv.close",e))(St||{});class Ro{constructor(t={}){B(this,"payload");this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}const Wn={CloseConversation:e=>new No(e)};class No extends Ro{constructor(){super(...arguments);B(this,"type","conv.close")}}const Tt={DEFAULT_BOT_MSG_BG:"#eeeeee",WHITE:"#ffffff",BLACK:"#000000"};function qn(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function Po(e){const t=qn(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Bo(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function Fo(e,t,n){e/=255,t/=255,n/=255;const o=Math.max(e,t,n),s=Math.min(e,t,n),a=o-s;let i=0,l=0;const c=(o+s)/2;return o!==s&&(l=c>.5?a/(2-o-s):a/(o+s)),o===e?i=(t-n)/a+(t<n?6:0):o===t?i=(n-e)/a+2:o===n&&(i=(e-t)/a+4),i/=6,[i,l,c]}function Ho(e,t,n){let o,s,a;if(t===0)o=s=a=n;else{const i=function(f,p,x){return x<0&&(x+=1),x>1&&(x-=1),x<.16666666666666666?f+(p-f)*6*x:x<.5?p:x<.6666666666666666?f+(p-f)*(.6666666666666666-x)*6:f},l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;o=i(c,l,e+1/3),s=i(c,l,e),a=i(c,l,e-1/3)}return[Math.round(o*255),Math.round(s*255),Math.round(a*255)]}function He(e,t,n){const[o,s,a]=Po(e),[i,l,c]=Fo(o,s,a),m=Math.max(0,Math.min(1,c*t)),f=Math.max(0,Math.min(1,l*n)),[p,x,y]=Ho(i,f,m);return Bo([Math.round(p),Math.round(x),Math.round(y)])}function Uo(e,t="light"){return{extraDark:He(e,.6,1.2),dark:He(e,.85,1.1),main:e,light:He(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:He(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function wt(e){const t=qn(e),n=149,o=+`0x${t[1]}${t[2]}`,s=+`0x${t[3]}${t[4]}`,a=+`0x${t[5]}${t[6]}`;return o*.299+s*.587+a*.114>n?Tt.BLACK:Tt.WHITE}function Vo(e,t,n,o,s){return{base:{primary:t,primaryContrastContent:n,background:e.background50,headerBackground:e.background50,modalContentBackground:e.background50},metadata:{errorContent:e.ondark.textHighEmphasis},messageInput:{text:e.onlight.textHighEmphasis,placeholderText:e.onlight.textLowEmphasis,background:e.background100},messageIncoming:{text:s,background:o},messageOutgoing:{text:n,background:t},csat:{background:e.background100}}}const zo=(e,t,n,o,s)=>({base:{primary:t,primaryContrastContent:n,background:e.background600,headerBackground:e.background500,modalContentBackground:e.background500},metadata:{errorContent:e.ondark.textHighEmphasis},messageInput:{text:e.ondark.textHighEmphasis,placeholderText:e.ondark.textLowEmphasis,background:e.background400},messageIncoming:{text:s,background:o},messageOutgoing:{text:n,background:t},csat:{background:e.background400}}),Ue={primary:{extraDark:"#491389",dark:"#6211c8",main:"#742ddd",light:"#c2a9fa",extraLight:"#dbd1ff"},secondary:{extraDark:"#066858",dark:"#027d69",main:"#259c72",light:"#69c085",extraLight:"#a8e2ab"},error:{extraDark:"#9d091e",dark:"#bf0711",main:"#de360b",light:"#f66161",extraLight:"#fdaaaa"},information:{extraDark:"#241389",dark:"#362ca9",main:"#4a48cd",light:"#a9bbfa",extraLight:"#d1dbff"},background700:"#000000",background600:"#161616",background500:"#2c2c2c",background400:"#393939",background300:"#bdbdbd",background200:"#e0e0e0",background100:"#eeeeee",background50:"#ffffff",onlight:{textHighEmphasis:"rgba(0, 0, 0, 0.88)",textMidEmphasis:"rgba(0, 0, 0, 0.5)",textLowEmphasis:"rgba(0, 0, 0, 0.38)",textDisabled:"rgba(0, 0, 0, 0.12)"},ondark:{textHighEmphasis:"rgba(255, 255, 255, 0.88)",textMidEmphasis:"rgba(255, 255, 255, 0.5)",textLowEmphasis:"rgba(255, 255, 255, 0.38)",textDisabled:"rgba(255, 255, 255, 0.12)"},overlay:{dark:"rgba(0, 0, 0, 0.55)",light:"rgba(22, 22, 22, 0.32)"}},bt={h1:{fontSize:18,fontWeight:700},h2:{fontSize:16,fontWeight:700},subtitle1:{fontSize:16,fontWeight:500},subtitle2:{fontSize:16,fontWeight:400},body1:{fontSize:16,fontWeight:400},body2:{fontSize:14,fontWeight:500},body3:{fontSize:14,fontWeight:400},button:{fontSize:14,fontWeight:700},caption1:{fontSize:12,fontWeight:700},caption2:{fontSize:12,fontWeight:400},caption3:{fontSize:11,fontWeight:700},caption4:{fontSize:11,fontWeight:400}};function dn(e){const t=Go(e),{colors:n,aiAgentColorVariables:o}=Wo(e,t),s=jo(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:o,typography:s}}function Go({selectedTheme:e,palette:t,primary:n}){const o=t!=null&&t.primary?t.primary:n?n===Ue.primary.main?Ue.primary:Uo(n,e):Ue.primary;return{...Ue,primary:o,...t}}function Wo({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:o},s){const a=s.primary.main,i=t??wt(a),l=n??Tt.DEFAULT_BOT_MSG_BG,c=o??wt(l);return{colors:(e==="light"?Vo:zo)(s,a,i,l,c),aiAgentColorVariables:{primary_color:a,bot_message_bg_color:l,primary_contrast_color:i,bot_message_bg_contrast_color:c}}}function qo(e,t,n){const o={...e};return n.forEach(s=>{const a=t[s];a!=null&&(o[s]=a)}),o}function jo({typography:e}){if(!e)return bt;const t={...bt};return Object.keys(e).forEach(n=>{const o=e[n];if(o&&typeof o=="object"){const s=bt[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=qo(s,o,a)}}),t}const{Provider:Ko,useContext:Ht}=Q("AIAgentTheme");function Yo({logger:e,palette:t,typography:n,appearance:o,children:s}){const a=d.useRef(null),[i,l]=d.useState(()=>dn({selectedTheme:(o==null?void 0:o.theme)??"light",palette:t,typography:n,primary:o==null?void 0:o.primaryColor,botMessageBackground:o==null?void 0:o.botMessageBackgroundColor})),c=d.useCallback((m,f)=>{f&&(a.current=f);const p=(o==null?void 0:o.theme)??m,x=a.current?a.current.themes[p]:null,y={primary:o==null?void 0:o.primaryColor,primaryContrast:void 0,botMessageBackground:o==null?void 0:o.botMessageBackgroundColor,botMessageBackgroundContrast:void 0};!y.primary&&(x!=null&&x.primary_color)&&(y.primary=x.primary_color,y.primaryContrast=x.primary_contrast_color),!y.botMessageBackground&&(x!=null&&x.bot_message_bg_color)&&(y.botMessageBackground=x.bot_message_bg_color,y.botMessageBackgroundContrast=x.bot_message_bg_contrast_color);const v=dn({selectedTheme:p,palette:t,typography:n,...y});l(v),e==null||e.info("theme.update:",p)},[o==null?void 0:o.theme,o==null?void 0:o.primaryColor,o==null?void 0:o.botMessageBackgroundColor,t,n,e]);return d.useEffect(()=>{(o!=null&&o.theme||o!=null&&o.primaryColor||o!=null&&o.botMessageBackgroundColor)&&c(i.selectedTheme)},[o==null?void 0:o.theme,o==null?void 0:o.primaryColor,o==null?void 0:o.botMessageBackgroundColor]),r.createElement(Ko,{value:{theme:i,updateTheme:c}},s)}function jn(){const{chatSDK:e,logger:t}=q();return d.useCallback(async n=>{if(n.userId===""){const o=new Error("userId cannot be empty string for messenger settings request");throw t.error("requestMessengerSettings: invalid userId",o),o}return await e.aiAgent.requestMessengerSettings(n)},[e,t])}function Zo(){const{chatSDK:e,logger:t}=q(),n=d.useCallback(async(s,a,i)=>{if(t.debug("useChatConnection.connect: start, session",s.userId),a){const l=new X.SessionHandler({...a,onSessionTokenRequired:Xo(a.onSessionTokenRequired,i)});e.setSessionHandler(l)}try{return await e.connect(s.userId,s.authToken),t.debug("useChatConnection.connect: end, currentUser",e.currentUser),e.currentUser}catch(l){const c=l;if(e.isCacheEnabled){if(Qo(c))t.warn("useChatConnection.connect","offline connect restricted",c.message,c.code),t.warn("useChatConnection.connect","clear cached-data"),await e.clearCachedData().catch(m=>t.warn("useChatConnection.connect","clear cached-data failure",m));else if(e.currentUser)return t.debug("useChatConnection.connect: end (offline), currentUser",e.currentUser),e.currentUser}throw t.warn("useChatConnection.connect","connect failure",c.message,c.code),c}},[e,t]),o=d.useCallback(async()=>{t.debug("useChatConnection.disconnect: start"),await e.disconnect(),t.debug("useChatConnection.disconnect: end")},[e,t]);return{connect:n,disconnect:o}}function Xo(e,t){if(e)return async(n,o)=>{new Promise((s,a)=>e==null?void 0:e(s,a)).then(s=>{s&&(t==null||t(s)),n(s)}).catch(s=>{o(s)})}}const Jo=[400300,400301,400302,400310];function Qo(e){return Jo.some(t=>e.code===t)}class Kn{constructor({userId:t,authToken:n,sessionHandler:o}){B(this,"userId");B(this,"authToken");B(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=o}}class At{constructor(){B(this,"userId");B(this,"authToken");B(this,"sessionHandler")}}const es=24*60*60*1e3,ts=e=>{const{logger:t,cache:n}=q(),o=()=>{const a=n.messenger.getAnonUser();return a?a.expireAt-es<=Date.now()?(t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session expired, clear cache"),n.messenger.clear(a.userId),null):(t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session info detected"),a):null},s=()=>{if(!e||e instanceof At)throw new Error("userSessionInfo must be an instance of ManualSessionInfo");if(typeof e.userId!="string")throw new Error("userSessionInfo.userId must be a string");const a=["userId","authToken","sessionHandler"].filter(i=>!(i in e));return a.length>0&&t.error(`useUserSessionCandidate.getManualSessionInfo: missing required keys in userSessionInfo: ${a.join(", ")}`),t.debug("useUserSessionCandidate.getManualSessionInfo: manual session info detected"),e};return d.useMemo(()=>e instanceof Kn?{type:"manual",userSessionCandidate:s()}:e instanceof At?{type:"anonymous",userSessionCandidate:o()}:e&&typeof e=="object"?(t.warn("Please use ManualSessionInfo instead of the old userSessionInfo format."),{type:"manual",userSessionCandidate:s()}):e===void 0?(t.warn("Please use AnonymousSessionInfo instead of undefined userSessionInfo."),{type:"anonymous",userSessionCandidate:o()}):{type:"anonymous",userSessionCandidate:null},[t,e==null?void 0:e.userId,e==null?void 0:e.authToken,e==null?void 0:e.sessionHandler,n.messenger.getAnonUser,n.messenger.clear])};function ns({userSessionInfo:e,onUpdateMessengerSettings:t,onPreAuth:n,onPostAuth:o,onErrorAuth:s,onAuthTokenRefreshed:a,onPostDeauth:i,forceCreateChannel:l}){const{aiAgentId:c,language:m,context:f,countryCode:p,logger:x,cache:y}=q(),{connect:v,disconnect:E}=Zo(),{type:b,userSessionCandidate:h}=ts(e),C=jn(),S=d.useCallback(async()=>{var N;x.debug("useAuthentication.authenticate: start");const w=h!=null&&h.userId?y.messenger.getSettings(h.userId):null;w!=null&&w.bot&&(t(w),x.debug("useAuthentication.authenticate: cached messenger settings",w));const k=await C({aiAgentId:c,userId:h==null?void 0:h.userId,language:m,country:p,context:f,forceCreateChannel:l,knownActiveChannelUrl:(N=w==null?void 0:w.active_channel)==null?void 0:N.channel_url});x.debug("useAuthentication.authenticate: messenger settings response",k);let I=null;if(k.auto_created_user)if(b==="manual")x.warn("Received auto created user info but current session is manual. Ignoring auto created user info."),I={userId:h.userId,authToken:h.authToken};else{const{user_id:J,session_token:$,expire_at:P}=k.auto_created_user;y.messenger.setAnonUser({userId:J,authToken:$,expireAt:P}),I={userId:J,authToken:$}}else I={userId:(h==null?void 0:h.userId)??"",authToken:(h==null?void 0:h.authToken)??""};y.messenger.setSettings(I.userId,k),t(k);try{await n(k,I),await v(I,h==null?void 0:h.sessionHandler,a),await o(k,I)}catch(J){throw J instanceof Error&&(s(J),x.error("useAuthentication.authenticate: failed to connect",J)),J}return k},[C,v,b,h==null?void 0:h.userId,h==null?void 0:h.sessionHandler,h==null?void 0:h.authToken,y.messenger.setAnonUser,y.messenger.getSettings,y.messenger.setSettings,t,n,o,s,a]),O=d.useCallback(async()=>{x.debug("useAuthentication.deauthenticate: start"),await E(),i(),x.debug("useAuthentication.deauthenticate: completed")},[E,x,i]);return{authenticate:S,deauthenticate:O,userSessionCandidate:h}}const Yn=e=>{try{const t=JSON.parse(e);return typeof t=="string"?JSON.stringify(t).slice(1,-1):e.trim()}catch{return JSON.stringify(e).slice(1,-1)}},Re=e=>JSON.parse(e),nt=e=>JSON.parse(e);function rs(e,t){const[n,o]=t.split(",").map(s=>s.trim());return e==="dark"&&o||n}function os(e){const t={};function n(o,s=""){for(const[a,i]of Object.entries(o)){const l=s?`${s}.${a}`:a;i&&typeof i=="object"&&!Array.isArray(i)?n(i,l):t[l]=i}}return n(e),t}function Ut({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:o}){return Object.entries(t).reduce((s,[a,i])=>{if(!o&&!["number","boolean","string"].includes(typeof i))throw new Error(`If transformer is not provided, value(${a}:${i}) must be a {string, number, or boolean}`);const l=o?o(i):String(i),c=n(a);return s.replace(c,Yn(l))},e)}async function ss({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:o}){return(await Promise.all(Object.entries(t).map(async([a,i])=>{const l=await o(i);return{regex:n(a),transformedValue:l}}))).reduce((a,{regex:i,transformedValue:l})=>a.replace(i,Yn(l)),e)}const as=()=>{const{chatSDK:e,logger:t,cache:n}=q(),o=d.useCallback(()=>{var l,c;const a=(c=(l=e.appInfo)==null?void 0:l.aiAgentInfo)==null?void 0:c.templateListToken;if(!a)return!1;const i=n.template.getCachedToken();return i?a!==i:!0},[e,n.template.getCachedToken]),s=d.useCallback(async()=>{try{const{templates:a,token:i}=await e.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:c}=Re(l);n.template.set(c,l)}n.template.setCachedToken(i)}catch(a){t==null||t.error("messageTemplateContext.syncCachedTemplates: error:",a)}},[e,t,n.template.set,n.template.setCachedToken]);return{shouldSyncCachedTemplate:o,syncCachedTemplates:s}};var Ke=(e=>(e.OFF="off",e.ALWAYS="always",e.HANDED_OFF_ONLY="handed_off_only",e))(Ke||{});const is={off:"off",always:"always",handed_off_only:"handed_off_only"},{Provider:ls,useContext:Vt}=Q("AIAgentMessengerSession"),cs=d.forwardRef(function({userSessionInfo:e,forceCreateChannel:t,children:n},o){const{appId:s,aiAgentId:a,chatSDK:i,language:l,countryCode:c,context:m,cache:f,logger:p}=q(),{updateTheme:x}=Ht(),[y,v]=d.useState(void 0),[E,b]=d.useState(void 0),[h,C]=d.useState(null),[S,O]=d.useState(null),[w,k]=d.useState(null),[I,N]=d.useState(null),[J,$]=d.useState("handed_off_only"),{shouldSyncCachedTemplate:P,syncCachedTemplates:W}=as(),U=jn(),{authenticate:K,deauthenticate:te}=ns({userSessionInfo:e,forceCreateChannel:t,onUpdateMessengerSettings:d.useCallback(_=>{const{appearance:D,bot:z,launcher:ne,active_channel:mt}=_;x(D.selected_theme,D),k({userId:z.bot_userid,profileUrl:z.bot_profile_url,nickname:z.bot_nickname,replyToFile:z.reply_to_file,specialNotice:z.special_notice,specialNoticeEnabled:z.is_special_notice_enabled,showHandoffButton:z.show_handoff_button??!0,isMultipleActiveConversationsEnabled:z.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:_.bot.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:_.bot.is_user_feedback_comment_option_enabled??!1}),N({type:ne.image_type||"default_icon",imageUrl:ne.image_url}),$(is[mt.attachment_mode]??"handed_off_only")},[x]),onPreAuth:d.useCallback((_,D)=>{v(void 0),O(D)},[]),onPostAuth:d.useCallback(async _=>{C(i.currentUser),P()&&await W(),b({url:_.active_channel.channel_url,status:G.ConversationStatus.OPEN})},[i,P,W]),onErrorAuth:d.useCallback(_=>{v(_)},[]),onAuthTokenRefreshed:d.useCallback(_=>{O(D=>D?{...D,authToken:_}:null)},[]),onPostDeauth:d.useCallback(()=>{f.template.clear(),f.messenger.clear(S==null?void 0:S.userId),C(null),b(void 0),O(null),k(null),N(null)},[f.template.clear,f.messenger.clear,S])}),le=d.useCallback(async()=>{var _;if(S){p.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"),b(void 0);const D=await U({aiAgentId:a,userId:S.userId,language:l,country:c,context:m,forceCreateChannel:t,knownActiveChannelUrl:(_=f.messenger.getSettings(S.userId))==null?void 0:_.active_channel.channel_url});return f.messenger.setSettings(S.userId,D),b({url:D.active_channel.channel_url,status:G.ConversationStatus.OPEN}),p.info("agentMessengerSession.refreshActiveChannel: refreshed active channel",D.active_channel.channel_url),D.active_channel.channel_url}else throw p.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[U,s,a,S==null?void 0:S.userId,l,c,m,t,f.messenger.getSettings,f.messenger.setSettings]),V=d.useCallback(async _=>{if(!(S!=null&&S.userId))throw new Error("Current user is not authenticated. Please authenticate first.");const D=await U({..._,userId:S.userId,knownActiveChannelUrl:void 0}),z=D.active_channel.channel_url;return f.messenger.setSettings(S.userId,D),z},[S==null?void 0:S.userId,U]);return Me.useGroupChannelHandler(i,{onChannelChanged:_=>{var D;_.isGroupChannel()&&_.url===(E==null?void 0:E.url)&&(p.info("agentMessengerSession.channelChanged: channel.conversation",_.conversation),b({url:_.url,status:((D=_.conversation)==null?void 0:D.status)??G.ConversationStatus.OPEN}))}}),d.useImperativeHandle(o,()=>{const _=async()=>{if(!E)throw new Error("No active conversation. Please start a conversation first.");return await i.groupChannel.getChannel(E.url)};return{activeChannel:E,chatSDK:i,authenticate:K,deauthenticate:te,updateContext:async D=>{const ne=await(await _()).updateContext(a,D);return{...ne,context:ne.context??{}}},patchContext:async D=>{const ne=await(await _()).patchContext(a,D);return{...ne,context:ne.context??{}}},getContextObject:async()=>{const z=await(await _()).getContextObject(a);return{...z,context:z.context??{}}}}},[K,te,E,i,a,p]),r.createElement(ls,{value:{sdkUser:h,userSessionInfo:e,userSession:S,activeChannel:E,setActiveChannel:b,refreshActiveChannel:le,createConversation:V,connectionError:y,aiAgentInfo:w,launcherInfo:I,authenticate:K,deauthenticate:te,attachmentMode:J}},n)}),Zn=e=>{const{chatSDK:t}=q(),[n,o]=d.useState([]);return Me.useGroupChannelHandler(t,{onTypingStatusUpdated(s){if(s.url===(e==null?void 0:e.url)){const a=s.getTypingUsers();o(a)}}}),n},ds=({channel:e,messages:t})=>{const{aiAgentInfo:n,userSession:o}=Vt(),s=us(),a=ms({channel:e,lastMessage:sn(t,[ve.SendingStatus.SUCCEEDED]),aiAgentUserId:(n==null?void 0:n.userId)??""}),i=ps({shouldApply:!!(e!=null&&e.isAIAgent)&&!De(e),isDisabledWhileAIResponding:a,lastMessage:sn(t,[ve.SendingStatus.PENDING,ve.SendingStatus.SUCCEEDED]),currentUserId:(o==null?void 0:o.userId)??""});if(!e||!s)return{disabled:!0,disabledBy:"unavailable"};if(fe(e))return{disabled:!0,disabledBy:"conversation_closed"};if(gs(e))return{disabled:!0,disabledBy:"form_active"};const l=hs(e);return l?{disabled:!0,disabledBy:l}:a||i?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},us=()=>{const e=d.useId(),{chatSDK:t}=q(),[n,o]=d.useState(!0);return d.useEffect(()=>{const s=new X.ConnectionHandler({onDisconnected:()=>o(!1),onConnected:()=>o(!0),onReconnectSucceeded:()=>o(!0)});return t.addConnectionHandler(e,s),()=>{t.removeConnectionHandler(e)}},[t]),n},ms=({channel:e,lastMessage:t,aiAgentUserId:n})=>{const[o,s]=d.useState(!1),a=Zn(e);return d.useEffect(()=>{if(!t)return;const i=a.some(c=>c.userId===n),l=Ie(t,n)&&be.isStreaming(t);s(!!(l||i))},[a,t,n]),o},gs=e=>{var i;const t=e==null?void 0:e.lastMessage;if(!t||!e)return!1;const n=t.extendedMessagePayload,o=n==null?void 0:n.form,s=o&&!o.submitted_at&&!o.canceled_at,a=e.isAIAgent&&!!((i=e.conversation)!=null&&i.handedOverAt);return s&&!a},hs=e=>{const t=e==null?void 0:e.lastMessage,n=t==null?void 0:t.extendedMessagePayload;return n==null?void 0:n.user_input_disabled_by},fs=3e4,ps=({shouldApply:e,lastMessage:t,isDisabledWhileAIResponding:n,currentUserId:o})=>{const[s,a]=d.useState(!1),i=d.useRef(null),l=t&&Ie(t,o)?t.createdAt:0;return d.useEffect(()=>{const c=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},m=x=>{i.current&&clearTimeout(i.current),a(!0),i.current=setTimeout(()=>{a(!1),i.current=null},x)},f=Date.now()-l,p=fs-f;return n||p<=0?c():m(p),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},{Provider:bs}=Q("AIAgentConversation");function Es({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:o,onMessagesUpdated:s,onConversationClosedViaDispatcher:a,onBeforeSendMessage:i,onAfterSendMessage:l=pe,shouldMarkAsRead:c=!0,sortComparator:m}){var O;const f=()=>c&&(v==null?void 0:v.markAsRead()),{chatSDK:p,logger:x,dispatcher:y}=q(),{channel:v,channelFetchError:E,fetchChannel:b}=xs(t),h=Do(p,v,{shouldCountNewMessages:()=>!1,onChannelDeleted:n,onMessagesReceived:w=>o==null?void 0:o(w),onMessagesUpdated:w=>s==null?void 0:s(w),logger:x,markAsRead:f,sortComparator:m}),C=ds({channel:v,messages:h.messages});d.useEffect(()=>{f()},[c]),d.useEffect(()=>{const w=async k=>{const I=typeof(k==null?void 0:k.channelUrl)=="string";v&&I&&k.channelUrl!==v.url||(x.debug("conversation.dispatcher: try to close conversation",v),v!=null&&v.conversation&&v.conversation.status===G.ConversationStatus.OPEN&&(await v.closeConversation(),a==null||a()))};return y.subscribe(St.ConversationClose,w),()=>{y.unsubscribe(St.ConversationClose,w)}},[y,(O=v==null?void 0:v.conversation)==null?void 0:O.status,a]);const S={conversation:(v==null?void 0:v.conversation)??void 0,channelSource:{channel:v,error:E,refetch:()=>b(),closeConversation:async()=>{fe(v)||await(v==null?void 0:v.closeConversation())}},messageSource:{messages:h.messages,initialized:h.initialized,loadPrevious:()=>h.loadPrevious(),loadNext:()=>h.loadNext(),deleteMessage:w=>h.deleteMessage(w),resendMessage:w=>h.resendMessage(w),sendUserMessage:async w=>{var I;if(((I=v==null?void 0:v.conversation)==null?void 0:I.status)===G.ConversationStatus.CLOSED)throw new Error("Conversation is closed");i&&(w=await i(w));const k=await h.sendUserMessage(w,l);return l==null||l(k),k},sendFileMessage:async w=>{var I;if(((I=v==null?void 0:v.conversation)==null?void 0:I.status)===G.ConversationStatus.CLOSED)throw new Error("Conversation is closed");i&&(w=await i(w));const k=await h.sendFileMessage(w,l);return l==null||l(k),k}},state:{input:C}};return r.createElement(bs,{value:S},e)}function xs(e){const{chatSDK:t,logger:n}=q(),[o,s]=d.useState(void 0),[a,i]=d.useState(void 0);async function l(){if(n.debug("conversation.fetchChannel: start"),s(void 0),i(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const c=await t.groupChannel.getChannel(e);s(c),n.debug("conversation.fetchChannel: fetched channel",c)}catch(c){c instanceof X.SendbirdError&&i(c),n.error("conversation.fetchChannel: error",c)}}return vs(o),d.useEffect(()=>{l()},[t,e]),{channel:o,channelFetchError:a,fetchChannel:l}}function vs(e){const{chatSDK:t}=q(),{activeChannel:n,setActiveChannel:o}=Vt(),s=d.useId();d.useEffect(()=>{if(!e||!n)return;const a=new X.ConnectionHandler({onReconnectSucceeded:async()=>{var l;const i=await e.refresh();i.url===n.url&&o({url:i.url,status:((l=i.conversation)==null?void 0:l.status)??G.ConversationStatus.OPEN})}});return t.addConnectionHandler(s,a),()=>{t.removeConnectionHandler(s)}},[t,e,n])}class ys{constructor(t,{filter:n,limit:o=20}){B(this,"filter");B(this,"_sdk");B(this,"_pinnedChannels");B(this,"_channels");B(this,"_isDisposed",!1);B(this,"_handlerId",`handler-id-${Date.now()}`);B(this,"_order",Ze.GroupChannelListOrder.LATEST_LAST_MESSAGE);B(this,"_limit");B(this,"_query");B(this,"_token");B(this,"_timestamp");B(this,"_isSyncing");B(this,"_channelHandler");B(this,"_connectionHandler");B(this,"_collectionEventHandler");var s,a,i,l,c,m,f;this.filter=n,this._sdk=t,this._pinnedChannels=[],this._channels=[],this._limit=o,this._query=this._sdk.aiAgent.createMyGroupChannelListQuery({aiAgentChannelFilter:(s=this.filter)==null?void 0:s.aiAgentChannelFilter,aiAgentConversationStatusFilter:(a=this.filter)==null?void 0:a.aiAgentConversationStatusFilter,aiAgentIds:(i=this.filter)==null?void 0:i.aiAgentIds,deskChannelFilter:(l=this.filter)==null?void 0:l.deskChannelFilter,pinnedChannelUrls:(c=this.filter)==null?void 0:c.pinnedChannelUrls,copilotConversationOnly:(m=this.filter)==null?void 0:m.copilotConversationOnly,copilotSupportChannelUrl:(f=this.filter)==null?void 0:f.copilotSupportChannelUrl,limit:this._limit}),this._token="",this._timestamp=Number.MAX_SAFE_INTEGER,this._isSyncing=!1,this._channelHandler=new Ze.GroupChannelHandler({onChannelChanged:p=>{p.isGroupChannel()&&(this._query.belongsTo(p)?this._addChannelsToView([p],!1):this._removeChannelsFromView([p.url]))},onChannelDeleted:p=>{this._removeChannelsFromView([p])}}),this._connectionHandler=new X.ConnectionHandler({onReconnectSucceeded:()=>{this._isDefaultChangelogSyncTimestampUpdated&&this._syncChannelChangelogs()}}),this._sdk.addConnectionHandler(this._handlerId,this._connectionHandler),this._sdk.groupChannel.addGroupChannelHandler(this._handlerId,this._channelHandler)}get _isDefaultChangelogSyncTimestampUpdated(){return this._timestamp!==Number.MAX_SAFE_INTEGER}_setDefaultChangelogsSyncTimestamp(t){var a,i;const n=new Set(((a=this.filter)==null?void 0:a.pinnedChannelUrls)??[]),o=t.find(l=>!n.has(l.url));let s;o?s=((i=o.lastMessage)==null?void 0:i.createdAt)??o.createdAt:s=this._query.lastResponseAt,this._timestamp>s&&(this._timestamp=s)}async _syncChannelChangelogs(){if(this._isDisposed)return[];if(this._isSyncing)return[];try{this._isSyncing=!0;let t;for(this._token?t=await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token,this.filter):t=await this._sdk.aiAgent.getMyGroupChannelChangeLogsByTimestamp(this._timestamp,this.filter),this._token=t.token,this._addChannelsToView(t.updatedChannels),this._removeChannelsFromView(t.deletedChannelUrls);t.hasMore&&t.token;)t=await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token,this.filter),this._token=t.token,this._addChannelsToView(t.updatedChannels),this._removeChannelsFromView(t.deletedChannelUrls)}catch{}finally{this._isSyncing=!1}return[]}_upsertPinnedChannelsToArray(t){var l;const n=((l=this.filter)==null?void 0:l.pinnedChannelUrls)??[],o=new Map(n.map((c,m)=>[c,m])),s=[],a=[],i=[];for(const c of t){if(!this._query.belongsTo(c)){i.push(c.url);continue}const m=o.get(c.url);if(m===void 0)continue;const f=kt(this._pinnedChannels,c);f>=0?(this._pinnedChannels.splice(f,1),a.push(c)):s.push(c);const x=this._pinnedChannels.findIndex(v=>(o.get(v.url)??1/0)>m),y=x===-1?this._pinnedChannels.length:x;this._pinnedChannels.splice(y,0,c)}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:i}}_upsertRegularChannelsToArray(t,n=!1){const o=[],s=[],a=[];for(const i of t){if(!this._query.belongsTo(i)){o.push(i.url);continue}const l=kt(this._channels,i),c=l<0;!c&&this._channels.splice(l,1);const f=Cs(this._channels,i,this._order).place,p=f===this._channels.length;c?p?(n||!this.hasMore)&&(this._channels.push(i),s.push(i)):(this._channels.splice(f,0,i),s.push(i)):(this._channels.splice(f,0,i),a.push(i))}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:o}}_addChannelsToView(t,n=!1){var p,x,y,v,E;const o=new Set(((p=this.filter)==null?void 0:p.pinnedChannelUrls)??[]),s=[],a=[];for(const b of t)o.has(b.url)?s.push(b):a.push(b);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),c=i.addedChannels.concat(l.addedChannels),m=i.updatedChannels.concat(l.updatedChannels),f=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);c.length>0&&((y=(x=this._collectionEventHandler)==null?void 0:x.onChannelsAdded)==null||y.call(x,{},c)),m.length>0&&((E=(v=this._collectionEventHandler)==null?void 0:v.onChannelsUpdated)==null||E.call(v,{},m)),f.length>0&&this._removeChannelsFromView(f)}_removeChannelsFromView(t){var s,a,i;const n=new Set(((s=this.filter)==null?void 0:s.pinnedChannelUrls)??[]),o=[];for(const l of t)if(n.has(l)){const c=this._pinnedChannels.findIndex(m=>m.url===l);c>=0&&(o.push(l),this._pinnedChannels.splice(c,1))}else{const c=this._channels.findIndex(m=>m.url===l);c>=0&&(o.push(l),this._channels.splice(c,1))}o.length>0&&((i=(a=this._collectionEventHandler)==null?void 0:a.onChannelsDeleted)==null||i.call(a,{},o))}get channels(){return this._isDisposed?[]:[...this._pinnedChannels,...this._channels]}get hasMore(){return this._isDisposed?!1:this._query.hasNext}async loadMore(){if(this._isDisposed)return[];if(this.hasMore){const t=await this._query.next();return this._setDefaultChangelogsSyncTimestamp(t),this._addChannelsToView(t,!0),t}return[]}setConversationListCollectionHandler(t){this._collectionEventHandler=t}dispose(){this._isDisposed||(this._isDisposed=!0,this._collectionEventHandler=void 0,this._sdk.removeConnectionHandler(this._handlerId),this._sdk.groupChannel.removeGroupChannelHandler(this._handlerId),this._pinnedChannels.length=0,this._channels.length=0)}}const kt=(e,t)=>e.findIndex(n=>n.isIdentical(t)),Cs=(e,t,n)=>{if(e.length>0){const o=kt(e,t);let s=0,a=e.length-1,i=Math.floor((s+a)/2);for(;s<a;){const c=un(e[i],t,n);if(c>0)a=i,i=Math.floor((s+a)/2);else if(c<0)s=i+1,i=Math.floor((s+a)/2);else return{place:i,oldPosition:o}}return{place:un(e[i],t,n)>=0?i:i+1,oldPosition:o}}return{place:e.length,oldPosition:-1}},un=(e,t,n)=>{switch(n){case Ze.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const o=t.lastMessage.createdAt-e.lastMessage.createdAt;return o===0?t.createdAt-e.createdAt:o}else return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;default:return 0}};function _s(e,t){var v,E,b,h,C,S,O,w,k,I;const n=d.useId(),[o,s]=d.useState(!1),[a,i]=d.useState(null),[l,c]=d.useState([]),[m,f]=d.useState(null),p=d.useRef(!1),x=d.useCallback(async()=>{if(!p.current&&e.currentUser){p.current=!0,s(!1),i(null),c([]);try{m==null||m.dispose();const N=new ys(e,t);N.setConversationListCollectionHandler({onChannelsAdded:()=>{c(N.channels)},onChannelsUpdated:()=>{c(N.channels)},onChannelsDeleted:()=>{c(N.channels)}}),await N.loadMore(),f(N),i(null)}catch(N){f(null),i(N)}finally{s(!0),p.current=!1}}},[e,e.currentUser,(v=t.filter)==null?void 0:v.aiAgentChannelFilter,(b=(E=t.filter)==null?void 0:E.aiAgentConversationStatusFilter)==null?void 0:b.join(),(C=(h=t.filter)==null?void 0:h.aiAgentIds)==null?void 0:C.join(),(S=t.filter)==null?void 0:S.deskChannelFilter,(w=(O=t.filter)==null?void 0:O.pinnedChannelUrls)==null?void 0:w.join(),(k=t.filter)==null?void 0:k.copilotConversationOnly,(I=t.filter)==null?void 0:I.copilotSupportChannelUrl,t.limit]),y=d.useCallback(async()=>{if(m)try{await m.loadMore()}catch(N){i(N)}},[m]);return d.useEffect(()=>(e.addConnectionHandler(n,new X.ConnectionHandler({onConnected:()=>x()})),()=>e.removeConnectionHandler(n)),[e,n,x]),d.useEffect(()=>{x()},[x]),d.useEffect(()=>()=>{p.current=!1,m==null||m.dispose()},[m]),{initialized:o,error:a,channels:l,loadMore:y}}const{Provider:Ss}=Q("AIAgentConversationList");function Ts({conversationListLimit:e,conversationListFilter:t,children:n}){var p,x;const{chatSDK:o,aiAgentId:s,queryParams:a}=q(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[G.ConversationStatus.CLOSED,G.ConversationStatus.OPEN]},l=e??((p=a==null?void 0:a.conversationListParams)==null?void 0:p.limit),c={...i,...(x=a==null?void 0:a.conversationListParams)==null?void 0:x.filter,...t},m=_s(o,{limit:l,filter:c}),f={listSource:{initialized:m.initialized,error:m.error??void 0,channels:m.channels,loadMore:()=>m.loadMore()}};return r.createElement(Ss,{value:f},n)}function ws(e){let t="pending",n=e.then(o=>{t="resolved",n=o}).catch(o=>{t="rejected",n=o});return{get value(){if(t==="resolved")return n;throw n}}}const{Provider:As,useContext:Xn}=Q("MessageTemplateFetching");function ks({children:e,internalVariables:t}){const n=d.useRef({}),o=d.useRef({}),[s,a]=d.useState({}),i=d.useCallback((m,f)=>{a(p=>({...p,[m]:{fetching:!1,error:!1,...p[m],...f}}))},[]),l=d.useCallback(async({onRequestTemplate:m,onGetCachedTemplate:f,templateKey:p,suspense:x=!1})=>{const y=f(p);if(y)return y;const v=o.current[p];if(v)return v;x||i(p,{fetching:!0});const E=m(p).catch(b=>{throw x||i(p,{error:!0}),b}).finally(()=>{x||i(p,{fetching:!1}),delete o.current[p]});return o.current[p]=E,E},[i]),c={internalVariables:t,fetchTemplate:l,suspend:(m,f)=>{if(n.current[m])return n.current[m];const p=ws(f());return n.current[m]=p,p},getIsFetching:m=>{var f;return((f=s[m])==null?void 0:f.fetching)??!1},getHasError:m=>{var f;return((f=s[m])==null?void 0:f.error)??!1}};return r.createElement(As,{value:c},e)}const rt={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function Ee({uiTemplateString:e,variables:t={}}){const n=os(t);return Ut({template:e,variables:n,variableKeyPattern:o=>rt.VARIABLE(o)})}function xe({theme:e,uiTemplateString:t,colorVariables:n={}}){return Ut({template:t,variables:n,variableKeyPattern:o=>rt.VARIABLE(o),variableValueTransformer:o=>rs(e,o)})}function Is({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:o,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(m=>m.key);return[...new Set(l)].some(m=>!a(m))?null:Ut({template:t,variables:n,variableKeyPattern:m=>rt.VIEW_VARIABLE(m),variableValueTransformer:m=>{const f=m.map(({key:p,variables:x})=>{const y=a(p),{ui_template:v,color_variables:E}=Re(y);let b=JSON.stringify(v);return b=Ee({uiTemplateString:b,variables:s}),b=xe({theme:e,uiTemplateString:b,colorVariables:E}),b=xe({theme:e,uiTemplateString:b,colorVariables:o}),b=Ee({uiTemplateString:b,variables:x}),nt(b)});return JSON.stringify(f)}})}async function $s({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:o,internalVariables:s,onRequestTemplate:a}){return ss({template:t,variables:n,variableKeyPattern:i=>rt.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:m,variables:f})=>{const p=await a(m),{ui_template:x,color_variables:y}=Re(p);let v=JSON.stringify(x);return v=Ee({uiTemplateString:v,variables:s}),v=xe({theme:e,uiTemplateString:v,colorVariables:y}),v=xe({theme:e,uiTemplateString:v,colorVariables:o}),v=Ee({uiTemplateString:v,variables:f}),nt(v)}),c=await Promise.all(l);return JSON.stringify(c)}})}const Ms=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...o})=>{const{ui_template:s,color_variables:a}=Re(e);let i=JSON.stringify(s);if(Object.keys(o.viewVariables??{}).length>0){const c=Is({...o,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(c===null)return null;i=c}return i=Ee({...o,uiTemplateString:i,variables:n}),i=xe({...o,uiTemplateString:i,colorVariables:a}),i=xe({...o,uiTemplateString:i,colorVariables:t}),i=Ee({...o,uiTemplateString:i}),nt(i)},Os=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...o})=>{const{ui_template:s,color_variables:a}=Re(e);let i=JSON.stringify(s);return Object.keys(o.viewVariables??{}).length>0&&(i=await $s({...o,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=Ee({...o,uiTemplateString:i,variables:n}),i=xe({...o,uiTemplateString:i,colorVariables:a}),i=xe({...o,uiTemplateString:i,colorVariables:t}),i=Ee({...o,uiTemplateString:i}),nt(i)},Ls=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=Xn();return d.useState(()=>{const o=e.onGetCachedTemplate(e.templateKey);return o?Ms({...e,rawTemplate:o,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Ds=e=>{const[t]=Ls(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:o,fetchTemplate:s,suspend:a}=Xn();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Os({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:o})}).value},Rs="remove_powered_by",zt=(e,t)=>{var s,a;const{chatSDK:n}=q(),{aiAgentInfo:o}=Vt();if(e==="handoff-button"){const i=!!((s=t==null?void 0:t.conversation)!=null&&s.handoff);return!!(t!=null&&t.isAIAgent)&&!!(o!=null&&o.showHandoffButton)&&i&&Ct(t)}if(e==="special-notice")return!!(t!=null&&t.isAIAgent)&&!!(o!=null&&o.specialNoticeEnabled)&&!!(o!=null&&o.specialNotice);if(e==="powered-by"){const i=(a=n==null?void 0:n.appInfo)==null?void 0:a.applicationAttributes;return d.useMemo(()=>!(Array.isArray(i)&&i.includes(Rs)),[i])}throw new Error("Unsupported feature")},Ns={required:"This question is required",minLength:e=>`Minimum ${e} characters required`,maxLength:e=>`Maximum ${e} characters allowed`,min:e=>`Minimum value is ${e}`,max:e=>`Maximum value is ${e}`,minSelect:e=>`Select at least ${e} options`,maxSelect:e=>`Select at most ${e} options`,regex:"Invalid format",invalidSelection:"Invalid selection"},Ps={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const o=t;if(e.required&&(!o||o.trim()===""))return{isValid:!1,error:n.required};if(!o)return{isValid:!0};const{rules:s}=e;if(s){if(s.min_length!==void 0&&o.length<s.min_length)return{isValid:!1,error:typeof n.minLength=="function"?n.minLength(s.min_length):n.minLength};if(s.max_length!==void 0&&o.length>s.max_length)return{isValid:!1,error:typeof n.maxLength=="function"?n.maxLength(s.max_length):n.maxLength};if(s.regex&&!new RegExp(s.regex).test(o))return{isValid:!1,error:n.regex}}return{isValid:!0}}},Bs={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const o=t;if(e.required&&o===null)return{isValid:!1,error:n.required};if(o===null)return{isValid:!0};const{rules:s}=e;if(s){if(s.min!==void 0&&o<s.min)return{isValid:!1,error:typeof n.min=="function"?n.min(s.min):n.min};if(s.max!==void 0&&o>s.max)return{isValid:!1,error:typeof n.max=="function"?n.max(s.max):n.max}}return{isValid:!0}}},Fs={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const o=t;return e.required&&!o?{isValid:!1,error:n.required}:o&&!e.options.includes(o)?{isValid:!1,error:n.invalidSelection}:{isValid:!0}}},Hs={getValueOrDefault:e=>e.values??e.default_values??null,validate:(e,t,n)=>{const o=t;if(e.required&&(!o||o.length===0))return{isValid:!1,error:n.required};if(!o||o.length===0)return{isValid:!0};if(o.filter(i=>!e.options.includes(i)).length>0)return{isValid:!1,error:n.invalidSelection};const{rules:a}=e;if(a){if(a.min_select!==void 0&&o.length<a.min_select)return{isValid:!1,error:typeof n.minSelect=="function"?n.minSelect(a.min_select):n.minSelect};if(a.max_select!==void 0&&o.length>a.max_select)return{isValid:!1,error:typeof n.maxSelect=="function"?n.maxSelect(a.max_select):n.maxSelect}}return{isValid:!0}}},Us={text:Ps,number:Bs,"single-select":Fs,"multi-select":Hs},Vs={getValueOrDefault:()=>null,validate:()=>({isValid:!1})};function Jn(e){return Us[e.type]||Vs}function mn(e){return Jn(e).getValueOrDefault(e)}function zs(e,t,n={}){const o={...Ns,...n};return Jn(e).validate(e,t,o)}const Gs=(e,t={})=>{const{labels:n={},onSubmit:o,onCancel:s}=t,[a,i]=d.useState({}),[l,c]=d.useState(()=>{const E={};return e.fields.forEach(b=>{E[b.key]=mn(b)}),E}),m=d.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);d.useEffect(()=>{if(m==="submitted"||m==="canceled"){const E={};let b=!1;e.fields.forEach(h=>{const C=mn(h);JSON.stringify(l[h.key])!==JSON.stringify(C)&&(b=!0),E[h.key]=C}),b&&c(E)}},[m]);const f=(E,b)=>{c(h=>({...h,[E]:b})),i(h=>({...h,[E]:void 0}))},p=e.fields.map(E=>{var C,S,O;const b=l[E.key]??null,h={key:E.key,label:E.label,error:a[E.key],required:E.required};return E.type==="text"?{...h,type:"text",layout:E.layout,value:b,...E.placeholder&&{placeholder:E.placeholder},...((C=E.rules)==null?void 0:C.max_length)&&{maxLength:E.rules.max_length}}:E.type==="number"?{...h,type:"number",layout:E.layout,value:b,...E.placeholder&&{placeholder:E.placeholder},...((S=E.rules)==null?void 0:S.max)&&{max:E.rules.max}}:E.type==="single-select"?{...h,type:"single-select",layout:E.layout,value:b,options:E.options}:E.type==="multi-select"?{...h,type:"multi-select",layout:E.layout,value:b,options:E.options,...((O=E.rules)==null?void 0:O.max_select)&&{maxSelect:E.rules.max_select}}:{...h,type:"unknown",layout:"default",value:null}});return{state:m,fields:p,getField:E=>p.find(b=>b.key===E),updateFieldValue:f,submit:async()=>{const E={};let b=!1;for(const h of e.fields){const C=l[h.key]??null,S=zs(h,C,n);S.isValid||(E[h.key]=S.error,b=!0)}if(i(E),!b&&o){const h={};e.fields.forEach(C=>{h[C.key]=l[C.key]??null}),await o(h)}},cancel:async()=>{await(s==null?void 0:s())}}},Qn=({channel:e,userSession:t,aiAgentInfo:n})=>{if(!t||!n)return{fallbackIcon:"bot-filled",url:void 0,title:""};const o={ai(a){return{fallbackIcon:a,url:n.profileUrl,title:n.nickname}},human(a){return{fallbackIcon:a,url:s==null?void 0:s.profileUrl,title:(s==null?void 0:s.nickname)||n.nickname}},channel(a){return{fallbackIcon:a,url:e==null?void 0:e.coverUrl,title:(e==null?void 0:e.name)??""}}};if(!e)return o.ai("bot-filled");const s=(()=>{const[a]=e.members.filter(i=>i.userId!==t.userId);return a})();return e.isAIAgent?De(e)?o.human("agent"):o.ai("bot-filled"):e.isDesk?o.human("agent"):o.channel("user")},gn=e=>d.useReducer((t,n)=>({...t,...n}),e);var ae=(e=>(e.AI_AGENT_CSAT_5="AI_AGENT_CSAT_5",e.AI_AGENT_CSAT_5_WITH_CRE="AI_AGENT_CSAT_5_WITH_CRE",e.HELPDESK_CSAT_5="HELPDESK_CSAT_5",e))(ae||{});const Ws='@import"https://fonts.googleapis.com/css?family=Roboto:400,500,600,700&display=swap";.sb-message-template__border{position:relative}.sb-message-template__border:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;box-shadow:inset 0 0 0 var(--border-width) var(--border-color);border-radius:var(--border-radius);pointer-events:none}.sb-message-template__action{cursor:pointer}.sb-message-template__parent{font-family:Roboto,serif}.sb-message-template__text{font-family:inherit;font-size:14px;font-weight:400;font-stretch:normal;font-style:normal;letter-spacing:normal;text-align:left}.sb-message-template__text-button{font-family:inherit;background-color:#e0e0e0;text-align:center;padding:10px;border-radius:6px;font-size:14px;font-weight:600;font-stretch:normal;font-style:normal;letter-spacing:normal}.sendbird-theme--light .sb-message-template__text-button{color:#742ddd}.sendbird-theme--dark .sb-message-template__text-button{color:#c2a9fa}.sb-message-template__text-button:hover{opacity:1;box-shadow:#0000001a 0 1px 3px,#0000000f 0 1px 2px}.sb-message-template__text-button,.sb-message-template__image-button{cursor:pointer;border-style:none}.sb-message-template__parent{border-radius:unset;background-color:transparent;overflow:hidden}.sb-message-template__parent *{box-sizing:border-box;line-height:1.3}.sb-message-template__carousel{display:flex;width:100%;box-sizing:border-box;touch-action:pan-y}',qs={conversation:{input_placeholder:"Ask a question",input_placeholder_disabled:"Chat is unavailable in this channel",input_placeholder_wait_ai_agent_response:"Waiting for the agent's reply...",input_placeholder_active_form:"Please fill out the form to move forward.",unknown_message_type:"(Unknown message type)",powered_by:"Powered by",citation_title:"Source",start_new_conversation_label:"Talk to agent",failed_message_resend:"Retry",failed_message_remove:"Remove"},conversation_list:{header_title:"Conversations",ended:"Ended"},date_format:{just_now:"Just now",minutes_ago:e=>`${e} minutes ago`,hours_ago:e=>`${e} hours ago`,date_short:"MM/dd/yyyy",date_separator:"MMMM dd, yyyy",message_timestamp:"p"},csat:{title:"Your feedback matters to us",submitted_label:"Successfully submitted!",cre_question:"Was your issue resolved?",cre_positive_label:"Yes, thank you! 👍",cre_negative_label:"No, that didn't help.",reason_placeholder:"Share your feedback",question:"How would you rate your experience?",submit_label:"Submit",submission_expired:"We're sorry, the survey period has ended."},form:{optional_label:"optional",validation_required:"This question is required"},common:{placeholder_something_went_wrong:"Something went wrong",placeholder_no_messages:"No messages",placeholder_no_conversations:"No conversations yet",placeholder_something_went_wrong_retry_label:"Retry"}},It={language:"en",strings:qs,dateLocale:no.enUS},er=e=>({MESSAGE_INPUT__PLACE_HOLDER:e.conversation.input_placeholder,MESSAGE_INPUT__PLACE_HOLDER__DISABLED:e.conversation.input_placeholder_disabled,MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE:e.conversation.input_placeholder_wait_ai_agent_response,UNKNOWN__UNKNOWN_MESSAGE_TYPE:e.conversation.unknown_message_type,POWERED_BY:e.conversation.powered_by,CSAT_TITLE_UNSUBMITTED:e.csat.title,CSAT_TITLE_SUBMITTED:e.csat.submitted_label,CSAT_CRE_TITLE:e.csat.cre_question,CSAT_CRE_SOLVED:e.csat.cre_positive_label,CSAT_CRE_NOT_SOLVED:e.csat.cre_negative_label,CSAT_REASON_PLACEHOLDER:e.csat.reason_placeholder,CSAT_RATING_TITLE:e.csat.question,CSAT_SUBMIT_LABEL:e.csat.submit_label,CSAT_SUBMISSION_EXPIRED:e.csat.submission_expired,DATE_FORMAT__JUST_NOW:e.date_format.just_now,DATE_FORMAT__MINUTES_AGO:e.date_format.minutes_ago,DATE_FORMAT__HOURS_AGO:e.date_format.hours_ago,DATE_FORMAT__DATE_SHORT:e.date_format.date_short,DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR:e.date_format.date_separator,DATE_FORMAT__MESSAGE_TIMESTAMP:e.date_format.message_timestamp,CONVERSATION_LIST__HEADER_TITLE:e.conversation_list.header_title,CONVERSATION_LIST__ENDED:e.conversation_list.ended,CONVERSATION_LIST__NO_CONVERSATIONS:e.common.placeholder_no_conversations,TALK_TO_AGENT:e.conversation.start_new_conversation_label,CITATION_SOURCE_TITLE:e.conversation.citation_title,FORM_PLACEHOLDER:e.conversation.input_placeholder_active_form,FORM_VALIDATION_REQUIRED:e.form.validation_required,OPTIONAL:e.form.optional_label,PLACE_HOLDER__WRONG:e.common.placeholder_something_went_wrong,PLACE_HOLDER__NO_MESSAGES:e.common.placeholder_no_messages,RETRY:e.common.placeholder_something_went_wrong_retry_label,FAILED_MESSAGE_RESEND:e.conversation.failed_message_resend,FAILED_MESSAGE_REMOVE:e.conversation.failed_message_remove}),js=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??ot},ot="en",Ks=new Set([ot,"ko","es","pt","fr","hi","it","de","tr","ja"]),Ys=(e,t,n)=>{const o=e[t];return o?typeof o=="function"?o():Promise.resolve(o):new Promise((s,a)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(a.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})},hn=er(It.strings),Zs={...hn,CHANNEL_FROZEN:"Channel frozen",HEADER_BUTTON__AGENT_HANDOFF:"Connect with an agent",MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES:"Select an option to continue",BUTTON__CANCEL:"Cancel",BUTTON__SAVE:"Save",BUTTON__OK:"OK",BUTTON__SUBMIT:"Submit",NO_NAME:"(No name)",SUBMITTED:"Submitted",TRY_AGAIN:"Please try again.",FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT:"You can't upload more than one image",FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT:"The maximum size per file is %d MB.",FILE_VIEWER__UNSUPPORT:"Unsupported message",CSAT5_RATING_SCORE_1:"Terrible",CSAT5_RATING_SCORE_2:"Bad",CSAT5_RATING_SCORE_3:"Okay",CSAT5_RATING_SCORE_4:"Good",CSAT5_RATING_SCORE_5:"Great",CONVERSATION_CLOSED_FOOTER_LABEL:"Your conversation has ended",START_NEW_CONVERSATION:"💬 Start a new conversation",RETURN_TO_CONVERSATION:"💬 Return to conversation",CONVERSATION_LIST__TOPICS_FALLBACK:"No category",FORM_UNAVAILABLE:"Form is no longer available.",FORM_NOT_SUPPORTED:"This form is not supported in the current version.",FORM_VALIDATION_MIN_LENGTH:e=>`Minimum ${e} characters required`,FORM_VALIDATION_MAX_LENGTH:e=>`Maximum ${e} characters allowed`,FORM_VALIDATION_MIN:e=>`Minimum value is ${e}`,FORM_VALIDATION_MAX:e=>`Maximum value is ${e}`,FORM_VALIDATION_MIN_SELECT:e=>`Select at least ${e} options`,FORM_VALIDATION_MAX_SELECT:e=>`Select at most ${e} options`,FORM_VALIDATION_REGEX_FAILED:"Invalid format",FEEDBACK_TITLE:"Submit feedback",FEEDBACK_GOOD:"Good",FEEDBACK_BAD:"Bad",FEEDBACK_COMMENT_LABEL:"Comment (optional)",FEEDBACK_COMMENT_PLACEHOLDER:"Leave a comment",FEEDBACK_CANCEL:"Cancel",FEEDBACK_SUBMIT:"Submit",FEEDBACK_SAVE:"Save",FEEDBACK_EDIT:"Edit feedback",FEEDBACK_REMOVE:"Remove feedback",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE:hn.DATE_FORMAT__DATE_SHORT,DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION:"h:mma"},Xe={language:It.language,dateLocale:It.dateLocale,stringSet:Zs},Xs=Object.freeze(Object.defineProperty({__proto__:null,default:Xe},Symbol.toStringTag,{value:"Module"})),$t=new Map([[ot,Xe]]);async function Js(e){const t=$t.get(e);if(t)return t;try{if(Ks.has(e)){const{default:n}=await Ys(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./DcYDdCqg.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>Xs),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./Dkqya79F.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./D0f7_4hh.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./B1gSGciq.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./T-Efq4pf.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./BDH-LU3h.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./dhwTCJfW.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./Dlu2l-v0.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./C3AB5XZJ.cjs"))}),`./languages/${e}.ts`,3);return $t.set(e,n),n}return Xe}catch{return Xe}}const{Provider:Qs,useContext:F}=Q("Localization"),ea=({language:e=navigator.language,logger:t,stringSet:n,children:o})=>{const[s,a]=d.useState($t.get(ot));return d.useEffect(()=>{const i=js(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",{from:s.language,to:i}),Js(i).then(a))},[e,t]),r.createElement(Qs,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,c)=>he.format(i,l,{locale:s.dateLocale,...c})}},o)},Je="data-sb-agent-theme",fn=e=>(t,...n)=>{let o="";return t.forEach((s,a)=>{o+=s+(n[a]??"")}),`[${Je}='${e}'] & { ${o} }`},L={light:fn("light"),dark:fn("dark")},ta=T.css(({theme:e})=>{const{palette:t}=e;return`
|
|
2
|
-
:root,
|
|
3
|
-
:host {
|
|
4
|
-
--sendbird-primary-extra-dark: ${t.primary.extraDark};
|
|
5
|
-
--sendbird-primary-dark: ${t.primary.dark};
|
|
6
|
-
--sendbird-primary-main: ${t.primary.main};
|
|
7
|
-
--sendbird-primary-light: ${t.primary.light};
|
|
8
|
-
--sendbird-primary-extra-light: ${t.primary.extraLight};
|
|
9
|
-
|
|
10
|
-
--sendbird-secondary-extra-dark: ${t.secondary.extraDark};
|
|
11
|
-
--sendbird-secondary-dark: ${t.secondary.dark};
|
|
12
|
-
--sendbird-secondary-main: ${t.secondary.main};
|
|
13
|
-
--sendbird-secondary-light: ${t.secondary.light};
|
|
14
|
-
--sendbird-secondary-extra-light: ${t.secondary.extraLight};
|
|
15
|
-
|
|
16
|
-
--sendbird-information-extra-dark: ${t.information.extraDark};
|
|
17
|
-
--sendbird-information-dark: ${t.information.dark};
|
|
18
|
-
--sendbird-information-main: ${t.information.main};
|
|
19
|
-
--sendbird-information-light: ${t.information.light};
|
|
20
|
-
--sendbird-information-extra-light: ${t.information.extraLight};
|
|
21
|
-
|
|
22
|
-
--sendbird-error-extra-dark: ${t.error.extraDark};
|
|
23
|
-
--sendbird-error-dark: ${t.error.dark};
|
|
24
|
-
--sendbird-error-main: ${t.error.main};
|
|
25
|
-
--sendbird-error-light: ${t.error.light};
|
|
26
|
-
--sendbird-error-extra-light: ${t.error.extraLight};
|
|
27
|
-
|
|
28
|
-
--sendbird-background-700: ${t.background700};
|
|
29
|
-
--sendbird-background-600: ${t.background600};
|
|
30
|
-
--sendbird-background-500: ${t.background500};
|
|
31
|
-
--sendbird-background-400: ${t.background400};
|
|
32
|
-
--sendbird-background-300: ${t.background300};
|
|
33
|
-
--sendbird-background-200: ${t.background200};
|
|
34
|
-
--sendbird-background-100: ${t.background100};
|
|
35
|
-
--sendbird-background-50: ${t.background50};
|
|
36
|
-
|
|
37
|
-
--sendbird-onlight-text-high-emphasis: ${t.onlight.textHighEmphasis};
|
|
38
|
-
--sendbird-onlight-text-mid-emphasis: ${t.onlight.textMidEmphasis};
|
|
39
|
-
--sendbird-onlight-text-low-emphasis: ${t.onlight.textLowEmphasis};
|
|
40
|
-
--sendbird-onlight-text-disabled: ${t.onlight.textDisabled};
|
|
41
|
-
|
|
42
|
-
--sendbird-ondark-text-high-emphasis: ${t.ondark.textHighEmphasis};
|
|
43
|
-
--sendbird-ondark-text-mid-emphasis: ${t.ondark.textMidEmphasis};
|
|
44
|
-
--sendbird-ondark-text-low-emphasis: ${t.ondark.textLowEmphasis};
|
|
45
|
-
--sendbird-ondark-text-disabled: ${t.ondark.textDisabled};
|
|
46
|
-
|
|
47
|
-
--sendbird-overlay-dark: ${t.overlay.dark};
|
|
48
|
-
--sendbird-overlay-light: ${t.overlay.light};
|
|
49
|
-
}
|
|
50
|
-
`}),na=T.css`[${Je}='light'] &{--sb-text-high-emphasis:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled:var(--sendbird-onlight-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-ondark-text-disabled);--sb-bg-50-600:var(--sendbird-background-50);--sb-bg-100-500:var(--sendbird-background-100);--sb-bg-200-400:var(--sendbird-background-200);--sb-primary:var(--sendbird-primary-main);--sb-secondary:var(--sendbird-secondary-main);--sb-error:var(--sendbird-error-main);--sb-information:var(--sendbird-information-light);}[${Je}='dark'] &{--sb-text-high-emphasis:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled:var(--sendbird-ondark-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-onlight-text-disabled);--sb-bg-50-600:var(--sendbird-background-600);--sb-bg-100-500:var(--sendbird-background-500);--sb-bg-200-400:var(--sendbird-background-400);--sb-primary:var(--sendbird-primary-light);--sb-secondary:var(--sendbird-secondary-light);--sb-error:var(--sendbird-error-light);--sb-information:var(--sendbird-information-light);}`,u={color:{primary:{dark:"var(--sendbird-primary-dark)",main:"var(--sendbird-primary-main)"},information:{main:"var(--sendbird-information-main)",light:"var(--sendbird-information-light)"},background700:"var(--sendbird-background-700)",background600:"var(--sendbird-background-600)",background500:"var(--sendbird-background-500)",background400:"var(--sendbird-background-400)",background200:"var(--sendbird-background-200)",background100:"var(--sendbird-background-100)",background50:"var(--sendbird-background-50)",onlight:{textLowEmphasis:"var(--sendbird-onlight-text-low-emphasis)"},ondark:{textMidEmphasis:"var(--sendbird-ondark-text-mid-emphasis)",textLowEmphasis:"var(--sendbird-ondark-text-low-emphasis)",textDisabled:"var(--sendbird-ondark-text-disabled)"},overlay:{dark:"var(--sendbird-overlay-dark)"}},themedColor:{textHighEmphasis:"var(--sb-text-high-emphasis)",textMidEmphasis:"var(--sb-text-mid-emphasis)",textLowEmphasis:"var(--sb-text-low-emphasis)",textDisabled:"var(--sb-text-disabled)",textHighEmphasisInverse:"var(--sb-text-high-emphasis-inverse)",textLowEmphasisInverse:"var(--sb-text-low-emphasis-inverse)",bg_50_600:"var(--sb-bg-50-600)",bg_100_500:"var(--sb-bg-100-500)",bg_200_400:"var(--sb-bg-200-400)",primary:"var(--sb-primary)",error:"var(--sb-error)",secondary:"var(--sb-secondary)"}},{Provider:ra,useContext:tr}=Q("MessengerTheme");function oa(e){const{theme:t,appearance:n,logger:o}=e;return r.createElement(Yo,{appearance:n,palette:t==null?void 0:t.palette,typography:t==null?void 0:t.typography,logger:o},r.createElement(sa,{...e}))}function sa({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:o}=Ht();return d.useLayoutEffect(()=>{e.setAttribute(Je,n.selectedTheme)},[e,n.selectedTheme]),r.createElement(T.ThemeProvider,{theme:n},r.createElement(ra,{value:{theme:n,updateTheme:o,rootElement:e}},t))}function ye(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const aa=(e,t)=>{d.useEffect(()=>{const n=ye(t)instanceof ShadowRoot,o=ye(t,!0);if(!(n?t:o).querySelector(`link[href*='${e}']`)){const a=o.createElement("link");a.rel="stylesheet",a.href=e,(n?t:o.head).appendChild(a)}},[e,t])},ia=(e,t=document.body)=>{d.useEffect(()=>{const n=ye(t),s=n instanceof ShadowRoot?t:n.head;if(!s)return;const a=`sba-${btoa(e).slice(0,10)}`;let i=s.querySelector(`style#${a}`);i?i.textContent!==e&&(i.textContent=e):(i=s.ownerDocument.createElement("style"),i.id=a,i.textContent=e,s.appendChild(i))},[e,t])},Gt=/iPad|iPhone|iPod/.test(navigator.userAgent),la=/Android/.test(navigator.userAgent),Oe=e=>Gt||la,{Provider:ca,Consumer:nr,useContext:j}=Q("Messenger");function da({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:o=!0,enableAutoDisconnectInLauncher:s=!0,...a}){const[i,l]=d.useState(!1),[c,m]=d.useState(!1),f={opened:(t==null?void 0:t.opened)??i,setOpened:(t==null?void 0:t.setOpened)??l,expanded:(t==null?void 0:t.expanded)??c,setExpanded:(t==null?void 0:t.setExpanded)??m};return r.createElement(Lo,{...a},p=>r.createElement(ca,{value:{...a,...p,state:f,enableCloseConversationButton:n,enableExpandButton:o,enableAutoDisconnectInLauncher:s}},e))}const{Provider:ua,useContext:ee}=Q("MessengerSession"),ma=d.forwardRef(function({children:e,...t},n){return r.createElement(cs,{ref:n,...t},o=>r.createElement(ga,{...o},e))}),ga=({children:e,...t})=>{const{chatSDK:n,logger:o,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:c}=j(),{userSessionInfo:m,authenticate:f,setActiveChannel:p,userSession:x,aiAgentInfo:y,launcherInfo:v}=t,E=d.useRef(null);return Me.useGroupChannelHandler(n,{async onUserJoined(b,h){var S,O,w;if(b.conversation&&b.conversation.type===G.ConversationType.PROACTIVE&&h.userId===((S=n.currentUser)==null?void 0:S.userId)){o.info("messengerSession.onUserJoined: proactive channel joined",b.url);const k=((O=b.conversation)==null?void 0:O.status)??G.ConversationStatus.OPEN;p({url:b.url,status:k}),l.setOpened(!0),ha({sound:document.hidden||!l.opened}),(w=E.current)==null||w.call(E,{channel:b})}}}),d.useEffect(()=>{f().then(({launcher:b})=>{b.auto_open&&!Oe()&&setTimeout(()=>l.setOpened(!0),500)}).catch(b=>{var h;o.error("messengerSession: failed to initialize",b),(h=c==null?void 0:c.onInitializeFailed)==null||h.call(c,b)})},[n,s,a,m==null?void 0:m.userId,m==null?void 0:m.authToken]),!x||!y||!v?null:r.createElement(ua,{value:{...t,userSession:x,aiAgentInfo:{...y,...i==null?void 0:i.bot},launcherInfo:{...v,...i==null?void 0:i.launcher},registerOnJoinedProactiveConversation:b=>E.current=b}},e)};function ha({sound:e}){const t="🔔You have received a new message",n=document.title,o=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(o),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const ie=e=>{const t=e;return typeof t=="number"?`${t}px`:t},A=({as:e,variant:t="body1",color:n,maxTextLines:o,className:s,...a})=>r.createElement(ba,{as:e,$variant:t,className:s,$color:n,$maxTextLines:o,...a}),pn=new WeakMap,fa=(e,t)=>{let n=pn.get(t);n||(n=new Map,pn.set(t,n));const o=n.get(e);if(o)return o;const s=t[e]??t.body1,a=T.css`font-size:${ie(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
|
|
51
|
-
${s.lineHeight?`line-height: ${s.lineHeight};`:"line-height: 100%;"}
|
|
52
|
-
`;return n.set(e,a),a},pa=e=>e?T.css`display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:${e};overflow:hidden;`:"",ba=g.default.span`font-stretch:normal;letter-spacing:normal;${({$variant:e,theme:t})=>fa(e,t.typography)}color:${({$color:e})=>e};${({$maxTextLines:e})=>pa(e)}`;class Qe extends d.PureComponent{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{fallback:t=null,errorFallback:n=t,loadingFallback:o=t,children:s}=this.props;return this.state.hasError?n:r.createElement(d.Suspense,{fallback:o},s)}}const Ea=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",...e},r.createElement("path",{className:"fill",d:"M52.552 11.448a2.666 2.666 0 0 1 .222 3.52l-.222.251-16.781 16.78 16.781 16.782a2.665 2.665 0 0 1 0 3.771 2.666 2.666 0 0 1-3.52.222l-.251-.222L32 35.771 15.219 52.552a2.665 2.665 0 0 1-3.771 0 2.666 2.666 0 0 1-.222-3.52l.222-.251L28.228 32l-16.78-16.781a2.665 2.665 0 0 1 0-3.771 2.666 2.666 0 0 1 3.52-.222l.251.222 16.78 16.78 16.782-16.78a2.665 2.665 0 0 1 3.771 0z",fill:"#000",fillRule:"evenodd"})),xa=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",...e},r.createElement("path",{className:"fill",d:"M7.33348 7.3335L2.00015 7.3335L2.00015 6.00016H5.05735L1.3335 2.27631L2.27631 1.3335L6.00015 5.05734V2.00016L7.33348 2.00016L7.33348 7.3335ZM8.66683 8.66683H14.0002V10.0002L10.943 10.0002L14.6668 13.724L13.724 14.6668L10.0002 10.943V14.0002H8.66683L8.66683 8.66683Z",fill:"#000",fillRule:"evenodd"})),va=e=>r.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{className:"fill",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H7.33333V3.33333L4.27613 3.33333L7.99999 7.05719L7.05718 8L3.33333 4.27616L3.33333 7.33333H2V2ZM14 14H8.66667V12.6667H11.7239L8.00001 8.94281L8.94282 8L12.6667 11.7238V8.66667H14V14Z",fill:"#000"})),ya=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",fill:"evenodd",...e},r.createElement("path",{className:"fill",fill:"#0D0D0D",d:"M50.667 18.667H13.333v-5.334h37.334zM50.667 34.667H13.333v-5.334h37.334zM13.333 50.667h37.334v-5.334H13.333z"})),Ca=e=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",...e},r.createElement("path",{fill:"#000",fillRule:"evenodd",d:"M59.795 29.43 7.329 2.979C4.691 1.802 1.76 4.153 2.932 6.798l6.925 18.609a2 2 0 0 0 1.544 1.275l32.273 5.394L11.4 37.47a1.998 1.998 0 0 0-1.544 1.275L2.932 57.353c-.879 2.645 1.76 4.997 4.397 3.527l52.466-26.453c2.051-.882 2.051-3.82 0-4.996z",className:"fill"})),_a=new Set(["send","chat","message","chevron-right","good","good-filled","bad","bad-filled"]),Sa={close:Ea,send:Ca,menu:ya,expand:va,collapse:xa,spinner:d.lazy(()=>Promise.resolve().then(()=>require("./Cf3-irI8.cjs"))),chat:d.lazy(()=>Promise.resolve().then(()=>require("./BmdfYY9c.cjs"))),message:d.lazy(()=>Promise.resolve().then(()=>require("./CmWLVNPR.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./DNmdC4-j.cjs"))),info:d.lazy(()=>Promise.resolve().then(()=>require("./ohTjxqcW.cjs"))),refresh:d.lazy(()=>Promise.resolve().then(()=>require("./D00MOxhE.cjs"))),"chevron-down":d.lazy(()=>Promise.resolve().then(()=>require("./wf-LdaaN.cjs"))),"chevron-right":d.lazy(()=>Promise.resolve().then(()=>require("./B0k-GApQ.cjs"))),done:d.lazy(()=>Promise.resolve().then(()=>require("./kp5wcW4s.cjs"))),user:d.lazy(()=>Promise.resolve().then(()=>require("./CtHfgPDp.cjs"))),"file-document":d.lazy(()=>Promise.resolve().then(()=>require("./_YfLwFkX.cjs"))),download:d.lazy(()=>Promise.resolve().then(()=>require("./BN09c8-A.cjs"))),attach:d.lazy(()=>Promise.resolve().then(()=>require("./DcDTXo8_.cjs"))),delete:d.lazy(()=>Promise.resolve().then(()=>require("./CKPzhVy2.cjs"))),"close-filled":d.lazy(()=>Promise.resolve().then(()=>require("./D1kINslt.cjs"))),agent:d.lazy(()=>Promise.resolve().then(()=>require("./Ce1MzjFq.cjs"))),question:d.lazy(()=>Promise.resolve().then(()=>require("./JA0x62Fd.cjs"))),actionbook:d.lazy(()=>Promise.resolve().then(()=>require("./CXa-CGHE.cjs"))),function:d.lazy(()=>Promise.resolve().then(()=>require("./zbLY6xl_.cjs"))),"radio-on":d.lazy(()=>Promise.resolve().then(()=>require("./B9NJk4MI.cjs"))),"radio-off":d.lazy(()=>Promise.resolve().then(()=>require("./Bb0r6Nhu.cjs"))),confluence:d.lazy(()=>Promise.resolve().then(()=>require("./c6TZaE94.cjs"))),zendesk:d.lazy(()=>Promise.resolve().then(()=>require("./DqpDy_26.cjs"))),salesforce:d.lazy(()=>Promise.resolve().then(()=>require("./BsgzT_SF.cjs"))),sprinklr:d.lazy(()=>Promise.resolve().then(()=>require("./D97ZpKUC.cjs"))),website:d.lazy(()=>Promise.resolve().then(()=>require("./ygZY2D-5.cjs"))),snippet:d.lazy(()=>Promise.resolve().then(()=>require("./BCFOnu0u.cjs"))),template:d.lazy(()=>Promise.resolve().then(()=>require("./eJXfXI1_.cjs"))),source:d.lazy(()=>Promise.resolve().then(()=>require("./yVmX6iux.cjs"))),bot:d.lazy(()=>Promise.resolve().then(()=>require("./PhHbzZB_.cjs"))),"bot-filled":d.lazy(()=>Promise.resolve().then(()=>require("./DlvMdI1f.cjs"))),copy:d.lazy(()=>Promise.resolve().then(()=>require("./COgkkyBM.cjs"))),show:d.lazy(()=>Promise.resolve().then(()=>require("./DM-WWpci.cjs"))),mute:d.lazy(()=>Promise.resolve().then(()=>require("./P_ra76fq.cjs"))),good:d.lazy(()=>Promise.resolve().then(()=>require("./DEgUVAck.cjs"))),bad:d.lazy(()=>Promise.resolve().then(()=>require("./C0s7eAf7.cjs"))),"good-filled":d.lazy(()=>Promise.resolve().then(()=>require("./Chg8xHXT.cjs"))),"bad-filled":d.lazy(()=>Promise.resolve().then(()=>require("./CGkmTaBn.cjs")))},M=({type:e,size:t=24,className:n,color:o})=>{const s=Sa[e];return r.createElement(wa,{className:n,$rtlFlip:_a.has(e),$size:t,$color:o??u.color.primary.main},r.createElement(Qe,{errorFallback:r.createElement(Aa,null)},r.createElement(s,null)))},Ta=T.css`[dir='rtl'] &{transform:scaleX(-1);}`,wa=g.default.div`width:${({$size:e})=>ie(e)};height:${({$size:e})=>ie(e)};display:inline-block;&:focus{outline:none;}svg{display:block;}[class*='fill']{fill:${({$color:e})=>e};}[class*='stroke']{stroke:${({$color:e})=>e};stroke-width:2px;stroke-linejoin:round;}${({$rtlFlip:e})=>e&&Ta};`,Aa=()=>r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64"},r.createElement("rect",{x:"8",y:"8",width:"48",height:"48",fill:"none",className:"stroke",rx:"4"}),r.createElement("line",{x1:"20",y1:"20",x2:"44",y2:"44",className:"stroke"}),r.createElement("line",{x1:"44",y1:"20",x2:"20",y2:"44",className:"stroke"}));function Wt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:o,onClick:s}){const{colors:a}=T.useTheme();return r.createElement(ka,{onClick:s,$clickable:!!s},r.createElement($a,{$bgColor:o??a.base.primary},r.createElement(M,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),r.createElement(Ma,null,r.createElement(Oa,{variant:"button",color:u.themedColor.textHighEmphasis},e),r.createElement(A,{color:u.themedColor.textMidEmphasis,variant:"caption3"},t)))}const ka=g.default.div`border-radius:12px;gap:8px;width:${R.BODY_MAX_WIDTH}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${u.themedColor.textDisabled};background-color:${u.themedColor.bg_50_600};${({$clickable:e})=>e&&Ia}`,Ia=T.css`cursor:pointer;&:hover{background-color:${u.themedColor.bg_100_500};}`,$a=g.default.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Ma=g.default.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,Oa=g.default(A)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function La({file:e,children:t,onClickFile:n}){return r.createElement(Da,null,r.createElement(Wt,{name:e.name,type:Pt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const Da=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${R.GAP_GROUPED}px;`,oe="sb-agent",se={ENTRY:`${oe}-entry`,MODAL_ROOT:`${oe}-modal-root`,WINDOW:`${oe}-window`,LAUNCHER:`${oe}-launcher`},Ve=2147483647,Se={MODAL:Ve-1,TOOLTIP:Ve-2,WINDOW:Ve-3,LAUNCHER:Ve-4},rr={DEFAULT_PRIMARY:"#742ddd",WHITE:"#ffffff"},or=36,Ra=100,Na=25*1024*1024,sr=["application/pdf","image/jpeg","image/jpg","image/png"],st="noopener noreferrer nofollow",me=`${oe}-incoming-msg`,Pa=`${oe}-marked-text`;function Ba({file:e,onClickMedia:t,children:n}){const o=()=>e.type.startsWith("image")?r.createElement(Ua,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?r.createElement(Va,{controls:!0},r.createElement("source",{src:e.url}),r.createElement("track",{kind:"captions"})):null;if(o){const s={id:`${me}-media-body`,onClick:()=>t==null?void 0:t(e)};return r.createElement(Fa,null,r.createElement(Ha,{...s},o()),n)}return null}const Fa=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${R.GAP_GROUPED}px;`,Ha=g.default.div`width:${R.BODY_MAX_WIDTH}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${L.light`
|
|
53
|
-
background-color: ${u.color.background100};
|
|
54
|
-
`}
|
|
55
|
-
${L.dark`
|
|
56
|
-
background-color: ${u.color.background400};
|
|
57
|
-
`}
|
|
58
|
-
`,Ua=g.default.img`width:100%;height:100%;object-fit:cover;`,Va=g.default.video`width:100%;height:100%;object-fit:cover;`,za="✱",ar=e=>{const t=new RegExp(`(\`+)([^\`]+?)\\1|(${za}+)`,"g");return e.replace(t,(n,o,s,a)=>o?n:a?`<span id=${Pa} aria-label="masked-text">${a}</span>`:n)},Ga=e=>e.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"),Wa=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./BPd5Xgh2.cjs"))).MarkdownText})),qa=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./DlvEEpWX.cjs"))).CodeBlock}));function bn(e){var s,a;const t=e.maxBodyWidth??R.BODY_MAX_WIDTH,n=d.useMemo(()=>Co(e.message,ar),[e.message]),o={id:`${me}-text-body`,$maxWidth:t,$color:(s=e.customStyle)==null?void 0:s.bubbleContentColor,$bgColor:(a=e.customStyle)==null?void 0:a.bubbleBackgroundColor};return n.length===0?e.children?r.createElement(En,{...o},e.children):null:r.createElement(En,{...o},n.map((i,l)=>i.type==="text"?r.createElement(xn,{key:l,variant:"body3"},r.createElement(Qe,{fallback:i.value},r.createElement(Wa,{onClickImage:c=>{var m;return(m=e.onClickMedia)==null?void 0:m.call(e,{url:c,type:"image/*"})}},i.value))):i.type==="code"?r.createElement(Qe,{key:l,fallback:r.createElement(xn,{variant:"body3"},i.value)},r.createElement(qa,{code:i.value,language:i.language})):null),e.children)}const En=g.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>T.css`
|
|
59
|
-
color: ${t||e.colors.messageIncoming.text};
|
|
60
|
-
background-color: ${n||e.colors.messageIncoming.background};
|
|
61
|
-
`}
|
|
62
|
-
padding: 12px 0;
|
|
63
|
-
transition: max-width 0.3s;
|
|
64
|
-
overflow-wrap: break-word;
|
|
65
|
-
`,xn=g.default(A)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ja(e){const{stringSet:t}=F(),n=Vn(e)?r.createElement(bn,{...e}):null;if(e.messageType==="user")return n;if(e.messageType==="file"){const o=e.file;return o.type.startsWith("image")||o.type.startsWith("video")?r.createElement(Ba,{...e},n):r.createElement(La,{...e},n)}return r.createElement(bn,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}function qt({id:e,src:t,size:n=56,onClick:o,style:s}){return r.createElement(Ka,{id:e,tabIndex:0,onClick:o,$size:ie(n),style:s},t?r.createElement(Ya,{src:t}):r.createElement(M,{type:"user",size:n}))}const Ka=g.default.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${e=>e.$size};width:${e=>e.$size};background-color:${u.themedColor.bg_100_500};&:focus{outline:none;}`,Ya=g.default.img`object-fit:cover;width:100%;height:100%;position:absolute;`;function Za({sender:e,isBotMessage:t}){const n=`${me}-sender-avatar`;return t&&!e.profileUrl?r.createElement(Xa,{id:n},r.createElement(M,{type:"bot-filled",size:"100%"})):r.createElement(qt,{id:n,size:R.AVATAR_SIZE,src:e.profileUrl})}const Xa=g.default.div`flex-shrink:0;width:${R.AVATAR_SIZE}px;height:${R.AVATAR_SIZE}px;box-sizing:border-box;padding:4px;border-radius:50%;display:flex;justify-content:center;align-items:center;background-color:${({theme:e})=>e.colors.base.primary}!important;path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}}`;function Ja({sender:e}){return r.createElement(Qa,{id:`${me}-sender-name`,variant:"caption1",color:u.themedColor.textMidEmphasis},e.nickname)}const Qa=g.default(A)`text-align:start;width:100%;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:5px;padding-inline:0 7px;`;function ei({createdAt:e}){const{stringSet:t,format:n}=F();return e?r.createElement(A,{id:`${me}-sent-time`,variant:"caption4",color:u.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}function ti({customStyle:e}){return r.createElement(ni,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>r.createElement(ri,{key:t,$color:e==null?void 0:e.bubbleContentColor})))}const ni=g.default.div`align-items:center;border-radius:12px;display:flex;gap:6px;justify-content:center;padding:16px 12px;background-color:${({theme:e,$bgColor:t})=>t||e.colors.messageIncoming.background};`,ri=g.default.span`animation:blink 1.4s infinite;animation-fill-mode:both;border-radius:50%;height:8px;width:8px;background:${({theme:e,$color:t})=>t||e.colors.messageIncoming.text};@keyframes blink{0%{opacity:0.12;transform:scale(1);}21.43%{opacity:0.38;transform:scale(1.2);}42.86%{opacity:0.12;transform:scale(1);}100%{opacity:0.12;transform:scale(1);}}&:nth-child(1){animation-delay:0.4s;}&:nth-child(2){animation-delay:0.6s;}&:nth-child(3){animation-delay:0.8s;}`;async function jt(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function oi({extendedMessagePayload:e,onClickCTA:t=({url:n})=>jt(n)}){const n=e==null?void 0:e.cta_button;return n?r.createElement(si,{id:`${me}-ext-cta-button`,role:"button",onClick:()=>t(n)},r.createElement(ai,{variant:"button"},n.label)):null}const si=g.default.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${u.themedColor.textHighEmphasis};background-color:${u.color.background50};${L.dark`
|
|
66
|
-
background-color: ${u.color.ondark.textDisabled};
|
|
67
|
-
`}
|
|
68
|
-
`,ai=g.default(A)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function ii({extendedMessagePayload:e,onClickCitation:t=n=>jt(n.link)}){const{stringSet:n}=F(),{theme:o}=Ht(),s=e==null?void 0:e.citations;return!s||s.length===0?null:r.createElement(li,{id:`${me}-ext-citation`},r.createElement(ci,{variant:"caption1",color:o.colors.messageIncoming.text},n.CITATION_SOURCE_TITLE),r.createElement(di,null,s.map((a,i)=>r.createElement(mi,{key:`${a.embedding_id}-${i}`,role:"button",onClick:()=>t(a)},r.createElement(M,{type:"source",size:16,color:o.colors.messageIncoming.text}),r.createElement(ui,{variant:"body3",color:o.colors.messageIncoming.text},a.title)))))}const li=g.default.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`,ci=g.default(A)`opacity:0.5;`,di=g.default.div`display:flex;flex-direction:column;gap:8px;`,ui=g.default(A)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,mi=g.default.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`,at=({style:e,rootElementId:t,visible:n,onClose:o,children:s})=>{if(!n)return null;const{rootElement:a}=tr(),i=ye(a),l=ye(a,!0);return ro.createPortal(r.createElement(gi,{onClick:o,style:e},r.createElement(hi,{onClick:c=>c.stopPropagation()},s)),i.getElementById(t)??i.getElementById(se.MODAL_ROOT)??l.body)},gi=g.default.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${u.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${Se.MODAL};`,hi=g.default.div`border-radius:4px;overflow:hidden;box-shadow:0 16px 24px 2px rgba(13,13,13,0.12),0 6px 30px 5px rgba(13,13,13,0.08),0 6px 10px -5px rgba(13,13,13,0.04);z-index:${Se.MODAL};`,fi=({visible:e,onClose:t,children:n})=>r.createElement(at,{rootElementId:se.WINDOW,visible:e,onClose:t},r.createElement(Ei,null,n)),pi=({onClick:e,destructive:t,children:n})=>r.createElement(bi,{onClick:e,$destructive:t},n),ke=Object.assign(fi,{ActionItem:pi}),bi=g.default.button`all:unset;width:100%;padding:14px 24px;text-align:start;cursor:pointer;color:${({$destructive:e})=>e?u.themedColor.error:u.themedColor.textHighEmphasis};`,Ei=g.default.div`position:absolute;left:0;right:0;bottom:0;border-radius:12px 12px 0 0;flex-direction:column;align-items:flex-end;margin:0 auto;box-sizing:border-box;background-color:${({theme:e})=>e.colors.base.modalContentBackground};`,Mt=e=>`${e}-filled`,xi=e=>e==="good"?G.AIAgentMessageFeedbackRating.GOOD:G.AIAgentMessageFeedbackRating.BAD,ir=T.css`&:hover{opacity:0.8;}&:active{opacity:0.6;}`,vn={good:u.themedColor.secondary,bad:u.themedColor.error},vi=({visible:e,onClose:t,isEdit:n,initialRating:o,initialComment:s="",onSubmit:a,isCommentEnabled:i=!1})=>{const{stringSet:l}=F(),[c,m]=d.useState(o),[f,p]=d.useState(s);d.useLayoutEffect(()=>{e?(m(o),p(s)):(m(void 0),p(""))},[e,o,s]);const x=()=>{c&&(a({rating:c,comment:f.trim()||void 0}),t())},y=()=>{t()};return e?r.createElement(at,{rootElementId:se.WINDOW,visible:e,onClose:y},r.createElement(yi,null,r.createElement(Ci,null,r.createElement(A,{variant:"h2",color:u.themedColor.textHighEmphasis},l.FEEDBACK_TITLE)),r.createElement(_i,null,r.createElement(Si,null,["good","bad"].map(v=>{const E=c===v,b=v==="good"?l.FEEDBACK_GOOD:l.FEEDBACK_BAD;return r.createElement(Ti,{key:v,$selected:E,$rating:v,onClick:()=>m(v)},r.createElement(M,{type:E?Mt(v):v,size:24,color:E?vn[v]:u.themedColor.textLowEmphasis}),r.createElement(A,{variant:"caption1",color:E?vn[v]:u.themedColor.textLowEmphasis},b))})),i&&r.createElement(wi,null,r.createElement(A,{variant:"caption3",color:u.themedColor.textHighEmphasis},l.FEEDBACK_COMMENT_LABEL),r.createElement(Ai,{placeholder:l.FEEDBACK_COMMENT_PLACEHOLDER,value:f,onChange:v=>p(v.target.value),maxLength:100}))),r.createElement(ki,null,r.createElement(Ii,{onClick:y},r.createElement(A,{variant:"button",color:u.themedColor.textHighEmphasis},l.FEEDBACK_CANCEL)),r.createElement($i,{onClick:x,disabled:!c},r.createElement(A,{variant:"button"},n?l.FEEDBACK_SAVE:l.FEEDBACK_SUBMIT))))):null},yi=g.default.div`width:280px;background-color:${({theme:e})=>e.colors.base.modalContentBackground};border-radius:12px;overflow:hidden;`,Ci=g.default.div`padding:24px;`,_i=g.default.div`padding-inline:24px;display:flex;flex-direction:column;gap:24px;`,Si=g.default.div`display:flex;gap:4px;`,Ti=g.default.button`width:114px;height:64px;border-radius:12px;border:1px solid ${u.themedColor.textDisabled};box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0;gap:0;transition:background-color 0.2s;background-color:${({$selected:e})=>e?u.color.background100:"transparent"};${({$selected:e})=>L.dark`
|
|
69
|
-
background-color: ${e?u.color.background600:"transparent"};
|
|
70
|
-
`}
|
|
71
|
-
|
|
72
|
-
&:hover {
|
|
73
|
-
opacity: 0.8;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&:active {
|
|
77
|
-
opacity: 0.6;
|
|
78
|
-
}
|
|
79
|
-
`,wi=g.default.div`display:flex;flex-direction:column;gap:6px;`,Ai=g.default.textarea`font-family:inherit;font-size:12px;line-height:16px;border:1px solid ${u.themedColor.textDisabled};border-radius:4px;padding:6px 12px;color:${u.themedColor.textHighEmphasis};background-color:${u.themedColor.textLowEmphasisInverse};resize:none;field-sizing:content;min-height:28px;max-height:118px;overflow-y:auto;&::placeholder{color:${u.themedColor.textLowEmphasis};}&:focus{outline:none;}`,ki=g.default.div`padding-inline:24px;padding-block:16px;display:flex;justify-content:flex-end;gap:4px;`,lr=g.default.button`width:86px;height:40px;border-radius:20px;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:opacity 0.2s;`,Ii=g.default(lr)`${ir}`,$i=g.default(lr)`cursor:${({disabled:e})=>e?"not-allowed":"pointer"};opacity:${({disabled:e})=>e?.4:1};&:hover:not(:disabled){opacity:0.8;}&:active:not(:disabled){opacity:0.6;}background-color:${({theme:e})=>e.colors.base.primary};span{color:${({theme:e})=>e.colors.base.primaryContrastContent};}`,yn={good:u.themedColor.secondary,bad:u.themedColor.error};function Mi({isBotMessage:e,isConversationClosed:t,isStreaming:n,isFeedbackEnabled:o,isFeedbackCommentEnabled:s,extendedMessagePayload:a,onFeedbackUpdate:i}){const{stringSet:l}=F(),[c,m]=d.useState(!1),[f,p]=d.useState(!1),[x,y]=d.useState(void 0),[v,E]=d.useState(""),b=a==null?void 0:a.feedback,h=(b==null?void 0:b.rating)??"none";if(h!=="none"?!1:!!(n||!e||!o||(a==null?void 0:a.bot_message_type)!=="generated"||t))return null;const S=I=>{h==="none"?(y(I),E(""),m(!0)):p(!0)},O=()=>{i==null||i(null),p(!1)},w=()=>{p(!1),y(b==null?void 0:b.rating),E((b==null?void 0:b.comment)??""),m(!0)},k=I=>{i==null||i(I)};return t&&h!=="none"?r.createElement(Cn,{$horizontal:!0},r.createElement(Oi,null,r.createElement(M,{type:Mt(h),size:12,color:yn[h]})),(b==null?void 0:b.comment)&&r.createElement(_n,{variant:"caption2",style:{lineHeight:"16px"}},b.comment)):r.createElement(r.Fragment,null,r.createElement(Cn,null,r.createElement(Li,null,["good","bad"].map(I=>{const N=h===I;return r.createElement(Di,{key:I,$selected:N,$rating:I,onClick:()=>S(I)},r.createElement(M,{type:N?Mt(I):I,size:14,color:N?yn[I]:u.themedColor.textMidEmphasis}))})),h!=="none"&&(b==null?void 0:b.comment)&&r.createElement(_n,{variant:"caption2"},b.comment)),r.createElement(ke,{visible:f,onClose:()=>p(!1)},r.createElement(ke.ActionItem,{onClick:w},l.FEEDBACK_EDIT),r.createElement(ke.ActionItem,{onClick:O,destructive:!0},l.FEEDBACK_REMOVE)),r.createElement(vi,{visible:c,onClose:()=>m(!1),isEdit:h!=="none",initialRating:x,initialComment:v,onSubmit:k,isCommentEnabled:s}))}const Cn=g.default.div`display:flex;flex-direction:${({$horizontal:e})=>e?"row":"column"};align-items:${({$horizontal:e})=>e?"flex-start":"stretch"};gap:4px;margin-top:8px;word-break:break-word;max-width:${R.BODY_MAX_WIDTH}px;`,Oi=g.default.div`padding:2px;flex-shrink:0;display:flex;align-items:center;`,Li=g.default.div`display:flex;gap:2px;`,Di=g.default.button`width:38px;height:20px;border-radius:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;transition:opacity 0.2s;border:1px solid ${u.color.background200};background-color:${({$selected:e})=>e?u.color.background100:"transparent"};${({$selected:e})=>L.dark`
|
|
80
|
-
border: 1px solid ${u.color.background400};
|
|
81
|
-
background-color: ${e?u.color.background500:"transparent"};
|
|
82
|
-
`}
|
|
83
|
-
|
|
84
|
-
${ir}
|
|
85
|
-
`,_n=g.default(A)`color:${u.themedColor.textMidEmphasis};${L.dark`
|
|
86
|
-
color: ${u.themedColor.textHighEmphasis};
|
|
87
|
-
`}
|
|
88
|
-
`,cr=({visible:e,title:t,description:n,confirmText:o="OK",onConfirm:s,onClose:a})=>{const i=()=>{s==null||s(),a()};return r.createElement(at,{rootElementId:se.WINDOW,visible:e,onClose:a},r.createElement(Ri,null,r.createElement(Ni,null,t&&r.createElement(A,{variant:"h1",color:u.themedColor.textHighEmphasis},t),n&&r.createElement(Pi,null,r.createElement(A,{variant:"subtitle2",color:u.themedColor.textHighEmphasis},n))),r.createElement(Bi,null,r.createElement(Fi,{onClick:i},r.createElement(A,{variant:"button",color:u.themedColor.primary},o)))))},Ri=g.default.div`width:100%;height:auto;padding-block:24px 12px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({theme:e})=>e.colors.base.modalContentBackground};`,Ni=g.default.div`margin-bottom:16px;`,Pi=g.default.div`margin-top:8px;`,Bi=g.default.div`display:flex;flex-direction:row;justify-content:flex-end;`,Fi=g.default.button`all:unset;display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:transparent;padding:10px 16px;`,Kt=T.css`width:100%;height:36px;border-radius:6px;cursor:pointer;transition:all 0.2s ease;padding:0 12px;border:none;outline:none;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,Sn=g.default.button`${Kt};background-color:${u.themedColor.primary};color:${u.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.9;}`,Hi=g.default.button`${Kt};color:${u.themedColor.primary};${L.light`
|
|
89
|
-
background-color: ${u.color.background50};
|
|
90
|
-
`};
|
|
91
|
-
${L.dark`
|
|
92
|
-
background-color: ${u.color.background700};
|
|
93
|
-
`};
|
|
94
|
-
|
|
95
|
-
&:hover:not(:disabled) {
|
|
96
|
-
opacity: 0.9;
|
|
97
|
-
}
|
|
98
|
-
`,Ui=g.default.button`${Kt};background-color:transparent;color:${u.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`,Vi=e=>{switch(e){case"primary":return Sn;case"secondary":return Hi;case"clear":return Ui;default:return Sn}},zi=g.default.div`animation:1s infinite linear;animation-name:rotate;display:flex;align-items:center;justify-content:center;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`,Gi=({children:e,onClick:t,variant:n="primary",disabled:o=!1,loading:s=!1,className:a})=>{const i=()=>{switch(n){case"primary":return u.themedColor.textHighEmphasisInverse;case"secondary":return u.themedColor.primary;case"clear":return u.themedColor.textHighEmphasis;default:return u.themedColor.textHighEmphasisInverse}},l=Vi(n);return r.createElement(l,{onClick:t,disabled:o||s,className:a},s?r.createElement(zi,null,r.createElement(M,{type:"spinner",size:22,color:i()})):r.createElement(A,{variant:"button",color:i()},e))},Wi=({children:e,className:t,style:n})=>r.createElement(A,{variant:"caption4",color:u.themedColor.error,className:t,style:n},e),qi=({children:e,className:t,style:n,required:o})=>{const{stringSet:s}=F();return r.createElement(A,{variant:"caption3",color:u.themedColor.textMidEmphasis,className:t,style:n},e,!o&&r.createElement("span",{style:{color:u.themedColor.textLowEmphasis}},` (${s.OPTIONAL})`))},ji=({value:e,onChange:t,placeholder:n,error:o=!1,submitted:s=!1,className:a,disabled:i=!1,max:l})=>{const c=f=>{const x=f.target.value.replace(/[^0-9.-]/g,""),y=x.split("."),E=y.length>1?y[0]+"."+y.slice(1).join("").replace(/\./g,""):x;if(f.target.value=E,E===""||E==="-")t==null||t(null);else{const b=Number(E);if(!isNaN(b)){if(l!==void 0&&b>l)return;t==null||t(b)}}},m=e==null?"":String(e);return r.createElement(Ji,{type:"text",value:m,onChange:c,placeholder:n,className:a,disabled:i||s,inputMode:"decimal",$error:o,$submitted:s})},Ki=T.css`width:100%;height:36px;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${u.themedColor.textLowEmphasis};}&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}`,Yi=T.css`color:${u.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${L.light`
|
|
99
|
-
background-color: ${u.color.ondark.textMidEmphasis};
|
|
100
|
-
`}
|
|
101
|
-
${L.dark`
|
|
102
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
103
|
-
`}
|
|
104
|
-
|
|
105
|
-
&::placeholder {
|
|
106
|
-
color: ${u.themedColor.textLowEmphasis};
|
|
107
|
-
}
|
|
108
|
-
`,Zi=T.css`border:1px solid ${u.themedColor.error};color:${u.themedColor.textHighEmphasis};${L.light`
|
|
109
|
-
background-color: ${u.color.background50};
|
|
110
|
-
`}
|
|
111
|
-
${L.dark`
|
|
112
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
113
|
-
`}
|
|
114
|
-
`,Xi=T.css`border:1px solid ${u.themedColor.textDisabled};color:${u.themedColor.textHighEmphasis};${L.light`
|
|
115
|
-
background-color: ${u.color.background50};
|
|
116
|
-
`}
|
|
117
|
-
${L.dark`
|
|
118
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
119
|
-
`}
|
|
120
|
-
|
|
121
|
-
&:focus {
|
|
122
|
-
border-color: ${u.themedColor.primary};
|
|
123
|
-
}
|
|
124
|
-
`,Ji=g.default.input`${Ki}${({$error:e,$submitted:t})=>t?Yi:e?Zi:Xi}`,Qi=e=>{if(e.multiple){const{value:t=[],onChange:n,maxSelect:o,submitted:s=!1}=e;return{selectedValues:t,handleOptionClick:i=>{if(s)return;if(t.includes(i)){const c=t.filter(m=>m!==i);n==null||n(c)}else{if(o&&t.length>=o)return;const c=[...t,i];n==null||n(c)}}}}else{const{value:t,onChange:n,submitted:o=!1}=e;return{selectedValues:t?[t]:[],handleOptionClick:a=>{if(o)return;const i=t===a?"":a;n==null||n(i)}}}},dr=e=>{const{options:t,submitted:n=!1,error:o=!1,className:s}=e,{selectedValues:a,handleOptionClick:i}=Qi(e);return r.createElement(tl,{className:s},t.map(l=>{const c=a.includes(l.value);return r.createElement(ll,{key:l.value,$active:c,$submitted:n,$error:o,onClick:()=>i(l.value)},r.createElement(A,{variant:"caption1",color:el(c,n)},l.label))}))},el=(e,t)=>t?e?u.themedColor.textHighEmphasis:u.themedColor.textDisabled:e?u.themedColor.primary:u.themedColor.textMidEmphasis,tl=g.default.div`display:flex;flex-wrap:wrap;gap:4px 2px;`,nl=T.css`display:inline-flex;align-items:center;padding:8px 12px;border-radius:15px;transition:all 0.2s ease;`,rl=T.css`cursor:default;background-color:${u.color.ondark.textMidEmphasis};color:${u.themedColor.textHighEmphasis};${L.dark`
|
|
125
|
-
background-color: transparent;
|
|
126
|
-
border: 1px solid white;
|
|
127
|
-
color: white;
|
|
128
|
-
`}
|
|
129
|
-
`,ol=T.css`cursor:default;${L.light`
|
|
130
|
-
background-color: ${u.color.ondark.textMidEmphasis};
|
|
131
|
-
color: ${u.themedColor.textDisabled};
|
|
132
|
-
`}
|
|
133
|
-
${L.dark`
|
|
134
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
135
|
-
border: 1px solid ${u.color.onlight.textLowEmphasis};
|
|
136
|
-
color: ${u.themedColor.textDisabled};
|
|
137
|
-
`}
|
|
138
|
-
`,sl=T.css`cursor:pointer;border:1px solid ${u.themedColor.primary};${L.light`
|
|
139
|
-
background-color: ${u.color.background50};
|
|
140
|
-
color: ${u.themedColor.primary};
|
|
141
|
-
`}
|
|
142
|
-
${L.dark`
|
|
143
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
144
|
-
color: ${u.themedColor.primary};
|
|
145
|
-
`}
|
|
146
|
-
`,al=T.css`cursor:pointer;border:1px solid ${u.themedColor.textDisabled};${L.light`
|
|
147
|
-
background-color: ${u.color.background50};
|
|
148
|
-
color: ${u.themedColor.textMidEmphasis};
|
|
149
|
-
`}
|
|
150
|
-
${L.dark`
|
|
151
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
152
|
-
color: ${u.themedColor.textMidEmphasis};
|
|
153
|
-
`}
|
|
154
|
-
`,il=T.css`border-color:${u.themedColor.error}!important;`,ll=g.default.div`${nl}${({$active:e,$submitted:t,$error:n})=>{if(t)return e?rl:ol;const o=e?sl:al;return n?T.css`
|
|
155
|
-
${o} ${il}
|
|
156
|
-
`:o}}
|
|
157
|
-
`,cl=e=>r.createElement(dr,{...e,multiple:!1}),dl=e=>r.createElement(dr,{...e,multiple:!0}),ul=g.default.div`width:100%;height:1px;background-color:${u.themedColor.textDisabled};`,ml=({className:e})=>r.createElement(ul,{className:e}),gl=({value:e="",onChange:t,placeholder:n,variant:o="single-line",error:s=!1,submitted:a=!1,className:i,disabled:l=!1,maxLength:c})=>{const f={value:e,onChange:p=>{const x=p.target.value;c&&x.length>c||t==null||t(x)},placeholder:n,className:i,disabled:l||a,maxLength:c,$error:s,$submitted:a};return o==="multi-line"?r.createElement(fl,{...f}):r.createElement(hl,{...f})},ur=T.css`width:100%;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${u.themedColor.textLowEmphasis};}`,mr=T.css`color:${u.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${L.light`
|
|
158
|
-
background-color: ${u.color.ondark.textMidEmphasis};
|
|
159
|
-
`}
|
|
160
|
-
${L.dark`
|
|
161
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
162
|
-
`}
|
|
163
|
-
|
|
164
|
-
&::placeholder {
|
|
165
|
-
color: ${u.themedColor.textLowEmphasis};
|
|
166
|
-
}
|
|
167
|
-
`,gr=T.css`border:1px solid ${u.themedColor.error};color:${u.themedColor.textHighEmphasis};${L.light`
|
|
168
|
-
background-color: ${u.color.background50};
|
|
169
|
-
`}
|
|
170
|
-
${L.dark`
|
|
171
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
172
|
-
`}
|
|
173
|
-
`,hr=T.css`border:1px solid ${u.themedColor.textDisabled};color:${u.themedColor.textHighEmphasis};${L.light`
|
|
174
|
-
background-color: ${u.color.background50};
|
|
175
|
-
`}
|
|
176
|
-
${L.dark`
|
|
177
|
-
background-color: ${u.color.onlight.textLowEmphasis};
|
|
178
|
-
`}
|
|
179
|
-
|
|
180
|
-
&:focus {
|
|
181
|
-
border-color: ${u.themedColor.primary};
|
|
182
|
-
}
|
|
183
|
-
`,hl=g.default.input`${ur};height:36px;${({$error:e,$submitted:t})=>t?mr:e?gr:hr}`,fl=g.default.textarea`${ur};height:96px;resize:none;font-family:inherit;${({$error:e,$submitted:t})=>t?mr:e?gr:hr}`,pl=({children:e,className:t,style:n})=>r.createElement(A,{variant:"button",color:u.themedColor.textHighEmphasis,className:t,style:n},e),Z={Title:pl,Label:qi,ErrorLabel:Wi,Separator:ml,Button:Gi,TextInput:gl,NumberInput:ji,SingleSelect:cl,MultiSelect:dl},bl=1,El=new Set(["text","number","single-select","multi-select"]),xl=e=>{var b;const t=(b=e.extendedMessagePayload)==null?void 0:b.form;if(!t)throw new Error("Form is not provided");const{stringSet:n}=F(),[o,s]=d.useState({submitting:!1,canceling:!1}),[a,i]=d.useState({visible:!1}),{state:l,fields:c,submit:m,cancel:f,updateFieldValue:p}=Gs(t,{labels:{required:n.FORM_VALIDATION_REQUIRED,regex:n.FORM_VALIDATION_REGEX_FAILED,minLength:n.FORM_VALIDATION_MIN_LENGTH,maxLength:n.FORM_VALIDATION_MAX_LENGTH,min:n.FORM_VALIDATION_MIN,max:n.FORM_VALIDATION_MAX,minSelect:n.FORM_VALIDATION_MIN_SELECT,maxSelect:n.FORM_VALIDATION_MAX_SELECT},onSubmit:h=>{var C;return(C=e.onSubmitForm)==null?void 0:C.call(e,{key:t.key,data:h})},onCancel:()=>{var h;return(h=e.onCancelForm)==null?void 0:h.call(e,{key:t.key})}}),x=l==="submitted",y=async()=>{s(h=>({...h,submitting:!0}));try{await m()}catch(h){i({visible:!0,description:h instanceof Error?h.message:n.TRY_AGAIN})}finally{s(h=>({...h,submitting:!1}))}},v=async()=>{s(h=>({...h,canceling:!0}));try{await f()}catch(h){i({visible:!0,description:h instanceof Error?h.message:n.TRY_AGAIN})}finally{s(h=>({...h,canceling:!1}))}},E=d.useMemo(()=>{const h=()=>t.version>bl,C=()=>t.fields.some(S=>!El.has(S.type));return h()||C()?{visible:!1,cancelable:!0,reason:n.FORM_NOT_SUPPORTED}:l==="draft"&&(e.isHandedOff||e.isConversationClosed)?{visible:!1,cancelable:!1,reason:n.FORM_UNAVAILABLE}:{visible:!0,cancelable:!0,reason:""}},[t.version,t.fields,l,e.isHandedOff,e.isConversationClosed]);return l==="canceled"?null:E.visible?r.createElement(d.Fragment,null,r.createElement(Tn,{$maxWidth:e.maxBodyWidth??R.BODY_MAX_WIDTH},r.createElement(Z.Title,null,t.title),r.createElement(vl,null,c.map(h=>r.createElement(yl,{key:h.key},r.createElement(Z.Label,{style:{marginBottom:"6px"},required:h.required},h.label),h.type==="text"&&r.createElement(Z.TextInput,{value:h.value||"",placeholder:h.placeholder,onChange:C=>p(h.key,C),disabled:x,error:!!h.error,submitted:x,variant:h.layout==="multiline"?"multi-line":"single-line",maxLength:h.maxLength}),h.type==="number"&&r.createElement(Z.NumberInput,{value:h.value||null,placeholder:h.placeholder,onChange:C=>p(h.key,C),disabled:x,error:!!h.error,submitted:x,max:h.max}),h.type==="single-select"&&r.createElement(Z.SingleSelect,{options:h.options.map(C=>({label:C,value:C})),value:h.value||"",onChange:C=>p(h.key,C),submitted:x}),h.type==="multi-select"&&r.createElement(Z.MultiSelect,{options:h.options.map(C=>({label:C,value:C})),value:h.value||[],onChange:C=>p(h.key,C),submitted:x,maxSelect:h.maxSelect}),h.error&&r.createElement(Z.ErrorLabel,{style:{marginTop:"4px"}},h.error)))),r.createElement(Z.Separator,null),r.createElement(Cl,null,r.createElement(Z.Button,{variant:x?"clear":"primary",onClick:y,disabled:x||o.canceling,loading:o.submitting},x?n.SUBMITTED:n.BUTTON__SUBMIT),l!=="submitted"&&r.createElement(Z.Button,{variant:"secondary",onClick:v,disabled:o.submitting,loading:o.canceling},n.BUTTON__CANCEL))),r.createElement(cr,{...a,onClose:()=>i({visible:!1,title:""})})):r.createElement(Tn,{$maxWidth:e.maxBodyWidth??R.BODY_MAX_WIDTH},r.createElement(A,{variant:"body3"},E.reason),E.cancelable&&r.createElement(Z.Button,{variant:"primary",onClick:v,loading:o.canceling},n.BUTTON__CANCEL))},Tn=g.default.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e})=>T.css`
|
|
184
|
-
color: ${e.colors.messageIncoming.text};
|
|
185
|
-
background-color: ${e.colors.messageIncoming.background};
|
|
186
|
-
`}
|
|
187
|
-
padding: 16px 12px;
|
|
188
|
-
transition: max-width 0.3s;
|
|
189
|
-
overflow-wrap: break-word;
|
|
190
|
-
`,vl=g.default.div`display:flex;flex-direction:column;gap:12px;`,yl=g.default.div`display:flex;flex-direction:column;`,Cl=g.default.div`display:flex;flex-direction:column;gap:8px;`;function _l(e){return r.createElement(r.Fragment,null)}const Sl=new Set(["default"]),{MessageTemplate:Tl}=oo.createMessageTemplate({parser:yt.parser,renderer:yt.renderer,Container:e=>r.createElement("div",{...e})});function wl(e){return r.createElement(Qe,{errorFallback:e.messageTemplateErrorFallback,loadingFallback:e.messageTemplateLoadingFallback},r.createElement(Al,{...e}))}const Al=({extendedMessagePayload:e,onGetCachedMessageTemplate:t=()=>null,onRequestMessageTemplate:n,onHandleTemplateInternalAction:o=pe})=>{const s=e==null?void 0:e.message_template;if(!Sl.has((s==null?void 0:s.type)??"default"))throw new Error("Unsupported template type");if(!n)throw new Error("onRequestMessageTemplate is required");const{theme:i}=tr(),l=Ds({onRequestTemplate:n,onGetCachedTemplate:t,theme:i.selectedTheme,templateKey:(s==null?void 0:s.key)??"invalid",variables:s==null?void 0:s.variables,viewVariables:s==null?void 0:s.view_variables,aiAgentColorVariables:i.aiAgentColorVariables});return r.createElement(kl,{id:`${me}-ext-message-template`},r.createElement(yt.MessageProvider,{handleInternalAction:(c,m)=>{c.stopPropagation(),o==null||o(m)}},r.createElement(Tl,{templateItems:l.body.items,templateVersion:l.version})))},kl=g.default.div`box-sizing:border-box;overflow:hidden;width:100%;`;function Il({extendedMessagePayload:e,onClickSuggestedReply:t,suggestedRepliesDirection:n="vertical"}){const[o,s]=d.useState(!1),a=(e==null?void 0:e.suggested_replies)??[];return a.length===0||o?null:r.createElement($l,{id:`${me}-ext-suggested-replies`,$type:n},a.map((i,l)=>r.createElement(Ml,{key:l,$type:n,variant:"body3",onClick:()=>{t&&(t==null||t({reply:i}),s(!0))}},i)))}const $l=g.default.div`margin:16px 0;padding:0 ${R.HORIZONTAL_PADDING}px;position:relative;display:flex;align-self:stretch;gap:8px;${({$type:e})=>e==="vertical"?Ol:Ll};`,Ml=g.default(A)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:20px / clamp(20px,5%,100px);cursor:pointer;word-break:break-word;color:${u.color.primary.main};border:1px solid ${u.color.primary.main};background-color:${u.themedColor.bg_50_600};&:hover{background-color:${u.themedColor.bg_100_500};}${({$type:e,theme:t})=>T.css`
|
|
191
|
-
${e==="vertical"?Dl:Rl};
|
|
192
|
-
&:active {
|
|
193
|
-
background-color: ${t.colors.base.primary};
|
|
194
|
-
color: ${t.colors.base.primaryContrastContent};
|
|
195
|
-
}
|
|
196
|
-
`}
|
|
197
|
-
`,Ol=T.css`flex-direction:column;align-items:flex-end;`,Ll=T.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,Dl=T.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Rl=T.css`white-space:nowrap;`,Ce=_e({template:Nl,components:{SenderName:Ja,SenderAvatar:Za,SentTime:ei,MessageBody:ja,TypingIndicator:ti,SuggestedReplies:Il,MessageTemplate:wl,CTAButton:oi,Citation:ii,Form:xl,Feedback:Mi,MessageLogs:_l}});function Nl(e){return r.createElement(fr,{...e,testerMode:!1})}function fr(e){var x,y,v,E,b,h,C;const{components:t}=Ce.useContext(),n=!!e.isTyping,o=e.testerMode,s=!!((x=e.extendedMessagePayload)!=null&&x.form)&&!((y=e.extendedMessagePayload)!=null&&y.form.canceled_at),a=!!((v=e.extendedMessagePayload)!=null&&v.message_template),i=!!((E=e.extendedMessagePayload)!=null&&E.cta_button),l=!!((b=e.extendedMessagePayload)!=null&&b.citations)&&e.extendedMessagePayload.citations.length>0,c=!!e.createdAt,m=e.groupType==="top"||e.groupType==="single",f=e.groupType==="bottom"||e.groupType==="single",p=o?0:R.AVATAR_SIZE;return r.createElement(Pl,{$marginBottom:n?0:Bt(e.groupType)},m&&r.createElement(Bl,null,!o&&r.createElement(t.SenderAvatar,{...e}),r.createElement(t.SenderName,{...e})),r.createElement(Hl,null,r.createElement(Et,{$extraStartPadding:p},n?r.createElement(t.TypingIndicator,{...e}):r.createElement(t.MessageBody,{...e},i&&r.createElement("div",{style:{marginTop:12,marginInline:12}},r.createElement(t.CTAButton,{...e})),l&&r.createElement(t.Citation,{...e}))),a&&r.createElement(wn,{$startPadding:0,$endPadding:0},r.createElement(t.MessageTemplate,{...e,messageTemplateErrorFallback:e.messageTemplateErrorFallback??r.createElement(Et,{$extraStartPadding:p},r.createElement(t.MessageBody,{...e,messageType:"user",message:((C=(h=e.extendedMessagePayload)==null?void 0:h.message_template)==null?void 0:C.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:e.messageTemplateLoadingFallback??r.createElement(Et,{$extraStartPadding:p},r.createElement(t.TypingIndicator,{...e}))})),s&&r.createElement(wn,{$extraStartPadding:p},r.createElement(t.Form,{...e}))),f&&c&&r.createElement(Fl,{$extraStartPadding:p+8},r.createElement(t.SentTime,{...e})),r.createElement(d.Fragment,null,!n&&r.createElement(Ne,{$extraStartPadding:p+8},r.createElement(t.Feedback,{...e})),e.suggestedRepliesVisible&&r.createElement(t.SuggestedReplies,{...e}),r.createElement(t.MessageLogs,{...e})))}const Pl=g.default.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
198
|
-
`,Ne=g.default.div`display:flex;align-self:stretch;justify-content:flex-start;${({$startPadding:e=R.HORIZONTAL_PADDING,$endPadding:t=R.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
199
|
-
padding-inline: ${e+n}px ${t}px;
|
|
200
|
-
`}
|
|
201
|
-
`,Bl=g.default(Ne)`display:flex;flex-direction:row;align-items:center;gap:8px;`,Et=g.default(Ne)`display:flex;`,Fl=g.default(Ne)`margin-top:${R.BODY_TIME_GAP}px;display:flex;align-items:flex-start;justify-content:flex-start;`,wn=g.default(Ne)`display:flex;${({$startPadding:e=R.HORIZONTAL_PADDING,$endPadding:t=R.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
202
|
-
padding-inline: ${e+n}px ${t}px;
|
|
203
|
-
`}
|
|
204
|
-
`,Hl=g.default.div`display:flex;flex-direction:column;gap:${R.GAP_GROUPED}px;`;function Ul({file:e,children:t,onClickFile:n,sendingStatus:o}){const s=(()=>{if(!(!n||o==="failed"))return()=>n==null?void 0:n(e)})();return r.createElement(Vl,null,r.createElement(Wt,{name:e.name,type:Pt(e.name,e.type),onClick:s}),t)}const Vl=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${R.GAP_GROUPED}px;`,Yt=({className:e,children:t,size:n=26})=>r.createElement(zl,{className:e,$size:n},t??r.createElement(M,{type:"spinner",size:n})),zl=g.default.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>ie(e)};height:${({$size:e})=>ie(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;function Gl({sendingStatus:e,file:t,metadata:n,onClickMedia:o,children:s}){const{aspectRatio:a,localFile:i}=n,[l]=d.useState(()=>i instanceof Blob?URL.createObjectURL(i):t.url),[c,m]=d.useState(!1),f=(()=>{if(!(!o||e==="failed"))return()=>o==null?void 0:o({...t,url:l})})(),p={onClick:f,$ratio:a,$clickable:!!f};return r.createElement(Wl,null,r.createElement(ql,{...p},!c&&r.createElement(Yt,{size:26},r.createElement(M,{type:"spinner",color:"textLowEmphasis",size:26})),r.createElement(jl,{$loaded:c,src:l,alt:"image-message",onLoad:()=>m(!0)})),s)}const Wl=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${R.GAP_GROUPED}px;`,ql=g.default.div`width:${R.BODY_MAX_WIDTH}px;border-radius:12px;overflow:hidden;cursor:${e=>e.$clickable?"pointer":"default"};height:auto;aspect-ratio:${e=>e.$ratio};position:relative;display:flex;align-items:center;justify-content:center;${L.light`
|
|
205
|
-
background-color: ${u.color.background100};
|
|
206
|
-
`}
|
|
207
|
-
${L.dark`
|
|
208
|
-
background-color: ${u.color.background400};
|
|
209
|
-
`}
|
|
210
|
-
`,jl=g.default.img`position:absolute;width:100%;height:100%;inset-block-start:0;inset-inline-start:0;object-fit:cover;opacity:${e=>e.$loaded?1:0};transition:opacity 0.5s ease;`;function An(e){var n,o;const t=d.useMemo(()=>{const s=Ga(ar(e.message));return Bn.default.sanitize(s)},[e.message]);return r.createElement(Kl,{$maxWidth:e.maxBodyWidth??R.BODY_MAX_WIDTH,$color:(n=e.customStyle)==null?void 0:n.bubbleContentColor,$bgColor:(o=e.customStyle)==null?void 0:o.bubbleBackgroundColor},r.createElement(Yl,{variant:"body3",dangerouslySetInnerHTML:{__html:t}}))}const Kl=g.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>T.css`
|
|
211
|
-
color: ${t||e.colors.messageOutgoing.text};
|
|
212
|
-
background-color: ${n||e.colors.messageOutgoing.background};
|
|
213
|
-
`}
|
|
214
|
-
padding: 12px 0;
|
|
215
|
-
transition: max-width 0.3s;
|
|
216
|
-
overflow-wrap: break-word;
|
|
217
|
-
`,Yl=g.default(A)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function Zl(e){const{stringSet:t}=F(),n=()=>{const s=Vn(e)?r.createElement(An,{...e}):null;return e.messageType==="user"?s:e.messageType==="file"?e.file.type.startsWith("image")?r.createElement(Gl,{...e},s):r.createElement(Ul,{...e},s):r.createElement(An,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})},o=e.sendingStatus==="failed"&&e.onClickFailedMessage;return r.createElement("div",{onClick:o?e.onClickFailedMessage:void 0,style:{display:"contents",cursor:o?"pointer":"default"}},n())}function Xl({sendingStatus:e}){const t=T.useTheme();switch(e){case"pending":return r.createElement(Jl,{size:16},r.createElement(M,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return r.createElement("div",{style:{marginBottom:2}},r.createElement(M,{type:"error",color:u.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return r.createElement("div",{style:{marginBottom:2}},r.createElement(M,{type:"done",color:u.themedColor.secondary,size:16}))}}const Jl=g.default(Yt)`margin-bottom:2px;width:16px;height:16px;`;function Ql({createdAt:e}){const{stringSet:t,format:n}=F();return e?r.createElement(A,{variant:"caption4",color:u.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}const it=_e({template:ec,components:{SendingStatus:Xl,SentTime:Ql,MessageBody:Zl}});function ec(e){const{components:t}=it.useContext(),n=e.sendingStatus==="succeeded",o=e.groupType==="bottom"||e.groupType==="single";return r.createElement(tc,{$marginBottom:Bt(e.groupType)},r.createElement(nc,null,r.createElement(t.MessageBody,{...e})),o&&r.createElement(rc,{$extraEndPadding:8},n?r.createElement(t.SentTime,{...e}):r.createElement(t.SendingStatus,{...e})))}const tc=g.default.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
218
|
-
`,pr=g.default.div`display:flex;align-self:stretch;justify-content:flex-end;${({$startPadding:e=R.HORIZONTAL_PADDING,$endPadding:t=R.HORIZONTAL_PADDING,$extraEndPadding:n=0})=>`padding-inline: ${e}px ${t+n}px;`};
|
|
219
|
-
`,nc=g.default(pr)``,rc=g.default(pr)`margin-top:${R.BODY_TIME_GAP}px;`;function oc(e){return e.messageType!=="admin"?null:r.createElement(sc,null,r.createElement(A,{variant:"caption2",color:u.themedColor.textMidEmphasis},ac(Bn.default.sanitize(e.message))))}const sc=g.default.div`text-align:center;text-wrap:pretty;word-break:break-word;padding-inline:${R.HORIZONTAL_PADDING}px;a{text-decoration:none;color:inherit;}`,ac=e=>{try{const t=[];let n=e,o=0;for(;n;){const s=n.match(/\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/),a=n.match(/\*\*([^*]+)\*\*/),i=[s&&{match:s,type:"link"},a&&{match:a,type:"bold"}].filter(p=>!!p);if(!i.length){t.push(n);break}const l=i.reduce((p,x)=>x.match.index<p.match.index?x:p),{match:c,type:m}=l,f=c.index;f>0&&t.push(n.slice(0,f)),m==="link"?t.push(r.createElement("a",{key:o++,href:c[2],target:"_blank",rel:st},c[1])):m==="bold"&&t.push(r.createElement("strong",{key:o++},c[1])),n=n.slice(f+c[0].length)}return t.filter(s=>s!=="")}catch{return[e]}},br=({onClick:e,checked:t,label:n,disabled:o,labelVariant:s="caption2"})=>{const a=t?u.themedColor.primary:o?u.themedColor.textDisabled:u.themedColor.textLowEmphasis,i=t?u.themedColor.textHighEmphasis:o?u.themedColor.textLowEmphasis:u.themedColor.textHighEmphasis;return r.createElement(cc,{onClick:e,disabled:o},r.createElement(ic,null,r.createElement(M,{size:20,type:t?"radio-on":"radio-off",color:a})),r.createElement(lc,{variant:s,color:i},n))},ic=g.default.div`width:20px;height:20px;`,lc=g.default(A)`line-height:20px;word-break:break-word;`,cc=g.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,dc=({csatPayload:e,submitted:t,defaultValue:n,value:o,onChange:s})=>(d.useEffect(()=>{typeof o>"u"&&typeof n=="boolean"&&(s==null||s(n))},[o,n]),e.cre?r.createElement(uc,null,r.createElement(A,{variant:"caption3",color:u.themedColor.textMidEmphasis},e.cre.question),r.createElement(mc,null,[{label:e.cre.positive_label,value:!0},{label:e.cre.negative_label,value:!1}].map(a=>r.createElement(br,{key:a.label,checked:o===a.value,label:a.label,disabled:t,onClick:()=>s==null?void 0:s(a.value)})))):null),uc=g.default.div`display:flex;flex-direction:column;gap:8px;`,mc=g.default.div`display:flex;flex-direction:column;gap:8px;`,gc=({followUpItem:e,submitted:t,value:n="",onChange:o,hasError:s})=>{const{stringSet:a}=F();return r.createElement(hc,null,r.createElement(Z.Label,{required:e.required},e.question),e.response_type==="free_text"&&r.createElement(Z.TextInput,{variant:"multi-line",disabled:t,submitted:t,maxLength:100,value:n,onChange:i=>o(i),error:s}),e.response_type==="single_choice"&&r.createElement(fc,null,e.options.map(i=>r.createElement(br,{key:i,checked:n===i,label:i,disabled:t,onClick:()=>o==null?void 0:o(i),labelVariant:"body3"}))),s&&r.createElement(Z.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},hc=g.default.div`display:flex;flex-direction:column;gap:8px;`,fc=g.default.div`display:flex;flex-direction:column;gap:8px;`,pc=({value:e,selected:t,label:n})=>r.createElement(bc,{$selected:t,"aria-label":n},Ec[e-1]),bc=g.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Ec=[r.createElement("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{d:"M2.08337 19.9999C2.08337 10.1048 10.1049 2.08325 20 2.08325C29.8952 2.08325 37.9167 10.1048 37.9167 19.9999C37.9167 29.8951 29.8952 37.9166 20 37.9166C10.1049 37.9166 2.08337 29.8951 2.08337 19.9999Z",fill:"url(#paint0_linear_159_173206)"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5828 29.3328C13.1348 29.7473 13.9184 29.636 14.3329 29.084C15.6272 27.3607 17.6839 26.25 20 26.25C22.3164 26.25 24.373 27.3607 25.6672 29.084C26.0819 29.636 26.8654 29.7473 27.4175 29.3328C27.9695 28.9182 28.0809 28.1347 27.6662 27.5825C25.9202 25.2577 23.136 23.75 20 23.75C16.8642 23.75 14.0801 25.2577 12.334 27.5825C11.9194 28.1347 12.0308 28.9182 12.5828 29.3328Z",fill:"#141B34"}),r.createElement("path",{d:"M28.4454 13.7707C29.1329 13.8328 29.6405 14.4406 29.5785 15.1281C29.5165 15.8153 28.9095 16.3221 28.2224 16.2608C28.2224 16.2608 28.0287 16.2502 27.9272 16.2487C27.7229 16.2457 27.4387 16.2509 27.1229 16.2833C26.7869 16.3177 26.4649 16.3782 26.1804 16.4662L26.3045 16.86C26.7797 18.3675 25.5099 19.5813 24.2062 19.5813C23.5045 19.5813 22.8324 19.2617 22.43 18.6857C22.003 18.0745 21.9422 17.241 22.408 16.5344C22.751 16.0143 23.2449 15.3831 23.8964 14.8657C24.836 14.1195 26.044 13.8809 26.8675 13.7963C27.3029 13.7517 28.0154 13.7319 28.4454 13.7707Z",fill:"#141B34"}),r.createElement("path",{d:"M11.5549 13.7707C10.8674 13.8328 10.3597 14.4406 10.4218 15.1281C10.4838 15.8153 11.0908 16.3221 11.7779 16.2608C11.7779 16.2608 11.9716 16.2502 12.073 16.2487C12.2774 16.2457 12.5616 16.2509 12.8774 16.2833C13.2134 16.3177 13.5353 16.3782 13.8199 16.4662L13.6958 16.86C13.2205 18.3675 14.4904 19.5813 15.794 19.5813C16.4958 19.5813 17.168 19.2617 17.5703 18.6857C17.9971 18.0745 18.0581 17.241 17.5921 16.5344C17.2493 16.0143 16.7553 15.3831 16.1039 14.8657C15.1643 14.1195 13.9562 13.8809 13.1327 13.7963C12.6974 13.7517 11.9849 13.7319 11.5549 13.7707Z",fill:"#141B34"}),r.createElement("defs",null,r.createElement("linearGradient",{id:"paint0_linear_159_173206",x1:"20",y1:"2.08325",x2:"20",y2:"37.9166",gradientUnits:"userSpaceOnUse"},r.createElement("stop",{stopColor:"#FF2D1D"}),r.createElement("stop",{offset:"1",stopColor:"#FFA540"})))),r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},r.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),r.createElement("path",{d:"M14.249 27.334C15.851 26.13 17.844 25.417 20 25.417c2.156 0 4.149.714 5.751 1.917.553.415.664 1.199.25 1.751-.415.552-1.199.664-1.751.25-1.183-.889-2.652-1.416-4.25-1.416s-3.067.527-4.25 1.416c-.553.414-1.336.302-1.751-.25-.415-.552-.303-1.336.249-1.751Z",fill:"#141B34"}),r.createElement("path",{d:"M23.445 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.125-.394c-.285-.088-.607-.148-.942-.182-.316-.033-.6-.038-.804-.035-.101.002-.242.01-.294.013Z",fill:"#141B34"}),r.createElement("path",{d:"M11.779 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.124-.394c-.284-.088-.606-.148-.941-.182-.316-.033-.6-.038-.804-.035-.101.002-.243.01-.294.013Z",fill:"#141B34"})),r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},r.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z",fill:"#141B34"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.75 26.667c0-.691.56-1.25 1.25-1.25h10c.69 0 1.25.559 1.25 1.25 0 .691-.56 1.25-1.25 1.25h-10c-.69 0-1.25-.559-1.25-1.25Z",fill:"#141B34"})),r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},r.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.583 24.001c.552-.414 1.335-.302 1.75.25 1.294 1.723 3.35 2.834 5.667 2.834s4.373-1.11 5.667-2.834c.415-.552 1.199-.664 1.751-.25.552.415.664 1.199.25 1.751C25.92 28.076 23.136 29.584 20 29.584s-5.92-1.508-7.666-3.832c-.415-.552-.303-1.336.249-1.751Z",fill:"#141B34"}),r.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z",fill:"#141B34"})),r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},r.createElement("path",{d:"M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z",fill:"#FFD46E"}),r.createElement("g",{clipPath:"url(#clip0_159_173224)"},r.createElement("g",{clipPath:"url(#clip1_159_173224)"},r.createElement("path",{d:"M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z",fill:"#141B34"})),r.createElement("mask",{id:"mask0_159_173224",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"12",y:"22",width:"16",height:"9"},r.createElement("path",{d:"M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z",fill:"#141B34"})),r.createElement("g",{mask:"url(#mask0_159_173224)"},r.createElement("path",{d:"M20 32.998c3.278 0 5.936-1.594 5.936-3.561 0-1.968-2.658-3.562-5.936-3.562-3.278 0-5.936 1.594-5.936 3.562 0 1.967 2.658 3.561 5.936 3.561Z",fill:"#FF493B"}))),r.createElement("path",{d:"M11.667 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5M23.333 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5",stroke:"#141B34",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_159_173224"},r.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"})),r.createElement("clipPath",{id:"clip1_159_173224"},r.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"}))))],xc=({csatPayload:e,submitted:t,value:n,onChange:o})=>{const s=typeof n>"u";return r.createElement(yc,null,r.createElement(A,{variant:"caption3",color:u.themedColor.textMidEmphasis},e.csat_question),r.createElement(Cc,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const c=l+1,m=n===c;return r.createElement(_c,{key:l,disabled:t,onClick:()=>o(c)},r.createElement(vc,{value:c,selected:s||m,label:a,src:i}),!!a&&r.createElement(A,{color:m?u.themedColor.textHighEmphasis:u.themedColor.textLowEmphasis,variant:"caption3"},a))})))},vc=({value:e,src:t,label:n,selected:o})=>{const[s,a]=d.useState(!1),i=s?r.createElement(pc,{value:e,selected:o,label:n}):r.createElement(Tc,{$selected:o,"aria-label":n,src:t,onError:()=>a(!0)});return r.createElement(Sc,null,i)},yc=g.default.div`display:flex;flex-direction:column;gap:8px;`,Cc=g.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,_c=g.default.button`background-color:transparent;border:none;gap:4px;display:flex;flex-direction:column;align-items:center;justify-content:start;box-sizing:border-box;min-width:48px;max-width:68px;&:hover:not(:disabled) span{color:${u.themedColor.textHighEmphasis};}`,Sc=g.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${u.color.background200};${L.dark`
|
|
220
|
-
background-color: ${u.color.background500};
|
|
221
|
-
`}
|
|
222
|
-
}
|
|
223
|
-
`,Tc=g.default.img`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,wc=({csatPayload:e})=>r.createElement(A,{variant:"button",color:u.themedColor.textHighEmphasis},e.title),Ac=new Set(["free_text","single_choice"]),xt=({csatPayload:e,type:t,renderSubmitButton:n,initialCsat:o,initialCsatReason:s,initialIsResolved:a})=>{const[i,l]=gn({csatType:t,csat:o,csatReason:s,isResolved:a}),[c,m]=gn({followUpItem:!1}),f=d.useMemo(()=>{var b;const v=i.csat;if(typeof v!="number")return;const E=(b=e.follow_up)==null?void 0:b.find(h=>h.scores.includes(v));if(Ac.has(E==null?void 0:E.response_type))return E},[i.csat]),p=typeof o=="number"?"submitted":(t===ae.AI_AGENT_CSAT_5||t===ae.HELPDESK_CSAT_5)&&typeof i.csat=="number"||t===ae.AI_AGENT_CSAT_5_WITH_CRE&&typeof i.csat=="number"&&typeof i.isResolved=="boolean"?"submittable":"unsubmittable",x=d.useCallback(()=>typeof i.csat>"u"?!1:f!=null&&f.required&&!i.csatReason?(m({followUpItem:!0}),!1):!0,[i,f]);d.useEffect(()=>{s||(l({csatReason:""}),m({followUpItem:!1}))},[s,f]);const y={csatPayload:e,state:p,submitted:p==="submitted"};return r.createElement(r.Fragment,null,r.createElement(kc,null,r.createElement(wc,{...y}),t===ae.AI_AGENT_CSAT_5_WITH_CRE&&r.createElement(dc,{...y,defaultValue:a,value:i.isResolved,onChange:v=>l({isResolved:v})}),r.createElement(xc,{...y,value:i.csat,onChange:v=>l({csat:v})}),f&&r.createElement(gc,{...y,followUpItem:f,value:i.csatReason,onChange:v=>{l({csatReason:v}),m({followUpItem:!1})},hasError:c.followUpItem})),p!=="unsubmittable"&&r.createElement(r.Fragment,null,r.createElement(Z.Separator,null),n({state:p,params:i,validateParams:x})))},kc=g.default.div`display:flex;flex-direction:column;gap:12px;`,Ic=e=>{const{stringSet:t}=F();return fo(e,{title:t.CSAT_TITLE_UNSUBMITTED,question:t.CSAT_RATING_TITLE,cre:{question:t.CSAT_CRE_TITLE,positive_label:t.CSAT_CRE_SOLVED,negative_label:t.CSAT_CRE_NOT_SOLVED},followUp:{question:t.CSAT_REASON_PLACEHOLDER},submit_label:t.CSAT_SUBMIT_LABEL,submitted_label:t.CSAT_TITLE_SUBMITTED})},$c=()=>{const{stringSet:e}=F();return r.createElement(A,{variant:"body2",color:u.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},Mc=e=>{if(e.messageType!=="admin.csat")throw new Error("Invalid message type");const{extendedMessagePayload:t,onSubmitCSAT:n}=e,{csat:o,csatReason:s,csatExpireAt:a,isResolvedWhenDeterminedByUser:i}=e,l=Me.useForceUpdate(),c=Ic(t==null?void 0:t.csat);if(!c||!c.visibility||!ae[c.type])return null;const m=c.type===ae.AI_AGENT_CSAT_5||c.type===ae.AI_AGENT_CSAT_5_WITH_CRE||c.type===ae.HELPDESK_CSAT_5?xt:()=>null;return r.createElement(Oc,null,!o&&on(a)?r.createElement($c,null):r.createElement(m,{csatPayload:c,type:c.type,initialCsat:o,initialCsatReason:s,initialIsResolved:i,renderSubmitButton:({state:f,params:p,validateParams:x})=>r.createElement(Lc,{$state:f,disabled:f==="submitted",onClick:()=>{!on(a)&&x()?n({csatType:p.csatType,csat:p.csat,csatReason:p.csatReason,isResolved:p.isResolved,csatStartedAt:p.csatStartedAt,resolutionScore:p.resolutionScore}):l()}},r.createElement(A,{variant:"button"},f==="submitted"?c.csat_submitted_label:c.csat_submit_label))}))},Oc=g.default.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:16px;`,Lc=g.default.button`all:unset;background-color:${({theme:e})=>e.colors.base.primary};color:${({theme:e})=>e.colors.base.primaryContrastContent};border-radius:6px;padding:10px 20px;display:flex;align-items:center;justify-content:center;cursor:pointer;text-align:center;word-break:break-word;&:hover{background-color:${u.color.primary.dark};}&:disabled{color:${({$state:e})=>e==="submitted"?u.themedColor.textHighEmphasis:u.color.ondark.textLowEmphasis};background-color:${u.themedColor.textDisabled};cursor:not-allowed;}`,lt=_e({template:Dc,components:{AdminMessage:oc,CSATMessage:Mc}});function Dc(e){const{components:t}=lt.useContext(),n=e.messageType==="admin"?r.createElement(t.AdminMessage,{...e}):e.messageType==="admin.csat"?r.createElement(t.CSATMessage,{...e}):null;return r.createElement(Rc,{$marginBottom:Bt(e.groupType)},n)}const Rc=g.default.div`padding-inline:${R.HORIZONTAL_PADDING}px;margin-bottom:${({$marginBottom:e})=>e}px;`,kn={file:"attach",snippet:"snippet",site:"website",sb_sprinklr:"sprinklr",sb_salesforce:"salesforce",sb_confluence:"confluence",sb_zendesk:"zendesk",sb_desk:"snippet"},Er=({actionbook:e,functionCalls:t,groundedness:n,agentMessageTemplates:o,onClickActionbook:s,onClickFunctionCall:a,onClickFunctionCallDetail:i,onClickGroundedness:l,onClickAgentMessageTemplate:c,bottomContent:m,renderCustomGroundednessIcon:f=x=>x.default,style:p={}})=>{const{iconColor:x="#000000",textColor:y="#000000",highlightColor:v=rr.DEFAULT_PRIMARY}=p;return r.createElement(In,null,e&&r.createElement(In,null,r.createElement(et,null,r.createElement(Ge,null,r.createElement(M,{size:16,type:"actionbook",color:x})),r.createElement(ze,{$clickable:!!s,$highlightColor:v,variant:"body2",color:y,onClick:()=>s==null?void 0:s(e),maxTextLines:1},e.name))),t==null?void 0:t.map(E=>r.createElement(vt,{key:E.key},r.createElement(Ge,null,r.createElement(M,{size:16,type:"function",color:x})),r.createElement(et,null,r.createElement(ze,{$clickable:!!a,$highlightColor:v,variant:"body2",color:y,onClick:()=>a==null?void 0:a(E),maxTextLines:1},E.name),i&&r.createElement(Pc,{role:"button",onClick:()=>i==null?void 0:i(E)},r.createElement(A,{variant:"body2",color:v},"View details"),r.createElement(M,{type:"chevron-right",size:16,color:v}))))),n==null?void 0:n.map(E=>r.createElement(vt,{key:E.id},r.createElement(Ge,null,f({default:r.createElement(M,{size:16,type:kn[E.source_type]??kn.snippet,color:x}),sourceType:E.source_type})),r.createElement(ze,{$clickable:!!l,$highlightColor:v,variant:"body2",color:y,onClick:()=>l==null?void 0:l(E),maxTextLines:1},E.preview_title))),o==null?void 0:o.map(E=>r.createElement(vt,{key:E.key},r.createElement(Ge,null,r.createElement(M,{size:16,type:"template",color:x})),r.createElement(ze,{$clickable:!!c,$highlightColor:v,variant:"body2",color:y,onClick:()=>c==null?void 0:c(E),maxTextLines:1},E.name))),m)},Nc=g.default(A)`font-weight:400;`,ze=g.default(Nc)`${({$clickable:e,$highlightColor:t})=>e&&T.css`
|
|
224
|
-
cursor: pointer;
|
|
225
|
-
text-decoration: underline;
|
|
226
|
-
&:hover {
|
|
227
|
-
color: ${t};
|
|
228
|
-
}
|
|
229
|
-
`}
|
|
230
|
-
`,Ge=g.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,et=g.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,Pc=g.default(et)`cursor:pointer;gap:4px;`,vt=g.default(et)`flex-direction:row;align-items:center;`,In=g.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,xr=d.createContext(null);function Bc({testerType:e,origin:t,children:n}){return r.createElement(xr.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&r.createElement(Fc,null),n)}const Te=()=>{const e=d.useContext(xr);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},Fc=()=>{const{isActionbookTester:e}=Te();return r.createElement(Ce.Template,{template:e?Hc:void 0},r.createElement(Ce.MessageLogs,{component:Uc}))},Hc=e=>r.createElement(fr,{...e,testerMode:!0,maxBodyWidth:R.WIDE_BODY_MAX_WIDTH}),Uc=({extendedMessagePayload:e={}})=>{const{handlers:t}=j(),{manual:n,groundedness:o,function_calls:s,agent_message_templates:a,is_thinking:i}=e;return i||!n&&!(o!=null&&o.length)&&!(s!=null&&s.length)&&!(a!=null&&a.length)?r.createElement(r.Fragment,null):r.createElement(Vc,null,r.createElement(zc,{width:4}),r.createElement(Er,{actionbook:n,functionCalls:s,groundedness:o,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:u.themedColor.textHighEmphasis,textColor:u.themedColor.textHighEmphasis,barColor:u.themedColor.textDisabled},bottomContent:r.createElement(Gc,{variant:"caption2",color:u.themedColor.textLowEmphasis},"Only visible in the tester")}))},Vc=g.default.div`display:flex;gap:16px;margin:16px ${R.HORIZONTAL_PADDING}px 0;align-self:stretch;`,zc=g.default.div`width:${({width:e})=>e}px;background-color:${u.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Gc=g.default(A)`margin-top:5px;`,Wc=e=>{const{chatSDK:t,handlers:n,logger:o}=j(),{aiAgentInfo:s}=ee(),a=d.useRef(new Set),i=f=>{if(!(n!=null&&n.onCustomEvent))return;ue(f)&&f.sender.userId===s.userId&&!be.isStreaming(f)&&!a.current.has(f.messageId)&&(o.debug("useCustomEventForMessageReceive: bot-message-received",f),n.onCustomEvent({type:"bot-message-received",data:{message:f}}),a.current.add(f.messageId))},l=f=>{if(n!=null&&n.onCustomEvent&&f.isAdminMessage()&&f.customType==="user_action_required"&&!a.current.has(f.messageId)){const p=_t(f.data);Array.isArray(p.history)&&p.history.length===0&&(o.debug("useCustomEventForMessageReceive: user_action_required",p),n.onCustomEvent({type:"user-action-requested",data:p}),a.current.add(f.messageId))}},c=(f,p)=>{f.url===e&&(i(p),l(p))},m=f=>{l(f)};return Me.useGroupChannelHandler(t,{onMessageUpdated:c,onMessageReceived:c}),{checkForUserActionRequired:m}};function qc(e){return new Promise(t=>{const n=new Image;n.onload=function(){const o=String(n.width),s=String(n.height);URL.revokeObjectURL(n.src),t({width:o,height:s})},n.src=URL.createObjectURL(e)})}async function jc(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await qc(e.file);return new ve.MessageMetaArray({key:Fn,value:[t,n]})}}const Kc=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=j(),o=d.useRef(t==null?void 0:t.agentAttributes);return o.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await jc(s),i={...s,metaArrays:a?[a]:void 0},l=Yc(o.current);return l?{...i,data:JSON.stringify(l)}:i},onAfterSendMessage:s=>{var a,i,l;e(),(a=n==null?void 0:n.onMessageSend)==null||a.call(n,s.message),s.sendingStatus===ve.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===ve.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},Yc=e=>{if(!e)return null;const t={};return e.ai&&Object.keys(e.ai).length>0&&(t.ai_attrs=e.ai),e.safeguard&&Object.keys(e.safeguard).length>0&&(t.safeguard_attrs=e.safeguard),typeof e.use_prompt_cache=="boolean"&&(t.use_prompt_cache=e.use_prompt_cache),Object.keys(t).length>0?t:null},Ot=50,We=Ot-20,{Provider:Zc,useContext:Xc}=Q("ConversationScroll"),$n={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function Jc({scrollMode:e,children:t}){const n=d.useRef(null),o=d.useRef(null),s=d.useRef($n),a=d.useRef(!1),[i,l]=d.useState(0),[c,m]=d.useState(0),[f,p]=d.useState(!1),x=d.useMemo(()=>f?"auto":e,[f,e]),y=()=>{s.current.contentSnapshotHeight=s.current.contentHeight,s.current.shouldUpdate=!0,s.current.shouldRecalc=!0},v=()=>{const $=n.current;!$||!s.current.shouldUpdate||l(P=>{s.current.shouldUpdate=!1;const{contentHeight:W,contentSnapshotHeight:U,shouldRecalc:K}=s.current,te=$.clientHeight;if(U>W)return P;const le=E($,{messageType:"outgoing"});let V=0;if(le){const _=le.message.offsetTop-We+te+Ot;V=Math.max(0,_-W)}else{const _=W-U,D=te-We;V=Math.max(0,_-D)}return P===0||V!==P||K?(s.current.shouldRecalc=!1,V):P})},E=d.useCallback(($,P)=>{const{messageType:W="all"}=P??{},U=Array.from($.querySelectorAll(`#${oe}-message-item`));let K=U;W==="outgoing"&&(K=U.filter(z=>z.getAttribute("data-layout-id")==="outgoingmessage"));const te=K[K.length-1];if(!te)return null;const le=$.getBoundingClientRect(),V=te.getBoundingClientRect(),_=$.scrollTop+(V.top-le.top),D=_+te.offsetHeight;return{message:te,scrollTop:_,lastMessageBottom:D}},[]),b=d.useCallback(()=>{const $=n.current;if(!$||x!=="fixed")return;const P=s.current.contentHeight,W=E($);if(s.current.contentHeight=(W==null?void 0:W.lastMessageBottom)??$.scrollHeight,!a.current&&s.current.contentSnapshotHeight>0&&y(),s.current.contentHeight>P){const U=E($,{messageType:"outgoing"});if(U&&P>0){const K=U.message.offsetTop-We;requestAnimationFrame(()=>{n.current&&(n.current.scrollTop=K)})}}if(!a.current){const U=Math.max(0,$.scrollHeight-$.scrollTop-$.clientHeight);m(U)}v()},[x,E]),h=d.useCallback(()=>{o.current&&(o.current.disconnect(),o.current=null),s.current=$n,l(0),m(0)},[]),C=d.useCallback(($=!0)=>{const P=n.current;P&&P.scrollTo({top:P.scrollHeight,behavior:$?"smooth":"auto"})},[]),S=d.useCallback($=>{$&&(n.current=$,x==="fixed"&&(h(),s.current.viewport=$.clientHeight,o.current=new MutationObserver(()=>{b()}),o.current.observe($,{childList:!0,subtree:!0})))},[x,b,h]),O=d.useCallback(()=>{const $=n.current;if(!$)return;const P=E($,{messageType:"outgoing"});P&&$.scrollTo({top:P.message.offsetTop-We,behavior:"smooth"})},[E]),w=$=>{const{scrollHeight:P,scrollTop:W,clientHeight:U}=$.currentTarget,K=Math.max(0,P-W-U);m(K)},k=d.useCallback(()=>{x==="fixed"&&y()},[x]),I=d.useCallback(()=>{x==="fixed"?setTimeout(()=>O(),300):C()},[x,O]),N=d.useCallback($=>{a.current=$,x==="fixed"&&y()},[x]),J=d.useCallback($=>{p($)},[]);return r.createElement(Zc,{value:{ref:S,state:{isAtBottom:c<=Ot,bottomSpace:i},props:{onScroll:w},actions:{scrollToBottom:C,onBeforeMessageSend:k,onAfterMessageSend:I,onStreamingUpdate:N,onConversationClosed:J}}},t)}const{Provider:Qc,Context:ed,useContext:re}=Q("Conversation"),td=({children:e})=>{var s;const{channelSource:t}=re(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:o}=Wc(n);return d.useEffect(()=>{var i;const a=(i=t.channel)==null?void 0:i.lastMessage;a&&o(a)},[t.channel,o]),r.createElement(r.Fragment,null,e)},vr=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:o,children:s})=>{var C;const{config:a}=q(),{activeChannel:i,refreshActiveChannel:l,aiAgentInfo:c}=ee(),{testerType:m}=Te(),f=Xc(),p=((C=a==null?void 0:a.conversation)==null?void 0:C.scrollMode)??"auto",{onBeforeSendMessage:x,onAfterSendMessage:y}=Kc({onScrollAfterSendMessage:()=>{f.actions.onAfterMessageSend()}}),v=e||(i==null?void 0:i.url),E=d.useCallback(S=>(f.actions.onBeforeMessageSend(),x(S)),[f.actions,x]),b=d.useCallback(S=>{const O=S.some(w=>be.isStreaming(w));if(f.actions.onStreamingUpdate(O),p==="auto"){const w=S[S.length-1];w&&be.shouldScrollToBottom(w,c.userId,!!m)&&setTimeout(()=>f.actions.scrollToBottom(!0),100)}},[f.actions,p,c.userId,m]),h=d.useCallback(async()=>{await l(),e&&(t==null||t())},[l,e,t]);return r.createElement(Es,{channelUrl:v,onBeforeSendMessage:E,onAfterSendMessage:y,onMessagesUpdated:b,onMessagesReceived:b,onChannelDeleted:h,shouldMarkAsRead:o},S=>r.createElement(Qc,{value:{...S,scrollSource:f,goToActiveConversation:h,onNavigateToConversationList:n}},r.createElement(td,null,s)))},Zt=d.createContext({onDrop:pe,subscribe:()=>pe}),Lt=({children:e})=>{const t=d.useRef(new Set);return r.createElement(Zt.Provider,{value:{onDrop:n=>{var o;if(n.preventDefault(),(o=n.dataTransfer)!=null&&o.files){const s=Array.from(n.dataTransfer.files);s.length>0&&t.current.forEach(a=>a(s))}},subscribe:n=>(t.current.add(n),()=>t.current.delete(n))}},e)},nd=({onDropFiles:e})=>{const{subscribe:t}=d.useContext(Zt);d.useEffect(()=>t(e),[e])};Lt.Consumer=({children:e})=>{const{onDrop:t}=d.useContext(Zt);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const Xt=({iconSize:e=64,icon:t,className:n,label:o,children:s})=>r.createElement(od,{className:n},t&&r.createElement(M,{type:t,size:e,color:u.themedColor.textLowEmphasis}),o&&r.createElement(A,{variant:"body1",color:u.themedColor.textMidEmphasis},o),s),rd=g.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,od=g.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,sd=({label:e="Something went wrong",icon:t="error",action:n,...o})=>r.createElement(Xt,{icon:t,label:e,...o},n&&r.createElement(ad,{onClick:n.onClick,label:n.label??"Retry"})),ad=({label:e,onClick:t})=>r.createElement(id,{tabIndex:0,onClick:t},r.createElement(M,{type:"refresh",size:20}),r.createElement(A,{variant:"button",color:u.color.primary.main},e)),id=g.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,ld=({iconSize:e=48,className:t})=>r.createElement(Yt,{size:e,className:t}),cd=({label:e="No channels",icon:t="chat",...n})=>r.createElement(Xt,{icon:t,label:e,...n}),dd=({label:e="No messages",icon:t="message",...n})=>r.createElement(Xt,{icon:t,label:e,...n}),ud=e=>{const{components:t}=ct.useContext(),n=e.type==="loading"?r.createElement(t.Loading,{...e}):e.type==="error"?r.createElement(t.Error,{...e}):e.type==="noChannels"?r.createElement(t.NoChannels,{...e}):e.type==="noMessages"?r.createElement(t.NoMessages,{...e}):null;return n&&r.createElement(rd,null,n)},ct=_e({template:ud,components:{Loading:ld,Error:sd,NoChannels:cd,NoMessages:dd}}),$e=e=>{const{Template:t}=ct.useContext();return r.createElement(t,{...e})},Mn=e=>Hn(e)||Un(e);function md(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function gd(e,t){return e.filter(n=>be.isWelcomeMessage(n,t))}const hd=g.default.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`,fd=g.default.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${u.themedColor.textDisabled};background-color:${u.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`,pd=g.default.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`,bd=g.default.div`margin-inline-end:8px;`,Ed=g.default.div`max-width:500px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;@media screen and (max-width:768px){position:absolute;inset-inline-start:64px;top:10px;display:block;max-width:calc(100vw - 240px);}`,xd=g.default.div`display:inline-block;margin-inline-start:8px;padding-top:5px;@media screen and (max-width:768px){position:absolute;inset-inline-start:56px;top:24px;}`,vd=g.default.div`display:flex;width:160px;justify-content:flex-end;`,yd=g.default.div`inset-inline-end:0;display:flex;flex-direction:row;`,yr=g.default.div`width:64px;padding:21px;box-sizing:border-box;cursor:${e=>e.disabled?"not-allowed":"pointer"};`,Cd=g.default(yr)`border-inline-start:1px solid ${u.themedColor.textDisabled};`,_d=g.default.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`,Sd=g.default.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,Td=g.default.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`,wd=g.default.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,Ad=({file:e,sender:t={},onClose:n,onDownloadClick:o})=>{const{type:s,url:a,name:i=""}=e,{profileUrl:l,nickname:c,userId:m}=t,{aiAgentInfo:f}=ee();return r.createElement(Id,{profileUrl:l??"",nickname:c??"",type:s,url:a,name:i,onClose:n,isBotMessage:m===f.userId,onDownloadClick:o})},kd=({profileUrl:e,isBotMessage:t})=>t&&!e?r.createElement($d,{$size:32},r.createElement(M,{type:"bot-filled",size:20})):r.createElement(qt,{size:32,src:e}),Id=({profileUrl:e,isBotMessage:t,nickname:n,name:o,type:s,url:a,onClose:i,onDownloadClick:l})=>{const{stringSet:c}=F();return r.createElement(at,{onClose:i,visible:!0,rootElementId:se.MODAL_ROOT},r.createElement(hd,null,r.createElement(fd,null,r.createElement(pd,null,r.createElement(bd,null,r.createElement(kd,{profileUrl:e,isBotMessage:t})),r.createElement(Ed,null,r.createElement(A,{variant:"h2",color:u.themedColor.textHighEmphasis},o)),r.createElement(xd,null,r.createElement(A,{variant:"body1",color:u.color.ondark.textMidEmphasis},n))),r.createElement(vd,null,Mn(s)&&r.createElement(yd,null,r.createElement(yr,{as:"a",href:a,target:"_blank",rel:st,onClick:l},r.createElement(M,{type:"download",color:u.themedColor.textHighEmphasis,size:24}))),r.createElement(Cd,{onClick:i},r.createElement(M,{type:"close",color:u.themedColor.textHighEmphasis,size:24})))),r.createElement(_d,{onClick:m=>m.currentTarget===m.target&&i()},Un(s)&&r.createElement(Sd,{controls:!0},r.createElement("source",{src:a,type:s})),Hn(s)&&r.createElement(Td,{src:a,alt:o}),!Mn(s)&&r.createElement(wd,null,r.createElement(A,{variant:"h1",color:u.themedColor.textHighEmphasis},c.FILE_VIEWER__UNSUPPORT)))))},$d=g.default.div`width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;background-color:${({theme:e})=>e.colors.base.primary}!important;path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}`,Cr=({className:e,locale:t,date:n=Date.now(),formatString:o="MMMM dd, yyyy",style:s})=>r.createElement(Md,{id:`${oe}-date-separator`,style:s,className:e},r.createElement(A,{variant:"caption4",color:u.themedColor.textMidEmphasis},he.format(n,o,{locale:t}))),Md=g.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,Od=d.forwardRef(function(t,n){const{messages:o,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:c,onLoadNext:m,loadThreshold:f=.05,onScroll:p=pe,depsForResetScrollPositionToBottom:x,stackDirection:y="top",bottomSpacerHeight:v=0}=t,E=d.useRef(null),b=d.useCallback(k=>{E.current=k,n&&(typeof n=="function"?n(k):n.current=k)},[n]),h=d.useRef(!1),C=d.useRef(void 0),S=d.useRef(0),O=d.useRef(0);d.useLayoutEffect(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},x),d.useLayoutEffect(()=>{E.current&&(C.current==="top"&&(E.current.scrollTop=E.current.scrollHeight-O.current),C.current==="bottom"&&(E.current.scrollTop=S.current),C.current=void 0)},[E.current,o.length]);const w=async k=>{if(p==null||p(k),!E.current)return;const I=E.current;if(O.current=I.scrollHeight-I.scrollTop,S.current=I.scrollTop,h.current)return;const N=I.clientHeight*Math.min(Math.max(0,f),1);I.scrollTop<=N?(h.current=!0,C.current="top",await c(),h.current=!1):I.scrollHeight-I.scrollTop-I.clientHeight<=N?(h.current=!0,C.current="bottom",await m(),h.current=!1):C.current=void 0};return r.createElement(Ld,{id:"infinite-list-container"},r.createElement(Dd,{id:"infinite-list-inner",ref:b,onScroll:w},y==="bottom"&&r.createElement("div",{style:{flexGrow:1}}),a,o.map((k,I)=>s({message:k,index:I})),i,v>0&&r.createElement("div",{style:{minHeight:v}})),r.createElement(Rd,{id:"infinite-list-overlay-container"},r.createElement(Nd,{id:"infinite-list-overlay"},l)))}),Ld=g.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,Dd=g.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;scrollbar-color:${u.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,Rd=g.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,Nd=g.default.div`pointer-events:auto;`,Pd=({className:e,onClick:t})=>r.createElement(Bd,{className:e,onClick:t,tabIndex:0},r.createElement(M,{size:24,type:"chevron-down",color:u.color.primary.main})),Bd=g.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:24px;box-shadow:0 2px 8px 0 rgba(0,0,0,0.08),0 4px 6px 0 rgba(0,0,0,0.12);${L.light`
|
|
231
|
-
background-color: ${u.color.background50};
|
|
232
|
-
&:hover {
|
|
233
|
-
background-color: ${u.color.background100};
|
|
234
|
-
}
|
|
235
|
-
&:active {
|
|
236
|
-
background-color: ${u.color.background200};
|
|
237
|
-
}
|
|
238
|
-
`}
|
|
239
|
-
${L.dark`
|
|
240
|
-
background-color: ${u.color.background400};
|
|
241
|
-
&:hover {
|
|
242
|
-
background-color: ${u.color.background500};
|
|
243
|
-
}
|
|
244
|
-
&:active {
|
|
245
|
-
background-color: ${u.color.background700};
|
|
246
|
-
}
|
|
247
|
-
`}
|
|
248
|
-
|
|
249
|
-
&:focus {
|
|
250
|
-
outline: none;
|
|
251
|
-
}
|
|
252
|
-
`,Fd=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=j(),{aiAgentInfo:n}=ee(),{stringSet:o,dateLocale:s}=F(),{messageSource:a}=re(),{Template:i}=Ce.useContext(),l=e.welcomeMessages??[],c=a.messages,m=gd(c,t),f=c[m.length+1],p=m[0]??f;return{filteredMessages:c.filter(x=>md(x)?!1:l.length>0?!be.isWelcomeMessage(x,t):!0),shouldShowOriginalDate:x=>x>0||l.length===0?!0:f&&!he.isSameDay(f.createdAt,(p==null?void 0:p.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>l.length===0?null:r.createElement(r.Fragment,null,r.createElement(Cr,{style:{margin:"16px 0"},date:p==null?void 0:p.createdAt,locale:s,formatString:o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}),l.map((x,y)=>{const v=y===l.length-1,E=m.length!==c.length,b=l.length===1?"single":y===0?"top":v||E?"bottom":"middle";return r.createElement(i,{messageType:"user",message:x.message,sender:n,groupType:b,createdAt:(p==null?void 0:p.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:x.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:v&&!E,isBotMessage:!0,onClickSuggestedReply:async({reply:h})=>{a.sendUserMessage({message:h})}})}))}},Hd=e=>g.default(e).withConfig({shouldForwardProp:uo.default}),Ud=({style:e})=>{const{stringSet:t}=F(),{isActionbookTester:n}=Te();return!zt("powered-by")||n?null:r.createElement(Vd,{variant:"caption2",style:e},t.POWERED_BY+" ",r.createElement(zd,{variant:"caption2",as:"a",href:"https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby","aria-label":"Learn more about Sendbird",rel:st,target:"_blank"},"Sendbird"))},Vd=g.default(A)`color:${u.themedColor.textLowEmphasis};text-align:center;`,zd=Hd(A)`
|
|
253
|
-
color: ${u.themedColor.textLowEmphasis};
|
|
254
|
-
cursor: pointer;
|
|
255
|
-
text-decoration: none;
|
|
256
|
-
`,Gd=()=>{var i;const{stringSet:e}=F(),{channelSource:t,goToActiveConversation:n,scrollSource:o}=re(),s=fe(t.channel),a=d.useRef(s);return d.useEffect(()=>{if(!a.current&&s){const m=setTimeout(()=>{o.actions.scrollToBottom(!0)},100);return()=>clearTimeout(m)}a.current=s},[s,o.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:r.createElement(Wd,null,r.createElement(qd,{variant:"button",role:"button",color:u.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},Wd=g.default.div`display:flex;justify-content:center;margin-bottom:16px;`,qd=g.default(A)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${u.themedColor.textDisabled};cursor:pointer;user-select:none;`,jd=()=>{var le;const{Template:e}=it.useContext(),{Template:t}=Ce.useContext(),{Template:n}=lt.useContext(),[o,s]=d.useState(null),[a,i]=d.useState(null),{userSession:l,aiAgentInfo:c}=ee(),{cache:m,agentPreviewConfigs:f,chatSDK:p,state:x}=j(),{config:y}=q(),{stringSet:v,dateLocale:E}=F(),{conversation:b,channelSource:h,messageSource:C,scrollSource:S,state:{input:O}}=re(),{isActionbookTester:w}=Te(),{filteredMessages:k,shouldShowOriginalDate:I,renderAgentPreviewWelcomeMessages:N}=Fd(),J=((le=y==null?void 0:y.conversation)==null?void 0:le.scrollMode)??"auto",$=Zn(h.channel),P=(()=>{const V=$[0];if(!V)return null;const _=V.userId===c.userId;return{user:_?c:V,isBot:_}})();d.useEffect(()=>{P&&J==="auto"&&S.actions.scrollToBottom(!0)},[!!P,S.actions.scrollToBottom,J]);const W=fe(h.channel);d.useEffect(()=>{S.actions.onConversationClosed(W)},[W,S.actions.onConversationClosed]);const U=(V,_=!1)=>{var D;return _?c:((D=h.channel)==null?void 0:D.members.find(z=>z.userId===V.sender.userId))??V.sender},K=V=>{if(V.sendingStatus==="failed"&&!O.disabled)return()=>i(V)},te=()=>{var V;if(!C.initialized)return r.createElement($e,{type:"loading"});if(C.messages.length===0){const _=N();return _?r.createElement("div",{style:{width:"100%"}},_):r.createElement($e,{type:"noMessages",label:v.PLACE_HOLDER__NO_MESSAGES})}return r.createElement(Od,{ref:S.ref,onScroll:S.props.onScroll,stackDirection:f==null?void 0:f.messageStackDirection,messages:k,onLoadPrev:C.loadPrevious,onLoadNext:C.loadNext,depsForResetScrollPositionToBottom:[C.initialized,C.messages.length!==0],bottomSpacerHeight:S.state.bottomSpace,messageTopArea:r.createElement(r.Fragment,null,r.createElement(Ud,{style:{marginTop:16}}),N()),messageBottomArea:r.createElement(r.Fragment,null,P&&r.createElement("div",{id:`${oe}-message-item`},r.createElement(t,{isTyping:!0,isBotMessage:P.isBot,sender:P.user,messageType:"user",groupType:"single",message:""})),((V=y==null?void 0:y.conversation)==null?void 0:V.isTalkToAgentViewEnabled)&&r.createElement(Gd,null)),overlayArea:r.createElement(r.Fragment,null,!S.state.isAtBottom&&r.createElement(Yd,{onClick:()=>S.actions.scrollToBottom(!0)})),renderMessage:({message:_,index:D})=>{const z=vo(_),ne=k[D-1],mt=k[D+1],zr=k[k.length-1],Gr=_===zr,Wr=fe(h.channel),gt=Ie(_,c.userId),qr=!(c.isUserFeedbackEnabled&>),jr=yo(_,ne,mt,qr),Kr=!ao.isSameDay((ne==null?void 0:ne.createdAt)??0,_.createdAt)&&I(D)&&!w,Yr=Fe=>{(_.isFileMessage()||_.isUserMessage())&&s({file:Fe,sender:U(_,_.sender.userId===c.userId)})},Zr=()=>{_.isFileMessage()&&jt(_.url)},Xr=Kr?r.createElement(Cr,{style:{margin:"16px 0"},date:_.createdAt,locale:E,formatString:v.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,Be={maxBodyWidth:x.expanded?R.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:_.extendedMessagePayload,createdAt:_.createdAt,groupType:jr,onClickMedia:Yr,onClickFile:Zr},Jr=()=>{if(we.isOutgoing(_,l.userId))return"outgoingmessage";if(we.isIncoming(_,l.userId))return"incomingmessage"},Qr=(()=>{var Fe,rn;if(we.isAdmin(_))return we.isCSAT(_)?b?r.createElement(n,{...Be,...b,isResolvedWhenDeterminedByUser:go(b),messageType:"admin.csat",onSubmitCSAT:({csat:ge,...H})=>{var Y;ge&&((Y=h.channel)==null||Y.submitCSAT({csat:ge,...H}))}}):null:r.createElement(n,{...Be,messageType:"admin",message:_.message});if(we.isOutgoing(_,l.userId)){const ge={...Be,message:_.message,sender:U(_),sendingStatus:_.sendingStatus,onClickFailedMessage:K(_)};if(_.isUserMessage())return r.createElement(e,{messageType:"user",...ge});if(_.isFileMessage()){const[H,Y]=((Fe=_.metaArrays.find(ce=>ce.key===Fn))==null?void 0:Fe.value)??[];return r.createElement(e,{messageType:"file",file:_,metadata:{aspectRatio:H&&Y?`${H}/${Y}`:"1/1",localFile:(rn=_.messageParams)==null?void 0:rn.file},...ge})}}if(we.isIncoming(_,l.userId)){const ge={...Be,sender:U(_,gt),message:_.message,suggestedRepliesVisible:Gr,suggestedRepliesDirection:f==null?void 0:f.suggestedRepliesDirection,isBotMessage:gt,isStreaming:be.isStreaming(_),isHandedOff:De(h.channel),isConversationClosed:Wr,isFeedbackEnabled:c.isUserFeedbackEnabled,isFeedbackCommentEnabled:c.isUserFeedbackCommentOptionEnabled,onClickSuggestedReply:async({reply:H})=>{C.sendUserMessage({message:H})},onRequestMessageTemplate:async H=>{const{template:Y}=await p.aiAgent.getMessageTemplate(H);return m.template.set(H,Y),Y},onGetCachedMessageTemplate:H=>m.template.get(H),onHandleTemplateInternalAction:H=>{if(H.type==="internal"&&H.internalData){const{method:Y,payload:ce}=H.internalData;Y==="message.send"&&(ce!=null&&ce.message)&&C.sendUserMessage({message:ce.message})}},onFeedbackUpdate:H=>{const Y={messageId:_.messageId,channelUrl:_.channelUrl};if(!H)return p.aiAgent.deleteMessageFeedback(Y);const ce={...Y,rating:xi(H.rating),comment:H.comment};return be.hasFeedback(_)?p.aiAgent.updateMessageFeedback(ce):p.aiAgent.createMessageFeedback(ce)},onSubmitForm:({key:H,data:Y})=>p.aiAgent.submitForm({messageId:_.messageId,channelUrl:_.channelUrl,formKey:H,formData:Y}),onCancelForm:({key:H})=>p.aiAgent.cancelForm({messageId:_.messageId,channelUrl:_.channelUrl,formKey:H})};if(_.isUserMessage())return r.createElement(t,{messageType:"user",...ge});if(_.isFileMessage())return r.createElement(t,{messageType:"file",file:_,...ge})}})();return r.createElement("div",{key:z,id:`${oe}-message-item`,"data-layout-id":Jr()},Xr,Qr)}})};return r.createElement(Kd,{id:`${oe}-message-list`},te(),o&&r.createElement(Ad,{onClose:()=>s(null),sender:o.sender,file:o.file}),a&&r.createElement(ke,{visible:!0,onClose:()=>i(null)},r.createElement(ke.ActionItem,{onClick:()=>{C.resendMessage(a),i(null)}},v.FAILED_MESSAGE_RESEND),r.createElement(ke.ActionItem,{destructive:!0,onClick:()=>{C.deleteMessage(a),i(null)}},v.FAILED_MESSAGE_REMOVE)))},Kd=g.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Yd=g.default(Pd)`position:absolute;bottom:20px;inset-inline-end:20px;`,Zd=()=>{const{stringSet:e}=F(),{connectionError:t}=ee(),{channelSource:n}=re(),o=t||n.error;if(o){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return r.createElement($e,{type:"error",label:o.message,action:s})}return n.channel?r.createElement(jd,null):r.createElement($e,{type:"loading"})},Xd=()=>{var s;const{origin:e}=Te(),{appId:t,aiAgentId:n}=q(),{channelSource:o}=re();return(s=o.channel)!=null&&s.conversation?r.createElement(Jd,null,r.createElement(Dt,{style:{gap:4}},r.createElement(M,{color:u.themedColor.textLowEmphasis,size:12,type:"show"}),r.createElement(A,{as:"i",color:u.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),r.createElement(Dt,{role:"button",style:{gap:4},onClick:()=>{var c,m;const a=e??window.location.origin,i=(m=(c=o.channel)==null?void 0:c.conversation)==null?void 0:m.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},r.createElement(A,{variant:"body3",color:u.themedColor.textHighEmphasis},"Copy ",r.createElement("span",{style:{color:u.themedColor.primary}},"conversation link")),r.createElement(M,{color:u.themedColor.primary,size:14,type:"copy"}))):null},Dt=g.default.div`display:flex;justify-content:center;align-items:center;`,Jd=g.default(Dt)`flex-direction:column;padding-block:16px;background-color:${u.themedColor.bg_100_500};gap:8px;`,_r=d.createContext(void 0),Qd=({children:e})=>{const{stringSet:t}=F(),{attachmentMode:n}=ee(),{channelSource:o}=re(),[s,a]=d.useState([]),[i,l]=d.useState({visible:!1,title:""}),c=De(o.channel),m=d.useMemo(()=>{if(o.channel&&!o.channel.isAIAgent)return!0;switch(n){case Ke.OFF:return!1;case Ke.ALWAYS:return!0;case Ke.HANDED_OFF_ONLY:return c;default:return c}},[n,c,o.channel]),f=y=>{if(!m)return;const v=y.filter(E=>sr.includes(E.type));if(v.length!==0){if(v.some(E=>E.size>Na)){l({visible:!0,title:t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d","25")});return}if(v.length>1||v.length>0&&s.length>0){l({visible:!0,title:t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT});return}a(E=>[...E,...v.map(b=>({file:b,preview:{url:URL.createObjectURL(b),type:b.type,name:b.name}}))])}},p=y=>{a(v=>{var b;const E=(b=v[y])==null?void 0:b.preview;return E&&URL.revokeObjectURL(E.url),v.filter((h,C)=>C!==y)})},x=()=>{a(y=>(y.forEach(v=>URL.revokeObjectURL(v.preview.url)),[]))};return r.createElement(_r.Provider,{value:{files:s,addFiles:f,removeFile:p,clearFiles:x,isFileUploadEnabled:m}},e,r.createElement(cr,{...i,onClose:()=>l({visible:!1,title:""})}))},Jt=()=>{const e=d.useContext(_r);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function eu({blurred:e,elementRef:t,document:n=window.document}){const o=d.useRef(!1);e&&t.current&&n.activeElement===t.current&&(o.current=!0),d.useLayoutEffect(()=>{var s;!e&&o.current&&((s=t.current)==null||s.focus(),o.current=!1)},[e])}const tu=(e,t)=>{d.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},nu=g.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,ru=g.default.div`display:flex;flex-shrink:0;position:relative;margin-block-start:8px;border-radius:12px;height:64px;img{border-radius:12px;object-fit:cover;width:64px;-webkit-user-drag:none;}`,ou=g.default.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${L.light`
|
|
257
|
-
background-color: ${u.color.background50};
|
|
258
|
-
`}
|
|
259
|
-
${L.dark`
|
|
260
|
-
background-color: ${u.color.background500};
|
|
261
|
-
`}
|
|
262
|
-
path {
|
|
263
|
-
fill: ${u.themedColor.textMidEmphasis};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
&:hover {
|
|
267
|
-
path {
|
|
268
|
-
fill: ${u.themedColor.textHighEmphasis};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
circle {
|
|
273
|
-
stroke: ${u.themedColor.bg_50_600};
|
|
274
|
-
}
|
|
275
|
-
`,su=()=>{const e=Oe(),[t,n]=d.useState(),{files:o,removeFile:s,isFileUploadEnabled:a}=Jt();return!a||o.length===0?null:r.createElement(nu,null,o.map(({preview:{type:i,name:l,url:c}},m)=>r.createElement(ru,{key:c,onMouseOver:()=>n(m),onMouseLeave:()=>n(void 0)},(e||t===m)&&r.createElement(ou,{title:"Remove file",onClick:()=>s(m)},r.createElement(M,{type:"close-filled",color:u.themedColor.textMidEmphasis})),i.startsWith("image/")?r.createElement("img",{alt:"file-image",src:c}):r.createElement(Wt,{name:l,type:Pt(l,i)}))))},Sr={textArea:T.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:T.css`margin-bottom:4px;`},Tr=g.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,au=g.default(Tr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${u.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${u.themedColor.bg_200_400};}}${Gt&&Sr.attachIcon};`,iu=g.default.input`display:none;`,On=g.default.div`width:100%;position:relative;background-color:${u.themedColor.bg_100_500};border-radius:20px;`,Ln=g.default.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Dn=g.default.textarea`all:unset;display:block;flex:1;min-width:0;padding-top:8px;padding-bottom:8px;padding-inline-start:16px;padding-inline-end:12px;box-sizing:border-box;font-size:14px;line-height:20px;color:${u.themedColor.textHighEmphasis};resize:none;width:100%;height:${or}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${Gt&&Sr.textArea};&::placeholder{color:${u.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${u.themedColor.textDisabled};}}`,Rn=g.default.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,Nn=({disabled:e})=>{const t=d.useRef(null),{addFiles:n,clearFiles:o,files:s,isFileUploadEnabled:a}=Jt();return!a||s.length>0?null:r.createElement(au,{disabled:e,onClick:()=>{var i;o(),(i=t.current)==null||i.click()}},r.createElement(M,{type:"attach",color:e?u.themedColor.textDisabled:u.themedColor.textMidEmphasis,size:16}),r.createElement(iu,{type:"file",ref:t,onChange:i=>{const l=i.currentTarget.files;l&&n(Array.from(l)),i.target.value=""},accept:sr.join(",")}))},lu=()=>{const e=d.useRef(null),[t,n]=d.useState(""),{stringSet:o}=F(),{rootElement:s}=j(),{channelSource:a,messageSource:i,state:l}=re(),{files:c,addFiles:m,clearFiles:f}=Jt(),p=l.input.disabled,x=(()=>{if(!p)return o.MESSAGE_INPUT__PLACE_HOLDER;switch(l.input.disabledBy){case"form_active":return o.FORM_PLACEHOLDER;case"ai_responding":return o.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE;case"suggested_replies":return o.MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES;case"unavailable":case"conversation_closed":default:return o.MESSAGE_INPUT__PLACE_HOLDER__DISABLED}})();nd({onDropFiles:m}),eu({blurred:p,elementRef:e,document:ye(s)}),tu(a.channel,t);const y=t.trim().length>0,v=c.length>0,E=!p&&(y||v),b=()=>{e.current&&(e.current.value="",e.current.style.height=""),f(),n("")},h=async()=>{const w=t.trim(),k={message:w};if(!(!w&&!c.length)){if(c.length>0){const I=c[0].file,N={...k,file:I};i.sendFileMessage(N),b();return}i.sendUserMessage(k),b()}},C=w=>{const k=Array.from(w.clipboardData.files);k.length>0&&(w.preventDefault(),m(k))},S=w=>{w.key!=="Enter"||w.nativeEvent.isComposing||w.shiftKey||(w.preventDefault(),h())},O=w=>{if(e.current){e.current.style.height="";const k=Math.min(Ra,e.current.scrollHeight);or<k&&(e.current.style.height=`${k}px`)}n(w.target.value)};return p?r.createElement(Rn,null,r.createElement(On,null,r.createElement(Ln,null,r.createElement(Dn,{disabled:!0,placeholder:x}),r.createElement(Nn,{disabled:!0})))):r.createElement(Rn,null,r.createElement(On,null,r.createElement(su,null),r.createElement(Ln,null,r.createElement(Dn,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:x,maxLength:5e3,onKeyDown:S,onChange:O,onPaste:C}),r.createElement(Nn,null))),E&&r.createElement(Tr,{onClick:()=>h()},r.createElement(M,{type:"send",color:u.color.primary.main,size:20})))},cu=g.default.div`padding:8px 16px;text-align:center;word-break:break-word;white-space:pre-wrap;line-height:1.43;letter-spacing:-0.2px;font-size:14px;font-weight:400;color:${u.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${L.light`
|
|
276
|
-
color: ${u.color.information.light};
|
|
277
|
-
`};
|
|
278
|
-
${L.dark`
|
|
279
|
-
color: ${u.color.information.main};
|
|
280
|
-
`};
|
|
281
|
-
}
|
|
282
|
-
`,du=d.lazy(()=>Promise.resolve().then(()=>require("./BPd5Xgh2.cjs")).then(e=>({default:e.MarkdownText}))),uu=()=>{const{aiAgentInfo:e,userSession:t}=ee(),{messageSource:n,channelSource:o}=re(),[s,a]=d.useState(null),i=zt("special-notice",o.channel),l=d.useCallback(()=>o.channel?i?n.messages.some(c=>Ie(c,(t==null?void 0:t.userId)??"")):!0:null,[o.channel,i,n.messages,t==null?void 0:t.userId]);return d.useEffect(()=>{s||a(l())},[l,s]),s?null:r.createElement(cu,null,r.createElement(du,null,e.specialNotice))},mu=()=>r.createElement(gu,null,r.createElement(uu,null),r.createElement(Qd,null,r.createElement(lu,null))),gu=g.default.div`z-index:0;border:none;width:100%;`,hu=()=>{var s;const{testerType:e}=Te(),{channelSource:t}=re(),n=fe(t.channel),o=!!e&&((s=t.channel)==null?void 0:s.isAIAgent);return n&&o?r.createElement(Xd,null):r.createElement(mu,null)},wr=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:o}=ee(),{fallbackIcon:s,url:a}=Qn({channel:e,aiAgentInfo:o,userSession:n}),i=T.useTheme();return a?r.createElement(qt,{src:a,size:t}):r.createElement(fu,{$size:t,$bgColor:i.colors.base.primary},r.createElement(M,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},fu=g.default.div`width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;border-radius:50%;background-color:${({$bgColor:e})=>e};display:flex;align-items:center;justify-content:center;flex-shrink:0;`,pu=({label:e,children:t,position:n="top",disabled:o})=>o?t:r.createElement(Rt,null,t,r.createElement(xu,{$position:n},r.createElement(vu,{variant:"caption1"},e),r.createElement(bu,{$position:n}))),bu=({$position:e})=>r.createElement("svg",{style:{transform:e==="top"?"rotate(0)":"rotate(180deg)"},xmlns:"http://www.w3.org/2000/svg",width:"12",height:"6",viewBox:"0 0 12 6",fill:"none"},r.createElement("path",{d:"M6 6L0 0h12L6 6Z",fill:u.themedColor.textHighEmphasis})),Eu={top:T.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:T.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},Rt=g.default.div`position:relative;`,xu=g.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${Se.TOOLTIP};${({$position:e})=>Eu[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Rt}:hover &,${Rt}:focus-within &{opacity:1;}`,vu=g.default(A)`padding:6px 8px;background:${u.themedColor.textHighEmphasis};color:${u.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,yu=()=>{const{state:e,logger:t,enableCloseConversationButton:n,enableExpandButton:o,dispatcher:s}=j(),{stringSet:a}=F(),{channelSource:i,onNavigateToConversationList:l}=re(),{aiAgentInfo:c,userSession:m}=ee(),f=i.channel,x=Oe()?24:16,y=Qn({channel:f,userSession:m,aiAgentInfo:c}),v=()=>{e.setOpened(!1)},E=async()=>{try{const S=await(f==null?void 0:f.markConversationAsHandoff());t.info("conversation.handleAgentHandoff: success",S)}catch(S){t.error("conversation.handleAgentHandoff: error",S)}},b=async()=>{f&&await s.send(Wn.CloseConversation({channelUrl:f.url}))},h=zt("handoff-button",f),C=(f==null?void 0:f.isAIAgent)&&n;return r.createElement(wu,null,r.createElement(Au,null,l&&r.createElement(Pe,{onClick:()=>l()},r.createElement(M,{type:"menu",size:24,color:u.themedColor.textHighEmphasis})),r.createElement(wr,{channel:f,size:34}),r.createElement(Iu,{variant:"h2",color:u.themedColor.textHighEmphasis},y.title)),r.createElement(ku,null,h&&r.createElement(Tu,{tooltipLabel:a.HEADER_BUTTON__AGENT_HANDOFF,disabled:!Ct(f)||De(f),size:x,onClick:E}),C&&r.createElement(Su,{disabled:!Ct(f),size:x,onClick:b}),o&&r.createElement(Cu,{size:x}),r.createElement(_u,{size:x,onClick:v})))},Cu=({size:e,disabled:t})=>{const{state:n}=j();return r.createElement(Pe,{"aria-label":"expand",onClick:()=>n.setExpanded(!n.expanded),disabled:t},r.createElement(M,{type:n.expanded?"collapse":"expand",size:e,color:u.themedColor.textHighEmphasis}))},_u=({size:e,disabled:t,onClick:n})=>r.createElement(Pe,{"aria-label":"close messenger",onClick:n,disabled:t},r.createElement(M,{type:"close",size:e,color:u.themedColor.textHighEmphasis})),Su=({size:e,disabled:t,onClick:n})=>r.createElement(Pe,{"aria-label":"close conversation",onClick:n,disabled:t},r.createElement(M,{type:"mute",size:e,color:t?u.themedColor.textDisabled:u.themedColor.textHighEmphasis})),Tu=({size:e,onClick:t,disabled:n,tooltipLabel:o})=>r.createElement(pu,{label:o,position:"bottom",disabled:n},r.createElement(Pe,{"aria-label":"agent",onClick:t,disabled:n},r.createElement(M,{type:"agent",size:e,color:n?u.themedColor.textDisabled:u.themedColor.textHighEmphasis}))),wu=g.default.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${u.themedColor.textDisabled};background-color:${({theme:e})=>e.colors.base.headerBackground};`,Au=g.default.div`display:flex;flex:1;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,ku=g.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,Iu=g.default(A)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Pe=g.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,$u=()=>{const{isActionbookTester:e}=Te();return e?null:r.createElement(yu,null)},Ar=({children:e,onNavigateToConversationList:t,channelUrl:n,onClearChannelUrl:o,shouldMarkAsRead:s,closedChannelUrl:a,onClearClosedChannelUrl:i})=>{var f;const{config:l}=q(),c=((f=l==null?void 0:l.conversation)==null?void 0:f.scrollMode)??"auto",{Template:m}=dt.useContext();return r.createElement(Jc,{scrollMode:c},r.createElement(vr,{onNavigateToConversationList:t,channelUrl:n??a,onClearChannelUrl:o??i,shouldMarkAsRead:s},r.createElement(Lt,null,r.createElement(Lt.Consumer,null,p=>r.createElement(r.Fragment,null,r.createElement(Ou,{...p},r.createElement(m,null)),e)))))},dt=_e({template:Mu,components:{Header:$u,Body:Zd,Footer:hu}});function Mu(){const{components:e}=dt.useContext();return r.createElement(r.Fragment,null,r.createElement(e.Header,null),r.createElement(e.Body,null),r.createElement(e.Footer,null))}const Ou=g.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,{Provider:Lu,Context:Du,useContext:Qt}=Q("ConversationList");function kr({conversationListLimit:e,conversationListFilter:t,onOpenConversationView:n=pe,children:o}){return r.createElement(Ts,{conversationListLimit:e,conversationListFilter:t},s=>r.createElement(Lu,{value:{...s,onOpenConversationView:n}},o))}const Ru=({channel:e})=>r.createElement(wr,{channel:e}),en=_e({template:Nu,components:{}}),Nt=99;function Nu(e){const{channel:t,onClick:n}=e,{stringSet:o,format:s}=F(),a=po(t),i=bo(t,s,{justNow:o.DATE_FORMAT__JUST_NOW,minutesAgo:o.DATE_FORMAT__MINUTES_AGO,hoursAgo:o.DATE_FORMAT__HOURS_AGO,dateShortFormat:o.DATE_FORMAT__DATE_SHORT}),l=t.unreadMessageCount;return r.createElement(Pu,{role:"button",onClick:()=>n==null?void 0:n()},r.createElement(Bu,null,r.createElement(Ru,{...e})),r.createElement(Fu,null,r.createElement(Hu,null,r.createElement(A,{variant:"subtitle1",color:u.themedColor.textHighEmphasis,maxTextLines:1},a),r.createElement(Uu,null,fe(t)&&r.createElement(r.Fragment,null,r.createElement(A,{variant:"caption1",color:u.themedColor.textMidEmphasis,maxTextLines:1},o.CONVERSATION_LIST__ENDED),r.createElement(Vu,null)),r.createElement(A,{variant:"caption2",color:u.themedColor.textLowEmphasis,maxTextLines:1},i))),l>0&&r.createElement(zu,{$count:l},r.createElement(A,{variant:"caption3",color:u.themedColor.textHighEmphasisInverse},l<=Nt?l:`${Nt}+`))))}const Pu=g.default.div`display:flex;flex-shrink:0;flex-direction:row;align-items:center;position:relative;width:100%;height:72px;box-sizing:border-box;gap:16px;cursor:pointer;`,Bu=g.default.div`display:flex;align-items:center;justify-content:center;padding-inline-start:16px;`,Fu=g.default.div`display:flex;flex-direction:row;align-items:center;flex:1;padding-inline-end:16px;height:100%;gap:8px;border-bottom:1px solid ${u.themedColor.textDisabled};`,Hu=g.default.div`display:flex;flex-direction:column;justify-content:center;flex:1;gap:4px;word-break:break-word;overflow-wrap:break-word;`,Uu=g.default.div`display:flex;align-items:center;gap:6px;`,Vu=g.default.div`width:2px;height:2px;border-radius:1px;background-color:${u.themedColor.textLowEmphasis};`,zu=g.default.div`display:flex;align-items:center;justify-content:center;height:20px;padding:4px;border-radius:10px;background-color:${u.themedColor.error};${({$count:e})=>e<=Nt&&T.css`
|
|
283
|
-
width: 20px;
|
|
284
|
-
`}
|
|
285
|
-
`,Gu=({items:e,renderItem:t,onEndReached:n})=>{const o=s=>{const a=s.target;a.scrollHeight-a.scrollTop===a.clientHeight&&(n==null||n())};return r.createElement(Wu,{onScroll:s=>o(s)},e.map((s,a)=>t(s,a)))},Wu=g.default.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`,qu=()=>{const{stringSet:e}=F(),{listSource:t,onOpenConversationView:n}=Qt(),{Template:o}=en.useContext();return t.initialized?t.channels.length===0?r.createElement($e,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):r.createElement(Gu,{items:t.channels,renderItem:s=>{var a,i,l;return r.createElement(o,{key:s.url,channel:s,onClick:()=>n(s.url,fe(s)?"closed":"open"),channelUrl:s.url,title:(i=(a=s.conversation)==null?void 0:a.topics)==null?void 0:i.join(", "),lastMessageTimestamp:(l=s.lastMessage)==null?void 0:l.createdAt})},onEndReached:()=>{t.loadMore()}}):r.createElement($e,{type:"loading"})},ju=()=>{const{stringSet:e}=F(),{language:t,countryCode:n,context:o}=j(),{aiAgentInfo:s,refreshActiveChannel:a,createConversation:i,setActiveChannel:l}=ee(),{onOpenConversationView:c}=Qt();return r.createElement(Ku,{role:"button",onClick:async()=>{if(s.isMultipleActiveConversationsEnabled){const m=await i({aiAgentId:s.userId,language:t,country:n,context:o});l({url:m,status:G.ConversationStatus.OPEN}),c(m,G.ConversationStatus.OPEN)}else{const m=await a();c(m,G.ConversationStatus.OPEN)}}},r.createElement(Yu,{variant:"h1"},e.TALK_TO_AGENT))},Ku=g.default.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,Yu=g.default(A)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,Zu=()=>{const{state:e}=j(),{stringSet:t}=F(),o=Oe()?24:16,s=()=>{e.setOpened(!1)};return r.createElement(Ju,null,r.createElement(Qu,{variant:"h2",color:u.themedColor.textHighEmphasis},t.CONVERSATION_LIST__HEADER_TITLE),r.createElement(em,null,r.createElement(Xu,{size:o,onClick:s})),r.createElement(tm,null))},Xu=({size:e,disabled:t,onClick:n})=>r.createElement(nm,{"aria-label":"close messenger",onClick:n,disabled:t},r.createElement(M,{type:"close",size:e,color:u.themedColor.textHighEmphasis})),Ju=g.default.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${u.themedColor.textDisabled};background-color:${({theme:e})=>e.colors.base.headerBackground};`,Qu=g.default(A)`padding:0 4px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,em=g.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,tm=g.default.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${u.themedColor.textDisabled};`,nm=g.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,Ir=({conversationListLimit:e,conversationListFilter:t,children:n,onOpenConversationView:o})=>{const{Template:s}=ut.useContext();return r.createElement(kr,{conversationListLimit:e,conversationListFilter:t,onOpenConversationView:o},r.createElement(om,null,r.createElement(s,null)),n)},ut=_e({template:rm,components:{Header:Zu,Body:qu,Footer:ju}});function rm(){const{components:e}=ut.useContext();return r.createElement(r.Fragment,null,r.createElement(e.Header,null),r.createElement(e.Body,null),r.createElement(e.Footer,null))}const om=g.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,sm=T.css`:where(#${se.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,am=[sm,ta,na],im=(e,...t)=>T.createGlobalStyle(e,...am,...t),lm=im``,cm=mo(dt,Ce,it,lt,ut,en,ct);function $r({appearance:e,rootElement:t,logger:n,language:o,stringSet:s,children:a,messageTemplate:i,theme:l}){return ia(Ws,t),r.createElement(T.StyleSheetManager,{target:t},r.createElement(oa,{rootElement:t,logger:n,appearance:e,theme:l},r.createElement(ks,{internalVariables:i==null?void 0:i.__internalVariables},r.createElement(ea,{stringSet:s,logger:n,language:o},r.createElement(cm,null,a,r.createElement(lm,null))))))}const qe={},je={getItem:e=>{try{return localStorage.getItem(e)}catch{return qe[e]??null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{qe[e]=t}},deleteItem:e=>{try{localStorage.removeItem(e)}catch{delete qe[e]}},getKeys:e=>{try{const t=[];for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);o&&o.startsWith(e)&&t.push(o)}return t}catch{return Object.keys(qe).filter(t=>t.startsWith(e))}}},tn=d.forwardRef(function({rootElement:t=document.body,logLevel:n=X.LogLevel.WARN,language:o=navigator.language,userSessionInfo:s,children:a,...i},l){var c,m;return Le.level!==n&&(Le.level=n),aa("https://fonts.googleapis.com/css2?family=Roboto&display=swap",t),r.createElement("div",{id:se.ENTRY,style:{width:"fit-content",height:"fit-content",...i.entryStyle}},r.createElement($r,{logger:Le,rootElement:t,appearance:(c=i.agentPreviewConfigs)==null?void 0:c.appearance,stringSet:i.stringSet,language:o,messageTemplate:i.messageTemplate,theme:i.theme},r.createElement(da,{rootElement:t,keyValueStorage:{get:je.getItem,set:je.setItem,delete:je.deleteItem,getKeys:je.getKeys},language:o,logger:Le,dispatcher:Mr,chatParams:{...i.chatParams,customApiHost:i.customApiHost,customWebSocketHost:i.customWebSocketHost},chatSDK:i.customChatSDK,...i},r.createElement(ma,{ref:l,userSessionInfo:s,forceCreateChannel:(m=i.agentPreviewConfigs)==null?void 0:m.forceCreateChannel},r.createElement(Bc,{...i._UNSAFE_INTERNAL_dashboardTester},a,r.createElement("div",{id:se.MODAL_ROOT}))))))}),Le=new Gn(X.LogLevel.WARN),Mr=new zn(Le),Or=({children:e,isOpened:t})=>{const{dir:n,rootElement:o}=j(),s=ye(o,!0);return d.useEffect(()=>{const a="sb-agent-block-scroll";return t?s.body.classList.add(a):s.body.classList.remove(a),()=>{s.body.classList.remove(a)}},[s,t]),r.createElement(dm,{dir:n,$visible:t},e)},dm=g.default.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${Se.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`,um=48,mm=2/3;function Lr({className:e,isOpened:t,onClick:n,type:o,imageUrl:s,dir:a,animated:i=!0,backgroundColor:l,size:c=um}){const m=wt(l),f=Math.round(c*mm);return r.createElement(fm,{dir:a,id:se.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:i,$backgroundColor:l,$size:c},r.createElement(pm,{$isOpened:t,$animated:i,$fillColor:m,$iconSize:f},r.createElement(Pn.Open,{url:s,isDefaultIcon:o==="default_icon",size:f})),r.createElement(bm,{$isOpened:t,$animated:i,$fillColor:m,$iconSize:f},r.createElement(Pn.Close,{size:f})))}const gm=T.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,hm=T.css`img{width:100%;height:100%;object-fit:cover;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;&[data-default-icon='true']{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;filter:${({$fillColor:e})=>e===rr.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,Dr=T.css`svg{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;${({$fillColor:e})=>T.css`
|
|
286
|
-
path {
|
|
287
|
-
fill: ${e};
|
|
288
|
-
}
|
|
289
|
-
[class*='fill'] {
|
|
290
|
-
fill: ${e};
|
|
291
|
-
}
|
|
292
|
-
`}
|
|
293
|
-
}
|
|
294
|
-
`,fm=g.default.button`position:relative;padding:0;width:${({$size:e})=>e}px;height:${({$size:e})=>e}px;background:${({$backgroundColor:e})=>e};border-radius:50%;transition:all 0.3s cubic-bezier(0.31,-0.105,0.43,1.4);border:none;display:flex;justify-content:center;align-items:center;box-shadow:0 16px 24px 2px rgba(33,33,33,0.12),0 6px 30px 5px rgba(33,33,33,0.08),0 6px 10px -5px rgba(33,33,33,0.04);${({$animated:e})=>e&&gm}`,Rr=g.default.span`position:absolute;width:100%;height:100%;border-radius:50%;overflow:hidden;transition:transform 0.16s linear,opacity 0.08s linear,scale 0.16s linear;user-select:none;display:flex;justify-content:center;align-items:center;`,pm=g.default(Rr)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${hm}${Dr}`,bm=g.default(Rr)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${Dr}`,Pn={Open:e=>e.url?r.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):r.createElement(M,{size:e.size,type:"bot-filled"}),Close:({size:e})=>r.createElement(M,{size:e,type:"chevron-down"})};function Nr({className:e,size:t}){const{colors:n}=T.useTheme(),{dir:o,state:s}=j(),{launcherInfo:a}=ee();return xm(),r.createElement(Lr,{dir:o,className:e,isOpened:s.opened,onClick:()=>s.setOpened(!s.opened),type:a.type,imageUrl:a.imageUrl,backgroundColor:n.base.primary,size:t})}const Em=1e3*60;function xm(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:o}=j(),s=d.useRef(null);d.useEffect(()=>{if(!o)return;function a(){s.current&&(clearTimeout(s.current),s.current=null)}function i(){e.connectionState===X.ConnectionState.CLOSED&&(e.reconnect(),n.debug("useSDKInactivityTimeout: reconnected")),a(),n.debug("useSDKInactivityTimeout: clear disconnect schedule")}function l(){a(),s.current=setTimeout(async()=>{await e.disconnectWebSocket(),n.debug("useSDKInactivityTimeout: disconnected")},Em)}t.opened?i():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[o,e,t.opened])}const Pr=d.createContext(null);function Br(){const e=d.useContext(Pr);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function Fr({children:e}){const t=Br();return typeof e=="function"?e(t):r.createElement(r.Fragment,null,e)}const vm=T.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,ym=T.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,Cm=T.css`animation-name:${vm};animation-duration:0.3s;animation-fill-mode:forwards;`,_m=T.css``,Sm=T.css`animation-name:${ym};animation-duration:0.3s;animation-fill-mode:forwards;`,Tm=T.css`visibility:hidden;`,wm=g.default.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return Cm;case"entered":return _m;case"exiting":return Sm;case"exited":return Tm;default:return""}}}${({$active:e})=>e?T.css`
|
|
295
|
-
z-index: 999;
|
|
296
|
-
`:T.css`z-index:1;pointer-events:none;`}
|
|
297
|
-
`;function Ye({initialId:e,children:t}){const[n,o]=d.useState([e]),s=n[n.length-1],a=d.useCallback((b,h)=>{o(C=>[...C,b]),p(C=>({...C,[b]:!0})),h!=null&&h.reset&&E(C=>({...C,[b]:(C[b]||0)+1})),y(C=>({...C,[b]:"entering"})),setTimeout(()=>{y(C=>({...C,[b]:"entered"}))},300)},[]),i=d.useCallback(()=>{o(b=>{if(b.length<=1)return b;const h=b[b.length-1];return y(C=>({...C,[h]:"exiting"})),setTimeout(()=>{y(C=>({...C,[h]:"exited"})),o(C=>C.slice(0,-1))},300),b})},[]),l=d.useMemo(()=>({navigation:{navigate:a,pop:i},activeScreenId:s}),[a,i,s]),c=d.useMemo(()=>d.Children.toArray(t).filter(b=>b.type===Fr),[t]),m=d.useMemo(()=>{const b={};return c.forEach(h=>{const{id:C,lazy:S,children:O}=h.props;b[C]={lazy:S,element:typeof O=="function"?O(l):O}}),b},[c,l]),[f,p]=d.useState(()=>{const b={};return Object.entries(m).forEach(([h,{lazy:C}])=>{C===!1&&(b[h]=!0)}),b[e]=!0,b}),[x,y]=d.useState(()=>{const b={};return Object.keys(m).forEach(h=>{h===e?b[h]="entered":b[h]="exited"}),b}),[v,E]=d.useState({});return r.createElement(Pr.Provider,{value:l},r.createElement(Am,null,Object.keys(m).map(b=>{var O;if(!f[b])return null;const h=x[b]||"exited",C=b===s,S=`${b}-${v[b]||0}`;return r.createElement(wm,{key:S,$transitionState:h,$active:C},(O=m[b])==null?void 0:O.element)})))}const Am=g.default.div`position:relative;width:100%;height:100%;`;Ye.Screen=Fr;const de={conv:"conv",convList:"conv-list"},Hr=({entryPoint:e,selectedChannelUrl:t,setSelectedChannelUrl:n})=>{const o=(()=>{switch(e){case"Conversation":return de.conv;case"ConversationList":return de.convList;default:return de.conv}})(),s=r.createElement(r.Fragment,null,r.createElement(km,{onOpenConversationView:n}));return r.createElement(Ye,{initialId:o},r.createElement(Ye.Screen,{id:de.conv},({navigation:a,activeScreenId:i})=>r.createElement(Ar,{key:t,channelUrl:t,onClearChannelUrl:()=>n(void 0),onNavigateToConversationList:()=>a.navigate(de.convList),shouldMarkAsRead:i===de.conv},s)),r.createElement(Ye.Screen,{id:de.convList,lazy:!0},({navigation:a})=>r.createElement(Ir,{onOpenConversationView:i=>{n(i),a.navigate(de.conv)}},s)))},km=({onOpenConversationView:e})=>{const{registerOnJoinedProactiveConversation:t}=ee(),{navigation:n}=Br();return t(({channel:o})=>{e(o.url),n.navigate(de.conv)}),null};function Im({isExpanded:e,isOpened:t,children:n,launcher:o}){const{dir:s}=j();return r.createElement($m,null,r.createElement(Mm,{dir:s,id:se.WINDOW,$isExpanded:e,$isOpened:t},n),o)}const $m=g.default.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,Mm=g.default.div`background:${({theme:e})=>e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:right bottom;[dir='rtl'] &:not([dir='ltr']),&[dir='rtl']{transform-origin:left bottom;}${({$isOpened:e})=>e&&Lm};${({$isExpanded:e})=>e&&Om};`,Om=T.css`width:743px;height:723px;`,Lm=T.css`z-index:${Se.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`,Dm=d.forwardRef(function({children:e,...t},n){const o=Oe(),[s,a]=d.useState(),i=o?Or:Im;return r.createElement(tn,{enableExpandButton:!o,ref:n,...t},r.createElement(nr,null,({state:l})=>r.createElement(r.Fragment,null,r.createElement(i,{isExpanded:l.expanded,isOpened:l.opened,launcher:r.createElement(Nr,null)},r.createElement(Hr,{entryPoint:t.entryPoint,selectedChannelUrl:s,setSelectedChannelUrl:a})),e)))}),{Provider:Rm,useContext:nn}=Q("FixedMessengerStyle");function Ur(e,t,n,o=0){const{top:s,bottom:a,start:i,end:l}=n;let c="",m="";switch(e){case"start":m=`inset-inline-start: ${ie(i)}`;break;case"end":m=`inset-inline-end: ${ie(l)}`;break}switch(t){case"top":c=`top: calc(${ie(s)} + ${o}px)`;break;case"bottom":c=`bottom: calc(${ie(a)} + ${o}px)`;break}return T.css`${c};${m};`}function Nm(e){const{horizontal:t,vertical:n,margin:o,launcherSize:s}=nn();return r.createElement(Pm,{...e,size:s,$horizontal:t,$vertical:n,$margin:o})}const Pm=g.default(Nr)`position:fixed;z-index:${Se.LAUNCHER};${({$horizontal:e,$vertical:t,$margin:n})=>Ur(e,t,n)};`;function Bm({isExpanded:e,isOpened:t,children:n}){const{dir:o}=j(),{horizontal:s,vertical:a,margin:i,launcherSize:l}=nn();return r.createElement(Fm,{dir:o,id:se.WINDOW,$isExpanded:e,$isOpened:t,$horizontal:s,$vertical:a,$margin:i,$launcherSize:l},n)}const Fm=g.default.div`background:${({theme:e})=>e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;${({$horizontal:e,$vertical:t,$margin:n,$launcherSize:o})=>Ur(e,t,n,o+12)};height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:${({$horizontal:e,$vertical:t})=>`${e==="start"?"left":"right"} ${t}`};
|
|
298
|
-
[dir='rtl'] &:not([dir='ltr']),
|
|
299
|
-
&[dir='rtl'] {
|
|
300
|
-
transform-origin: ${({$horizontal:e,$vertical:t})=>`${e==="start"?"right":"left"} ${t}`};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
${({$isOpened:e})=>e&&Um};
|
|
304
|
-
${({$isExpanded:e})=>e&&Hm};
|
|
305
|
-
`,Hm=T.css`width:743px;height:723px;`,Um=T.css`z-index:${Se.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`,Vr={top:24,bottom:24,start:24,end:24},Vm=d.forwardRef(function({children:e,...t},n){const[o,s]=d.useState(),[a,i]=d.useState("end-bottom"),[l,c]=d.useState(Vr),[m,f]=d.useState(48),p=Oe(),x=p?Or:Bm,{horizontal:y,vertical:v}=d.useMemo(()=>{const[E,b]=a.split("-");return{horizontal:E==="start"?"start":"end",vertical:b==="top"?"top":"bottom"}},[a]);return r.createElement(tn,{enableExpandButton:!p,ref:n,...t},r.createElement(nr,null,({state:E})=>r.createElement(Rm,{value:{horizontal:y,vertical:v,margin:l,launcherSize:m,setPosition:i,setMargin:c,setLauncherSize:f}},r.createElement(x,{isExpanded:E.expanded,isOpened:E.opened},r.createElement(Hr,{entryPoint:t.entryPoint,selectedChannelUrl:o,setSelectedChannelUrl:s})),r.createElement(Nm,null),e)))}),zm=e=>{var s,a,i,l;const{setPosition:t,setMargin:n,setLauncherSize:o}=nn();return d.useLayoutEffect(()=>{e.position&&t(e.position),e.margin&&n({...Vr,...e.margin}),e.launcherSize&&o(e.launcherSize)},[e.position,(s=e.margin)==null?void 0:s.top,(a=e.margin)==null?void 0:a.bottom,(i=e.margin)==null?void 0:i.start,(l=e.margin)==null?void 0:l.end,e.launcherSize]),null},Gm=Object.assign(Vm,{Style:zm});exports.ANCHOR_REL=st;exports.AgentProviderContainer=tn;exports.AgentUIProviderContainer=$r;exports.AnonymousSessionInfo=At;exports.CSATType=ae;exports.Conversation=Ar;exports.ConversationContext=ed;exports.ConversationContextProvider=vr;exports.ConversationLayout=dt;exports.ConversationList=Ir;exports.ConversationListContext=Du;exports.ConversationListContextProvider=kr;exports.ConversationListItemLayout=en;exports.ConversationListLayout=ut;exports.DefaultMessenger=Dm;exports.DispatcherCommands=Wn;exports.FixedMessenger=Gm;exports.IncomingMessageLayout=Ce;exports.LauncherBase=Lr;exports.LogLevel=Ft;exports.ManualSessionInfo=Kn;exports.MessageLogs=Er;exports.OutgoingMessageLayout=it;exports.PlaceholderLayout=ct;exports.SystemMessageLayout=lt;exports.cssVars=u;exports.escapeMarkdownSyntax=wo;exports.mapCommonStringsToReactFormat=er;exports.messengerDispatcher=Mr;exports.useConversationContext=re;exports.useConversationListContext=Qt;exports.useLocalizationContext=F;exports.useMessengerContext=j;exports.useMessengerSessionContext=ee;
|