@sendbird/ai-agent-messenger-react 1.10.2 → 1.10.3
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/BBDXgVHP.cjs +1 -0
- package/dist/cjs/BKGUMAll.cjs +1 -0
- package/dist/cjs/BMWSkFPd.cjs +1 -0
- package/dist/cjs/CshEwefQ.cjs +1 -0
- package/dist/cjs/D2b9Fh2D.cjs +1 -0
- package/dist/cjs/DDZcs_TL.cjs +1 -0
- package/dist/cjs/{Cfid8u9U.cjs → DTOB4bD8.cjs} +43 -43
- package/dist/cjs/HGTRpnXG.cjs +1 -0
- package/dist/cjs/Lt9QbwOc.cjs +1 -0
- package/dist/cjs/VMkpPP3I.cjs +1 -0
- package/dist/cjs/h90fKnkA.cjs +1 -0
- package/dist/es/{CNOl7erj.js → BJEfprOj.js} +11 -8
- package/dist/es/{v1TL54QW.js → BK3NLWD7.js} +11 -8
- package/dist/es/{CtCMo2TS.js → BQ0E1drV.js} +5 -2
- package/dist/es/{Ck4nAD4B.js → BUjZwbLs.js} +10 -7
- package/dist/es/{TAdObZan.js → BjgNa6vj.js} +32 -18
- package/dist/es/{DCVV5mpw.js → DV3Z-BEQ.js} +1431 -1395
- package/dist/es/{CcTi8RMT.js → DbjtlqMh.js} +11 -8
- package/dist/es/{CAPycZHB.js → Drf_-1iy.js} +8 -5
- package/dist/es/{71nKW4JE.js → QLoGj0Il.js} +5 -2
- package/dist/es/{SWkYvgHM.js → bp8ut7x_.js} +11 -8
- package/dist/es/{CvPILy6Q.js → fnTAJEKK.js} +15 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/package.json +6 -4
- package/dist/cjs/1ACj2pIu.cjs +0 -1
- package/dist/cjs/39Vu-gp1.cjs +0 -1
- package/dist/cjs/8LgPimFK.cjs +0 -1
- package/dist/cjs/B6HiuRPt.cjs +0 -1
- package/dist/cjs/BVlVEisk.cjs +0 -1
- package/dist/cjs/CbSJ7GnB.cjs +0 -1
- package/dist/cjs/DBjNv8rR.cjs +0 -1
- package/dist/cjs/DI-EXSWj.cjs +0 -1
- package/dist/cjs/DOXieS3b.cjs +0 -1
- package/dist/cjs/sjY7fr9U.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var oo=Object.defineProperty;var so=(e,t,n)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>so(e,typeof t!="symbol"?t+"":t,n);const c=require("react"),Z=require("@sendbird/chat"),k=require("styled-components"),Ce=require("date-fns"),ao=require("date-fns/locale/en-US"),ye=require("@sendbird/chat/message"),z=require("@sendbird/chat/aiAgent"),at=require("@sendbird/chat/groupChannel"),io=require("react-dom"),Lt=require("@sendbird/react-uikit-message-template-view"),lo=require("@sendbird/uikit-message-template"),He=require("@sendbird/uikit-tools"),co=require("dompurify"),uo=require("date-fns/isSameDay"),mo=require("@emotion/is-prop-valid"),dt=e=>e&&e.__esModule?e:{default:e};function go(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 r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const o=go(c),ho=dt(Z),h=dt(k),Yn=dt(co),fo=dt(mo),X=(e,t)=>{const n=c.createContext(null),r=({children:i,value:l})=>o.createElement(n.Provider,{value:l},typeof i=="function"?i(l):i),s=({children:i})=>o.createElement(n.Consumer,null,l=>l?typeof i=="function"?i(l):i:null),a=()=>{const i=c.useContext(n);if(!i)throw new Error(`use${e}Context must be used within a ${e}Provider`);return i};return n.displayName=`${e}Context`,r.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,a.displayName=`use${e}Context`,{Context:n,Provider:r,Consumer:s,useContext:a}};function fe(e){const t=c.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=c.useState(()=>e.template),[u,d]=c.useState(e.components),f={Template:i,updateTemplate:p=>l(()=>p),components:u,updateComponent:(p,x)=>d(y=>({...y,[p]:x}))};return o.createElement(t.Provider,{value:f},a)}function r({template:a,children:i}){const{updateTemplate:l}=c.useContext(t);return c.useLayoutEffect(()=>{a&&l(a)},[a]),o.createElement(o.Fragment,null,i)}function s({children:a}){return o.createElement(n,null,a)}return s.defaults=e,s.useContext=()=>c.useContext(t),s.Context=t,s.Template=r,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:u}=c.useContext(t);return c.useLayoutEffect(()=>{l&&u(a,l)},[l]),null}}),s}function po(...e){return function({children:n}){return e.reduce((r,s)=>o.createElement(s,null,r),n)}}const _e=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===z.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},Wt=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===z.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function Ne(e){var n,r,s;return typeof(((n=e==null?void 0:e.conversation)==null?void 0:n.handedOverAt)??((s=(r=e==null?void 0:e.conversation)==null?void 0:r.handoff)==null?void 0:s.timestamp))=="number"}function bo(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}function fn(e){return!!e&&e<Date.now()}function Eo(e){return!e.title}function xo(e,t){var n;if(e)return Eo(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:{required:((n=e.cre)==null?void 0:n.required)??!0,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 vo(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 Co(e,t,n){var i;const r=new Date,s=new Date(((i=e.lastMessage)==null?void 0:i.createdAt)||e.createdAt),a=Ce.differenceInMinutes(r,s);return a<1?n.justNow:a<60?n.minutesAgo(a):Ce.isToday(s)?n.hoursAgo(Ce.differenceInHours(r,s)):t(s,n.dateShortFormat)}const De="sb-agent",Zn="KEY_IMG_ASPECT_RATIO",yo="*/*",P={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},me=e=>!!e&&"sender"in e,_o=e=>me(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),So=(e,t,n,r=!0)=>{if(!r||!me(e))return"single";const s=()=>{if(!t||!me(t))return!1;const u=t.sender.userId===e.sender.userId,d=Ce.isSameMinute(t.createdAt,e.createdAt);return u&&d},a=()=>{if(!n||!me(n))return!1;const u=n.sender.userId===e.sender.userId,d=Ce.isSameMinute(n.createdAt,e.createdAt);return u&&d},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},Be=(e,t)=>(()=>{var r;return me(e)?e.sender.userId:((r=e==null?void 0:e.sender)==null?void 0:r.userId)??void 0})()===t,Oe={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>me(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>me(e)&&(e.sender.userId===t||e.sendingStatus===ye.SendingStatus.PENDING)},Xn=e=>e.startsWith("image/"),Jn=e=>e.startsWith("video/"),qt=(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"},Qn=e=>e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0,jt=e=>{switch(e){case"top":case"middle":return P.GAP_GROUPED;default:return P.GAP_UNGROUPED}},To=(e,t)=>{const n=/```(\w+)?\n([\s\S]*?)```/g,r=[];let s=0;return e.replace(n,(a,...i)=>{const[l,u,d]=i;return s<d&&r.push({type:"text",value:e.slice(s,d).trim()}),r.push({type:"code",value:u.trim(),language:l?l.trim():"plaintext"}),s=d+a.length,a}),s<e.length&&r.push({type:"text",value:e.slice(s).trim()}),t?r.map(a=>a.type!=="text"?a:{...a,value:t(a.value)}):r},Ao=e=>e.replace(/\[([^\]]+)\](?!\()/g,"\\[$1\\]"),wo=e=>e.replace(/([a-zA-Z0-9])_(?=[a-zA-Z0-9])/g,"$1\\_"),ko=e=>e.replace(/~~/g,"\\~\\~"),Io=e=>{let t=e;return t=Ao(t),t=wo(t),t=ko(t),t},$o=typeof navigator<"u"&&navigator.product==="ReactNative",pn=(e,t)=>{const n=r=>!t||t.length===0?!0:me(r)&&t.includes(r.sendingStatus);return $o?e.find(n):e.findLast(n)};function he(){}function Mo(){const e=typeof navigator<"u"?navigator.userAgent:"",t=/iPad|iPhone|iPod/.test(e),n=/Android/.test(e);return t||n}function Lo(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 Ot=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},ge={isStreaming(e){const t=Ot(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(Be(e,t)){const r=Ot(e.data);return!(r!=null&&r.respond_mesg_id)&&!(r!=null&&r.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=>["suggested_replies"].includes(l)?Array.isArray(t[l])&&t[l].length>0:typeof t[l]<"u"),r=n(St.ui),s=n(St.trail),a=n(St.unusedAsync);return{ui:r,trail:s,unusedAsync:a}},shouldScrollToBottom(e,t,n=!1){if(Be(e,t)){if(this.isGeneratedMessage(e)&&this.isStreaming(e))return!0;const{ui:r,trail:s,unusedAsync:a}=this.checkExtendedFieldPresence(e);return r?!(!n&&a):!!(n&&(s||a))}return!0}},St={ui:["suggested_replies","cta_button","message_template","csat"],trail:["groundedness","manual","function_calls"],unusedAsync:["is_hallucination","is_moderated","flagged_types","is_last_in_turn","flagged_reason","used_sources"]},Tt=`@${De}`,bn=({appId:e,aiAgentId:t,storage:n})=>{const r={templateBase:`${Tt}-template`,template:s=>`${r.templateBase}/templates/${s}`,templateToken:()=>`${r.templateBase}-template/message-template/tokens`,messengerSession:s=>{const a=Lo(`${e}/${t}/${s}`);return`${Tt}-udata/${a}`},anonUserSession:()=>`${Tt}-session/${e}/${t}`};return{template:{set:(s,a)=>n.set(r.template(s),a),get:s=>n.get(r.template(s)),setCachedToken:s=>n.set(r.templateToken(),s),getCachedToken:()=>n.get(r.templateToken()),clear:()=>{n.getKeys(r.templateBase).forEach(n.delete)}},messenger:{getSettings:s=>{try{const a=n.get(r.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(r.messengerSession(s),i)}catch{return}},getAnonUser:()=>{try{const s=n.get(r.anonUserSession());return s?JSON.parse(s):null}catch{return null}},setAnonUser:s=>{try{const a=JSON.stringify(s);n.set(r.anonUserSession(),a)}catch{return}},clear:s=>{try{s&&n.delete(r.messengerSession(s)),n.delete(r.anonUserSession())}catch{return}}}}};class er{constructor(t){B(this,"subscribers",{});this.logger=t}async send(t){const n=Oo(),r=this.subscribers[t.type];if(r){this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`,t.payload);const s=r.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(r=>r!==n))}}const Oo=()=>{let e=he,t=he;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}};var Kt=(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))(Kt||{});class tr{constructor(t){B(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${De}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${De}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${De}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${De}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${De}/error]`,...t)}}function En(e,t,n,r){const s=ho.default.init({appId:e,modules:[new at.GroupChannelModule,new z.AIAgentModule],localCacheEnabled:!0,options:new Z.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...r});return s.addSendbirdExtensions([{version:n,product:Z.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),s}function Ro(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 Re={conversation:{isTalkToAgentViewEnabled:!0,input:{camera:{photoEnabled:!0},gallery:{photoEnabled:!0},fileEnabled:!0}}},Do=e=>{var t,n,r,s,a,i,l,u,d,f;return e?{...Re,...e,conversation:{...Re.conversation,...e==null?void 0:e.conversation,input:{...(t=Re.conversation)==null?void 0:t.input,...(n=e==null?void 0:e.conversation)==null?void 0:n.input,camera:{...(s=(r=Re.conversation)==null?void 0:r.input)==null?void 0:s.camera,...(i=(a=e==null?void 0:e.conversation)==null?void 0:a.input)==null?void 0:i.camera},gallery:{...(u=(l=Re.conversation)==null?void 0:l.input)==null?void 0:u.gallery,...(f=(d=e==null?void 0:e.conversation)==null?void 0:d.input)==null?void 0:f.gallery}}}}:Re},{Provider:Po,useContext:G}=X("AIAgent");function No({appId:e,aiAgentId:t,keyValueStorage:n,networkStateAdapter:r,language:s,countryCode:a,context:i,queryParams:l,config:u,chatSDK:d,chatParams:f,children:p,logger:x,dispatcher:y,messengerVersion:v,extensions:E={platform:Z.SendbirdPlatform.JS,deviceOSPlatform:Mo()?Z.DeviceOsPlatform.MOBILE_WEB:Z.DeviceOsPlatform.WEB}}){const[b,g]=c.useState(()=>{const C=x??new tr(Kt.WARN),_=y??new er(C);return{logger:C,dispatcher:_,chatSDK:d??En(e,E,v,f),cache:bn({appId:e,aiAgentId:t,storage:n})}});return c.useEffect(()=>{g(C=>{let _=C.logger,I=C.dispatcher,S=C.chatSDK;return x&&x!==C.logger&&(_=x),y&&y!==C.dispatcher&&(I=y),d&&d!==C.chatSDK?S=d:!d&&C.chatSDK.appId!==e&&(S=En(e,E,v,{newInstance:!0,...f})),{...C,logger:_,dispatcher:I,chatSDK:S,cache:bn({appId:e,aiAgentId:t,storage:n})}})},[e,t,x,y,d,n]),c.useEffect(()=>()=>{b.chatSDK.disconnectWebSocket()},[b.chatSDK]),Ro(b.chatSDK),o.createElement(Po,{value:{...b,appId:e,aiAgentId:t,context:i,language:s,countryCode:a,queryParams:l,config:Do(u),networkStateAdapter:r}},p)}const Bo=(e,t,n)=>He.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var Rt=(e=>(e.ConversationClose="conv.close",e))(Rt||{});class Fo{constructor(t={}){B(this,"payload");this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}const nr={CloseConversation:e=>new Ho(e)};class Ho extends Fo{constructor(){super(...arguments);B(this,"type","conv.close")}}const rr=(e,t,n={})=>{let r=null,s=null,a=null;const{leading:i=!0,trailing:l=!0}=n,u=(...d)=>{const f=Date.now();if(a===null||f-a>=t)i?(e(...d),a=f):(s=d,a=f);else if(s=d,l&&!r){const p=t-(f-a);r=setTimeout(()=>{s&&l&&(e(...s),a=Date.now()),r=null,s=null},p)}};return u.cancel=()=>{r&&(clearTimeout(r),r=null),s=null,a=null},u},We={DEFAULT_PRIMARY:"#000000",DEFAULT_BOT_MSG_BG:"#ECECEC",WHITE:"#ffffff",BLACK:"#000000"};function or(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function Uo(e){const t=or(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function zo(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function Vo(e,t,n){e/=255,t/=255,n/=255;const r=Math.max(e,t,n),s=Math.min(e,t,n),a=r-s;let i=0,l=0;const u=(r+s)/2;return r!==s&&(l=u>.5?a/(2-r-s):a/(r+s)),r===e?i=(t-n)/a+(t<n?6:0):r===t?i=(n-e)/a+2:r===n&&(i=(e-t)/a+4),i/=6,[i,l,u]}function Go(e,t,n){let r,s,a;if(t===0)r=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,u=2*n-l;r=i(u,l,e+1/3),s=i(u,l,e),a=i(u,l,e-1/3)}return[Math.round(r*255),Math.round(s*255),Math.round(a*255)]}function Je(e,t,n){const[r,s,a]=Uo(e),[i,l,u]=Vo(r,s,a),d=Math.max(0,Math.min(1,u*t)),f=Math.max(0,Math.min(1,l*n)),[p,x,y]=Go(i,f,d);return zo([Math.round(p),Math.round(x),Math.round(y)])}function Wo(e,t="light"){return{extraDark:Je(e,.6,1.2),dark:Je(e,.85,1.1),main:e,light:Je(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:Je(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function Dt(e){const t=or(e),n=149,r=+`0x${t[1]}${t[2]}`,s=+`0x${t[3]}${t[4]}`,a=+`0x${t[5]}${t[6]}`;return r*.299+s*.587+a*.114>n?We.BLACK:We.WHITE}function qo(e,t,n,r,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:r},messageOutgoing:{text:n,background:t},csat:{background:e.background100}}}const jo=(e,t,n,r,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:r},messageOutgoing:{text:n,background:t},csat:{background:e.background400}}),Qe={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)"}},At={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 xn(e){const t=Ko(e),{colors:n,aiAgentColorVariables:r}=Yo(e,t),s=Xo(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:r,typography:s}}function Ko({selectedTheme:e,palette:t,primary:n}){const r=t!=null&&t.primary?t.primary:n?n===Qe.primary.main?Qe.primary:Wo(n,e):Qe.primary;return{...Qe,primary:r,...t}}function Yo({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:r},s){const a=s.primary.main,i=t??Dt(a),l=n??We.DEFAULT_BOT_MSG_BG,u=r??Dt(l);return{colors:(e==="light"?qo:jo)(s,a,i,l,u),aiAgentColorVariables:{primary_color:a,bot_message_bg_color:l,primary_contrast_color:i,bot_message_bg_contrast_color:u}}}function Zo(e,t,n){const r={...e};return n.forEach(s=>{const a=t[s];a!=null&&(r[s]=a)}),r}function Xo({typography:e}){if(!e)return At;const t={...At};return Object.keys(e).forEach(n=>{const r=e[n];if(r&&typeof r=="object"){const s=At[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=Zo(s,r,a)}}),t}const{Provider:Jo,useContext:Yt}=X("AIAgentTheme");function Qo({logger:e,palette:t,typography:n,appearance:r,children:s}){const a=c.useRef(null),[i,l]=c.useState(()=>xn({selectedTheme:(r==null?void 0:r.theme)??"light",palette:t,typography:n,primary:r==null?void 0:r.primaryColor,botMessageBackground:r==null?void 0:r.botMessageBackgroundColor})),u=c.useCallback((d,f)=>{f&&(a.current=f);const p=(r==null?void 0:r.theme)??d,x=a.current?a.current.themes[p]:null,y={primary:r==null?void 0:r.primaryColor,primaryContrast:void 0,botMessageBackground:r==null?void 0:r.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=xn({selectedTheme:p,palette:t,typography:n,...y});l(v),e==null||e.info("theme.update:",p)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor,t,n,e]);return c.useEffect(()=>{(r!=null&&r.theme||r!=null&&r.primaryColor||r!=null&&r.botMessageBackgroundColor)&&u(i.selectedTheme)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor]),o.createElement(Jo,{value:{theme:i,updateTheme:u}},s)}const vn=25*1024*1024,es={off:"off",always:"always",handed_off_only:"handed_off_only"},ts=()=>{const[e,t]=c.useState(()=>({maxAttachmentCount:1,attachmentMode:"handed_off_only",defaultUploadSizeLimit:vn,uploadSizeLimitPerType:new Map,supportedImageMimeTypes:new Set(["image/png","image/jpeg","image/jpg"]),supportedFileMimeTypes:new Set(["application/pdf"])})),n=c.useCallback(({active_channel:s,upload_restriction:a})=>{const{maxAttachmentCount:i,attachmentMode:l,defaultUploadSizeLimit:u,supportedImageMimeTypes:d,supportedFileMimeTypes:f}=e;t({maxAttachmentCount:i,attachmentMode:es[s.attachment_mode]??l,defaultUploadSizeLimit:(a==null?void 0:a.default_upload_size_limit)??u,uploadSizeLimitPerType:new Map(Object.entries((a==null?void 0:a.upload_size_limit_per_type)??[])),supportedImageMimeTypes:new Set((a==null?void 0:a.supported_image_mime_types)??d),supportedFileMimeTypes:new Set((a==null?void 0:a.supported_file_mime_types)??f)})},[]),r=c.useCallback(s=>{const{channel:a,uploadSizeLimit:i=vn}=s,l=(d=!0)=>a!=null&&a.isAIAgent?d?Ne(a):!1:!0,u=d=>{if(l())return e.defaultUploadSizeLimit??i;const f=e.defaultUploadSizeLimit??i,p=e.uploadSizeLimitPerType.get(d)??f;return Math.min(f,p)};return{maxAttachmentCount:e.maxAttachmentCount,isEnabled:()=>{if(l(!1))return!0;switch(e.attachmentMode){case"off":return!1;case"always":return!0;case"handed_off_only":return Ne(a);default:return!0}},get supportedMimeTypes(){return l()?[yo]:[...e.supportedImageMimeTypes,...e.supportedFileMimeTypes]},isSupportedMimeType:d=>l()?!0:e.supportedImageMimeTypes.has(d)||e.supportedFileMimeTypes.has(d),getUploadSizeLimit:u,getUploadSizeLimitInMB:d=>u(d)/(1024*1024)}},[e]);return{updateBaseAttachmentRules:n,createAttachmentRules:r}};function sr(){const{chatSDK:e,logger:t}=G();return c.useCallback(async n=>{if(n.userId===""){const r=new Error("userId cannot be empty string for messenger settings request");throw t.error("requestMessengerSettings: invalid userId",r),r}return await e.aiAgent.requestMessengerSettings(n)},[e,t])}function ns(){const{chatSDK:e,logger:t}=G(),n=c.useCallback(async(s,a,i)=>{if(t.debug("useChatConnection.connect: start, session",s.userId),a){const l=new Z.SessionHandler({...a,onSessionTokenRequired:rs(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 u=l;if(e.isCacheEnabled){if(ss(u))t.warn("useChatConnection.connect","offline connect restricted",u.message,u.code),t.warn("useChatConnection.connect","clear cached-data"),await e.clearCachedData().catch(d=>t.warn("useChatConnection.connect","clear cached-data failure",d));else if(e.currentUser)return t.debug("useChatConnection.connect: end (offline), currentUser",e.currentUser),e.currentUser}throw t.warn("useChatConnection.connect","connect failure",u.message,u.code),u}},[e,t]),r=c.useCallback(async()=>{t.debug("useChatConnection.disconnect: start"),await e.disconnect(),t.debug("useChatConnection.disconnect: end")},[e,t]);return{connect:n,disconnect:r}}function rs(e,t){if(e)return async(n,r)=>{new Promise((s,a)=>e==null?void 0:e(s,a)).then(s=>{s&&(t==null||t(s)),n(s)}).catch(s=>{r(s)})}}const os=[400300,400301,400302,400310];function ss(e){return os.some(t=>e.code===t)}class ar{constructor({userId:t,authToken:n,sessionHandler:r}){B(this,"userId");B(this,"authToken");B(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=r}}class Pt{constructor(){B(this,"userId");B(this,"authToken");B(this,"sessionHandler")}}const as=1440*60*1e3,is=e=>{const{logger:t,cache:n}=G(),r=()=>{const a=n.messenger.getAnonUser();return a?a.expireAt-as<=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 Pt)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 c.useMemo(()=>e instanceof ar?{type:"manual",userSessionCandidate:s()}:e instanceof Pt?{type:"anonymous",userSessionCandidate:r()}: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:r()}):{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 ls({userSessionInfo:e,onUpdateMessengerSettings:t,onPreAuth:n,onPostAuth:r,onErrorAuth:s,onAuthTokenRefreshed:a,onPostDeauth:i,forceCreateChannel:l}){const{aiAgentId:u,language:d,context:f,countryCode:p,logger:x,cache:y}=G(),{connect:v,disconnect:E}=ns(),{type:b,userSessionCandidate:g}=is(e),C=sr(),_=c.useCallback(async()=>{var O;x.debug("useAuthentication.authenticate: start");const S=g!=null&&g.userId?y.messenger.getSettings(g.userId):null;S!=null&&S.bot&&(t(S),x.debug("useAuthentication.authenticate: cached messenger settings",S));const A=await C({aiAgentId:u,userId:g==null?void 0:g.userId,language:d,country:p,context:f,forceCreateChannel:l,knownActiveChannelUrl:(O=S==null?void 0:S.active_channel)==null?void 0:O.channel_url});x.debug("useAuthentication.authenticate: messenger settings response",A);let w=null;if(A.auto_created_user)if(b==="manual")x.warn("Received auto created user info but current session is manual. Ignoring auto created user info."),w={userId:g.userId,authToken:g.authToken};else{const{user_id:W,session_token:te,expire_at:K}=A.auto_created_user;y.messenger.setAnonUser({userId:W,authToken:te,expireAt:K}),w={userId:W,authToken:te}}else w={userId:(g==null?void 0:g.userId)??"",authToken:(g==null?void 0:g.authToken)??""};y.messenger.setSettings(w.userId,A),t(A);try{await n(A,w),await v(w,g==null?void 0:g.sessionHandler,a),await r(A,w)}catch(W){throw W instanceof Error&&(s(W),x.error("useAuthentication.authenticate: failed to connect",W)),W}return A},[C,v,b,g==null?void 0:g.userId,g==null?void 0:g.sessionHandler,g==null?void 0:g.authToken,u,d,f,p,l,y.messenger.setAnonUser,y.messenger.getSettings,y.messenger.setSettings,t,n,r,s,a]),I=c.useCallback(async()=>{x.debug("useAuthentication.deauthenticate: start"),await E(),i(),x.debug("useAuthentication.deauthenticate: completed")},[E,x,i]);return{authenticate:_,deauthenticate:I,userSessionCandidate:g}}const ir=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)}},qe=e=>JSON.parse(e),mt=e=>JSON.parse(e);function cs(e,t){const[n,r]=t.split(",").map(s=>s.trim());return e==="dark"&&r||n}function us(e){const t={};function n(r,s=""){for(const[a,i]of Object.entries(r)){const l=s?`${s}.${a}`:a;i&&typeof i=="object"&&!Array.isArray(i)?n(i,l):t[l]=i}}return n(e),t}function Zt({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:r}){return Object.entries(t).reduce((s,[a,i])=>{if(!r&&!["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=r?r(i):String(i),u=n(a);return s.replace(u,ir(l))},e)}async function ds({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:r}){return(await Promise.all(Object.entries(t).map(async([a,i])=>{const l=await r(i);return{regex:n(a),transformedValue:l}}))).reduce((a,{regex:i,transformedValue:l})=>a.replace(i,ir(l)),e)}const ms=()=>{const{chatSDK:e,logger:t,cache:n}=G(),r=c.useCallback(()=>{var l,u;const a=(u=(l=e.appInfo)==null?void 0:l.aiAgentInfo)==null?void 0:u.templateListToken;if(!a)return!1;const i=n.template.getCachedToken();return i?a!==i:!0},[e,n.template.getCachedToken]),s=c.useCallback(async()=>{try{const{templates:a,token:i}=await e.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:u}=qe(l);n.template.set(u,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:r,syncCachedTemplates:s}},{Provider:gs,useContext:gt}=X("AIAgentMessengerSession"),hs=c.forwardRef(function({userSessionInfo:e,forceCreateChannel:t,children:n},r){const{appId:s,aiAgentId:a,chatSDK:i,language:l,countryCode:u,context:d,cache:f,logger:p}=G(),{updateTheme:x}=Yt(),[y,v]=c.useState(void 0),[E,b]=c.useState(void 0),[g,C]=c.useState(null),[_,I]=c.useState(null),[S,A]=c.useState(null),[w,O]=c.useState(null),{updateBaseAttachmentRules:W,createAttachmentRules:te}=ts(),{shouldSyncCachedTemplate:K,syncCachedTemplates:ie}=ms(),oe=sr(),{authenticate:Ae,deauthenticate:we}=ls({userSessionInfo:e,forceCreateChannel:t,onUpdateMessengerSettings:c.useCallback(T=>{const{appearance:L,bot:N,launcher:V}=T;x(L.selected_theme,L),A({userId:N.bot_userid,profileUrl:N.bot_profile_url,nickname:N.bot_nickname,replyToFile:N.reply_to_file,specialNotice:N.special_notice,specialNoticeEnabled:N.is_special_notice_enabled,showHandoffButton:N.show_handoff_button??!0,isMultipleActiveConversationsEnabled:N.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:T.bot.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:T.bot.is_user_feedback_comment_option_enabled??!1}),O({type:V.image_type||"default_icon",imageUrl:V.image_url}),W(T)},[x]),onPreAuth:c.useCallback((T,L)=>{v(void 0),I(L)},[]),onPostAuth:c.useCallback(async T=>{C(i.currentUser),K()&&await ie(),b({url:T.active_channel.channel_url,status:z.ConversationStatus.OPEN})},[i,K,ie]),onErrorAuth:c.useCallback(T=>{v(T)},[]),onAuthTokenRefreshed:c.useCallback(T=>{I(L=>L?{...L,authToken:T}:null)},[]),onPostDeauth:c.useCallback(()=>{f.template.clear(),f.messenger.clear(_==null?void 0:_.userId),C(null),b(void 0),I(null),A(null),O(null)},[f.template.clear,f.messenger.clear,_])}),q=c.useCallback(async()=>{var T;if(_){p.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"),b(void 0);const L=await oe({aiAgentId:a,userId:_.userId,language:l,country:u,context:d,forceCreateChannel:t,knownActiveChannelUrl:(T=f.messenger.getSettings(_.userId))==null?void 0:T.active_channel.channel_url});return f.messenger.setSettings(_.userId,L),b({url:L.active_channel.channel_url,status:z.ConversationStatus.OPEN}),p.info("agentMessengerSession.refreshActiveChannel: refreshed active channel",L.active_channel.channel_url),L.active_channel.channel_url}else throw p.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[oe,s,a,_==null?void 0:_.userId,l,u,d,t,f.messenger.getSettings,f.messenger.setSettings]),$=c.useCallback(async T=>{if(!(_!=null&&_.userId))throw new Error("Current user is not authenticated. Please authenticate first.");const L=await oe({...T,userId:_.userId,knownActiveChannelUrl:void 0}),N=L.active_channel.channel_url;return f.messenger.setSettings(_.userId,L),N},[_==null?void 0:_.userId,oe]),[ee]=c.useState(()=>rr(T=>{var L;p.info("agentMessengerSession.channelChanged: channel.conversation",T.conversation),b({url:T.url,status:((L=T.conversation)==null?void 0:L.status)??z.ConversationStatus.OPEN})},250,{trailing:!1,leading:!0}));return He.useGroupChannelHandler(i,{onChannelChanged:T=>{T.isGroupChannel()&&T.url===(E==null?void 0:E.url)&&ee(T)}}),c.useEffect(()=>()=>{ee.cancel()},[ee]),c.useImperativeHandle(r,()=>{const T=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:Ae,deauthenticate:we,updateContext:async L=>{const V=await(await T()).updateContext(a,L);return{...V,context:V.context??{}}},patchContext:async L=>{const V=await(await T()).patchContext(a,L);return{...V,context:V.context??{}}},getContextObject:async()=>{const N=await(await T()).getContextObject(a);return{...N,context:N.context??{}}}}},[Ae,we,E,i,a,p]),o.createElement(gs,{value:{sdkUser:g,userSessionInfo:e,userSession:_,activeChannel:E,setActiveChannel:b,refreshActiveChannel:q,createConversation:$,connectionError:y,aiAgentInfo:S,launcherInfo:w,authenticate:Ae,deauthenticate:we,createAttachmentRules:te}},n)}),fs=()=>{const e=c.useId(),{chatSDK:t,networkStateAdapter:n}=G(),[r,s]=c.useState(()=>n?n.isOnline()?"connected":"reconnecting":"connected");return c.useEffect(()=>{const a=new Z.ConnectionHandler({onDisconnected:()=>s("disconnected"),onConnected:()=>s("connected"),onReconnectStarted:()=>s("reconnecting"),onReconnectSucceeded:()=>s("connected"),onReconnectFailed:()=>s("disconnected")});return t.addConnectionHandler(e,a),()=>{t.removeConnectionHandler(e)}},[t,e]),c.useEffect(()=>{if(n)return n.subscribe(()=>{s("reconnecting")})},[n]),r},lr=e=>{const{chatSDK:t}=G(),[n,r]=c.useState([]);return He.useGroupChannelHandler(t,{onTypingStatusUpdated(s){if(s.url===(e==null?void 0:e.url)){const a=s.getTypingUsers();r(a)}}}),n},ps=({channel:e,messages:t,isStreamAnimating:n})=>{const{aiAgentInfo:r,userSession:s}=gt(),a=fs(),i=bs({channel:e,lastMessage:pn(t,[ye.SendingStatus.SUCCEEDED]),aiAgentUserId:(r==null?void 0:r.userId)??"",isStreamAnimating:n}),l=Cs({shouldApply:!!(e!=null&&e.isAIAgent)&&!Ne(e),isDisabledWhileAIResponding:i,lastMessage:pn(t,[ye.SendingStatus.PENDING,ye.SendingStatus.SUCCEEDED]),currentUserId:(s==null?void 0:s.userId)??""});if(!e||a==="disconnected")return{disabled:!0,disabledBy:"unavailable"};if(a==="reconnecting")return{disabled:!0,disabledBy:"reconnecting"};if(_e(e))return{disabled:!0,disabledBy:"conversation_closed"};if(Es(e))return{disabled:!0,disabledBy:"form_active"};const u=xs(e);return u?{disabled:!0,disabledBy:u}:i||l?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},bs=({channel:e,lastMessage:t,aiAgentUserId:n,isStreamAnimating:r})=>{const[s,a]=c.useState(!1),i=lr(e);return c.useEffect(()=>{if(!t)return;const l=i.some(d=>d.userId===n),u=Be(t,n)&&(ge.isStreaming(t)||r);a(!!(u||l))},[i,t,n,r]),s},Es=e=>{var i;const t=e==null?void 0:e.lastMessage;if(!t||!e)return!1;const n=t.extendedMessagePayload,r=n==null?void 0:n.form,s=r&&!r.submitted_at&&!r.canceled_at,a=e.isAIAgent&&!!((i=e.conversation)!=null&&i.handedOverAt);return s&&!a},xs=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},vs=3e4,Cs=({shouldApply:e,lastMessage:t,isDisabledWhileAIResponding:n,currentUserId:r})=>{const[s,a]=c.useState(!1),i=c.useRef(null),l=t&&Be(t,r)?t.createdAt:0;return c.useEffect(()=>{const u=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},d=x=>{i.current&&clearTimeout(i.current),a(!0),i.current=setTimeout(()=>{a(!1),i.current=null},x)},f=Date.now()-l,p=vs-f;return n||p<=0?u():d(p),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},ys=()=>{const[e,t]=c.useState(new Set),n=c.useCallback(s=>{t(a=>{if(a.has(s))return a;const i=new Set(a);return i.add(s),i})},[]),r=c.useCallback(s=>{t(a=>{if(!a.has(s))return a;const i=new Set(a);return i.delete(s),i})},[]);return{isAnimating:e.size>0,start:n,stop:r}},{Provider:_s}=X("AIAgentConversation");function Ss({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:r,onMessagesUpdated:s,onConversationClosedViaDispatcher:a,onBeforeSendMessage:i,onAfterSendMessage:l=he,shouldMarkAsRead:u=!0,sortComparator:d}){var S;const f=()=>u&&(v==null?void 0:v.markAsRead()),{chatSDK:p,logger:x,dispatcher:y}=G(),{channel:v,channelFetchError:E,fetchChannel:b}=Ts(t),g=Bo(p,v,{replyType:ye.ReplyType.ONLY_REPLY_TO_CHANNEL,shouldCountNewMessages:()=>!1,onChannelDeleted:n,onMessagesReceived:A=>r==null?void 0:r(A),onMessagesUpdated:A=>s==null?void 0:s(A),logger:x,markAsRead:f,sortComparator:d}),C=ys(),_=ps({channel:v,messages:g.messages,isStreamAnimating:C.isAnimating});c.useEffect(()=>{f()},[u]),c.useEffect(()=>{const A=async w=>{const O=typeof(w==null?void 0:w.channelUrl)=="string";v&&O&&w.channelUrl!==v.url||(x.debug("conversation.dispatcher: try to close conversation",v),v!=null&&v.conversation&&v.conversation.status===z.ConversationStatus.OPEN&&(await v.closeConversation(),a==null||a()))};return y.subscribe(Rt.ConversationClose,A),()=>{y.unsubscribe(Rt.ConversationClose,A)}},[y,(S=v==null?void 0:v.conversation)==null?void 0:S.status,a]);const I={conversation:(v==null?void 0:v.conversation)??void 0,channelSource:{channel:v,error:E,refetch:()=>b(),closeConversation:async()=>{_e(v)||await(v==null?void 0:v.closeConversation())}},messageSource:{messages:g.messages,initialized:g.initialized,loadPrevious:()=>g.loadPrevious(),loadNext:()=>g.loadNext(),deleteMessage:A=>g.deleteMessage(A),resendMessage:A=>g.resendMessage(A),sendUserMessage:async A=>{var O;if(((O=v==null?void 0:v.conversation)==null?void 0:O.status)===z.ConversationStatus.CLOSED)throw new Error("Conversation is closed");i&&(A=await i(A));const w=await g.sendUserMessage(A,l);return l==null||l(w),w},sendFileMessage:async A=>{var O;if(((O=v==null?void 0:v.conversation)==null?void 0:O.status)===z.ConversationStatus.CLOSED)throw new Error("Conversation is closed");i&&(A=await i(A));const w=await g.sendFileMessage(A,l);return l==null||l(w),w}},state:{streamAnimation:C,input:_}};return o.createElement(_s,{value:I},e)}function Ts(e){const{chatSDK:t,logger:n}=G(),{sdkUser:r}=gt(),[s,a]=c.useState(void 0),[i,l]=c.useState(void 0);async function u(){if(!r){n.debug("conversation.fetchChannel: no sdk user, skip fetching channel");return}if(n.debug("conversation.fetchChannel: start"),a(void 0),l(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const d=await t.groupChannel.getChannel(e);a(d),n.debug("conversation.fetchChannel: fetched channel",d)}catch(d){d instanceof Z.SendbirdError&&l(d),n.error("conversation.fetchChannel: error",d)}}return As(s),c.useEffect(()=>{u()},[t,r,e]),{channel:s,channelFetchError:i,fetchChannel:u}}function As(e){const{chatSDK:t}=G(),{activeChannel:n,setActiveChannel:r}=gt(),s=c.useId();c.useEffect(()=>{if(!e||!n)return;const a=new Z.ConnectionHandler({onReconnectSucceeded:async()=>{var l;const i=await e.refresh();i.url===n.url&&r({url:i.url,status:((l=i.conversation)==null?void 0:l.status)??z.ConversationStatus.OPEN})}});return t.addConnectionHandler(s,a),()=>{t.removeConnectionHandler(s)}},[t,e,n])}class ws{constructor(t,{filter:n,limit:r=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",at.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");B(this,"_throttledOnChannelChanged");var s,a,i,l,u,d,f;this.filter=n,this._sdk=t,this._pinnedChannels=[],this._channels=[],this._limit=r,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:(u=this.filter)==null?void 0:u.pinnedChannelUrls,copilotConversationOnly:(d=this.filter)==null?void 0:d.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._throttledOnChannelChanged=rr(p=>{p.isGroupChannel()&&(this._query.belongsTo(p)?this._addChannelsToView([p],!1):this._removeChannelsFromView([p.url]))},250,{trailing:!1,leading:!0}),this._channelHandler=new at.GroupChannelHandler({onChannelChanged:this._throttledOnChannelChanged,onChannelDeleted:p=>{this._removeChannelsFromView([p])}}),this._connectionHandler=new Z.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)??[]),r=t.find(l=>!n.has(l.url));let s;r?s=((i=r.lastMessage)==null?void 0:i.createdAt)??r.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)??[],r=new Map(n.map((u,d)=>[u,d])),s=[],a=[],i=[];for(const u of t){if(!this._query.belongsTo(u)){i.push(u.url);continue}const d=r.get(u.url);if(d===void 0)continue;const f=Nt(this._pinnedChannels,u);f>=0?(this._pinnedChannels.splice(f,1),a.push(u)):s.push(u);const x=this._pinnedChannels.findIndex(v=>(r.get(v.url)??1/0)>d),y=x===-1?this._pinnedChannels.length:x;this._pinnedChannels.splice(y,0,u)}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:i}}_upsertRegularChannelsToArray(t,n=!1){const r=[],s=[],a=[];for(const i of t){if(!this._query.belongsTo(i)){r.push(i.url);continue}const l=Nt(this._channels,i),u=l<0;!u&&this._channels.splice(l,1);const f=ks(this._channels,i,this._order).place,p=f===this._channels.length;u?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:r}}_addChannelsToView(t,n=!1){var p,x,y,v,E;const r=new Set(((p=this.filter)==null?void 0:p.pinnedChannelUrls)??[]),s=[],a=[];for(const b of t)r.has(b.url)?s.push(b):a.push(b);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),u=i.addedChannels.concat(l.addedChannels),d=i.updatedChannels.concat(l.updatedChannels),f=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);u.length>0&&((y=(x=this._collectionEventHandler)==null?void 0:x.onChannelsAdded)==null||y.call(x,{},u)),d.length>0&&((E=(v=this._collectionEventHandler)==null?void 0:v.onChannelsUpdated)==null||E.call(v,{},d)),f.length>0&&this._removeChannelsFromView(f)}_removeChannelsFromView(t){var s,a,i;const n=new Set(((s=this.filter)==null?void 0:s.pinnedChannelUrls)??[]),r=[];for(const l of t)if(n.has(l)){const u=this._pinnedChannels.findIndex(d=>d.url===l);u>=0&&(r.push(l),this._pinnedChannels.splice(u,1))}else{const u=this._channels.findIndex(d=>d.url===l);u>=0&&(r.push(l),this._channels.splice(u,1))}r.length>0&&((i=(a=this._collectionEventHandler)==null?void 0:a.onChannelsDeleted)==null||i.call(a,{},r))}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._throttledOnChannelChanged.cancel(),this._collectionEventHandler=void 0,this._sdk.removeConnectionHandler(this._handlerId),this._sdk.groupChannel.removeGroupChannelHandler(this._handlerId),this._pinnedChannels.length=0,this._channels.length=0)}}const Nt=(e,t)=>e.findIndex(n=>n.isIdentical(t)),ks=(e,t,n)=>{if(e.length>0){const r=Nt(e,t);let s=0,a=e.length-1,i=Math.floor((s+a)/2);for(;s<a;){const u=Cn(e[i],t,n);if(u>0)a=i,i=Math.floor((s+a)/2);else if(u<0)s=i+1,i=Math.floor((s+a)/2);else return{place:i,oldPosition:r}}return{place:Cn(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Cn=(e,t,n)=>{switch(n){case at.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const r=t.lastMessage.createdAt-e.lastMessage.createdAt;return r===0?t.createdAt-e.createdAt:r}else return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;default:return 0}};function Is(e,t){var v,E,b,g,C,_,I,S,A,w;const n=c.useId(),[r,s]=c.useState(!1),[a,i]=c.useState(null),[l,u]=c.useState([]),[d,f]=c.useState(null),p=c.useRef(!1),x=c.useCallback(async()=>{if(!p.current&&e.currentUser){p.current=!0,s(!1),i(null),u([]);try{d==null||d.dispose();const O=new ws(e,t);O.setConversationListCollectionHandler({onChannelsAdded:()=>{u(O.channels)},onChannelsUpdated:()=>{u(O.channels)},onChannelsDeleted:()=>{u(O.channels)}}),await O.loadMore(),f(O),i(null)}catch(O){f(null),i(O)}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=(g=t.filter)==null?void 0:g.aiAgentIds)==null?void 0:C.join(),(_=t.filter)==null?void 0:_.deskChannelFilter,(S=(I=t.filter)==null?void 0:I.pinnedChannelUrls)==null?void 0:S.join(),(A=t.filter)==null?void 0:A.copilotConversationOnly,(w=t.filter)==null?void 0:w.copilotSupportChannelUrl,t.limit]),y=c.useCallback(async()=>{if(d)try{await d.loadMore()}catch(O){i(O)}},[d]);return c.useEffect(()=>(e.addConnectionHandler(n,new Z.ConnectionHandler({onConnected:()=>x()})),()=>e.removeConnectionHandler(n)),[e,n,x]),c.useEffect(()=>{x()},[x]),c.useEffect(()=>()=>{p.current=!1,d==null||d.dispose()},[d]),{initialized:r,error:a,channels:l,loadMore:y}}const{Provider:$s}=X("AIAgentConversationList");function Ms({conversationListLimit:e,conversationListFilter:t,children:n}){var p,x;const{chatSDK:r,aiAgentId:s,queryParams:a}=G(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[z.ConversationStatus.CLOSED,z.ConversationStatus.OPEN]},l=e??((p=a==null?void 0:a.conversationListParams)==null?void 0:p.limit),u={...i,...(x=a==null?void 0:a.conversationListParams)==null?void 0:x.filter,...t},d=Is(r,{limit:l,filter:u}),f={listSource:{initialized:d.initialized,error:d.error??void 0,channels:d.channels,loadMore:()=>d.loadMore()}};return o.createElement($s,{value:f},n)}function Ls(e){let t="pending",n=e.then(r=>{t="resolved",n=r}).catch(r=>{t="rejected",n=r});return{get value(){if(t==="resolved")return n;throw n}}}const{Provider:Os,useContext:cr}=X("MessageTemplateFetching");function Rs({children:e,internalVariables:t}){const n=c.useRef({}),r=c.useRef({}),[s,a]=c.useState({}),i=c.useCallback((d,f)=>{a(p=>({...p,[d]:{fetching:!1,error:!1,...p[d],...f}}))},[]),l=c.useCallback(async({onRequestTemplate:d,onGetCachedTemplate:f,templateKey:p,suspense:x=!1})=>{const y=f(p);if(y)return y;const v=r.current[p];if(v)return v;x||i(p,{fetching:!0});const E=d(p).catch(b=>{throw x||i(p,{error:!0}),b}).finally(()=>{x||i(p,{fetching:!1}),delete r.current[p]});return r.current[p]=E,E},[i]),u={internalVariables:t,fetchTemplate:l,suspend:(d,f)=>{if(n.current[d])return n.current[d];const p=Ls(f());return n.current[d]=p,p},getIsFetching:d=>{var f;return((f=s[d])==null?void 0:f.fetching)??!1},getHasError:d=>{var f;return((f=s[d])==null?void 0:f.error)??!1}};return o.createElement(Os,{value:u},e)}const ht={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function Se({uiTemplateString:e,variables:t={}}){const n=us(t);return Zt({template:e,variables:n,variableKeyPattern:r=>ht.VARIABLE(r)})}function Te({theme:e,uiTemplateString:t,colorVariables:n={}}){return Zt({template:t,variables:n,variableKeyPattern:r=>ht.VARIABLE(r),variableValueTransformer:r=>cs(e,r)})}function Ds({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(d=>d.key);return[...new Set(l)].some(d=>!a(d))?null:Zt({template:t,variables:n,variableKeyPattern:d=>ht.VIEW_VARIABLE(d),variableValueTransformer:d=>{const f=d.map(({key:p,variables:x})=>{const y=a(p),{ui_template:v,color_variables:E}=qe(y);let b=JSON.stringify(v);return b=Se({uiTemplateString:b,variables:s}),b=Te({theme:e,uiTemplateString:b,colorVariables:E}),b=Te({theme:e,uiTemplateString:b,colorVariables:r}),b=Se({uiTemplateString:b,variables:x}),mt(b)});return JSON.stringify(f)}})}async function Ps({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){return ds({template:t,variables:n,variableKeyPattern:i=>ht.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:d,variables:f})=>{const p=await a(d),{ui_template:x,color_variables:y}=qe(p);let v=JSON.stringify(x);return v=Se({uiTemplateString:v,variables:s}),v=Te({theme:e,uiTemplateString:v,colorVariables:y}),v=Te({theme:e,uiTemplateString:v,colorVariables:r}),v=Se({uiTemplateString:v,variables:f}),mt(v)}),u=await Promise.all(l);return JSON.stringify(u)}})}const Ns=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=qe(e);let i=JSON.stringify(s);if(Object.keys(r.viewVariables??{}).length>0){const u=Ds({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(u===null)return null;i=u}return i=Se({...r,uiTemplateString:i,variables:n}),i=Te({...r,uiTemplateString:i,colorVariables:a}),i=Te({...r,uiTemplateString:i,colorVariables:t}),i=Se({...r,uiTemplateString:i}),mt(i)},Bs=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=qe(e);let i=JSON.stringify(s);return Object.keys(r.viewVariables??{}).length>0&&(i=await Ps({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=Se({...r,uiTemplateString:i,variables:n}),i=Te({...r,uiTemplateString:i,colorVariables:a}),i=Te({...r,uiTemplateString:i,colorVariables:t}),i=Se({...r,uiTemplateString:i}),mt(i)},Fs=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=cr();return c.useState(()=>{const r=e.onGetCachedTemplate(e.templateKey);return r?Ns({...e,rawTemplate:r,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Hs=e=>{const[t]=Fs(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:r,fetchTemplate:s,suspend:a}=cr();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Bs({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:r})}).value},Us="remove_powered_by",Xt=(e,t)=>{var s,a;const{chatSDK:n}=G(),{aiAgentInfo:r}=gt();if(e==="handoff-button"){const i=!!((s=t==null?void 0:t.conversation)!=null&&s.handoff);return!!(t!=null&&t.isAIAgent)&&!!(r!=null&&r.showHandoffButton)&&i&&Wt(t)}if(e==="special-notice")return!!(t!=null&&t.isAIAgent)&&!!(r!=null&&r.specialNoticeEnabled)&&!!(r!=null&&r.specialNotice);if(e==="powered-by"){const i=(a=n==null?void 0:n.appInfo)==null?void 0:a.applicationAttributes;return c.useMemo(()=>!(Array.isArray(i)&&i.includes(Us)),[i])}throw new Error("Unsupported feature")},zs={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"},Vs={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;if(e.required&&(!r||r.trim()===""))return{isValid:!1,error:n.required};if(!r)return{isValid:!0};const{rules:s}=e;if(s){if(s.min_length!==void 0&&r.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&&r.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(r))return{isValid:!1,error:n.regex}}return{isValid:!0}}},Gs={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;if(e.required&&r===null)return{isValid:!1,error:n.required};if(r===null)return{isValid:!0};const{rules:s}=e;if(s){if(s.min!==void 0&&r<s.min)return{isValid:!1,error:typeof n.min=="function"?n.min(s.min):n.min};if(s.max!==void 0&&r>s.max)return{isValid:!1,error:typeof n.max=="function"?n.max(s.max):n.max}}return{isValid:!0}}},Ws={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;return e.required&&!r?{isValid:!1,error:n.required}:r&&!e.options.includes(r)?{isValid:!1,error:n.invalidSelection}:{isValid:!0}}},qs={getValueOrDefault:e=>e.values??e.default_values??null,validate:(e,t,n)=>{const r=t;if(e.required&&(!r||r.length===0))return{isValid:!1,error:n.required};if(!r||r.length===0)return{isValid:!0};if(r.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&&r.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&&r.length>a.max_select)return{isValid:!1,error:typeof n.maxSelect=="function"?n.maxSelect(a.max_select):n.maxSelect}}return{isValid:!0}}},js={text:Vs,number:Gs,"single-select":Ws,"multi-select":qs},Ks={getValueOrDefault:()=>null,validate:()=>({isValid:!1})};function ur(e){return js[e.type]||Ks}function yn(e){return ur(e).getValueOrDefault(e)}function Ys(e,t,n={}){const r={...zs,...n};return ur(e).validate(e,t,r)}const Zs=(e,t={})=>{const{labels:n={},onSubmit:r,onCancel:s}=t,[a,i]=c.useState({}),[l,u]=c.useState(()=>{const E={};return e.fields.forEach(b=>{E[b.key]=yn(b)}),E}),d=c.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);c.useEffect(()=>{if(d==="submitted"||d==="canceled"){const E={};let b=!1;e.fields.forEach(g=>{const C=yn(g);JSON.stringify(l[g.key])!==JSON.stringify(C)&&(b=!0),E[g.key]=C}),b&&u(E)}},[d]);const f=(E,b)=>{u(g=>({...g,[E]:b})),i(g=>({...g,[E]:void 0}))},p=e.fields.map(E=>{var C,_,I;const b=l[E.key]??null,g={key:E.key,label:E.label,error:a[E.key],required:E.required};return E.type==="text"?{...g,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"?{...g,type:"number",layout:E.layout,value:b,...E.placeholder&&{placeholder:E.placeholder},...((_=E.rules)==null?void 0:_.max)&&{max:E.rules.max}}:E.type==="single-select"?{...g,type:"single-select",layout:E.layout,value:b,options:E.options}:E.type==="multi-select"?{...g,type:"multi-select",layout:E.layout,value:b,options:E.options,...((I=E.rules)==null?void 0:I.max_select)&&{maxSelect:E.rules.max_select}}:{...g,type:"unknown",layout:"default",value:null}});return{state:d,fields:p,getField:E=>p.find(b=>b.key===E),updateFieldValue:f,submit:async()=>{const E={};let b=!1;for(const g of e.fields){const C=l[g.key]??null,_=Ys(g,C,n);_.isValid||(E[g.key]=_.error,b=!0)}if(i(E),!b&&r){const g={};e.fields.forEach(C=>{g[C.key]=l[C.key]??null}),await r(g)}},cancel:async()=>{await(s==null?void 0:s())}}},dr=({channel:e,userSession:t,aiAgentInfo:n})=>{if(!t||!n||!e)return{fallbackIcon:"delight",url:void 0,title:""};const r=(()=>{const[a]=e.members.filter(i=>i.userId!==t.userId);return a})(),s={ai(a){return{fallbackIcon:a,url:n.profileUrl,title:n.nickname}},human(a){return{fallbackIcon:a,url:r==null?void 0:r.profileUrl,title:(r==null?void 0:r.nickname)||n.nickname}},channel(a){return{fallbackIcon:a,url:e==null?void 0:e.coverUrl,title:(e==null?void 0:e.name)??""}}};return e.isAIAgent?Ne(e)?s.human("agent"):s.ai("delight"):e.isDesk?s.human("agent"):s.channel("user")},_n=e=>c.useReducer((t,n)=>({...t,...n}),e);var se=(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))(se||{});const Xs=new Set(["free_text","single_choice"]),Js=({csatPayload:e,type:t,initialCsat:n,initialCsatReason:r,initialIsResolved:s})=>{const[a,i]=_n({csatType:t,csat:n,csatReason:r,isResolved:s}),[l,u]=_n({followUpItem:!1}),d=c.useMemo(()=>{var E;const y=a.csat;if(typeof y!="number")return;const v=(E=e.follow_up)==null?void 0:E.find(b=>b.scores.includes(y));if(Xs.has(v==null?void 0:v.response_type))return v},[a.csat,e.follow_up]),f=(()=>{var y;if(typeof n=="number")return"submitted";if((t===se.AI_AGENT_CSAT_5||t===se.HELPDESK_CSAT_5)&&typeof a.csat=="number")return"submittable";if(t===se.AI_AGENT_CSAT_5_WITH_CRE){const v=typeof a.csat=="number",E=!((y=e.cre)!=null&&y.required)||typeof a.isResolved=="boolean";if(v&&E)return"submittable"}return"unsubmittable"})(),p=c.useCallback(()=>typeof a.csat>"u"?!1:d!=null&&d.required&&!a.csatReason?(u({followUpItem:!0}),!1):!0,[a,d,u]);return c.useEffect(()=>{r||(i({csatReason:""}),u({followUpItem:!1}))},[r,d,i,u]),{params:a,setParams:i,error:l,setError:u,followUpItem:d,state:f,validateParams:p,itemProps:{csatPayload:e,state:f,submitted:f==="submitted"}}},wt=5,Qs=50,Sn=e=>Math.max(0,e-Qs),ea=e=>e<1e3?{speed:wt*.5,chunkSize:2}:e<2e3?{speed:wt*.8,chunkSize:2}:{speed:wt*.6,chunkSize:3},ta=e=>{const{text:t,enabled:n=!1,onAnimationStart:r,onAnimationComplete:s}=e,[a,i]=c.useState(()=>Sn(t.length)),l=c.useRef(null),u=c.useRef(0),d=c.useRef(0),f=c.useRef(n),p=c.useRef(r),x=c.useRef(s),y=c.useRef(!1),v=c.useRef(!1),E=c.useRef(t.length),b=c.useRef(n),g=n,C=a<t.length,_=f.current&&(g||C);return c.useLayoutEffect(()=>{p.current=r,x.current=s,E.current=t.length,b.current=n}),c.useLayoutEffect(()=>{var I;f.current&&(y.current||(y.current=!0,(I=p.current)==null||I.call(p)),i(S=>t.length<S?t.length:S))},[t]),c.useEffect(()=>{if(!f.current)return;let I=Sn(t.length);u.current=0,d.current=0;const S=A=>{u.current===0&&(u.current=A,d.current=A);const w=E.current,O=A-u.current,W=A-d.current,{speed:te,chunkSize:K}=ea(W),ie=te*K;O>=ie&&I<w&&(I=Math.min(I+K,w),i(I),u.current=A),(I<w||b.current)&&(l.current=requestAnimationFrame(S))};return l.current=requestAnimationFrame(S),()=>{l.current&&cancelAnimationFrame(l.current)}},[]),c.useEffect(()=>{var w;const I=f.current&&y.current,S=!n,A=a>=t.length&&t.length>0;I&&S&&A&&!v.current&&(v.current=!0,(w=x.current)==null||w.call(x))},[n,a,t.length]),{streamText:f.current?t.slice(0,a):t,isAnimating:_}},na='@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}',ra={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.",input_placeholder_reconnecting:"Trying to reconnect. Refresh if persists.",unknown_message_type:"(Unknown message type)",powered_by:"Powered by",citation_title:"Source",start_new_conversation_label:"Start a conversation",failed_message_resend:"Retry",failed_message_remove:"Remove",file_upload_no_supported_files:"No supported file types available."},conversation_list:{header_title:"Conversations",ended:"Ended",footer_title:"Start a conversation"},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"},feedback:{title:"Submit feedback",good:"Good",bad:"Bad",comment_label:"Comment (optional)",comment_placeholder:"Leave a comment",cancel:"Cancel",submit:"Submit",save:"Save",edit:"Edit feedback",remove:"Remove feedback"}},Bt={language:"en",strings:ra,dateLocale:ao.enUS},mr=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,MESSAGE_INPUT__PLACE_HOLDER__RECONNECTING:e.conversation.input_placeholder_reconnecting,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,FILE_UPLOAD_NO_SUPPORTED_FILES:e.conversation.file_upload_no_supported_files,FEEDBACK_TITLE:e.feedback.title,FEEDBACK_GOOD:e.feedback.good,FEEDBACK_BAD:e.feedback.bad,FEEDBACK_COMMENT_LABEL:e.feedback.comment_label,FEEDBACK_COMMENT_PLACEHOLDER:e.feedback.comment_placeholder,FEEDBACK_CANCEL:e.feedback.cancel,FEEDBACK_SUBMIT:e.feedback.submit,FEEDBACK_SAVE:e.feedback.save,FEEDBACK_EDIT:e.feedback.edit,FEEDBACK_REMOVE:e.feedback.remove}),oa=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??ft},ft="en",sa=new Set([ft,"ko","es","pt","fr","hi","it","de","tr","ja"]),aa=(e,t,n)=>{const r=e[t];return r?typeof r=="function"?r():Promise.resolve(r):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.":""))))})},Tn=mr(Bt.strings),ia={...Tn,HEADER_BUTTON__AGENT_HANDOFF:"Connect with an agent",MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES:"Select an option to continue",BUTTON__CANCEL:"Cancel",BUTTON__SUBMIT:"Submit",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",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",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE:Tn.DATE_FORMAT__DATE_SHORT,DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION:"h:mma",CONVERSATION_LIST__TOPICS_FALLBACK:"No category",CONVERSATION_CLOSED_FOOTER_LABEL:"Your conversation has ended",START_NEW_CONVERSATION:"💬 Start a new conversation",RETURN_TO_CONVERSATION:"💬 Return to conversation",BUTTON__SAVE:"Save",BUTTON__OK:"OK",NO_NAME:"(No name)",CHANNEL_FROZEN:"Channel frozen"},it={language:Bt.language,dateLocale:Bt.dateLocale,stringSet:ia},la=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"})),Ft=new Map([[ft,it]]);async function ca(e){const t=Ft.get(e);if(t)return t;try{if(sa.has(e)){const{default:n}=await aa(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./DI-EXSWj.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>la),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./BVlVEisk.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./39Vu-gp1.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./DOXieS3b.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./DBjNv8rR.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./8LgPimFK.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./sjY7fr9U.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./1ACj2pIu.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./CbSJ7GnB.cjs"))}),`./languages/${e}.ts`,3);return Ft.set(e,n),n}return it}catch{return it}}const{Provider:ua,useContext:F}=X("Localization"),da=({language:e=navigator.language,logger:t,stringSet:n,children:r})=>{const[s,a]=c.useState(Ft.get(ft));return c.useEffect(()=>{const i=oa(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",{from:s.language,to:i}),ca(i).then(a))},[e,t]),o.createElement(ua,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,u)=>Ce.format(i,l,{locale:s.dateLocale,...u})}},r)},lt="data-sb-agent-theme",An=e=>(t,...n)=>{let r="";return t.forEach((s,a)=>{r+=s+(n[a]??"")}),`[${lt}='${e}'] & { ${r} }`},R={light:An("light"),dark:An("dark")},ma=k.css(({theme:e})=>{const{palette:t}=e;return`
|
|
1
|
+
"use strict";var so=Object.defineProperty;var ao=(e,t,n)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>ao(e,typeof t!="symbol"?t+"":t,n);const c=require("react"),Z=require("@sendbird/chat"),A=require("styled-components"),Ce=require("date-fns"),io=require("date-fns/locale/en-US"),ye=require("@sendbird/chat/message"),V=require("@sendbird/chat/aiAgent"),at=require("@sendbird/chat/groupChannel"),lo=require("react-dom"),Lt=require("@sendbird/react-uikit-message-template-view"),co=require("@sendbird/uikit-message-template"),He=require("@sendbird/uikit-tools"),uo=require("dompurify"),mo=require("date-fns/isSameDay"),go=require("@emotion/is-prop-valid"),dt=e=>e&&e.__esModule?e:{default:e};function ho(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 r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const o=ho(c),fo=dt(Z),g=dt(A),Yn=dt(uo),po=dt(go),X=(e,t)=>{const n=c.createContext(null),r=({children:i,value:l})=>o.createElement(n.Provider,{value:l},typeof i=="function"?i(l):i),s=({children:i})=>o.createElement(n.Consumer,null,l=>l?typeof i=="function"?i(l):i:null),a=()=>{const i=c.useContext(n);if(!i)throw new Error(`use${e}Context must be used within a ${e}Provider`);return i};return n.displayName=`${e}Context`,r.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,a.displayName=`use${e}Context`,{Context:n,Provider:r,Consumer:s,useContext:a}};function fe(e){const t=c.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=c.useState(()=>e.template),[u,d]=c.useState(e.components),f={Template:i,updateTemplate:b=>l(()=>b),components:u,updateComponent:(b,E)=>d(y=>({...y,[b]:E}))};return o.createElement(t.Provider,{value:f},a)}function r({template:a,children:i}){const{updateTemplate:l}=c.useContext(t);return c.useLayoutEffect(()=>{a&&l(a)},[a]),o.createElement(o.Fragment,null,i)}function s({children:a}){return o.createElement(n,null,a)}return s.defaults=e,s.useContext=()=>c.useContext(t),s.Context=t,s.Template=r,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:u}=c.useContext(t);return c.useLayoutEffect(()=>{l&&u(a,l)},[l]),null}}),s}function bo(...e){return function({children:n}){return e.reduce((r,s)=>o.createElement(s,null,r),n)}}const _e=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===V.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},Wt=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===V.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function Ne(e){var n,r,s;return typeof(((n=e==null?void 0:e.conversation)==null?void 0:n.handedOverAt)??((s=(r=e==null?void 0:e.conversation)==null?void 0:r.handoff)==null?void 0:s.timestamp))=="number"}function Eo(e){var t;if(((t=e==null?void 0:e.resolution)==null?void 0:t.determinedBy)==="user")return e.resolution.isResolved}function fn(e){return!!e&&e<Date.now()}function xo(e){return!e.title}function vo(e,t){var n;if(e)return xo(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:{required:((n=e.cre)==null?void 0:n.required)??!0,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 Co(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 yo(e,t,n){var i;const r=new Date,s=new Date(((i=e.lastMessage)==null?void 0:i.createdAt)||e.createdAt),a=Ce.differenceInMinutes(r,s);return a<1?n.justNow:a<60?n.minutesAgo(a):Ce.isToday(s)?n.hoursAgo(Ce.differenceInHours(r,s)):t(s,n.dateShortFormat)}const De="sb-agent",Zn="KEY_IMG_ASPECT_RATIO",_o="*/*",P={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},me=e=>!!e&&"sender"in e,So=e=>me(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),To=(e,t,n,r=!0)=>{if(!r||!me(e))return"single";const s=()=>{if(!t||!me(t))return!1;const u=t.sender.userId===e.sender.userId,d=Ce.isSameMinute(t.createdAt,e.createdAt);return u&&d},a=()=>{if(!n||!me(n))return!1;const u=n.sender.userId===e.sender.userId,d=Ce.isSameMinute(n.createdAt,e.createdAt);return u&&d},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},Be=(e,t)=>(()=>{var r;return me(e)?e.sender.userId:((r=e==null?void 0:e.sender)==null?void 0:r.userId)??void 0})()===t,Oe={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>me(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>me(e)&&(e.sender.userId===t||e.sendingStatus===ye.SendingStatus.PENDING)},Xn=e=>e.startsWith("image/"),Jn=e=>e.startsWith("video/"),qt=(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"},Qn=e=>e.messageType==="file"?e.message.length>0&&e.file.name!==e.message:e.message.length>0,jt=e=>{switch(e){case"top":case"middle":return P.GAP_GROUPED;default:return P.GAP_UNGROUPED}},Ao=(e,t)=>{const n=/```(\w+)?\n([\s\S]*?)```/g,r=[];let s=0;return e.replace(n,(a,...i)=>{const[l,u,d]=i;return s<d&&r.push({type:"text",value:e.slice(s,d).trim()}),r.push({type:"code",value:u.trim(),language:l?l.trim():"plaintext"}),s=d+a.length,a}),s<e.length&&r.push({type:"text",value:e.slice(s).trim()}),t?r.map(a=>a.type!=="text"?a:{...a,value:t(a.value)}):r},wo=e=>e.replace(/\[([^\]]+)\](?!\()/g,"\\[$1\\]"),ko=e=>e.replace(/([a-zA-Z0-9])_(?=[a-zA-Z0-9])/g,"$1\\_"),Io=e=>e.replace(/~~/g,"\\~\\~"),$o=e=>{let t=e;return t=wo(t),t=ko(t),t=Io(t),t},Mo=typeof navigator<"u"&&navigator.product==="ReactNative",pn=(e,t)=>{const n=r=>!t||t.length===0?!0:me(r)&&t.includes(r.sendingStatus);return Mo?e.find(n):e.findLast(n)};function he(){}function Lo(){const e=typeof navigator<"u"?navigator.userAgent:"",t=/iPad|iPhone|iPod/.test(e),n=/Android/.test(e);return t||n}function Oo(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 Ot=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},ge={isStreaming(e){const t=Ot(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(Be(e,t)){const r=Ot(e.data);return!(r!=null&&r.respond_mesg_id)&&!(r!=null&&r.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=>["suggested_replies"].includes(l)?Array.isArray(t[l])&&t[l].length>0:typeof t[l]<"u"),r=n(St.ui),s=n(St.trail),a=n(St.unusedAsync);return{ui:r,trail:s,unusedAsync:a}},shouldScrollToBottom(e,t,n=!1){if(Be(e,t)){if(this.isGeneratedMessage(e)&&this.isStreaming(e))return!0;const{ui:r,trail:s,unusedAsync:a}=this.checkExtendedFieldPresence(e);return r?!(!n&&a):!!(n&&(s||a))}return!0}},St={ui:["suggested_replies","cta_button","message_template","csat"],trail:["groundedness","manual","function_calls"],unusedAsync:["is_hallucination","is_moderated","flagged_types","is_last_in_turn","flagged_reason","used_sources"]},Tt=`@${De}`,bn=({appId:e,aiAgentId:t,storage:n})=>{const r={templateBase:`${Tt}-template`,template:s=>`${r.templateBase}/templates/${s}`,templateToken:()=>`${r.templateBase}-template/message-template/tokens`,messengerSession:s=>{const a=Oo(`${e}/${t}/${s}`);return`${Tt}-udata/${a}`},anonUserSession:()=>`${Tt}-session/${e}/${t}`};return{template:{set:(s,a)=>n.set(r.template(s),a),get:s=>n.get(r.template(s)),setCachedToken:s=>n.set(r.templateToken(),s),getCachedToken:()=>n.get(r.templateToken()),clear:()=>{n.getKeys(r.templateBase).forEach(n.delete)}},messenger:{getSettings:s=>{try{const a=n.get(r.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(r.messengerSession(s),i)}catch{return}},getAnonUser:()=>{try{const s=n.get(r.anonUserSession());return s?JSON.parse(s):null}catch{return null}},setAnonUser:s=>{try{const a=JSON.stringify(s);n.set(r.anonUserSession(),a)}catch{return}},clear:s=>{try{s&&n.delete(r.messengerSession(s)),n.delete(r.anonUserSession())}catch{return}}}}};class er{constructor(t){B(this,"subscribers",{});this.logger=t}async send(t){const n=Ro(),r=this.subscribers[t.type];if(r){this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`,t.payload);const s=r.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(r=>r!==n))}}const Ro=()=>{let e=he,t=he;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}};var Kt=(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))(Kt||{});class tr{constructor(t){B(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${De}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${De}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${De}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${De}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${De}/error]`,...t)}}function En(e,t,n,r){const s=fo.default.init({appId:e,modules:[new at.GroupChannelModule,new V.AIAgentModule],localCacheEnabled:!0,options:new Z.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...r});return s.addSendbirdExtensions([{version:n,product:Z.SendbirdProduct.AI_AGENT,platform:t.platform}],{platform:t.deviceOSPlatform,version:t.deviceOSVersion},t.customData)||console.warn("Invalid Sendbird Extensions",t),s}function Do(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 Re={conversation:{isTalkToAgentViewEnabled:!0,input:{camera:{photoEnabled:!0},gallery:{photoEnabled:!0},fileEnabled:!0}}},Po=e=>{var t,n,r,s,a,i,l,u,d,f;return e?{...Re,...e,conversation:{...Re.conversation,...e==null?void 0:e.conversation,input:{...(t=Re.conversation)==null?void 0:t.input,...(n=e==null?void 0:e.conversation)==null?void 0:n.input,camera:{...(s=(r=Re.conversation)==null?void 0:r.input)==null?void 0:s.camera,...(i=(a=e==null?void 0:e.conversation)==null?void 0:a.input)==null?void 0:i.camera},gallery:{...(u=(l=Re.conversation)==null?void 0:l.input)==null?void 0:u.gallery,...(f=(d=e==null?void 0:e.conversation)==null?void 0:d.input)==null?void 0:f.gallery}}}}:Re},{Provider:No,useContext:W}=X("AIAgent");function Bo({appId:e,aiAgentId:t,keyValueStorage:n,networkStateAdapter:r,language:s,countryCode:a,context:i,queryParams:l,config:u,chatSDK:d,chatParams:f,children:b,logger:E,dispatcher:y,messengerVersion:x,extensions:v={platform:Z.SendbirdPlatform.JS,deviceOSPlatform:Lo()?Z.DeviceOsPlatform.MOBILE_WEB:Z.DeviceOsPlatform.WEB}}){const[p,h]=c.useState(()=>{const C=E??new tr(Kt.WARN),_=y??new er(C);return{logger:C,dispatcher:_,chatSDK:d??En(e,v,x,f),cache:bn({appId:e,aiAgentId:t,storage:n})}});return c.useEffect(()=>{h(C=>{let _=C.logger,w=C.dispatcher,S=C.chatSDK;return E&&E!==C.logger&&(_=E),y&&y!==C.dispatcher&&(w=y),d&&d!==C.chatSDK?S=d:!d&&C.chatSDK.appId!==e&&(S=En(e,v,x,{newInstance:!0,...f})),{...C,logger:_,dispatcher:w,chatSDK:S,cache:bn({appId:e,aiAgentId:t,storage:n})}})},[e,t,E,y,d,n]),c.useEffect(()=>()=>{p.chatSDK.disconnectWebSocket()},[p.chatSDK]),Do(p.chatSDK),o.createElement(No,{value:{...p,appId:e,aiAgentId:t,context:i,language:s,countryCode:a,queryParams:l,config:Po(u),networkStateAdapter:r}},b)}const Fo=(e,t,n)=>He.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var Rt=(e=>(e.ConversationClose="conv.close",e))(Rt||{});class Ho{constructor(t={}){B(this,"payload");this.payload=t}toJSON(){return JSON.stringify({type:this.type,payload:this.payload})}}const nr={CloseConversation:e=>new Uo(e)};class Uo extends Ho{constructor(){super(...arguments);B(this,"type","conv.close")}}const rr=(e,t,n={})=>{let r=null,s=null,a=null;const{leading:i=!0,trailing:l=!0}=n,u=(...d)=>{const f=Date.now();if(a===null||f-a>=t)i?(e(...d),a=f):(s=d,a=f);else if(s=d,l&&!r){const b=t-(f-a);r=setTimeout(()=>{s&&l&&(e(...s),a=Date.now()),r=null,s=null},b)}};return u.cancel=()=>{r&&(clearTimeout(r),r=null),s=null,a=null},u},We={DEFAULT_PRIMARY:"#000000",DEFAULT_BOT_MSG_BG:"#ECECEC",WHITE:"#ffffff",BLACK:"#000000"};function or(e){return e.length===4?`#${[...e.slice(1)].map(t=>t+t).join("")}`:e}function zo(e){const t=or(e);return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Vo(e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function Go(e,t,n){e/=255,t/=255,n/=255;const r=Math.max(e,t,n),s=Math.min(e,t,n),a=r-s;let i=0,l=0;const u=(r+s)/2;return r!==s&&(l=u>.5?a/(2-r-s):a/(r+s)),r===e?i=(t-n)/a+(t<n?6:0):r===t?i=(n-e)/a+2:r===n&&(i=(e-t)/a+4),i/=6,[i,l,u]}function Wo(e,t,n){let r,s,a;if(t===0)r=s=a=n;else{const i=function(f,b,E){return E<0&&(E+=1),E>1&&(E-=1),E<.16666666666666666?f+(b-f)*6*E:E<.5?b:E<.6666666666666666?f+(b-f)*(.6666666666666666-E)*6:f},l=n<.5?n*(1+t):n+t-n*t,u=2*n-l;r=i(u,l,e+1/3),s=i(u,l,e),a=i(u,l,e-1/3)}return[Math.round(r*255),Math.round(s*255),Math.round(a*255)]}function Je(e,t,n){const[r,s,a]=zo(e),[i,l,u]=Go(r,s,a),d=Math.max(0,Math.min(1,u*t)),f=Math.max(0,Math.min(1,l*n)),[b,E,y]=Wo(i,f,d);return Vo([Math.round(b),Math.round(E),Math.round(y)])}function qo(e,t="light"){return{extraDark:Je(e,.6,1.2),dark:Je(e,.85,1.1),main:e,light:Je(e,t==="dark"?1.1:1.5,t==="dark"?.95:.9),extraLight:Je(e,t==="dark"?1.2:1.75,t==="dark"?.9:.8)}}function Dt(e){const t=or(e),n=149,r=+`0x${t[1]}${t[2]}`,s=+`0x${t[3]}${t[4]}`,a=+`0x${t[5]}${t[6]}`;return r*.299+s*.587+a*.114>n?We.BLACK:We.WHITE}function jo(e,t,n,r,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:r},messageOutgoing:{text:n,background:t},csat:{background:e.background100}}}const Ko=(e,t,n,r,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:r},messageOutgoing:{text:n,background:t},csat:{background:e.background400}}),Qe={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)"}},At={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 xn(e){const t=Yo(e),{colors:n,aiAgentColorVariables:r}=Zo(e,t),s=Jo(e);return{selectedTheme:e.selectedTheme,palette:t,colors:n,aiAgentColorVariables:r,typography:s}}function Yo({selectedTheme:e,palette:t,primary:n}){const r=t!=null&&t.primary?t.primary:n?n===Qe.primary.main?Qe.primary:qo(n,e):Qe.primary;return{...Qe,primary:r,...t}}function Zo({selectedTheme:e,primaryContrast:t,botMessageBackground:n,botMessageBackgroundContrast:r},s){const a=s.primary.main,i=t??Dt(a),l=n??We.DEFAULT_BOT_MSG_BG,u=r??Dt(l);return{colors:(e==="light"?jo:Ko)(s,a,i,l,u),aiAgentColorVariables:{primary_color:a,bot_message_bg_color:l,primary_contrast_color:i,bot_message_bg_contrast_color:u}}}function Xo(e,t,n){const r={...e};return n.forEach(s=>{const a=t[s];a!=null&&(r[s]=a)}),r}function Jo({typography:e}){if(!e)return At;const t={...At};return Object.keys(e).forEach(n=>{const r=e[n];if(r&&typeof r=="object"){const s=At[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=Xo(s,r,a)}}),t}const{Provider:Qo,useContext:Yt}=X("AIAgentTheme");function es({logger:e,palette:t,typography:n,appearance:r,children:s}){const a=c.useRef(null),[i,l]=c.useState(()=>xn({selectedTheme:(r==null?void 0:r.theme)??"light",palette:t,typography:n,primary:r==null?void 0:r.primaryColor,botMessageBackground:r==null?void 0:r.botMessageBackgroundColor})),u=c.useCallback((d,f)=>{f&&(a.current=f);const b=(r==null?void 0:r.theme)??d,E=a.current?a.current.themes[b]:null,y={primary:r==null?void 0:r.primaryColor,primaryContrast:void 0,botMessageBackground:r==null?void 0:r.botMessageBackgroundColor,botMessageBackgroundContrast:void 0};!y.primary&&(E!=null&&E.primary_color)&&(y.primary=E.primary_color,y.primaryContrast=E.primary_contrast_color),!y.botMessageBackground&&(E!=null&&E.bot_message_bg_color)&&(y.botMessageBackground=E.bot_message_bg_color,y.botMessageBackgroundContrast=E.bot_message_bg_contrast_color);const x=xn({selectedTheme:b,palette:t,typography:n,...y});l(x),e==null||e.info("theme.update:",b)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor,t,n,e]);return c.useEffect(()=>{(r!=null&&r.theme||r!=null&&r.primaryColor||r!=null&&r.botMessageBackgroundColor)&&u(i.selectedTheme)},[r==null?void 0:r.theme,r==null?void 0:r.primaryColor,r==null?void 0:r.botMessageBackgroundColor]),o.createElement(Qo,{value:{theme:i,updateTheme:u}},s)}const vn=25*1024*1024,ts={off:"off",always:"always",handed_off_only:"handed_off_only"},ns=()=>{const[e,t]=c.useState(()=>({maxAttachmentCount:1,attachmentMode:"handed_off_only",defaultUploadSizeLimit:vn,uploadSizeLimitPerType:new Map,supportedImageMimeTypes:new Set(["image/png","image/jpeg","image/jpg"]),supportedFileMimeTypes:new Set(["application/pdf"])})),n=c.useCallback(({active_channel:s,upload_restriction:a})=>{const{maxAttachmentCount:i,attachmentMode:l,defaultUploadSizeLimit:u,supportedImageMimeTypes:d,supportedFileMimeTypes:f}=e;t({maxAttachmentCount:i,attachmentMode:ts[s.attachment_mode]??l,defaultUploadSizeLimit:(a==null?void 0:a.default_upload_size_limit)??u,uploadSizeLimitPerType:new Map(Object.entries((a==null?void 0:a.upload_size_limit_per_type)??[])),supportedImageMimeTypes:new Set((a==null?void 0:a.supported_image_mime_types)??d),supportedFileMimeTypes:new Set((a==null?void 0:a.supported_file_mime_types)??f)})},[]),r=c.useCallback(s=>{const{channel:a,uploadSizeLimit:i=vn}=s,l=(d=!0)=>a!=null&&a.isAIAgent?d?Ne(a):!1:!0,u=d=>{if(l())return e.defaultUploadSizeLimit??i;const f=e.defaultUploadSizeLimit??i,b=e.uploadSizeLimitPerType.get(d)??f;return Math.min(f,b)};return{maxAttachmentCount:e.maxAttachmentCount,isEnabled:()=>{if(l(!1))return!0;switch(e.attachmentMode){case"off":return!1;case"always":return!0;case"handed_off_only":return Ne(a);default:return!0}},get supportedMimeTypes(){return l()?[_o]:[...e.supportedImageMimeTypes,...e.supportedFileMimeTypes]},isSupportedMimeType:d=>l()?!0:e.supportedImageMimeTypes.has(d)||e.supportedFileMimeTypes.has(d),getUploadSizeLimit:u,getUploadSizeLimitInMB:d=>u(d)/(1024*1024)}},[e]);return{updateBaseAttachmentRules:n,createAttachmentRules:r}};function sr(){const{chatSDK:e,logger:t}=W();return c.useCallback(async n=>{if(n.userId===""){const r=new Error("userId cannot be empty string for messenger settings request");throw t.error("requestMessengerSettings: invalid userId",r),r}return await e.aiAgent.requestMessengerSettings(n)},[e,t])}function rs(){const{chatSDK:e,logger:t}=W(),n=c.useCallback(async(s,a,i)=>{if(t.debug("useChatConnection.connect: start, session",s.userId),a){const l=new Z.SessionHandler({...a,onSessionTokenRequired:os(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 u=l;if(e.isCacheEnabled){if(as(u))t.warn("useChatConnection.connect","offline connect restricted",u.message,u.code),t.warn("useChatConnection.connect","clear cached-data"),await e.clearCachedData().catch(d=>t.warn("useChatConnection.connect","clear cached-data failure",d));else if(e.currentUser)return t.debug("useChatConnection.connect: end (offline), currentUser",e.currentUser),e.currentUser}throw t.warn("useChatConnection.connect","connect failure",u.message,u.code),u}},[e,t]),r=c.useCallback(async()=>{t.debug("useChatConnection.disconnect: start"),await e.disconnect(),t.debug("useChatConnection.disconnect: end")},[e,t]);return{connect:n,disconnect:r}}function os(e,t){if(e)return async(n,r)=>{new Promise((s,a)=>e==null?void 0:e(s,a)).then(s=>{s&&(t==null||t(s)),n(s)}).catch(s=>{r(s)})}}const ss=[400300,400301,400302,400310];function as(e){return ss.some(t=>e.code===t)}class ar{constructor({userId:t,authToken:n,sessionHandler:r}){B(this,"userId");B(this,"authToken");B(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=r}}class Pt{constructor(){B(this,"userId");B(this,"authToken");B(this,"sessionHandler")}}const is=1440*60*1e3,ls=e=>{const{logger:t,cache:n}=W(),r=()=>{const a=n.messenger.getAnonUser();return a?a.expireAt-is<=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 Pt)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 c.useMemo(()=>e instanceof ar?{type:"manual",userSessionCandidate:s()}:e instanceof Pt?{type:"anonymous",userSessionCandidate:r()}: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:r()}):{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 cs({userSessionInfo:e,onUpdateMessengerSettings:t,onPreAuth:n,onPostAuth:r,onErrorAuth:s,onAuthTokenRefreshed:a,onPostDeauth:i,forceCreateChannel:l}){const{aiAgentId:u,language:d,context:f,countryCode:b,logger:E,cache:y}=W(),{connect:x,disconnect:v}=rs(),{type:p,userSessionCandidate:h}=ls(e),C=sr(),_=c.useCallback(async()=>{var L;E.debug("useAuthentication.authenticate: start");const S=h!=null&&h.userId?y.messenger.getSettings(h.userId):null;S!=null&&S.bot&&(t(S),E.debug("useAuthentication.authenticate: cached messenger settings",S));const k=await C({aiAgentId:u,userId:h==null?void 0:h.userId,language:d,country:b,context:f,forceCreateChannel:l,knownActiveChannelUrl:(L=S==null?void 0:S.active_channel)==null?void 0:L.channel_url});E.debug("useAuthentication.authenticate: messenger settings response",k);let I=null;if(k.auto_created_user)if(p==="manual")E.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:z,session_token:te,expire_at:K}=k.auto_created_user;y.messenger.setAnonUser({userId:z,authToken:te,expireAt:K}),I={userId:z,authToken:te}}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 x(I,h==null?void 0:h.sessionHandler,a),await r(k,I)}catch(z){throw z instanceof Error&&(s(z),E.error("useAuthentication.authenticate: failed to connect",z)),z}return k},[C,x,p,h==null?void 0:h.userId,h==null?void 0:h.sessionHandler,h==null?void 0:h.authToken,u,d,f,b,l,y.messenger.setAnonUser,y.messenger.getSettings,y.messenger.setSettings,t,n,r,s,a]),w=c.useCallback(async()=>{E.debug("useAuthentication.deauthenticate: start"),await v(),i(),E.debug("useAuthentication.deauthenticate: completed")},[v,E,i]);return{authenticate:_,deauthenticate:w,userSessionCandidate:h}}const ir=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)}},qe=e=>JSON.parse(e),mt=e=>JSON.parse(e);function us(e,t){const[n,r]=t.split(",").map(s=>s.trim());return e==="dark"&&r||n}function ds(e){const t={};function n(r,s=""){for(const[a,i]of Object.entries(r)){const l=s?`${s}.${a}`:a;i&&typeof i=="object"&&!Array.isArray(i)?n(i,l):t[l]=i}}return n(e),t}function Zt({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:r}){return Object.entries(t).reduce((s,[a,i])=>{if(!r&&!["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=r?r(i):String(i),u=n(a);return s.replace(u,ir(l))},e)}async function ms({template:e,variables:t,variableKeyPattern:n,variableValueTransformer:r}){return(await Promise.all(Object.entries(t).map(async([a,i])=>{const l=await r(i);return{regex:n(a),transformedValue:l}}))).reduce((a,{regex:i,transformedValue:l})=>a.replace(i,ir(l)),e)}const gs=()=>{const{chatSDK:e,logger:t,cache:n}=W(),r=c.useCallback(()=>{var l,u;const a=(u=(l=e.appInfo)==null?void 0:l.aiAgentInfo)==null?void 0:u.templateListToken;if(!a)return!1;const i=n.template.getCachedToken();return i?a!==i:!0},[e,n.template.getCachedToken]),s=c.useCallback(async()=>{try{const{templates:a,token:i}=await e.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:u}=qe(l);n.template.set(u,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:r,syncCachedTemplates:s}},{Provider:hs,useContext:gt}=X("AIAgentMessengerSession"),fs=c.forwardRef(function({userSessionInfo:e,forceCreateChannel:t,children:n},r){const{appId:s,aiAgentId:a,chatSDK:i,language:l,countryCode:u,context:d,cache:f,logger:b}=W(),{updateTheme:E}=Yt(),[y,x]=c.useState(void 0),[v,p]=c.useState(void 0),[h,C]=c.useState(null),[_,w]=c.useState(null),[S,k]=c.useState(null),[I,L]=c.useState(null),{updateBaseAttachmentRules:z,createAttachmentRules:te}=ns(),{shouldSyncCachedTemplate:K,syncCachedTemplates:ie}=gs(),oe=sr(),{authenticate:Ae,deauthenticate:we}=cs({userSessionInfo:e,forceCreateChannel:t,onUpdateMessengerSettings:c.useCallback(T=>{const{appearance:O,bot:N,launcher:G}=T;E(O.selected_theme,O),k({userId:N.bot_userid,profileUrl:N.bot_profile_url,nickname:N.bot_nickname,replyToFile:N.reply_to_file,specialNotice:N.special_notice,specialNoticeEnabled:N.is_special_notice_enabled,showHandoffButton:N.show_handoff_button??!0,isMultipleActiveConversationsEnabled:N.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:T.bot.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:T.bot.is_user_feedback_comment_option_enabled??!1}),L({type:G.image_type||"default_icon",imageUrl:G.image_url}),z(T)},[E]),onPreAuth:c.useCallback((T,O)=>{x(void 0),w(O)},[]),onPostAuth:c.useCallback(async T=>{C(i.currentUser),K()&&await ie(),p({url:T.active_channel.channel_url,status:V.ConversationStatus.OPEN})},[i,K,ie]),onErrorAuth:c.useCallback(T=>{x(T)},[]),onAuthTokenRefreshed:c.useCallback(T=>{w(O=>O?{...O,authToken:T}:null)},[]),onPostDeauth:c.useCallback(()=>{f.template.clear(),f.messenger.clear(_==null?void 0:_.userId),C(null),p(void 0),w(null),k(null),L(null)},[f.template.clear,f.messenger.clear,_])}),q=c.useCallback(async()=>{var T;if(_){b.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"),p(void 0);const O=await oe({aiAgentId:a,userId:_.userId,language:l,country:u,context:d,forceCreateChannel:t,knownActiveChannelUrl:(T=f.messenger.getSettings(_.userId))==null?void 0:T.active_channel.channel_url});return f.messenger.setSettings(_.userId,O),p({url:O.active_channel.channel_url,status:V.ConversationStatus.OPEN}),b.info("agentMessengerSession.refreshActiveChannel: refreshed active channel",O.active_channel.channel_url),O.active_channel.channel_url}else throw b.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[oe,s,a,_==null?void 0:_.userId,l,u,d,t,f.messenger.getSettings,f.messenger.setSettings]),$=c.useCallback(async T=>{if(!(_!=null&&_.userId))throw new Error("Current user is not authenticated. Please authenticate first.");const O=await oe({...T,userId:_.userId,knownActiveChannelUrl:void 0}),N=O.active_channel.channel_url;return f.messenger.setSettings(_.userId,O),N},[_==null?void 0:_.userId,oe]),[ee]=c.useState(()=>rr(T=>{var O;b.info("agentMessengerSession.channelChanged: channel.conversation",T.conversation),p({url:T.url,status:((O=T.conversation)==null?void 0:O.status)??V.ConversationStatus.OPEN})},250,{trailing:!1,leading:!0}));return He.useGroupChannelHandler(i,{onChannelChanged:T=>{T.isGroupChannel()&&T.url===(v==null?void 0:v.url)&&ee(T)}}),c.useEffect(()=>()=>{ee.cancel()},[ee]),c.useImperativeHandle(r,()=>{const T=async()=>{if(!v)throw new Error("No active conversation. Please start a conversation first.");return await i.groupChannel.getChannel(v.url)};return{activeChannel:v,chatSDK:i,authenticate:Ae,deauthenticate:we,updateContext:async O=>{const G=await(await T()).updateContext(a,O);return{...G,context:G.context??{}}},patchContext:async O=>{const G=await(await T()).patchContext(a,O);return{...G,context:G.context??{}}},getContextObject:async()=>{const N=await(await T()).getContextObject(a);return{...N,context:N.context??{}}}}},[Ae,we,v,i,a,b]),o.createElement(hs,{value:{sdkUser:h,userSessionInfo:e,userSession:_,activeChannel:v,setActiveChannel:p,refreshActiveChannel:q,createConversation:$,connectionError:y,aiAgentInfo:S,launcherInfo:I,authenticate:Ae,deauthenticate:we,createAttachmentRules:te}},n)}),ps=()=>{const e=c.useId(),{chatSDK:t,networkStateAdapter:n}=W(),[r,s]=c.useState(()=>n?n.isOnline()?"connected":"reconnecting":"connected");return c.useEffect(()=>{const a=new Z.ConnectionHandler({onDisconnected:()=>s("disconnected"),onConnected:()=>s("connected"),onReconnectStarted:()=>s("reconnecting"),onReconnectSucceeded:()=>s("connected"),onReconnectFailed:()=>s("disconnected")});return t.addConnectionHandler(e,a),()=>{t.removeConnectionHandler(e)}},[t,e]),c.useEffect(()=>{if(n)return n.subscribe(()=>{s("reconnecting")})},[n]),r},lr=e=>{const{chatSDK:t}=W(),[n,r]=c.useState([]);return He.useGroupChannelHandler(t,{onTypingStatusUpdated(s){if(s.url===(e==null?void 0:e.url)){const a=s.getTypingUsers();r(a)}}}),n},bs=({channel:e,messages:t,isStreamAnimating:n})=>{const{aiAgentInfo:r,userSession:s}=gt(),a=ps(),i=Es({channel:e,lastMessage:pn(t,[ye.SendingStatus.SUCCEEDED]),aiAgentUserId:(r==null?void 0:r.userId)??"",isStreamAnimating:n}),l=ys({shouldApply:!!(e!=null&&e.isAIAgent)&&!Ne(e),isDisabledWhileAIResponding:i,lastMessage:pn(t,[ye.SendingStatus.PENDING,ye.SendingStatus.SUCCEEDED]),currentUserId:(s==null?void 0:s.userId)??""});if(!e||a==="disconnected")return{disabled:!0,disabledBy:"unavailable"};if(a==="reconnecting")return{disabled:!0,disabledBy:"reconnecting"};if(_e(e))return{disabled:!0,disabledBy:"conversation_closed"};if(xs(e))return{disabled:!0,disabledBy:"form_active"};const u=vs(e);return u?{disabled:!0,disabledBy:u}:i||l?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},Es=({channel:e,lastMessage:t,aiAgentUserId:n,isStreamAnimating:r})=>{const[s,a]=c.useState(!1),i=lr(e);return c.useEffect(()=>{if(!t)return;const l=i.some(d=>d.userId===n),u=Be(t,n)&&(ge.isStreaming(t)||r);a(!!(u||l))},[i,t,n,r]),s},xs=e=>{var i;const t=e==null?void 0:e.lastMessage;if(!t||!e)return!1;const n=t.extendedMessagePayload,r=n==null?void 0:n.form,s=r&&!r.submitted_at&&!r.canceled_at,a=e.isAIAgent&&!!((i=e.conversation)!=null&&i.handedOverAt);return s&&!a},vs=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},Cs=3e4,ys=({shouldApply:e,lastMessage:t,isDisabledWhileAIResponding:n,currentUserId:r})=>{const[s,a]=c.useState(!1),i=c.useRef(null),l=t&&Be(t,r)?t.createdAt:0;return c.useEffect(()=>{const u=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},d=E=>{i.current&&clearTimeout(i.current),a(!0),i.current=setTimeout(()=>{a(!1),i.current=null},E)},f=Date.now()-l,b=Cs-f;return n||b<=0?u():d(b),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},_s=()=>{const[e,t]=c.useState(new Set),n=c.useCallback(s=>{t(a=>{if(a.has(s))return a;const i=new Set(a);return i.add(s),i})},[]),r=c.useCallback(s=>{t(a=>{if(!a.has(s))return a;const i=new Set(a);return i.delete(s),i})},[]);return{isAnimating:e.size>0,start:n,stop:r}},{Provider:Ss}=X("AIAgentConversation");function Ts({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:r,onMessagesUpdated:s,onConversationClosedViaDispatcher:a,onBeforeSendMessage:i,onAfterSendMessage:l=he,shouldMarkAsRead:u=!0,sortComparator:d}){var S;const f=()=>u&&(x==null?void 0:x.markAsRead()),{chatSDK:b,logger:E,dispatcher:y}=W(),{channel:x,channelFetchError:v,fetchChannel:p}=As(t),h=Fo(b,x,{replyType:ye.ReplyType.ONLY_REPLY_TO_CHANNEL,shouldCountNewMessages:()=>!1,onChannelDeleted:n,onMessagesReceived:k=>r==null?void 0:r(k),onMessagesUpdated:k=>s==null?void 0:s(k),logger:E,markAsRead:f,sortComparator:d}),C=_s(),_=bs({channel:x,messages:h.messages,isStreamAnimating:C.isAnimating});c.useEffect(()=>{f()},[u]),c.useEffect(()=>{const k=async I=>{const L=typeof(I==null?void 0:I.channelUrl)=="string";x&&L&&I.channelUrl!==x.url||(E.debug("conversation.dispatcher: try to close conversation",x),x!=null&&x.conversation&&x.conversation.status===V.ConversationStatus.OPEN&&(await x.closeConversation(),a==null||a()))};return y.subscribe(Rt.ConversationClose,k),()=>{y.unsubscribe(Rt.ConversationClose,k)}},[y,(S=x==null?void 0:x.conversation)==null?void 0:S.status,a]);const w={conversation:(x==null?void 0:x.conversation)??void 0,channelSource:{channel:x,error:v,refetch:()=>p(),closeConversation:async()=>{_e(x)||await(x==null?void 0:x.closeConversation())}},messageSource:{messages:h.messages,initialized:h.initialized,loadPrevious:()=>h.loadPrevious(),loadNext:()=>h.loadNext(),deleteMessage:k=>h.deleteMessage(k),resendMessage:k=>h.resendMessage(k),sendUserMessage:async k=>{var L;if(((L=x==null?void 0:x.conversation)==null?void 0:L.status)===V.ConversationStatus.CLOSED)throw new Error("Conversation is closed");i&&(k=await i(k));const I=await h.sendUserMessage(k,l);return l==null||l(I),I},sendFileMessage:async k=>{var L;if(((L=x==null?void 0:x.conversation)==null?void 0:L.status)===V.ConversationStatus.CLOSED)throw new Error("Conversation is closed");i&&(k=await i(k));const I=await h.sendFileMessage(k,l);return l==null||l(I),I}},state:{streamAnimation:C,input:_}};return o.createElement(Ss,{value:w},e)}function As(e){const{chatSDK:t,logger:n}=W(),{sdkUser:r}=gt(),[s,a]=c.useState(void 0),[i,l]=c.useState(void 0);async function u(){if(!r){n.debug("conversation.fetchChannel: no sdk user, skip fetching channel");return}if(n.debug("conversation.fetchChannel: start"),a(void 0),l(void 0),e)try{n.debug("conversation.fetchChannel: get channel",e);const d=await t.groupChannel.getChannel(e);a(d),n.debug("conversation.fetchChannel: fetched channel",d)}catch(d){d instanceof Z.SendbirdError&&l(d),n.error("conversation.fetchChannel: error",d)}}return ws(s),c.useEffect(()=>{u()},[t,r,e]),{channel:s,channelFetchError:i,fetchChannel:u}}function ws(e){const{chatSDK:t}=W(),{activeChannel:n,setActiveChannel:r}=gt(),s=c.useId();c.useEffect(()=>{if(!e||!n)return;const a=new Z.ConnectionHandler({onReconnectSucceeded:async()=>{var l;const i=await e.refresh();i.url===n.url&&r({url:i.url,status:((l=i.conversation)==null?void 0:l.status)??V.ConversationStatus.OPEN})}});return t.addConnectionHandler(s,a),()=>{t.removeConnectionHandler(s)}},[t,e,n])}class ks{constructor(t,{filter:n,limit:r=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",at.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");B(this,"_throttledOnChannelChanged");var s,a,i,l,u,d,f;this.filter=n,this._sdk=t,this._pinnedChannels=[],this._channels=[],this._limit=r,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:(u=this.filter)==null?void 0:u.pinnedChannelUrls,copilotConversationOnly:(d=this.filter)==null?void 0:d.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._throttledOnChannelChanged=rr(b=>{b.isGroupChannel()&&(this._query.belongsTo(b)?this._addChannelsToView([b],!1):this._removeChannelsFromView([b.url]))},250,{trailing:!1,leading:!0}),this._channelHandler=new at.GroupChannelHandler({onChannelChanged:this._throttledOnChannelChanged,onChannelDeleted:b=>{this._removeChannelsFromView([b])}}),this._connectionHandler=new Z.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)??[]),r=t.find(l=>!n.has(l.url));let s;r?s=((i=r.lastMessage)==null?void 0:i.createdAt)??r.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)??[],r=new Map(n.map((u,d)=>[u,d])),s=[],a=[],i=[];for(const u of t){if(!this._query.belongsTo(u)){i.push(u.url);continue}const d=r.get(u.url);if(d===void 0)continue;const f=Nt(this._pinnedChannels,u);f>=0?(this._pinnedChannels.splice(f,1),a.push(u)):s.push(u);const E=this._pinnedChannels.findIndex(x=>(r.get(x.url)??1/0)>d),y=E===-1?this._pinnedChannels.length:E;this._pinnedChannels.splice(y,0,u)}return{addedChannels:s,updatedChannels:a,unmatchedChannelUrls:i}}_upsertRegularChannelsToArray(t,n=!1){const r=[],s=[],a=[];for(const i of t){if(!this._query.belongsTo(i)){r.push(i.url);continue}const l=Nt(this._channels,i),u=l<0;!u&&this._channels.splice(l,1);const f=Is(this._channels,i,this._order).place,b=f===this._channels.length;u?b?(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:r}}_addChannelsToView(t,n=!1){var b,E,y,x,v;const r=new Set(((b=this.filter)==null?void 0:b.pinnedChannelUrls)??[]),s=[],a=[];for(const p of t)r.has(p.url)?s.push(p):a.push(p);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),u=i.addedChannels.concat(l.addedChannels),d=i.updatedChannels.concat(l.updatedChannels),f=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);u.length>0&&((y=(E=this._collectionEventHandler)==null?void 0:E.onChannelsAdded)==null||y.call(E,{},u)),d.length>0&&((v=(x=this._collectionEventHandler)==null?void 0:x.onChannelsUpdated)==null||v.call(x,{},d)),f.length>0&&this._removeChannelsFromView(f)}_removeChannelsFromView(t){var s,a,i;const n=new Set(((s=this.filter)==null?void 0:s.pinnedChannelUrls)??[]),r=[];for(const l of t)if(n.has(l)){const u=this._pinnedChannels.findIndex(d=>d.url===l);u>=0&&(r.push(l),this._pinnedChannels.splice(u,1))}else{const u=this._channels.findIndex(d=>d.url===l);u>=0&&(r.push(l),this._channels.splice(u,1))}r.length>0&&((i=(a=this._collectionEventHandler)==null?void 0:a.onChannelsDeleted)==null||i.call(a,{},r))}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._throttledOnChannelChanged.cancel(),this._collectionEventHandler=void 0,this._sdk.removeConnectionHandler(this._handlerId),this._sdk.groupChannel.removeGroupChannelHandler(this._handlerId),this._pinnedChannels.length=0,this._channels.length=0)}}const Nt=(e,t)=>e.findIndex(n=>n.isIdentical(t)),Is=(e,t,n)=>{if(e.length>0){const r=Nt(e,t);let s=0,a=e.length-1,i=Math.floor((s+a)/2);for(;s<a;){const u=Cn(e[i],t,n);if(u>0)a=i,i=Math.floor((s+a)/2);else if(u<0)s=i+1,i=Math.floor((s+a)/2);else return{place:i,oldPosition:r}}return{place:Cn(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Cn=(e,t,n)=>{switch(n){case at.GroupChannelListOrder.LATEST_LAST_MESSAGE:if(e.lastMessage&&t.lastMessage){const r=t.lastMessage.createdAt-e.lastMessage.createdAt;return r===0?t.createdAt-e.createdAt:r}else return e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;default:return 0}};function $s(e,t){var x,v,p,h,C,_,w,S,k,I;const n=c.useId(),[r,s]=c.useState(!1),[a,i]=c.useState(null),[l,u]=c.useState([]),[d,f]=c.useState(null),b=c.useRef(!1),E=c.useCallback(async()=>{if(!b.current&&e.currentUser){b.current=!0,s(!1),i(null),u([]);try{d==null||d.dispose();const L=new ks(e,t);L.setConversationListCollectionHandler({onChannelsAdded:()=>{u(L.channels)},onChannelsUpdated:()=>{u(L.channels)},onChannelsDeleted:()=>{u(L.channels)}}),await L.loadMore(),f(L),i(null)}catch(L){f(null),i(L)}finally{s(!0),b.current=!1}}},[e,e.currentUser,(x=t.filter)==null?void 0:x.aiAgentChannelFilter,(p=(v=t.filter)==null?void 0:v.aiAgentConversationStatusFilter)==null?void 0:p.join(),(C=(h=t.filter)==null?void 0:h.aiAgentIds)==null?void 0:C.join(),(_=t.filter)==null?void 0:_.deskChannelFilter,(S=(w=t.filter)==null?void 0:w.pinnedChannelUrls)==null?void 0:S.join(),(k=t.filter)==null?void 0:k.copilotConversationOnly,(I=t.filter)==null?void 0:I.copilotSupportChannelUrl,t.limit]),y=c.useCallback(async()=>{if(d)try{await d.loadMore()}catch(L){i(L)}},[d]);return c.useEffect(()=>(e.addConnectionHandler(n,new Z.ConnectionHandler({onConnected:()=>E()})),()=>e.removeConnectionHandler(n)),[e,n,E]),c.useEffect(()=>{E()},[E]),c.useEffect(()=>()=>{b.current=!1,d==null||d.dispose()},[d]),{initialized:r,error:a,channels:l,loadMore:y}}const{Provider:Ms}=X("AIAgentConversationList");function Ls({conversationListLimit:e,conversationListFilter:t,children:n}){var b,E;const{chatSDK:r,aiAgentId:s,queryParams:a}=W(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[V.ConversationStatus.CLOSED,V.ConversationStatus.OPEN]},l=e??((b=a==null?void 0:a.conversationListParams)==null?void 0:b.limit),u={...i,...(E=a==null?void 0:a.conversationListParams)==null?void 0:E.filter,...t},d=$s(r,{limit:l,filter:u}),f={listSource:{initialized:d.initialized,error:d.error??void 0,channels:d.channels,loadMore:()=>d.loadMore()}};return o.createElement(Ms,{value:f},n)}function Os(e){let t="pending",n=e.then(r=>{t="resolved",n=r}).catch(r=>{t="rejected",n=r});return{get value(){if(t==="resolved")return n;throw n}}}const{Provider:Rs,useContext:cr}=X("MessageTemplateFetching");function Ds({children:e,internalVariables:t}){const n=c.useRef({}),r=c.useRef({}),[s,a]=c.useState({}),i=c.useCallback((d,f)=>{a(b=>({...b,[d]:{fetching:!1,error:!1,...b[d],...f}}))},[]),l=c.useCallback(async({onRequestTemplate:d,onGetCachedTemplate:f,templateKey:b,suspense:E=!1})=>{const y=f(b);if(y)return y;const x=r.current[b];if(x)return x;E||i(b,{fetching:!0});const v=d(b).catch(p=>{throw E||i(b,{error:!0}),p}).finally(()=>{E||i(b,{fetching:!1}),delete r.current[b]});return r.current[b]=v,v},[i]),u={internalVariables:t,fetchTemplate:l,suspend:(d,f)=>{if(n.current[d])return n.current[d];const b=Os(f());return n.current[d]=b,b},getIsFetching:d=>{var f;return((f=s[d])==null?void 0:f.fetching)??!1},getHasError:d=>{var f;return((f=s[d])==null?void 0:f.error)??!1}};return o.createElement(Rs,{value:u},e)}const ht={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function Se({uiTemplateString:e,variables:t={}}){const n=ds(t);return Zt({template:e,variables:n,variableKeyPattern:r=>ht.VARIABLE(r)})}function Te({theme:e,uiTemplateString:t,colorVariables:n={}}){return Zt({template:t,variables:n,variableKeyPattern:r=>ht.VARIABLE(r),variableValueTransformer:r=>us(e,r)})}function Ps({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(d=>d.key);return[...new Set(l)].some(d=>!a(d))?null:Zt({template:t,variables:n,variableKeyPattern:d=>ht.VIEW_VARIABLE(d),variableValueTransformer:d=>{const f=d.map(({key:b,variables:E})=>{const y=a(b),{ui_template:x,color_variables:v}=qe(y);let p=JSON.stringify(x);return p=Se({uiTemplateString:p,variables:s}),p=Te({theme:e,uiTemplateString:p,colorVariables:v}),p=Te({theme:e,uiTemplateString:p,colorVariables:r}),p=Se({uiTemplateString:p,variables:E}),mt(p)});return JSON.stringify(f)}})}async function Ns({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){return ms({template:t,variables:n,variableKeyPattern:i=>ht.VIEW_VARIABLE(i),variableValueTransformer:async i=>{const l=i.map(async({key:d,variables:f})=>{const b=await a(d),{ui_template:E,color_variables:y}=qe(b);let x=JSON.stringify(E);return x=Se({uiTemplateString:x,variables:s}),x=Te({theme:e,uiTemplateString:x,colorVariables:y}),x=Te({theme:e,uiTemplateString:x,colorVariables:r}),x=Se({uiTemplateString:x,variables:f}),mt(x)}),u=await Promise.all(l);return JSON.stringify(u)}})}const Bs=({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=qe(e);let i=JSON.stringify(s);if(Object.keys(r.viewVariables??{}).length>0){const u=Ps({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(u===null)return null;i=u}return i=Se({...r,uiTemplateString:i,variables:n}),i=Te({...r,uiTemplateString:i,colorVariables:a}),i=Te({...r,uiTemplateString:i,colorVariables:t}),i=Se({...r,uiTemplateString:i}),mt(i)},Fs=async({rawTemplate:e,aiAgentColorVariables:t,internalVariables:n,...r})=>{const{ui_template:s,color_variables:a}=qe(e);let i=JSON.stringify(s);return Object.keys(r.viewVariables??{}).length>0&&(i=await Ns({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=Se({...r,uiTemplateString:i,variables:n}),i=Te({...r,uiTemplateString:i,colorVariables:a}),i=Te({...r,uiTemplateString:i,colorVariables:t}),i=Se({...r,uiTemplateString:i}),mt(i)},Hs=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=cr();return c.useState(()=>{const r=e.onGetCachedTemplate(e.templateKey);return r?Bs({...e,rawTemplate:r,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Us=e=>{const[t]=Hs(e);if(t)return t;const{aiAgentColorVariables:n={}}=e,{internalVariables:r,fetchTemplate:s,suspend:a}=cr();return a(e.templateKey,async()=>{const l=await s({...e,suspense:!0});return await Fs({...e,rawTemplate:l,aiAgentColorVariables:n,internalVariables:r})}).value},zs="remove_powered_by",Xt=(e,t)=>{var s,a;const{chatSDK:n}=W(),{aiAgentInfo:r}=gt();if(e==="handoff-button"){const i=!!((s=t==null?void 0:t.conversation)!=null&&s.handoff);return!!(t!=null&&t.isAIAgent)&&!!(r!=null&&r.showHandoffButton)&&i&&Wt(t)}if(e==="special-notice")return!!(t!=null&&t.isAIAgent)&&!!(r!=null&&r.specialNoticeEnabled)&&!!(r!=null&&r.specialNotice);if(e==="powered-by"){const i=(a=n==null?void 0:n.appInfo)==null?void 0:a.applicationAttributes;return c.useMemo(()=>!(Array.isArray(i)&&i.includes(zs)),[i])}throw new Error("Unsupported feature")},Vs={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"},Gs={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;if(e.required&&(!r||r.trim()===""))return{isValid:!1,error:n.required};if(!r)return{isValid:!0};const{rules:s}=e;if(s){if(s.min_length!==void 0&&r.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&&r.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(r))return{isValid:!1,error:n.regex}}return{isValid:!0}}},Ws={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;if(e.required&&r===null)return{isValid:!1,error:n.required};if(r===null)return{isValid:!0};const{rules:s}=e;if(s){if(s.min!==void 0&&r<s.min)return{isValid:!1,error:typeof n.min=="function"?n.min(s.min):n.min};if(s.max!==void 0&&r>s.max)return{isValid:!1,error:typeof n.max=="function"?n.max(s.max):n.max}}return{isValid:!0}}},qs={getValueOrDefault:e=>e.value??e.default_value??null,validate:(e,t,n)=>{const r=t;return e.required&&!r?{isValid:!1,error:n.required}:r&&!e.options.includes(r)?{isValid:!1,error:n.invalidSelection}:{isValid:!0}}},js={getValueOrDefault:e=>e.values??e.default_values??null,validate:(e,t,n)=>{const r=t;if(e.required&&(!r||r.length===0))return{isValid:!1,error:n.required};if(!r||r.length===0)return{isValid:!0};if(r.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&&r.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&&r.length>a.max_select)return{isValid:!1,error:typeof n.maxSelect=="function"?n.maxSelect(a.max_select):n.maxSelect}}return{isValid:!0}}},Ks={text:Gs,number:Ws,"single-select":qs,"multi-select":js},Ys={getValueOrDefault:()=>null,validate:()=>({isValid:!1})};function ur(e){return Ks[e.type]||Ys}function yn(e){return ur(e).getValueOrDefault(e)}function Zs(e,t,n={}){const r={...Vs,...n};return ur(e).validate(e,t,r)}const Xs=(e,t={})=>{const{labels:n={},onSubmit:r,onCancel:s}=t,[a,i]=c.useState({}),[l,u]=c.useState(()=>{const v={};return e.fields.forEach(p=>{v[p.key]=yn(p)}),v}),d=c.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);c.useEffect(()=>{if(d==="submitted"||d==="canceled"){const v={};let p=!1;e.fields.forEach(h=>{const C=yn(h);JSON.stringify(l[h.key])!==JSON.stringify(C)&&(p=!0),v[h.key]=C}),p&&u(v)}},[d]);const f=(v,p)=>{u(h=>({...h,[v]:p})),i(h=>({...h,[v]:void 0}))},b=e.fields.map(v=>{var C,_,w;const p=l[v.key]??null,h={key:v.key,label:v.label,error:a[v.key],required:v.required};return v.type==="text"?{...h,type:"text",layout:v.layout,value:p,...v.placeholder&&{placeholder:v.placeholder},...((C=v.rules)==null?void 0:C.max_length)&&{maxLength:v.rules.max_length}}:v.type==="number"?{...h,type:"number",layout:v.layout,value:p,...v.placeholder&&{placeholder:v.placeholder},...((_=v.rules)==null?void 0:_.max)&&{max:v.rules.max}}:v.type==="single-select"?{...h,type:"single-select",layout:v.layout,value:p,options:v.options}:v.type==="multi-select"?{...h,type:"multi-select",layout:v.layout,value:p,options:v.options,...((w=v.rules)==null?void 0:w.max_select)&&{maxSelect:v.rules.max_select}}:{...h,type:"unknown",layout:"default",value:null}});return{state:d,fields:b,getField:v=>b.find(p=>p.key===v),updateFieldValue:f,submit:async()=>{const v={};let p=!1;for(const h of e.fields){const C=l[h.key]??null,_=Zs(h,C,n);_.isValid||(v[h.key]=_.error,p=!0)}if(i(v),!p&&r){const h={};e.fields.forEach(C=>{h[C.key]=l[C.key]??null}),await r(h)}},cancel:async()=>{await(s==null?void 0:s())}}},dr=({channel:e,userSession:t,aiAgentInfo:n})=>{if(!t||!n||!e)return{fallbackIcon:"delight",url:void 0,title:""};const r=(()=>{const[a]=e.members.filter(i=>i.userId!==t.userId);return a})(),s={ai(a){return{fallbackIcon:a,url:n.profileUrl,title:n.nickname}},human(a){return{fallbackIcon:a,url:r==null?void 0:r.profileUrl,title:(r==null?void 0:r.nickname)||n.nickname}},channel(a){return{fallbackIcon:a,url:e==null?void 0:e.coverUrl,title:(e==null?void 0:e.name)??""}}};return e.isAIAgent?Ne(e)?s.human("agent"):s.ai("delight"):e.isDesk?s.human("agent"):s.channel("user")},_n=e=>c.useReducer((t,n)=>({...t,...n}),e);var se=(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))(se||{});const Js=new Set(["free_text","single_choice"]),Qs=({csatPayload:e,type:t,initialCsat:n,initialCsatReason:r,initialIsResolved:s})=>{const[a,i]=_n({csatType:t,csat:n,csatReason:r,isResolved:s}),[l,u]=_n({followUpItem:!1}),d=c.useMemo(()=>{var v;const y=a.csat;if(typeof y!="number")return;const x=(v=e.follow_up)==null?void 0:v.find(p=>p.scores.includes(y));if(Js.has(x==null?void 0:x.response_type))return x},[a.csat,e.follow_up]),f=(()=>{var y;if(typeof n=="number")return"submitted";if((t===se.AI_AGENT_CSAT_5||t===se.HELPDESK_CSAT_5)&&typeof a.csat=="number")return"submittable";if(t===se.AI_AGENT_CSAT_5_WITH_CRE){const x=typeof a.csat=="number",v=!((y=e.cre)!=null&&y.required)||typeof a.isResolved=="boolean";if(x&&v)return"submittable"}return"unsubmittable"})(),b=c.useCallback(()=>typeof a.csat>"u"?!1:d!=null&&d.required&&!a.csatReason?(u({followUpItem:!0}),!1):!0,[a,d,u]);return c.useEffect(()=>{r||(i({csatReason:""}),u({followUpItem:!1}))},[r,d,i,u]),{params:a,setParams:i,error:l,setError:u,followUpItem:d,state:f,validateParams:b,itemProps:{csatPayload:e,state:f,submitted:f==="submitted"}}},wt=5,ea=50,Sn=e=>Math.max(0,e-ea),ta=e=>e<1e3?{speed:wt*.5,chunkSize:2}:e<2e3?{speed:wt*.8,chunkSize:2}:{speed:wt*.6,chunkSize:3},na=e=>{const{text:t,enabled:n=!1,onAnimationStart:r,onAnimationComplete:s}=e,[a,i]=c.useState(()=>Sn(t.length)),l=c.useRef(null),u=c.useRef(0),d=c.useRef(0),f=c.useRef(n),b=c.useRef(r),E=c.useRef(s),y=c.useRef(!1),x=c.useRef(!1),v=c.useRef(t.length),p=c.useRef(n),h=n,C=a<t.length,_=f.current&&(h||C);return c.useLayoutEffect(()=>{b.current=r,E.current=s,v.current=t.length,p.current=n}),c.useLayoutEffect(()=>{var w;f.current&&(y.current||(y.current=!0,(w=b.current)==null||w.call(b)),i(S=>t.length<S?t.length:S))},[t]),c.useEffect(()=>{if(!f.current)return;let w=Sn(t.length);u.current=0,d.current=0;const S=k=>{u.current===0&&(u.current=k,d.current=k);const I=v.current,L=k-u.current,z=k-d.current,{speed:te,chunkSize:K}=ta(z),ie=te*K;L>=ie&&w<I&&(w=Math.min(w+K,I),i(w),u.current=k),(w<I||p.current)&&(l.current=requestAnimationFrame(S))};return l.current=requestAnimationFrame(S),()=>{l.current&&cancelAnimationFrame(l.current)}},[]),c.useEffect(()=>{var I;const w=f.current&&y.current,S=!n,k=a>=t.length&&t.length>0;w&&S&&k&&!x.current&&(x.current=!0,(I=E.current)==null||I.call(E))},[n,a,t.length]),{streamText:f.current?t.slice(0,a):t,isAnimating:_}},ra='@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}',oa={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.",input_placeholder_reconnecting:"Trying to reconnect. Refresh if persists.",unknown_message_type:"(Unknown message type)",powered_by:"Powered by",citation_title:"Source",start_new_conversation_label:"Start a conversation",failed_message_resend:"Retry",failed_message_remove:"Remove",file_upload_no_supported_files:"No supported file types available.",a11y_message_list:"Chat messages",a11y_scroll_to_bottom:"Scroll to bottom"},conversation_list:{header_title:"Conversations",ended:"Ended",footer_title:"Start a conversation"},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"},feedback:{title:"Submit feedback",good:"Good",bad:"Bad",comment_label:"Comment (optional)",comment_placeholder:"Leave a comment",cancel:"Cancel",submit:"Submit",save:"Save",edit:"Edit feedback",remove:"Remove feedback"}},Bt={language:"en",strings:oa,dateLocale:io.enUS},mr=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,MESSAGE_INPUT__PLACE_HOLDER__RECONNECTING:e.conversation.input_placeholder_reconnecting,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,FILE_UPLOAD_NO_SUPPORTED_FILES:e.conversation.file_upload_no_supported_files,FEEDBACK_TITLE:e.feedback.title,FEEDBACK_GOOD:e.feedback.good,FEEDBACK_BAD:e.feedback.bad,FEEDBACK_COMMENT_LABEL:e.feedback.comment_label,FEEDBACK_COMMENT_PLACEHOLDER:e.feedback.comment_placeholder,FEEDBACK_CANCEL:e.feedback.cancel,FEEDBACK_SUBMIT:e.feedback.submit,FEEDBACK_SAVE:e.feedback.save,FEEDBACK_EDIT:e.feedback.edit,FEEDBACK_REMOVE:e.feedback.remove,A11Y_MESSAGE_LIST:e.conversation.a11y_message_list,A11Y_SCROLL_TO_BOTTOM:e.conversation.a11y_scroll_to_bottom}),sa=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??ft},ft="en",aa=new Set([ft,"ko","es","pt","fr","hi","it","de","tr","ja"]),ia=(e,t,n)=>{const r=e[t];return r?typeof r=="function"?r():Promise.resolve(r):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.":""))))})},Tn=mr(Bt.strings),la={...Tn,HEADER_BUTTON__AGENT_HANDOFF:"Connect with an agent",MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES:"Select an option to continue",BUTTON__CANCEL:"Cancel",BUTTON__SUBMIT:"Submit",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",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",DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE:Tn.DATE_FORMAT__DATE_SHORT,DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION:"h:mma",CONVERSATION_LIST__TOPICS_FALLBACK:"No category",CONVERSATION_CLOSED_FOOTER_LABEL:"Your conversation has ended",START_NEW_CONVERSATION:"💬 Start a new conversation",RETURN_TO_CONVERSATION:"💬 Return to conversation",BUTTON__SAVE:"Save",BUTTON__OK:"OK",NO_NAME:"(No name)",CHANNEL_FROZEN:"Channel frozen"},it={language:Bt.language,dateLocale:Bt.dateLocale,stringSet:la},ca=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"})),Ft=new Map([[ft,it]]);async function ua(e){const t=Ft.get(e);if(t)return t;try{if(aa.has(e)){const{default:n}=await ia(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./BKGUMAll.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>ca),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./BMWSkFPd.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./CshEwefQ.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./VMkpPP3I.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./HGTRpnXG.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./DDZcs_TL.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./D2b9Fh2D.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./BBDXgVHP.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./h90fKnkA.cjs"))}),`./languages/${e}.ts`,3);return Ft.set(e,n),n}return it}catch{return it}}const{Provider:da,useContext:F}=X("Localization"),ma=({language:e=navigator.language,logger:t,stringSet:n,children:r})=>{const[s,a]=c.useState(Ft.get(ft));return c.useEffect(()=>{const i=sa(e);s.language!==i&&(t==null||t.debug("localization.useEffect: update language",{from:s.language,to:i}),ua(i).then(a))},[e,t]),o.createElement(da,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,u)=>Ce.format(i,l,{locale:s.dateLocale,...u})}},r)},lt="data-sb-agent-theme",An=e=>(t,...n)=>{let r="";return t.forEach((s,a)=>{r+=s+(n[a]??"")}),`[${lt}='${e}'] & { ${r} }`},R={light:An("light"),dark:An("dark")},ga=A.css(({theme:e})=>{const{palette:t}=e;return`
|
|
2
2
|
:root,
|
|
3
3
|
:host {
|
|
4
4
|
--sendbird-primary-extra-dark: ${t.primary.extraDark};
|
|
@@ -47,25 +47,25 @@
|
|
|
47
47
|
--sendbird-overlay-dark: ${t.overlay.dark};
|
|
48
48
|
--sendbird-overlay-light: ${t.overlay.light};
|
|
49
49
|
}
|
|
50
|
-
`}),
|
|
50
|
+
`}),ha=A.css`[${lt}='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);}[${lt}='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);}`,m={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:fa,useContext:gr}=X("MessengerTheme");function pa(e){const{theme:t,appearance:n,logger:r}=e;return o.createElement(es,{appearance:n,palette:t==null?void 0:t.palette,typography:t==null?void 0:t.typography,logger:r},o.createElement(ba,{...e}))}function ba({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:r}=Yt();return c.useLayoutEffect(()=>{e.setAttribute(lt,n.selectedTheme)},[e,n.selectedTheme]),o.createElement(A.ThemeProvider,{theme:n},o.createElement(fa,{value:{theme:n,updateTheme:r,rootElement:e}},t))}function ke(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const Ea=(e,t)=>{c.useEffect(()=>{const n=ke(t)instanceof ShadowRoot,r=ke(t,!0);if(!(n?t:r).querySelector(`link[href*='${e}']`)){const a=r.createElement("link");a.rel="stylesheet",a.href=e,(n?t:r.head).appendChild(a)}},[e,t])},xa=(e,t=document.body)=>{c.useEffect(()=>{const n=ke(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])},{Provider:va,Consumer:hr,useContext:U}=X("Messenger");function Ca({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:r=!0,enableAutoDisconnectInLauncher:s=!0,...a}){const[i,l]=c.useState(!1),[u,d]=c.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)??u,setExpanded:(t==null?void 0:t.setExpanded)??d};return o.createElement(Bo,{...a},b=>o.createElement(va,{value:{...a,...b,state:f,enableCloseConversationButton:n,enableExpandButton:r,enableAutoDisconnectInLauncher:s}},e))}const ae=e=>{const t=e;return typeof t=="number"?`${t}px`:t},M=({as:e,variant:t="body1",color:n,maxTextLines:r,className:s,...a})=>o.createElement(Sa,{as:e,$variant:t,className:s,$color:n,$maxTextLines:r,...a}),wn=new WeakMap,ya=(e,t)=>{let n=wn.get(t);n||(n=new Map,wn.set(t,n));const r=n.get(e);if(r)return r;const s=t[e]??t.body1,a=A.css`font-size:${ae(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
|
|
51
51
|
${s.lineHeight?`line-height: ${s.lineHeight};`:"line-height: 100%;"}
|
|
52
|
-
`;return n.set(e,a),a},
|
|
52
|
+
`;return n.set(e,a),a},_a=e=>e?A.css`display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:${e};overflow:hidden;`:"",Sa=g.default.span`font-stretch:normal;letter-spacing:normal;${({$variant:e,theme:t})=>ya(e,t.typography)}color:${({$color:e})=>e};${({$maxTextLines:e})=>_a(e)}`;class ct extends c.PureComponent{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{fallback:t=null,errorFallback:n=t,loadingFallback:r=t,children:s}=this.props;return this.state.hasError?n:o.createElement(c.Suspense,{fallback:r},s)}}const Ta=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",...e},o.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"})),Aa=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",...e},o.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"})),wa=e=>o.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},o.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"})),ka=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",fill:"evenodd",...e},o.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"})),Ia=e=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",...e},o.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"]),Ma={close:Ta,send:Ia,menu:ka,expand:wa,collapse:Aa,spinner:c.lazy(()=>Promise.resolve().then(()=>require("./Cf3-irI8.cjs"))),chat:c.lazy(()=>Promise.resolve().then(()=>require("./BmdfYY9c.cjs"))),message:c.lazy(()=>Promise.resolve().then(()=>require("./CmWLVNPR.cjs"))),error:c.lazy(()=>Promise.resolve().then(()=>require("./DNmdC4-j.cjs"))),info:c.lazy(()=>Promise.resolve().then(()=>require("./ohTjxqcW.cjs"))),refresh:c.lazy(()=>Promise.resolve().then(()=>require("./D00MOxhE.cjs"))),"chevron-down":c.lazy(()=>Promise.resolve().then(()=>require("./wf-LdaaN.cjs"))),"chevron-right":c.lazy(()=>Promise.resolve().then(()=>require("./B0k-GApQ.cjs"))),done:c.lazy(()=>Promise.resolve().then(()=>require("./kp5wcW4s.cjs"))),user:c.lazy(()=>Promise.resolve().then(()=>require("./CtHfgPDp.cjs"))),"file-document":c.lazy(()=>Promise.resolve().then(()=>require("./_YfLwFkX.cjs"))),download:c.lazy(()=>Promise.resolve().then(()=>require("./BN09c8-A.cjs"))),attach:c.lazy(()=>Promise.resolve().then(()=>require("./DcDTXo8_.cjs"))),delete:c.lazy(()=>Promise.resolve().then(()=>require("./CKPzhVy2.cjs"))),"close-filled":c.lazy(()=>Promise.resolve().then(()=>require("./D1kINslt.cjs"))),agent:c.lazy(()=>Promise.resolve().then(()=>require("./Ce1MzjFq.cjs"))),question:c.lazy(()=>Promise.resolve().then(()=>require("./JA0x62Fd.cjs"))),actionbook:c.lazy(()=>Promise.resolve().then(()=>require("./CXa-CGHE.cjs"))),function:c.lazy(()=>Promise.resolve().then(()=>require("./zbLY6xl_.cjs"))),"radio-on":c.lazy(()=>Promise.resolve().then(()=>require("./B9NJk4MI.cjs"))),"radio-off":c.lazy(()=>Promise.resolve().then(()=>require("./Bb0r6Nhu.cjs"))),confluence:c.lazy(()=>Promise.resolve().then(()=>require("./c6TZaE94.cjs"))),zendesk:c.lazy(()=>Promise.resolve().then(()=>require("./DqpDy_26.cjs"))),salesforce:c.lazy(()=>Promise.resolve().then(()=>require("./BsgzT_SF.cjs"))),sprinklr:c.lazy(()=>Promise.resolve().then(()=>require("./D97ZpKUC.cjs"))),website:c.lazy(()=>Promise.resolve().then(()=>require("./ygZY2D-5.cjs"))),snippet:c.lazy(()=>Promise.resolve().then(()=>require("./BCFOnu0u.cjs"))),template:c.lazy(()=>Promise.resolve().then(()=>require("./eJXfXI1_.cjs"))),source:c.lazy(()=>Promise.resolve().then(()=>require("./yVmX6iux.cjs"))),bot:c.lazy(()=>Promise.resolve().then(()=>require("./PhHbzZB_.cjs"))),"bot-filled":c.lazy(()=>Promise.resolve().then(()=>require("./DlvMdI1f.cjs"))),copy:c.lazy(()=>Promise.resolve().then(()=>require("./COgkkyBM.cjs"))),show:c.lazy(()=>Promise.resolve().then(()=>require("./DM-WWpci.cjs"))),mute:c.lazy(()=>Promise.resolve().then(()=>require("./P_ra76fq.cjs"))),good:c.lazy(()=>Promise.resolve().then(()=>require("./DEgUVAck.cjs"))),bad:c.lazy(()=>Promise.resolve().then(()=>require("./C0s7eAf7.cjs"))),"good-filled":c.lazy(()=>Promise.resolve().then(()=>require("./Chg8xHXT.cjs"))),"bad-filled":c.lazy(()=>Promise.resolve().then(()=>require("./CGkmTaBn.cjs"))),delight:c.lazy(()=>Promise.resolve().then(()=>require("./DCB0iTxd.cjs")))},D=({type:e,size:t=24,className:n,color:r})=>{const s=Ma[e];return o.createElement(Oa,{className:n,$rtlFlip:$a.has(e),$size:t,$color:r??m.color.primary.main},o.createElement(ct,{errorFallback:o.createElement(Ra,null)},o.createElement(s,null)))},La=A.css`[dir='rtl'] &{transform:scaleX(-1);}`,Oa=g.default.div`width:${({$size:e})=>ae(e)};height:${({$size:e})=>ae(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&&La};`,Ra=()=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64"},o.createElement("rect",{x:"8",y:"8",width:"48",height:"48",fill:"none",className:"stroke",rx:"4"}),o.createElement("line",{x1:"20",y1:"20",x2:"44",y2:"44",className:"stroke"}),o.createElement("line",{x1:"44",y1:"20",x2:"20",y2:"44",className:"stroke"}));function Jt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:r,onClick:s}){const{colors:a}=A.useTheme();return o.createElement(Da,{onClick:s,$clickable:!!s},o.createElement(Na,{$bgColor:r??a.base.primary},o.createElement(D,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),o.createElement(Ba,null,o.createElement(Fa,{variant:"button",color:m.themedColor.textHighEmphasis},e),o.createElement(M,{color:m.themedColor.textMidEmphasis,variant:"caption3"},t)))}const Da=g.default.div`border-radius:12px;gap:8px;width:${P.BODY_MAX_WIDTH}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};${({$clickable:e})=>e&&Pa}`,Pa=A.css`cursor:pointer;&:hover{background-color:${m.themedColor.bg_100_500};}`,Na=g.default.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Ba=g.default.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,Fa=g.default(M)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function Ha({file:e,children:t,onClickFile:n}){return o.createElement(Ua,null,o.createElement(Jt,{name:e.name,type:qt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const Ua=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${P.GAP_GROUPED}px;`,za="1.10.3",ne="sb-agent",re={ENTRY:`${ne}-entry`,MODAL_ROOT:`${ne}-modal-root`,WINDOW:`${ne}-window`,LAUNCHER:`${ne}-launcher`},et=2147483647,$e={MODAL:et-1,TOOLTIP:et-2,WINDOW:et-3,LAUNCHER:et-4},fr=36,Va=100,Ga=za,pt="noopener noreferrer nofollow",pe=`${ne}-incoming-msg`,Wa=`${ne}-marked-text`;function qa({file:e,onClickMedia:t,children:n}){const r=()=>e.type.startsWith("image")?o.createElement(Ya,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?o.createElement(Za,{controls:!0},o.createElement("source",{src:e.url}),o.createElement("track",{kind:"captions"})):null;if(r){const s={id:`${pe}-media-body`,onClick:()=>t==null?void 0:t(e)};return o.createElement(ja,null,o.createElement(Ka,{...s},r()),n)}return null}const ja=g.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${P.GAP_GROUPED}px;`,Ka=g.default.div`width:${P.BODY_MAX_WIDTH}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${R.light`
|
|
53
53
|
background-color: ${m.color.background100};
|
|
54
54
|
`}
|
|
55
55
|
${R.dark`
|
|
56
56
|
background-color: ${m.color.background400};
|
|
57
57
|
`}
|
|
58
|
-
`,
|
|
58
|
+
`,Ya=g.default.img`width:100%;height:100%;object-fit:cover;`,Za=g.default.video`width:100%;height:100%;object-fit:cover;`,Xa="✱",pr=e=>{const t=new RegExp(`(\`+)([^\`]+?)\\1|(${Xa}+)`,"g");return e.replace(t,(n,r,s,a)=>r?n:a?`<span id=${Wa} aria-label="masked-text">${a}</span>`:n)},Ja=e=>e.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"),Qa=c.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./Lt9QbwOc.cjs"))).MarkdownText})),ei=c.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./DlvEEpWX.cjs"))).CodeBlock}));function kn(e){var s,a;const t=e.maxBodyWidth??P.BODY_MAX_WIDTH,n=c.useMemo(()=>Ao(e.message,pr),[e.message]),r={id:`${pe}-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?o.createElement(In,{...r},e.children):null:o.createElement(In,{...r},n.map((i,l)=>i.type==="text"?o.createElement($n,{key:l,variant:"body3"},o.createElement(ct,{fallback:i.value},o.createElement(Qa,{onClickImage:u=>{var d;return(d=e.onClickMedia)==null?void 0:d.call(e,{url:u,type:"image/*"})}},i.value))):i.type==="code"?o.createElement(ct,{key:l,fallback:o.createElement($n,{variant:"body3"},i.value)},o.createElement(ei,{code:i.value,language:i.language})):null),e.children)}const In=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})=>A.css`
|
|
59
59
|
color: ${t||e.colors.messageIncoming.text};
|
|
60
60
|
background-color: ${n||e.colors.messageIncoming.background};
|
|
61
61
|
`}
|
|
62
62
|
padding: 12px 0;
|
|
63
63
|
transition: max-width 0.3s;
|
|
64
64
|
overflow-wrap: break-word;
|
|
65
|
-
`,$n=
|
|
65
|
+
`,$n=g.default(M)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ti(e){const{stringSet:t}=F(),n=Qn(e)?o.createElement(kn,{...e}):null;if(e.messageType==="user")return n;if(e.messageType==="file"){const r=e.file;return r.type.startsWith("image")||r.type.startsWith("video")?o.createElement(qa,{...e},n):o.createElement(Ha,{...e},n)}return o.createElement(kn,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}function Qt({id:e,src:t,size:n=56,onClick:r,style:s}){return o.createElement(ni,{id:e,tabIndex:0,onClick:r,$size:ae(n),style:s},t?o.createElement(ri,{src:t}):o.createElement(D,{type:"user",size:n}))}const ni=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:${m.themedColor.bg_100_500};&:focus{outline:none;}`,ri=g.default.img`object-fit:cover;width:100%;height:100%;position:absolute;`;function oi({sender:e,isBotMessage:t}){const n=`${pe}-sender-avatar`;return t&&!e.profileUrl?o.createElement(si,{id:n},o.createElement(D,{type:"delight",size:"100%"})):o.createElement(Qt,{id:n,size:P.AVATAR_SIZE,src:e.profileUrl})}const si=g.default.div`flex-shrink:0;width:${P.AVATAR_SIZE}px;height:${P.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;ellipse,path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}}`;function ai({sender:e}){return o.createElement(ii,{id:`${pe}-sender-name`,variant:"caption1",color:m.themedColor.textMidEmphasis},e.nickname)}const ii=g.default(M)`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 li({createdAt:e}){const{stringSet:t,format:n}=F();return e?o.createElement(M,{id:`${pe}-sent-time`,variant:"caption4",color:m.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}function ci({customStyle:e}){return o.createElement(ui,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>o.createElement(di,{key:t,$color:e==null?void 0:e.bubbleContentColor})))}const ui=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};`,di=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 en(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function mi({extendedMessagePayload:e,onClickCTA:t=({url:n})=>en(n)}){const n=e==null?void 0:e.cta_button;return n?o.createElement(gi,{id:`${pe}-ext-cta-button`,role:"button",onClick:()=>t(n)},o.createElement(hi,{variant:"button"},n.label)):null}const gi=g.default.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${m.themedColor.textHighEmphasis};background-color:${m.color.background50};${R.dark`
|
|
66
66
|
background-color: ${m.color.ondark.textDisabled};
|
|
67
67
|
`}
|
|
68
|
-
`,
|
|
68
|
+
`,hi=g.default(M)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function fi({extendedMessagePayload:e,onClickCitation:t=n=>en(n.link)}){const{stringSet:n}=F(),{theme:r}=Yt(),s=e==null?void 0:e.citations;return!s||s.length===0?null:o.createElement(pi,{id:`${pe}-ext-citation`},o.createElement(bi,{variant:"caption1",color:r.colors.messageIncoming.text},n.CITATION_SOURCE_TITLE),o.createElement(Ei,null,s.map((a,i)=>o.createElement(vi,{key:`${a.embedding_id}-${i}`,role:"button",onClick:()=>t(a)},o.createElement(D,{type:"source",size:16,color:r.colors.messageIncoming.text}),o.createElement(xi,{variant:"body3",color:r.colors.messageIncoming.text},a.title)))))}const pi=g.default.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`,bi=g.default(M)`opacity:0.5;`,Ei=g.default.div`display:flex;flex-direction:column;gap:8px;`,xi=g.default(M)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,vi=g.default.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`,bt=({style:e,rootElementId:t,visible:n,onClose:r,children:s})=>{if(!n)return null;const{rootElement:a}=gr(),i=ke(a),l=ke(a,!0);return lo.createPortal(o.createElement(Ci,{onClick:r,style:e},o.createElement(yi,{onClick:u=>u.stopPropagation()},s)),i.getElementById(t)??i.getElementById(re.MODAL_ROOT)??l.body)},Ci=g.default.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${m.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${$e.MODAL};`,yi=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:${$e.MODAL};`,_i=({visible:e,onClose:t,children:n})=>o.createElement(bt,{rootElementId:re.WINDOW,visible:e,onClose:t},o.createElement(Ai,null,n)),Si=({onClick:e,destructive:t,children:n})=>o.createElement(Ti,{onClick:e,$destructive:t},n),Pe=Object.assign(_i,{ActionItem:Si}),Ti=g.default.button`all:unset;width:100%;padding:14px 24px;text-align:start;cursor:pointer;color:${({$destructive:e})=>e?m.themedColor.error:m.themedColor.textHighEmphasis};`,Ai=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};`,Ht=e=>`${e}-filled`,wi=e=>e==="good"?V.AIAgentMessageFeedbackRating.GOOD:V.AIAgentMessageFeedbackRating.BAD,br=A.css`&:hover{opacity:0.8;}&:active{opacity:0.6;}`,Mn={good:m.themedColor.secondary,bad:m.themedColor.error},ki=({visible:e,onClose:t,isEdit:n,initialRating:r,initialComment:s="",onSubmit:a,isCommentEnabled:i=!1})=>{const{stringSet:l}=F(),[u,d]=c.useState(r),[f,b]=c.useState(s);c.useLayoutEffect(()=>{e?(d(r),b(s)):(d(void 0),b(""))},[e,r,s]);const E=()=>{u&&(a({rating:u,comment:f.trim()||void 0}),t())},y=()=>{t()};return e?o.createElement(bt,{rootElementId:re.WINDOW,visible:e,onClose:y},o.createElement(Ii,null,o.createElement($i,null,o.createElement(M,{variant:"h2",color:m.themedColor.textHighEmphasis},l.FEEDBACK_TITLE)),o.createElement(Mi,null,o.createElement(Li,null,["good","bad"].map(x=>{const v=u===x,p=x==="good"?l.FEEDBACK_GOOD:l.FEEDBACK_BAD;return o.createElement(Oi,{key:x,$selected:v,$rating:x,onClick:()=>d(x)},o.createElement(D,{type:v?Ht(x):x,size:24,color:v?Mn[x]:m.themedColor.textLowEmphasis}),o.createElement(M,{variant:"caption1",color:v?Mn[x]:m.themedColor.textLowEmphasis},p))})),i&&o.createElement(Ri,null,o.createElement(M,{variant:"caption3",color:m.themedColor.textHighEmphasis},l.FEEDBACK_COMMENT_LABEL),o.createElement(Di,{placeholder:l.FEEDBACK_COMMENT_PLACEHOLDER,value:f,onChange:x=>b(x.target.value),maxLength:100}))),o.createElement(Pi,null,o.createElement(Ni,{onClick:y},o.createElement(M,{variant:"button",color:m.themedColor.textHighEmphasis},l.FEEDBACK_CANCEL)),o.createElement(Bi,{onClick:E,disabled:!u},o.createElement(M,{variant:"button"},n?l.FEEDBACK_SAVE:l.FEEDBACK_SUBMIT))))):null},Ii=g.default.div`width:280px;background-color:${({theme:e})=>e.colors.base.modalContentBackground};border-radius:12px;overflow:hidden;`,$i=g.default.div`padding:24px;`,Mi=g.default.div`padding-inline:24px;display:flex;flex-direction:column;gap:24px;`,Li=g.default.div`display:flex;gap:4px;`,Oi=g.default.button`width:114px;height:64px;border-radius:12px;border:1px solid ${m.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?m.color.background100:"transparent"};${({$selected:e})=>R.dark`
|
|
69
69
|
background-color: ${e?m.color.background600:"transparent"};
|
|
70
70
|
`}
|
|
71
71
|
|
|
@@ -76,16 +76,16 @@
|
|
|
76
76
|
&:active {
|
|
77
77
|
opacity: 0.6;
|
|
78
78
|
}
|
|
79
|
-
`,
|
|
79
|
+
`,Ri=g.default.div`display:flex;flex-direction:column;gap:6px;`,Di=g.default.textarea`font-family:inherit;font-size:12px;line-height:16px;border:1px solid ${m.themedColor.textDisabled};border-radius:4px;padding:6px 12px;color:${m.themedColor.textHighEmphasis};background-color:${m.themedColor.textLowEmphasisInverse};resize:none;field-sizing:content;min-height:28px;max-height:118px;overflow-y:auto;&::placeholder{color:${m.themedColor.textLowEmphasis};}&:focus{outline:none;}`,Pi=g.default.div`padding-inline:24px;padding-block:16px;display:flex;justify-content:flex-end;gap:4px;`,Er=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;`,Ni=g.default(Er)`${br}`,Bi=g.default(Er)`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};}`,Ln={good:m.themedColor.secondary,bad:m.themedColor.error};function Fi({isBotMessage:e,isConversationClosed:t,isStreaming:n,isFeedbackEnabled:r,isFeedbackCommentEnabled:s,extendedMessagePayload:a,onFeedbackUpdate:i}){const{stringSet:l}=F(),[u,d]=c.useState(!1),[f,b]=c.useState(!1),[E,y]=c.useState(void 0),[x,v]=c.useState(""),p=a==null?void 0:a.feedback,h=(p==null?void 0:p.rating)??"none";if(h!=="none"?!1:!!(n||!e||!r||(a==null?void 0:a.bot_message_type)!=="generated"||t))return null;const _=I=>{h==="none"?(y(I),v(""),d(!0)):b(!0)},w=()=>{i==null||i(null),b(!1)},S=()=>{b(!1),y(p==null?void 0:p.rating),v((p==null?void 0:p.comment)??""),d(!0)},k=I=>{i==null||i(I)};return t&&h!=="none"?o.createElement(On,{$horizontal:!0},o.createElement(Hi,null,o.createElement(D,{type:Ht(h),size:12,color:Ln[h]})),(p==null?void 0:p.comment)&&o.createElement(Rn,{variant:"caption2",style:{lineHeight:"16px"}},p.comment)):o.createElement(o.Fragment,null,o.createElement(On,null,o.createElement(Ui,null,["good","bad"].map(I=>{const L=h===I;return o.createElement(zi,{key:I,$selected:L,$rating:I,onClick:()=>_(I)},o.createElement(D,{type:L?Ht(I):I,size:14,color:L?Ln[I]:m.themedColor.textMidEmphasis}))})),h!=="none"&&(p==null?void 0:p.comment)&&o.createElement(Rn,{variant:"caption2"},p.comment)),o.createElement(Pe,{visible:f,onClose:()=>b(!1)},o.createElement(Pe.ActionItem,{onClick:S},l.FEEDBACK_EDIT),o.createElement(Pe.ActionItem,{onClick:w,destructive:!0},l.FEEDBACK_REMOVE)),o.createElement(ki,{visible:u,onClose:()=>d(!1),isEdit:h!=="none",initialRating:E,initialComment:x,onSubmit:k,isCommentEnabled:s}))}const On=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:${P.BODY_MAX_WIDTH}px;`,Hi=g.default.div`padding:2px;flex-shrink:0;display:flex;align-items:center;`,Ui=g.default.div`display:flex;gap:2px;`,zi=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 ${m.color.background200};background-color:${({$selected:e})=>e?m.color.background100:"transparent"};${({$selected:e})=>R.dark`
|
|
80
80
|
border: 1px solid ${m.color.background400};
|
|
81
81
|
background-color: ${e?m.color.background500:"transparent"};
|
|
82
82
|
`}
|
|
83
83
|
|
|
84
84
|
${br}
|
|
85
|
-
`,Rn=
|
|
85
|
+
`,Rn=g.default(M)`color:${m.themedColor.textMidEmphasis};${R.dark`
|
|
86
86
|
color: ${m.themedColor.textHighEmphasis};
|
|
87
87
|
`}
|
|
88
|
-
`,tn=({visible:e,title:t,description:n,confirmText:r="OK",onConfirm:s,onClose:a})=>{const i=()=>{s==null||s(),a()};return o.createElement(bt,{rootElementId:re.WINDOW,visible:e,onClose:a},o.createElement(
|
|
88
|
+
`,tn=({visible:e,title:t,description:n,confirmText:r="OK",onConfirm:s,onClose:a})=>{const i=()=>{s==null||s(),a()};return o.createElement(bt,{rootElementId:re.WINDOW,visible:e,onClose:a},o.createElement(Vi,null,o.createElement(Gi,null,t&&o.createElement(M,{variant:"h1",color:m.themedColor.textHighEmphasis},t),n&&o.createElement(Wi,null,o.createElement(M,{variant:"subtitle2",color:m.themedColor.textHighEmphasis},n))),o.createElement(qi,null,o.createElement(ji,{onClick:i},o.createElement(M,{variant:"button",color:m.themedColor.primary},r)))))},Vi=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};`,Gi=g.default.div`margin-bottom:16px;`,Wi=g.default.div`margin-top:8px;`,qi=g.default.div`display:flex;flex-direction:row;justify-content:flex-end;`,ji=g.default.button`all:unset;display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:transparent;padding:10px 16px;`,nn=A.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;}`,Dn=g.default.button`${nn};background-color:${m.themedColor.primary};color:${m.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.9;}`,Ki=g.default.button`${nn};color:${m.themedColor.primary};${R.light`
|
|
89
89
|
background-color: ${m.color.background50};
|
|
90
90
|
`};
|
|
91
91
|
${R.dark`
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
&:hover:not(:disabled) {
|
|
96
96
|
opacity: 0.9;
|
|
97
97
|
}
|
|
98
|
-
`,
|
|
98
|
+
`,Yi=g.default.button`${nn};background-color:transparent;color:${m.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`,Zi=e=>{switch(e){case"primary":return Dn;case"secondary":return Ki;case"clear":return Yi;default:return Dn}},Xi=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);}}`,Ji=({children:e,onClick:t,variant:n="primary",disabled:r=!1,loading:s=!1,className:a})=>{const i=()=>{switch(n){case"primary":return m.themedColor.textHighEmphasisInverse;case"secondary":return m.themedColor.primary;case"clear":return m.themedColor.textHighEmphasis;default:return m.themedColor.textHighEmphasisInverse}},l=Zi(n);return o.createElement(l,{onClick:t,disabled:r||s,className:a},s?o.createElement(Xi,null,o.createElement(D,{type:"spinner",size:22,color:i()})):o.createElement(M,{variant:"button",color:i()},e))},Qi=({children:e,className:t,style:n})=>o.createElement(M,{variant:"caption4",color:m.themedColor.error,className:t,style:n},e),el=({children:e,className:t,style:n,required:r})=>{const{stringSet:s}=F();return o.createElement(M,{variant:"caption3",color:m.themedColor.textMidEmphasis,className:t,style:n},e,!r&&o.createElement("span",{style:{color:m.themedColor.textLowEmphasis}},` (${s.OPTIONAL})`))},tl=({value:e,onChange:t,placeholder:n,error:r=!1,submitted:s=!1,className:a,disabled:i=!1,max:l})=>{const u=f=>{const E=f.target.value.replace(/[^0-9.-]/g,""),y=E.split("."),v=y.length>1?y[0]+"."+y.slice(1).join("").replace(/\./g,""):E;if(f.target.value=v,v===""||v==="-")t==null||t(null);else{const p=Number(v);if(!isNaN(p)){if(l!==void 0&&p>l)return;t==null||t(p)}}},d=e==null?"":String(e);return o.createElement(al,{type:"text",value:d,onChange:u,placeholder:n,className:a,disabled:i||s,inputMode:"decimal",$error:r,$submitted:s})},nl=A.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:${m.themedColor.textLowEmphasis};}&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}`,rl=A.css`color:${m.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${R.light`
|
|
99
99
|
background-color: ${m.color.ondark.textMidEmphasis};
|
|
100
100
|
`}
|
|
101
101
|
${R.dark`
|
|
@@ -105,13 +105,13 @@
|
|
|
105
105
|
&::placeholder {
|
|
106
106
|
color: ${m.themedColor.textLowEmphasis};
|
|
107
107
|
}
|
|
108
|
-
`,
|
|
108
|
+
`,ol=A.css`border:1px solid ${m.themedColor.error};color:${m.themedColor.textHighEmphasis};${R.light`
|
|
109
109
|
background-color: ${m.color.background50};
|
|
110
110
|
`}
|
|
111
111
|
${R.dark`
|
|
112
112
|
background-color: ${m.color.onlight.textLowEmphasis};
|
|
113
113
|
`}
|
|
114
|
-
`,
|
|
114
|
+
`,sl=A.css`border:1px solid ${m.themedColor.textDisabled};color:${m.themedColor.textHighEmphasis};${R.light`
|
|
115
115
|
background-color: ${m.color.background50};
|
|
116
116
|
`}
|
|
117
117
|
${R.dark`
|
|
@@ -121,12 +121,12 @@
|
|
|
121
121
|
&:focus {
|
|
122
122
|
border-color: ${m.themedColor.primary};
|
|
123
123
|
}
|
|
124
|
-
`,
|
|
124
|
+
`,al=g.default.input`${nl}${({$error:e,$submitted:t})=>t?rl:e?ol:sl}`,il=e=>{if(e.multiple){const{value:t=[],onChange:n,maxSelect:r,submitted:s=!1}=e;return{selectedValues:t,handleOptionClick:i=>{if(s)return;if(t.includes(i)){const u=t.filter(d=>d!==i);n==null||n(u)}else{if(r&&t.length>=r)return;const u=[...t,i];n==null||n(u)}}}}else{const{value:t,onChange:n,submitted:r=!1}=e;return{selectedValues:t?[t]:[],handleOptionClick:a=>{if(r)return;const i=t===a?"":a;n==null||n(i)}}}},xr=e=>{const{options:t,submitted:n=!1,error:r=!1,className:s}=e,{selectedValues:a,handleOptionClick:i}=il(e);return o.createElement(cl,{className:s},t.map(l=>{const u=a.includes(l.value);return o.createElement(pl,{key:l.value,$active:u,$submitted:n,$error:r,onClick:()=>i(l.value)},o.createElement(M,{variant:"caption1",color:ll(u,n)},l.label))}))},ll=(e,t)=>t?e?m.themedColor.textHighEmphasis:m.themedColor.textDisabled:e?m.themedColor.primary:m.themedColor.textMidEmphasis,cl=g.default.div`display:flex;flex-wrap:wrap;gap:4px 2px;`,ul=A.css`display:inline-flex;align-items:center;padding:8px 12px;border-radius:15px;transition:all 0.2s ease;`,dl=A.css`cursor:default;background-color:${m.color.ondark.textMidEmphasis};color:${m.themedColor.textHighEmphasis};${R.dark`
|
|
125
125
|
background-color: transparent;
|
|
126
126
|
border: 1px solid white;
|
|
127
127
|
color: white;
|
|
128
128
|
`}
|
|
129
|
-
`,
|
|
129
|
+
`,ml=A.css`cursor:default;${R.light`
|
|
130
130
|
background-color: ${m.color.ondark.textMidEmphasis};
|
|
131
131
|
color: ${m.themedColor.textDisabled};
|
|
132
132
|
`}
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
border: 1px solid ${m.color.onlight.textLowEmphasis};
|
|
136
136
|
color: ${m.themedColor.textDisabled};
|
|
137
137
|
`}
|
|
138
|
-
`,
|
|
138
|
+
`,gl=A.css`cursor:pointer;border:1px solid ${m.themedColor.primary};${R.light`
|
|
139
139
|
background-color: ${m.color.background50};
|
|
140
140
|
color: ${m.themedColor.primary};
|
|
141
141
|
`}
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
background-color: ${m.color.onlight.textLowEmphasis};
|
|
144
144
|
color: ${m.themedColor.primary};
|
|
145
145
|
`}
|
|
146
|
-
`,
|
|
146
|
+
`,hl=A.css`cursor:pointer;border:1px solid ${m.themedColor.textDisabled};${R.light`
|
|
147
147
|
background-color: ${m.color.background50};
|
|
148
148
|
color: ${m.themedColor.textMidEmphasis};
|
|
149
149
|
`}
|
|
@@ -151,10 +151,10 @@
|
|
|
151
151
|
background-color: ${m.color.onlight.textLowEmphasis};
|
|
152
152
|
color: ${m.themedColor.textMidEmphasis};
|
|
153
153
|
`}
|
|
154
|
-
`,
|
|
155
|
-
${r} ${
|
|
154
|
+
`,fl=A.css`border-color:${m.themedColor.error}!important;`,pl=g.default.div`${ul}${({$active:e,$submitted:t,$error:n})=>{if(t)return e?dl:ml;const r=e?gl:hl;return n?A.css`
|
|
155
|
+
${r} ${fl}
|
|
156
156
|
`:r}}
|
|
157
|
-
`,
|
|
157
|
+
`,bl=e=>o.createElement(xr,{...e,multiple:!1}),El=e=>o.createElement(xr,{...e,multiple:!0}),xl=g.default.div`width:100%;height:1px;background-color:${m.themedColor.textDisabled};`,vl=({className:e})=>o.createElement(xl,{className:e}),Cl=({value:e="",onChange:t,placeholder:n,variant:r="single-line",error:s=!1,submitted:a=!1,className:i,disabled:l=!1,maxLength:u})=>{const f={value:e,onChange:b=>{const E=b.target.value;u&&E.length>u||t==null||t(E)},placeholder:n,className:i,disabled:l||a,maxLength:u,$error:s,$submitted:a};return r==="multi-line"?o.createElement(_l,{...f}):o.createElement(yl,{...f})},vr=A.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:${m.themedColor.textLowEmphasis};}`,Cr=A.css`color:${m.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${R.light`
|
|
158
158
|
background-color: ${m.color.ondark.textMidEmphasis};
|
|
159
159
|
`}
|
|
160
160
|
${R.dark`
|
|
@@ -164,13 +164,13 @@
|
|
|
164
164
|
&::placeholder {
|
|
165
165
|
color: ${m.themedColor.textLowEmphasis};
|
|
166
166
|
}
|
|
167
|
-
`,yr=
|
|
167
|
+
`,yr=A.css`border:1px solid ${m.themedColor.error};color:${m.themedColor.textHighEmphasis};${R.light`
|
|
168
168
|
background-color: ${m.color.background50};
|
|
169
169
|
`}
|
|
170
170
|
${R.dark`
|
|
171
171
|
background-color: ${m.color.onlight.textLowEmphasis};
|
|
172
172
|
`}
|
|
173
|
-
`,_r=
|
|
173
|
+
`,_r=A.css`border:1px solid ${m.themedColor.textDisabled};color:${m.themedColor.textHighEmphasis};${R.light`
|
|
174
174
|
background-color: ${m.color.background50};
|
|
175
175
|
`}
|
|
176
176
|
${R.dark`
|
|
@@ -180,54 +180,54 @@
|
|
|
180
180
|
&:focus {
|
|
181
181
|
border-color: ${m.themedColor.primary};
|
|
182
182
|
}
|
|
183
|
-
`,
|
|
183
|
+
`,yl=g.default.input`${vr};height:36px;${({$error:e,$submitted:t})=>t?Cr:e?yr:_r}`,_l=g.default.textarea`${vr};height:96px;resize:none;font-family:inherit;${({$error:e,$submitted:t})=>t?Cr:e?yr:_r}`,Sl=({children:e,className:t,style:n})=>o.createElement(M,{variant:"button",color:m.themedColor.textHighEmphasis,className:t,style:n},e),j={Title:Sl,Label:el,ErrorLabel:Qi,Separator:vl,Button:Ji,TextInput:Cl,NumberInput:tl,SingleSelect:bl,MultiSelect:El},Tl=1,Al=new Set(["text","number","single-select","multi-select"]),wl=e=>{var p;const t=(p=e.extendedMessagePayload)==null?void 0:p.form;if(!t)throw new Error("Form is not provided");const{stringSet:n}=F(),[r,s]=c.useState({submitting:!1,canceling:!1}),[a,i]=c.useState({visible:!1}),{state:l,fields:u,submit:d,cancel:f,updateFieldValue:b}=Xs(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})}}),E=l==="submitted",y=async()=>{s(h=>({...h,submitting:!0}));try{await d()}catch(h){i({visible:!0,description:h instanceof Error?h.message:n.TRY_AGAIN})}finally{s(h=>({...h,submitting:!1}))}},x=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}))}},v=c.useMemo(()=>{const h=()=>t.version>Tl,C=()=>t.fields.some(_=>!Al.has(_.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:v.visible?o.createElement(c.Fragment,null,o.createElement(Pn,{$maxWidth:e.maxBodyWidth??P.BODY_MAX_WIDTH},o.createElement(j.Title,null,t.title),o.createElement(kl,null,u.map(h=>o.createElement(Il,{key:h.key},o.createElement(j.Label,{style:{marginBottom:"6px"},required:h.required},h.label),h.type==="text"&&o.createElement(j.TextInput,{value:h.value||"",placeholder:h.placeholder,onChange:C=>b(h.key,C),disabled:E,error:!!h.error,submitted:E,variant:h.layout==="multiline"?"multi-line":"single-line",maxLength:h.maxLength}),h.type==="number"&&o.createElement(j.NumberInput,{value:h.value||null,placeholder:h.placeholder,onChange:C=>b(h.key,C),disabled:E,error:!!h.error,submitted:E,max:h.max}),h.type==="single-select"&&o.createElement(j.SingleSelect,{options:h.options.map(C=>({label:C,value:C})),value:h.value||"",onChange:C=>b(h.key,C),submitted:E}),h.type==="multi-select"&&o.createElement(j.MultiSelect,{options:h.options.map(C=>({label:C,value:C})),value:h.value||[],onChange:C=>b(h.key,C),submitted:E,maxSelect:h.maxSelect}),h.error&&o.createElement(j.ErrorLabel,{style:{marginTop:"4px"}},h.error)))),o.createElement(j.Separator,null),o.createElement($l,null,o.createElement(j.Button,{variant:E?"clear":"primary",onClick:y,disabled:E||r.canceling,loading:r.submitting},E?n.SUBMITTED:n.BUTTON__SUBMIT),l!=="submitted"&&o.createElement(j.Button,{variant:"secondary",onClick:x,disabled:r.submitting,loading:r.canceling},n.BUTTON__CANCEL))),o.createElement(tn,{...a,onClose:()=>i({visible:!1,title:""})})):o.createElement(Pn,{$maxWidth:e.maxBodyWidth??P.BODY_MAX_WIDTH},o.createElement(M,{variant:"body3"},v.reason),v.cancelable&&o.createElement(j.Button,{variant:"primary",onClick:x,loading:r.canceling},n.BUTTON__CANCEL))},Pn=g.default.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e})=>A.css`
|
|
184
184
|
color: ${e.colors.messageIncoming.text};
|
|
185
185
|
background-color: ${e.colors.messageIncoming.background};
|
|
186
186
|
`}
|
|
187
187
|
padding: 16px 12px;
|
|
188
188
|
transition: max-width 0.3s;
|
|
189
189
|
overflow-wrap: break-word;
|
|
190
|
-
`,
|
|
191
|
-
${e==="vertical"?
|
|
190
|
+
`,kl=g.default.div`display:flex;flex-direction:column;gap:12px;`,Il=g.default.div`display:flex;flex-direction:column;`,$l=g.default.div`display:flex;flex-direction:column;gap:8px;`;function Ml(e){return o.createElement(o.Fragment,null)}const Ll=new Set(["default"]),{MessageTemplate:Ol}=co.createMessageTemplate({parser:Lt.parser,renderer:Lt.renderer,Container:e=>o.createElement("div",{...e})});function Rl(e){return o.createElement(ct,{errorFallback:e.messageTemplateErrorFallback,loadingFallback:e.messageTemplateLoadingFallback},o.createElement(Dl,{...e}))}const Dl=({extendedMessagePayload:e,onGetCachedMessageTemplate:t=()=>null,onRequestMessageTemplate:n,onHandleTemplateInternalAction:r=he})=>{const s=e==null?void 0:e.message_template;if(!Ll.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}=gr(),l=Us({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 o.createElement(Pl,{id:`${pe}-ext-message-template`},o.createElement(Lt.MessageProvider,{handleInternalAction:(u,d)=>{u.stopPropagation(),r==null||r(d)}},o.createElement(Ol,{templateItems:l.body.items,templateVersion:l.version})))},Pl=g.default.div`box-sizing:border-box;overflow:hidden;width:100%;`;function Nl({extendedMessagePayload:e,onClickSuggestedReply:t,suggestedRepliesDirection:n="vertical"}){const[r,s]=c.useState(!1),a=(e==null?void 0:e.suggested_replies)??[];return a.length===0||r?null:o.createElement(Bl,{id:`${pe}-ext-suggested-replies`,$type:n},a.map((i,l)=>o.createElement(Fl,{key:l,$type:n,variant:"body3",onClick:()=>{t&&(t==null||t({reply:i}),s(!0))}},i)))}const Bl=g.default.div`margin:16px 0;padding:0 ${P.HORIZONTAL_PADDING}px;position:relative;display:flex;align-self:stretch;gap:8px;${({$type:e})=>e==="vertical"?Hl:Ul};`,Fl=g.default(M)`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:${m.color.primary.main};border:1px solid ${m.color.primary.main};background-color:${m.themedColor.bg_50_600};&:hover{background-color:${m.themedColor.bg_100_500};}${({$type:e,theme:t})=>A.css`
|
|
191
|
+
${e==="vertical"?zl:Vl};
|
|
192
192
|
&:active {
|
|
193
193
|
background-color: ${t.colors.base.primary};
|
|
194
194
|
color: ${t.colors.base.primaryContrastContent};
|
|
195
195
|
}
|
|
196
196
|
`}
|
|
197
|
-
`,
|
|
198
|
-
`,je=
|
|
197
|
+
`,Hl=A.css`flex-direction:column;align-items:flex-end;`,Ul=A.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,zl=A.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Vl=A.css`white-space:nowrap;`,Ie=fe({template:Gl,components:{SenderName:ai,SenderAvatar:oi,SentTime:li,MessageBody:ti,TypingIndicator:ci,SuggestedReplies:Nl,MessageTemplate:Rl,CTAButton:mi,Citation:fi,Form:wl,Feedback:Fi,MessageLogs:Ml}});function Gl(e){return o.createElement(Sr,{...e,testerMode:!1})}function Sr(e){var v,p,h,C,_,w,S;const{components:t}=Ie.useContext(),{streamText:n,isAnimating:r}=na({text:e.message,enabled:e.isStreaming,onAnimationStart:e.onStreamAnimationStart,onAnimationComplete:e.onStreamAnimationComplete}),s={...e,message:n,extendedMessagePayload:r?{}:e.extendedMessagePayload},a=!!s.isTyping,i=s.testerMode,l=!!((v=s.extendedMessagePayload)!=null&&v.form)&&!((p=s.extendedMessagePayload)!=null&&p.form.canceled_at),u=!!((h=s.extendedMessagePayload)!=null&&h.message_template),d=!!((C=s.extendedMessagePayload)!=null&&C.cta_button),f=!!((_=s.extendedMessagePayload)!=null&&_.citations)&&s.extendedMessagePayload.citations.length>0,b=!!s.createdAt,E=s.groupType==="top"||s.groupType==="single",y=s.groupType==="bottom"||s.groupType==="single",x=i?0:P.AVATAR_SIZE;return o.createElement(Wl,{$marginBottom:a?0:jt(s.groupType)},E&&o.createElement(ql,null,!i&&o.createElement(t.SenderAvatar,{...s}),o.createElement(t.SenderName,{...s})),o.createElement(Kl,null,o.createElement(kt,{$extraStartPadding:x},a?o.createElement(t.TypingIndicator,{...s}):o.createElement(t.MessageBody,{...s},d&&o.createElement("div",{style:{marginTop:12,marginInline:12}},o.createElement(t.CTAButton,{...s})),f&&o.createElement(t.Citation,{...s}))),u&&o.createElement(Nn,{$startPadding:0,$endPadding:0},o.createElement(t.MessageTemplate,{...s,messageTemplateErrorFallback:s.messageTemplateErrorFallback??o.createElement(kt,{$extraStartPadding:x},o.createElement(t.MessageBody,{...s,messageType:"user",message:((S=(w=s.extendedMessagePayload)==null?void 0:w.message_template)==null?void 0:S.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:s.messageTemplateLoadingFallback??o.createElement(kt,{$extraStartPadding:x},o.createElement(t.TypingIndicator,{...s}))})),l&&o.createElement(Nn,{$extraStartPadding:x},o.createElement(t.Form,{...s}))),y&&b&&o.createElement(jl,{$extraStartPadding:x+8},o.createElement(t.SentTime,{...s})),o.createElement(c.Fragment,null,!a&&o.createElement(je,{$extraStartPadding:x+8},o.createElement(t.Feedback,{...s})),s.suggestedRepliesVisible&&o.createElement(t.SuggestedReplies,{...s}),o.createElement(t.MessageLogs,{...s})))}const Wl=g.default.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
198
|
+
`,je=g.default.div`display:flex;align-self:stretch;justify-content:flex-start;${({$startPadding:e=P.HORIZONTAL_PADDING,$endPadding:t=P.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
199
199
|
padding-inline: ${e+n}px ${t}px;
|
|
200
200
|
`}
|
|
201
|
-
`,
|
|
201
|
+
`,ql=g.default(je)`display:flex;flex-direction:row;align-items:center;gap:8px;`,kt=g.default(je)`display:flex;`,jl=g.default(je)`margin-top:${P.BODY_TIME_GAP}px;display:flex;align-items:flex-start;justify-content:flex-start;`,Nn=g.default(je)`display:flex;${({$startPadding:e=P.HORIZONTAL_PADDING,$endPadding:t=P.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
202
202
|
padding-inline: ${e+n}px ${t}px;
|
|
203
203
|
`}
|
|
204
|
-
`,
|
|
204
|
+
`,Kl=g.default.div`display:flex;flex-direction:column;gap:${P.GAP_GROUPED}px;`;function Yl({file:e,children:t,onClickFile:n,sendingStatus:r}){const s=(()=>{if(!(!n||r==="failed"))return()=>n==null?void 0:n(e)})();return o.createElement(Zl,null,o.createElement(Jt,{name:e.name,type:qt(e.name,e.type),onClick:s}),t)}const Zl=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${P.GAP_GROUPED}px;`,rn=({className:e,children:t,size:n=26})=>o.createElement(Xl,{className:e,$size:n},t??o.createElement(D,{type:"spinner",size:n})),Xl=g.default.div`display:flex;align-items:center;justify-content:center;width:${({$size:e})=>ae(e)};height:${({$size:e})=>ae(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;function Jl({sendingStatus:e,file:t,metadata:n,onClickMedia:r,children:s}){const{aspectRatio:a,localFile:i}=n,[l]=c.useState(()=>i instanceof Blob?URL.createObjectURL(i):t.url),[u,d]=c.useState(!1),f=(()=>{if(!(!r||e==="failed"))return()=>r==null?void 0:r({...t,url:l})})(),b={onClick:f,$ratio:a,$clickable:!!f};return o.createElement(Ql,null,o.createElement(ec,{...b},!u&&o.createElement(rn,{size:26},o.createElement(D,{type:"spinner",color:"textLowEmphasis",size:26})),o.createElement(tc,{$loaded:u,src:l,alt:"image-message",onLoad:()=>d(!0)})),s)}const Ql=g.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${P.GAP_GROUPED}px;`,ec=g.default.div`width:${P.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;${R.light`
|
|
205
205
|
background-color: ${m.color.background100};
|
|
206
206
|
`}
|
|
207
207
|
${R.dark`
|
|
208
208
|
background-color: ${m.color.background400};
|
|
209
209
|
`}
|
|
210
|
-
`,
|
|
210
|
+
`,tc=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 Bn(e){var n,r;const t=c.useMemo(()=>{const s=Ja(pr(e.message));return Yn.default.sanitize(s)},[e.message]);return o.createElement(nc,{$maxWidth:e.maxBodyWidth??P.BODY_MAX_WIDTH,$color:(n=e.customStyle)==null?void 0:n.bubbleContentColor,$bgColor:(r=e.customStyle)==null?void 0:r.bubbleBackgroundColor},o.createElement(rc,{variant:"body3",dangerouslySetInnerHTML:{__html:t}}))}const nc=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})=>A.css`
|
|
211
211
|
color: ${t||e.colors.messageOutgoing.text};
|
|
212
212
|
background-color: ${n||e.colors.messageOutgoing.background};
|
|
213
213
|
`}
|
|
214
214
|
padding: 12px 0;
|
|
215
215
|
transition: max-width 0.3s;
|
|
216
216
|
overflow-wrap: break-word;
|
|
217
|
-
`,
|
|
218
|
-
`,Tr=
|
|
219
|
-
`,cc=h.default(Tr)``,uc=h.default(Tr)`margin-top:${P.BODY_TIME_GAP}px;`;function dc(e){return e.messageType!=="admin"?null:o.createElement(mc,null,o.createElement(M,{variant:"caption2",color:m.themedColor.textMidEmphasis},gc(Yn.default.sanitize(e.message))))}const mc=h.default.div`text-align:center;text-wrap:pretty;word-break:break-word;padding-inline:${P.HORIZONTAL_PADDING}px;a{text-decoration:underline;color:inherit;}`,gc=e=>{try{const t=[];let n=e,r=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:u,type:d}=l,f=u.index;f>0&&t.push(n.slice(0,f)),d==="link"?t.push(o.createElement("a",{key:r++,href:u[2],target:"_blank",rel:pt},u[1])):d==="bold"&&t.push(o.createElement("strong",{key:r++},u[1])),n=n.slice(f+u[0].length)}return t.filter(s=>s!=="")}catch{return[e]}},Ar=({onClick:e,checked:t,label:n,disabled:r,labelVariant:s="caption2"})=>{const a=t?m.themedColor.primary:r?m.themedColor.textDisabled:m.themedColor.textLowEmphasis,i=t?m.themedColor.textHighEmphasis:r?m.themedColor.textLowEmphasis:m.themedColor.textHighEmphasis;return o.createElement(pc,{onClick:e,disabled:r},o.createElement(hc,null,o.createElement(D,{size:20,type:t?"radio-on":"radio-off",color:a})),o.createElement(fc,{variant:s,color:i},n))},hc=h.default.div`width:20px;height:20px;`,fc=h.default(M)`line-height:20px;word-break:break-word;`,pc=h.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,bc=({csatPayload:e,submitted:t,defaultValue:n,value:r,onChange:s})=>(c.useEffect(()=>{typeof r>"u"&&typeof n=="boolean"&&(s==null||s(n))},[r,n]),e.cre?o.createElement(Ec,null,o.createElement(j.Label,{required:e.cre.required},e.cre.question),o.createElement(xc,null,[{label:e.cre.positive_label,value:!0},{label:e.cre.negative_label,value:!1}].map(a=>o.createElement(Ar,{key:a.label,checked:r===a.value,label:a.label,disabled:t,onClick:()=>s==null?void 0:s(a.value)})))):null),Ec=h.default.div`display:flex;flex-direction:column;gap:8px;`,xc=h.default.div`display:flex;flex-direction:column;gap:8px;`,vc=({followUpItem:e,submitted:t,value:n="",onChange:r,hasError:s})=>{const{stringSet:a}=F();return o.createElement(Cc,null,o.createElement(j.Label,{required:e.required},e.question),e.response_type==="free_text"&&o.createElement(j.TextInput,{variant:"multi-line",disabled:t,submitted:t,maxLength:100,value:n,onChange:i=>r(i),error:s}),e.response_type==="single_choice"&&o.createElement(yc,null,e.options.map(i=>o.createElement(Ar,{key:i,checked:n===i,label:i,disabled:t,onClick:()=>r==null?void 0:r(i),labelVariant:"body3"}))),s&&o.createElement(j.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},Cc=h.default.div`display:flex;flex-direction:column;gap:8px;`,yc=h.default.div`display:flex;flex-direction:column;gap:8px;`,_c=({value:e,selected:t,label:n})=>o.createElement(Sc,{$selected:t,"aria-label":n},Tc[e-1]),Sc=h.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Tc=[o.createElement("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o.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)"}),o.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"}),o.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"}),o.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"}),o.createElement("defs",null,o.createElement("linearGradient",{id:"paint0_linear_159_173206",x1:"20",y1:"2.08325",x2:"20",y2:"37.9166",gradientUnits:"userSpaceOnUse"},o.createElement("stop",{stopColor:"#FF2D1D"}),o.createElement("stop",{offset:"1",stopColor:"#FFA540"})))),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.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"}),o.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"}),o.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"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.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"}),o.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"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.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"}),o.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"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.createElement("g",{clipPath:"url(#clip0_159_173224)"},o.createElement("g",{clipPath:"url(#clip1_159_173224)"},o.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"})),o.createElement("mask",{id:"mask0_159_173224",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"12",y:"22",width:"16",height:"9"},o.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"})),o.createElement("g",{mask:"url(#mask0_159_173224)"},o.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"}))),o.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"}),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_159_173224"},o.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"})),o.createElement("clipPath",{id:"clip1_159_173224"},o.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"}))))],Ac=({csatPayload:e,submitted:t,value:n,onChange:r})=>{const s=typeof n>"u";return o.createElement(kc,null,o.createElement(M,{variant:"caption3",color:m.themedColor.textMidEmphasis},e.csat_question),o.createElement(Ic,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const u=l+1,d=n===u;return o.createElement($c,{key:l,disabled:t,onClick:()=>r(u)},o.createElement(wc,{value:u,selected:s||d,label:a,src:i}),!!a&&o.createElement(M,{color:d?m.themedColor.textHighEmphasis:m.themedColor.textLowEmphasis,variant:"caption3"},a))})))},wc=({value:e,src:t,label:n,selected:r})=>{const[s,a]=c.useState(!1),i=s?o.createElement(_c,{value:e,selected:r,label:n}):o.createElement(Lc,{$selected:r,"aria-label":n,src:t,onError:()=>a(!0)});return o.createElement(Mc,null,i)},kc=h.default.div`display:flex;flex-direction:column;gap:8px;`,Ic=h.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,$c=h.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:${m.themedColor.textHighEmphasis};}`,Mc=h.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${m.color.background200};${R.dark`
|
|
217
|
+
`,rc=g.default(M)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function oc(e){const{stringSet:t}=F(),n=()=>{const a=Qn(e)?o.createElement(Bn,{...e}):null;return e.messageType==="user"?a:e.messageType==="file"?e.file.type.startsWith("image")?o.createElement(Jl,{...e},a):o.createElement(Yl,{...e},a):o.createElement(Bn,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})},r=e.sendingStatus==="failed"&&e.onClickFailedMessage,s=a=>{var i;(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),(i=e.onClickFailedMessage)==null||i.call(e))};return o.createElement("div",{...r&&{onClick:e.onClickFailedMessage,onKeyDown:s,role:"button",tabIndex:0},style:{display:"contents",cursor:r?"pointer":"default"}},n())}function sc({sendingStatus:e}){const t=A.useTheme();switch(e){case"pending":return o.createElement(ac,{size:16},o.createElement(D,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return o.createElement("div",{style:{marginBottom:2}},o.createElement(D,{type:"error",color:m.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return o.createElement("div",{style:{marginBottom:2}},o.createElement(D,{type:"done",color:m.themedColor.secondary,size:16}))}}const ac=g.default(rn)`margin-bottom:2px;width:16px;height:16px;`;function ic({createdAt:e}){const{stringSet:t,format:n}=F();return e?o.createElement(M,{variant:"caption4",color:m.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}const Et=fe({template:lc,components:{SendingStatus:sc,SentTime:ic,MessageBody:oc}});function lc(e){const{components:t}=Et.useContext(),n=e.sendingStatus==="succeeded",r=e.groupType==="bottom"||e.groupType==="single";return o.createElement(cc,{$marginBottom:jt(e.groupType)},o.createElement(uc,null,o.createElement(t.MessageBody,{...e})),r&&o.createElement(dc,{$extraEndPadding:8},n?o.createElement(t.SentTime,{...e}):o.createElement(t.SendingStatus,{...e})))}const cc=g.default.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
218
|
+
`,Tr=g.default.div`display:flex;align-self:stretch;justify-content:flex-end;${({$startPadding:e=P.HORIZONTAL_PADDING,$endPadding:t=P.HORIZONTAL_PADDING,$extraEndPadding:n=0})=>`padding-inline: ${e}px ${t+n}px;`};
|
|
219
|
+
`,uc=g.default(Tr)``,dc=g.default(Tr)`margin-top:${P.BODY_TIME_GAP}px;`;function mc(e){return e.messageType!=="admin"?null:o.createElement(gc,null,o.createElement(M,{variant:"caption2",color:m.themedColor.textMidEmphasis},hc(Yn.default.sanitize(e.message))))}const gc=g.default.div`text-align:center;text-wrap:pretty;word-break:break-word;padding-inline:${P.HORIZONTAL_PADDING}px;a{text-decoration:underline;color:inherit;}`,hc=e=>{try{const t=[];let n=e,r=0;for(;n;){const s=n.match(/\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/),a=n.match(/\*\*([^*]+)\*\*/),i=[s&&{match:s,type:"link"},a&&{match:a,type:"bold"}].filter(b=>!!b);if(!i.length){t.push(n);break}const l=i.reduce((b,E)=>E.match.index<b.match.index?E:b),{match:u,type:d}=l,f=u.index;f>0&&t.push(n.slice(0,f)),d==="link"?t.push(o.createElement("a",{key:r++,href:u[2],target:"_blank",rel:pt},u[1])):d==="bold"&&t.push(o.createElement("strong",{key:r++},u[1])),n=n.slice(f+u[0].length)}return t.filter(s=>s!=="")}catch{return[e]}},Ar=({onClick:e,checked:t,label:n,disabled:r,labelVariant:s="caption2"})=>{const a=t?m.themedColor.primary:r?m.themedColor.textDisabled:m.themedColor.textLowEmphasis,i=t?m.themedColor.textHighEmphasis:r?m.themedColor.textLowEmphasis:m.themedColor.textHighEmphasis;return o.createElement(bc,{onClick:e,disabled:r},o.createElement(fc,null,o.createElement(D,{size:20,type:t?"radio-on":"radio-off",color:a})),o.createElement(pc,{variant:s,color:i},n))},fc=g.default.div`width:20px;height:20px;`,pc=g.default(M)`line-height:20px;word-break:break-word;`,bc=g.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,Ec=({csatPayload:e,submitted:t,defaultValue:n,value:r,onChange:s})=>(c.useEffect(()=>{typeof r>"u"&&typeof n=="boolean"&&(s==null||s(n))},[r,n]),e.cre?o.createElement(xc,null,o.createElement(j.Label,{required:e.cre.required},e.cre.question),o.createElement(vc,null,[{label:e.cre.positive_label,value:!0},{label:e.cre.negative_label,value:!1}].map(a=>o.createElement(Ar,{key:a.label,checked:r===a.value,label:a.label,disabled:t,onClick:()=>s==null?void 0:s(a.value)})))):null),xc=g.default.div`display:flex;flex-direction:column;gap:8px;`,vc=g.default.div`display:flex;flex-direction:column;gap:8px;`,Cc=({followUpItem:e,submitted:t,value:n="",onChange:r,hasError:s})=>{const{stringSet:a}=F();return o.createElement(yc,null,o.createElement(j.Label,{required:e.required},e.question),e.response_type==="free_text"&&o.createElement(j.TextInput,{variant:"multi-line",disabled:t,submitted:t,maxLength:100,value:n,onChange:i=>r(i),error:s}),e.response_type==="single_choice"&&o.createElement(_c,null,e.options.map(i=>o.createElement(Ar,{key:i,checked:n===i,label:i,disabled:t,onClick:()=>r==null?void 0:r(i),labelVariant:"body3"}))),s&&o.createElement(j.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},yc=g.default.div`display:flex;flex-direction:column;gap:8px;`,_c=g.default.div`display:flex;flex-direction:column;gap:8px;`,Sc=({value:e,selected:t,label:n})=>o.createElement(Tc,{$selected:t,"aria-label":n},Ac[e-1]),Tc=g.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Ac=[o.createElement("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o.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)"}),o.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"}),o.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"}),o.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"}),o.createElement("defs",null,o.createElement("linearGradient",{id:"paint0_linear_159_173206",x1:"20",y1:"2.08325",x2:"20",y2:"37.9166",gradientUnits:"userSpaceOnUse"},o.createElement("stop",{stopColor:"#FF2D1D"}),o.createElement("stop",{offset:"1",stopColor:"#FFA540"})))),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.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"}),o.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"}),o.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"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.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"}),o.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"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.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"}),o.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"})),o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none"},o.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"}),o.createElement("g",{clipPath:"url(#clip0_159_173224)"},o.createElement("g",{clipPath:"url(#clip1_159_173224)"},o.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"})),o.createElement("mask",{id:"mask0_159_173224",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"12",y:"22",width:"16",height:"9"},o.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"})),o.createElement("g",{mask:"url(#mask0_159_173224)"},o.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"}))),o.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"}),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_159_173224"},o.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"})),o.createElement("clipPath",{id:"clip1_159_173224"},o.createElement("rect",{width:"15.83",height:"7.915",fill:"white",transform:"translate(12.085 22.709)"}))))],wc=({csatPayload:e,submitted:t,value:n,onChange:r})=>{const s=typeof n>"u";return o.createElement(Ic,null,o.createElement(M,{variant:"caption3",color:m.themedColor.textMidEmphasis},e.csat_question),o.createElement($c,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const u=l+1,d=n===u;return o.createElement(Mc,{key:l,disabled:t,onClick:()=>r(u)},o.createElement(kc,{value:u,selected:s||d,label:a,src:i}),!!a&&o.createElement(M,{color:d?m.themedColor.textHighEmphasis:m.themedColor.textLowEmphasis,variant:"caption3"},a))})))},kc=({value:e,src:t,label:n,selected:r})=>{const[s,a]=c.useState(!1),i=s?o.createElement(Sc,{value:e,selected:r,label:n}):o.createElement(Oc,{$selected:r,"aria-label":n,src:t,onError:()=>a(!0)});return o.createElement(Lc,null,i)},Ic=g.default.div`display:flex;flex-direction:column;gap:8px;`,$c=g.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,Mc=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:${m.themedColor.textHighEmphasis};}`,Lc=g.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${m.color.background200};${R.dark`
|
|
220
220
|
background-color: ${m.color.background500};
|
|
221
221
|
`}
|
|
222
222
|
}
|
|
223
|
-
`,
|
|
223
|
+
`,Oc=g.default.img`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Rc=({csatPayload:e})=>o.createElement(M,{variant:"button",color:m.themedColor.textHighEmphasis},e.title),It=({csatPayload:e,type:t,renderSubmitButton:n,initialCsat:r,initialCsatReason:s,initialIsResolved:a})=>{const{params:i,setParams:l,error:u,setError:d,followUpItem:f,state:b,validateParams:E,itemProps:y}=Qs({csatPayload:e,type:t,initialCsat:r,initialCsatReason:s,initialIsResolved:a});return o.createElement(o.Fragment,null,o.createElement(Dc,null,o.createElement(Rc,{...y}),t===se.AI_AGENT_CSAT_5_WITH_CRE&&o.createElement(Ec,{...y,defaultValue:a,value:i.isResolved,onChange:x=>l({isResolved:x})}),o.createElement(wc,{...y,value:i.csat,onChange:x=>l({csat:x})}),f&&o.createElement(Cc,{...y,followUpItem:f,value:i.csatReason,onChange:x=>{l({csatReason:x}),d({followUpItem:!1})},hasError:u.followUpItem})),b!=="unsubmittable"&&o.createElement(o.Fragment,null,o.createElement(j.Separator,null),n({state:b,params:i,validateParams:E})))},Dc=g.default.div`display:flex;flex-direction:column;gap:12px;`,Pc=e=>{const{stringSet:t}=F();return vo(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})},Nc=()=>{const{stringSet:e}=F();return o.createElement(M,{variant:"body2",color:m.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},Bc=e=>{if(e.messageType!=="admin.csat")throw new Error("Invalid message type");const{extendedMessagePayload:t,onSubmitCSAT:n}=e,{csat:r,csatReason:s,csatExpireAt:a,isResolvedWhenDeterminedByUser:i}=e,l=He.useForceUpdate(),u=Pc(t==null?void 0:t.csat);if(!u||!u.visibility||!se[u.type])return null;const d=u.type===se.AI_AGENT_CSAT_5||u.type===se.AI_AGENT_CSAT_5_WITH_CRE||u.type===se.HELPDESK_CSAT_5?It:()=>null;return o.createElement(Fc,null,!r&&fn(a)?o.createElement(Nc,null):o.createElement(d,{csatPayload:u,type:u.type,initialCsat:r,initialCsatReason:s,initialIsResolved:i,renderSubmitButton:({state:f,params:b,validateParams:E})=>o.createElement(Hc,{$state:f,disabled:f==="submitted",onClick:async()=>{!fn(a)&&E()?await n({csatType:b.csatType,csat:b.csat,csatReason:b.csatReason,isResolved:b.isResolved,csatStartedAt:b.csatStartedAt,resolutionScore:b.resolutionScore}):l()}},o.createElement(M,{variant:"button"},f==="submitted"?u.csat_submitted_label:u.csat_submit_label))}))},Fc=g.default.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:16px;`,Hc=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:${m.color.primary.dark};}&:disabled{color:${({$state:e})=>e==="submitted"?m.themedColor.textHighEmphasis:m.color.ondark.textLowEmphasis};background-color:${m.themedColor.textDisabled};cursor:not-allowed;}`,xt=fe({template:Uc,components:{AdminMessage:mc,CSATMessage:Bc}});function Uc(e){const{components:t}=xt.useContext(),n=e.messageType==="admin"?o.createElement(t.AdminMessage,{...e}):e.messageType==="admin.csat"?o.createElement(t.CSATMessage,{...e}):null;return o.createElement(zc,{$marginBottom:jt(e.groupType)},n)}const zc=g.default.div`padding-inline:${P.HORIZONTAL_PADDING}px;margin-bottom:${({$marginBottom:e})=>e}px;`,Fn={file:"attach",snippet:"snippet",site:"website",sb_sprinklr:"sprinklr",sb_salesforce:"salesforce",sb_confluence:"confluence",sb_zendesk:"zendesk",sb_desk:"snippet"},wr=({actionbook:e,functionCalls:t,groundedness:n,agentMessageTemplates:r,onClickActionbook:s,onClickFunctionCall:a,onClickFunctionCallDetail:i,onClickGroundedness:l,onClickAgentMessageTemplate:u,bottomContent:d,renderCustomGroundednessIcon:f=E=>E.default,style:b={}})=>{const{iconColor:E="#000000",textColor:y="#000000",highlightColor:x=We.DEFAULT_PRIMARY}=b;return o.createElement(Hn,null,e&&o.createElement(Hn,null,o.createElement(ut,null,o.createElement(nt,null,o.createElement(D,{size:16,type:"actionbook",color:E})),o.createElement(tt,{$clickable:!!s,$highlightColor:x,variant:"body2",color:y,onClick:()=>s==null?void 0:s(e),maxTextLines:1},e.name))),t==null?void 0:t.map(v=>o.createElement($t,{key:v.key},o.createElement(nt,null,o.createElement(D,{size:16,type:"function",color:E})),o.createElement(ut,null,o.createElement(tt,{$clickable:!!a,$highlightColor:x,variant:"body2",color:y,onClick:()=>a==null?void 0:a(v),maxTextLines:1},v.name),i&&o.createElement(Gc,{role:"button",onClick:()=>i==null?void 0:i(v)},o.createElement(M,{variant:"body2",color:x},"View details"),o.createElement(D,{type:"chevron-right",size:16,color:x}))))),n==null?void 0:n.map(v=>o.createElement($t,{key:v.id},o.createElement(nt,null,f({default:o.createElement(D,{size:16,type:Fn[v.source_type]??Fn.snippet,color:E}),sourceType:v.source_type})),o.createElement(tt,{$clickable:!!l,$highlightColor:x,variant:"body2",color:y,onClick:()=>l==null?void 0:l(v),maxTextLines:1},v.preview_title))),r==null?void 0:r.map(v=>o.createElement($t,{key:v.key},o.createElement(nt,null,o.createElement(D,{size:16,type:"template",color:E})),o.createElement(tt,{$clickable:!!u,$highlightColor:x,variant:"body2",color:y,onClick:()=>u==null?void 0:u(v),maxTextLines:1},v.name))),d)},Vc=g.default(M)`font-weight:400;`,tt=g.default(Vc)`${({$clickable:e,$highlightColor:t})=>e&&A.css`
|
|
224
224
|
cursor: pointer;
|
|
225
225
|
text-decoration: underline;
|
|
226
226
|
&:hover {
|
|
227
227
|
color: ${t};
|
|
228
228
|
}
|
|
229
229
|
`}
|
|
230
|
-
`,nt=h.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,ut=h.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,Vc=h.default(ut)`cursor:pointer;gap:4px;`,$t=h.default(ut)`flex-direction:row;align-items:center;`,Hn=h.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,kr=c.createContext(null);function Gc({testerType:e,origin:t,children:n}){return o.createElement(kr.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&o.createElement(Wc,null),n)}const Me=()=>{const e=c.useContext(kr);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},Wc=()=>{const{isActionbookTester:e}=Me();return o.createElement(Ie.Template,{template:e?qc:void 0},o.createElement(Ie.MessageLogs,{component:jc}))},qc=e=>o.createElement(Sr,{...e,testerMode:!0,maxBodyWidth:P.WIDE_BODY_MAX_WIDTH}),jc=({extendedMessagePayload:e={}})=>{const{handlers:t}=U(),{manual:n,groundedness:r,function_calls:s,agent_message_templates:a,is_thinking:i}=e;return i||!n&&!(r!=null&&r.length)&&!(s!=null&&s.length)&&!(a!=null&&a.length)?o.createElement(o.Fragment,null):o.createElement(Kc,null,o.createElement(Yc,{width:4}),o.createElement(wr,{actionbook:n,functionCalls:s,groundedness:r,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:m.themedColor.textHighEmphasis,textColor:m.themedColor.textHighEmphasis,barColor:m.themedColor.textDisabled},bottomContent:o.createElement(Zc,{variant:"caption2",color:m.themedColor.textLowEmphasis},"Only visible in the tester")}))},Kc=h.default.div`display:flex;gap:16px;margin:16px ${P.HORIZONTAL_PADDING}px 0;align-self:stretch;`,Yc=h.default.div`width:${({width:e})=>e}px;background-color:${m.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Zc=h.default(M)`margin-top:5px;`,Ir=({start:e,title:t,titleAlign:n="start",end:r})=>{const s=c.useRef(null),a=c.useRef(null),[i,l]=c.useState(0),[u,d]=c.useState(0);return c.useLayoutEffect(()=>{s.current&&l(s.current.offsetWidth),a.current&&d(a.current.offsetWidth)},[e,r]),o.createElement(Xc,null,o.createElement(Jc,null,n==="center"&&t&&o.createElement(Qc,{$sideWidth:Math.max(i,u)},o.createElement(eu,null,t)),o.createElement(tu,null,o.createElement(nu,{ref:s},e),(n==="start"||n==="end")&&t&&o.createElement(ou,{$align:n,$hasStart:!!e,$hasEnd:!!r},t),o.createElement(ru,{ref:a},r))))},Xc=h.default.div`position:relative;width:100%;background-color:${({theme:e})=>e.colors.base.headerBackground};border-bottom:1px solid ${m.themedColor.textDisabled};`,Jc=h.default.div`position:relative;height:56px;padding:11px 12px;`,Qc=h.default.div`position:absolute;left:${({$sideWidth:e})=>e}px;right:${({$sideWidth:e})=>e}px;top:0;bottom:0;display:flex;align-items:center;justify-content:center;`,eu=h.default.div`max-width:100%;overflow:hidden;`,tu=h.default.div`display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:100%;z-index:1;`,nu=h.default.div`flex-shrink:0;`,ru=h.default.div`flex-shrink:0;`,ou=h.default.div`flex:1;overflow:hidden;display:flex;align-items:${({$align:e})=>e==="start"?"flex-start":"flex-end"};margin-left:${({$hasStart:e})=>e?8:0}px;margin-right:${({$hasEnd:e})=>e?8:0}px;`,Ue=({type:e,size:t=16,color:n,disabled:r,onClick:s,"aria-label":a})=>{const i=r?m.themedColor.textDisabled:m.themedColor.textHighEmphasis;return o.createElement(su,{onClick:s,disabled:r,"aria-label":a},o.createElement(D,{type:e,size:t,color:n??i}))},su=h.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,on=/iPad|iPhone|iPod/.test(navigator.userAgent),au=/Android/.test(navigator.userAgent),Ke=e=>on||au,Ye=()=>Ke()?24:16,iu=()=>{const{state:e}=U(),t=Ye(),n=()=>{e.setOpened(!1)};return o.createElement(Ue,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},{Provider:lu,useContext:J}=X("MessengerSession"),cu=c.forwardRef(function({children:e,...t},n){return o.createElement(hs,{ref:n,...t},r=>o.createElement(uu,{...r},e))}),uu=({children:e,...t})=>{const{chatSDK:n,logger:r,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:u}=U(),{userSessionInfo:d,authenticate:f,setActiveChannel:p,userSession:x,aiAgentInfo:y,launcherInfo:v}=t,E=c.useRef(null);return He.useGroupChannelHandler(n,{async onUserJoined(b,g){var _,I,S;if(b.conversation&&b.conversation.type===z.ConversationType.PROACTIVE&&g.userId===((_=n.currentUser)==null?void 0:_.userId)){r.info("messengerSession.onUserJoined: proactive channel joined",b.url);const A=((I=b.conversation)==null?void 0:I.status)??z.ConversationStatus.OPEN;p({url:b.url,status:A}),l.setOpened(!0),du({sound:document.hidden||!l.opened}),(S=E.current)==null||S.call(E,{channel:b})}}}),c.useEffect(()=>{f().then(({launcher:b})=>{b.auto_open&&!Ke()&&setTimeout(()=>l.setOpened(!0),500)}).catch(b=>{var g;r.error("messengerSession: failed to initialize",b),(g=u==null?void 0:u.onInitializeFailed)==null||g.call(u,b)})},[n,s,a,d==null?void 0:d.userId]),!x||!y||!v?null:o.createElement(lu,{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 du({sound:e}){const t="🔔You have received a new message",n=document.title,r=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(r),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const mu=e=>{const{chatSDK:t,handlers:n,logger:r}=U(),{aiAgentInfo:s}=J(),a=c.useRef(new Set),i=f=>{if(!(n!=null&&n.onCustomEvent))return;me(f)&&f.sender.userId===s.userId&&!ge.isStreaming(f)&&!a.current.has(f.messageId)&&(r.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=Ot(f.data);Array.isArray(p.history)&&p.history.length===0&&(r.debug("useCustomEventForMessageReceive: user_action_required",p),n.onCustomEvent({type:"user-action-requested",data:p}),a.current.add(f.messageId))}},u=(f,p)=>{f.url===e&&(i(p),l(p))},d=f=>{l(f)};return He.useGroupChannelHandler(t,{onMessageUpdated:u,onMessageReceived:u}),{checkForUserActionRequired:d}};function gu(e){return new Promise(t=>{const n=new Image;n.onload=function(){const r=String(n.width),s=String(n.height);URL.revokeObjectURL(n.src),t({width:r,height:s})},n.src=URL.createObjectURL(e)})}async function hu(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await gu(e.file);return new ye.MessageMetaArray({key:Zn,value:[t,n]})}}const fu=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=U(),r=c.useRef(t==null?void 0:t.agentAttributes);return r.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await hu(s),i={...s,metaArrays:a?[a]:void 0},l=pu(r.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===ye.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===ye.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},pu=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},$r=50,Mt=$r-40,{Provider:bu,useContext:Eu}=X("ConversationScroll"),Un={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function xu({scrollMode:e,children:t}){const n=c.useRef(null),r=c.useRef(null),s=c.useRef(Un),a=c.useRef(!1),i=c.useRef(null),[l,u]=c.useState(0),[d,f]=c.useState(0),[p,x]=c.useState(!1),[y,v]=c.useState(!1),[E,b]=c.useState(!1),g=c.useMemo(()=>p?"auto":e,[p,e]),C=c.useCallback(T=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{v(!1)},T)},[]),_=()=>{s.current.contentSnapshotHeight=s.current.contentHeight,s.current.shouldUpdate=!0,s.current.shouldRecalc=!0},I=()=>{const T=n.current;!T||!s.current.shouldUpdate||u(L=>{s.current.shouldUpdate=!1;const{contentHeight:N,contentSnapshotHeight:V,shouldRecalc:le}=s.current,ce=T.clientHeight;if(V>N)return L;const be=S(T,{messageType:"outgoing"});let Ee=0;if(be){const xe=be.message.offsetTop-Mt+ce;Ee=Math.max(0,xe-N)}else{const xe=N-V,Ve=ce-Mt;Ee=Math.max(0,xe-Ve)}return L===0||Ee!==L||le?(s.current.shouldRecalc=!1,Ee):L})},S=c.useCallback((T,L)=>{const{messageType:N="all"}=L??{},V=Array.from(T.querySelectorAll(`#${ne}-message-item`));let le=V;N==="outgoing"&&(le=V.filter(_t=>_t.getAttribute("data-layout-id")==="outgoingmessage"));const ce=le[le.length-1];if(!ce)return null;const be=T.getBoundingClientRect(),Ee=ce.getBoundingClientRect(),xe=T.scrollTop+(Ee.top-be.top),Ve=xe+ce.offsetHeight;return{message:ce,scrollTop:xe,lastMessageBottom:Ve}},[]),A=c.useCallback(()=>{const T=n.current;if(!T||g!=="fixed")return;const L=S(T);s.current.contentHeight=(L==null?void 0:L.lastMessageBottom)??T.scrollHeight,!a.current&&s.current.contentSnapshotHeight>0&&_();const N=Math.max(0,T.scrollHeight-T.scrollTop-T.clientHeight);f(N),I()},[g,S]),w=c.useCallback(()=>{r.current&&(r.current.disconnect(),r.current=null),s.current=Un,u(0),f(0)},[]),O=c.useCallback((T=!0)=>{const L=n.current;L&&L.scrollTo({top:L.scrollHeight,behavior:T?"smooth":"auto"})},[]),W=c.useCallback(T=>{T&&(n.current=T,g==="fixed"&&(w(),s.current.viewport=T.clientHeight,r.current=new MutationObserver(()=>{A()}),r.current.observe(T,{childList:!0,subtree:!0})))},[g,A,w]),te=c.useCallback(()=>{const T=n.current;if(!T)return;const L=S(T,{messageType:"outgoing"});L&&(T.scrollTo({top:L.message.offsetTop-Mt,behavior:"smooth"}),C(500))},[S,C]),K=T=>{const{scrollHeight:L,scrollTop:N,clientHeight:V}=T.currentTarget,le=Math.max(0,L-N-V);f(le)},ie=c.useCallback(()=>{g==="fixed"&&(v(!0),_())},[g]),oe=c.useCallback(()=>{g==="fixed"?setTimeout(()=>te(),300):O()},[g,te]),Ae=c.useCallback(T=>{a.current=T,g==="fixed"&&_()},[g]),we=c.useCallback(T=>{x(T)},[]),q=c.useCallback(T=>{b(T),g==="auto"&&T&&O(!0)},[g,O]),ee=!(d<=$r)&&!y&&!E;return o.createElement(bu,{value:{ref:W,state:{bottomSpace:l,shouldShowScrollButton:ee},props:{onScroll:K},actions:{scrollToBottom:O,onBeforeMessageSend:ie,onAfterMessageSend:oe,onStreamingUpdate:Ae,onConversationClosed:we,onTypingIndicatorUpdate:q}}},t)}const{Provider:vu,Context:Cu,useContext:Q}=X("Conversation"),yu=({children:e})=>{var s;const{channelSource:t}=Q(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:r}=mu(n);return c.useEffect(()=>{var i;const a=(i=t.channel)==null?void 0:i.lastMessage;a&&r(a)},[t.channel,r]),o.createElement(o.Fragment,null,e)},_u=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:r,children:s})=>{var C;const{config:a}=G(),{activeChannel:i,refreshActiveChannel:l,aiAgentInfo:u}=J(),{testerType:d}=Me(),f=Eu(),p=((C=a==null?void 0:a.conversation)==null?void 0:C.scrollMode)??"auto",{onBeforeSendMessage:x,onAfterSendMessage:y}=fu({onScrollAfterSendMessage:()=>{f.actions.onAfterMessageSend()}}),v=e||(i==null?void 0:i.url),E=c.useCallback(_=>(f.actions.onBeforeMessageSend(),x(_)),[f.actions,x]),b=c.useCallback(_=>{const I=_.some(S=>ge.isStreaming(S));if(f.actions.onStreamingUpdate(I),p==="auto"){const S=_[_.length-1];S&&ge.shouldScrollToBottom(S,u.userId,!!d)&&setTimeout(()=>f.actions.scrollToBottom(!0),100)}},[f.actions,p,u.userId,d]),g=c.useCallback(async()=>{await l(),e&&(t==null||t())},[l,e,t]);return o.createElement(Ss,{key:v,channelUrl:v,onBeforeSendMessage:E,onAfterSendMessage:y,onMessagesUpdated:b,onMessagesReceived:b,onChannelDeleted:g,shouldMarkAsRead:r},_=>o.createElement(vu,{value:{..._,scrollSource:f,goToActiveConversation:g,onNavigateToConversationList:n}},o.createElement(yu,null,s)))},Mr=({children:e,...t})=>{var s;const{config:n}=G(),r=((s=n==null?void 0:n.conversation)==null?void 0:s.scrollMode)??"auto";return o.createElement(xu,{scrollMode:r},o.createElement(_u,{...t},e))},Su=()=>{const{enableCloseConversationButton:e,dispatcher:t}=U(),{channelSource:n}=Q(),r=n.channel,s=Ye(),a=(r==null?void 0:r.isAIAgent)&&e,i=!Wt(r);if(!a)return null;const l=async()=>{r&&await t.send(nr.CloseConversation({channelUrl:r.url}))};return o.createElement(Ue,{"aria-label":"close conversation",type:"mute",size:s,disabled:i,onClick:l})},Tu=()=>{const{state:e,enableExpandButton:t}=U(),n=Ye();return t?o.createElement(Ue,{"aria-label":"expand",type:e.expanded?"collapse":"expand",size:n,onClick:()=>e.setExpanded(!e.expanded)}):null},Au=({label:e,children:t,position:n="top",disabled:r})=>r?t:o.createElement(Ut,null,t,o.createElement(Iu,{$position:n},o.createElement($u,{variant:"caption1"},e),o.createElement(wu,{$position:n}))),wu=({$position:e})=>o.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"},o.createElement("path",{d:"M6 6L0 0h12L6 6Z",fill:m.themedColor.textHighEmphasis})),ku={top:k.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:k.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},Ut=h.default.div`position:relative;`,Iu=h.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${$e.TOOLTIP};${({$position:e})=>ku[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Ut}:hover &,${Ut}:focus-within &{opacity:1;}`,$u=h.default(M)`padding:6px 8px;background:${m.themedColor.textHighEmphasis};color:${m.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Mu=()=>{const{logger:e}=U(),{stringSet:t}=F(),{channelSource:n}=Q(),r=n.channel,s=Ye(),a=Xt("handoff-button",r),i=!Wt(r)||Ne(r),l=async()=>{try{const u=await(r==null?void 0:r.markConversationAsHandoff());e.info("conversation.handleAgentHandoff: success",u)}catch(u){e.error("conversation.handleAgentHandoff: error",u)}};return a?o.createElement(Au,{label:t.HEADER_BUTTON__AGENT_HANDOFF,position:"bottom",disabled:i},o.createElement(Ue,{"aria-label":"request handoff",type:"agent",size:s,disabled:i,onClick:l})):null},Lu=()=>{const{onNavigateToConversationList:e}=Q();return e?o.createElement(Ue,{type:"menu",size:24,onClick:()=>e()}):null},Lr=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:r}=J(),{fallbackIcon:s,url:a}=dr({channel:e,aiAgentInfo:r,userSession:n}),i=k.useTheme();return a?o.createElement(Qt,{src:a,size:t}):o.createElement(Ou,{$size:t,$bgColor:i.colors.base.primary},o.createElement(D,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},Ou=h.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;`,Ru=()=>{const{channelSource:e}=Q(),{aiAgentInfo:t,userSession:n}=J(),r=e.channel,s=dr({channel:r,userSession:n,aiAgentInfo:t});return o.createElement(Du,null,o.createElement(Lr,{channel:r,size:34}),o.createElement(Pu,{variant:"h2",color:m.themedColor.textHighEmphasis},s.title))},Du=h.default.div`display:flex;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Pu=h.default(M)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Nu=e=>{const{components:t}=Le.useContext();return o.createElement(Ir,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Bu=()=>{const{components:e}=Le.useContext();return o.createElement(e.MenuButton,null)},Fu=()=>{const{components:e}=Le.useContext();return o.createElement(e.Title,null)},Hu=()=>{const{components:e}=Le.useContext();return o.createElement(zu,null,o.createElement(e.HandoffButton,null),o.createElement(e.ConversationCloseButton,null),o.createElement(e.ExpandButton,null),o.createElement(e.CloseButton,null))},Le=fe({template:Nu,components:{StartArea:Bu,TitleArea:Fu,EndArea:Hu,MenuButton:Lu,Title:Ru,HandoffButton:Mu,ConversationCloseButton:Su,ExpandButton:Tu,CloseButton:iu}}),Uu=()=>{const{isActionbookTester:e}=Me(),{Template:t}=Le.useContext();return e?null:o.createElement(t,{titleAlign:"start"})},zu=h.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,sn=c.createContext({onDrop:he,subscribe:()=>he}),zt=({children:e})=>{const t=c.useRef(new Set);return o.createElement(sn.Provider,{value:{onDrop:n=>{var r;if(n.preventDefault(),(r=n.dataTransfer)!=null&&r.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)},Vu=({onDropFiles:e})=>{const{subscribe:t}=c.useContext(sn);c.useEffect(()=>t(e),[e])};zt.Consumer=({children:e})=>{const{onDrop:t}=c.useContext(sn);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const an=({iconSize:e=64,icon:t,className:n,label:r,children:s})=>o.createElement(Wu,{className:n},t&&o.createElement(D,{type:t,size:e,color:m.themedColor.textLowEmphasis}),r&&o.createElement(M,{variant:"body1",color:m.themedColor.textMidEmphasis},r),s),Gu=h.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,Wu=h.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,qu=({label:e="Something went wrong",icon:t="error",action:n,...r})=>o.createElement(an,{icon:t,label:e,...r},n&&o.createElement(ju,{onClick:n.onClick,label:n.label??"Retry"})),ju=({label:e,onClick:t})=>o.createElement(Ku,{tabIndex:0,onClick:t},o.createElement(D,{type:"refresh",size:20}),o.createElement(M,{variant:"button",color:m.color.primary.main},e)),Ku=h.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,Yu=({iconSize:e=48,className:t})=>o.createElement(rn,{size:e,className:t}),Zu=({label:e="No channels",icon:t="chat",...n})=>o.createElement(an,{icon:t,label:e,...n}),Xu=({label:e="No messages",icon:t="message",...n})=>o.createElement(an,{icon:t,label:e,...n}),Ju=e=>{const{components:t}=vt.useContext(),n=e.type==="loading"?o.createElement(t.Loading,{...e}):e.type==="error"?o.createElement(t.Error,{...e}):e.type==="noChannels"?o.createElement(t.NoChannels,{...e}):e.type==="noMessages"?o.createElement(t.NoMessages,{...e}):null;return n&&o.createElement(Gu,null,n)},vt=fe({template:Ju,components:{Loading:Yu,Error:qu,NoChannels:Zu,NoMessages:Xu}}),Fe=e=>{const{Template:t}=vt.useContext();return o.createElement(t,{...e})},zn=e=>Xn(e)||Jn(e);function Qu(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function ed(e,t){return e.filter(n=>ge.isWelcomeMessage(n,t))}const td=h.default.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`,nd=h.default.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`,rd=h.default.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`,od=h.default.div`margin-inline-end:8px;`,sd=h.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);}`,ad=h.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;}`,id=h.default.div`display:flex;width:160px;justify-content:flex-end;`,ld=h.default.div`inset-inline-end:0;display:flex;flex-direction:row;`,Or=h.default.div`width:64px;padding:21px;box-sizing:border-box;cursor:${e=>e.disabled?"not-allowed":"pointer"};`,cd=h.default(Or)`border-inline-start:1px solid ${m.themedColor.textDisabled};`,ud=h.default.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`,dd=h.default.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,md=h.default.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`,gd=h.default.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,hd=({file:e,sender:t={},onClose:n,onDownloadClick:r})=>{const{type:s,url:a,name:i=""}=e,{profileUrl:l,nickname:u,userId:d}=t,{aiAgentInfo:f}=J();return o.createElement(pd,{profileUrl:l??"",nickname:u??"",type:s,url:a,name:i,onClose:n,isBotMessage:d===f.userId,onDownloadClick:r})},fd=({profileUrl:e,isBotMessage:t})=>t&&!e?o.createElement(bd,{$size:32},o.createElement(D,{type:"delight",size:20})):o.createElement(Qt,{size:32,src:e}),pd=({profileUrl:e,isBotMessage:t,nickname:n,name:r,type:s,url:a,onClose:i,onDownloadClick:l})=>{const{stringSet:u}=F();return o.createElement(bt,{onClose:i,visible:!0,rootElementId:re.MODAL_ROOT},o.createElement(td,null,o.createElement(nd,null,o.createElement(rd,null,o.createElement(od,null,o.createElement(fd,{profileUrl:e,isBotMessage:t})),o.createElement(sd,null,o.createElement(M,{variant:"h2",color:m.themedColor.textHighEmphasis},r)),o.createElement(ad,null,o.createElement(M,{variant:"body1",color:m.color.ondark.textMidEmphasis},n))),o.createElement(id,null,zn(s)&&o.createElement(ld,null,o.createElement(Or,{as:"a",href:a,target:"_blank",rel:pt,onClick:l},o.createElement(D,{type:"download",color:m.themedColor.textHighEmphasis,size:24}))),o.createElement(cd,{onClick:i},o.createElement(D,{type:"close",color:m.themedColor.textHighEmphasis,size:24})))),o.createElement(ud,{onClick:d=>d.currentTarget===d.target&&i()},Jn(s)&&o.createElement(dd,{controls:!0},o.createElement("source",{src:a,type:s})),Xn(s)&&o.createElement(md,{src:a,alt:r}),!zn(s)&&o.createElement(gd,null,o.createElement(M,{variant:"h1",color:m.themedColor.textHighEmphasis},u.FILE_VIEWER__UNSUPPORT)))))},bd=h.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;ellipse,path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}`,Rr=({className:e,locale:t,date:n=Date.now(),formatString:r="MMMM dd, yyyy",style:s})=>o.createElement(Ed,{id:`${ne}-date-separator`,style:s,className:e},o.createElement(M,{variant:"caption4",color:m.themedColor.textMidEmphasis},Ce.format(n,r,{locale:t}))),Ed=h.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,xd=c.forwardRef(function(t,n){const{messages:r,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:u,onLoadNext:d,loadThreshold:f=.05,onScroll:p=he,depsForResetScrollPositionToBottom:x,stackDirection:y="top",bottomSpacerHeight:v=0}=t,E=c.useRef(null),b=c.useCallback(A=>{E.current=A,n&&(typeof n=="function"?n(A):n.current=A)},[n]),g=c.useRef(!1),C=c.useRef(void 0),_=c.useRef(0),I=c.useRef(0);c.useLayoutEffect(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},x),c.useLayoutEffect(()=>{E.current&&(C.current==="top"&&(E.current.scrollTop=E.current.scrollHeight-I.current),C.current==="bottom"&&(E.current.scrollTop=_.current),C.current=void 0)},[E.current,r.length]);const S=async A=>{if(p==null||p(A),!E.current)return;const w=E.current;if(I.current=w.scrollHeight-w.scrollTop,_.current=w.scrollTop,g.current)return;const O=w.clientHeight*Math.min(Math.max(0,f),1);w.scrollTop<=O?(g.current=!0,C.current="top",await u(),g.current=!1):w.scrollHeight-w.scrollTop-w.clientHeight<=O?(g.current=!0,C.current="bottom",await d(),g.current=!1):C.current=void 0};return o.createElement(vd,{id:"infinite-list-container"},o.createElement(Cd,{id:"infinite-list-inner",ref:b,onScroll:S},y==="bottom"&&o.createElement("div",{style:{flexGrow:1}}),a,r.map((A,w)=>s({message:A,index:w})),i,v>0&&o.createElement("div",{style:{minHeight:v}})),o.createElement(yd,{id:"infinite-list-overlay-container"},o.createElement(_d,{id:"infinite-list-overlay"},l)))}),vd=h.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,Cd=h.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;scrollbar-color:${m.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,yd=h.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,_d=h.default.div`pointer-events:auto;`,Sd=({className:e,onClick:t})=>o.createElement(Td,{className:e,onClick:t,tabIndex:0},o.createElement(D,{size:24,type:"chevron-down",color:m.color.primary.main})),Td=h.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);${R.light`
|
|
230
|
+
`,nt=g.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,ut=g.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,Gc=g.default(ut)`cursor:pointer;gap:4px;`,$t=g.default(ut)`flex-direction:row;align-items:center;`,Hn=g.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,kr=c.createContext(null);function Wc({testerType:e,origin:t,children:n}){return o.createElement(kr.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&o.createElement(qc,null),n)}const Me=()=>{const e=c.useContext(kr);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},qc=()=>{const{isActionbookTester:e}=Me();return o.createElement(Ie.Template,{template:e?jc:void 0},o.createElement(Ie.MessageLogs,{component:Kc}))},jc=e=>o.createElement(Sr,{...e,testerMode:!0,maxBodyWidth:P.WIDE_BODY_MAX_WIDTH}),Kc=({extendedMessagePayload:e={}})=>{const{handlers:t}=U(),{manual:n,groundedness:r,function_calls:s,agent_message_templates:a,is_thinking:i}=e;return i||!n&&!(r!=null&&r.length)&&!(s!=null&&s.length)&&!(a!=null&&a.length)?o.createElement(o.Fragment,null):o.createElement(Yc,null,o.createElement(Zc,{width:4}),o.createElement(wr,{actionbook:n,functionCalls:s,groundedness:r,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:m.themedColor.textHighEmphasis,textColor:m.themedColor.textHighEmphasis,barColor:m.themedColor.textDisabled},bottomContent:o.createElement(Xc,{variant:"caption2",color:m.themedColor.textLowEmphasis},"Only visible in the tester")}))},Yc=g.default.div`display:flex;gap:16px;margin:16px ${P.HORIZONTAL_PADDING}px 0;align-self:stretch;`,Zc=g.default.div`width:${({width:e})=>e}px;background-color:${m.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Xc=g.default(M)`margin-top:5px;`,Ir=({start:e,title:t,titleAlign:n="start",end:r})=>{const s=c.useRef(null),a=c.useRef(null),[i,l]=c.useState(0),[u,d]=c.useState(0);return c.useLayoutEffect(()=>{s.current&&l(s.current.offsetWidth),a.current&&d(a.current.offsetWidth)},[e,r]),o.createElement(Jc,null,o.createElement(Qc,null,n==="center"&&t&&o.createElement(eu,{$sideWidth:Math.max(i,u)},o.createElement(tu,null,t)),o.createElement(nu,null,o.createElement(ru,{ref:s},e),(n==="start"||n==="end")&&t&&o.createElement(su,{$align:n,$hasStart:!!e,$hasEnd:!!r},t),o.createElement(ou,{ref:a},r))))},Jc=g.default.div`position:relative;width:100%;background-color:${({theme:e})=>e.colors.base.headerBackground};border-bottom:1px solid ${m.themedColor.textDisabled};`,Qc=g.default.div`position:relative;height:56px;padding:11px 12px;`,eu=g.default.div`position:absolute;left:${({$sideWidth:e})=>e}px;right:${({$sideWidth:e})=>e}px;top:0;bottom:0;display:flex;align-items:center;justify-content:center;`,tu=g.default.div`max-width:100%;overflow:hidden;`,nu=g.default.div`display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:100%;z-index:1;`,ru=g.default.div`flex-shrink:0;`,ou=g.default.div`flex-shrink:0;`,su=g.default.div`flex:1;overflow:hidden;display:flex;align-items:${({$align:e})=>e==="start"?"flex-start":"flex-end"};margin-left:${({$hasStart:e})=>e?8:0}px;margin-right:${({$hasEnd:e})=>e?8:0}px;`,Ue=({type:e,size:t=16,color:n,disabled:r,onClick:s,"aria-label":a})=>{const i=r?m.themedColor.textDisabled:m.themedColor.textHighEmphasis;return o.createElement(au,{onClick:s,disabled:r,"aria-label":a},o.createElement(D,{type:e,size:t,color:n??i}))},au=g.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,on=/iPad|iPhone|iPod/.test(navigator.userAgent),iu=/Android/.test(navigator.userAgent),Ke=e=>on||iu,Ye=()=>Ke()?24:16,lu=()=>{const{state:e}=U(),t=Ye(),n=()=>{e.setOpened(!1)};return o.createElement(Ue,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},{Provider:cu,useContext:J}=X("MessengerSession"),uu=c.forwardRef(function({children:e,...t},n){return o.createElement(fs,{ref:n,...t},r=>o.createElement(du,{...r},e))}),du=({children:e,...t})=>{const{chatSDK:n,logger:r,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:u}=U(),{userSessionInfo:d,authenticate:f,setActiveChannel:b,userSession:E,aiAgentInfo:y,launcherInfo:x}=t,v=c.useRef(null);return He.useGroupChannelHandler(n,{async onUserJoined(p,h){var _,w,S;if(p.conversation&&p.conversation.type===V.ConversationType.PROACTIVE&&h.userId===((_=n.currentUser)==null?void 0:_.userId)){r.info("messengerSession.onUserJoined: proactive channel joined",p.url);const k=((w=p.conversation)==null?void 0:w.status)??V.ConversationStatus.OPEN;b({url:p.url,status:k}),l.setOpened(!0),mu({sound:document.hidden||!l.opened}),(S=v.current)==null||S.call(v,{channel:p})}}}),c.useEffect(()=>{f().then(({launcher:p})=>{p.auto_open&&!Ke()&&setTimeout(()=>l.setOpened(!0),500)}).catch(p=>{var h;r.error("messengerSession: failed to initialize",p),(h=u==null?void 0:u.onInitializeFailed)==null||h.call(u,p)})},[n,s,a,d==null?void 0:d.userId]),!E||!y||!x?null:o.createElement(cu,{value:{...t,userSession:E,aiAgentInfo:{...y,...i==null?void 0:i.bot},launcherInfo:{...x,...i==null?void 0:i.launcher},registerOnJoinedProactiveConversation:p=>v.current=p}},e)};function mu({sound:e}){const t="🔔You have received a new message",n=document.title,r=setInterval(()=>{document.title=document.title===t?n:t},750);setTimeout(()=>clearInterval(r),5e3),e&&Promise.resolve().then(()=>require("./B93o4u0P.cjs")).then(s=>{new Audio(s.default).play()})}const gu=e=>{const{chatSDK:t,handlers:n,logger:r}=U(),{aiAgentInfo:s}=J(),a=c.useRef(new Set),i=f=>{if(!(n!=null&&n.onCustomEvent))return;me(f)&&f.sender.userId===s.userId&&!ge.isStreaming(f)&&!a.current.has(f.messageId)&&(r.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 b=Ot(f.data);Array.isArray(b.history)&&b.history.length===0&&(r.debug("useCustomEventForMessageReceive: user_action_required",b),n.onCustomEvent({type:"user-action-requested",data:b}),a.current.add(f.messageId))}},u=(f,b)=>{f.url===e&&(i(b),l(b))},d=f=>{l(f)};return He.useGroupChannelHandler(t,{onMessageUpdated:u,onMessageReceived:u}),{checkForUserActionRequired:d}};function hu(e){return new Promise(t=>{const n=new Image;n.onload=function(){const r=String(n.width),s=String(n.height);URL.revokeObjectURL(n.src),t({width:r,height:s})},n.src=URL.createObjectURL(e)})}async function fu(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await hu(e.file);return new ye.MessageMetaArray({key:Zn,value:[t,n]})}}const pu=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=U(),r=c.useRef(t==null?void 0:t.agentAttributes);return r.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await fu(s),i={...s,metaArrays:a?[a]:void 0},l=bu(r.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===ye.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===ye.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},bu=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},$r=50,Mt=$r-40,{Provider:Eu,useContext:xu}=X("ConversationScroll"),Un={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function vu({scrollMode:e,children:t}){const n=c.useRef(null),r=c.useRef(null),s=c.useRef(Un),a=c.useRef(!1),i=c.useRef(null),[l,u]=c.useState(0),[d,f]=c.useState(0),[b,E]=c.useState(!1),[y,x]=c.useState(!1),[v,p]=c.useState(!1),h=c.useMemo(()=>b?"auto":e,[b,e]),C=c.useCallback(T=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{x(!1)},T)},[]),_=()=>{s.current.contentSnapshotHeight=s.current.contentHeight,s.current.shouldUpdate=!0,s.current.shouldRecalc=!0},w=()=>{const T=n.current;!T||!s.current.shouldUpdate||u(O=>{s.current.shouldUpdate=!1;const{contentHeight:N,contentSnapshotHeight:G,shouldRecalc:le}=s.current,ce=T.clientHeight;if(G>N)return O;const be=S(T,{messageType:"outgoing"});let Ee=0;if(be){const xe=be.message.offsetTop-Mt+ce;Ee=Math.max(0,xe-N)}else{const xe=N-G,Ve=ce-Mt;Ee=Math.max(0,xe-Ve)}return O===0||Ee!==O||le?(s.current.shouldRecalc=!1,Ee):O})},S=c.useCallback((T,O)=>{const{messageType:N="all"}=O??{},G=Array.from(T.querySelectorAll(`#${ne}-message-item`));let le=G;N==="outgoing"&&(le=G.filter(_t=>_t.getAttribute("data-layout-id")==="outgoingmessage"));const ce=le[le.length-1];if(!ce)return null;const be=T.getBoundingClientRect(),Ee=ce.getBoundingClientRect(),xe=T.scrollTop+(Ee.top-be.top),Ve=xe+ce.offsetHeight;return{message:ce,scrollTop:xe,lastMessageBottom:Ve}},[]),k=c.useCallback(()=>{const T=n.current;if(!T||h!=="fixed")return;const O=S(T);s.current.contentHeight=(O==null?void 0:O.lastMessageBottom)??T.scrollHeight,!a.current&&s.current.contentSnapshotHeight>0&&_();const N=Math.max(0,T.scrollHeight-T.scrollTop-T.clientHeight);f(N),w()},[h,S]),I=c.useCallback(()=>{r.current&&(r.current.disconnect(),r.current=null),s.current=Un,u(0),f(0)},[]),L=c.useCallback((T=!0)=>{const O=n.current;O&&O.scrollTo({top:O.scrollHeight,behavior:T?"smooth":"auto"})},[]),z=c.useCallback(T=>{T&&(n.current=T,h==="fixed"&&(I(),s.current.viewport=T.clientHeight,r.current=new MutationObserver(()=>{k()}),r.current.observe(T,{childList:!0,subtree:!0})))},[h,k,I]),te=c.useCallback(()=>{const T=n.current;if(!T)return;const O=S(T,{messageType:"outgoing"});O&&(T.scrollTo({top:O.message.offsetTop-Mt,behavior:"smooth"}),C(500))},[S,C]),K=T=>{const{scrollHeight:O,scrollTop:N,clientHeight:G}=T.currentTarget,le=Math.max(0,O-N-G);f(le)},ie=c.useCallback(()=>{h==="fixed"&&(x(!0),_())},[h]),oe=c.useCallback(()=>{h==="fixed"?setTimeout(()=>te(),300):L()},[h,te]),Ae=c.useCallback(T=>{a.current=T,h==="fixed"&&_()},[h]),we=c.useCallback(T=>{E(T)},[]),q=c.useCallback(T=>{p(T),h==="auto"&&T&&L(!0)},[h,L]),ee=!(d<=$r)&&!y&&!v;return o.createElement(Eu,{value:{ref:z,state:{bottomSpace:l,shouldShowScrollButton:ee},props:{onScroll:K},actions:{scrollToBottom:L,onBeforeMessageSend:ie,onAfterMessageSend:oe,onStreamingUpdate:Ae,onConversationClosed:we,onTypingIndicatorUpdate:q}}},t)}const{Provider:Cu,Context:yu,useContext:Q}=X("Conversation"),_u=({children:e})=>{var s;const{channelSource:t}=Q(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:r}=gu(n);return c.useEffect(()=>{var i;const a=(i=t.channel)==null?void 0:i.lastMessage;a&&r(a)},[t.channel,r]),o.createElement(o.Fragment,null,e)},Su=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:r,children:s})=>{var C;const{config:a}=W(),{activeChannel:i,refreshActiveChannel:l,aiAgentInfo:u}=J(),{testerType:d}=Me(),f=xu(),b=((C=a==null?void 0:a.conversation)==null?void 0:C.scrollMode)??"auto",{onBeforeSendMessage:E,onAfterSendMessage:y}=pu({onScrollAfterSendMessage:()=>{f.actions.onAfterMessageSend()}}),x=e||(i==null?void 0:i.url),v=c.useCallback(_=>(f.actions.onBeforeMessageSend(),E(_)),[f.actions,E]),p=c.useCallback(_=>{const w=_.some(S=>ge.isStreaming(S));if(f.actions.onStreamingUpdate(w),b==="auto"){const S=_[_.length-1];S&&ge.shouldScrollToBottom(S,u.userId,!!d)&&setTimeout(()=>f.actions.scrollToBottom(!0),100)}},[f.actions,b,u.userId,d]),h=c.useCallback(async()=>{await l(),e&&(t==null||t())},[l,e,t]);return o.createElement(Ts,{key:x,channelUrl:x,onBeforeSendMessage:v,onAfterSendMessage:y,onMessagesUpdated:p,onMessagesReceived:p,onChannelDeleted:h,shouldMarkAsRead:r},_=>o.createElement(Cu,{value:{..._,scrollSource:f,goToActiveConversation:h,onNavigateToConversationList:n}},o.createElement(_u,null,s)))},Mr=({children:e,...t})=>{var s;const{config:n}=W(),r=((s=n==null?void 0:n.conversation)==null?void 0:s.scrollMode)??"auto";return o.createElement(vu,{scrollMode:r},o.createElement(Su,{...t},e))},Tu=()=>{const{enableCloseConversationButton:e,dispatcher:t}=U(),{channelSource:n}=Q(),r=n.channel,s=Ye(),a=(r==null?void 0:r.isAIAgent)&&e,i=!Wt(r);if(!a)return null;const l=async()=>{r&&await t.send(nr.CloseConversation({channelUrl:r.url}))};return o.createElement(Ue,{"aria-label":"close conversation",type:"mute",size:s,disabled:i,onClick:l})},Au=()=>{const{state:e,enableExpandButton:t}=U(),n=Ye();return t?o.createElement(Ue,{"aria-label":"expand",type:e.expanded?"collapse":"expand",size:n,onClick:()=>e.setExpanded(!e.expanded)}):null},wu=({label:e,children:t,position:n="top",disabled:r})=>r?t:o.createElement(Ut,null,t,o.createElement($u,{$position:n},o.createElement(Mu,{variant:"caption1"},e),o.createElement(ku,{$position:n}))),ku=({$position:e})=>o.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"},o.createElement("path",{d:"M6 6L0 0h12L6 6Z",fill:m.themedColor.textHighEmphasis})),Iu={top:A.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:A.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},Ut=g.default.div`position:relative;`,$u=g.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${$e.TOOLTIP};${({$position:e})=>Iu[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Ut}:hover &,${Ut}:focus-within &{opacity:1;}`,Mu=g.default(M)`padding:6px 8px;background:${m.themedColor.textHighEmphasis};color:${m.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Lu=()=>{const{logger:e}=U(),{stringSet:t}=F(),{channelSource:n}=Q(),r=n.channel,s=Ye(),a=Xt("handoff-button",r),i=!Wt(r)||Ne(r),l=async()=>{try{const u=await(r==null?void 0:r.markConversationAsHandoff());e.info("conversation.handleAgentHandoff: success",u)}catch(u){e.error("conversation.handleAgentHandoff: error",u)}};return a?o.createElement(wu,{label:t.HEADER_BUTTON__AGENT_HANDOFF,position:"bottom",disabled:i},o.createElement(Ue,{"aria-label":"request handoff",type:"agent",size:s,disabled:i,onClick:l})):null},Ou=()=>{const{onNavigateToConversationList:e}=Q();return e?o.createElement(Ue,{type:"menu",size:24,onClick:()=>e()}):null},Lr=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:r}=J(),{fallbackIcon:s,url:a}=dr({channel:e,aiAgentInfo:r,userSession:n}),i=A.useTheme();return a?o.createElement(Qt,{src:a,size:t}):o.createElement(Ru,{$size:t,$bgColor:i.colors.base.primary},o.createElement(D,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},Ru=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;`,Du=()=>{const{channelSource:e}=Q(),{aiAgentInfo:t,userSession:n}=J(),r=e.channel,s=dr({channel:r,userSession:n,aiAgentInfo:t});return o.createElement(Pu,null,o.createElement(Lr,{channel:r,size:34}),o.createElement(Nu,{variant:"h2",color:m.themedColor.textHighEmphasis},s.title))},Pu=g.default.div`display:flex;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Nu=g.default(M)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Bu=e=>{const{components:t}=Le.useContext();return o.createElement(Ir,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Fu=()=>{const{components:e}=Le.useContext();return o.createElement(e.MenuButton,null)},Hu=()=>{const{components:e}=Le.useContext();return o.createElement(e.Title,null)},Uu=()=>{const{components:e}=Le.useContext();return o.createElement(Vu,null,o.createElement(e.HandoffButton,null),o.createElement(e.ConversationCloseButton,null),o.createElement(e.ExpandButton,null),o.createElement(e.CloseButton,null))},Le=fe({template:Bu,components:{StartArea:Fu,TitleArea:Hu,EndArea:Uu,MenuButton:Ou,Title:Du,HandoffButton:Lu,ConversationCloseButton:Tu,ExpandButton:Au,CloseButton:lu}}),zu=()=>{const{isActionbookTester:e}=Me(),{Template:t}=Le.useContext();return e?null:o.createElement(t,{titleAlign:"start"})},Vu=g.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,sn=c.createContext({onDrop:he,subscribe:()=>he}),zt=({children:e})=>{const t=c.useRef(new Set);return o.createElement(sn.Provider,{value:{onDrop:n=>{var r;if(n.preventDefault(),(r=n.dataTransfer)!=null&&r.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)},Gu=({onDropFiles:e})=>{const{subscribe:t}=c.useContext(sn);c.useEffect(()=>t(e),[e])};zt.Consumer=({children:e})=>{const{onDrop:t}=c.useContext(sn);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const an=({iconSize:e=64,icon:t,className:n,label:r,children:s})=>o.createElement(qu,{className:n},t&&o.createElement(D,{type:t,size:e,color:m.themedColor.textLowEmphasis}),r&&o.createElement(M,{variant:"body1",color:m.themedColor.textMidEmphasis},r),s),Wu=g.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,qu=g.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,ju=({label:e="Something went wrong",icon:t="error",action:n,...r})=>o.createElement(an,{icon:t,label:e,...r},n&&o.createElement(Ku,{onClick:n.onClick,label:n.label??"Retry"})),Ku=({label:e,onClick:t})=>o.createElement(Yu,{tabIndex:0,onClick:t},o.createElement(D,{type:"refresh",size:20}),o.createElement(M,{variant:"button",color:m.color.primary.main},e)),Yu=g.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,Zu=({iconSize:e=48,className:t})=>o.createElement(rn,{size:e,className:t}),Xu=({label:e="No channels",icon:t="chat",...n})=>o.createElement(an,{icon:t,label:e,...n}),Ju=({label:e="No messages",icon:t="message",...n})=>o.createElement(an,{icon:t,label:e,...n}),Qu=e=>{const{components:t}=vt.useContext(),n=e.type==="loading"?o.createElement(t.Loading,{...e}):e.type==="error"?o.createElement(t.Error,{...e}):e.type==="noChannels"?o.createElement(t.NoChannels,{...e}):e.type==="noMessages"?o.createElement(t.NoMessages,{...e}):null;return n&&o.createElement(Wu,null,n)},vt=fe({template:Qu,components:{Loading:Zu,Error:ju,NoChannels:Xu,NoMessages:Ju}}),Fe=e=>{const{Template:t}=vt.useContext();return o.createElement(t,{...e})},zn=e=>Xn(e)||Jn(e);function ed(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function td(e,t){return e.filter(n=>ge.isWelcomeMessage(n,t))}const nd=g.default.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`,rd=g.default.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${m.themedColor.textDisabled};background-color:${m.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`,od=g.default.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`,sd=g.default.div`margin-inline-end:8px;`,ad=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);}`,id=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;}`,ld=g.default.div`display:flex;width:160px;justify-content:flex-end;`,cd=g.default.div`inset-inline-end:0;display:flex;flex-direction:row;`,Or=g.default.div`width:64px;padding:21px;box-sizing:border-box;cursor:${e=>e.disabled?"not-allowed":"pointer"};`,ud=g.default(Or)`border-inline-start:1px solid ${m.themedColor.textDisabled};`,dd=g.default.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`,md=g.default.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,gd=g.default.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`,hd=g.default.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,fd=({file:e,sender:t={},onClose:n,onDownloadClick:r})=>{const{type:s,url:a,name:i=""}=e,{profileUrl:l,nickname:u,userId:d}=t,{aiAgentInfo:f}=J();return o.createElement(bd,{profileUrl:l??"",nickname:u??"",type:s,url:a,name:i,onClose:n,isBotMessage:d===f.userId,onDownloadClick:r})},pd=({profileUrl:e,isBotMessage:t})=>t&&!e?o.createElement(Ed,{$size:32},o.createElement(D,{type:"delight",size:20})):o.createElement(Qt,{size:32,src:e}),bd=({profileUrl:e,isBotMessage:t,nickname:n,name:r,type:s,url:a,onClose:i,onDownloadClick:l})=>{const{stringSet:u}=F();return o.createElement(bt,{onClose:i,visible:!0,rootElementId:re.MODAL_ROOT},o.createElement(nd,null,o.createElement(rd,null,o.createElement(od,null,o.createElement(sd,null,o.createElement(pd,{profileUrl:e,isBotMessage:t})),o.createElement(ad,null,o.createElement(M,{variant:"h2",color:m.themedColor.textHighEmphasis},r)),o.createElement(id,null,o.createElement(M,{variant:"body1",color:m.color.ondark.textMidEmphasis},n))),o.createElement(ld,null,zn(s)&&o.createElement(cd,null,o.createElement(Or,{as:"a",href:a,target:"_blank",rel:pt,onClick:l},o.createElement(D,{type:"download",color:m.themedColor.textHighEmphasis,size:24}))),o.createElement(ud,{onClick:i},o.createElement(D,{type:"close",color:m.themedColor.textHighEmphasis,size:24})))),o.createElement(dd,{onClick:d=>d.currentTarget===d.target&&i()},Jn(s)&&o.createElement(md,{controls:!0},o.createElement("source",{src:a,type:s})),Xn(s)&&o.createElement(gd,{src:a,alt:r}),!zn(s)&&o.createElement(hd,null,o.createElement(M,{variant:"h1",color:m.themedColor.textHighEmphasis},u.FILE_VIEWER__UNSUPPORT)))))},Ed=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;ellipse,path{fill:${({theme:e})=>e.colors.base.primaryContrastContent}!important;}`,Rr=({className:e,locale:t,date:n=Date.now(),formatString:r="MMMM dd, yyyy",style:s})=>o.createElement(xd,{id:`${ne}-date-separator`,style:s,className:e},o.createElement(M,{variant:"caption4",color:m.themedColor.textMidEmphasis},Ce.format(n,r,{locale:t}))),xd=g.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,vd=c.forwardRef(function(t,n){const{messages:r,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:u,onLoadNext:d,loadThreshold:f=.05,onScroll:b=he,depsForResetScrollPositionToBottom:E,stackDirection:y="top",bottomSpacerHeight:x=0,ariaLabel:v}=t,p=c.useRef(null),h=c.useCallback(I=>{p.current=I,n&&(typeof n=="function"?n(I):n.current=I)},[n]),C=c.useRef(!1),_=c.useRef(void 0),w=c.useRef(0),S=c.useRef(0);c.useLayoutEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},E),c.useLayoutEffect(()=>{p.current&&(_.current==="top"&&(p.current.scrollTop=p.current.scrollHeight-S.current),_.current==="bottom"&&(p.current.scrollTop=w.current),_.current=void 0)},[p.current,r.length]);const k=async I=>{if(b==null||b(I),!p.current)return;const L=p.current;if(S.current=L.scrollHeight-L.scrollTop,w.current=L.scrollTop,C.current)return;const z=L.clientHeight*Math.min(Math.max(0,f),1);L.scrollTop<=z?(C.current=!0,_.current="top",await u(),C.current=!1):L.scrollHeight-L.scrollTop-L.clientHeight<=z?(C.current=!0,_.current="bottom",await d(),C.current=!1):_.current=void 0};return o.createElement(Cd,{id:"infinite-list-container"},o.createElement(yd,{id:"infinite-list-inner",ref:h,onScroll:k,role:"list","aria-label":v},y==="bottom"&&o.createElement("div",{style:{flexGrow:1}}),a,r.map((I,L)=>s({message:I,index:L})),i,x>0&&o.createElement("div",{style:{minHeight:x}})),o.createElement(_d,{id:"infinite-list-overlay-container"},o.createElement(Sd,{id:"infinite-list-overlay"},l)))}),Cd=g.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,yd=g.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;scrollbar-color:${m.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,_d=g.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,Sd=g.default.div`pointer-events:auto;`,Td=({className:e,onClick:t,ariaLabel:n})=>o.createElement(Ad,{className:e,onClick:t,tabIndex:0,"aria-label":n},o.createElement(D,{size:24,type:"chevron-down",color:m.color.primary.main})),Ad=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);${R.light`
|
|
231
231
|
background-color: ${m.color.background50};
|
|
232
232
|
&:hover {
|
|
233
233
|
background-color: ${m.color.background100};
|
|
@@ -249,11 +249,11 @@
|
|
|
249
249
|
&:focus {
|
|
250
250
|
outline: none;
|
|
251
251
|
}
|
|
252
|
-
`,
|
|
252
|
+
`,wd=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=U(),{aiAgentInfo:n}=J(),{stringSet:r,dateLocale:s}=F(),{messageSource:a}=Q(),{Template:i}=Ie.useContext(),l=e.welcomeMessages??[],u=a.messages,d=td(u,t),f=u[d.length+1],b=d[0]??f;return{filteredMessages:u.filter(E=>ed(E)?!1:l.length>0?!ge.isWelcomeMessage(E,t):!0),shouldShowOriginalDate:E=>E>0||l.length===0?!0:f&&!Ce.isSameDay(f.createdAt,(b==null?void 0:b.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>l.length===0?null:o.createElement(o.Fragment,null,o.createElement(Rr,{style:{margin:"16px 0"},date:b==null?void 0:b.createdAt,locale:s,formatString:r.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}),l.map((E,y)=>{const x=y===l.length-1,v=d.length!==u.length,p=l.length===1?"single":y===0?"top":x||v?"bottom":"middle";return o.createElement(i,{messageType:"user",message:E.message,sender:n,groupType:p,createdAt:(b==null?void 0:b.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:E.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:x&&!v,isBotMessage:!0,onClickSuggestedReply:async({reply:h})=>{a.sendUserMessage({message:h})}})}))}},kd=e=>g.default(e).withConfig({shouldForwardProp:po.default}),Id=({style:e})=>{const{stringSet:t}=F(),{isActionbookTester:n}=Me();return!Xt("powered-by")||n?null:o.createElement($d,{variant:"caption2",style:e},t.POWERED_BY+" ",o.createElement(Md,{variant:"caption2",as:"a",href:"https://delight.ai?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby","aria-label":"Learn more about Delight AI Agent",rel:pt,target:"_blank"},"Sendbird"))},$d=g.default(M)`color:${m.themedColor.textLowEmphasis};text-align:center;`,Md=kd(M)`
|
|
253
253
|
color: ${m.themedColor.textLowEmphasis};
|
|
254
254
|
cursor: pointer;
|
|
255
255
|
text-decoration: none;
|
|
256
|
-
`,Md=()=>{var i;const{stringSet:e}=F(),{channelSource:t,goToActiveConversation:n,scrollSource:r}=Q(),s=_e(t.channel),a=c.useRef(s);return c.useEffect(()=>{if(!a.current&&s){const d=setTimeout(()=>{r.actions.scrollToBottom(!0)},100);return()=>clearTimeout(d)}a.current=s},[s,r.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:o.createElement(Ld,null,o.createElement(Od,{variant:"button",role:"button",color:m.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},Ld=h.default.div`display:flex;justify-content:center;margin-bottom:16px;`,Od=h.default(M)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${m.themedColor.textDisabled};cursor:pointer;user-select:none;`,Rd=()=>{const{Template:e}=Et.useContext(),{Template:t}=Ie.useContext(),{Template:n}=xt.useContext(),[r,s]=c.useState(null),[a,i]=c.useState(null),{userSession:l,aiAgentInfo:u}=J(),{cache:d,agentPreviewConfigs:f,chatSDK:p,state:x}=U(),{config:y}=G(),{stringSet:v,dateLocale:E}=F(),{conversation:b,channelSource:g,messageSource:C,scrollSource:_,state:{input:I,streamAnimation:S}}=Q(),{isActionbookTester:A}=Me(),{filteredMessages:w,shouldShowOriginalDate:O,renderAgentPreviewWelcomeMessages:W}=Ad(),te=lr(g.channel),K=(()=>{const q=te[0];if(!q)return null;const $=q.userId===u.userId;return{user:$?u:q,isBot:$}})();c.useEffect(()=>{_.actions.onTypingIndicatorUpdate(!!K)},[!!K,_.actions.onTypingIndicatorUpdate]);const ie=_e(g.channel);c.useEffect(()=>{_.actions.onConversationClosed(ie)},[ie,_.actions.onConversationClosed]);const oe=(q,$=!1)=>{var ee;return $?u:((ee=g.channel)==null?void 0:ee.members.find(T=>T.userId===q.sender.userId))??q.sender},Ae=q=>{if(q.sendingStatus==="failed"&&!I.disabled)return()=>i(q)},we=()=>{var q;if(!C.initialized)return o.createElement(Fe,{type:"loading"});if(C.messages.length===0){const $=W();return $?o.createElement("div",{style:{width:"100%"}},$):o.createElement(Fe,{type:"noMessages",label:v.PLACE_HOLDER__NO_MESSAGES})}return o.createElement(xd,{ref:_.ref,onScroll:_.props.onScroll,stackDirection:f==null?void 0:f.messageStackDirection,messages:w,onLoadPrev:C.loadPrevious,onLoadNext:C.loadNext,depsForResetScrollPositionToBottom:[C.initialized,C.messages.length!==0],bottomSpacerHeight:_.state.bottomSpace,messageTopArea:o.createElement(o.Fragment,null,o.createElement(kd,{style:{marginTop:16}}),W()),messageBottomArea:o.createElement(o.Fragment,null,K&&o.createElement("div",{id:`${ne}-message-item`},o.createElement(t,{isTyping:!0,isBotMessage:K.isBot,sender:K.user,messageType:"user",groupType:"single",message:""})),((q=y==null?void 0:y.conversation)==null?void 0:q.isTalkToAgentViewEnabled)&&o.createElement(Md,null)),overlayArea:o.createElement(o.Fragment,null,_.state.shouldShowScrollButton&&o.createElement(Pd,{onClick:()=>_.actions.scrollToBottom(!0)})),renderMessage:({message:$,index:ee})=>{const T=_o($),L=w[ee-1],N=w[ee+1],V=w[w.length-1],le=$===V,ce=_e(g.channel),be=Be($,u.userId),Ee=!(u.isUserFeedbackEnabled&&be&&!ge.isWelcomeMessage($)),xe=So($,L,N,Ee),Ve=!uo.isSameDay((L==null?void 0:L.createdAt)??0,$.createdAt)&&O(ee)&&!A,_t=Xe=>{($.isFileMessage()||$.isUserMessage())&&s({file:Xe,sender:oe($,$.sender.userId===u.userId)})},eo=()=>{$.isFileMessage()&&en($.url)},to=Ve?o.createElement(Rr,{style:{margin:"16px 0"},date:$.createdAt,locale:E,formatString:v.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,Ze={maxBodyWidth:x.expanded?P.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:$.extendedMessagePayload,createdAt:$.createdAt,groupType:xe,onClickMedia:_t,onClickFile:eo},no=()=>{if(Oe.isOutgoing($,l.userId))return"outgoingmessage";if(Oe.isIncoming($,l.userId))return"incomingmessage"},ro=(()=>{var Xe,hn;if(Oe.isAdmin($))return Oe.isCSAT($)?b?o.createElement(n,{...Ze,...b,isResolvedWhenDeterminedByUser:bo(b),messageType:"admin.csat",onSubmitCSAT:({csat:ve,...H})=>{var Y;ve&&((Y=g.channel)==null||Y.submitCSAT({csat:ve,...H}))}}):null:o.createElement(n,{...Ze,messageType:"admin",message:$.message});if(Oe.isOutgoing($,l.userId)){const ve={...Ze,message:$.message,sender:oe($),sendingStatus:$.sendingStatus,onClickFailedMessage:Ae($)};if($.isUserMessage())return o.createElement(e,{messageType:"user",...ve});if($.isFileMessage()){const[H,Y]=((Xe=$.metaArrays.find(ue=>ue.key===Zn))==null?void 0:Xe.value)??[];return o.createElement(e,{messageType:"file",file:$,metadata:{aspectRatio:H&&Y?`${H}/${Y}`:"1/1",localFile:(hn=$.messageParams)==null?void 0:hn.file},...ve})}}if(Oe.isIncoming($,l.userId)){const ve={...Ze,sender:oe($,be),message:$.message,suggestedRepliesVisible:le,suggestedRepliesDirection:f==null?void 0:f.suggestedRepliesDirection,isBotMessage:be,isStreaming:ge.isStreaming($),isHandedOff:Ne(g.channel),isConversationClosed:ce,isFeedbackEnabled:u.isUserFeedbackEnabled,isFeedbackCommentEnabled:u.isUserFeedbackCommentOptionEnabled,onClickSuggestedReply:async({reply:H})=>{C.sendUserMessage({message:H})},onRequestMessageTemplate:async H=>{const{template:Y}=await p.aiAgent.getMessageTemplate(H);return d.template.set(H,Y),Y},onGetCachedMessageTemplate:H=>d.template.get(H),onHandleTemplateInternalAction:H=>{if(H.type==="internal"&&H.internalData){const{method:Y,payload:ue}=H.internalData;Y==="message.send"&&(ue!=null&&ue.message)&&C.sendUserMessage({message:ue.message})}},onFeedbackUpdate:H=>{const Y={messageId:$.messageId,channelUrl:$.channelUrl};if(!H)return p.aiAgent.deleteMessageFeedback(Y);const ue={...Y,rating:Ai(H.rating),comment:H.comment};return ge.hasFeedback($)?p.aiAgent.updateMessageFeedback(ue):p.aiAgent.createMessageFeedback(ue)},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}),onStreamAnimationStart:()=>{S.start($.messageId)},onStreamAnimationComplete:()=>{S.stop($.messageId)}};if($.isUserMessage())return o.createElement(t,{messageType:"user",...ve});if($.isFileMessage())return o.createElement(t,{messageType:"file",file:$,...ve})}})();return o.createElement("div",{key:T,id:`${ne}-message-item`,"data-layout-id":no()},to,ro)}})};return o.createElement(Dd,{id:`${ne}-message-list`},we(),r&&o.createElement(hd,{onClose:()=>s(null),sender:r.sender,file:r.file}),a&&o.createElement(Pe,{visible:!0,onClose:()=>i(null)},o.createElement(Pe.ActionItem,{onClick:()=>{C.resendMessage(a),i(null)}},v.FAILED_MESSAGE_RESEND),o.createElement(Pe.ActionItem,{destructive:!0,onClick:()=>{C.deleteMessage(a),i(null)}},v.FAILED_MESSAGE_REMOVE)))},Dd=h.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Pd=h.default(Sd)`position:absolute;bottom:20px;inset-inline-end:20px;`,Nd=()=>{const{stringSet:e}=F(),{connectionError:t}=J(),{channelSource:n}=Q(),r=t||n.error;if(r){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return o.createElement(Fe,{type:"error",label:r.message,action:s})}return n.channel?o.createElement(Rd,null):o.createElement(Fe,{type:"loading"})},Bd=()=>{var s;const{origin:e}=Me(),{appId:t,aiAgentId:n}=G(),{channelSource:r}=Q();return(s=r.channel)!=null&&s.conversation?o.createElement(Fd,null,o.createElement(Vt,{style:{gap:4}},o.createElement(D,{color:m.themedColor.textLowEmphasis,size:12,type:"show"}),o.createElement(M,{as:"i",color:m.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),o.createElement(Vt,{role:"button",style:{gap:4},onClick:()=>{var u,d;const a=e??window.location.origin,i=(d=(u=r.channel)==null?void 0:u.conversation)==null?void 0:d.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},o.createElement(M,{variant:"body3",color:m.themedColor.textHighEmphasis},"Copy ",o.createElement("span",{style:{color:m.themedColor.primary}},"conversation link")),o.createElement(D,{color:m.themedColor.primary,size:14,type:"copy"}))):null},Vt=h.default.div`display:flex;justify-content:center;align-items:center;`,Fd=h.default(Vt)`flex-direction:column;padding-block:16px;background-color:${m.themedColor.bg_100_500};gap:8px;`,Dr=c.createContext(void 0),Hd=({children:e})=>{var E;const{chatSDK:t}=U(),{createAttachmentRules:n}=J(),{stringSet:r}=F(),{channelSource:s}=Q(),[a,i]=c.useState([]),[l,u]=c.useState({visible:!1,title:""}),d=n({channel:s.channel,uploadSizeLimit:(E=t.appInfo)==null?void 0:E.uploadSizeLimit}),f=d.isEnabled(),p=b=>{const g=d.getUploadSizeLimit(b.type);return b.size>g},x=b=>{if(!f)return;const g=b.filter(I=>d.isSupportedMimeType(I.type));if(g.length===0)return;const C=g.find(I=>p(I));if(C){const I=d.getUploadSizeLimitInMB(C.type);u({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d",I.toString())});return}if(a.length+g.length>d.maxAttachmentCount){u({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT});return}i(I=>[...I,...g.map(S=>({file:S,preview:{url:URL.createObjectURL(S),type:S.type,name:S.name}}))])},y=b=>{i(g=>{var _;const C=(_=g[b])==null?void 0:_.preview;return C&&URL.revokeObjectURL(C.url),g.filter((I,S)=>S!==b)})},v=()=>{i(b=>(b.forEach(g=>URL.revokeObjectURL(g.preview.url)),[]))};return o.createElement(Dr.Provider,{value:{files:a,addFiles:x,removeFile:y,clearFiles:v,isFileUploadEnabled:f,acceptableMimeTypes:d.supportedMimeTypes}},e,o.createElement(tn,{...l,onClose:()=>u({visible:!1,title:""})}))},ln=()=>{const e=c.useContext(Dr);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function Ud({blurred:e,elementRef:t,document:n=window.document}){const r=c.useRef(!1);e&&t.current&&n.activeElement===t.current&&(r.current=!0),c.useLayoutEffect(()=>{var s;!e&&r.current&&((s=t.current)==null||s.focus(),r.current=!1)},[e])}const zd=(e,t)=>{c.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},Vd=h.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,Gd=h.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;}`,Wd=h.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%;${R.light`
|
|
256
|
+
`,Ld=()=>{var i;const{stringSet:e}=F(),{channelSource:t,goToActiveConversation:n,scrollSource:r}=Q(),s=_e(t.channel),a=c.useRef(s);return c.useEffect(()=>{if(!a.current&&s){const d=setTimeout(()=>{r.actions.scrollToBottom(!0)},100);return()=>clearTimeout(d)}a.current=s},[s,r.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:o.createElement(Od,null,o.createElement(Rd,{variant:"button",role:"button",color:m.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},Od=g.default.div`display:flex;justify-content:center;margin-bottom:16px;`,Rd=g.default(M)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${m.themedColor.textDisabled};cursor:pointer;user-select:none;`,Dd=()=>{const{Template:e}=Et.useContext(),{Template:t}=Ie.useContext(),{Template:n}=xt.useContext(),[r,s]=c.useState(null),[a,i]=c.useState(null),{userSession:l,aiAgentInfo:u}=J(),{cache:d,agentPreviewConfigs:f,chatSDK:b,state:E}=U(),{config:y}=W(),{stringSet:x,dateLocale:v}=F(),{conversation:p,channelSource:h,messageSource:C,scrollSource:_,state:{input:w,streamAnimation:S}}=Q(),{isActionbookTester:k}=Me(),{filteredMessages:I,shouldShowOriginalDate:L,renderAgentPreviewWelcomeMessages:z}=wd(),te=lr(h.channel),K=(()=>{const q=te[0];if(!q)return null;const $=q.userId===u.userId;return{user:$?u:q,isBot:$}})();c.useEffect(()=>{_.actions.onTypingIndicatorUpdate(!!K)},[!!K,_.actions.onTypingIndicatorUpdate]);const ie=_e(h.channel);c.useEffect(()=>{_.actions.onConversationClosed(ie)},[ie,_.actions.onConversationClosed]);const oe=(q,$=!1)=>{var ee;return $?u:((ee=h.channel)==null?void 0:ee.members.find(T=>T.userId===q.sender.userId))??q.sender},Ae=q=>{if(q.sendingStatus==="failed"&&!w.disabled)return()=>i(q)},we=()=>{var q;if(!C.initialized)return o.createElement(Fe,{type:"loading"});if(C.messages.length===0){const $=z();return $?o.createElement("div",{style:{width:"100%"}},$):o.createElement(Fe,{type:"noMessages",label:x.PLACE_HOLDER__NO_MESSAGES})}return o.createElement(vd,{ref:_.ref,onScroll:_.props.onScroll,stackDirection:f==null?void 0:f.messageStackDirection,messages:I,onLoadPrev:C.loadPrevious,onLoadNext:C.loadNext,depsForResetScrollPositionToBottom:[C.initialized,C.messages.length!==0],bottomSpacerHeight:_.state.bottomSpace,ariaLabel:x.A11Y_MESSAGE_LIST,messageTopArea:o.createElement(o.Fragment,null,o.createElement(Id,{style:{marginTop:16}}),z()),messageBottomArea:o.createElement(o.Fragment,null,K&&o.createElement("div",{id:`${ne}-message-item`,role:"listitem"},o.createElement(t,{isTyping:!0,isBotMessage:K.isBot,sender:K.user,messageType:"user",groupType:"single",message:""})),((q=y==null?void 0:y.conversation)==null?void 0:q.isTalkToAgentViewEnabled)&&o.createElement(Ld,null)),overlayArea:o.createElement(o.Fragment,null,_.state.shouldShowScrollButton&&o.createElement(Nd,{onClick:()=>_.actions.scrollToBottom(!0),ariaLabel:x.A11Y_SCROLL_TO_BOTTOM})),renderMessage:({message:$,index:ee})=>{const T=So($),O=I[ee-1],N=I[ee+1],G=I[I.length-1],le=$===G,ce=_e(h.channel),be=Be($,u.userId),Ee=!(u.isUserFeedbackEnabled&&be&&!ge.isWelcomeMessage($)),xe=To($,O,N,Ee),Ve=!mo.isSameDay((O==null?void 0:O.createdAt)??0,$.createdAt)&&L(ee)&&!k,_t=Xe=>{($.isFileMessage()||$.isUserMessage())&&s({file:Xe,sender:oe($,$.sender.userId===u.userId)})},to=()=>{$.isFileMessage()&&en($.url)},no=Ve?o.createElement(Rr,{style:{margin:"16px 0"},date:$.createdAt,locale:v,formatString:x.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,Ze={maxBodyWidth:E.expanded?P.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:$.extendedMessagePayload,createdAt:$.createdAt,groupType:xe,onClickMedia:_t,onClickFile:to},ro=()=>{if(Oe.isOutgoing($,l.userId))return"outgoingmessage";if(Oe.isIncoming($,l.userId))return"incomingmessage"},oo=(()=>{var Xe,hn;if(Oe.isAdmin($))return Oe.isCSAT($)?p?o.createElement(n,{...Ze,...p,isResolvedWhenDeterminedByUser:Eo(p),messageType:"admin.csat",onSubmitCSAT:async({csat:ve,...H})=>{var Y;ve&&await((Y=h.channel)==null?void 0:Y.submitCSAT({csat:ve,...H}))}}):null:o.createElement(n,{...Ze,messageType:"admin",message:$.message});if(Oe.isOutgoing($,l.userId)){const ve={...Ze,message:$.message,sender:oe($),sendingStatus:$.sendingStatus,onClickFailedMessage:Ae($)};if($.isUserMessage())return o.createElement(e,{messageType:"user",...ve});if($.isFileMessage()){const[H,Y]=((Xe=$.metaArrays.find(ue=>ue.key===Zn))==null?void 0:Xe.value)??[];return o.createElement(e,{messageType:"file",file:$,metadata:{aspectRatio:H&&Y?`${H}/${Y}`:"1/1",localFile:(hn=$.messageParams)==null?void 0:hn.file},...ve})}}if(Oe.isIncoming($,l.userId)){const ve={...Ze,sender:oe($,be),message:$.message,suggestedRepliesVisible:le,suggestedRepliesDirection:f==null?void 0:f.suggestedRepliesDirection,isBotMessage:be,isStreaming:ge.isStreaming($),isHandedOff:Ne(h.channel),isConversationClosed:ce,isFeedbackEnabled:u.isUserFeedbackEnabled,isFeedbackCommentEnabled:u.isUserFeedbackCommentOptionEnabled,onClickSuggestedReply:async({reply:H})=>{C.sendUserMessage({message:H})},onRequestMessageTemplate:async H=>{const{template:Y}=await b.aiAgent.getMessageTemplate(H);return d.template.set(H,Y),Y},onGetCachedMessageTemplate:H=>d.template.get(H),onHandleTemplateInternalAction:H=>{if(H.type==="internal"&&H.internalData){const{method:Y,payload:ue}=H.internalData;Y==="message.send"&&(ue!=null&&ue.message)&&C.sendUserMessage({message:ue.message})}},onFeedbackUpdate:H=>{const Y={messageId:$.messageId,channelUrl:$.channelUrl};if(!H)return b.aiAgent.deleteMessageFeedback(Y);const ue={...Y,rating:wi(H.rating),comment:H.comment};return ge.hasFeedback($)?b.aiAgent.updateMessageFeedback(ue):b.aiAgent.createMessageFeedback(ue)},onSubmitForm:({key:H,data:Y})=>b.aiAgent.submitForm({messageId:$.messageId,channelUrl:$.channelUrl,formKey:H,formData:Y}),onCancelForm:({key:H})=>b.aiAgent.cancelForm({messageId:$.messageId,channelUrl:$.channelUrl,formKey:H}),onStreamAnimationStart:()=>{S.start($.messageId)},onStreamAnimationComplete:()=>{S.stop($.messageId)}};if($.isUserMessage())return o.createElement(t,{messageType:"user",...ve});if($.isFileMessage())return o.createElement(t,{messageType:"file",file:$,...ve})}})();return o.createElement("div",{key:T,id:`${ne}-message-item`,role:"listitem","data-layout-id":ro()},no,oo)}})};return o.createElement(Pd,{id:`${ne}-message-list`},we(),r&&o.createElement(fd,{onClose:()=>s(null),sender:r.sender,file:r.file}),a&&o.createElement(Pe,{visible:!0,onClose:()=>i(null)},o.createElement(Pe.ActionItem,{onClick:()=>{C.resendMessage(a),i(null)}},x.FAILED_MESSAGE_RESEND),o.createElement(Pe.ActionItem,{destructive:!0,onClick:()=>{C.deleteMessage(a),i(null)}},x.FAILED_MESSAGE_REMOVE)))},Pd=g.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Nd=g.default(Td)`position:absolute;bottom:20px;inset-inline-end:20px;`,Bd=()=>{const{stringSet:e}=F(),{connectionError:t}=J(),{channelSource:n}=Q(),r=t||n.error;if(r){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return o.createElement(Fe,{type:"error",label:r.message,action:s})}return n.channel?o.createElement(Dd,null):o.createElement(Fe,{type:"loading"})},Fd=()=>{var s;const{origin:e}=Me(),{appId:t,aiAgentId:n}=W(),{channelSource:r}=Q();return(s=r.channel)!=null&&s.conversation?o.createElement(Hd,null,o.createElement(Vt,{style:{gap:4}},o.createElement(D,{color:m.themedColor.textLowEmphasis,size:12,type:"show"}),o.createElement(M,{as:"i",color:m.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),o.createElement(Vt,{role:"button",style:{gap:4},onClick:()=>{var u,d;const a=e??window.location.origin,i=(d=(u=r.channel)==null?void 0:u.conversation)==null?void 0:d.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},o.createElement(M,{variant:"body3",color:m.themedColor.textHighEmphasis},"Copy ",o.createElement("span",{style:{color:m.themedColor.primary}},"conversation link")),o.createElement(D,{color:m.themedColor.primary,size:14,type:"copy"}))):null},Vt=g.default.div`display:flex;justify-content:center;align-items:center;`,Hd=g.default(Vt)`flex-direction:column;padding-block:16px;background-color:${m.themedColor.bg_100_500};gap:8px;`,Dr=c.createContext(void 0),Ud=({children:e})=>{var v;const{chatSDK:t}=U(),{createAttachmentRules:n}=J(),{stringSet:r}=F(),{channelSource:s}=Q(),[a,i]=c.useState([]),[l,u]=c.useState({visible:!1,title:""}),d=n({channel:s.channel,uploadSizeLimit:(v=t.appInfo)==null?void 0:v.uploadSizeLimit}),f=d.isEnabled(),b=p=>{const h=d.getUploadSizeLimit(p.type);return p.size>h},E=p=>{if(!f)return;const h=p.filter(w=>d.isSupportedMimeType(w.type));if(h.length===0)return;const C=h.find(w=>b(w));if(C){const w=d.getUploadSizeLimitInMB(C.type);u({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d",w.toString())});return}if(a.length+h.length>d.maxAttachmentCount){u({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT});return}i(w=>[...w,...h.map(S=>({file:S,preview:{url:URL.createObjectURL(S),type:S.type,name:S.name}}))])},y=p=>{i(h=>{var _;const C=(_=h[p])==null?void 0:_.preview;return C&&URL.revokeObjectURL(C.url),h.filter((w,S)=>S!==p)})},x=()=>{i(p=>(p.forEach(h=>URL.revokeObjectURL(h.preview.url)),[]))};return o.createElement(Dr.Provider,{value:{files:a,addFiles:E,removeFile:y,clearFiles:x,isFileUploadEnabled:f,acceptableMimeTypes:d.supportedMimeTypes}},e,o.createElement(tn,{...l,onClose:()=>u({visible:!1,title:""})}))},ln=()=>{const e=c.useContext(Dr);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function zd({blurred:e,elementRef:t,document:n=window.document}){const r=c.useRef(!1);e&&t.current&&n.activeElement===t.current&&(r.current=!0),c.useLayoutEffect(()=>{var s;!e&&r.current&&((s=t.current)==null||s.focus(),r.current=!1)},[e])}const Vd=(e,t)=>{c.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},Gd=g.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,Wd=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;}`,qd=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%;${R.light`
|
|
257
257
|
background-color: ${m.color.background50};
|
|
258
258
|
`}
|
|
259
259
|
${R.dark`
|
|
@@ -272,17 +272,17 @@
|
|
|
272
272
|
circle {
|
|
273
273
|
stroke: ${m.themedColor.bg_50_600};
|
|
274
274
|
}
|
|
275
|
-
`,
|
|
275
|
+
`,jd=()=>{const e=Ke(),[t,n]=c.useState(),{files:r,removeFile:s,isFileUploadEnabled:a}=ln();return!a||r.length===0?null:o.createElement(Gd,null,r.map(({preview:{type:i,name:l,url:u}},d)=>o.createElement(Wd,{key:u,onMouseOver:()=>n(d),onMouseLeave:()=>n(void 0)},(e||t===d)&&o.createElement(qd,{title:"Remove file",onClick:()=>s(d)},o.createElement(D,{type:"close-filled",color:m.themedColor.textMidEmphasis})),i.startsWith("image/")?o.createElement("img",{alt:"file-image",src:u}):o.createElement(Jt,{name:l,type:qt(l,i)}))))},Pr={textArea:A.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:A.css`margin-bottom:4px;`},Nr=g.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,Kd=g.default(Nr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${m.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${m.themedColor.bg_200_400};}}${on&&Pr.attachIcon};`,Yd=g.default.input`display:none;`,Vn=g.default.div`width:100%;position:relative;background-color:${m.themedColor.bg_100_500};border-radius:20px;`,Gn=g.default.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Wn=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:${m.themedColor.textHighEmphasis};resize:none;width:100%;height:${fr}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${on&&Pr.textArea};&::placeholder{color:${m.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${m.themedColor.textDisabled};}}`,qn=g.default.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,jn=({disabled:e})=>{const{stringSet:t}=F(),n=c.useRef(null),[r,s]=c.useState(!1),{addFiles:a,clearFiles:i,files:l,isFileUploadEnabled:u,acceptableMimeTypes:d}=ln();return!u||l.length>0?null:o.createElement(Kd,{disabled:e,onClick:()=>{var f;if(d.length===0)return s(!0);i(),(f=n.current)==null||f.click()}},o.createElement(D,{type:"attach",color:e?m.themedColor.textDisabled:m.themedColor.textMidEmphasis,size:16}),o.createElement(Yd,{type:"file",ref:n,onChange:f=>{const b=f.currentTarget.files;b&&a(Array.from(b)),f.target.value=""},accept:d.join(",")}),o.createElement(tn,{visible:r,title:t.FILE_UPLOAD_NO_SUPPORTED_FILES,onClose:()=>s(!1)}))},Zd=()=>{const e=c.useRef(null),[t,n]=c.useState(""),{stringSet:r}=F(),{rootElement:s}=U(),{channelSource:a,messageSource:i,state:l}=Q(),{files:u,addFiles:d,clearFiles:f}=ln(),b=l.input.disabled,E=(()=>{if(!b)return r.MESSAGE_INPUT__PLACE_HOLDER;switch(l.input.disabledBy){case"form_active":return r.FORM_PLACEHOLDER;case"ai_responding":return r.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE;case"suggested_replies":return r.MESSAGE_INPUT__PLACE_HOLDER__SUGGESTED_REPLIES;case"reconnecting":return r.MESSAGE_INPUT__PLACE_HOLDER__RECONNECTING;case"unavailable":case"conversation_closed":default:return r.MESSAGE_INPUT__PLACE_HOLDER__DISABLED}})();Gu({onDropFiles:d}),zd({blurred:b,elementRef:e,document:ke(s)}),Vd(a.channel,t);const y=t.trim().length>0,x=u.length>0,v=!b&&(y||x),p=()=>{e.current&&(e.current.value="",e.current.style.height=""),f(),n("")},h=async()=>{const S=t.trim(),k={message:S};if(!(!S&&!u.length)){if(u.length>0){const I=u[0].file,L={...k,file:I};i.sendFileMessage(L),p();return}i.sendUserMessage(k),p()}},C=S=>{const k=Array.from(S.clipboardData.files);k.length>0&&(S.preventDefault(),d(k))},_=S=>{S.key!=="Enter"||S.nativeEvent.isComposing||S.shiftKey||(S.preventDefault(),h())},w=S=>{if(e.current){e.current.style.height="";const k=Math.min(Va,e.current.scrollHeight);fr<k&&(e.current.style.height=`${k}px`)}n(S.target.value)};return b?o.createElement(qn,null,o.createElement(Vn,null,o.createElement(Gn,null,o.createElement(Wn,{disabled:!0,placeholder:E}),o.createElement(jn,{disabled:!0})))):o.createElement(qn,null,o.createElement(Vn,null,o.createElement(jd,null),o.createElement(Gn,null,o.createElement(Wn,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:E,maxLength:5e3,onKeyDown:_,onChange:w,onPaste:C}),o.createElement(jn,null))),v&&o.createElement(Nr,{onClick:()=>h()},o.createElement(D,{type:"send",color:m.color.primary.main,size:20})))},Xd=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:${m.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${R.light`
|
|
276
276
|
color: ${m.color.information.light};
|
|
277
277
|
`};
|
|
278
278
|
${R.dark`
|
|
279
279
|
color: ${m.color.information.main};
|
|
280
280
|
`};
|
|
281
281
|
}
|
|
282
|
-
`,
|
|
282
|
+
`,Jd=c.lazy(()=>Promise.resolve().then(()=>require("./Lt9QbwOc.cjs")).then(e=>({default:e.MarkdownText}))),Qd=()=>{const{aiAgentInfo:e,userSession:t}=J(),{messageSource:n,channelSource:r}=Q(),[s,a]=c.useState(null),i=Xt("special-notice",r.channel),l=c.useCallback(()=>r.channel?i?n.messages.some(u=>Be(u,(t==null?void 0:t.userId)??"")):!0:null,[r.channel,i,n.messages,t==null?void 0:t.userId]);return c.useEffect(()=>{s||a(l())},[l,s]),s||!e.specialNotice?null:o.createElement(Xd,null,o.createElement(Jd,null,e.specialNotice))},em=()=>o.createElement(tm,null,o.createElement(Qd,null),o.createElement(Ud,null,o.createElement(Zd,null))),tm=g.default.div`z-index:0;border:none;width:100%;`,nm=()=>{var s;const{testerType:e}=Me(),{channelSource:t}=Q(),n=_e(t.channel),r=!!e&&((s=t.channel)==null?void 0:s.isAIAgent);return n&&r?o.createElement(Fd,null):o.createElement(em,null)},Br=({children:e,onNavigateToConversationList:t,channelUrl:n,onClearChannelUrl:r,shouldMarkAsRead:s,closedChannelUrl:a,onClearClosedChannelUrl:i})=>{const{Template:l}=Ct.useContext();return o.createElement(Mr,{onNavigateToConversationList:t,channelUrl:n??a,onClearChannelUrl:r??i,shouldMarkAsRead:s},o.createElement(zt,null,o.createElement(zt.Consumer,null,u=>o.createElement(o.Fragment,null,o.createElement(om,{...u},o.createElement(l,null)),e))))},Ct=fe({template:rm,components:{Header:zu,Body:Bd,Footer:nm}});function rm(){const{components:e}=Ct.useContext();return o.createElement(o.Fragment,null,o.createElement(e.Header,null),o.createElement(e.Body,null),o.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};`,{Provider:sm,Context:am,useContext:cn}=X("ConversationList");function Fr({conversationListLimit:e,conversationListFilter:t,onOpenConversationView:n=he,children:r}){return o.createElement(Ls,{conversationListLimit:e,conversationListFilter:t},s=>o.createElement(sm,{value:{...s,onOpenConversationView:n}},r))}const im=({channel:e})=>o.createElement(Lr,{channel:e}),un=fe({template:lm,components:{}}),Gt=99;function lm(e){const{channel:t,onClick:n}=e,{stringSet:r,format:s}=F(),a=Co(t),i=yo(t,s,{justNow:r.DATE_FORMAT__JUST_NOW,minutesAgo:r.DATE_FORMAT__MINUTES_AGO,hoursAgo:r.DATE_FORMAT__HOURS_AGO,dateShortFormat:r.DATE_FORMAT__DATE_SHORT}),l=t.unreadMessageCount;return o.createElement(cm,{role:"button",onClick:()=>n==null?void 0:n()},o.createElement(um,null,o.createElement(im,{...e})),o.createElement(dm,null,o.createElement(mm,null,o.createElement(M,{variant:"subtitle1",color:m.themedColor.textHighEmphasis,maxTextLines:1},a),o.createElement(gm,null,_e(t)&&o.createElement(o.Fragment,null,o.createElement(M,{variant:"caption1",color:m.themedColor.textMidEmphasis,maxTextLines:1},r.CONVERSATION_LIST__ENDED),o.createElement(hm,null)),o.createElement(M,{variant:"caption2",color:m.themedColor.textLowEmphasis,maxTextLines:1},i))),l>0&&o.createElement(fm,{$count:l},o.createElement(M,{variant:"caption3",color:m.themedColor.textHighEmphasisInverse},l<=Gt?l:`${Gt}+`))))}const cm=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;`,um=g.default.div`display:flex;align-items:center;justify-content:center;padding-inline-start:16px;`,dm=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 ${m.themedColor.textDisabled};`,mm=g.default.div`display:flex;flex-direction:column;justify-content:center;flex:1;gap:4px;word-break:break-word;overflow-wrap:break-word;`,gm=g.default.div`display:flex;align-items:center;gap:6px;`,hm=g.default.div`width:2px;height:2px;border-radius:1px;background-color:${m.themedColor.textLowEmphasis};`,fm=g.default.div`display:flex;align-items:center;justify-content:center;height:20px;padding:4px;border-radius:10px;background-color:${m.themedColor.error};${({$count:e})=>e<=Gt&&A.css`
|
|
283
283
|
width: 20px;
|
|
284
284
|
`}
|
|
285
|
-
`,
|
|
285
|
+
`,pm=({items:e,renderItem:t,onEndReached:n})=>{const r=s=>{const a=s.target;a.scrollHeight-a.scrollTop===a.clientHeight&&(n==null||n())};return o.createElement(bm,{onScroll:s=>r(s)},e.map((s,a)=>t(s,a)))},bm=g.default.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;overscroll-behavior:contain;`,Em=()=>{const{stringSet:e}=F(),{listSource:t,onOpenConversationView:n}=cn(),{Template:r}=un.useContext();return t.initialized?t.channels.length===0?o.createElement(Fe,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):o.createElement(pm,{items:t.channels,renderItem:s=>{var a,i,l;return o.createElement(r,{key:s.url,channel:s,onClick:()=>n(s.url,_e(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()}}):o.createElement(Fe,{type:"loading"})},xm=()=>{const{stringSet:e}=F(),{language:t,countryCode:n,context:r}=U(),{aiAgentInfo:s,refreshActiveChannel:a,createConversation:i,setActiveChannel:l}=J(),{onOpenConversationView:u}=cn();return o.createElement(vm,{role:"button",onClick:async()=>{if(s.isMultipleActiveConversationsEnabled){const d=await i({aiAgentId:s.userId,language:t,country:n,context:r});l({url:d,status:V.ConversationStatus.OPEN}),u(d,V.ConversationStatus.OPEN)}else{const d=await a();u(d,V.ConversationStatus.OPEN)}}},o.createElement(Cm,{variant:"h1"},e.TALK_TO_AGENT))},vm=g.default.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,Cm=g.default(M)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,ym=()=>{const{state:e}=U(),t=Ye(),n=()=>{e.setOpened(!1)};return o.createElement(Ue,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},_m=()=>{const{stringSet:e}=F();return o.createElement(Sm,{variant:"h2",color:m.themedColor.textHighEmphasis},e.CONVERSATION_LIST__HEADER_TITLE)},Sm=g.default(M)`padding:0 4px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,Tm=e=>{const{components:t}=ze.useContext();return o.createElement(Ir,{start:o.createElement(t.StartArea,null),title:o.createElement(t.TitleArea,null),titleAlign:e.titleAlign,end:o.createElement(t.EndArea,null)})},Am=()=>null,wm=()=>{const{components:e}=ze.useContext();return o.createElement(e.Title,null)},km=()=>{const{components:e}=ze.useContext();return o.createElement(e.CloseButton,null)},ze=fe({template:Tm,components:{StartArea:Am,TitleArea:wm,EndArea:km,Title:_m,CloseButton:ym}}),Im=()=>{const{Template:e}=ze.useContext();return o.createElement(e,{titleAlign:"start"})},Hr=({conversationListLimit:e,conversationListFilter:t,children:n,onOpenConversationView:r})=>{const{Template:s}=yt.useContext();return o.createElement(Fr,{conversationListLimit:e,conversationListFilter:t,onOpenConversationView:r},o.createElement(Mm,null,o.createElement(s,null)),n)},yt=fe({template:$m,components:{Header:Im,Body:Em,Footer:xm}});function $m(){const{components:e}=yt.useContext();return o.createElement(o.Fragment,null,o.createElement(e.Header,null),o.createElement(e.Body,null),o.createElement(e.Footer,null))}const Mm=g.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,Lm=A.css`:where(#${re.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,Om=[Lm,ga,ha],Rm=(e,...t)=>A.createGlobalStyle(e,...Om,...t),Dm=Rm``,Pm=bo(Ct,Ie,Et,xt,yt,Le,un,ze,vt);function Ur({appearance:e,rootElement:t,logger:n,language:r,stringSet:s,children:a,messageTemplate:i,theme:l}){return xa(ra,t),o.createElement(A.StyleSheetManager,{target:t},o.createElement(pa,{rootElement:t,logger:n,appearance:e,theme:l},o.createElement(Ds,{internalVariables:i==null?void 0:i.__internalVariables},o.createElement(ma,{stringSet:s,logger:n,language:r},o.createElement(Pm,null,a,o.createElement(Dm,null))))))}const Nm={isOnline:()=>typeof window>"u"?!0:navigator.onLine,subscribe:e=>{if(typeof window>"u")return he;const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t),window.addEventListener("offline",n),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}},rt={},ot={getItem:e=>{try{return localStorage.getItem(e)}catch{return rt[e]??null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{rt[e]=t}},deleteItem:e=>{try{localStorage.removeItem(e)}catch{delete rt[e]}},getKeys:e=>{try{const t=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r&&r.startsWith(e)&&t.push(r)}return t}catch{return Object.keys(rt).filter(t=>t.startsWith(e))}}},dn=c.forwardRef(function({rootElement:t=document.body,logLevel:n=Z.LogLevel.WARN,language:r=navigator.language,userSessionInfo:s,children:a,...i},l){var u,d;return Ge.level!==n&&(Ge.level=n),Ea("https://fonts.googleapis.com/css2?family=Roboto&display=swap",t),o.createElement("div",{id:re.ENTRY,style:{width:"fit-content",height:"fit-content",...i.entryStyle}},o.createElement(Ur,{logger:Ge,rootElement:t,appearance:(u=i.agentPreviewConfigs)==null?void 0:u.appearance,stringSet:i.stringSet,language:r,messageTemplate:i.messageTemplate,theme:i.theme},o.createElement(Ca,{rootElement:t,keyValueStorage:{get:ot.getItem,set:ot.setItem,delete:ot.deleteItem,getKeys:ot.getKeys},networkStateAdapter:Nm,language:r,logger:Ge,dispatcher:zr,chatParams:{...i.chatParams,customApiHost:i.customApiHost,customWebSocketHost:i.customWebSocketHost},chatSDK:i.customChatSDK,messengerVersion:Ga,...i},o.createElement(uu,{ref:l,userSessionInfo:s,forceCreateChannel:(d=i.agentPreviewConfigs)==null?void 0:d.forceCreateChannel},o.createElement(Wc,{...i._UNSAFE_INTERNAL_dashboardTester},a,o.createElement("div",{id:re.MODAL_ROOT}))))))}),Ge=new tr(Z.LogLevel.WARN),zr=new er(Ge),{Provider:Bm,useContext:mn}=X("PageChildren"),Vr=({children:e})=>{const[t,n]=c.useState(null),[r,s]=c.useState(null);return o.createElement(Bm,{value:{conversationChildren:t,setConversationChildren:n,conversationListChildren:r,setConversationListChildren:s}},e)},Gr=({children:e,isOpened:t})=>{const{dir:n,rootElement:r}=U(),s=ke(r,!0);return c.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]),o.createElement(Fm,{dir:n,$visible:t},e)},Fm=g.default.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${$e.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`,Hm=48,Um=2/3;function Wr({className:e,isOpened:t,onClick:n,type:r,imageUrl:s,dir:a,animated:i=!0,backgroundColor:l,size:u=Hm}){const d=Dt(l),f=Math.round(u*Um);return o.createElement(Gm,{dir:a,id:re.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:i,$backgroundColor:l,$size:u},o.createElement(Wm,{$isOpened:t,$animated:i,$fillColor:d,$iconSize:f},o.createElement(Kn.Open,{url:s,isDefaultIcon:r==="default_icon",size:f})),o.createElement(qm,{$isOpened:t,$animated:i,$fillColor:d,$iconSize:f},o.createElement(Kn.Close,{size:f})))}const zm=A.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,Vm=A.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===We.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,qr=A.css`svg{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;${({$fillColor:e})=>A.css`
|
|
286
286
|
ellipse,
|
|
287
287
|
path {
|
|
288
288
|
fill: ${e};
|
|
@@ -292,10 +292,10 @@
|
|
|
292
292
|
}
|
|
293
293
|
`}
|
|
294
294
|
}
|
|
295
|
-
`,
|
|
295
|
+
`,Gm=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&&zm}`,jr=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;`,Wm=g.default(jr)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${Vm}${qr}`,qm=g.default(jr)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${qr}`,Kn={Open:e=>e.url?o.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):o.createElement(D,{size:e.size,type:"delight"}),Close:({size:e})=>o.createElement(D,{size:e,type:"chevron-down"})};function Kr({className:e,size:t}){const{colors:n}=A.useTheme(),{dir:r,state:s}=U(),{launcherInfo:a}=J();return Km(),o.createElement(Wr,{dir:r,className:e,isOpened:s.opened,onClick:()=>s.setOpened(!s.opened),type:a.type,imageUrl:a.imageUrl,backgroundColor:n.base.primary,size:t})}const jm=1e3*60;function Km(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:r}=U(),s=c.useRef(null);c.useEffect(()=>{if(!r)return;function a(){s.current&&(clearTimeout(s.current),s.current=null)}function i(){e.connectionState===Z.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")},jm)}t.opened?i():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[r,e,t.opened])}const Yr=c.createContext(null);function Zr(){const e=c.useContext(Yr);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function Xr({children:e}){const t=Zr();return typeof e=="function"?e(t):o.createElement(o.Fragment,null,e)}const Ym=A.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,Zm=A.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,Xm=A.css`animation-name:${Ym};animation-duration:0.3s;animation-fill-mode:forwards;`,Jm=A.css``,Qm=A.css`animation-name:${Zm};animation-duration:0.3s;animation-fill-mode:forwards;`,eg=A.css`visibility:hidden;`,tg=g.default.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return Xm;case"entered":return Jm;case"exiting":return Qm;case"exited":return eg;default:return""}}}${({$active:e})=>e?A.css`
|
|
296
296
|
z-index: 999;
|
|
297
|
-
`:
|
|
298
|
-
`;function st({initialId:e,children:t}){const[n,r]=c.useState([e]),s=n[n.length-1],a=c.useCallback((
|
|
297
|
+
`:A.css`z-index:1;pointer-events:none;`}
|
|
298
|
+
`;function st({initialId:e,children:t}){const[n,r]=c.useState([e]),s=n[n.length-1],a=c.useCallback((p,h)=>{r(C=>[...C,p]),b(C=>({...C,[p]:!0})),h!=null&&h.reset&&v(C=>({...C,[p]:(C[p]||0)+1})),y(C=>({...C,[p]:"entering"})),setTimeout(()=>{y(C=>({...C,[p]:"entered"}))},300)},[]),i=c.useCallback(()=>{r(p=>{if(p.length<=1)return p;const h=p[p.length-1];return y(C=>({...C,[h]:"exiting"})),setTimeout(()=>{y(C=>({...C,[h]:"exited"})),r(C=>C.slice(0,-1))},300),p})},[]),l=c.useMemo(()=>({navigation:{navigate:a,pop:i},activeScreenId:s}),[a,i,s]),u=c.useMemo(()=>c.Children.toArray(t).filter(p=>p.type===Xr),[t]),d=c.useMemo(()=>{const p={};return u.forEach(h=>{const{id:C,lazy:_,children:w}=h.props;p[C]={lazy:_,element:typeof w=="function"?w(l):w}}),p},[u,l]),[f,b]=c.useState(()=>{const p={};return Object.entries(d).forEach(([h,{lazy:C}])=>{C===!1&&(p[h]=!0)}),p[e]=!0,p}),[E,y]=c.useState(()=>{const p={};return Object.keys(d).forEach(h=>{h===e?p[h]="entered":p[h]="exited"}),p}),[x,v]=c.useState({});return o.createElement(Yr.Provider,{value:l},o.createElement(ng,null,Object.keys(d).map(p=>{var w;if(!f[p])return null;const h=E[p]||"exited",C=p===s,_=`${p}-${x[p]||0}`;return o.createElement(tg,{key:_,$transitionState:h,$active:C},(w=d[p])==null?void 0:w.element)})))}const ng=g.default.div`position:relative;width:100%;height:100%;`;st.Screen=Xr;const de={conv:"conv",convList:"conv-list"},Jr=({isOpened:e,entryPoint:t,selectedChannelUrl:n,setSelectedChannelUrl:r})=>{const{conversationChildren:s,conversationListChildren:a}=mn(),i=(()=>{switch(t){case"Conversation":return de.conv;case"ConversationList":return de.convList;default:return de.conv}})(),l=o.createElement(o.Fragment,null,o.createElement(rg,{onOpenConversationView:r}));return o.createElement(st,{initialId:i},o.createElement(st.Screen,{id:de.conv},({navigation:u,activeScreenId:d})=>o.createElement(Br,{key:n,channelUrl:n,onClearChannelUrl:()=>r(void 0),onNavigateToConversationList:()=>u.navigate(de.convList),shouldMarkAsRead:e&&d===de.conv},l,s)),o.createElement(st.Screen,{id:de.convList,lazy:!0},({navigation:u})=>o.createElement(Hr,{onOpenConversationView:d=>{r(d),u.navigate(de.conv)}},l,a)))},rg=({onOpenConversationView:e})=>{const{registerOnJoinedProactiveConversation:t}=J(),{navigation:n}=Zr();return t(({channel:r})=>{e(r.url),n.navigate(de.conv)}),null};function og({isExpanded:e,isOpened:t,children:n,launcher:r}){const{dir:s}=U();return o.createElement(sg,null,o.createElement(ag,{dir:s,id:re.WINDOW,$isExpanded:e,$isOpened:t},n),r)}const sg=g.default.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,ag=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&&lg};${({$isExpanded:e})=>e&&ig};`,ig=A.css`width:743px;height:723px;`,lg=A.css`z-index:${$e.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;`,cg=c.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const s=Ke(),[a,i]=c.useState(t),l=s?Gr:og;return o.createElement(dn,{enableExpandButton:!s,ref:r,...n},o.createElement(hr,null,({state:u})=>o.createElement(Vr,null,o.createElement(l,{isExpanded:u.expanded,isOpened:u.opened,launcher:o.createElement(Kr,null)},o.createElement(Jr,{isOpened:u.opened,entryPoint:n.entryPoint,selectedChannelUrl:a,setSelectedChannelUrl:i})),e)))}),{Provider:ug,useContext:gn}=X("FixedMessengerStyle");function Qr(e,t,n,r=0){const{top:s,bottom:a,start:i,end:l}=n;let u="",d="";switch(e){case"start":d=`inset-inline-start: ${ae(i)}`;break;case"end":d=`inset-inline-end: ${ae(l)}`;break}switch(t){case"top":u=`top: calc(${ae(s)} + ${r}px)`;break;case"bottom":u=`bottom: calc(${ae(a)} + ${r}px)`;break}return A.css`${u};${d};`}function dg(e){const{horizontal:t,vertical:n,margin:r,launcherSize:s}=gn();return o.createElement(mg,{...e,size:s,$horizontal:t,$vertical:n,$margin:r})}const mg=g.default(Kr)`position:fixed;z-index:${$e.LAUNCHER};${({$horizontal:e,$vertical:t,$margin:n})=>Qr(e,t,n)};`;function gg({isExpanded:e,isOpened:t,children:n}){const{dir:r}=U(),{horizontal:s,vertical:a,margin:i,launcherSize:l}=gn();return o.createElement(hg,{dir:r,id:re.WINDOW,$isExpanded:e,$isOpened:t,$horizontal:s,$vertical:a,$margin:i,$launcherSize:l},n)}const hg=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:r})=>Qr(e,t,n,r+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}`};
|
|
299
299
|
[dir='rtl'] &:not([dir='ltr']),
|
|
300
300
|
&[dir='rtl'] {
|
|
301
301
|
transform-origin: ${({$horizontal:e,$vertical:t})=>`${e==="start"?"right":"left"} ${t}`};
|
|
@@ -303,4 +303,4 @@
|
|
|
303
303
|
|
|
304
304
|
${({$isOpened:e})=>e&&pg};
|
|
305
305
|
${({$isExpanded:e})=>e&&fg};
|
|
306
|
-
`,fg=
|
|
306
|
+
`,fg=A.css`width:743px;height:723px;`,pg=A.css`z-index:${$e.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;`,eo={top:24,bottom:24,start:24,end:24},bg=c.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const[s,a]=c.useState(t),[i,l]=c.useState("end-bottom"),[u,d]=c.useState(eo),[f,b]=c.useState(48),E=Ke(),y=E?Gr:gg,{horizontal:x,vertical:v}=c.useMemo(()=>{const[p,h]=i.split("-");return{horizontal:p==="start"?"start":"end",vertical:h==="top"?"top":"bottom"}},[i]);return o.createElement(dn,{enableExpandButton:!E,ref:r,...n},o.createElement(hr,null,({state:p})=>o.createElement(ug,{value:{horizontal:x,vertical:v,margin:u,launcherSize:f,setPosition:l,setMargin:d,setLauncherSize:b}},o.createElement(Vr,null,o.createElement(y,{isExpanded:p.expanded,isOpened:p.opened},o.createElement(Jr,{isOpened:p.opened,entryPoint:n.entryPoint,selectedChannelUrl:s,setSelectedChannelUrl:a})),o.createElement(dg,null),e))))}),Eg=e=>{var s,a,i,l;const{setPosition:t,setMargin:n,setLauncherSize:r}=gn();return c.useLayoutEffect(()=>{e.position&&t(e.position),e.margin&&n({...eo,...e.margin}),e.launcherSize&&r(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},xg=({children:e})=>{const{setConversationChildren:t}=mn();return c.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},vg=({children:e})=>{const{setConversationListChildren:t}=mn();return c.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},Cg=Object.assign(bg,{Style:Eg,ConversationChildren:xg,ConversationListChildren:vg}),yg=e=>{const{refreshActiveChannel:t}=J(),[n,r]=c.useState(!1),s=c.useRef(null),a=c.useRef(null);return c.useEffect(()=>{n&&t().then(()=>{var i;(i=s.current)==null||i.call(s),r(!1)}).catch(i=>{var l;(l=a.current)==null||l.call(a,i),r(!1)})},[n]),c.useCallback(()=>new Promise((i,l)=>{s.current=i,a.current=l,e().then(()=>r(!0)).catch(l)}),[e])};exports.ANCHOR_REL=pt;exports.AgentProviderContainer=dn;exports.AgentUIProviderContainer=Ur;exports.AnonymousSessionInfo=Pt;exports.CSATType=se;exports.Conversation=Br;exports.ConversationContext=yu;exports.ConversationContextProvider=Mr;exports.ConversationHeaderLayout=Le;exports.ConversationLayout=Ct;exports.ConversationList=Hr;exports.ConversationListContext=am;exports.ConversationListContextProvider=Fr;exports.ConversationListHeaderLayout=ze;exports.ConversationListItemLayout=un;exports.ConversationListLayout=yt;exports.DefaultMessenger=cg;exports.DispatcherCommands=nr;exports.FixedMessenger=Cg;exports.IncomingMessageLayout=Ie;exports.LauncherBase=Wr;exports.LogLevel=Kt;exports.ManualSessionInfo=ar;exports.MessageLogs=wr;exports.OutgoingMessageLayout=Et;exports.PlaceholderLayout=vt;exports.SystemMessageLayout=xt;exports.cssVars=m;exports.escapeMarkdownSyntax=$o;exports.mapCommonStringsToReactFormat=mr;exports.messengerDispatcher=zr;exports.useConversationContext=Q;exports.useConversationListContext=cn;exports.useLocalizationContext=F;exports.useMessengerContext=U;exports.useMessengerSessionContext=J;exports.useRefreshActiveChannel=yg;
|