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