@sendbird/ai-agent-messenger-react 1.10.3 → 1.12.0
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/0FArne3s.cjs +1 -0
- package/dist/cjs/B3EdwVP_.cjs +1 -0
- package/dist/cjs/BC8yV2vW.cjs +1 -0
- package/dist/cjs/BDwqrgZD.cjs +1 -0
- package/dist/cjs/BZWmhiRy.cjs +306 -0
- package/dist/cjs/CQbdMB7S.cjs +1 -0
- package/dist/cjs/{Lt9QbwOc.cjs → CdV-y2tE.cjs} +1 -1
- package/dist/cjs/ChN6oo70.cjs +1 -0
- package/dist/cjs/XUKkIcnf.cjs +1 -0
- package/dist/cjs/ZgKCWcTm.cjs +1 -0
- package/dist/cjs/mzSLgcai.cjs +1 -0
- package/dist/es/{BUjZwbLs.js → BI9lULk5.js} +10 -8
- package/dist/es/{Drf_-1iy.js → BNpZ-PNc.js} +4 -2
- package/dist/es/{fnTAJEKK.js → BNrrEkaM.js} +12 -10
- package/dist/es/{BK3NLWD7.js → BXQEb3Gj.js} +10 -8
- package/dist/es/{bp8ut7x_.js → BnmtYOQR.js} +4 -2
- package/dist/es/{QLoGj0Il.js → CDp93E9_.js} +6 -4
- package/dist/es/{DV3Z-BEQ.js → D9GVP-3J.js} +2029 -2002
- package/dist/es/{BQ0E1drV.js → DJw82TDk.js} +8 -6
- package/dist/es/{DbjtlqMh.js → DftOx_kr.js} +10 -8
- package/dist/es/{BJEfprOj.js → DgQD8JsO.js} +10 -8
- package/dist/es/{BjgNa6vj.js → q3o5Qi21.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +46 -5
- package/dist/index.js +1 -1
- package/package.json +8 -8
- package/dist/cjs/BBDXgVHP.cjs +0 -1
- package/dist/cjs/BKGUMAll.cjs +0 -1
- package/dist/cjs/BMWSkFPd.cjs +0 -1
- package/dist/cjs/CshEwefQ.cjs +0 -1
- package/dist/cjs/D2b9Fh2D.cjs +0 -1
- package/dist/cjs/DDZcs_TL.cjs +0 -1
- package/dist/cjs/DTOB4bD8.cjs +0 -306
- package/dist/cjs/HGTRpnXG.cjs +0 -1
- package/dist/cjs/VMkpPP3I.cjs +0 -1
- package/dist/cjs/h90fKnkA.cjs +0 -1
|
@@ -0,0 +1,306 @@
|
|
|
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 F=(e,t,n)=>ao(e,typeof t!="symbol"?t+"":t,n);const d=require("react"),X=require("@sendbird/chat"),T=require("styled-components"),xe=require("date-fns"),io=require("date-fns/locale/en-US"),ve=require("@sendbird/chat/message"),q=require("@sendbird/chat/aiAgent"),at=require("@sendbird/chat/groupChannel"),lo=require("react-dom"),Mt=require("@sendbird/react-uikit-message-template-view"),co=require("@sendbird/uikit-message-template"),Pe=require("@sendbird/uikit-tools"),uo=require("dompurify"),mo=require("date-fns/isSameDay"),go=require("@emotion/is-prop-valid"),ut=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(d),fo=ut(X),h=ut(T),Yn=ut(uo),po=ut(go),J=(e,t)=>{const n=d.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=d.useContext(n);if(!i)throw new Error(`use${e}Context must be used within a ${e}Provider`);return i};return n.displayName=`${e}Context`,r.displayName=`${e}Provider`,s.displayName=`${e}Consumer`,a.displayName=`use${e}Context`,{Context:n,Provider:r,Consumer:s,useContext:a}};function ge(e){const t=d.createContext({Template:e.template,updateTemplate:()=>{},components:e.components,updateComponent:()=>{}});function n({children:a}){const[i,l]=d.useState(()=>e.template),[c,u]=d.useState(e.components),f={Template:i,updateTemplate:b=>l(()=>b),components:c,updateComponent:(b,E)=>u(y=>({...y,[b]:E}))};return o.createElement(t.Provider,{value:f},a)}function r({template:a,children:i}){const{updateTemplate:l}=d.useContext(t);return d.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=()=>d.useContext(t),s.Context=t,s.Template=r,Object.keys(e.components).forEach(a=>{s[a]=function({component:l}){const{updateComponent:c}=d.useContext(t);return d.useLayoutEffect(()=>{l&&c(a,l)},[l]),null}}),s}function bo(...e){return function({children:n}){return e.reduce((r,s)=>o.createElement(s,null,r),n)}}const ye=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===q.ConversationStatus.CLOSED||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="closed")},Gt=e=>{var t,n;return!!(e!=null&&e.isAIAgent&&((t=e==null?void 0:e.conversation)==null?void 0:t.status)===q.ConversationStatus.OPEN||e!=null&&e.isDesk&&((n=e==null?void 0:e.helpdeskInfo)==null?void 0:n.ticketStatus)==="open")};function De(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=xe.differenceInMinutes(r,s);return a<1?n.justNow:a<60?n.minutesAgo(a):xe.isToday(s)?n.hoursAgo(xe.differenceInHours(r,s)):t(s,n.dateShortFormat)}const Oe="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},ue=e=>!!e&&"sender"in e,So=e=>ue(e)?e.sendingStatus==="succeeded"?String(e.messageId):e.reqId:String(e.messageId),To=(e,t,n,r=!0)=>{if(!r||!ue(e))return"single";const s=()=>{if(!t||!ue(t))return!1;const c=t.sender.userId===e.sender.userId,u=xe.isSameMinute(t.createdAt,e.createdAt);return c&&u},a=()=>{if(!n||!ue(n))return!1;const c=n.sender.userId===e.sender.userId,u=xe.isSameMinute(n.createdAt,e.createdAt);return c&&u},i=s(),l=a();return i&&l?"middle":i?"bottom":l?"top":"single"},We=(e,t)=>(()=>{var r;return ue(e)?e.sender.userId:((r=e==null?void 0:e.sender)==null?void 0:r.userId)??void 0})()===t,Le={isAdmin:e=>e.isAdminMessage(),isCSAT:e=>{var t;return e.isAdminMessage()&&!!((t=e.extendedMessagePayload)!=null&&t.csat)},isIncoming:(e,t)=>ue(e)&&e.sender.userId!==t,isOutgoing:(e,t)=>ue(e)&&(e.sender.userId===t||e.sendingStatus===ve.SendingStatus.PENDING)},Xn=e=>e.startsWith("image/"),Jn=e=>e.startsWith("video/"),Wt=(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,qt=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,c,u]=i;return s<u&&r.push({type:"text",value:e.slice(s,u).trim()}),r.push({type:"code",value:c.trim(),language:l?l.trim():"plaintext"}),s=u+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:ue(r)&&t.includes(r.sendingStatus);return Mo?e.find(n):e.findLast(n)};function me(){}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 Lt=e=>{try{return JSON.parse(e===""?"{}":e)}catch{return{}}},Ce={isStreaming(e){const t=Lt(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(We(e,t)){const r=Lt(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)}},St=`@${Oe}`,bn=({appId:e,aiAgentId:t,storage:n})=>{const r={templateBase:`${St}-template`,template:s=>`${r.templateBase}/templates/${s}`,templateToken:()=>`${r.templateBase}-template/message-template/tokens`,messengerSession:s=>{const a=Oo(`${e}/${t}/${s}`);return`${St}-udata/${a}`},anonUserSession:()=>`${St}-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){F(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=me,t=me;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}};var jt=(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))(jt||{});class tr{constructor(t){F(this,"level");this.level=t}verbose(...t){this.level<=0&&console.log(`[${Oe}/verbose]`,...t)}debug(...t){this.level<=1&&console.log(`[${Oe}/debug]`,...t)}info(...t){this.level<=2&&console.log(`[${Oe}/info]`,...t)}warn(...t){this.level<=3&&console.warn(`[${Oe}/warn]`,...t)}error(...t){this.level<=4&&console.error(`[${Oe}/error]`,...t)}}function En(e,t,n,r){const s=fo.default.init({appId:e,modules:[new at.GroupChannelModule,new q.AIAgentModule],localCacheEnabled:!0,options:new X.SendbirdChatOptions({typingIndicatorInvalidateTime:2e4}),...r});return s.addSendbirdExtensions([{version:n,product:X.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 Ae={conversation:{isTalkToAgentViewEnabled:!0,scrollMode:"auto",newMessageIndicatorEnabled:!0,senderAvatarEnabled:!0,header:{avatarEnabled:!0},input:{camera:{photoEnabled:!0},gallery:{photoEnabled:!0},fileEnabled:!0}}},No=e=>{var t,n,r,s,a,i,l,c,u,f,b,E;return e?{...Ae,...e,conversation:{...Ae.conversation,...e==null?void 0:e.conversation,header:{...(t=Ae.conversation)==null?void 0:t.header,...(n=e==null?void 0:e.conversation)==null?void 0:n.header},input:{...(r=Ae.conversation)==null?void 0:r.input,...(s=e==null?void 0:e.conversation)==null?void 0:s.input,camera:{...(i=(a=Ae.conversation)==null?void 0:a.input)==null?void 0:i.camera,...(c=(l=e==null?void 0:e.conversation)==null?void 0:l.input)==null?void 0:c.camera},gallery:{...(f=(u=Ae.conversation)==null?void 0:u.input)==null?void 0:f.gallery,...(E=(b=e==null?void 0:e.conversation)==null?void 0:b.input)==null?void 0:E.gallery}}}}:Ae},{Provider:Po,useContext:K}=J("AIAgent");function Bo({appId:e,aiAgentId:t,keyValueStorage:n,networkStateAdapter:r,language:s,countryCode:a,context:i,queryParams:l,config:c,chatSDK:u,chatParams:f,children:b,logger:E,dispatcher:y,messengerVersion:C,extensions:x={platform:X.SendbirdPlatform.JS,deviceOSPlatform:Lo()?X.DeviceOsPlatform.MOBILE_WEB:X.DeviceOsPlatform.WEB}}){const[m,p]=d.useState(()=>{const v=E??new tr(jt.WARN),_=y??new er(v);return{logger:v,dispatcher:_,chatSDK:u??En(e,x,C,f),cache:bn({appId:e,aiAgentId:t,storage:n})}});return d.useEffect(()=>{p(v=>{let _=v.logger,I=v.dispatcher,A=v.chatSDK;return E&&E!==v.logger&&(_=E),y&&y!==v.dispatcher&&(I=y),u&&u!==v.chatSDK?A=u:!u&&v.chatSDK.appId!==e&&(A=En(e,x,C,{newInstance:!0,...f})),{...v,logger:_,dispatcher:I,chatSDK:A,cache:bn({appId:e,aiAgentId:t,storage:n})}})},[e,t,E,y,u,n]),d.useEffect(()=>()=>{m.chatSDK.disconnectWebSocket()},[m.chatSDK]),Do(m.chatSDK),o.createElement(Po,{value:{...m,appId:e,aiAgentId:t,context:i,language:s,countryCode:a,queryParams:l,config:No(c),networkStateAdapter:r}},b)}const Fo=(e,t,n)=>Pe.useGroupChannelMessages(e,t,{...n,strictStreamingOrder:!0});var Ot=(e=>(e.ConversationClose="conv.close",e))(Ot||{});class Uo{constructor(t={}){F(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 Uo{constructor(){super(...arguments);F(this,"type","conv.close")}}const rr=(e,t,n={})=>{let r=null,s=null,a=null;const{leading:i=!0,trailing:l=!0}=n,c=(...u)=>{const f=Date.now();if(a===null||f-a>=t)i?(e(...u),a=f):(s=u,a=f);else if(s=u,l&&!r){const b=t-(f-a);r=setTimeout(()=>{s&&l&&(e(...s),a=Date.now()),r=null,s=null},b)}};return c.cancel=()=>{r&&(clearTimeout(r),r=null),s=null,a=null},c},Ge={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 c=(r+s)/2;return r!==s&&(l=c>.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,c]}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,c=2*n-l;r=i(c,l,e+1/3),s=i(c,l,e),a=i(c,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,c]=Go(r,s,a),u=Math.max(0,Math.min(1,c*t)),f=Math.max(0,Math.min(1,l*n)),[b,E,y]=Wo(i,f,u);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 Rt(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?Ge.BLACK:Ge.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)"}},Tt={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??Rt(a),l=n??Ge.DEFAULT_BOT_MSG_BG,c=r??Rt(l);return{colors:(e==="light"?jo:Ko)(s,a,i,l,c),aiAgentColorVariables:{primary_color:a,bot_message_bg_color:l,primary_contrast_color:i,bot_message_bg_contrast_color:c}}}function 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 Tt;const t={...Tt};return Object.keys(e).forEach(n=>{const r=e[n];if(r&&typeof r=="object"){const s=Tt[n],a=["fontSize","fontWeight","fontFamily","lineHeight"];t[n]=Xo(s,r,a)}}),t}const{Provider:Qo,useContext:Kt}=J("AIAgentTheme");function es({logger:e,palette:t,typography:n,appearance:r,children:s}){const a=d.useRef(null),[i,l]=d.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})),c=d.useCallback((u,f)=>{f&&(a.current=f);const b=(r==null?void 0:r.theme)??u,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 C=xn({selectedTheme:b,palette:t,typography:n,...y});l(C),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 d.useEffect(()=>{(r!=null&&r.theme||r!=null&&r.primaryColor||r!=null&&r.botMessageBackgroundColor)&&c(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:c}},s)}const vn=25*1024*1024,ts={off:"off",always:"always",handed_off_only:"handed_off_only"},ns=()=>{const[e,t]=d.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=d.useCallback(({active_channel:s,upload_restriction:a})=>{const{maxAttachmentCount:i,attachmentMode:l,defaultUploadSizeLimit:c,supportedImageMimeTypes:u,supportedFileMimeTypes:f}=e;t({maxAttachmentCount:i,attachmentMode:ts[s.attachment_mode]??l,defaultUploadSizeLimit:(a==null?void 0:a.default_upload_size_limit)??c,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)??u),supportedFileMimeTypes:new Set((a==null?void 0:a.supported_file_mime_types)??f)})},[]),r=d.useCallback(s=>{const{channel:a,uploadSizeLimit:i=vn}=s,l=(u=!0)=>a!=null&&a.isAIAgent?u?De(a):!1:!0,c=u=>{if(l())return e.defaultUploadSizeLimit??i;const f=e.defaultUploadSizeLimit??i,b=e.uploadSizeLimitPerType.get(u)??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 De(a);default:return!0}},get supportedMimeTypes(){return l()?[_o]:[...e.supportedImageMimeTypes,...e.supportedFileMimeTypes]},isSupportedMimeType:u=>l()?!0:e.supportedImageMimeTypes.has(u)||e.supportedFileMimeTypes.has(u),getUploadSizeLimit:c,getUploadSizeLimitInMB:u=>c(u)/(1024*1024)}},[e]);return{updateBaseAttachmentRules:n,createAttachmentRules:r}};function sr(){const{chatSDK:e,logger:t}=K();return d.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}=K(),n=d.useCallback(async(s,a,i)=>{if(t.debug("useChatConnection.connect: start, session",s.userId),a){const l=new X.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 c=l;if(e.isCacheEnabled){if(as(c))t.warn("useChatConnection.connect","offline connect restricted",c.message,c.code),t.warn("useChatConnection.connect","clear cached-data"),await e.clearCachedData().catch(u=>t.warn("useChatConnection.connect","clear cached-data failure",u));else if(e.currentUser)return t.debug("useChatConnection.connect: end (offline), currentUser",e.currentUser),e.currentUser}throw t.warn("useChatConnection.connect","connect failure",c.message,c.code),c}},[e,t]),r=d.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}){F(this,"userId");F(this,"authToken");F(this,"sessionHandler");this.userId=t,this.authToken=n,this.sessionHandler=r}}class Dt{constructor(){F(this,"userId");F(this,"authToken");F(this,"sessionHandler")}}const is=1440*60*1e3,ls=e=>{const{logger:t,cache:n}=K(),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 Dt)throw new Error("userSessionInfo must be an instance of ManualSessionInfo");if(typeof e.userId!="string")throw new Error("userSessionInfo.userId must be a string");const a=["userId","authToken","sessionHandler"].filter(i=>!(i in e));return a.length>0&&t.error(`useUserSessionCandidate.getManualSessionInfo: missing required keys in userSessionInfo: ${a.join(", ")}`),t.debug("useUserSessionCandidate.getManualSessionInfo: manual session info detected"),e};return d.useMemo(()=>e instanceof ar?{type:"manual",userSessionCandidate:s()}:e instanceof Dt?{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:c,language:u,context:f,countryCode:b,logger:E,cache:y}=K(),{connect:C,disconnect:x}=rs(),{type:m,userSessionCandidate:p}=ls(e),v=sr(),_=d.useCallback(async()=>{var L;E.debug("useAuthentication.authenticate: start");const A=p!=null&&p.userId?y.messenger.getSettings(p.userId):null;A!=null&&A.bot&&(t(A),E.debug("useAuthentication.authenticate: cached messenger settings",A));const M=await v({aiAgentId:c,userId:p==null?void 0:p.userId,language:u,country:b,context:f,forceCreateChannel:l,knownActiveChannelUrl:(L=A==null?void 0:A.active_channel)==null?void 0:L.channel_url});E.debug("useAuthentication.authenticate: messenger settings response",M);let $=null;if(M.auto_created_user)if(m==="manual")E.warn("Received auto created user info but current session is manual. Ignoring auto created user info."),$={userId:p.userId,authToken:p.authToken};else{const{user_id:O,session_token:z,expire_at:V}=M.auto_created_user;y.messenger.setAnonUser({userId:O,authToken:z,expireAt:V}),$={userId:O,authToken:z}}else $={userId:(p==null?void 0:p.userId)??"",authToken:(p==null?void 0:p.authToken)??""};y.messenger.setSettings($.userId,M),t(M);try{await n(M,$),await C($,p==null?void 0:p.sessionHandler,a),await r(M,$)}catch(O){throw O instanceof Error&&(s(O),E.error("useAuthentication.authenticate: failed to connect",O)),O}return M},[v,C,m,p==null?void 0:p.userId,p==null?void 0:p.sessionHandler,p==null?void 0:p.authToken,c,u,f,b,l,y.messenger.setAnonUser,y.messenger.getSettings,y.messenger.setSettings,t,n,r,s,a]),I=d.useCallback(async()=>{E.debug("useAuthentication.deauthenticate: start"),await x(),i(),E.debug("useAuthentication.deauthenticate: completed")},[x,E,i]);return{authenticate:_,deauthenticate:I,userSessionCandidate:p}}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 ds(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 Yt({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),c=n(a);return s.replace(c,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}=K(),r=d.useCallback(()=>{var l,c;const a=(c=(l=e.appInfo)==null?void 0:l.aiAgentInfo)==null?void 0:c.templateListToken;if(!a)return!1;const i=n.template.getCachedToken();return i?a!==i:!0},[e,n.template.getCachedToken]),s=d.useCallback(async()=>{try{const{templates:a,token:i}=await e.aiAgent.getMessageTemplates({limit:20});for(const{template:l}of a){const{key:c}=qe(l);n.template.set(c,l)}n.template.setCachedToken(i)}catch(a){t==null||t.error("messageTemplateContext.syncCachedTemplates: error:",a)}},[e,t,n.template.set,n.template.setCachedToken]);return{shouldSyncCachedTemplate:r,syncCachedTemplates:s}},{Provider:hs,useContext:gt}=J("AIAgentMessengerSession"),fs=d.forwardRef(function({userSessionInfo:e,forceCreateChannel:t,children:n},r){const{appId:s,aiAgentId:a,chatSDK:i,language:l,countryCode:c,context:u,cache:f,logger:b}=K(),{updateTheme:E}=Kt(),[y,C]=d.useState(void 0),[x,m]=d.useState(void 0),[p,v]=d.useState(null),[_,I]=d.useState(null),[A,M]=d.useState(null),[$,L]=d.useState(null),{updateBaseAttachmentRules:O,createAttachmentRules:z}=ns(),{shouldSyncCachedTemplate:V,syncCachedTemplates:fe}=gs(),pe=sr(),{authenticate:Te,deauthenticate:j}=cs({userSessionInfo:e,forceCreateChannel:t,onUpdateMessengerSettings:d.useCallback(k=>{const{appearance:D,bot:B,launcher:W}=k;E(D.selected_theme,D),M({userId:B.bot_userid,profileUrl:B.bot_profile_url,nickname:B.bot_nickname,replyToFile:B.reply_to_file,specialNotice:B.special_notice,specialNoticeEnabled:B.is_special_notice_enabled,showHandoffButton:B.show_handoff_button??!0,isMultipleActiveConversationsEnabled:B.is_multiple_active_conversations_enabled??!0,isUserFeedbackEnabled:k.bot.is_user_feedback_enabled??!1,isUserFeedbackCommentOptionEnabled:k.bot.is_user_feedback_comment_option_enabled??!1}),L({type:W.image_type||"default_icon",imageUrl:W.image_url}),O(k)},[E]),onPreAuth:d.useCallback((k,D)=>{C(void 0),I(D)},[]),onPostAuth:d.useCallback(async k=>{v(i.currentUser),V()&&await fe(),m({url:k.active_channel.channel_url,status:q.ConversationStatus.OPEN})},[i,V,fe]),onErrorAuth:d.useCallback(k=>{C(k)},[]),onAuthTokenRefreshed:d.useCallback(k=>{I(D=>D?{...D,authToken:k}:null)},[]),onPostDeauth:d.useCallback(()=>{f.template.clear(),f.messenger.clear(_==null?void 0:_.userId),v(null),m(void 0),I(null),M(null),L(null)},[f.template.clear,f.messenger.clear,_])}),te=d.useCallback(async()=>{var k;if(_){b.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"),m(void 0);const D=await pe({aiAgentId:a,userId:_.userId,language:l,country:c,context:u,forceCreateChannel:t,knownActiveChannelUrl:(k=f.messenger.getSettings(_.userId))==null?void 0:k.active_channel.channel_url});return f.messenger.setSettings(_.userId,D),m({url:D.active_channel.channel_url,status:q.ConversationStatus.OPEN}),b.info("agentMessengerSession.refreshActiveChannel: refreshed active channel",D.active_channel.channel_url),D.active_channel.channel_url}else throw b.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"),new Error("userSession is not ready")},[pe,s,a,_==null?void 0:_.userId,l,c,u,t,f.messenger.getSettings,f.messenger.setSettings]),ie=d.useCallback(async k=>{if(!(_!=null&&_.userId))throw new Error("Current user is not authenticated. Please authenticate first.");const D=await pe({...k,userId:_.userId,knownActiveChannelUrl:void 0}),B=D.active_channel.channel_url;return f.messenger.setSettings(_.userId,D),B},[_==null?void 0:_.userId,pe]),[S]=d.useState(()=>rr(k=>{var D;b.info("agentMessengerSession.channelChanged: channel.conversation",k.conversation),m({url:k.url,status:((D=k.conversation)==null?void 0:D.status)??q.ConversationStatus.OPEN})},250,{trailing:!1,leading:!0}));return Pe.useGroupChannelHandler(i,{onChannelChanged:k=>{k.isGroupChannel()&&k.url===(x==null?void 0:x.url)&&S(k)}}),d.useEffect(()=>()=>{S.cancel()},[S]),d.useImperativeHandle(r,()=>{const k=async()=>{if(!x)throw new Error("No active conversation. Please start a conversation first.");return await i.groupChannel.getChannel(x.url)};return{activeChannel:x,chatSDK:i,authenticate:Te,deauthenticate:j,updateContext:async D=>{const W=await(await k()).updateContext(a,D);return{...W,context:W.context??{}}},patchContext:async D=>{const W=await(await k()).patchContext(a,D);return{...W,context:W.context??{}}},getContextObject:async()=>{const B=await(await k()).getContextObject(a);return{...B,context:B.context??{}}}}},[Te,j,x,i,a,b]),o.createElement(hs,{value:{sdkUser:p,userSessionInfo:e,userSession:_,activeChannel:x,setActiveChannel:m,refreshActiveChannel:te,createConversation:ie,connectionError:y,aiAgentInfo:A,launcherInfo:$,authenticate:Te,deauthenticate:j,createAttachmentRules:z}},n)}),ps=()=>{const e=d.useId(),{chatSDK:t,networkStateAdapter:n}=K(),[r,s]=d.useState(()=>n?n.isOnline()?"connected":"reconnecting":"connected");return d.useEffect(()=>{const a=new X.ConnectionHandler({onDisconnected:()=>s("disconnected"),onConnected:()=>s("connected"),onReconnectStarted:()=>s("reconnecting"),onReconnectSucceeded:()=>s("connected"),onReconnectFailed:()=>s("disconnected"),onConnectionLost:()=>s("reconnecting")});return t.addConnectionHandler(e,a),()=>{t.removeConnectionHandler(e)}},[t,e]),d.useEffect(()=>{if(n)return n.subscribe(()=>{s("reconnecting")})},[n]),r},lr=e=>{const{chatSDK:t}=K(),[n,r]=d.useState([]);return Pe.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,[ve.SendingStatus.SUCCEEDED]),aiAgentUserId:(r==null?void 0:r.userId)??"",isStreamAnimating:n}),l=ys({shouldApply:!!(e!=null&&e.isAIAgent)&&!De(e),isDisabledWhileAIResponding:i,lastMessage:pn(t,[ve.SendingStatus.PENDING,ve.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(ye(e))return{disabled:!0,disabledBy:"conversation_closed"};if(xs(e))return{disabled:!0,disabledBy:"form_active"};const c=vs(e);return c?{disabled:!0,disabledBy:c}:i||l?{disabled:!0,disabledBy:"ai_responding"}:{disabled:!1,disabledBy:""}},Es=({channel:e,lastMessage:t,aiAgentUserId:n,isStreamAnimating:r})=>{const[s,a]=d.useState(!1),i=lr(e);return d.useEffect(()=>{if(!t)return;const l=i.some(u=>u.userId===n),c=We(t,n)&&(Ce.isStreaming(t)||r);a(!!(c||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]=d.useState(!1),i=d.useRef(null),l=t&&We(t,r)?t.createdAt:0;return d.useEffect(()=>{const c=()=>{i.current&&(clearTimeout(i.current),i.current=null),a(!1)},u=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?c():u(b),()=>{i.current&&clearTimeout(i.current)}},[n,l]),s&&e},_s=()=>{const[e,t]=d.useState(new Set),n=d.useCallback(s=>{t(a=>{if(a.has(s))return a;const i=new Set(a);return i.add(s),i})},[]),r=d.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}=J("AIAgentConversation");function Ts({children:e,channelUrl:t,onChannelDeleted:n,onMessagesReceived:r,onMessagesUpdated:s,onConversationClosedStatusChanged:a,onConversationClosedViaDispatcher:i,onBeforeSendMessage:l,onAfterSendMessage:c=me,shouldMarkAsRead:u=!0,shouldCountNewMessages:f=()=>!1,sortComparator:b}){var L;const E=()=>u&&(m==null?void 0:m.markAsRead()),{chatSDK:y,logger:C,dispatcher:x}=K(),{channel:m,channelFetchError:p,fetchChannel:v}=As(t),_=Fo(y,m,{replyType:ve.ReplyType.ONLY_REPLY_TO_CHANNEL,shouldCountNewMessages:f,onChannelDeleted:n,onMessagesReceived:O=>r==null?void 0:r(O),onMessagesUpdated:O=>s==null?void 0:s(O),logger:C,markAsRead:E,sortComparator:b}),I=_s(),A=bs({channel:m,messages:_.messages,isStreamAnimating:I.isAnimating});d.useEffect(()=>{E()},[u]);const M=ye(m);d.useEffect(()=>{a==null||a(M)},[M,a]),d.useEffect(()=>{const O=async z=>{const V=typeof(z==null?void 0:z.channelUrl)=="string";m&&V&&z.channelUrl!==m.url||(C.debug("conversation.dispatcher: try to close conversation",m),m!=null&&m.conversation&&m.conversation.status===q.ConversationStatus.OPEN&&(await m.closeConversation(),i==null||i()))};return x.subscribe(Ot.ConversationClose,O),()=>{x.unsubscribe(Ot.ConversationClose,O)}},[x,(L=m==null?void 0:m.conversation)==null?void 0:L.status,i]);const $={conversation:(m==null?void 0:m.conversation)??void 0,channelSource:{channel:m,error:p,refetch:()=>v(),closeConversation:async()=>{ye(m)||await(m==null?void 0:m.closeConversation())}},messageSource:{messages:_.messages,newMessages:_.newMessages,initialized:_.initialized,loadPrevious:()=>_.loadPrevious(),loadNext:()=>_.loadNext(),deleteMessage:O=>_.deleteMessage(O),resendMessage:O=>_.resendMessage(O),resetNewMessages:()=>_.resetNewMessages(),sendUserMessage:async O=>{var V;if(((V=m==null?void 0:m.conversation)==null?void 0:V.status)===q.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(O=await l(O));const z=await _.sendUserMessage(O,c);return c==null||c(z),z},sendFileMessage:async O=>{var V;if(((V=m==null?void 0:m.conversation)==null?void 0:V.status)===q.ConversationStatus.CLOSED)throw new Error("Conversation is closed");l&&(O=await l(O));const z=await _.sendFileMessage(O,c);return c==null||c(z),z}},state:{streamAnimation:I,input:A}};return o.createElement(Ss,{value:$},e)}function As(e){const{chatSDK:t,logger:n}=K(),{sdkUser:r}=gt(),[s,a]=d.useState(void 0),[i,l]=d.useState(void 0);async function c(){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 u=await t.groupChannel.getChannel(e);a(u),n.debug("conversation.fetchChannel: fetched channel",u)}catch(u){u instanceof X.SendbirdError&&l(u),n.error("conversation.fetchChannel: error",u)}}return ws(s),d.useEffect(()=>{c()},[t,r,e]),{channel:s,channelFetchError:i,fetchChannel:c}}function ws(e){const{chatSDK:t}=K(),{activeChannel:n,setActiveChannel:r}=gt(),s=d.useId();d.useEffect(()=>{if(!e||!n)return;const a=new X.ConnectionHandler({onReconnectSucceeded:async()=>{var l;const i=await e.refresh();i.url===n.url&&r({url:i.url,status:((l=i.conversation)==null?void 0:l.status)??q.ConversationStatus.OPEN})}});return t.addConnectionHandler(s,a),()=>{t.removeConnectionHandler(s)}},[t,e,n])}class ks{constructor(t,{filter:n,limit:r=20}){F(this,"filter");F(this,"_sdk");F(this,"_pinnedChannels");F(this,"_channels");F(this,"_isDisposed",!1);F(this,"_handlerId",`handler-id-${Date.now()}`);F(this,"_order",at.GroupChannelListOrder.LATEST_LAST_MESSAGE);F(this,"_limit");F(this,"_query");F(this,"_token");F(this,"_timestamp");F(this,"_isSyncing");F(this,"_channelHandler");F(this,"_connectionHandler");F(this,"_collectionEventHandler");F(this,"_throttledOnChannelChanged");var s,a,i,l,c,u,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:(c=this.filter)==null?void 0:c.pinnedChannelUrls,copilotConversationOnly:(u=this.filter)==null?void 0:u.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 X.ConnectionHandler({onReconnectSucceeded:()=>{this._isDefaultChangelogSyncTimestampUpdated&&this._syncChannelChangelogs()}}),this._sdk.addConnectionHandler(this._handlerId,this._connectionHandler),this._sdk.groupChannel.addGroupChannelHandler(this._handlerId,this._channelHandler)}get _isDefaultChangelogSyncTimestampUpdated(){return this._timestamp!==Number.MAX_SAFE_INTEGER}_setDefaultChangelogsSyncTimestamp(t){var a,i;const n=new Set(((a=this.filter)==null?void 0:a.pinnedChannelUrls)??[]),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((c,u)=>[c,u])),s=[],a=[],i=[];for(const c of t){if(!this._query.belongsTo(c)){i.push(c.url);continue}const u=r.get(c.url);if(u===void 0)continue;const f=Nt(this._pinnedChannels,c);f>=0?(this._pinnedChannels.splice(f,1),a.push(c)):s.push(c);const E=this._pinnedChannels.findIndex(C=>(r.get(C.url)??1/0)>u),y=E===-1?this._pinnedChannels.length:E;this._pinnedChannels.splice(y,0,c)}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),c=l<0;!c&&this._channels.splice(l,1);const f=Is(this._channels,i,this._order).place,b=f===this._channels.length;c?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,C,x;const r=new Set(((b=this.filter)==null?void 0:b.pinnedChannelUrls)??[]),s=[],a=[];for(const m of t)r.has(m.url)?s.push(m):a.push(m);const i=this._upsertPinnedChannelsToArray(s),l=this._upsertRegularChannelsToArray(a,n),c=i.addedChannels.concat(l.addedChannels),u=i.updatedChannels.concat(l.updatedChannels),f=i.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);c.length>0&&((y=(E=this._collectionEventHandler)==null?void 0:E.onChannelsAdded)==null||y.call(E,{},c)),u.length>0&&((x=(C=this._collectionEventHandler)==null?void 0:C.onChannelsUpdated)==null||x.call(C,{},u)),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 c=this._pinnedChannels.findIndex(u=>u.url===l);c>=0&&(r.push(l),this._pinnedChannels.splice(c,1))}else{const c=this._channels.findIndex(u=>u.url===l);c>=0&&(r.push(l),this._channels.splice(c,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 c=Cn(e[i],t,n);if(c>0)a=i,i=Math.floor((s+a)/2);else if(c<0)s=i+1,i=Math.floor((s+a)/2);else return{place:i,oldPosition: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 C,x,m,p,v,_,I,A,M,$;const n=d.useId(),[r,s]=d.useState(!1),[a,i]=d.useState(null),[l,c]=d.useState([]),[u,f]=d.useState(null),b=d.useRef(!1),E=d.useCallback(async()=>{if(!b.current&&e.currentUser){b.current=!0,s(!1),i(null),c([]);try{u==null||u.dispose();const L=new ks(e,t);L.setConversationListCollectionHandler({onChannelsAdded:()=>{c(L.channels)},onChannelsUpdated:()=>{c(L.channels)},onChannelsDeleted:()=>{c(L.channels)}}),await L.loadMore(),f(L),i(null)}catch(L){f(null),i(L)}finally{s(!0),b.current=!1}}},[e,e.currentUser,(C=t.filter)==null?void 0:C.aiAgentChannelFilter,(m=(x=t.filter)==null?void 0:x.aiAgentConversationStatusFilter)==null?void 0:m.join(),(v=(p=t.filter)==null?void 0:p.aiAgentIds)==null?void 0:v.join(),(_=t.filter)==null?void 0:_.deskChannelFilter,(A=(I=t.filter)==null?void 0:I.pinnedChannelUrls)==null?void 0:A.join(),(M=t.filter)==null?void 0:M.copilotConversationOnly,($=t.filter)==null?void 0:$.copilotSupportChannelUrl,t.limit]),y=d.useCallback(async()=>{if(u)try{await u.loadMore()}catch(L){i(L)}},[u]);return d.useEffect(()=>(e.addConnectionHandler(n,new X.ConnectionHandler({onConnected:()=>E()})),()=>e.removeConnectionHandler(n)),[e,n,E]),d.useEffect(()=>{E()},[E]),d.useEffect(()=>()=>{b.current=!1,u==null||u.dispose()},[u]),{initialized:r,error:a,channels:l,loadMore:y}}const{Provider:Ms}=J("AIAgentConversationList");function Ls({conversationListLimit:e,conversationListFilter:t,children:n}){var b,E;const{chatSDK:r,aiAgentId:s,queryParams:a}=K(),i={aiAgentIds:[s],aiAgentConversationStatusFilter:[q.ConversationStatus.CLOSED,q.ConversationStatus.OPEN]},l=e??((b=a==null?void 0:a.conversationListParams)==null?void 0:b.limit),c={...i,...(E=a==null?void 0:a.conversationListParams)==null?void 0:E.filter,...t},u=$s(r,{limit:l,filter:c}),f={listSource:{initialized:u.initialized,error:u.error??void 0,channels:u.channels,loadMore:()=>u.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}=J("MessageTemplateFetching");function Ds({children:e,internalVariables:t}){const n=d.useRef({}),r=d.useRef({}),[s,a]=d.useState({}),i=d.useCallback((u,f)=>{a(b=>({...b,[u]:{fetching:!1,error:!1,...b[u],...f}}))},[]),l=d.useCallback(async({onRequestTemplate:u,onGetCachedTemplate:f,templateKey:b,suspense:E=!1})=>{const y=f(b);if(y)return y;const C=r.current[b];if(C)return C;E||i(b,{fetching:!0});const x=u(b).catch(m=>{throw E||i(b,{error:!0}),m}).finally(()=>{E||i(b,{fetching:!1}),delete r.current[b]});return r.current[b]=x,x},[i]),c={internalVariables:t,fetchTemplate:l,suspend:(u,f)=>{if(n.current[u])return n.current[u];const b=Os(f());return n.current[u]=b,b},getIsFetching:u=>{var f;return((f=s[u])==null?void 0:f.fetching)??!1},getHasError:u=>{var f;return((f=s[u])==null?void 0:f.error)??!1}};return o.createElement(Rs,{value:c},e)}const ht={VARIABLE:e=>new RegExp(`\\{${e}\\}`,"g"),VIEW_VARIABLE:e=>new RegExp(`"{@${e}}"`,"g")};function _e({uiTemplateString:e,variables:t={}}){const n=us(t);return Yt({template:e,variables:n,variableKeyPattern:r=>ht.VARIABLE(r)})}function Se({theme:e,uiTemplateString:t,colorVariables:n={}}){return Yt({template:t,variables:n,variableKeyPattern:r=>ht.VARIABLE(r),variableValueTransformer:r=>ds(e,r)})}function Ns({theme:e,uiTemplateString:t,viewVariables:n={},aiAgentColorVariables:r,internalVariables:s,onRequestTemplate:a}){const l=Object.values(n).flat().map(u=>u.key);return[...new Set(l)].some(u=>!a(u))?null:Yt({template:t,variables:n,variableKeyPattern:u=>ht.VIEW_VARIABLE(u),variableValueTransformer:u=>{const f=u.map(({key:b,variables:E})=>{const y=a(b),{ui_template:C,color_variables:x}=qe(y);let m=JSON.stringify(C);return m=_e({uiTemplateString:m,variables:s}),m=Se({theme:e,uiTemplateString:m,colorVariables:x}),m=Se({theme:e,uiTemplateString:m,colorVariables:r}),m=_e({uiTemplateString:m,variables:E}),mt(m)});return JSON.stringify(f)}})}async function Ps({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:u,variables:f})=>{const b=await a(u),{ui_template:E,color_variables:y}=qe(b);let C=JSON.stringify(E);return C=_e({uiTemplateString:C,variables:s}),C=Se({theme:e,uiTemplateString:C,colorVariables:y}),C=Se({theme:e,uiTemplateString:C,colorVariables:r}),C=_e({uiTemplateString:C,variables:f}),mt(C)}),c=await Promise.all(l);return JSON.stringify(c)}})}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 c=Ns({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n});if(c===null)return null;i=c}return i=_e({...r,uiTemplateString:i,variables:n}),i=Se({...r,uiTemplateString:i,colorVariables:a}),i=Se({...r,uiTemplateString:i,colorVariables:t}),i=_e({...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 Ps({...r,uiTemplateString:i,aiAgentColorVariables:t,internalVariables:n})),i=_e({...r,uiTemplateString:i,variables:n}),i=Se({...r,uiTemplateString:i,colorVariables:a}),i=Se({...r,uiTemplateString:i,colorVariables:t}),i=_e({...r,uiTemplateString:i}),mt(i)},Us=e=>{const{aiAgentColorVariables:t={}}=e,{internalVariables:n}=cr();return d.useState(()=>{const r=e.onGetCachedTemplate(e.templateKey);return r?Bs({...e,rawTemplate:r,aiAgentColorVariables:t,internalVariables:n,onRequestTemplate:e.onGetCachedTemplate}):null})},Hs=e=>{const[t]=Us(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",Zt=(e,t)=>{var s,a;const{chatSDK:n}=K(),{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&&Gt(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 d.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 dr(e){return Ks[e.type]||Ys}function yn(e){return dr(e).getValueOrDefault(e)}function Zs(e,t,n={}){const r={...Vs,...n};return dr(e).validate(e,t,r)}const Xs=(e,t={})=>{const{labels:n={},onSubmit:r,onCancel:s}=t,[a,i]=d.useState({}),[l,c]=d.useState(()=>{const x={};return e.fields.forEach(m=>{x[m.key]=yn(m)}),x}),u=d.useMemo(()=>e.submitted_at?"submitted":e.canceled_at?"canceled":"draft",[e.submitted_at,e.canceled_at]);d.useEffect(()=>{if(u==="submitted"||u==="canceled"){const x={};let m=!1;e.fields.forEach(p=>{const v=yn(p);JSON.stringify(l[p.key])!==JSON.stringify(v)&&(m=!0),x[p.key]=v}),m&&c(x)}},[u]);const f=(x,m)=>{c(p=>({...p,[x]:m})),i(p=>({...p,[x]:void 0}))},b=e.fields.map(x=>{var v,_,I;const m=l[x.key]??null,p={key:x.key,label:x.label,error:a[x.key],required:x.required};return x.type==="text"?{...p,type:"text",layout:x.layout,value:m,...x.placeholder&&{placeholder:x.placeholder},...((v=x.rules)==null?void 0:v.max_length)&&{maxLength:x.rules.max_length}}:x.type==="number"?{...p,type:"number",layout:x.layout,value:m,...x.placeholder&&{placeholder:x.placeholder},...((_=x.rules)==null?void 0:_.max)&&{max:x.rules.max}}:x.type==="single-select"?{...p,type:"single-select",layout:x.layout,value:m,options:x.options}:x.type==="multi-select"?{...p,type:"multi-select",layout:x.layout,value:m,options:x.options,...((I=x.rules)==null?void 0:I.max_select)&&{maxSelect:x.rules.max_select}}:{...p,type:"unknown",layout:"default",value:null}});return{state:u,fields:b,getField:x=>b.find(m=>m.key===x),updateFieldValue:f,submit:async()=>{const x={};let m=!1;for(const p of e.fields){const v=l[p.key]??null,_=Zs(p,v,n);_.isValid||(x[p.key]=_.error,m=!0)}if(i(x),!m&&r){const p={};e.fields.forEach(v=>{p[v.key]=l[v.key]??null}),await r(p)}},cancel:async()=>{await(s==null?void 0:s())}}},ur=({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?De(e)?s.human("agent"):s.ai("delight"):e.isDesk?s.human("agent"):s.channel("user")},_n=e=>d.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,c]=_n({followUpItem:!1}),u=d.useMemo(()=>{var x;const y=a.csat;if(typeof y!="number")return;const C=(x=e.follow_up)==null?void 0:x.find(m=>m.scores.includes(y));if(Js.has(C==null?void 0:C.response_type))return C},[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 C=typeof a.csat=="number",x=!((y=e.cre)!=null&&y.required)||typeof a.isResolved=="boolean";if(C&&x)return"submittable"}return"unsubmittable"})(),b=d.useCallback(()=>typeof a.csat>"u"?!1:u!=null&&u.required&&!a.csatReason?(c({followUpItem:!0}),!1):!0,[a,u,c]);return d.useEffect(()=>{r||(i({csatReason:""}),c({followUpItem:!1}))},[r,u,i,c]),{params:a,setParams:i,error:l,setError:c,followUpItem:u,state:f,validateParams:b,itemProps:{csatPayload:e,state:f,submitted:f==="submitted"}}},At=5,ea=250,ta=50,Sn=e=>Math.max(0,e-ta),na=e=>e<1e3?{speed:At*.5,chunkSize:2}:e<2e3?{speed:At*.8,chunkSize:2}:{speed:At*.6,chunkSize:3},ra=e=>{const{text:t,enabled:n=!1,onAnimationStart:r,onAnimationProgress:s,onAnimationComplete:a}=e,[i,l]=d.useState(()=>Sn(t.length)),c=d.useRef(null),u=d.useRef({startTime:0,lastUpdate:0,lastProgressCall:0}).current,f=d.useRef({onStart:r,onProgress:s,onComplete:a}).current,b=d.useRef({startCalled:!1,completeCalled:!1}).current,E=d.useRef({initialEnabled:n,textLength:t.length,enabled:n}).current,y=n,C=i<t.length,x=E.initialEnabled&&(y||C);return d.useLayoutEffect(()=>{f.onStart=r,f.onProgress=s,f.onComplete=a,E.textLength=t.length,E.enabled=n}),d.useLayoutEffect(()=>{var m;E.initialEnabled&&(b.startCalled||(b.startCalled=!0,(m=f.onStart)==null||m.call(f)),l(p=>t.length<p?t.length:p))},[t]),d.useEffect(()=>{if(!E.initialEnabled)return;let m=Sn(t.length);u.lastUpdate=0,u.startTime=0,u.lastProgressCall=0;const p=v=>{var z;u.lastUpdate===0&&(u.lastUpdate=v,u.startTime=v,u.lastProgressCall=v);const _=E.textLength,I=v-u.lastUpdate,A=v-u.startTime,{speed:M,chunkSize:$}=na(A),L=M*$;I>=L&&m<_&&(m=Math.min(m+$,_),l(m),u.lastUpdate=v),v-u.lastProgressCall>=ea&&(u.lastProgressCall=v,(z=f.onProgress)==null||z.call(f)),(m<_||E.enabled)&&(c.current=requestAnimationFrame(p))};return c.current=requestAnimationFrame(p),()=>{c.current&&cancelAnimationFrame(c.current)}},[]),d.useEffect(()=>{var _;const m=E.initialEnabled&&b.startCalled,p=!n,v=i>=t.length&&t.length>0;m&&p&&v&&!b.completeCalled&&(b.completeCalled=!0,(_=f.onComplete)==null||_.call(f))},[n,i,t.length]),{streamText:E.initialEnabled?t.slice(0,i):t,isAnimating:x}},oa='@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}',sa={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",scroll_to_new_messages_label:()=>"New message",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",a11y_scroll_to_new_messages:"Scroll to new messages"},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"}},Pt={language:"en",strings:sa,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,A11Y_SCROLL_TO_NEW_MESSAGES:e.conversation.a11y_scroll_to_new_messages,SCROLL_TO_NEW_MESSAGES_LABEL:e.conversation.scroll_to_new_messages_label}),aa=e=>{var t;return((t=e.split("-"))==null?void 0:t[0])??ft},ft="en",ia=new Set([ft,"ko","es","pt","fr","hi","it","de","tr","ja"]),la=(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(Pt.strings),ca={...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:Pt.language,dateLocale:Pt.dateLocale,stringSet:ca},da=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"})),Bt=new Map([[ft,it]]);async function ua(e){const t=Bt.get(e);if(t)return t;try{if(ia.has(e)){const{default:n}=await la(Object.assign({"./languages/de.ts":()=>Promise.resolve().then(()=>require("./XUKkIcnf.cjs")),"./languages/en.ts":()=>Promise.resolve().then(()=>da),"./languages/es.ts":()=>Promise.resolve().then(()=>require("./BDwqrgZD.cjs")),"./languages/fr.ts":()=>Promise.resolve().then(()=>require("./0FArne3s.cjs")),"./languages/hi.ts":()=>Promise.resolve().then(()=>require("./CQbdMB7S.cjs")),"./languages/it.ts":()=>Promise.resolve().then(()=>require("./B3EdwVP_.cjs")),"./languages/ja.ts":()=>Promise.resolve().then(()=>require("./ChN6oo70.cjs")),"./languages/ko.ts":()=>Promise.resolve().then(()=>require("./BC8yV2vW.cjs")),"./languages/pt.ts":()=>Promise.resolve().then(()=>require("./ZgKCWcTm.cjs")),"./languages/tr.ts":()=>Promise.resolve().then(()=>require("./mzSLgcai.cjs"))}),`./languages/${e}.ts`,3);return Bt.set(e,n),n}return it}catch{return it}}const{Provider:ma,useContext:U}=J("Localization"),ga=({language:e=navigator.language,logger:t,stringSet:n,children:r})=>{const[s,a]=d.useState(Bt.get(ft));return d.useEffect(()=>{const i=aa(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(ma,{value:{language:s.language,stringSet:{...s.stringSet,...n},dateLocale:s.dateLocale,format:(i,l,c)=>xe.format(i,l,{locale:s.dateLocale,...c})}},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")},ha=T.css(({theme:e})=>{const{palette:t}=e;return`
|
|
2
|
+
:root,
|
|
3
|
+
:host {
|
|
4
|
+
--sendbird-primary-extra-dark: ${t.primary.extraDark};
|
|
5
|
+
--sendbird-primary-dark: ${t.primary.dark};
|
|
6
|
+
--sendbird-primary-main: ${t.primary.main};
|
|
7
|
+
--sendbird-primary-light: ${t.primary.light};
|
|
8
|
+
--sendbird-primary-extra-light: ${t.primary.extraLight};
|
|
9
|
+
|
|
10
|
+
--sendbird-secondary-extra-dark: ${t.secondary.extraDark};
|
|
11
|
+
--sendbird-secondary-dark: ${t.secondary.dark};
|
|
12
|
+
--sendbird-secondary-main: ${t.secondary.main};
|
|
13
|
+
--sendbird-secondary-light: ${t.secondary.light};
|
|
14
|
+
--sendbird-secondary-extra-light: ${t.secondary.extraLight};
|
|
15
|
+
|
|
16
|
+
--sendbird-information-extra-dark: ${t.information.extraDark};
|
|
17
|
+
--sendbird-information-dark: ${t.information.dark};
|
|
18
|
+
--sendbird-information-main: ${t.information.main};
|
|
19
|
+
--sendbird-information-light: ${t.information.light};
|
|
20
|
+
--sendbird-information-extra-light: ${t.information.extraLight};
|
|
21
|
+
|
|
22
|
+
--sendbird-error-extra-dark: ${t.error.extraDark};
|
|
23
|
+
--sendbird-error-dark: ${t.error.dark};
|
|
24
|
+
--sendbird-error-main: ${t.error.main};
|
|
25
|
+
--sendbird-error-light: ${t.error.light};
|
|
26
|
+
--sendbird-error-extra-light: ${t.error.extraLight};
|
|
27
|
+
|
|
28
|
+
--sendbird-background-700: ${t.background700};
|
|
29
|
+
--sendbird-background-600: ${t.background600};
|
|
30
|
+
--sendbird-background-500: ${t.background500};
|
|
31
|
+
--sendbird-background-400: ${t.background400};
|
|
32
|
+
--sendbird-background-300: ${t.background300};
|
|
33
|
+
--sendbird-background-200: ${t.background200};
|
|
34
|
+
--sendbird-background-100: ${t.background100};
|
|
35
|
+
--sendbird-background-50: ${t.background50};
|
|
36
|
+
|
|
37
|
+
--sendbird-onlight-text-high-emphasis: ${t.onlight.textHighEmphasis};
|
|
38
|
+
--sendbird-onlight-text-mid-emphasis: ${t.onlight.textMidEmphasis};
|
|
39
|
+
--sendbird-onlight-text-low-emphasis: ${t.onlight.textLowEmphasis};
|
|
40
|
+
--sendbird-onlight-text-disabled: ${t.onlight.textDisabled};
|
|
41
|
+
|
|
42
|
+
--sendbird-ondark-text-high-emphasis: ${t.ondark.textHighEmphasis};
|
|
43
|
+
--sendbird-ondark-text-mid-emphasis: ${t.ondark.textMidEmphasis};
|
|
44
|
+
--sendbird-ondark-text-low-emphasis: ${t.ondark.textLowEmphasis};
|
|
45
|
+
--sendbird-ondark-text-disabled: ${t.ondark.textDisabled};
|
|
46
|
+
|
|
47
|
+
--sendbird-overlay-dark: ${t.overlay.dark};
|
|
48
|
+
--sendbird-overlay-light: ${t.overlay.light};
|
|
49
|
+
}
|
|
50
|
+
`}),fa=T.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);}`,g={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:pa,useContext:gr}=J("MessengerTheme");function ba(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(Ea,{...e}))}function Ea({rootElement:e=document.body,children:t}){const{theme:n,updateTheme:r}=Kt();return d.useLayoutEffect(()=>{e.setAttribute(lt,n.selectedTheme)},[e,n.selectedTheme]),o.createElement(T.ThemeProvider,{theme:n},o.createElement(pa,{value:{theme:n,updateTheme:r,rootElement:e}},t))}function we(e,t){const n=e.getRootNode({composed:t});return n instanceof ShadowRoot||n instanceof Document?n:document}const xa=(e,t)=>{d.useEffect(()=>{const n=we(t)instanceof ShadowRoot,r=we(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])},va=(e,t=document.body)=>{d.useEffect(()=>{const n=we(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:Ca,Consumer:hr,useContext:G}=J("Messenger");function ya({children:e,state:t,enableCloseConversationButton:n=!1,enableExpandButton:r=!0,enableAutoDisconnectInLauncher:s=!0,...a}){const[i,l]=d.useState(!1),[c,u]=d.useState(!1),f={opened:(t==null?void 0:t.opened)??i,setOpened:(t==null?void 0:t.setOpened)??l,expanded:(t==null?void 0:t.expanded)??c,setExpanded:(t==null?void 0:t.setExpanded)??u};return o.createElement(Bo,{...a},b=>o.createElement(Ca,{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},w=({as:e,variant:t="body1",color:n,maxTextLines:r,className:s,...a})=>o.createElement(Ta,{as:e,$variant:t,className:s,$color:n,$maxTextLines:r,...a}),wn=new WeakMap,_a=(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=T.css`font-size:${ae(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily?`font-family: ${s.fontFamily};`:""}
|
|
51
|
+
${s.lineHeight?`line-height: ${s.lineHeight};`:"line-height: 100%;"}
|
|
52
|
+
`;return n.set(e,a),a},Sa=e=>e?T.css`display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:${e};overflow:hidden;`:"",Ta=h.default.span`font-stretch:normal;letter-spacing:normal;${({$variant:e,theme:t})=>_a(e,t.typography)}color:${({$color:e})=>e};${({$maxTextLines:e})=>Sa(e)}`;class ct extends d.PureComponent{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){const{fallback:t=null,errorFallback:n=t,loadingFallback:r=t,children:s}=this.props;return this.state.hasError?n:o.createElement(d.Suspense,{fallback:r},s)}}const Aa=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"})),wa=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"})),ka=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"})),Ia=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"})),$a=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"})),Ma=new Set(["send","chat","message","chevron-right","good","good-filled","bad","bad-filled"]),La={close:Aa,send:$a,menu:Ia,expand:ka,collapse:wa,spinner:d.lazy(()=>Promise.resolve().then(()=>require("./Cf3-irI8.cjs"))),chat:d.lazy(()=>Promise.resolve().then(()=>require("./BmdfYY9c.cjs"))),message:d.lazy(()=>Promise.resolve().then(()=>require("./CmWLVNPR.cjs"))),error:d.lazy(()=>Promise.resolve().then(()=>require("./DNmdC4-j.cjs"))),info:d.lazy(()=>Promise.resolve().then(()=>require("./ohTjxqcW.cjs"))),refresh:d.lazy(()=>Promise.resolve().then(()=>require("./D00MOxhE.cjs"))),"chevron-down":d.lazy(()=>Promise.resolve().then(()=>require("./wf-LdaaN.cjs"))),"chevron-right":d.lazy(()=>Promise.resolve().then(()=>require("./B0k-GApQ.cjs"))),done:d.lazy(()=>Promise.resolve().then(()=>require("./kp5wcW4s.cjs"))),user:d.lazy(()=>Promise.resolve().then(()=>require("./CtHfgPDp.cjs"))),"file-document":d.lazy(()=>Promise.resolve().then(()=>require("./_YfLwFkX.cjs"))),download:d.lazy(()=>Promise.resolve().then(()=>require("./BN09c8-A.cjs"))),attach:d.lazy(()=>Promise.resolve().then(()=>require("./DcDTXo8_.cjs"))),delete:d.lazy(()=>Promise.resolve().then(()=>require("./CKPzhVy2.cjs"))),"close-filled":d.lazy(()=>Promise.resolve().then(()=>require("./D1kINslt.cjs"))),agent:d.lazy(()=>Promise.resolve().then(()=>require("./Ce1MzjFq.cjs"))),question:d.lazy(()=>Promise.resolve().then(()=>require("./JA0x62Fd.cjs"))),actionbook:d.lazy(()=>Promise.resolve().then(()=>require("./CXa-CGHE.cjs"))),function:d.lazy(()=>Promise.resolve().then(()=>require("./zbLY6xl_.cjs"))),"radio-on":d.lazy(()=>Promise.resolve().then(()=>require("./B9NJk4MI.cjs"))),"radio-off":d.lazy(()=>Promise.resolve().then(()=>require("./Bb0r6Nhu.cjs"))),confluence:d.lazy(()=>Promise.resolve().then(()=>require("./c6TZaE94.cjs"))),zendesk:d.lazy(()=>Promise.resolve().then(()=>require("./DqpDy_26.cjs"))),salesforce:d.lazy(()=>Promise.resolve().then(()=>require("./BsgzT_SF.cjs"))),sprinklr:d.lazy(()=>Promise.resolve().then(()=>require("./D97ZpKUC.cjs"))),website:d.lazy(()=>Promise.resolve().then(()=>require("./ygZY2D-5.cjs"))),snippet:d.lazy(()=>Promise.resolve().then(()=>require("./BCFOnu0u.cjs"))),template:d.lazy(()=>Promise.resolve().then(()=>require("./eJXfXI1_.cjs"))),source:d.lazy(()=>Promise.resolve().then(()=>require("./yVmX6iux.cjs"))),bot:d.lazy(()=>Promise.resolve().then(()=>require("./PhHbzZB_.cjs"))),"bot-filled":d.lazy(()=>Promise.resolve().then(()=>require("./DlvMdI1f.cjs"))),copy:d.lazy(()=>Promise.resolve().then(()=>require("./COgkkyBM.cjs"))),show:d.lazy(()=>Promise.resolve().then(()=>require("./DM-WWpci.cjs"))),mute:d.lazy(()=>Promise.resolve().then(()=>require("./P_ra76fq.cjs"))),good:d.lazy(()=>Promise.resolve().then(()=>require("./DEgUVAck.cjs"))),bad:d.lazy(()=>Promise.resolve().then(()=>require("./C0s7eAf7.cjs"))),"good-filled":d.lazy(()=>Promise.resolve().then(()=>require("./Chg8xHXT.cjs"))),"bad-filled":d.lazy(()=>Promise.resolve().then(()=>require("./CGkmTaBn.cjs"))),delight:d.lazy(()=>Promise.resolve().then(()=>require("./DCB0iTxd.cjs")))},N=({type:e,size:t=24,className:n,color:r})=>{const s=La[e];return o.createElement(Ra,{className:n,$rtlFlip:Ma.has(e),$size:t,$color:r??g.color.primary.main},o.createElement(ct,{errorFallback:o.createElement(Da,null)},o.createElement(s,null)))},Oa=T.css`[dir='rtl'] &{transform:scaleX(-1);}`,Ra=h.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&&Oa};`,Da=()=>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 Xt({name:e,type:t="FILE",iconColor:n,iconBackgroundColor:r,onClick:s}){const{colors:a}=T.useTheme();return o.createElement(Na,{onClick:s,$clickable:!!s},o.createElement(Ba,{$bgColor:r??a.base.primary},o.createElement(N,{type:"file-document",size:24,color:n??a.base.primaryContrastContent})),o.createElement(Fa,null,o.createElement(Ua,{variant:"button",color:g.themedColor.textHighEmphasis},e),o.createElement(w,{color:g.themedColor.textMidEmphasis,variant:"caption3"},t)))}const Na=h.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 ${g.themedColor.textDisabled};background-color:${g.themedColor.bg_50_600};${({$clickable:e})=>e&&Pa}`,Pa=T.css`cursor:pointer;&:hover{background-color:${g.themedColor.bg_100_500};}`,Ba=h.default.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({$bgColor:e})=>e};`,Fa=h.default.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`,Ua=h.default(w)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;function Ha({file:e,children:t,onClickFile:n}){return o.createElement(za,null,o.createElement(Xt,{name:e.name,type:Wt(e.name,e.type),onClick:n&&(()=>n==null?void 0:n(e))}),t)}const za=h.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${P.GAP_GROUPED}px;`,Va="1.12.0",ne="sb-agent",re={ENTRY:`${ne}-entry`,MODAL_ROOT:`${ne}-modal-root`,WINDOW:`${ne}-window`,LAUNCHER:`${ne}-launcher`},et=2147483647,Ie={MODAL:et-1,TOOLTIP:et-2,WINDOW:et-3,LAUNCHER:et-4},fr=36,Ga=100,Wa=Va,pt="noopener noreferrer nofollow",he=`${ne}-incoming-msg`,qa=`${ne}-marked-text`;function ja({file:e,onClickMedia:t,children:n}){const r=()=>e.type.startsWith("image")?o.createElement(Za,{src:e.url,alt:"image-message"}):e.type.startsWith("video")?o.createElement(Xa,{controls:!0},o.createElement("source",{src:e.url}),o.createElement("track",{kind:"captions"})):null;if(r){const s={id:`${he}-media-body`,onClick:()=>t==null?void 0:t(e)};return o.createElement(Ka,null,o.createElement(Ya,{...s},r()),n)}return null}const Ka=h.default.div`display:flex;flex-direction:column;align-items:flex-start;gap:${P.GAP_GROUPED}px;`,Ya=h.default.div`width:${P.BODY_MAX_WIDTH}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${R.light`
|
|
53
|
+
background-color: ${g.color.background100};
|
|
54
|
+
`}
|
|
55
|
+
${R.dark`
|
|
56
|
+
background-color: ${g.color.background400};
|
|
57
|
+
`}
|
|
58
|
+
`,Za=h.default.img`width:100%;height:100%;object-fit:cover;`,Xa=h.default.video`width:100%;height:100%;object-fit:cover;`,Ja="✱",pr=e=>{const t=new RegExp(`(\`+)([^\`]+?)\\1|(${Ja}+)`,"g");return e.replace(t,(n,r,s,a)=>r?n:a?`<span id=${qa} aria-label="masked-text">${a}</span>`:n)},Qa=e=>e.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"),ei=d.lazy(async()=>({default:(await Promise.resolve().then(()=>require("./CdV-y2tE.cjs"))).MarkdownText})),ti=d.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=d.useMemo(()=>Ao(e.message,pr),[e.message]),r={id:`${he}-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(ei,{onClickImage:c=>{var u;return(u=e.onClickMedia)==null?void 0:u.call(e,{url:c,type:"image/*"})}},i.value))):i.type==="code"?o.createElement(ct,{key:l,fallback:o.createElement($n,{variant:"body3"},i.value)},o.createElement(ti,{code:i.value,language:i.language})):null),e.children)}const In=h.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>T.css`
|
|
59
|
+
color: ${t||e.colors.messageIncoming.text};
|
|
60
|
+
background-color: ${n||e.colors.messageIncoming.background};
|
|
61
|
+
`}
|
|
62
|
+
padding: 12px 0;
|
|
63
|
+
transition: max-width 0.3s;
|
|
64
|
+
overflow-wrap: break-word;
|
|
65
|
+
`,$n=h.default(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ni(e){const{stringSet:t}=U(),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(ja,{...e},n):o.createElement(Ha,{...e},n)}return o.createElement(kn,{...e,message:t.UNKNOWN__UNKNOWN_MESSAGE_TYPE})}function Jt({id:e,src:t,size:n=56,onClick:r,style:s}){return o.createElement(ri,{id:e,tabIndex:0,onClick:r,$size:ae(n),style:s},t?o.createElement(oi,{src:t}):o.createElement(N,{type:"user",size:n}))}const ri=h.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:${g.themedColor.bg_100_500};&:focus{outline:none;}`,oi=h.default.img`object-fit:cover;width:100%;height:100%;position:absolute;`;function si({sender:e,isBotMessage:t}){const n=`${he}-sender-avatar`;return t&&!e.profileUrl?o.createElement(ai,{id:n},o.createElement(N,{type:"delight",size:"100%"})):o.createElement(Jt,{id:n,size:P.AVATAR_SIZE,src:e.profileUrl})}const ai=h.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 ii({sender:e}){return o.createElement(li,{id:`${he}-sender-name`,variant:"caption1",color:g.themedColor.textMidEmphasis},e.nickname)}const li=h.default(w)`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 ci({createdAt:e}){const{stringSet:t,format:n}=U();return e?o.createElement(w,{id:`${he}-sent-time`,variant:"caption4",color:g.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}function di({customStyle:e}){return o.createElement(ui,{$bgColor:e==null?void 0:e.bubbleBackgroundColor},[0,1,2].map(t=>o.createElement(mi,{key:t,$color:e==null?void 0:e.bubbleContentColor})))}const ui=h.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};`,mi=h.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 Qt(e){let t=e;t&&(!t.startsWith("http://")&&!t.startsWith("https://")&&(t="https://"+t),window.open(t,"_blank","noopener,noreferrer"))}function gi(e){requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}function hi({extendedMessagePayload:e,onClickCTA:t=({url:n})=>Qt(n)}){const n=e==null?void 0:e.cta_button;return n?o.createElement(fi,{id:`${he}-ext-cta-button`,role:"button",onClick:()=>t(n)},o.createElement(pi,{variant:"button"},n.label)):null}const fi=h.default.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${g.themedColor.textHighEmphasis};background-color:${g.color.background50};${R.dark`
|
|
66
|
+
background-color: ${g.color.ondark.textDisabled};
|
|
67
|
+
`}
|
|
68
|
+
`,pi=h.default(w)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;function bi({extendedMessagePayload:e,onClickCitation:t=n=>Qt(n.link)}){const{stringSet:n}=U(),{theme:r}=Kt(),s=e==null?void 0:e.citations;return!s||s.length===0?null:o.createElement(Ei,{id:`${he}-ext-citation`},o.createElement(xi,{variant:"caption1",color:r.colors.messageIncoming.text},n.CITATION_SOURCE_TITLE),o.createElement(vi,null,s.map((a,i)=>o.createElement(yi,{key:`${a.embedding_id}-${i}`,role:"button",onClick:()=>t(a)},o.createElement(N,{type:"source",size:16,color:r.colors.messageIncoming.text}),o.createElement(Ci,{variant:"body3",color:r.colors.messageIncoming.text},a.title)))))}const Ei=h.default.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`,xi=h.default(w)`opacity:0.5;`,vi=h.default.div`display:flex;flex-direction:column;gap:8px;`,Ci=h.default(w)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,yi=h.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=we(a),l=we(a,!0);return lo.createPortal(o.createElement(_i,{onClick:r,style:e},o.createElement(Si,{onClick:c=>c.stopPropagation()},s)),i.getElementById(t)??i.getElementById(re.MODAL_ROOT)??l.body)},_i=h.default.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${g.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${Ie.MODAL};`,Si=h.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:${Ie.MODAL};`,Ti=({visible:e,onClose:t,children:n})=>o.createElement(bt,{rootElementId:re.WINDOW,visible:e,onClose:t},o.createElement(ki,null,n)),Ai=({onClick:e,destructive:t,children:n})=>o.createElement(wi,{onClick:e,$destructive:t},n),Re=Object.assign(Ti,{ActionItem:Ai}),wi=h.default.button`all:unset;width:100%;padding:14px 24px;text-align:start;cursor:pointer;color:${({$destructive:e})=>e?g.themedColor.error:g.themedColor.textHighEmphasis};`,ki=h.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};`,Ft=e=>`${e}-filled`,Ii=e=>e==="good"?q.AIAgentMessageFeedbackRating.GOOD:q.AIAgentMessageFeedbackRating.BAD,br=T.css`&:hover{opacity:0.8;}&:active{opacity:0.6;}`,Mn={good:g.themedColor.secondary,bad:g.themedColor.error},$i=({visible:e,onClose:t,isEdit:n,initialRating:r,initialComment:s="",onSubmit:a,isCommentEnabled:i=!1})=>{const{stringSet:l}=U(),[c,u]=d.useState(r),[f,b]=d.useState(s);d.useLayoutEffect(()=>{e?(u(r),b(s)):(u(void 0),b(""))},[e,r,s]);const E=()=>{c&&(a({rating:c,comment:f.trim()||void 0}),t())},y=()=>{t()};return e?o.createElement(bt,{rootElementId:re.WINDOW,visible:e,onClose:y},o.createElement(Mi,null,o.createElement(Li,null,o.createElement(w,{variant:"h2",color:g.themedColor.textHighEmphasis},l.FEEDBACK_TITLE)),o.createElement(Oi,null,o.createElement(Ri,null,["good","bad"].map(C=>{const x=c===C,m=C==="good"?l.FEEDBACK_GOOD:l.FEEDBACK_BAD;return o.createElement(Di,{key:C,$selected:x,$rating:C,onClick:()=>u(C)},o.createElement(N,{type:x?Ft(C):C,size:24,color:x?Mn[C]:g.themedColor.textLowEmphasis}),o.createElement(w,{variant:"caption1",color:x?Mn[C]:g.themedColor.textLowEmphasis},m))})),i&&o.createElement(Ni,null,o.createElement(w,{variant:"caption3",color:g.themedColor.textHighEmphasis},l.FEEDBACK_COMMENT_LABEL),o.createElement(Pi,{placeholder:l.FEEDBACK_COMMENT_PLACEHOLDER,value:f,onChange:C=>b(C.target.value),maxLength:100}))),o.createElement(Bi,null,o.createElement(Fi,{onClick:y},o.createElement(w,{variant:"button",color:g.themedColor.textHighEmphasis},l.FEEDBACK_CANCEL)),o.createElement(Ui,{onClick:E,disabled:!c},o.createElement(w,{variant:"button"},n?l.FEEDBACK_SAVE:l.FEEDBACK_SUBMIT))))):null},Mi=h.default.div`width:280px;background-color:${({theme:e})=>e.colors.base.modalContentBackground};border-radius:12px;overflow:hidden;`,Li=h.default.div`padding:24px;`,Oi=h.default.div`padding-inline:24px;display:flex;flex-direction:column;gap:24px;`,Ri=h.default.div`display:flex;gap:4px;`,Di=h.default.button`width:114px;height:64px;border-radius:12px;border:1px solid ${g.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?g.color.background100:"transparent"};${({$selected:e})=>R.dark`
|
|
69
|
+
background-color: ${e?g.color.background600:"transparent"};
|
|
70
|
+
`}
|
|
71
|
+
|
|
72
|
+
&:hover {
|
|
73
|
+
opacity: 0.8;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:active {
|
|
77
|
+
opacity: 0.6;
|
|
78
|
+
}
|
|
79
|
+
`,Ni=h.default.div`display:flex;flex-direction:column;gap:6px;`,Pi=h.default.textarea`font-family:inherit;font-size:12px;line-height:16px;border:1px solid ${g.themedColor.textDisabled};border-radius:4px;padding:6px 12px;color:${g.themedColor.textHighEmphasis};background-color:${g.themedColor.textLowEmphasisInverse};resize:none;field-sizing:content;min-height:28px;max-height:118px;overflow-y:auto;&::placeholder{color:${g.themedColor.textLowEmphasis};}&:focus{outline:none;}`,Bi=h.default.div`padding-inline:24px;padding-block:16px;display:flex;justify-content:flex-end;gap:4px;`,Er=h.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;`,Fi=h.default(Er)`${br}`,Ui=h.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:g.themedColor.secondary,bad:g.themedColor.error};function Hi({isBotMessage:e,isConversationClosed:t,isStreaming:n,isFeedbackEnabled:r,isFeedbackCommentEnabled:s,extendedMessagePayload:a,onFeedbackUpdate:i}){const{stringSet:l}=U(),[c,u]=d.useState(!1),[f,b]=d.useState(!1),[E,y]=d.useState(void 0),[C,x]=d.useState(""),m=a==null?void 0:a.feedback,p=(m==null?void 0:m.rating)??"none";if(p!=="none"?!1:!!(n||!e||!r||(a==null?void 0:a.bot_message_type)!=="generated"||t))return null;const _=$=>{p==="none"?(y($),x(""),u(!0)):b(!0)},I=()=>{i==null||i(null),b(!1)},A=()=>{b(!1),y(m==null?void 0:m.rating),x((m==null?void 0:m.comment)??""),u(!0)},M=$=>{i==null||i($)};return t&&p!=="none"?o.createElement(On,{$horizontal:!0},o.createElement(zi,null,o.createElement(N,{type:Ft(p),size:12,color:Ln[p]})),(m==null?void 0:m.comment)&&o.createElement(Rn,{variant:"caption2",style:{lineHeight:"16px"}},m.comment)):o.createElement(o.Fragment,null,o.createElement(On,null,o.createElement(Vi,null,["good","bad"].map($=>{const L=p===$;return o.createElement(Gi,{key:$,$selected:L,$rating:$,onClick:()=>_($)},o.createElement(N,{type:L?Ft($):$,size:14,color:L?Ln[$]:g.themedColor.textMidEmphasis}))})),p!=="none"&&(m==null?void 0:m.comment)&&o.createElement(Rn,{variant:"caption2"},m.comment)),o.createElement(Re,{visible:f,onClose:()=>b(!1)},o.createElement(Re.ActionItem,{onClick:A},l.FEEDBACK_EDIT),o.createElement(Re.ActionItem,{onClick:I,destructive:!0},l.FEEDBACK_REMOVE)),o.createElement($i,{visible:c,onClose:()=>u(!1),isEdit:p!=="none",initialRating:E,initialComment:C,onSubmit:M,isCommentEnabled:s}))}const On=h.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;`,zi=h.default.div`padding:2px;flex-shrink:0;display:flex;align-items:center;`,Vi=h.default.div`display:flex;gap:2px;`,Gi=h.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 ${g.color.background200};background-color:${({$selected:e})=>e?g.color.background100:"transparent"};${({$selected:e})=>R.dark`
|
|
80
|
+
border: 1px solid ${g.color.background400};
|
|
81
|
+
background-color: ${e?g.color.background500:"transparent"};
|
|
82
|
+
`}
|
|
83
|
+
|
|
84
|
+
${br}
|
|
85
|
+
`,Rn=h.default(w)`color:${g.themedColor.textMidEmphasis};${R.dark`
|
|
86
|
+
color: ${g.themedColor.textHighEmphasis};
|
|
87
|
+
`}
|
|
88
|
+
`,en=({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(Wi,null,o.createElement(qi,null,t&&o.createElement(w,{variant:"h1",color:g.themedColor.textHighEmphasis},t),n&&o.createElement(ji,null,o.createElement(w,{variant:"subtitle2",color:g.themedColor.textHighEmphasis},n))),o.createElement(Ki,null,o.createElement(Yi,{onClick:i},o.createElement(w,{variant:"button",color:g.themedColor.primary},r)))))},Wi=h.default.div`width:360px;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};`,qi=h.default.div`margin-bottom:16px;`,ji=h.default.div`margin-top:8px;`,Ki=h.default.div`display:flex;flex-direction:row;justify-content:flex-end;`,Yi=h.default.button`all:unset;display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:transparent;padding:10px 16px;`,tn=T.css`width:100%;height:36px;border-radius:6px;cursor:pointer;transition:all 0.2s ease;padding:0 12px;border:none;outline:none;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,Dn=h.default.button`${tn};background-color:${g.themedColor.primary};color:${g.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.9;}`,Zi=h.default.button`${tn};color:${g.themedColor.primary};${R.light`
|
|
89
|
+
background-color: ${g.color.background50};
|
|
90
|
+
`};
|
|
91
|
+
${R.dark`
|
|
92
|
+
background-color: ${g.color.background700};
|
|
93
|
+
`};
|
|
94
|
+
|
|
95
|
+
&:hover:not(:disabled) {
|
|
96
|
+
opacity: 0.9;
|
|
97
|
+
}
|
|
98
|
+
`,Xi=h.default.button`${tn};background-color:transparent;color:${g.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`,Ji=e=>{switch(e){case"primary":return Dn;case"secondary":return Zi;case"clear":return Xi;default:return Dn}},Qi=h.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);}}`,el=({children:e,onClick:t,variant:n="primary",disabled:r=!1,loading:s=!1,className:a})=>{const i=()=>{switch(n){case"primary":return g.themedColor.textHighEmphasisInverse;case"secondary":return g.themedColor.primary;case"clear":return g.themedColor.textHighEmphasis;default:return g.themedColor.textHighEmphasisInverse}},l=Ji(n);return o.createElement(l,{onClick:t,disabled:r||s,className:a},s?o.createElement(Qi,null,o.createElement(N,{type:"spinner",size:22,color:i()})):o.createElement(w,{variant:"button",color:i()},e))},tl=({children:e,className:t,style:n})=>o.createElement(w,{variant:"caption4",color:g.themedColor.error,className:t,style:n},e),nl=({children:e,className:t,style:n,required:r})=>{const{stringSet:s}=U();return o.createElement(w,{variant:"caption3",color:g.themedColor.textMidEmphasis,className:t,style:n},e,!r&&o.createElement("span",{style:{color:g.themedColor.textLowEmphasis}},` (${s.OPTIONAL})`))},rl=({value:e,onChange:t,placeholder:n,error:r=!1,submitted:s=!1,className:a,disabled:i=!1,max:l})=>{const c=f=>{const E=f.target.value.replace(/[^0-9.-]/g,""),y=E.split("."),x=y.length>1?y[0]+"."+y.slice(1).join("").replace(/\./g,""):E;if(f.target.value=x,x===""||x==="-")t==null||t(null);else{const m=Number(x);if(!isNaN(m)){if(l!==void 0&&m>l)return;t==null||t(m)}}},u=e==null?"":String(e);return o.createElement(ll,{type:"text",value:u,onChange:c,placeholder:n,className:a,disabled:i||s,inputMode:"decimal",$error:r,$submitted:s})},ol=T.css`width:100%;height:36px;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${g.themedColor.textLowEmphasis};}&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}`,sl=T.css`color:${g.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${R.light`
|
|
99
|
+
background-color: ${g.color.ondark.textMidEmphasis};
|
|
100
|
+
`}
|
|
101
|
+
${R.dark`
|
|
102
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
103
|
+
`}
|
|
104
|
+
|
|
105
|
+
&::placeholder {
|
|
106
|
+
color: ${g.themedColor.textLowEmphasis};
|
|
107
|
+
}
|
|
108
|
+
`,al=T.css`border:1px solid ${g.themedColor.error};color:${g.themedColor.textHighEmphasis};${R.light`
|
|
109
|
+
background-color: ${g.color.background50};
|
|
110
|
+
`}
|
|
111
|
+
${R.dark`
|
|
112
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
113
|
+
`}
|
|
114
|
+
`,il=T.css`border:1px solid ${g.themedColor.textDisabled};color:${g.themedColor.textHighEmphasis};${R.light`
|
|
115
|
+
background-color: ${g.color.background50};
|
|
116
|
+
`}
|
|
117
|
+
${R.dark`
|
|
118
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
119
|
+
`}
|
|
120
|
+
|
|
121
|
+
&:focus {
|
|
122
|
+
border-color: ${g.themedColor.primary};
|
|
123
|
+
}
|
|
124
|
+
`,ll=h.default.input`${ol}${({$error:e,$submitted:t})=>t?sl:e?al:il}`,cl=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 c=t.filter(u=>u!==i);n==null||n(c)}else{if(r&&t.length>=r)return;const c=[...t,i];n==null||n(c)}}}}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}=cl(e);return o.createElement(ul,{className:s},t.map(l=>{const c=a.includes(l.value);return o.createElement(El,{key:l.value,$active:c,$submitted:n,$error:r,onClick:()=>i(l.value)},o.createElement(w,{variant:"caption1",color:dl(c,n)},l.label))}))},dl=(e,t)=>t?e?g.themedColor.textHighEmphasis:g.themedColor.textDisabled:e?g.themedColor.primary:g.themedColor.textMidEmphasis,ul=h.default.div`display:flex;flex-wrap:wrap;gap:4px 2px;`,ml=T.css`display:inline-flex;align-items:center;padding:8px 12px;border-radius:15px;transition:all 0.2s ease;`,gl=T.css`cursor:default;background-color:${g.color.ondark.textMidEmphasis};color:${g.themedColor.textHighEmphasis};${R.dark`
|
|
125
|
+
background-color: transparent;
|
|
126
|
+
border: 1px solid white;
|
|
127
|
+
color: white;
|
|
128
|
+
`}
|
|
129
|
+
`,hl=T.css`cursor:default;${R.light`
|
|
130
|
+
background-color: ${g.color.ondark.textMidEmphasis};
|
|
131
|
+
color: ${g.themedColor.textDisabled};
|
|
132
|
+
`}
|
|
133
|
+
${R.dark`
|
|
134
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
135
|
+
border: 1px solid ${g.color.onlight.textLowEmphasis};
|
|
136
|
+
color: ${g.themedColor.textDisabled};
|
|
137
|
+
`}
|
|
138
|
+
`,fl=T.css`cursor:pointer;border:1px solid ${g.themedColor.primary};${R.light`
|
|
139
|
+
background-color: ${g.color.background50};
|
|
140
|
+
color: ${g.themedColor.primary};
|
|
141
|
+
`}
|
|
142
|
+
${R.dark`
|
|
143
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
144
|
+
color: ${g.themedColor.primary};
|
|
145
|
+
`}
|
|
146
|
+
`,pl=T.css`cursor:pointer;border:1px solid ${g.themedColor.textDisabled};${R.light`
|
|
147
|
+
background-color: ${g.color.background50};
|
|
148
|
+
color: ${g.themedColor.textMidEmphasis};
|
|
149
|
+
`}
|
|
150
|
+
${R.dark`
|
|
151
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
152
|
+
color: ${g.themedColor.textMidEmphasis};
|
|
153
|
+
`}
|
|
154
|
+
`,bl=T.css`border-color:${g.themedColor.error}!important;`,El=h.default.div`${ml}${({$active:e,$submitted:t,$error:n})=>{if(t)return e?gl:hl;const r=e?fl:pl;return n?T.css`
|
|
155
|
+
${r} ${bl}
|
|
156
|
+
`:r}}
|
|
157
|
+
`,xl=e=>o.createElement(xr,{...e,multiple:!1}),vl=e=>o.createElement(xr,{...e,multiple:!0}),Cl=h.default.div`width:100%;height:1px;background-color:${g.themedColor.textDisabled};`,yl=({className:e})=>o.createElement(Cl,{className:e}),_l=({value:e="",onChange:t,placeholder:n,variant:r="single-line",error:s=!1,submitted:a=!1,className:i,disabled:l=!1,maxLength:c})=>{const f={value:e,onChange:b=>{const E=b.target.value;c&&E.length>c||t==null||t(E)},placeholder:n,className:i,disabled:l||a,maxLength:c,$error:s,$submitted:a};return r==="multi-line"?o.createElement(Tl,{...f}):o.createElement(Sl,{...f})},vr=T.css`width:100%;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${g.themedColor.textLowEmphasis};}`,Cr=T.css`color:${g.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${R.light`
|
|
158
|
+
background-color: ${g.color.ondark.textMidEmphasis};
|
|
159
|
+
`}
|
|
160
|
+
${R.dark`
|
|
161
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
162
|
+
`}
|
|
163
|
+
|
|
164
|
+
&::placeholder {
|
|
165
|
+
color: ${g.themedColor.textLowEmphasis};
|
|
166
|
+
}
|
|
167
|
+
`,yr=T.css`border:1px solid ${g.themedColor.error};color:${g.themedColor.textHighEmphasis};${R.light`
|
|
168
|
+
background-color: ${g.color.background50};
|
|
169
|
+
`}
|
|
170
|
+
${R.dark`
|
|
171
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
172
|
+
`}
|
|
173
|
+
`,_r=T.css`border:1px solid ${g.themedColor.textDisabled};color:${g.themedColor.textHighEmphasis};${R.light`
|
|
174
|
+
background-color: ${g.color.background50};
|
|
175
|
+
`}
|
|
176
|
+
${R.dark`
|
|
177
|
+
background-color: ${g.color.onlight.textLowEmphasis};
|
|
178
|
+
`}
|
|
179
|
+
|
|
180
|
+
&:focus {
|
|
181
|
+
border-color: ${g.themedColor.primary};
|
|
182
|
+
}
|
|
183
|
+
`,Sl=h.default.input`${vr};height:36px;${({$error:e,$submitted:t})=>t?Cr:e?yr:_r}`,Tl=h.default.textarea`${vr};height:96px;resize:none;font-family:inherit;${({$error:e,$submitted:t})=>t?Cr:e?yr:_r}`,Al=({children:e,className:t,style:n})=>o.createElement(w,{variant:"button",color:g.themedColor.textHighEmphasis,className:t,style:n},e),Y={Title:Al,Label:nl,ErrorLabel:tl,Separator:yl,Button:el,TextInput:_l,NumberInput:rl,SingleSelect:xl,MultiSelect:vl},wl=1,kl=new Set(["text","number","single-select","multi-select"]),Il=e=>{var m;const t=(m=e.extendedMessagePayload)==null?void 0:m.form;if(!t)throw new Error("Form is not provided");const{stringSet:n}=U(),[r,s]=d.useState({submitting:!1,canceling:!1}),[a,i]=d.useState({visible:!1}),{state:l,fields:c,submit:u,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:p=>{var v;return(v=e.onSubmitForm)==null?void 0:v.call(e,{key:t.key,data:p})},onCancel:()=>{var p;return(p=e.onCancelForm)==null?void 0:p.call(e,{key:t.key})}}),E=l==="submitted",y=async()=>{s(p=>({...p,submitting:!0}));try{await u()}catch(p){i({visible:!0,description:p instanceof Error?p.message:n.TRY_AGAIN})}finally{s(p=>({...p,submitting:!1}))}},C=async()=>{s(p=>({...p,canceling:!0}));try{await f()}catch(p){i({visible:!0,description:p instanceof Error?p.message:n.TRY_AGAIN})}finally{s(p=>({...p,canceling:!1}))}},x=d.useMemo(()=>{const p=()=>t.version>wl,v=()=>t.fields.some(_=>!kl.has(_.type));return p()||v()?{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:x.visible?o.createElement(d.Fragment,null,o.createElement(Nn,{$maxWidth:e.maxBodyWidth??P.BODY_MAX_WIDTH},o.createElement(Y.Title,null,t.title),o.createElement($l,null,c.map(p=>o.createElement(Ml,{key:p.key},o.createElement(Y.Label,{style:{marginBottom:"6px"},required:p.required},p.label),p.type==="text"&&o.createElement(Y.TextInput,{value:p.value||"",placeholder:p.placeholder,onChange:v=>b(p.key,v),disabled:E,error:!!p.error,submitted:E,variant:p.layout==="multiline"?"multi-line":"single-line",maxLength:p.maxLength}),p.type==="number"&&o.createElement(Y.NumberInput,{value:p.value||null,placeholder:p.placeholder,onChange:v=>b(p.key,v),disabled:E,error:!!p.error,submitted:E,max:p.max}),p.type==="single-select"&&o.createElement(Y.SingleSelect,{options:p.options.map(v=>({label:v,value:v})),value:p.value||"",onChange:v=>b(p.key,v),submitted:E}),p.type==="multi-select"&&o.createElement(Y.MultiSelect,{options:p.options.map(v=>({label:v,value:v})),value:p.value||[],onChange:v=>b(p.key,v),submitted:E,maxSelect:p.maxSelect}),p.error&&o.createElement(Y.ErrorLabel,{style:{marginTop:"4px"}},p.error)))),o.createElement(Y.Separator,null),o.createElement(Ll,null,o.createElement(Y.Button,{variant:E?"clear":"primary",onClick:y,disabled:E||r.canceling,loading:r.submitting},E?n.SUBMITTED:n.BUTTON__SUBMIT),l!=="submitted"&&o.createElement(Y.Button,{variant:"secondary",onClick:C,disabled:r.submitting,loading:r.canceling},n.BUTTON__CANCEL))),o.createElement(en,{...a,onClose:()=>i({visible:!1,title:""})})):o.createElement(Nn,{$maxWidth:e.maxBodyWidth??P.BODY_MAX_WIDTH},o.createElement(w,{variant:"body3"},x.reason),x.cancelable&&o.createElement(Y.Button,{variant:"primary",onClick:C,loading:r.canceling},n.BUTTON__CANCEL))},Nn=h.default.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e})=>T.css`
|
|
184
|
+
color: ${e.colors.messageIncoming.text};
|
|
185
|
+
background-color: ${e.colors.messageIncoming.background};
|
|
186
|
+
`}
|
|
187
|
+
padding: 16px 12px;
|
|
188
|
+
transition: max-width 0.3s;
|
|
189
|
+
overflow-wrap: break-word;
|
|
190
|
+
`,$l=h.default.div`display:flex;flex-direction:column;gap:12px;`,Ml=h.default.div`display:flex;flex-direction:column;`,Ll=h.default.div`display:flex;flex-direction:column;gap:8px;`;function Ol(e){return o.createElement(o.Fragment,null)}const Rl=new Set(["default"]),{MessageTemplate:Dl}=co.createMessageTemplate({parser:Mt.parser,renderer:Mt.renderer,Container:e=>o.createElement("div",{...e})});function Nl(e){return o.createElement(ct,{errorFallback:e.messageTemplateErrorFallback,loadingFallback:e.messageTemplateLoadingFallback},o.createElement(Pl,{...e}))}const Pl=({extendedMessagePayload:e,onGetCachedMessageTemplate:t=()=>null,onRequestMessageTemplate:n,onHandleTemplateInternalAction:r=me})=>{const s=e==null?void 0:e.message_template;if(!Rl.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=Hs({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(Bl,{id:`${he}-ext-message-template`},o.createElement(Mt.MessageProvider,{handleInternalAction:(c,u)=>{c.stopPropagation(),r==null||r(u)}},o.createElement(Dl,{templateItems:l.body.items,templateVersion:l.version})))},Bl=h.default.div`box-sizing:border-box;overflow:hidden;width:100%;`;function Fl({extendedMessagePayload:e,onClickSuggestedReply:t,suggestedRepliesDirection:n="vertical"}){const[r,s]=d.useState(!1),a=(e==null?void 0:e.suggested_replies)??[];return a.length===0||r?null:o.createElement(Ul,{id:`${he}-ext-suggested-replies`,$type:n},a.map((i,l)=>o.createElement(Hl,{key:l,$type:n,variant:"body3",onClick:()=>{t&&(t==null||t({reply:i}),s(!0))}},i)))}const Ul=h.default.div`margin:16px 0;padding:0 ${P.HORIZONTAL_PADDING}px;position:relative;display:flex;align-self:stretch;gap:8px;${({$type:e})=>e==="vertical"?zl:Vl};`,Hl=h.default(w)`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:${g.color.primary.main};border:1px solid ${g.color.primary.main};background-color:${g.themedColor.bg_50_600};&:hover{background-color:${g.themedColor.bg_100_500};}${({$type:e,theme:t})=>T.css`
|
|
191
|
+
${e==="vertical"?Gl:Wl};
|
|
192
|
+
&:active {
|
|
193
|
+
background-color: ${t.colors.base.primary};
|
|
194
|
+
color: ${t.colors.base.primaryContrastContent};
|
|
195
|
+
}
|
|
196
|
+
`}
|
|
197
|
+
`,zl=T.css`flex-direction:column;align-items:flex-end;`,Vl=T.css`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`,Gl=T.css`max-width:calc(100% - 70px);white-space:pre-wrap;`,Wl=T.css`white-space:nowrap;`,ke=ge({template:ql,components:{SenderName:ii,SenderAvatar:si,SentTime:ci,MessageBody:ni,TypingIndicator:di,SuggestedReplies:Fl,MessageTemplate:Nl,CTAButton:hi,Citation:bi,Form:Il,Feedback:Hi,MessageLogs:Ol}});function ql(e){return o.createElement(Sr,{...e,testerMode:!1})}function Sr(e){var m,p,v,_,I,A,M;const{components:t}=ke.useContext(),{streamText:n,isAnimating:r}=ra({text:e.message,enabled:e.isStreaming,onAnimationStart:e.onStreamAnimationStart,onAnimationProgress:e.onStreamAnimationProgress,onAnimationComplete:e.onStreamAnimationComplete}),s={...e,message:n,extendedMessagePayload:r?{}:e.extendedMessagePayload},a=!!s.isTyping,i=s.testerMode,l=!!s.isSenderAvatarVisible,c=!!((m=s.extendedMessagePayload)!=null&&m.form)&&!((p=s.extendedMessagePayload)!=null&&p.form.canceled_at),u=!!((v=s.extendedMessagePayload)!=null&&v.message_template),f=!!((_=s.extendedMessagePayload)!=null&&_.cta_button),b=!!((I=s.extendedMessagePayload)!=null&&I.citations)&&s.extendedMessagePayload.citations.length>0,E=!!s.createdAt,y=s.groupType==="top"||s.groupType==="single",C=s.groupType==="bottom"||s.groupType==="single",x=i||!l?0:P.AVATAR_SIZE;return o.createElement(jl,{$marginBottom:a?0:qt(s.groupType)},y&&o.createElement(Kl,null,!i&&l&&o.createElement(t.SenderAvatar,{...s}),o.createElement(t.SenderName,{...s})),o.createElement(Zl,null,o.createElement(wt,{$extraStartPadding:x},a?o.createElement(t.TypingIndicator,{...s}):o.createElement(t.MessageBody,{...s},f&&o.createElement("div",{style:{marginTop:12,marginInline:12}},o.createElement(t.CTAButton,{...s})),b&&o.createElement(t.Citation,{...s}))),u&&o.createElement(Pn,{$startPadding:0,$endPadding:0},o.createElement(t.MessageTemplate,{...s,messageTemplateErrorFallback:s.messageTemplateErrorFallback??o.createElement(wt,{$extraStartPadding:x},o.createElement(t.MessageBody,{...s,messageType:"user",message:((M=(A=s.extendedMessagePayload)==null?void 0:A.message_template)==null?void 0:M.fallback_message)??"Cannot read this template."})),messageTemplateLoadingFallback:s.messageTemplateLoadingFallback??o.createElement(wt,{$extraStartPadding:x},o.createElement(t.TypingIndicator,{...s}))})),c&&o.createElement(Pn,{$extraStartPadding:x},o.createElement(t.Form,{...s}))),C&&E&&o.createElement(Yl,{$extraStartPadding:x+8},o.createElement(t.SentTime,{...s})),o.createElement(d.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 jl=h.default.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
198
|
+
`,je=h.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
|
+
padding-inline: ${e+n}px ${t}px;
|
|
200
|
+
`}
|
|
201
|
+
`,Kl=h.default(je)`display:flex;flex-direction:row;align-items:center;gap:8px;`,wt=h.default(je)`display:flex;`,Yl=h.default(je)`margin-top:${P.BODY_TIME_GAP}px;display:flex;align-items:flex-start;justify-content:flex-start;`,Pn=h.default(je)`display:flex;${({$startPadding:e=P.HORIZONTAL_PADDING,$endPadding:t=P.HORIZONTAL_PADDING,$extraStartPadding:n=0})=>`
|
|
202
|
+
padding-inline: ${e+n}px ${t}px;
|
|
203
|
+
`}
|
|
204
|
+
`,Zl=h.default.div`display:flex;flex-direction:column;gap:${P.GAP_GROUPED}px;`;function Xl({file:e,children:t,onClickFile:n,sendingStatus:r}){const s=(()=>{if(!(!n||r==="failed"))return()=>n==null?void 0:n(e)})();return o.createElement(Jl,null,o.createElement(Xt,{name:e.name,type:Wt(e.name,e.type),onClick:s}),t)}const Jl=h.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${P.GAP_GROUPED}px;`,nn=({className:e,children:t,size:n=26})=>o.createElement(Ql,{className:e,$size:n},t??o.createElement(N,{type:"spinner",size:n})),Ql=h.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 ec({sendingStatus:e,file:t,metadata:n,onClickMedia:r,children:s}){const{aspectRatio:a,localFile:i}=n,[l]=d.useState(()=>i instanceof Blob?URL.createObjectURL(i):t.url),[c,u]=d.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(tc,null,o.createElement(nc,{...b},!c&&o.createElement(nn,{size:26},o.createElement(N,{type:"spinner",color:"textLowEmphasis",size:26})),o.createElement(rc,{$loaded:c,src:l,alt:"image-message",onLoad:()=>u(!0)})),s)}const tc=h.default.div`display:flex;flex-direction:column;align-items:flex-end;gap:${P.GAP_GROUPED}px;`,nc=h.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
|
+
background-color: ${g.color.background100};
|
|
206
|
+
`}
|
|
207
|
+
${R.dark`
|
|
208
|
+
background-color: ${g.color.background400};
|
|
209
|
+
`}
|
|
210
|
+
`,rc=h.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=d.useMemo(()=>{const s=Qa(pr(e.message));return Yn.default.sanitize(s)},[e.message]);return o.createElement(oc,{$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(sc,{variant:"body3",dangerouslySetInnerHTML:{__html:t}}))}const oc=h.default.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({$maxWidth:e})=>e}px;${({theme:e,$color:t,$bgColor:n})=>T.css`
|
|
211
|
+
color: ${t||e.colors.messageOutgoing.text};
|
|
212
|
+
background-color: ${n||e.colors.messageOutgoing.background};
|
|
213
|
+
`}
|
|
214
|
+
padding: 12px 0;
|
|
215
|
+
transition: max-width 0.3s;
|
|
216
|
+
overflow-wrap: break-word;
|
|
217
|
+
`,sc=h.default(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;function ac(e){const{stringSet:t}=U(),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(ec,{...e},a):o.createElement(Xl,{...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 ic({sendingStatus:e}){const t=T.useTheme();switch(e){case"pending":return o.createElement(lc,{size:16},o.createElement(N,{type:"spinner",color:t.colors.messageOutgoing.background,size:16}));case"failed":return o.createElement("div",{style:{marginBottom:2}},o.createElement(N,{type:"error",color:g.themedColor.error,size:16}));case"scheduled":case"canceled":return null;default:return o.createElement("div",{style:{marginBottom:2}},o.createElement(N,{type:"done",color:g.themedColor.secondary,size:16}))}}const lc=h.default(nn)`margin-bottom:2px;width:16px;height:16px;`;function cc({createdAt:e}){const{stringSet:t,format:n}=U();return e?o.createElement(w,{variant:"caption4",color:g.themedColor.textLowEmphasis},n(e,t.DATE_FORMAT__MESSAGE_TIMESTAMP)):null}const Et=ge({template:dc,components:{SendingStatus:ic,SentTime:cc,MessageBody:ac}});function dc(e){const{components:t}=Et.useContext(),n=e.sendingStatus==="succeeded",r=e.groupType==="bottom"||e.groupType==="single";return o.createElement(uc,{$marginBottom:qt(e.groupType)},o.createElement(mc,null,o.createElement(t.MessageBody,{...e})),r&&o.createElement(gc,{$extraEndPadding:8},n?o.createElement(t.SentTime,{...e}):o.createElement(t.SendingStatus,{...e})))}const uc=h.default.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({$marginBottom:e})=>`${e}px`};
|
|
218
|
+
`,Tr=h.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
|
+
`,mc=h.default(Tr)``,gc=h.default(Tr)`margin-top:${P.BODY_TIME_GAP}px;`;function hc(e){return e.messageType!=="admin"?null:o.createElement(fc,null,o.createElement(w,{variant:"caption2",color:g.themedColor.textMidEmphasis},pc(Yn.default.sanitize(e.message))))}const fc=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;}`,pc=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:c,type:u}=l,f=c.index;f>0&&t.push(n.slice(0,f)),u==="link"?t.push(o.createElement("a",{key:r++,href:c[2],target:"_blank",rel:pt},c[1])):u==="bold"&&t.push(o.createElement("strong",{key:r++},c[1])),n=n.slice(f+c[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?g.themedColor.primary:r?g.themedColor.textDisabled:g.themedColor.textLowEmphasis,i=t?g.themedColor.textHighEmphasis:r?g.themedColor.textLowEmphasis:g.themedColor.textHighEmphasis;return o.createElement(xc,{onClick:e,disabled:r},o.createElement(bc,null,o.createElement(N,{size:20,type:t?"radio-on":"radio-off",color:a})),o.createElement(Ec,{variant:s,color:i},n))},bc=h.default.div`width:20px;height:20px;`,Ec=h.default(w)`line-height:20px;word-break:break-word;`,xc=h.default.button`all:unset;display:flex;align-items:flex-start;justify-content:flex-start;gap:2px;&:enabled{cursor:pointer;}`,vc=({csatPayload:e,submitted:t,defaultValue:n,value:r,onChange:s})=>(d.useEffect(()=>{typeof r>"u"&&typeof n=="boolean"&&(s==null||s(n))},[r,n]),e.cre?o.createElement(Cc,null,o.createElement(Y.Label,{required:e.cre.required},e.cre.question),o.createElement(yc,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),Cc=h.default.div`display:flex;flex-direction:column;gap:8px;`,yc=h.default.div`display:flex;flex-direction:column;gap:8px;`,_c=({followUpItem:e,submitted:t,value:n="",onChange:r,hasError:s})=>{const{stringSet:a}=U();return o.createElement(Sc,null,o.createElement(Y.Label,{required:e.required},e.question),e.response_type==="free_text"&&o.createElement(Y.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(Tc,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(Y.ErrorLabel,null,a.FORM_VALIDATION_REQUIRED))},Sc=h.default.div`display:flex;flex-direction:column;gap:8px;`,Tc=h.default.div`display:flex;flex-direction:column;gap:8px;`,Ac=({value:e,selected:t,label:n})=>o.createElement(wc,{$selected:t,"aria-label":n},kc[e-1]),wc=h.default.div`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,kc=[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)"}))))],Ic=({csatPayload:e,submitted:t,value:n,onChange:r})=>{const s=typeof n>"u";return o.createElement(Mc,null,o.createElement(w,{variant:"caption3",color:g.themedColor.textMidEmphasis},e.csat_question),o.createElement(Lc,null,e.csat_scores.map(({label:a,image_url:i},l)=>{const c=l+1,u=n===c;return o.createElement(Oc,{key:l,disabled:t,onClick:()=>r(c)},o.createElement($c,{value:c,selected:s||u,label:a,src:i}),!!a&&o.createElement(w,{color:u?g.themedColor.textHighEmphasis:g.themedColor.textLowEmphasis,variant:"caption3"},a))})))},$c=({value:e,src:t,label:n,selected:r})=>{const[s,a]=d.useState(!1),i=s?o.createElement(Ac,{value:e,selected:r,label:n}):o.createElement(Dc,{$selected:r,"aria-label":n,src:t,onError:()=>a(!0)});return o.createElement(Rc,null,i)},Mc=h.default.div`display:flex;flex-direction:column;gap:8px;`,Lc=h.default.div`display:flex;justify-content:space-between;align-self:center;width:100%;max-width:400px;gap:16px;`,Oc=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:${g.themedColor.textHighEmphasis};}`,Rc=h.default.div`button:hover:not(:disabled) &{border-radius:4px;cursor:pointer;background-color:${g.color.background200};${R.dark`
|
|
220
|
+
background-color: ${g.color.background500};
|
|
221
|
+
`}
|
|
222
|
+
}
|
|
223
|
+
`,Dc=h.default.img`user-select:none;-webkit-user-drag:none;width:40px;height:40px;aspect-ratio:1;opacity:${({$selected:e})=>e?1:.38};`,Nc=({csatPayload:e})=>o.createElement(w,{variant:"button",color:g.themedColor.textHighEmphasis},e.title),kt=({csatPayload:e,type:t,renderSubmitButton:n,initialCsat:r,initialCsatReason:s,initialIsResolved:a})=>{const{params:i,setParams:l,error:c,setError:u,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(Pc,null,o.createElement(Nc,{...y}),t===se.AI_AGENT_CSAT_5_WITH_CRE&&o.createElement(vc,{...y,defaultValue:a,value:i.isResolved,onChange:C=>l({isResolved:C})}),o.createElement(Ic,{...y,value:i.csat,onChange:C=>l({csat:C})}),f&&o.createElement(_c,{...y,followUpItem:f,value:i.csatReason,onChange:C=>{l({csatReason:C}),u({followUpItem:!1})},hasError:c.followUpItem})),b!=="unsubmittable"&&o.createElement(o.Fragment,null,o.createElement(Y.Separator,null),n({state:b,params:i,validateParams:E})))},Pc=h.default.div`display:flex;flex-direction:column;gap:12px;`,Bc=e=>{const{stringSet:t}=U();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})},Fc=()=>{const{stringSet:e}=U();return o.createElement(w,{variant:"body2",color:g.themedColor.textMidEmphasis,style:{textAlign:"center"}},e.CSAT_SUBMISSION_EXPIRED)},Uc=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=Pe.useForceUpdate(),c=Bc(t==null?void 0:t.csat);if(!c||!c.visibility||!se[c.type])return null;const u=c.type===se.AI_AGENT_CSAT_5||c.type===se.AI_AGENT_CSAT_5_WITH_CRE||c.type===se.HELPDESK_CSAT_5?kt:()=>null;return o.createElement(Hc,null,!r&&fn(a)?o.createElement(Fc,null):o.createElement(u,{csatPayload:c,type:c.type,initialCsat:r,initialCsatReason:s,initialIsResolved:i,renderSubmitButton:({state:f,params:b,validateParams:E})=>o.createElement(zc,{$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(w,{variant:"button"},f==="submitted"?c.csat_submitted_label:c.csat_submit_label))}))},Hc=h.default.div`display:flex;flex-direction:column;background-color:${({theme:e})=>e.colors.csat.background};border-radius:16px;gap:16px;padding:16px;`,zc=h.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:${g.color.primary.dark};}&:disabled{color:${({$state:e})=>e==="submitted"?g.themedColor.textHighEmphasis:g.color.ondark.textLowEmphasis};background-color:${g.themedColor.textDisabled};cursor:not-allowed;}`,xt=ge({template:Vc,components:{AdminMessage:hc,CSATMessage:Uc}});function Vc(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(Gc,{$marginBottom:qt(e.groupType)},n)}const Gc=h.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:c,bottomContent:u,renderCustomGroundednessIcon:f=E=>E.default,style:b={}})=>{const{iconColor:E="#000000",textColor:y="#000000",highlightColor:C=Ge.DEFAULT_PRIMARY}=b;return o.createElement(Un,null,e&&o.createElement(Un,null,o.createElement(dt,null,o.createElement(nt,null,o.createElement(N,{size:16,type:"actionbook",color:E})),o.createElement(tt,{$clickable:!!s,$highlightColor:C,variant:"body2",color:y,onClick:()=>s==null?void 0:s(e),maxTextLines:1},e.name))),t==null?void 0:t.map(x=>o.createElement(It,{key:x.key},o.createElement(nt,null,o.createElement(N,{size:16,type:"function",color:E})),o.createElement(dt,null,o.createElement(tt,{$clickable:!!a,$highlightColor:C,variant:"body2",color:y,onClick:()=>a==null?void 0:a(x),maxTextLines:1},x.name),i&&o.createElement(qc,{role:"button",onClick:()=>i==null?void 0:i(x)},o.createElement(w,{variant:"body2",color:C},"View details"),o.createElement(N,{type:"chevron-right",size:16,color:C}))))),n==null?void 0:n.map(x=>o.createElement(It,{key:x.id},o.createElement(nt,null,f({default:o.createElement(N,{size:16,type:Fn[x.source_type]??Fn.snippet,color:E}),sourceType:x.source_type})),o.createElement(tt,{$clickable:!!l,$highlightColor:C,variant:"body2",color:y,onClick:()=>l==null?void 0:l(x),maxTextLines:1},x.preview_title))),r==null?void 0:r.map(x=>o.createElement(It,{key:x.key},o.createElement(nt,null,o.createElement(N,{size:16,type:"template",color:E})),o.createElement(tt,{$clickable:!!c,$highlightColor:C,variant:"body2",color:y,onClick:()=>c==null?void 0:c(x),maxTextLines:1},x.name))),u)},Wc=h.default(w)`font-weight:400;`,tt=h.default(Wc)`${({$clickable:e,$highlightColor:t})=>e&&T.css`
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
text-decoration: underline;
|
|
226
|
+
&:hover {
|
|
227
|
+
color: ${t};
|
|
228
|
+
}
|
|
229
|
+
`}
|
|
230
|
+
`,nt=h.default.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`,dt=h.default.div`display:flex;gap:8px;align-items:center;word-break:break-word;`,qc=h.default(dt)`cursor:pointer;gap:4px;`,It=h.default(dt)`flex-direction:row;align-items:center;`,Un=h.default.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`,kr=d.createContext(null);function jc({testerType:e,origin:t,children:n}){return o.createElement(kr.Provider,{value:{testerType:e,isActionbookTester:e==="actionbook",origin:t}},e&&o.createElement(Kc,null),n)}const Be=()=>{const e=d.useContext(kr);if(!e)throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");return e},Kc=()=>{const{isActionbookTester:e}=Be();return o.createElement(ke.Template,{template:e?Yc:void 0},o.createElement(ke.MessageLogs,{component:Zc}))},Yc=e=>o.createElement(Sr,{...e,testerMode:!0,maxBodyWidth:P.WIDE_BODY_MAX_WIDTH}),Zc=({extendedMessagePayload:e={}})=>{const{handlers:t}=G(),{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(Xc,null,o.createElement(Jc,{width:4}),o.createElement(wr,{actionbook:n,functionCalls:s,groundedness:r,agentMessageTemplates:a,onClickFunctionCallDetail:t==null?void 0:t.onFunctionCallDetailClick,style:{iconColor:g.themedColor.textHighEmphasis,textColor:g.themedColor.textHighEmphasis,barColor:g.themedColor.textDisabled},bottomContent:o.createElement(Qc,{variant:"caption2",color:g.themedColor.textLowEmphasis},"Only visible in the tester")}))},Xc=h.default.div`display:flex;gap:16px;margin:16px ${P.HORIZONTAL_PADDING}px 0;align-self:stretch;`,Jc=h.default.div`width:${({width:e})=>e}px;background-color:${g.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`,Qc=h.default(w)`margin-top:5px;`,Ir=({start:e,title:t,titleAlign:n="start",end:r})=>{const s=d.useRef(null),a=d.useRef(null),[i,l]=d.useState(0),[c,u]=d.useState(0);return d.useLayoutEffect(()=>{s.current&&l(s.current.offsetWidth),a.current&&u(a.current.offsetWidth)},[e,r]),o.createElement(ed,null,o.createElement(td,null,n==="center"&&t&&o.createElement(nd,{$sideWidth:Math.max(i,c)},o.createElement(rd,null,t)),o.createElement(od,null,o.createElement(sd,{ref:s},e),(n==="start"||n==="end")&&t&&o.createElement(id,{$align:n,$hasStart:!!e,$hasEnd:!!r},t),o.createElement(ad,{ref:a},r))))},ed=h.default.div`position:relative;width:100%;background-color:${({theme:e})=>e.colors.base.headerBackground};border-bottom:1px solid ${g.themedColor.textDisabled};`,td=h.default.div`position:relative;height:56px;padding:11px 12px;`,nd=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;`,rd=h.default.div`max-width:100%;overflow:hidden;`,od=h.default.div`display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:100%;z-index:1;`,sd=h.default.div`flex-shrink:0;`,ad=h.default.div`flex-shrink:0;`,id=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;`,Fe=({type:e,size:t=16,color:n,disabled:r,onClick:s,"aria-label":a})=>{const i=r?g.themedColor.textDisabled:g.themedColor.textHighEmphasis;return o.createElement(ld,{onClick:s,disabled:r,"aria-label":a},o.createElement(N,{type:e,size:t,color:n??i}))},ld=h.default.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`,rn=/iPad|iPhone|iPod/.test(navigator.userAgent),cd=/Android/.test(navigator.userAgent),Ke=e=>rn||cd,Ye=()=>Ke()?24:16,dd=()=>{const{state:e}=G(),t=Ye(),n=()=>{e.setOpened(!1)};return o.createElement(Fe,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},{Provider:ud,useContext:Q}=J("MessengerSession"),md=d.forwardRef(function({children:e,...t},n){return o.createElement(fs,{ref:n,...t},r=>o.createElement(gd,{...r},e))}),gd=({children:e,...t})=>{const{chatSDK:n,logger:r,appId:s,aiAgentId:a,agentPreviewConfigs:i,state:l,handlers:c}=G(),{userSessionInfo:u,authenticate:f,setActiveChannel:b,userSession:E,aiAgentInfo:y,launcherInfo:C}=t,x=d.useRef(null);return Pe.useGroupChannelHandler(n,{async onUserJoined(m,p){var _,I,A;if(m.conversation&&m.conversation.type===q.ConversationType.PROACTIVE&&p.userId===((_=n.currentUser)==null?void 0:_.userId)){r.info("messengerSession.onUserJoined: proactive channel joined",m.url);const M=((I=m.conversation)==null?void 0:I.status)??q.ConversationStatus.OPEN;b({url:m.url,status:M}),l.setOpened(!0),hd({sound:document.hidden||!l.opened}),(A=x.current)==null||A.call(x,{channel:m})}}}),d.useEffect(()=>{f().then(({launcher:m})=>{m.auto_open&&!Ke()&&setTimeout(()=>l.setOpened(!0),500)}).catch(m=>{var p;r.error("messengerSession: failed to initialize",m),(p=c==null?void 0:c.onInitializeFailed)==null||p.call(c,m)})},[n,s,a,u==null?void 0:u.userId]),!E||!y||!C?null:o.createElement(ud,{value:{...t,userSession:E,aiAgentInfo:{...y,...i==null?void 0:i.bot},launcherInfo:{...C,...i==null?void 0:i.launcher},registerOnJoinedProactiveConversation:m=>x.current=m}},e)};function hd({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 fd=e=>{const{chatSDK:t,handlers:n,logger:r}=G(),{aiAgentInfo:s}=Q(),a=d.useRef(new Set),i=f=>{if(!(n!=null&&n.onCustomEvent))return;ue(f)&&f.sender.userId===s.userId&&!Ce.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=Lt(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))}},c=(f,b)=>{f.url===e&&(i(b),l(b))},u=f=>{l(f)};return Pe.useGroupChannelHandler(t,{onMessageUpdated:c,onMessageReceived:c}),{checkForUserActionRequired:u}};function pd(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 bd(e){if("file"in e&&e.file instanceof File&&e.file.type.startsWith("image/")){const{width:t,height:n}=await pd(e.file);return new ve.MessageMetaArray({key:Zn,value:[t,n]})}}const Ed=({onScrollAfterSendMessage:e})=>{const{agentPreviewConfigs:t,handlers:n}=G(),r=d.useRef(t==null?void 0:t.agentAttributes);return r.current=t==null?void 0:t.agentAttributes,{onBeforeSendMessage:async s=>{const a=await bd(s),i={...s,metaArrays:a?[a]:void 0},l=xd(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===ve.SendingStatus.SUCCEEDED?(i=n==null?void 0:n.onCustomEvent)==null||i.call(n,{type:"message-sent-succeeded",data:{message:s}}):s.sendingStatus===ve.SendingStatus.PENDING&&((l=n==null?void 0:n.onCustomEvent)==null||l.call(n,{type:"message-sent-pending",data:{message:s}}))}}},xd=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},ze=50,$t=ze-40,{Provider:vd,useContext:Cd}=J("ConversationScroll"),Hn={viewport:0,contentHeight:0,contentSnapshotHeight:0,shouldRecalc:!1,shouldUpdate:!1};function yd({scrollMode:e,children:t}){const n=d.useRef(null),r=d.useRef(null),s=d.useRef(Hn),a=d.useRef(!1),i=d.useRef(null),l=d.useRef(0),[c,u]=d.useState(0),[f,b]=d.useState(0),[E,y]=d.useState(!1),[C,x]=d.useState(!1),m=d.useMemo(()=>E?"auto":e,[E,e]),p=()=>{s.current.contentSnapshotHeight=s.current.contentHeight,s.current.shouldUpdate=!0,s.current.shouldRecalc=!0},v=()=>{const S=n.current;!S||!s.current.shouldUpdate||u(k=>{s.current.shouldUpdate=!1;const{contentHeight:D,contentSnapshotHeight:B,shouldRecalc:W}=s.current,le=S.clientHeight;if(B>D)return k;const Me=_(S,{messageType:"outgoing"});let oe=0;if(Me){const be=Me.message.offsetTop-$t+le;oe=Math.max(0,be-D)}else{const be=D-B,He=le-$t;oe=Math.max(0,be-He)}return k===0||oe!==k||W?(s.current.shouldRecalc=!1,oe):k})},_=d.useCallback((S,k)=>{const{messageType:D="all"}=k??{},B=Array.from(S.querySelectorAll(`#${ne}-message-item`));let W=B;D==="outgoing"&&(W=B.filter(_t=>_t.getAttribute("data-layout-id")==="outgoingmessage"));const le=W[W.length-1];if(!le)return null;const Me=S.getBoundingClientRect(),oe=le.getBoundingClientRect(),be=S.scrollTop+(oe.top-Me.top),He=be+le.offsetHeight;return{message:le,scrollTop:be,lastMessageBottom:He}},[]),I=d.useCallback(()=>{const S=n.current;if(!S||m!=="fixed")return;const k=_(S);s.current.contentHeight=(k==null?void 0:k.lastMessageBottom)??S.scrollHeight,!a.current&&s.current.contentSnapshotHeight>0&&p();const D=Math.max(0,S.scrollHeight-S.scrollTop-S.clientHeight);b(D),v()},[m,_]),A=d.useCallback(()=>{r.current&&(r.current.disconnect(),r.current=null),s.current=Hn,u(0),b(0)},[]),M=d.useCallback((S=!0)=>{gi(()=>{const k=n.current;k&&k.scrollTo({top:k.scrollHeight,behavior:S?"smooth":"auto"})})},[]),$=d.useCallback(S=>{S&&(n.current=S,m==="fixed"&&(A(),s.current.viewport=S.clientHeight,r.current=new MutationObserver(()=>{I()}),r.current.observe(S,{childList:!0,subtree:!0})))},[m,I,A]),L=d.useCallback(()=>{const S=n.current;if(!S)return;const k=_(S,{messageType:"outgoing"});k&&(S.scrollTo({top:k.message.offsetTop-$t,behavior:"smooth"}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{x(!1)},500))},[_]),O=S=>{const{scrollHeight:k,scrollTop:D,clientHeight:B}=S.currentTarget,W=Math.max(0,k-D-B);l.current=W,b(W)},z=d.useCallback(()=>{m==="fixed"&&(x(!0),p())},[m]),V=d.useCallback(()=>{m==="fixed"?setTimeout(()=>L(),300):M()},[m,L]),fe=d.useCallback(S=>{a.current=S,m==="fixed"?p():l.current<=ze&&M()},[m,M]),pe=d.useCallback(S=>{y(S)},[]),Te=d.useCallback(S=>{m==="auto"&&S&&l.current<=ze&&M()},[m,M]),te=!(f<=ze)&&!C,ie=d.useCallback(()=>l.current>ze,[]);return o.createElement(vd,{value:{ref:$,state:{bottomSpace:c,isAwayFromBottom:te,shouldCountNewMessages:ie},props:{onScroll:O},actions:{scrollToBottom:M,onBeforeMessageSend:z,onAfterMessageSend:V,onStreamingUpdate:fe,onConversationClosed:pe,onTypingIndicatorUpdate:Te}}},t)}const{Provider:_d,Context:Sd,useContext:ee}=J("Conversation"),Td=({children:e})=>{var s;const{channelSource:t}=ee(),n=(s=t.channel)==null?void 0:s.url,{checkForUserActionRequired:r}=fd(n);return d.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)},Ad=({channelUrl:e,onClearChannelUrl:t,onNavigateToConversationList:n,shouldMarkAsRead:r,children:s})=>{const{activeChannel:a,refreshActiveChannel:i}=Q(),l=Cd(),{onBeforeSendMessage:c,onAfterSendMessage:u}=Ed({onScrollAfterSendMessage:()=>{l.actions.onAfterMessageSend()}}),f=e||(a==null?void 0:a.url),b=d.useCallback(C=>(l.actions.onBeforeMessageSend(),c(C)),[l.actions,c]),E=d.useCallback(C=>{const x=C.some(m=>Ce.isStreaming(m));l.actions.onStreamingUpdate(x)},[l.actions.onStreamingUpdate]),y=d.useCallback(async()=>{await i(),e&&(t==null||t())},[i,e,t]);return o.createElement(Ts,{key:f,channelUrl:f,onBeforeSendMessage:b,onAfterSendMessage:u,onMessagesUpdated:E,onMessagesReceived:E,onChannelDeleted:y,onConversationClosedStatusChanged:l.actions.onConversationClosed,shouldMarkAsRead:r,shouldCountNewMessages:l.state.shouldCountNewMessages},C=>o.createElement(_d,{value:{...C,scrollSource:l,goToActiveConversation:y,onNavigateToConversationList:n}},o.createElement(Td,null,s)))},$r=({children:e,...t})=>{var s;const{config:n}=K(),r=((s=n==null?void 0:n.conversation)==null?void 0:s.scrollMode)??"auto";return o.createElement(yd,{scrollMode:r},o.createElement(Ad,{...t},e))},wd=()=>{const{enableCloseConversationButton:e,dispatcher:t}=G(),{channelSource:n}=ee(),r=n.channel,s=Ye(),a=(r==null?void 0:r.isAIAgent)&&e,i=!Gt(r);if(!a)return null;const l=async()=>{r&&await t.send(nr.CloseConversation({channelUrl:r.url}))};return o.createElement(Fe,{"aria-label":"close conversation",type:"mute",size:s,disabled:i,onClick:l})},kd=()=>{const{state:e,enableExpandButton:t}=G(),n=Ye();return t?o.createElement(Fe,{"aria-label":"expand",type:e.expanded?"collapse":"expand",size:n,onClick:()=>e.setExpanded(!e.expanded)}):null},Id=({label:e,children:t,position:n="top",disabled:r})=>r?t:o.createElement(Ut,null,t,o.createElement(Ld,{$position:n},o.createElement(Od,{variant:"caption1"},e),o.createElement($d,{$position:n}))),$d=({$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:g.themedColor.textHighEmphasis})),Md={top:T.css`flex-direction:column;top:0;transform:translate(-50%,-100%);`,bottom:T.css`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`},Ut=h.default.div`position:relative;`,Ld=h.default.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${Ie.TOOLTIP};${({$position:e})=>Md[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Ut}:hover &,${Ut}:focus-within &{opacity:1;}`,Od=h.default(w)`padding:6px 8px;background:${g.themedColor.textHighEmphasis};color:${g.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`,Rd=()=>{const{logger:e}=G(),{stringSet:t}=U(),{channelSource:n}=ee(),r=n.channel,s=Ye(),a=Zt("handoff-button",r),i=!Gt(r)||De(r),l=async()=>{try{const c=await(r==null?void 0:r.markConversationAsHandoff());e.info("conversation.handleAgentHandoff: success",c)}catch(c){e.error("conversation.handleAgentHandoff: error",c)}};return a?o.createElement(Id,{label:t.HEADER_BUTTON__AGENT_HANDOFF,position:"bottom",disabled:i},o.createElement(Fe,{"aria-label":"request handoff",type:"agent",size:s,disabled:i,onClick:l})):null},Dd=()=>{const{onNavigateToConversationList:e}=ee();return e?o.createElement(Fe,{type:"menu",size:24,onClick:()=>e()}):null},Mr=({channel:e,size:t=40})=>{const{userSession:n,aiAgentInfo:r}=Q(),{fallbackIcon:s,url:a}=ur({channel:e,aiAgentInfo:r,userSession:n}),i=T.useTheme();return a?o.createElement(Jt,{src:a,size:t}):o.createElement(Nd,{$size:t,$bgColor:i.colors.base.primary},o.createElement(N,{type:s,size:t*.55,color:i.colors.base.primaryContrastContent}))},Nd=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;`,Pd=()=>{var l,c;const{channelSource:e}=ee(),{aiAgentInfo:t,userSession:n}=Q(),{config:r}=K(),s=e.channel,a=ur({channel:s,userSession:n,aiAgentInfo:t}),i=(c=(l=r==null?void 0:r.conversation)==null?void 0:l.header)==null?void 0:c.avatarEnabled;return o.createElement(Bd,null,i&&o.createElement(Mr,{channel:s,size:34}),o.createElement(Fd,{variant:"h2",color:g.themedColor.textHighEmphasis},a.title))},Bd=h.default.div`display:flex;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`,Fd=h.default(w)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`,Ud=e=>{const{components:t}=$e.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)})},Hd=()=>{const{components:e}=$e.useContext();return o.createElement(e.MenuButton,null)},zd=()=>{const{components:e}=$e.useContext();return o.createElement(e.Title,null)},Vd=()=>{const{components:e}=$e.useContext();return o.createElement(Wd,null,o.createElement(e.HandoffButton,null),o.createElement(e.ConversationCloseButton,null),o.createElement(e.ExpandButton,null),o.createElement(e.CloseButton,null))},$e=ge({template:Ud,components:{StartArea:Hd,TitleArea:zd,EndArea:Vd,MenuButton:Dd,Title:Pd,HandoffButton:Rd,ConversationCloseButton:wd,ExpandButton:kd,CloseButton:dd}}),Gd=()=>{const{isActionbookTester:e}=Be(),{Template:t}=$e.useContext();return e?null:o.createElement(t,{titleAlign:"start"})},Wd=h.default.div`display:flex;gap:10px;align-items:center;justify-content:center;`,on=d.createContext({onDrop:me,subscribe:()=>me}),Ht=({children:e})=>{const t=d.useRef(new Set);return o.createElement(on.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)},qd=({onDropFiles:e})=>{const{subscribe:t}=d.useContext(on);d.useEffect(()=>t(e),[e])};Ht.Consumer=({children:e})=>{const{onDrop:t}=d.useContext(on);return e({onDrop:t,onDragOver:s=>s.preventDefault()})};const sn=({iconSize:e=64,icon:t,className:n,label:r,children:s})=>o.createElement(Kd,{className:n},t&&o.createElement(N,{type:t,size:e,color:g.themedColor.textLowEmphasis}),r&&o.createElement(w,{variant:"body1",color:g.themedColor.textMidEmphasis},r),s),jd=h.default.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`,Kd=h.default.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`,Yd=({label:e="Something went wrong",icon:t="error",action:n,...r})=>o.createElement(sn,{icon:t,label:e,...r},n&&o.createElement(Zd,{onClick:n.onClick,label:n.label??"Retry"})),Zd=({label:e,onClick:t})=>o.createElement(Xd,{tabIndex:0,onClick:t},o.createElement(N,{type:"refresh",size:20}),o.createElement(w,{variant:"button",color:g.color.primary.main},e)),Xd=h.default.button`all:unset;display:flex;cursor:pointer;gap:4px;align-items:center;justify-content:center;`,Jd=({iconSize:e=48,className:t})=>o.createElement(nn,{size:e,className:t}),Qd=({label:e="No channels",icon:t="chat",...n})=>o.createElement(sn,{icon:t,label:e,...n}),eu=({label:e="No messages",icon:t="message",...n})=>o.createElement(sn,{icon:t,label:e,...n}),tu=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(jd,null,n)},vt=ge({template:tu,components:{Loading:Jd,Error:Yd,NoChannels:Qd,NoMessages:eu}}),Ne=e=>{const{Template:t}=vt.useContext();return o.createElement(t,{...e})},zn=e=>Xn(e)||Jn(e);function nu(e){return e.isAdminMessage()?e.message==="The channel's custom_type was updated.":!1}function ru(e,t){return e.filter(n=>Ce.isWelcomeMessage(n,t))}const ou=h.default.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`,su=h.default.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${g.themedColor.textDisabled};background-color:${g.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`,au=h.default.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`,iu=h.default.div`margin-inline-end:8px;`,lu=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);}`,cu=h.default.div`display:flex;width:160px;justify-content:flex-end;`,du=h.default.div`inset-inline-end:0;display:flex;flex-direction:row;`,Lr=h.default.div`width:64px;padding:21px;box-sizing:border-box;cursor:${e=>e.disabled?"not-allowed":"pointer"};`,uu=h.default(Lr)`border-inline-start:1px solid ${g.themedColor.textDisabled};`,mu=h.default.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`,gu=h.default.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`,hu=h.default.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`,fu=h.default.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`,pu=({file:e,sender:t={},onClose:n})=>{const{type:r,url:s,name:a=""}=e,{profileUrl:i,userId:l}=t,{aiAgentInfo:c}=Q();return o.createElement(Eu,{profileUrl:i??"",type:r,url:s,name:a,onClose:n,isBotMessage:l===c.userId})},bu=({profileUrl:e,isBotMessage:t})=>t&&!e?o.createElement(xu,{$size:32},o.createElement(N,{type:"delight",size:20})):o.createElement(Jt,{size:32,src:e}),Eu=({profileUrl:e,isBotMessage:t,name:n,type:r,url:s,onClose:a})=>{const{stringSet:i}=U();return o.createElement(bt,{onClose:a,visible:!0,rootElementId:re.MODAL_ROOT},o.createElement(ou,null,o.createElement(su,null,o.createElement(au,null,o.createElement(iu,null,o.createElement(bu,{profileUrl:e,isBotMessage:t})),o.createElement(lu,null,o.createElement(w,{variant:"h2",color:g.themedColor.textHighEmphasis},n))),o.createElement(cu,null,zn(r)&&o.createElement(du,null,o.createElement(Lr,{as:"a",href:s,download:n,target:"_blank",rel:pt},o.createElement(N,{type:"download",color:g.themedColor.textHighEmphasis,size:24}))),o.createElement(uu,{onClick:a},o.createElement(N,{type:"close",color:g.themedColor.textHighEmphasis,size:24})))),o.createElement(mu,{onClick:l=>l.currentTarget===l.target&&a()},Jn(r)&&o.createElement(gu,{controls:!0},o.createElement("source",{src:s,type:r})),Xn(r)&&o.createElement(hu,{src:s,alt:n}),!zn(r)&&o.createElement(fu,null,o.createElement(w,{variant:"h1",color:g.themedColor.textHighEmphasis},i.FILE_VIEWER__UNSUPPORT)))))},xu=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;}`,Or=({className:e,locale:t,date:n=Date.now(),formatString:r="MMMM dd, yyyy",style:s})=>o.createElement(vu,{id:`${ne}-date-separator`,style:s,className:e},o.createElement(w,{variant:"caption4",color:g.themedColor.textMidEmphasis},xe.format(n,r,{locale:t}))),vu=h.default.div`display:flex;justify-content:center;align-items:center;text-align:center;word-break:break-word;`,Cu=d.forwardRef(function(t,n){const{messages:r,renderMessage:s,messageTopArea:a,messageBottomArea:i,overlayArea:l,onLoadPrev:c,onLoadNext:u,loadThreshold:f=.05,onScroll:b=me,depsForResetScrollPositionToBottom:E,stackDirection:y="top",bottomSpacerHeight:C=0,ariaLabel:x}=t,m=d.useRef(null),p=d.useCallback($=>{m.current=$,n&&(typeof n=="function"?n($):n.current=$)},[n]),v=d.useRef(!1),_=d.useRef(void 0),I=d.useRef(0),A=d.useRef(0);d.useLayoutEffect(()=>{m.current&&(m.current.scrollTop=m.current.scrollHeight)},E),d.useLayoutEffect(()=>{m.current&&(_.current==="top"&&(m.current.scrollTop=m.current.scrollHeight-A.current),_.current==="bottom"&&(m.current.scrollTop=I.current),_.current=void 0)},[m.current,r.length]);const M=async $=>{if(b==null||b($),!m.current)return;const L=m.current;if(A.current=L.scrollHeight-L.scrollTop,I.current=L.scrollTop,v.current)return;const O=L.clientHeight*Math.min(Math.max(0,f),1);L.scrollTop<=O?(v.current=!0,_.current="top",await c(),v.current=!1):L.scrollHeight-L.scrollTop-L.clientHeight<=O?(v.current=!0,_.current="bottom",await u(),v.current=!1):_.current=void 0};return o.createElement(yu,{id:"infinite-list-container"},o.createElement(_u,{id:"infinite-list-inner",ref:p,onScroll:M,role:"list","aria-label":x},y==="bottom"&&o.createElement("div",{style:{flexGrow:1}}),a,r.map(($,L)=>s({message:$,index:L})),i,C>0&&o.createElement("div",{style:{minHeight:C}})),o.createElement(Su,{id:"infinite-list-overlay-container"},o.createElement(Tu,{id:"infinite-list-overlay"},l)))}),yu=h.default.div`display:flex;position:relative;flex:1;overflow:hidden;`,_u=h.default.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;scrollbar-color:${g.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`,Su=h.default.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`,Tu=h.default.div`pointer-events:auto;`,Au=({className:e,label:t,ariaLabel:n,onClick:r})=>{const{colors:s}=T.useTheme();return o.createElement(wu,{className:e,onClick:r,"aria-label":n},o.createElement(w,{variant:"button",color:s.base.primaryContrastContent},t),o.createElement(N,{size:16,type:"chevron-down",color:s.base.primaryContrastContent}))},wu=h.default.button`all:unset;cursor:pointer;display:flex;align-items:center;gap:4px;padding:10px 12px 10px 16px;border-radius:24px;background-color:${({theme:e})=>e.colors.base.primary};box-shadow:0 8px 10px 1px rgba(13,13,13,0.12),0 3px 14px 2px rgba(13,13,13,0.08),0 3px 5px -3px rgba(13,13,13,0.04);&:focus{outline:none;}`,ku=({className:e,onClick:t,ariaLabel:n})=>o.createElement(Iu,{className:e,onClick:t,tabIndex:0,"aria-label":n},o.createElement(N,{size:24,type:"chevron-down",color:g.color.primary.main})),Iu=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`
|
|
231
|
+
background-color: ${g.color.background50};
|
|
232
|
+
&:hover {
|
|
233
|
+
background-color: ${g.color.background100};
|
|
234
|
+
}
|
|
235
|
+
&:active {
|
|
236
|
+
background-color: ${g.color.background200};
|
|
237
|
+
}
|
|
238
|
+
`}
|
|
239
|
+
${R.dark`
|
|
240
|
+
background-color: ${g.color.background400};
|
|
241
|
+
&:hover {
|
|
242
|
+
background-color: ${g.color.background500};
|
|
243
|
+
}
|
|
244
|
+
&:active {
|
|
245
|
+
background-color: ${g.color.background700};
|
|
246
|
+
}
|
|
247
|
+
`}
|
|
248
|
+
|
|
249
|
+
&:focus {
|
|
250
|
+
outline: none;
|
|
251
|
+
}
|
|
252
|
+
`,$u=()=>{const{agentPreviewConfigs:e={},aiAgentId:t}=G(),{aiAgentInfo:n}=Q(),{stringSet:r,dateLocale:s}=U(),{messageSource:a}=ee(),{Template:i}=ke.useContext(),l=e.welcomeMessages??[],c=a.messages,u=ru(c,t),f=c[u.length+1],b=u[0]??f;return{filteredMessages:c.filter(E=>nu(E)?!1:l.length>0?!Ce.isWelcomeMessage(E,t):!0),shouldShowOriginalDate:E=>E>0||l.length===0?!0:f&&!xe.isSameDay(f.createdAt,(b==null?void 0:b.createdAt)??0),renderAgentPreviewWelcomeMessages:()=>l.length===0?null:o.createElement(o.Fragment,null,o.createElement(Or,{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 C=y===l.length-1,x=u.length!==c.length,m=l.length===1?"single":y===0?"top":C||x?"bottom":"middle";return o.createElement(i,{messageType:"user",message:E.message,sender:n,groupType:m,createdAt:(b==null?void 0:b.createdAt)??Date.now(),extendedMessagePayload:{suggested_replies:E.suggestedReplies},suggestedRepliesDirection:e.suggestedRepliesDirection,suggestedRepliesVisible:C&&!x,isBotMessage:!0,onClickSuggestedReply:async({reply:p})=>{a.sendUserMessage({message:p})}})}))}},Mu=e=>h.default(e).withConfig({shouldForwardProp:po.default}),Lu=({style:e})=>{const{stringSet:t}=U(),{isActionbookTester:n}=Be();return!Zt("powered-by")||n?null:o.createElement(Ou,{variant:"caption2",style:e},t.POWERED_BY+" ",o.createElement(Ru,{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"))},Ou=h.default(w)`color:${g.themedColor.textLowEmphasis};text-align:center;`,Ru=Mu(w)`
|
|
253
|
+
color: ${g.themedColor.textLowEmphasis};
|
|
254
|
+
cursor: pointer;
|
|
255
|
+
text-decoration: none;
|
|
256
|
+
`,Du=()=>{var i;const{stringSet:e}=U(),{channelSource:t,goToActiveConversation:n,scrollSource:r}=ee(),s=ye(t.channel),a=d.useRef(s);return d.useEffect(()=>{if(!a.current&&s){const u=setTimeout(()=>{r.actions.scrollToBottom()},100);return()=>clearTimeout(u)}a.current=s},[s,r.actions.scrollToBottom]),!((i=t.channel)!=null&&i.isAIAgent)||!s?null:o.createElement(Nu,null,o.createElement(Pu,{variant:"button",role:"button",color:g.themedColor.textHighEmphasis,onClick:()=>n()},e.TALK_TO_AGENT))},Nu=h.default.div`display:flex;justify-content:center;margin-bottom:16px;`,Pu=h.default(w)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${g.themedColor.textDisabled};cursor:pointer;user-select:none;`,Bu=()=>{const{Template:e}=Et.useContext(),{Template:t}=ke.useContext(),{Template:n}=xt.useContext(),[r,s]=d.useState(null),[a,i]=d.useState(null),{userSession:l,aiAgentInfo:c}=Q(),{cache:u,agentPreviewConfigs:f,chatSDK:b,state:E}=G(),{config:y}=K(),{stringSet:C,dateLocale:x}=U(),{conversation:m,channelSource:p,messageSource:v,scrollSource:_,state:{input:I,streamAnimation:A}}=ee(),{isActionbookTester:M}=Be(),{filteredMessages:$,shouldShowOriginalDate:L,renderAgentPreviewWelcomeMessages:O}=$u(),z=lr(p.channel),V=(()=>{const j=z[0];if(!j)return null;const te=j.userId===c.userId;return{user:te?c:j,isBot:te}})();d.useEffect(()=>{_.actions.onTypingIndicatorUpdate(!!V)},[!!V,_.actions.onTypingIndicatorUpdate]),d.useEffect(()=>{_.state.isAwayFromBottom||v.resetNewMessages()},[_.state.isAwayFromBottom]);const fe=(j,te=!1)=>{var ie;return te?c:((ie=p.channel)==null?void 0:ie.members.find(S=>S.userId===j.sender.userId))??j.sender},pe=j=>{if(j.sendingStatus==="failed"&&!I.disabled)return()=>i(j)},Te=()=>{var j,te,ie;if(!v.initialized)return o.createElement(Ne,{type:"loading"});if(v.messages.length===0){const S=O();return S?o.createElement("div",{style:{width:"100%"}},S):o.createElement(Ne,{type:"noMessages",label:C.PLACE_HOLDER__NO_MESSAGES})}return o.createElement(Cu,{ref:_.ref,onScroll:_.props.onScroll,stackDirection:f==null?void 0:f.messageStackDirection,messages:$,onLoadPrev:v.loadPrevious,onLoadNext:v.loadNext,depsForResetScrollPositionToBottom:[v.initialized,v.messages.length!==0],bottomSpacerHeight:_.state.bottomSpace,ariaLabel:C.A11Y_MESSAGE_LIST,messageTopArea:o.createElement(o.Fragment,null,o.createElement(Lu,{style:{marginTop:16}}),O()),messageBottomArea:o.createElement(o.Fragment,null,V&&o.createElement("div",{id:`${ne}-message-item`,role:"listitem"},o.createElement(t,{isTyping:!0,isBotMessage:V.isBot,sender:V.user,messageType:"user",groupType:"single",message:"",isSenderAvatarVisible:(j=y==null?void 0:y.conversation)==null?void 0:j.senderAvatarEnabled})),((te=y==null?void 0:y.conversation)==null?void 0:te.isTalkToAgentViewEnabled)&&o.createElement(Du,null)),overlayArea:o.createElement(o.Fragment,null,((ie=y==null?void 0:y.conversation)==null?void 0:ie.newMessageIndicatorEnabled)&&_.state.isAwayFromBottom&&v.newMessages.length>0&&o.createElement(Hu,{label:C.SCROLL_TO_NEW_MESSAGES_LABEL(v.newMessages),ariaLabel:C.A11Y_SCROLL_TO_NEW_MESSAGES,onClick:()=>_.actions.scrollToBottom()}),_.state.isAwayFromBottom&&v.newMessages.length===0&&!V&&o.createElement(Uu,{ariaLabel:C.A11Y_SCROLL_TO_BOTTOM,onClick:()=>_.actions.scrollToBottom()})),renderMessage:({message:S,index:k})=>{const D=So(S),B=$[k-1],W=$[k+1],le=$[$.length-1],Me=S===le,oe=We(S,c.userId),be=!(c.isUserFeedbackEnabled&&oe&&!Ce.isWelcomeMessage(S)),He=To(S,B,W,be),_t=!mo.isSameDay((B==null?void 0:B.createdAt)??0,S.createdAt)&&L(k)&&!M,eo=Xe=>{(S.isFileMessage()||S.isUserMessage())&&s({file:Xe,sender:fe(S,S.sender.userId===c.userId)})},to=()=>{S.isFileMessage()&&Qt(S.url)},no=_t?o.createElement(Or,{style:{margin:"16px 0"},date:S.createdAt,locale:x,formatString:C.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR}):null,Ze={data:S.data,maxBodyWidth:E.expanded?P.WIDE_BODY_MAX_WIDTH:void 0,extendedMessagePayload:S.extendedMessagePayload,createdAt:S.createdAt,groupType:He,onClickMedia:eo,onClickFile:to},ro=()=>{if(Le.isOutgoing(S,l.userId))return"outgoingmessage";if(Le.isIncoming(S,l.userId))return"incomingmessage"},oo=(()=>{var Xe,gn,hn;if(Le.isAdmin(S))return Le.isCSAT(S)?m?o.createElement(n,{...Ze,...m,isResolvedWhenDeterminedByUser:Eo(m),messageType:"admin.csat",onSubmitCSAT:async({csat:Ee,...H})=>{var Z;Ee&&await((Z=p.channel)==null?void 0:Z.submitCSAT({csat:Ee,...H}))}}):null:o.createElement(n,{...Ze,messageType:"admin",message:S.message});if(Le.isOutgoing(S,l.userId)){const Ee={...Ze,message:S.message,sender:fe(S),sendingStatus:S.sendingStatus,onClickFailedMessage:pe(S)};if(S.isUserMessage())return o.createElement(e,{messageType:"user",...Ee});if(S.isFileMessage()){const[H,Z]=((Xe=S.metaArrays.find(ce=>ce.key===Zn))==null?void 0:Xe.value)??[];return o.createElement(e,{messageType:"file",file:S,metadata:{aspectRatio:H&&Z?`${H}/${Z}`:"1/1",localFile:(gn=S.messageParams)==null?void 0:gn.file},...Ee})}}if(Le.isIncoming(S,l.userId)){const Ee={...Ze,sender:fe(S,oe),message:S.message,suggestedRepliesVisible:Me,suggestedRepliesDirection:f==null?void 0:f.suggestedRepliesDirection,isBotMessage:oe,isStreaming:Ce.isStreaming(S),isHandedOff:De(p.channel),isConversationClosed:ye(p.channel),isFeedbackEnabled:c.isUserFeedbackEnabled,isFeedbackCommentEnabled:c.isUserFeedbackCommentOptionEnabled,isSenderAvatarVisible:(hn=y==null?void 0:y.conversation)==null?void 0:hn.senderAvatarEnabled,onClickSuggestedReply:async({reply:H})=>{v.sendUserMessage({message:H})},onRequestMessageTemplate:async H=>{const{template:Z}=await b.aiAgent.getMessageTemplate(H);return u.template.set(H,Z),Z},onGetCachedMessageTemplate:H=>u.template.get(H),onHandleTemplateInternalAction:H=>{if(H.type==="internal"&&H.internalData){const{method:Z,payload:ce}=H.internalData;Z==="message.send"&&(ce!=null&&ce.message)&&v.sendUserMessage({message:ce.message})}},onFeedbackUpdate:H=>{const Z={messageId:S.messageId,channelUrl:S.channelUrl};if(!H)return b.aiAgent.deleteMessageFeedback(Z);const ce={...Z,rating:Ii(H.rating),comment:H.comment};return Ce.hasFeedback(S)?b.aiAgent.updateMessageFeedback(ce):b.aiAgent.createMessageFeedback(ce)},onSubmitForm:({key:H,data:Z})=>b.aiAgent.submitForm({messageId:S.messageId,channelUrl:S.channelUrl,formKey:H,formData:Z}),onCancelForm:({key:H})=>b.aiAgent.cancelForm({messageId:S.messageId,channelUrl:S.channelUrl,formKey:H}),onStreamAnimationStart:()=>{A.start(S.messageId)},onStreamAnimationProgress:()=>{_.actions.onStreamingUpdate(!0)},onStreamAnimationComplete:()=>{A.stop(S.messageId),_.actions.onStreamingUpdate(!1)}};if(S.isUserMessage())return o.createElement(t,{messageType:"user",...Ee});if(S.isFileMessage())return o.createElement(t,{messageType:"file",file:S,...Ee})}})();return o.createElement("div",{key:D,id:`${ne}-message-item`,role:"listitem","data-layout-id":ro()},no,oo)}})};return o.createElement(Fu,{id:`${ne}-message-list`},Te(),r&&o.createElement(pu,{onClose:()=>s(null),sender:r.sender,file:r.file}),a&&o.createElement(Re,{visible:!0,onClose:()=>i(null)},o.createElement(Re.ActionItem,{onClick:()=>{v.resendMessage(a),i(null)}},C.FAILED_MESSAGE_RESEND),o.createElement(Re.ActionItem,{destructive:!0,onClick:()=>{v.deleteMessage(a),i(null)}},C.FAILED_MESSAGE_REMOVE)))},Fu=h.default.div`overflow-y:hidden;display:flex;flex:1;position:relative;`,Uu=h.default(ku)`position:absolute;bottom:12px;inset-inline-end:16px;`,Hu=h.default(Au)`position:absolute;bottom:12px;left:50%;transform:translateX(-50%);`,zu=()=>{const{stringSet:e}=U(),{connectionError:t}=Q(),{channelSource:n}=ee(),r=t||n.error;if(r){const s=t?void 0:{label:e.RETRY,onClick:()=>n.refetch()};return o.createElement(Ne,{type:"error",label:r.message,action:s})}return n.channel?o.createElement(Bu,null):o.createElement(Ne,{type:"loading"})},Vu=()=>{var s;const{origin:e}=Be(),{appId:t,aiAgentId:n}=K(),{channelSource:r}=ee();return(s=r.channel)!=null&&s.conversation?o.createElement(Gu,null,o.createElement(zt,{style:{gap:4}},o.createElement(N,{color:g.themedColor.textLowEmphasis,size:12,type:"show"}),o.createElement(w,{as:"i",color:g.themedColor.textLowEmphasis,variant:"caption2"},"Only visible in the tester")),o.createElement(zt,{role:"button",style:{gap:4},onClick:()=>{var c,u;const a=e??window.location.origin,i=(u=(c=r.channel)==null?void 0:c.conversation)==null?void 0:u.id,l=`${a}/ai-agent/${t}/${n}/evaluate/conversations/${i}`;navigator.clipboard.writeText(l)}},o.createElement(w,{variant:"body3",color:g.themedColor.textHighEmphasis},"Copy ",o.createElement("span",{style:{color:g.themedColor.primary}},"conversation link")),o.createElement(N,{color:g.themedColor.primary,size:14,type:"copy"}))):null},zt=h.default.div`display:flex;justify-content:center;align-items:center;`,Gu=h.default(zt)`flex-direction:column;padding-block:16px;background-color:${g.themedColor.bg_100_500};gap:8px;`,Rr=d.createContext(void 0),Wu=({children:e})=>{var x;const{chatSDK:t}=G(),{createAttachmentRules:n}=Q(),{stringSet:r}=U(),{channelSource:s}=ee(),[a,i]=d.useState([]),[l,c]=d.useState({visible:!1,title:""}),u=n({channel:s.channel,uploadSizeLimit:(x=t.appInfo)==null?void 0:x.uploadSizeLimit}),f=u.isEnabled(),b=m=>{const p=u.getUploadSizeLimit(m.type);return m.size>p},E=m=>{if(!f)return;const p=m.filter(I=>u.isSupportedMimeType(I.type));if(p.length===0)return;const v=p.find(I=>b(I));if(v){const I=u.getUploadSizeLimitInMB(v.type);c({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d",I.toString())});return}if(a.length+p.length>u.maxAttachmentCount){c({visible:!0,title:r.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT});return}i(I=>[...I,...p.map(A=>({file:A,preview:{url:URL.createObjectURL(A),type:A.type,name:A.name}}))])},y=m=>{i(p=>{var _;const v=(_=p[m])==null?void 0:_.preview;return v&&URL.revokeObjectURL(v.url),p.filter((I,A)=>A!==m)})},C=()=>{i(m=>(m.forEach(p=>URL.revokeObjectURL(p.preview.url)),[]))};return o.createElement(Rr.Provider,{value:{files:a,addFiles:E,removeFile:y,clearFiles:C,isFileUploadEnabled:f,acceptableMimeTypes:u.supportedMimeTypes}},e,o.createElement(en,{...l,onClose:()=>c({visible:!1,title:""})}))},an=()=>{const e=d.useContext(Rr);if(!e)throw new Error("useFileUpload must be used within FileUploadProvider");return e};function qu({blurred:e,elementRef:t,document:n=window.document}){const r=d.useRef(!1);e&&t.current&&n.activeElement===t.current&&(r.current=!0),d.useLayoutEffect(()=>{var s;!e&&r.current&&((s=t.current)==null||s.focus(),r.current=!1)},[e])}const ju=(e,t)=>{d.useEffect(()=>{t?e==null||e.startTyping():e==null||e.endTyping()},[e,t])},Ku=h.default.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`,Yu=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;}`,Zu=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`
|
|
257
|
+
background-color: ${g.color.background50};
|
|
258
|
+
`}
|
|
259
|
+
${R.dark`
|
|
260
|
+
background-color: ${g.color.background500};
|
|
261
|
+
`}
|
|
262
|
+
path {
|
|
263
|
+
fill: ${g.themedColor.textMidEmphasis};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
&:hover {
|
|
267
|
+
path {
|
|
268
|
+
fill: ${g.themedColor.textHighEmphasis};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
circle {
|
|
273
|
+
stroke: ${g.themedColor.bg_50_600};
|
|
274
|
+
}
|
|
275
|
+
`,Xu=()=>{const e=Ke(),[t,n]=d.useState(),{files:r,removeFile:s,isFileUploadEnabled:a}=an();return!a||r.length===0?null:o.createElement(Ku,null,r.map(({preview:{type:i,name:l,url:c}},u)=>o.createElement(Yu,{key:c,onMouseOver:()=>n(u),onMouseLeave:()=>n(void 0)},(e||t===u)&&o.createElement(Zu,{title:"Remove file",onClick:()=>s(u)},o.createElement(N,{type:"close-filled",color:g.themedColor.textMidEmphasis})),i.startsWith("image/")?o.createElement("img",{alt:"file-image",src:c}):o.createElement(Xt,{name:l,type:Wt(l,i)}))))},Dr={textArea:T.css`min-height:40px;height:40px;font-size:16px;line-height:24px;`,attachIcon:T.css`margin-bottom:4px;`},Nr=h.default.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`,Ju=h.default(Nr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${g.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${g.themedColor.bg_200_400};}}${rn&&Dr.attachIcon};`,Qu=h.default.input`display:none;`,Vn=h.default.div`width:100%;position:relative;background-color:${g.themedColor.bg_100_500};border-radius:20px;`,Gn=h.default.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`,Wn=h.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:${g.themedColor.textHighEmphasis};resize:none;width:100%;height:${fr}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${rn&&Dr.textArea};&::placeholder{color:${g.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${g.themedColor.textDisabled};}}`,qn=h.default.div`padding:12px 16px;position:relative;display:flex;align-items:center;`,jn=({disabled:e})=>{const{stringSet:t}=U(),n=d.useRef(null),[r,s]=d.useState(!1),{addFiles:a,clearFiles:i,files:l,isFileUploadEnabled:c,acceptableMimeTypes:u}=an();return!c||l.length>0?null:o.createElement(Ju,{disabled:e,onClick:()=>{var f;if(u.length===0)return s(!0);i(),(f=n.current)==null||f.click()}},o.createElement(N,{type:"attach",color:e?g.themedColor.textDisabled:g.themedColor.textMidEmphasis,size:16}),o.createElement(Qu,{type:"file",ref:n,onChange:f=>{const b=f.currentTarget.files;b&&a(Array.from(b)),f.target.value=""},accept:u.join(",")}),o.createElement(en,{visible:r,title:t.FILE_UPLOAD_NO_SUPPORTED_FILES,onClose:()=>s(!1)}))},em=()=>{const e=d.useRef(null),[t,n]=d.useState(""),{stringSet:r}=U(),{rootElement:s}=G(),{channelSource:a,messageSource:i,state:l}=ee(),{files:c,addFiles:u,clearFiles:f}=an(),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}})();qd({onDropFiles:u}),qu({blurred:b,elementRef:e,document:we(s)}),ju(a.channel,t);const y=t.trim().length>0,C=c.length>0,x=!b&&(y||C),m=()=>{e.current&&(e.current.value="",e.current.style.height=""),f(),n("")},p=async()=>{const A=t.trim(),M={message:A};if(!(!A&&!c.length)){if(c.length>0){const $=c[0].file,L={...M,file:$};i.sendFileMessage(L),m();return}i.sendUserMessage(M),m()}},v=A=>{const M=Array.from(A.clipboardData.files);M.length>0&&(A.preventDefault(),u(M))},_=A=>{A.key!=="Enter"||A.nativeEvent.isComposing||A.shiftKey||(A.preventDefault(),p())},I=A=>{if(e.current){e.current.style.height="";const M=Math.min(Ga,e.current.scrollHeight);fr<M&&(e.current.style.height=`${M}px`)}n(A.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(Xu,null),o.createElement(Gn,null,o.createElement(Wn,{ref:e,role:"textbox","aria-label":"Text Input",placeholder:E,maxLength:5e3,onKeyDown:_,onChange:I,onPaste:v}),o.createElement(jn,null))),x&&o.createElement(Nr,{onClick:()=>p()},o.createElement(N,{type:"send",color:g.color.primary.main,size:20})))},tm=h.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:${g.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${R.light`
|
|
276
|
+
color: ${g.color.information.light};
|
|
277
|
+
`};
|
|
278
|
+
${R.dark`
|
|
279
|
+
color: ${g.color.information.main};
|
|
280
|
+
`};
|
|
281
|
+
}
|
|
282
|
+
`,nm=d.lazy(()=>Promise.resolve().then(()=>require("./CdV-y2tE.cjs")).then(e=>({default:e.MarkdownText}))),rm=()=>{const{aiAgentInfo:e,userSession:t}=Q(),{messageSource:n,channelSource:r}=ee(),[s,a]=d.useState(null),i=Zt("special-notice",r.channel),l=d.useCallback(()=>r.channel?i?n.messages.some(c=>We(c,(t==null?void 0:t.userId)??"")):!0:null,[r.channel,i,n.messages,t==null?void 0:t.userId]);return d.useEffect(()=>{s||a(l())},[l,s]),s||!e.specialNotice?null:o.createElement(tm,null,o.createElement(nm,null,e.specialNotice))},om=()=>o.createElement(sm,null,o.createElement(rm,null),o.createElement(Wu,null,o.createElement(em,null))),sm=h.default.div`z-index:0;border:none;width:100%;`,am=()=>{var s;const{testerType:e}=Be(),{channelSource:t}=ee(),n=ye(t.channel),r=!!e&&((s=t.channel)==null?void 0:s.isAIAgent);return n&&r?o.createElement(Vu,null):o.createElement(om,null)},Pr=({children:e,onNavigateToConversationList:t,channelUrl:n,onClearChannelUrl:r,shouldMarkAsRead:s,closedChannelUrl:a,onClearClosedChannelUrl:i})=>{const{Template:l}=Ct.useContext();return o.createElement($r,{onNavigateToConversationList:t,channelUrl:n??a,onClearChannelUrl:r??i,shouldMarkAsRead:s},o.createElement(Ht,null,o.createElement(Ht.Consumer,null,c=>o.createElement(o.Fragment,null,o.createElement(lm,{...c},o.createElement(l,null)),e))))},Ct=ge({template:im,components:{Header:Gd,Body:zu,Footer:am}});function im(){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 lm=h.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,{Provider:cm,Context:dm,useContext:ln}=J("ConversationList");function Br({conversationListLimit:e,conversationListFilter:t,onOpenConversationView:n=me,children:r}){return o.createElement(Ls,{conversationListLimit:e,conversationListFilter:t},s=>o.createElement(cm,{value:{...s,onOpenConversationView:n}},r))}const um=({channel:e})=>o.createElement(Mr,{channel:e}),cn=ge({template:mm,components:{}}),Vt=99;function mm(e){const{channel:t,onClick:n}=e,{stringSet:r,format:s}=U(),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(gm,{role:"button",onClick:()=>n==null?void 0:n()},o.createElement(hm,null,o.createElement(um,{...e})),o.createElement(fm,null,o.createElement(pm,null,o.createElement(w,{variant:"subtitle1",color:g.themedColor.textHighEmphasis,maxTextLines:1},a),o.createElement(bm,null,ye(t)&&o.createElement(o.Fragment,null,o.createElement(w,{variant:"caption1",color:g.themedColor.textMidEmphasis,maxTextLines:1},r.CONVERSATION_LIST__ENDED),o.createElement(Em,null)),o.createElement(w,{variant:"caption2",color:g.themedColor.textLowEmphasis,maxTextLines:1},i))),l>0&&o.createElement(xm,{$count:l},o.createElement(w,{variant:"caption3",color:g.themedColor.textHighEmphasisInverse},l<=Vt?l:`${Vt}+`))))}const gm=h.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;`,hm=h.default.div`display:flex;align-items:center;justify-content:center;padding-inline-start:16px;`,fm=h.default.div`display:flex;flex-direction:row;align-items:center;flex:1;padding-inline-end:16px;height:100%;gap:8px;border-bottom:1px solid ${g.themedColor.textDisabled};`,pm=h.default.div`display:flex;flex-direction:column;justify-content:center;flex:1;gap:4px;word-break:break-word;overflow-wrap:break-word;`,bm=h.default.div`display:flex;align-items:center;gap:6px;`,Em=h.default.div`width:2px;height:2px;border-radius:1px;background-color:${g.themedColor.textLowEmphasis};`,xm=h.default.div`display:flex;align-items:center;justify-content:center;height:20px;padding:4px;border-radius:10px;background-color:${g.themedColor.error};${({$count:e})=>e<=Vt&&T.css`
|
|
283
|
+
width: 20px;
|
|
284
|
+
`}
|
|
285
|
+
`,vm=({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(Cm,{onScroll:s=>r(s)},e.map((s,a)=>t(s,a)))},Cm=h.default.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;overscroll-behavior:contain;`,ym=()=>{const{stringSet:e}=U(),{listSource:t,onOpenConversationView:n}=ln(),{Template:r}=cn.useContext();return t.initialized?t.channels.length===0?o.createElement(Ne,{type:"noChannels",label:e.CONVERSATION_LIST__NO_CONVERSATIONS}):o.createElement(vm,{items:t.channels,renderItem:s=>{var a,i,l;return o.createElement(r,{key:s.url,channel:s,onClick:()=>n(s.url,ye(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(Ne,{type:"loading"})},_m=()=>{const{stringSet:e}=U(),{language:t,countryCode:n,context:r}=G(),{aiAgentInfo:s,refreshActiveChannel:a,createConversation:i,setActiveChannel:l}=Q(),{onOpenConversationView:c}=ln();return o.createElement(Sm,{role:"button",onClick:async()=>{if(s.isMultipleActiveConversationsEnabled){const u=await i({aiAgentId:s.userId,language:t,country:n,context:r});l({url:u,status:q.ConversationStatus.OPEN}),c(u,q.ConversationStatus.OPEN)}else{const u=await a();c(u,q.ConversationStatus.OPEN)}}},o.createElement(Tm,{variant:"h1"},e.TALK_TO_AGENT))},Sm=h.default.div`background-color:${({theme:e})=>e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`,Tm=h.default(w)`color:${({theme:e})=>e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`,Am=()=>{const{state:e}=G(),t=Ye(),n=()=>{e.setOpened(!1)};return o.createElement(Fe,{"aria-label":"close messenger",type:"close",size:t,onClick:n})},wm=()=>{const{stringSet:e}=U();return o.createElement(km,{variant:"h2",color:g.themedColor.textHighEmphasis},e.CONVERSATION_LIST__HEADER_TITLE)},km=h.default(w)`padding:0 4px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`,Im=e=>{const{components:t}=Ue.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)})},$m=()=>null,Mm=()=>{const{components:e}=Ue.useContext();return o.createElement(e.Title,null)},Lm=()=>{const{components:e}=Ue.useContext();return o.createElement(e.CloseButton,null)},Ue=ge({template:Im,components:{StartArea:$m,TitleArea:Mm,EndArea:Lm,Title:wm,CloseButton:Am}}),Om=()=>{const{Template:e}=Ue.useContext();return o.createElement(e,{titleAlign:"start"})},Fr=({conversationListLimit:e,conversationListFilter:t,children:n,onOpenConversationView:r})=>{const{Template:s}=yt.useContext();return o.createElement(Br,{conversationListLimit:e,conversationListFilter:t,onOpenConversationView:r},o.createElement(Dm,null,o.createElement(s,null)),n)},yt=ge({template:Rm,components:{Header:Om,Body:ym,Footer:_m}});function Rm(){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 Dm=h.default.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({theme:e})=>e.colors.base.background};`,Nm=T.css`:where(#${re.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`,Pm=[Nm,ha,fa],Bm=(e,...t)=>T.createGlobalStyle(e,...Pm,...t),Fm=Bm``,Um=bo(Ct,ke,Et,xt,yt,$e,cn,Ue,vt);function Ur({appearance:e,rootElement:t,logger:n,language:r,stringSet:s,children:a,messageTemplate:i,theme:l}){return va(oa,t),o.createElement(T.StyleSheetManager,{target:t},o.createElement(ba,{rootElement:t,logger:n,appearance:e,theme:l},o.createElement(Ds,{internalVariables:i==null?void 0:i.__internalVariables},o.createElement(ga,{stringSet:s,logger:n,language:r},o.createElement(Um,null,a,o.createElement(Fm,null))))))}const Hm={isOnline:()=>typeof window>"u"?!0:navigator.onLine,subscribe:e=>{if(typeof window>"u")return me;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=d.forwardRef(function({rootElement:t=document.body,logLevel:n=X.LogLevel.WARN,language:r=navigator.language,userSessionInfo:s,children:a,...i},l){var c,u;return Ve.level!==n&&(Ve.level=n),xa("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:Ve,rootElement:t,appearance:(c=i.agentPreviewConfigs)==null?void 0:c.appearance,stringSet:i.stringSet,language:r,messageTemplate:i.messageTemplate,theme:i.theme},o.createElement(ya,{rootElement:t,keyValueStorage:{get:ot.getItem,set:ot.setItem,delete:ot.deleteItem,getKeys:ot.getKeys},networkStateAdapter:Hm,language:r,logger:Ve,dispatcher:Hr,chatParams:{...i.chatParams,customApiHost:i.customApiHost,customWebSocketHost:i.customWebSocketHost},chatSDK:i.customChatSDK,messengerVersion:Wa,...i},o.createElement(md,{ref:l,userSessionInfo:s,forceCreateChannel:(u=i.agentPreviewConfigs)==null?void 0:u.forceCreateChannel},o.createElement(jc,{...i._UNSAFE_INTERNAL_dashboardTester},a,o.createElement("div",{id:re.MODAL_ROOT}))))))}),Ve=new tr(X.LogLevel.WARN),Hr=new er(Ve),{Provider:zm,useContext:un}=J("PageChildren"),zr=({children:e})=>{const[t,n]=d.useState(null),[r,s]=d.useState(null);return o.createElement(zm,{value:{conversationChildren:t,setConversationChildren:n,conversationListChildren:r,setConversationListChildren:s}},e)},Vr=({children:e,isOpened:t})=>{const{dir:n,rootElement:r}=G(),s=we(r,!0);return d.useEffect(()=>{const a="sb-agent-block-scroll";return t?s.body.classList.add(a):s.body.classList.remove(a),()=>{s.body.classList.remove(a)}},[s,t]),o.createElement(Vm,{dir:n,$visible:t},e)},Vm=h.default.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${Ie.WINDOW};visibility:${({$visible:e})=>e?"visible":"hidden"};`,Gm=48,Wm=2/3;function Gr({className:e,isOpened:t,onClick:n,type:r,imageUrl:s,dir:a,animated:i=!0,backgroundColor:l,size:c=Gm}){const u=Rt(l),f=Math.round(c*Wm);return o.createElement(Km,{dir:a,id:re.LAUNCHER,className:e,"aria-label":"Sendbird AIAgent Launcher",onClick:n,$animated:i,$backgroundColor:l,$size:c},o.createElement(Ym,{$isOpened:t,$animated:i,$fillColor:u,$iconSize:f},o.createElement(Kn.Open,{url:s,isDefaultIcon:r==="default_icon",size:f})),o.createElement(Zm,{$isOpened:t,$animated:i,$fillColor:u,$iconSize:f},o.createElement(Kn.Close,{size:f})))}const qm=T.css`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`,jm=T.css`img{width:100%;height:100%;object-fit:cover;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;&[data-default-icon='true']{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;filter:${({$fillColor:e})=>e===Ge.WHITE?"grayscale(100%) brightness(2000%)":"grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`,Wr=T.css`svg{width:${({$iconSize:e})=>e}px;height:${({$iconSize:e})=>e}px;${({$fillColor:e})=>T.css`
|
|
286
|
+
ellipse,
|
|
287
|
+
path {
|
|
288
|
+
fill: ${e};
|
|
289
|
+
}
|
|
290
|
+
[class*='fill'] {
|
|
291
|
+
fill: ${e};
|
|
292
|
+
}
|
|
293
|
+
`}
|
|
294
|
+
}
|
|
295
|
+
`,Km=h.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&&qm}`,qr=h.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;`,Ym=h.default(qr)`opacity:${({$isOpened:e})=>e?0:1};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(-90deg) scale(0)":"rotate(0deg)")};${jm}${Wr}`,Zm=h.default(qr)`scale:${({$isOpened:e})=>e?1:0};transform:${({$animated:e,$isOpened:t})=>e&&(t?"rotate(0deg)":"rotate(-90deg)")};${Wr}`,Kn={Open:e=>e.url?o.createElement("img",{src:e.url,alt:"launcher-img","data-default-icon":e.isDefaultIcon}):o.createElement(N,{size:e.size,type:"delight"}),Close:({size:e})=>o.createElement(N,{size:e,type:"chevron-down"})};function jr({className:e,size:t}){const{colors:n}=T.useTheme(),{dir:r,state:s}=G(),{launcherInfo:a}=Q();return Jm(),o.createElement(Gr,{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 Xm=1e3*60;function Jm(){const{chatSDK:e,state:t,logger:n,enableAutoDisconnectInLauncher:r}=G(),s=d.useRef(null);d.useEffect(()=>{if(!r)return;function a(){s.current&&(clearTimeout(s.current),s.current=null)}function i(){e.connectionState===X.ConnectionState.CLOSED&&(e.reconnect(),n.debug("useSDKInactivityTimeout: reconnected")),a(),n.debug("useSDKInactivityTimeout: clear disconnect schedule")}function l(){a(),s.current=setTimeout(async()=>{await e.disconnectWebSocket(),n.debug("useSDKInactivityTimeout: disconnected")},Xm)}t.opened?i():(l(),n.debug("useSDKInactivityTimeout: schedule disconnect"))},[r,e,t.opened])}const Kr=d.createContext(null);function Yr(){const e=d.useContext(Kr);if(!e)throw new Error("useNavigator() must be used within <Navigator />");return e}function Zr({children:e}){const t=Yr();return typeof e=="function"?e(t):o.createElement(o.Fragment,null,e)}const Qm=T.keyframes`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`,eg=T.keyframes`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`,tg=T.css`animation-name:${Qm};animation-duration:0.3s;animation-fill-mode:forwards;`,ng=T.css``,rg=T.css`animation-name:${eg};animation-duration:0.3s;animation-fill-mode:forwards;`,og=T.css`visibility:hidden;`,sg=h.default.div`position:absolute;top:0;left:0;width:100%;height:100%;${({$transitionState:e})=>{switch(e){case"entering":return tg;case"entered":return ng;case"exiting":return rg;case"exited":return og;default:return""}}}${({$active:e})=>e?T.css`
|
|
296
|
+
z-index: 999;
|
|
297
|
+
`:T.css`z-index:1;pointer-events:none;`}
|
|
298
|
+
`;function st({initialId:e,children:t}){const[n,r]=d.useState([e]),s=n[n.length-1],a=d.useCallback((m,p)=>{r(v=>[...v,m]),b(v=>({...v,[m]:!0})),p!=null&&p.reset&&x(v=>({...v,[m]:(v[m]||0)+1})),y(v=>({...v,[m]:"entering"})),setTimeout(()=>{y(v=>({...v,[m]:"entered"}))},300)},[]),i=d.useCallback(()=>{r(m=>{if(m.length<=1)return m;const p=m[m.length-1];return y(v=>({...v,[p]:"exiting"})),setTimeout(()=>{y(v=>({...v,[p]:"exited"})),r(v=>v.slice(0,-1))},300),m})},[]),l=d.useMemo(()=>({navigation:{navigate:a,pop:i},activeScreenId:s}),[a,i,s]),c=d.useMemo(()=>d.Children.toArray(t).filter(m=>m.type===Zr),[t]),u=d.useMemo(()=>{const m={};return c.forEach(p=>{const{id:v,lazy:_,children:I}=p.props;m[v]={lazy:_,element:typeof I=="function"?I(l):I}}),m},[c,l]),[f,b]=d.useState(()=>{const m={};return Object.entries(u).forEach(([p,{lazy:v}])=>{v===!1&&(m[p]=!0)}),m[e]=!0,m}),[E,y]=d.useState(()=>{const m={};return Object.keys(u).forEach(p=>{p===e?m[p]="entered":m[p]="exited"}),m}),[C,x]=d.useState({});return o.createElement(Kr.Provider,{value:l},o.createElement(ag,null,Object.keys(u).map(m=>{var I;if(!f[m])return null;const p=E[m]||"exited",v=m===s,_=`${m}-${C[m]||0}`;return o.createElement(sg,{key:_,$transitionState:p,$active:v},(I=u[m])==null?void 0:I.element)})))}const ag=h.default.div`position:relative;width:100%;height:100%;`;st.Screen=Zr;const de={conv:"conv",convList:"conv-list"},Xr=({isOpened:e,entryPoint:t,selectedChannelUrl:n,setSelectedChannelUrl:r})=>{const{conversationChildren:s,conversationListChildren:a}=un(),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(ig,{onOpenConversationView:r}));return o.createElement(st,{initialId:i},o.createElement(st.Screen,{id:de.conv},({navigation:c,activeScreenId:u})=>o.createElement(Pr,{key:n,channelUrl:n,onClearChannelUrl:()=>r(void 0),onNavigateToConversationList:()=>c.navigate(de.convList),shouldMarkAsRead:e&&u===de.conv},l,s)),o.createElement(st.Screen,{id:de.convList,lazy:!0},({navigation:c})=>o.createElement(Fr,{onOpenConversationView:u=>{r(u),c.navigate(de.conv)}},l,a)))},ig=({onOpenConversationView:e})=>{const{registerOnJoinedProactiveConversation:t}=Q(),{navigation:n}=Yr();return t(({channel:r})=>{e(r.url),n.navigate(de.conv)}),null};function lg({isExpanded:e,isOpened:t,children:n,launcher:r}){const{dir:s}=G();return o.createElement(cg,null,o.createElement(dg,{dir:s,id:re.WINDOW,$isExpanded:e,$isOpened:t},n),r)}const cg=h.default.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`,dg=h.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&&mg};${({$isExpanded:e})=>e&&ug};`,ug=T.css`width:743px;height:723px;`,mg=T.css`z-index:${Ie.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;`,gg=d.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const s=Ke(),[a,i]=d.useState(t),l=s?Vr:lg;return o.createElement(dn,{enableExpandButton:!s,ref:r,...n},o.createElement(hr,null,({state:c})=>o.createElement(zr,null,o.createElement(l,{isExpanded:c.expanded,isOpened:c.opened,launcher:o.createElement(jr,null)},o.createElement(Xr,{isOpened:c.opened,entryPoint:n.entryPoint,selectedChannelUrl:a,setSelectedChannelUrl:i})),e)))}),{Provider:hg,useContext:mn}=J("FixedMessengerStyle");function Jr(e,t,n,r=0){const{top:s,bottom:a,start:i,end:l}=n;let c="",u="";switch(e){case"start":u=`inset-inline-start: ${ae(i)}`;break;case"end":u=`inset-inline-end: ${ae(l)}`;break}switch(t){case"top":c=`top: calc(${ae(s)} + ${r}px)`;break;case"bottom":c=`bottom: calc(${ae(a)} + ${r}px)`;break}return T.css`${c};${u};`}function fg(e){const{horizontal:t,vertical:n,margin:r,launcherSize:s}=mn();return o.createElement(pg,{...e,size:s,$horizontal:t,$vertical:n,$margin:r})}const pg=h.default(jr)`position:fixed;z-index:${Ie.LAUNCHER};${({$horizontal:e,$vertical:t,$margin:n})=>Jr(e,t,n)};`;function bg({isExpanded:e,isOpened:t,children:n}){const{dir:r}=G(),{horizontal:s,vertical:a,margin:i,launcherSize:l}=mn();return o.createElement(Eg,{dir:r,id:re.WINDOW,$isExpanded:e,$isOpened:t,$horizontal:s,$vertical:a,$margin:i,$launcherSize:l},n)}const Eg=h.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})=>Jr(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
|
+
[dir='rtl'] &:not([dir='ltr']),
|
|
300
|
+
&[dir='rtl'] {
|
|
301
|
+
transform-origin: ${({$horizontal:e,$vertical:t})=>`${e==="start"?"right":"left"} ${t}`};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
${({$isOpened:e})=>e&&vg};
|
|
305
|
+
${({$isExpanded:e})=>e&&xg};
|
|
306
|
+
`,xg=T.css`width:743px;height:723px;`,vg=T.css`z-index:${Ie.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;`,Qr={top:24,bottom:24,start:24,end:24},Cg=d.forwardRef(function({children:e,initialChannelUrl:t,...n},r){const[s,a]=d.useState(t),[i,l]=d.useState("end-bottom"),[c,u]=d.useState(Qr),[f,b]=d.useState(48),E=Ke(),y=E?Vr:bg,{horizontal:C,vertical:x}=d.useMemo(()=>{const[m,p]=i.split("-");return{horizontal:m==="start"?"start":"end",vertical:p==="top"?"top":"bottom"}},[i]);return o.createElement(dn,{enableExpandButton:!E,ref:r,...n},o.createElement(hr,null,({state:m})=>o.createElement(hg,{value:{horizontal:C,vertical:x,margin:c,launcherSize:f,setPosition:l,setMargin:u,setLauncherSize:b}},o.createElement(zr,null,o.createElement(y,{isExpanded:m.expanded,isOpened:m.opened},o.createElement(Xr,{isOpened:m.opened,entryPoint:n.entryPoint,selectedChannelUrl:s,setSelectedChannelUrl:a})),o.createElement(fg,null),e))))}),yg=e=>{var s,a,i,l;const{setPosition:t,setMargin:n,setLauncherSize:r}=mn();return d.useLayoutEffect(()=>{e.position&&t(e.position),e.margin&&n({...Qr,...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},_g=({children:e})=>{const{setConversationChildren:t}=un();return d.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},Sg=({children:e})=>{const{setConversationListChildren:t}=un();return d.useLayoutEffect(()=>(t(e),()=>t(null)),[e]),null},Tg=Object.assign(Cg,{Style:yg,ConversationChildren:_g,ConversationListChildren:Sg}),Ag=e=>{const{refreshActiveChannel:t}=Q(),[n,r]=d.useState(!1),s=d.useRef(null),a=d.useRef(null);return d.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]),d.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=Dt;exports.CSATType=se;exports.Conversation=Pr;exports.ConversationContext=Sd;exports.ConversationContextProvider=$r;exports.ConversationHeaderLayout=$e;exports.ConversationLayout=Ct;exports.ConversationList=Fr;exports.ConversationListContext=dm;exports.ConversationListContextProvider=Br;exports.ConversationListHeaderLayout=Ue;exports.ConversationListItemLayout=cn;exports.ConversationListLayout=yt;exports.DefaultMessenger=gg;exports.DispatcherCommands=nr;exports.FixedMessenger=Tg;exports.IncomingMessageLayout=ke;exports.LauncherBase=Gr;exports.LogLevel=jt;exports.ManualSessionInfo=ar;exports.MessageLogs=wr;exports.OutgoingMessageLayout=Et;exports.PlaceholderLayout=vt;exports.SystemMessageLayout=xt;exports.cssVars=g;exports.escapeMarkdownSyntax=$o;exports.mapCommonStringsToReactFormat=mr;exports.messengerDispatcher=Hr;exports.useConversationContext=ee;exports.useConversationListContext=ln;exports.useLocalizationContext=U;exports.useMessengerContext=G;exports.useMessengerSessionContext=Q;exports.useRefreshActiveChannel=Ag;
|