@maebgch/rcs-emulator 0.1.13 → 0.1.14

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),n=require("react");function W(s){return"reply"in s}function L(s){return"action"in s}function re(s){if(!L(s))return!1;const{urlAction:r}=s.action;return r?.openUrl?.application==="WEBVIEW"}function P(s){const{urlAction:r}=s.action;return r?.openUrl?.application==="WEBVIEW"?r.openUrl:null}const te={name:"Business",verified:!1},se={currentMessageId:null,chatHistory:[],isTyping:!1,error:null},G=n.createContext(null);function F({children:s,theme:r,device:t,businessInfo:o,state:a,showSuggestions:c,isProfileOpen:l,toggleProfile:u,onReply:m,onAction:i,webView:h,openWebView:x,closeWebView:j}){const g={theme:r,device:t,businessInfo:{...te,...o},state:{...se,...a},showSuggestions:c,isProfileOpen:l,toggleProfile:u,handleReply:m,handleAction:i,webView:h,openWebView:x,closeWebView:j};return e.jsx(G.Provider,{value:g,children:s})}function w(){const s=n.useContext(G);if(!s)throw new Error("useEmulator must be used within an EmulatorProvider");return s}function q(s){const r=Object.values(s.messages);return r.find(t=>t.is_first)||r[0]||null}function z(s,r){return s.messages[r]||null}function V(s,r){const t=s.responses?.keyword?.keyword_response?.choices;return t&&t[r]?.next_message||null}function T(s,r){const t=s.parts,o=oe(t),a=le(t);return{id:`${s.id}-${r}-${Date.now()}`,sender:"business",content:o,timestamp:Date.now(),suggestions:a}}function oe(s){for(const r of s){const t=r.RCSMessage;if(t.textMessage)return{type:"text",text:t.textMessage};const o=t.richcardMessage?.message?.generalPurposeCard;if(o)return{type:"richcard",card:H(o.content,o.layout)};const a=t.richcardMessage?.message?.generalPurposeCardCarousel;if(a)return{type:"carousel",cards:a.content.map(c=>H(c,{cardOrientation:"VERTICAL",cardWidth:a.layout.cardWidth}))}}return{type:"text",text:"[Unsupported message type]"}}function H(s,r){const t=()=>{if(s.media){if(s.media.mediaUrl)return s.media.mediaUrl;if(s.media.contentInfo?.fileUrl)return s.media.contentInfo.fileUrl}},o=()=>{if(s.media){if(s.media.thumbnailUri)return s.media.thumbnailUri;if(s.media.contentInfo?.thumbnailUrl)return s.media.contentInfo.thumbnailUrl}},a=t();return{title:s.title,description:s.description,media:a?{url:a,height:ae(s.media?.height||"MEDIUM_HEIGHT"),thumbnailUrl:o()}:void 0,suggestions:s.suggestions,layout:{orientation:r.cardOrientation==="HORIZONTAL"?"horizontal":"vertical",width:r.cardWidth==="SMALL_WIDTH"?"small":"medium",imageAlignment:r.imageAlignment==="RIGHT"?"right":"left"}}}function ae(s){switch(s){case"SHORT_HEIGHT":return"short";case"TALL_HEIGHT":return"tall";default:return"medium"}}function le(s){const r=[];for(const t of s){const o=t.RCSMessage;o.suggestedChipList?.suggestions&&r.push(...o.suggestedChipList.suggestions)}return r}function ce(s){return{id:`user-${Date.now()}`,sender:"user",content:{type:"userReply",text:s},timestamp:Date.now()}}function J(s){if(!s||typeof s!="object")return!1;const r=s;if(typeof r.name!="string"||!r.messages||typeof r.messages!="object")return!1;const t=Object.values(r.messages);if(t.length===0)return!1;for(const o of t){if(!o||typeof o!="object")return!1;const a=o;if(typeof a.id!="string"||!Array.isArray(a.parts))return!1}return!0}function Y(s){const r=q(s);if(!r||!r.parts.length)return"New message";const o=r.parts[0].RCSMessage;if(o.textMessage)return o.textMessage.slice(0,50)+(o.textMessage.length>50?"...":"");const a=o.richcardMessage?.message?.generalPurposeCard;if(a?.content.title)return a.content.title;const c=o.richcardMessage?.message?.generalPurposeCardCarousel;return c?.content[0]?.title?c.content[0].title:"New message"}const Q={currentMessageId:null,chatHistory:[],isTyping:!1,error:null};function ne(s,r){switch(r.type){case"INIT":return{...s,currentMessageId:r.messageId,error:null};case"ADD_BUSINESS_MESSAGE":return{...s,chatHistory:[...s.chatHistory,r.message],isTyping:!1};case"ADD_USER_REPLY":{const t=ce(r.text),o=s.chatHistory.map((a,c)=>c===s.chatHistory.length-1?{...a,suggestions:void 0}:a);return{...s,chatHistory:[...o,t]}}case"SET_TYPING":return{...s,isTyping:r.isTyping};case"NAVIGATE_TO":return{...s,currentMessageId:r.messageId};case"SET_ERROR":return{...s,error:r.error,isTyping:!1};case"RESET":return Q;default:return s}}function ie({flow:s,onUserReply:r,typingDelay:t=800}){const[o,a]=n.useReducer(ne,Q),c=n.useRef(0),l=n.useRef(!1);n.useEffect(()=>{if(l.current)return;l.current=!0;const h=q(s);if(!h){a({type:"SET_ERROR",error:"No first message found in conversation flow"});return}a({type:"INIT",messageId:h.id});const x=T(h,c.current++);a({type:"ADD_BUSINESS_MESSAGE",message:x})},[s]);const u=n.useCallback(h=>{if(!W(h))return;const{displayText:x,postback:j}=h.reply,g=j.data;a({type:"ADD_USER_REPLY",text:x,postbackData:g});const y={type:"reply",postbackData:g,displayText:x,timestamp:Date.now()};r(y);const b=o.currentMessageId?z(s,o.currentMessageId):null;if(!b){a({type:"SET_ERROR",error:"Current message not found"});return}const v=V(b,g);if(!v)return;const f=z(s,v);if(!f){a({type:"SET_ERROR",error:`Next message "${v}" not found`});return}a({type:"SET_TYPING",isTyping:!0}),a({type:"NAVIGATE_TO",messageId:v}),setTimeout(()=>{const d=T(f,c.current++);a({type:"ADD_BUSINESS_MESSAGE",message:d})},t)},[s,o.currentMessageId,r,t]),m=n.useCallback(h=>{if(!L(h))return;const{displayText:x,postback:j,openUrlAction:g,dialAction:y,dialerAction:b,mapAction:v,viewLocationAction:f}=h.action,d=j.data,p=y?.phoneNumber||b?.dialPhoneNumber?.phoneNumber,N=v?.showLocation?.location||f?.latLong;let M;g?M={type:"openUrl",url:g.url}:p?M={type:"dial",phoneNumber:p}:N&&(M={type:"viewLocation",latitude:N.latitude,longitude:N.longitude,query:f?.query});const k={type:"action",postbackData:d,displayText:x,timestamp:Date.now(),actionData:M};if(r(k),g)window.open(g.url,"_blank","noopener,noreferrer");else if(p)window.location.href=`tel:${p}`;else if(N){const C=v?.showLocation?.location?.label||f?.label||"",A=`https://www.google.com/maps/search/?api=1&query=${N.latitude},${N.longitude}${C?`&query_place_id=${encodeURIComponent(C)}`:""}`;window.open(A,"_blank","noopener,noreferrer")}const $=o.currentMessageId?z(s,o.currentMessageId):null;if($){const C=V($,d);if(C){const A=z(s,C);A&&(a({type:"ADD_USER_REPLY",text:x,postbackData:d}),a({type:"SET_TYPING",isTyping:!0}),a({type:"NAVIGATE_TO",messageId:C}),setTimeout(()=>{const ee=T(A,c.current++);a({type:"ADD_BUSINESS_MESSAGE",message:ee})},t))}}},[s,o.currentMessageId,r,t]),i=n.useCallback(()=>{l.current=!1,c.current=0,a({type:"RESET"})},[]);return{state:o,handleReply:u,handleAction:m,reset:i}}function Z(s){const[r,t]=n.useState(null),[o,a]=n.useState(!1),[c,l]=n.useState(null),u=n.useCallback(async()=>{if(!s){t(null),l(null);return}a(!0),l(null);try{const m=await fetch(s,{method:"GET",headers:{Accept:"application/json"}});if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);const i=await m.json();if(!i||typeof i!="object")throw new Error("Invalid JSON: Expected an object");if(!i.messages||typeof i.messages!="object")throw new Error("Invalid RBM JSON: Missing 'messages' object");t(i)}catch(m){const i=m instanceof Error?m.message:"Failed to fetch JSON";l(i),t(null)}finally{a(!1)}},[s]);return n.useEffect(()=>{u()},[u]),{data:r,isLoading:o,error:c,refetch:u}}function ue(s){const r=n.useRef(null);return n.useEffect(()=>{r.current&&r.current.scrollTo({top:r.current.scrollHeight,behavior:"smooth"})},[s]),r}const me=n.memo(function(){const{theme:r,businessInfo:t,toggleProfile:o}=w(),a=r==="dark",c=a?"rcs-emulator-dark":"rcs-emulator-light",l=t.brandColor||"#1A73E8";return e.jsxs("header",{className:`rcs-emulator-header ${c}`,role:"banner","aria-label":`Chat with ${t.name}`,children:[e.jsx("button",{type:"button",className:`rcs-emulator-icon-btn rcs-emulator-p-1-5 rcs-emulator--ml-1 ${c} ${a?"rcs-emulator-text-white":"rcs-emulator-text-gray-700"}`,"aria-label":"Go back",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsxs("button",{onClick:o,className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-2-5 rcs-emulator-flex-1 rcs-emulator-min-w-0 rcs-emulator-text-left rcs-emulator-bg-transparent",style:{background:"transparent"},"aria-label":"View business info",children:[e.jsx("div",{className:`rcs-emulator-logo-avatar rcs-emulator-w-9 rcs-emulator-h-9 ${c}`,style:{backgroundColor:t.logo?void 0:l},children:t.logo?e.jsx("img",{src:t.logo,alt:`${t.name} logo`,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-text-sm rcs-emulator-font-bold rcs-emulator-text-white",children:t.name.charAt(0).toUpperCase()})}),e.jsx("h1",{className:`rcs-emulator-text-base rcs-emulator-font-medium rcs-emulator-truncate ${a?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.name})]}),e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-0-5",children:[t.verified&&e.jsx("button",{type:"button",className:`rcs-emulator-icon-btn rcs-emulator-p-2 ${c}`,"aria-label":"Verified business",children:e.jsxs("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:a?"#9ca3af":"#6b7280",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 12l2 2 4-4",stroke:"#3b82f6",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{type:"button",className:`rcs-emulator-icon-btn rcs-emulator-p-2 ${c} ${a?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,"aria-label":"More options",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]})]})}),de=n.memo(function(){const{theme:r,businessInfo:t}=w(),o=r==="dark",a=o?"rcs-emulator-dark":"rcs-emulator-light",c=t.brandColor||"#0084ff";return e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-py-4 rcs-emulator-px-4",children:[e.jsxs("div",{className:"rcs-emulator-relative rcs-emulator-mb-3",children:[e.jsx("div",{className:`rcs-emulator-logo-avatar rcs-emulator-w-16 rcs-emulator-h-16 rcs-emulator-shadow-lg ${a}`,style:{backgroundColor:t.logo?void 0:c},children:t.logo?e.jsx("img",{src:t.logo,alt:`${t.name} logo`,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-text-2xl rcs-emulator-font-bold rcs-emulator-text-white",children:t.name.charAt(0).toUpperCase()})}),t.verified&&e.jsx("div",{className:"rcs-emulator-verified-badge",children:e.jsx("svg",{className:"rcs-emulator-w-3 rcs-emulator-h-3 rcs-emulator-text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})})]}),e.jsx("h1",{className:`rcs-emulator-text-lg rcs-emulator-font-semibold rcs-emulator-text-center ${o?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.name}),t.description&&e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-text-center rcs-emulator-mt-0-5 ${o?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:t.description})]})}),he=n.memo(function({text:r,sender:t,timestamp:o}){const{theme:a,businessInfo:c}=w(),u=a==="dark"?"rcs-emulator-dark":"rcs-emulator-light",m=t==="business",i=c.brandColor||"#1A73E8",h=new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return m?e.jsxs("div",{className:"rcs-emulator-max-w-90 rcs-emulator-flex rcs-emulator-flex-col",children:[e.jsx("div",{className:`rcs-emulator-message-bubble rcs-emulator-business ${u}`,children:r}),e.jsx("span",{className:"rcs-emulator-sr-only",children:h})]}):e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-items-end rcs-emulator-gap-1-5 rcs-emulator-max-w-85 rcs-emulator-ml-auto",children:[e.jsx("div",{className:"rcs-emulator-message-bubble rcs-emulator-user",style:{backgroundColor:i},children:r}),e.jsx("div",{className:"rcs-emulator-delivery-status",style:{backgroundColor:i},children:e.jsx("svg",{className:"rcs-emulator-w-3 rcs-emulator-h-3 rcs-emulator-text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"rcs-emulator-sr-only",children:h})]})}),xe=n.memo(function({text:r,timestamp:t}){const{businessInfo:o}=w(),a=o.brandColor||"#1A73E8",c=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-items-end rcs-emulator-gap-1-5 rcs-emulator-max-w-85 rcs-emulator-ml-auto",children:[e.jsx("div",{className:"rcs-emulator-message-bubble rcs-emulator-user rcs-emulator-shadow-sm",style:{backgroundColor:a,color:"white"},children:r}),e.jsx("div",{className:"rcs-emulator-delivery-status",style:{backgroundColor:a},children:e.jsx("svg",{className:"rcs-emulator-w-3 rcs-emulator-h-3 rcs-emulator-text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"rcs-emulator-sr-only",children:c})]})}),fe=n.memo(function({card:r,timestamp:t}){const{theme:o,handleReply:a,handleAction:c}=w(),l=o==="dark",u=l?"rcs-emulator-dark":"rcs-emulator-light",m=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),i=x=>{"reply"in x?a(x):c(x)},h={short:"rcs-emulator-h-36",medium:"rcs-emulator-h-44",tall:"rcs-emulator-h-56"};return e.jsxs("div",{className:"rcs-emulator-w-full",children:[e.jsxs("div",{className:`rcs-emulator-rich-card ${u}`,children:[r.media&&e.jsx("div",{className:`rcs-emulator-w-full rcs-emulator-overflow-hidden rcs-emulator-media-placeholder ${h[r.media.height]} ${l?"rcs-emulator-dark":"rcs-emulator-light"}`,style:{borderRadius:"12px 12px 0 0"},children:e.jsx("img",{src:r.media.url,alt:r.title||"Rich card media",className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover",loading:"lazy",onError:x=>{const j=x.target;j.style.display="none"}})}),e.jsxs("div",{className:"rcs-emulator-p-4",children:[r.title&&e.jsx("h3",{className:`rcs-emulator-text-base rcs-emulator-font-semibold rcs-emulator-leading-snug rcs-emulator-card-title ${l?"rcs-emulator-dark":"rcs-emulator-light"}`,children:r.title}),r.description&&e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-leading-relaxed rcs-emulator-mt-1-5 rcs-emulator-card-subtitle ${l?"rcs-emulator-dark":"rcs-emulator-light"}`,children:r.description}),r.suggestions&&r.suggestions.length>0&&e.jsx("div",{className:`rcs-emulator-card-actions rcs-emulator-mt-4 rcs-emulator-divide-y ${l?"rcs-emulator-divide-zinc-700":"rcs-emulator-divide-gray-100"} ${u}`,children:r.suggestions.map((x,j)=>e.jsx(ve,{suggestion:x,onClick:()=>i(x),isDark:l},j))})]})]}),e.jsx("span",{className:"rcs-emulator-sr-only",children:m})]})}),S="rcs-emulator-w-5 rcs-emulator-h-5 rcs-emulator-text-gray-400",pe=()=>e.jsx("svg",{className:S,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),ge=()=>e.jsx("svg",{className:S,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),je=()=>e.jsxs("svg",{className:S,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),be=()=>e.jsx("svg",{className:S,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),_=()=>e.jsx("svg",{className:S,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),ve=n.memo(function({suggestion:r,onClick:t,isDark:o}){const a=L(r),c=a?r.action.displayText:r.reply.displayText,l=()=>{if(!a)return e.jsx(_,{});const{action:u}=r;return u.urlAction||u.openUrlAction?e.jsx(pe,{}):u.dialerAction||u.dialAction?e.jsx(ge,{}):u.mapAction||u.viewLocationAction?e.jsx(je,{}):u.calendarAction||u.createCalendarEventAction?e.jsx(be,{}):e.jsx(_,{})};return e.jsxs("button",{onClick:t,className:`rcs-emulator-list-item ${o?"rcs-emulator-dark":"rcs-emulator-light"}`,style:{gap:"0.75rem",padding:"0.75rem 1rem"},children:[e.jsx("span",{className:"rcs-emulator-flex-shrink-0",children:l()}),e.jsx("span",{className:`rcs-emulator-text-sm ${o?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:c})]})}),we=n.memo(function({cards:r,timestamp:t}){const{theme:o,handleReply:a,handleAction:c}=w(),l=n.useRef(null),[u,m]=n.useState(!1),[i,h]=n.useState(r.length>1),x=o==="dark",j=x?"rcs-emulator-dark":"rcs-emulator-light",g=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),y=f=>{"reply"in f?a(f):c(f)},b=n.useCallback(()=>{if(l.current){const{scrollLeft:f,scrollWidth:d,clientWidth:p}=l.current;m(f>0),h(f<d-p-10)}},[]),v=f=>{l.current&&l.current.scrollBy({left:f==="left"?-200:200,behavior:"smooth"})};return e.jsxs("div",{className:"rcs-emulator-w-full rcs-emulator--mx-3",children:[e.jsxs("div",{className:"rcs-emulator-relative",children:[u&&e.jsx("button",{onClick:()=>v("left"),className:`rcs-emulator-carousel-arrow rcs-emulator-left ${j}`,"aria-label":"Scroll left",children:e.jsx("svg",{className:"rcs-emulator-w-4 rcs-emulator-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("div",{ref:l,onScroll:b,className:"rcs-emulator-flex rcs-emulator-gap-2-5 rcs-emulator-overflow-x-auto rcs-emulator-py-1 rcs-emulator-px-3 rcs-emulator-snap-x rcs-emulator-scrollbar-hide",children:r.map((f,d)=>e.jsx(ke,{card:f,isDark:x,onSuggestionClick:y},d))}),i&&e.jsx("button",{onClick:()=>v("right"),className:`rcs-emulator-carousel-arrow rcs-emulator-right ${j}`,"aria-label":"Scroll right",children:e.jsx("svg",{className:"rcs-emulator-w-4 rcs-emulator-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("span",{className:"rcs-emulator-sr-only",children:g})]})}),I="rcs-emulator-w-4 rcs-emulator-h-4 rcs-emulator-text-gray-400",ye=s=>{if(!L(s))return e.jsx("svg",{className:I,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});const{action:r}=s;return r.urlAction||r.openUrlAction?e.jsx("svg",{className:I,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}):r.dialerAction||r.dialAction?e.jsx("svg",{className:I,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}):r.mapAction||r.viewLocationAction?e.jsxs("svg",{className:I,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):r.calendarAction||r.createCalendarEventAction?e.jsx("svg",{className:I,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e.jsx("svg",{className:I,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})},ke=n.memo(function({card:r,isDark:t,onSuggestionClick:o}){const a=r.layout.width==="small"?"rcs-emulator-w-44":"rcs-emulator-w-52",c=t?"rcs-emulator-dark":"rcs-emulator-light";return e.jsxs("div",{className:`rcs-emulator-carousel-card ${a} ${c}`,children:[r.media&&e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-32 rcs-emulator-bg-gray-200 rcs-emulator-overflow-hidden",children:e.jsx("img",{src:r.media.url,alt:r.title||"Carousel card media",className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover",loading:"lazy"})}),e.jsxs("div",{className:"rcs-emulator-p-3",children:[r.title&&e.jsx("h4",{className:`rcs-emulator-text-sm rcs-emulator-font-semibold rcs-emulator-leading-tight rcs-emulator-mb-1 rcs-emulator-line-clamp-2 ${t?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:r.title}),r.description&&e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-leading-relaxed rcs-emulator-line-clamp-3 ${t?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-700"}`,children:r.description}),r.suggestions&&r.suggestions.length>0&&e.jsx("div",{className:`rcs-emulator-carousel-actions rcs-emulator-mt-3 rcs-emulator-divide-y ${t?"rcs-emulator-divide-zinc-600":"rcs-emulator-divide-gray-100"} ${c}`,children:r.suggestions.map((l,u)=>{const i=L(l)?l.action.displayText:l.reply.displayText;return e.jsxs("button",{onClick:()=>o(l),className:`rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-2 rcs-emulator-px-3 rcs-emulator-py-2-5 rcs-emulator-text-xs rcs-emulator-transition-colors rcs-emulator-text-left rcs-emulator-border-none ${t?"rcs-emulator-hover-bg-zinc-700 rcs-emulator-text-white":"rcs-emulator-hover-bg-gray-50 rcs-emulator-text-gray-900"}`,children:[e.jsx("span",{className:"rcs-emulator-flex-shrink-0",children:ye(l)}),e.jsx("span",{className:"rcs-emulator-truncate",children:i})]},u)})})]})]})}),Ne={text:({content:s,sender:r,timestamp:t})=>s.type!=="text"?null:e.jsx(he,{text:s.text,sender:r,timestamp:t}),userReply:({content:s,timestamp:r})=>s.type!=="userReply"?null:e.jsx(xe,{text:s.text,timestamp:r}),richcard:({content:s,timestamp:r})=>s.type!=="richcard"?null:e.jsx(fe,{card:s.card,timestamp:r}),carousel:({content:s,timestamp:r})=>s.type!=="carousel"?null:e.jsx(we,{cards:s.cards,timestamp:r})},Ce=n.memo(function({message:r,isLast:t}){const{content:o,sender:a,timestamp:c}=r,l=Ne[o.type];return l?e.jsx(l,{content:o,sender:a,timestamp:c,showSuggestions:t&&a==="business"}):(console.warn(`Unknown message type: ${o.type}`),e.jsx("div",{className:"rcs-emulator-px-4 rcs-emulator-py-2 rcs-emulator-text-gray-500 rcs-emulator-text-sm rcs-emulator-italic",children:"[Unsupported message type]"}))}),Le=n.memo(function(){const{theme:r}=w(),t=r==="dark";return e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-items-start rcs-emulator-gap-2 rcs-emulator-px-4 rcs-emulator-py-2",role:"status","aria-label":"Business is typing",children:e.jsxs("div",{className:`rcs-emulator-inline-flex rcs-emulator-items-center rcs-emulator-gap-1 rcs-emulator-px-4 rcs-emulator-py-3 rcs-emulator-rounded-2xl rcs-emulator-rounded-bl-sm rcs-emulator-typing-bubble ${t?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("span",{className:`rcs-emulator-typing-dot rcs-emulator-w-2 rcs-emulator-h-2 rcs-emulator-rounded-full ${t?"rcs-emulator-bg-zinc-500":"rcs-emulator-bg-gray-400"}`}),e.jsx("span",{className:`rcs-emulator-typing-dot rcs-emulator-w-2 rcs-emulator-h-2 rcs-emulator-rounded-full ${t?"rcs-emulator-bg-zinc-500":"rcs-emulator-bg-gray-400"}`}),e.jsx("span",{className:`rcs-emulator-typing-dot rcs-emulator-w-2 rcs-emulator-h-2 rcs-emulator-rounded-full ${t?"rcs-emulator-bg-zinc-500":"rcs-emulator-bg-gray-400"}`})]})})}),Me=n.memo(function(){const{theme:r,state:t}=w(),{chatHistory:o,isTyping:a}=t,c=r==="dark",l=c?"rcs-emulator-dark":"rcs-emulator-light";return e.jsxs("div",{className:"rcs-emulator-px-3 rcs-emulator-pb-3 rcs-emulator-space-y-3",role:"log","aria-label":"Chat messages","aria-live":"polite",children:[o.length>0&&e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-py-2",children:e.jsx("span",{className:`rcs-emulator-text-xs rcs-emulator-font-medium rcs-emulator-px-3 rcs-emulator-py-1 ${c?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-500"}`,children:"Today"})}),e.jsxs("div",{className:`rcs-emulator-messages-container ${l}`,children:[o.length===0&&!a&&e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-py-12",children:e.jsx("p",{className:`rcs-emulator-text-sm ${c?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,children:"No messages yet"})}),e.jsxs("div",{className:"rcs-emulator-p-3 rcs-emulator-space-y-3",children:[o.map((u,m)=>e.jsx("div",{className:`rcs-emulator-flex ${u.sender==="user"?"rcs-emulator-justify-end":"rcs-emulator-justify-start"}`,children:e.jsx(Ce,{message:u,isLast:m===o.length-1&&!a})},u.id)),a&&e.jsx(Le,{})]})]})]})}),$e=n.memo(function({suggestion:r,onClick:t,variant:o="bar"}){const{theme:a,businessInfo:c}=w(),l=a==="dark",u=L(r),m=u?r.action.displayText:r.reply.displayText,i=u?Ae(r):null,h=c.brandColor||"#1A73E8",x=l?"rcs-emulator-dark":"rcs-emulator-light";return o==="bar"?e.jsxs("button",{type:"button",onClick:t,className:`rcs-emulator-suggestion-chip rcs-emulator-inline-flex rcs-emulator-items-center rcs-emulator-gap-2 rcs-emulator-px-4 rcs-emulator-py-2 rcs-emulator-rounded-full rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-whitespace-nowrap rcs-emulator-transition-colors rcs-emulator-flex-shrink-0 rcs-emulator-border ${x}`,"aria-label":u?`${Ie(r)}: ${m}`:m,children:[i&&e.jsx("span",{style:{color:h},children:e.jsx(i,{className:"rcs-emulator-w-4 rcs-emulator-h-4"})}),e.jsx("span",{className:"rcs-emulator-text-sm rcs-emulator-font-medium",children:m})]}):o==="card"?e.jsxs("button",{type:"button",onClick:t,className:`rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-px-3 rcs-emulator-py-2-5 rcs-emulator-text-left rcs-emulator-transition-colors rcs-emulator-rounded-lg rcs-emulator-list-item rcs-emulator-border-none ${x}`,children:[i&&e.jsx("div",{className:"rcs-emulator-w-8 rcs-emulator-h-8 rcs-emulator-rounded-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-flex-shrink-0",style:{backgroundColor:`${h}15`},children:e.jsx(i,{className:"rcs-emulator-w-4 rcs-emulator-h-4",style:{color:h}})}),e.jsx("span",{className:`rcs-emulator-text-sm rcs-emulator-font-medium ${l?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:m})]}):e.jsx("button",{type:"button",onClick:t,className:`rcs-emulator-w-full rcs-emulator-px-3 rcs-emulator-py-2 rcs-emulator-rounded-lg rcs-emulator-text-xs rcs-emulator-font-medium rcs-emulator-text-center rcs-emulator-border rcs-emulator-transition-colors ${l?"rcs-emulator-border-zinc-600 rcs-emulator-hover-bg-zinc-700 rcs-emulator-text-white":"rcs-emulator-border-gray-300 rcs-emulator-hover-bg-gray-50 rcs-emulator-text-gray-900"}`,children:m})});function Ae(s){if(!L(s))return null;const{action:r}=s;return r.openUrlAction?({className:t,style:o})=>e.jsx("svg",{className:t,style:o,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}):r.dialAction?({className:t,style:o})=>e.jsx("svg",{className:t,style:o,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}):r.shareLocationAction?({className:t,style:o})=>e.jsxs("svg",{className:t,style:o,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):r.viewLocationAction?({className:t,style:o})=>e.jsxs("svg",{className:t,style:o,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):r.createCalendarEventAction?({className:t,style:o})=>e.jsx("svg",{className:t,style:o,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):null}function Ie(s){if(!L(s))return"Reply";const{action:r}=s;return r.openUrlAction?"Open link":r.dialAction?"Call":r.shareLocationAction?"Share location":r.viewLocationAction?"View location":r.createCalendarEventAction?"Add to calendar":"Action"}const Se=n.memo(function({suggestions:r}){const{theme:t,handleReply:o,handleAction:a}=w(),c=t==="dark";if(!r||r.length===0)return null;const l=u=>{W(u)?o(u):L(u)&&a(u)};return e.jsx("div",{className:`rcs-emulator-suggestions-bar rcs-emulator-px-3 rcs-emulator-py-2 ${c?"rcs-emulator-dark":"rcs-emulator-light"}`,role:"group","aria-label":"Quick replies",children:e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-gap-2 rcs-emulator-overflow-x-auto rcs-emulator-pb-1 rcs-emulator--mx-1 rcs-emulator-px-1 rcs-emulator-scrollbar-hide",children:r.map((u,m)=>e.jsx($e,{suggestion:u,onClick:()=>l(u),variant:"bar"},m))})})}),ze=n.memo(function(){const{theme:r,state:t,showSuggestions:o}=w(),{chatHistory:a,isTyping:c,error:l}=t,u=ue([a.length,c]),m=r==="dark",i=m?"rcs-emulator-dark":"rcs-emulator-light",h=a[a.length-1],x=o&&h?.sender==="business"&&!c?h.suggestions:void 0;return e.jsxs("div",{className:`rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-h-full rcs-emulator-w-full rcs-emulator-overflow-hidden ${m?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx(me,{}),l&&e.jsx("div",{className:"rcs-emulator-error-alert",role:"alert",children:e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-text-red-500",children:l})}),e.jsxs("div",{ref:u,className:"rcs-emulator-flex-1 rcs-emulator-overflow-y-auto rcs-emulator-scrollbar",children:[e.jsx(de,{}),e.jsx(Me,{})]}),x&&x.length>0&&e.jsx(Se,{suggestions:x}),e.jsxs("div",{className:`rcs-emulator-input-area ${i}`,children:[e.jsx("button",{type:"button",className:`rcs-emulator-add-btn ${i}`,"aria-label":"Add attachment",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),e.jsxs("div",{className:`rcs-emulator-input-container ${i}`,children:[e.jsx("span",{className:`rcs-emulator-flex-1 rcs-emulator-text-sm ${m?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,children:"RCS message"}),e.jsx("button",{type:"button",className:`rcs-emulator-p-1 ${m?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,"aria-label":"Emoji",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("button",{type:"button",className:`rcs-emulator-p-1 ${m?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,"aria-label":"Attach image",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),e.jsx("button",{type:"button",className:"rcs-emulator-voice-btn","aria-label":"Voice message",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1 1.93c-3.94-.49-7-3.85-7-7.93h2c0 3.31 2.69 6 6 6s6-2.69 6-6h2c0 4.08-3.06 7.44-7 7.93V20h4v2H8v-2h4v-4.07z"})})})]})]})}),Te=n.memo(function(){const{theme:r,businessInfo:t,toggleProfile:o}=w(),[a,c]=n.useState("info"),l=r==="dark",u=t.bannerImage||"https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=800&q=80",m=t.brandColor||"#0084ff";return e.jsxs("div",{className:`rcs-emulator-absolute rcs-emulator-inset-0 rcs-emulator-z-50 rcs-emulator-flex rcs-emulator-flex-col ${l?"rcs-emulator-bg-zinc-950":"rcs-emulator-bg-white"}`,children:[e.jsxs("header",{className:`rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-px-4 rcs-emulator-py-3 rcs-emulator-border-b ${l?"rcs-emulator-bg-zinc-900 rcs-emulator-border-zinc-800":"rcs-emulator-bg-white rcs-emulator-border-gray-200"}`,children:[e.jsx("button",{onClick:o,className:`rcs-emulator-p-1-5 rcs-emulator--ml-1-5 rcs-emulator-rounded-full rcs-emulator-transition-colors ${l?"rcs-emulator-hover-bg-zinc-800 rcs-emulator-text-white":"rcs-emulator-hover-bg-gray-100 rcs-emulator-text-gray-900"}`,"aria-label":"Go back",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("span",{className:`rcs-emulator-text-base rcs-emulator-font-medium ${l?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"Info & options"})]}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-overflow-y-auto",children:[e.jsx("div",{className:"rcs-emulator-relative rcs-emulator-h-40 rcs-emulator-bg-gray-200",children:e.jsx("img",{src:u,alt:"Business banner",className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"})}),e.jsx("div",{className:"rcs-emulator-relative rcs-emulator-px-4",children:e.jsx("div",{className:`rcs-emulator-absolute rcs-emulator--top-10 rcs-emulator-left-1-2 rcs-emulator--translate-x-1-2 rcs-emulator-w-20 rcs-emulator-h-20 rcs-emulator-rounded-full rcs-emulator-overflow-hidden rcs-emulator-border-4 ${l?"rcs-emulator-border-zinc-950 rcs-emulator-bg-zinc-800":"rcs-emulator-border-white rcs-emulator-bg-gray-100"} rcs-emulator-shadow-lg`,children:t.logo?e.jsx("img",{src:t.logo,alt:`${t.name} logo`,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-text-2xl rcs-emulator-font-bold rcs-emulator-text-white",style:{backgroundColor:m},children:t.name.charAt(0).toUpperCase()})})}),e.jsxs("div",{className:"rcs-emulator-pt-12 rcs-emulator-pb-4 rcs-emulator-px-4 rcs-emulator-text-center",children:[e.jsx("h1",{className:`rcs-emulator-text-xl rcs-emulator-font-semibold ${l?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.name}),t.description&&e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-mt-1 ${l?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:t.description})]}),e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-gap-4 rcs-emulator-px-4 rcs-emulator-pb-4",children:[t.phoneNumbers&&t.phoneNumbers.length>0&&e.jsx(E,{icon:"phone",label:"Call",isDark:l,brandColor:m,onClick:()=>{const i=t.phoneNumbers?.[0]?.number;i&&(window.location.href=`tel:${i}`)}}),t.websites&&t.websites.length>0&&e.jsx(E,{icon:"globe",label:"Website",isDark:l,brandColor:m,onClick:()=>{const i=t.websites?.[0]?.url;i&&window.open(i,"_blank","noopener,noreferrer")}}),t.emails&&t.emails.length>0&&e.jsx(E,{icon:"mail",label:"Contact",isDark:l,brandColor:m,onClick:()=>{const i=t.emails?.[0]?.email;i&&(window.location.href=`mailto:${i}`)}})]}),e.jsxs("div",{className:`rcs-emulator-tabs-container rcs-emulator-flex rcs-emulator-mx-4 rcs-emulator-rounded-lg rcs-emulator-overflow-hidden rcs-emulator-border ${l?"rcs-emulator-border-zinc-700 rcs-emulator-bg-zinc-800":"rcs-emulator-border-gray-200 rcs-emulator-bg-gray-100"}`,children:[e.jsx(U,{active:a==="info",onClick:()=>c("info"),isDark:l,brandColor:m,children:"Info"}),e.jsx(U,{active:a==="options",onClick:()=>c("options"),isDark:l,brandColor:m,children:"Options"})]}),e.jsx("div",{className:"rcs-emulator-p-4",children:a==="info"?e.jsx(Ee,{isDark:l,brandColor:m}):e.jsx(Re,{isDark:l})})]})]})}),E=n.memo(function({icon:r,label:t,isDark:o,brandColor:a,onClick:c}){const l={phone:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"}),globe:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"}),mail:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})};return e.jsxs("button",{onClick:c,className:`rcs-emulator-quick-action-btn rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-gap-2 rcs-emulator-px-6 rcs-emulator-py-3 rcs-emulator-rounded-xl rcs-emulator-border rcs-emulator-transition-colors ${o?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("svg",{className:"rcs-emulator-w-6 rcs-emulator-h-6",fill:"none",viewBox:"0 0 24 24",stroke:a,children:l[r]}),e.jsx("span",{className:`rcs-emulator-text-xs rcs-emulator-font-medium ${o?"rcs-emulator-text-zinc-300":"rcs-emulator-text-gray-600"}`,children:t})]})}),U=n.memo(function({active:r,onClick:t,isDark:o,brandColor:a,children:c}){return e.jsx("button",{onClick:t,className:`rcs-emulator-tab-btn rcs-emulator-flex-1 rcs-emulator-py-2-5 rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-transition-colors rcs-emulator-rounded-lg ${r?"rcs-emulator-active":`rcs-emulator-inactive ${o?"rcs-emulator-dark":"rcs-emulator-light"}`}`,style:r?{backgroundColor:a}:void 0,children:c})}),Ee=n.memo(function({isDark:r,brandColor:t}){const{businessInfo:o}=w();return o.phoneNumbers&&o.phoneNumbers.length>0||o.websites&&o.websites.length>0||o.emails&&o.emails.length>0?e.jsxs("div",{className:`rcs-emulator-profile-section rcs-emulator-rounded-xl rcs-emulator-overflow-hidden rcs-emulator-border rcs-emulator-divide-y ${r?"rcs-emulator-dark rcs-emulator-divide-zinc-800":"rcs-emulator-light rcs-emulator-divide-gray-200"}`,children:[o.phoneNumbers?.map((c,l)=>e.jsx(R,{icon:"phone",primary:c.number,secondary:c.label,isDark:r,brandColor:t,onClick:()=>window.location.href=`tel:${c.number}`},`phone-${l}`)),o.websites?.map((c,l)=>e.jsx(R,{icon:"globe",primary:c.url.replace(/^https?:\/\//,""),secondary:c.label||"Website",isDark:r,brandColor:t,onClick:()=>window.open(c.url,"_blank","noopener,noreferrer")},`web-${l}`)),o.emails?.map((c,l)=>e.jsx(R,{icon:"mail",primary:c.email,secondary:c.label||"Email",isDark:r,brandColor:t,onClick:()=>window.location.href=`mailto:${c.email}`},`email-${l}`))]}):e.jsx("div",{className:`rcs-emulator-text-center rcs-emulator-py-8 ${r?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,children:"No contact information available"})}),R=n.memo(function({icon:r,primary:t,secondary:o,isDark:a,onClick:c}){const l={phone:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z",globe:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9",mail:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"};return e.jsxs("button",{onClick:c,className:`rcs-emulator-list-item rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-4 rcs-emulator-px-4 rcs-emulator-py-3-5 rcs-emulator-text-left rcs-emulator-transition-colors ${a?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("svg",{className:`rcs-emulator-w-5 rcs-emulator-h-5 rcs-emulator-flex-shrink-0 ${a?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:l[r]})}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-min-w-0",children:[e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-truncate ${a?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t}),o&&e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-truncate ${a?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-500"}`,children:o})]})]})}),Re=n.memo(function({isDark:r}){return e.jsxs("div",{className:`rcs-emulator-profile-section rcs-emulator-rounded-xl rcs-emulator-overflow-hidden rcs-emulator-border rcs-emulator-divide-y ${r?"rcs-emulator-dark rcs-emulator-divide-zinc-800":"rcs-emulator-light rcs-emulator-divide-gray-200"}`,children:[e.jsx(B,{icon:"bell",label:"Notifications",isDark:r}),e.jsx(B,{icon:"block",label:"Block & report spam",isDark:r}),e.jsx(B,{icon:"info",label:"About RCS",isDark:r})]})}),B=n.memo(function({icon:r,label:t,isDark:o}){const a={bell:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",block:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"};return e.jsxs("button",{className:`rcs-emulator-list-item rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-4 rcs-emulator-px-4 rcs-emulator-py-3-5 rcs-emulator-text-left rcs-emulator-transition-colors ${o?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("svg",{className:`rcs-emulator-w-5 rcs-emulator-h-5 rcs-emulator-flex-shrink-0 ${o?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:a[r]})}),e.jsx("span",{className:`rcs-emulator-text-sm rcs-emulator-font-medium ${o?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t})]})}),D={FULL:"rcs-emulator-webview-full",TALL:"rcs-emulator-webview-tall",HALF:"rcs-emulator-webview-half"},K=n.memo(function(){const{theme:r,businessInfo:t,webView:o,closeWebView:a}=w(),[c,l]=n.useState(!0),[u,m]=n.useState(!1),i=r==="dark",h=t.brandColor||"#0084ff";n.useEffect(()=>{o?.url&&(l(!0),m(!1))},[o?.url]);const x=n.useCallback(()=>{l(!1)},[]),j=n.useCallback(()=>{l(!1),m(!0)},[]),g=k=>{try{return new URL(k).hostname}catch{return"Web Page"}};if(!o||!o.isOpen)return null;const{url:y,viewMode:b,title:v,postbackData:f}=o,d=v||g(y),p=b==="FULL",N=b==="TALL"||b==="HALF",M=D[b]||D.TALL;return e.jsxs("div",{className:`rcs-emulator-webview-overlay ${p?"rcs-emulator-webview-full":"rcs-emulator-webview-bottom-sheet"} rcs-emulator-absolute rcs-emulator-inset-0 rcs-emulator-z-50 rcs-emulator-flex rcs-emulator-flex-col ${p?"":"rcs-emulator-justify-end"} ${i?"rcs-emulator-bg-black-60":"rcs-emulator-bg-black-40"}`,role:"dialog","aria-modal":"true","aria-label":`WebView: ${d}`,"data-postback":f,"data-view-mode":b,children:[N&&e.jsx("button",{type:"button",className:"rcs-emulator-absolute rcs-emulator-inset-0 rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-cursor-default",onClick:a,"aria-label":"Close WebView"}),e.jsxs("div",{className:`rcs-emulator-relative rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-overflow-hidden ${i?"rcs-emulator-bg-zinc-900":"rcs-emulator-bg-white"} ${M} rcs-emulator-w-full ${N?"rcs-emulator-rounded-t-2xl rcs-emulator-shadow-2xl":""}`,style:{position:"relative",zIndex:1},children:[e.jsxs("header",{className:`rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-px-2 rcs-emulator-py-2 rcs-emulator-flex-shrink-0 rcs-emulator-border-b ${i?"rcs-emulator-bg-zinc-900 rcs-emulator-border-zinc-800":"rcs-emulator-bg-white rcs-emulator-border-gray-200"}`,children:[e.jsx("button",{type:"button",onClick:a,className:`rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-rounded-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-transition-colors ${i?"rcs-emulator-text-white rcs-emulator-hover-bg-zinc-800":"rcs-emulator-text-gray-700 rcs-emulator-hover-bg-gray-100"}`,"aria-label":"Close WebView",children:e.jsx("svg",{className:"rcs-emulator-w-6 rcs-emulator-h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-min-w-0",children:[e.jsx("h2",{className:`rcs-emulator-text-base rcs-emulator-font-medium rcs-emulator-truncate ${i?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:d}),e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-truncate ${i?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:g(y)})]}),e.jsx("button",{type:"button",className:`rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-rounded-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center ${i?"rcs-emulator-text-zinc-400 rcs-emulator-hover-bg-zinc-800":"rcs-emulator-text-gray-500 rcs-emulator-hover-bg-gray-100"}`,"aria-label":"More options",children:e.jsxs("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})]}),c&&e.jsx("div",{className:"rcs-emulator-absolute rcs-emulator-top-14 rcs-emulator-left-0 rcs-emulator-right-0 rcs-emulator-h-1 rcs-emulator-overflow-hidden",style:{backgroundColor:`${h}20`},children:e.jsx("div",{className:"rcs-emulator-h-full rcs-emulator-animate-pulse rcs-emulator-webview-loading-bar",style:{backgroundColor:h,width:"30%"}})}),u&&e.jsxs("div",{className:`rcs-emulator-flex-1 rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-p-6 rcs-emulator-text-center ${i?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:[e.jsx("svg",{className:"rcs-emulator-w-16 rcs-emulator-h-16 rcs-emulator-mb-4 rcs-emulator-opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-mb-2",children:"Unable to load page"}),e.jsx("p",{className:"rcs-emulator-text-xs rcs-emulator-opacity-75 rcs-emulator-mb-4",children:"This content cannot be displayed in the emulator"}),e.jsx("button",{type:"button",onClick:a,className:`rcs-emulator-px-4 rcs-emulator-py-2 rcs-emulator-rounded-full rcs-emulator-text-sm rcs-emulator-font-medium ${i?"rcs-emulator-bg-zinc-800 rcs-emulator-text-white rcs-emulator-hover-bg-zinc-700":"rcs-emulator-bg-gray-100 rcs-emulator-text-gray-700 rcs-emulator-hover-bg-gray-200"}`,children:"Go Back"})]}),!u&&e.jsx("div",{className:"rcs-emulator-flex-1 rcs-emulator-overflow-hidden",children:e.jsx("iframe",{src:y,title:d,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-border-0",onLoad:x,onError:j,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",referrerPolicy:"no-referrer-when-downgrade",loading:"lazy"})}),N&&e.jsx("div",{className:`rcs-emulator-h-2 rcs-emulator-flex-shrink-0 ${i?"rcs-emulator-bg-zinc-900":"rcs-emulator-bg-white"}`})]})]})}),Be=n.memo(function({onUnlock:r,messagePreview:t="New message"}){const{theme:o,businessInfo:a}=w(),[c,l]=n.useState(new Date),u=o==="dark";n.useEffect(()=>{const h=setInterval(()=>{l(new Date)},1e3);return()=>clearInterval(h)},[]);const m=c.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),i=c.toLocaleDateString([],{weekday:"short",month:"long",day:"numeric"});return e.jsxs("div",{className:`rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-h-full rcs-emulator-w-full rcs-emulator-select-none ${u?"rcs-emulator-bg-zinc-900":"rcs-emulator-bg-zinc-800"}`,children:[e.jsx("div",{className:"rcs-emulator-h-6"}),e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-mt-4",children:e.jsx("div",{className:"rcs-emulator-w-8 rcs-emulator-h-8 rcs-emulator-rounded-full rcs-emulator-bg-zinc-700 rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center",children:e.jsx("svg",{className:"rcs-emulator-w-4 rcs-emulator-h-4 rcs-emulator-text-zinc-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})})})}),e.jsx("div",{className:"rcs-emulator-mt-6 rcs-emulator-text-center",children:e.jsx("h1",{className:"rcs-emulator-text-5xl rcs-emulator-font-light rcs-emulator-text-white rcs-emulator-tracking-tight",children:m})}),e.jsx("div",{className:"rcs-emulator-mt-2 rcs-emulator-text-center",children:e.jsx("p",{className:"rcs-emulator-text-zinc-400 rcs-emulator-text-sm",children:i})}),e.jsx("div",{className:"rcs-emulator-h-24"}),e.jsx("div",{className:"rcs-emulator-px-4 rcs-emulator-pb-8",children:e.jsxs("button",{onClick:r,className:"rcs-emulator-notification-card rcs-emulator-w-full rcs-emulator-bg-white rcs-emulator-rounded-2xl rcs-emulator-p-3 rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-shadow-lg rcs-emulator-transition-transform rcs-emulator-active-scale-98 rcs-emulator-hover-shadow-xl",children:[e.jsx("div",{className:"rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-rounded-xl rcs-emulator-bg-zinc-900 rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-flex-shrink-0 rcs-emulator-overflow-hidden",children:a.logo?e.jsx("img",{src:a.logo,alt:a.name,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-text-white",children:e.jsxs("svg",{className:"rcs-emulator-w-7 rcs-emulator-h-7",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"6",r:"1"}),e.jsx("circle",{cx:"12",cy:"18",r:"1"}),e.jsx("circle",{cx:"6",cy:"12",r:"1"}),e.jsx("circle",{cx:"18",cy:"12",r:"1"}),e.jsx("circle",{cx:"8",cy:"8",r:"0.8"}),e.jsx("circle",{cx:"16",cy:"8",r:"0.8"}),e.jsx("circle",{cx:"8",cy:"16",r:"0.8"}),e.jsx("circle",{cx:"16",cy:"16",r:"0.8"}),e.jsx("circle",{cx:"6",cy:"6",r:"0.5"}),e.jsx("circle",{cx:"18",cy:"6",r:"0.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"0.5"}),e.jsx("circle",{cx:"18",cy:"18",r:"0.5"})]})})}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-text-left rcs-emulator-min-w-0",children:[e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-font-semibold rcs-emulator-text-gray-900 rcs-emulator-truncate rcs-emulator-mb-1",children:a.name}),e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-text-gray-500 rcs-emulator-truncate rcs-emulator-line-clamp-2 rcs-emulator-mb-1",children:t})]}),e.jsx("span",{className:"rcs-emulator-text-xs rcs-emulator-text-gray-400 rcs-emulator-flex-shrink-0",children:"now"})]})}),e.jsx("div",{className:"rcs-emulator-flex-1"}),e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-pb-2",children:e.jsx("div",{className:"rcs-emulator-home-indicator rcs-emulator-w-32 rcs-emulator-h-1 rcs-emulator-rounded-full rcs-emulator-bg-zinc-600"})})]})}),O={name:"Business",verified:!1},We=n.memo(function({flow:r,onUserReply:t,theme:o,device:a,businessInfo:c,showSuggestions:l}){const{state:u,handleReply:m,handleAction:i}=ie({flow:r,onUserReply:t,typingDelay:800}),[h,x]=n.useState(!1),j=n.useCallback(()=>{x(d=>!d)},[]),[g,y]=n.useState(null),b=n.useCallback(d=>{y({...d,isOpen:!0})},[]),v=n.useCallback(()=>{y(null)},[]),f=n.useCallback(d=>{if(!L(d))return;const p=P(d);if(p){b({url:p.url,viewMode:p.webviewViewMode||"TALL",title:p.description||"",postbackData:d.action.postback.data}),t({type:"action",postbackData:d.action.postback.data,displayText:d.action.displayText,timestamp:Date.now(),actionData:{type:"webview",url:p.url,viewMode:p.webviewViewMode||"TALL",description:p.description}});return}i(d)},[i,b,t]);return e.jsxs(F,{theme:o,device:a,businessInfo:c,state:u,showSuggestions:l,isProfileOpen:h,toggleProfile:j,onReply:m,onAction:f,webView:g,openWebView:b,closeWebView:v,children:[e.jsx(ze,{}),h&&e.jsx(Te,{}),e.jsx(K,{})]})}),X=n.memo(function({messages:r,jsonUrl:t,onUserReply:o,theme:a="light",device:c="android",businessInfo:l,className:u="",width:m=375,height:i=667,showSuggestions:h=!0,showLockScreen:x=!1}){const[j,g]=n.useState(x),y=n.useCallback(()=>{g(!1)},[]),{data:b,isLoading:v,error:f}=Z(t),d=t?b:r,p=n.useMemo(()=>d?J(d):!1,[d]),N=n.useMemo(()=>({...O,...l,name:l?.name||d?.name||O.name}),[l,d?.name]),M=n.useMemo(()=>d&&p?Y(d):"New message",[d,p]),k=a==="dark",$=k?"rcs-emulator-dark":"rcs-emulator-light",C=({children:A})=>e.jsx("div",{className:`rcs-emulator rcs-emulator-container ${$} ${u}`,style:{width:m,height:i},role:"application","aria-label":"RCS Message Emulator","data-theme":a,"data-device":c,children:A});return t&&v?e.jsx(C,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6",children:[e.jsx("div",{className:`rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-spinner rcs-emulator-mb-4 ${$}`}),e.jsx("p",{className:`rcs-emulator-text-sm ${k?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:"Loading conversation..."})]})}):t&&f?e.jsx(C,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6 rcs-emulator-text-center",children:[e.jsx("svg",{className:"rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-mb-4 rcs-emulator-text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("h3",{className:`rcs-emulator-text-lg rcs-emulator-font-medium rcs-emulator-mb-2 ${k?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"Failed to Load"}),e.jsx("p",{className:`rcs-emulator-text-sm ${k?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:f}),e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-mt-2 rcs-emulator-max-w-full ${k?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,style:{wordBreak:"break-all"},children:t})]})}):d?p?e.jsx(C,{children:j?e.jsx(F,{theme:a,device:c,businessInfo:N,state:{currentMessageId:null,chatHistory:[],isTyping:!1,error:null},showSuggestions:!1,isProfileOpen:!1,toggleProfile:()=>{},onReply:()=>{},onAction:()=>{},webView:null,openWebView:()=>{},closeWebView:()=>{},children:e.jsx(Be,{onUnlock:y,messagePreview:M})}):e.jsx(We,{flow:d,onUserReply:o,theme:a,device:c,businessInfo:N,showSuggestions:h})}):e.jsx(C,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6 rcs-emulator-text-center",children:[e.jsx("svg",{className:"rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-mb-4",style:{color:"#f59e0b"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("h3",{className:`rcs-emulator-text-lg rcs-emulator-font-medium rcs-emulator-mb-2 ${k?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"Invalid RBM JSON"}),e.jsx("p",{className:`rcs-emulator-text-sm ${k?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:"The conversation flow structure is not valid"})]})}):e.jsx(C,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6 rcs-emulator-text-center",children:[e.jsx("svg",{className:`rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-mb-4 ${k?"rcs-emulator-text-zinc-600":"rcs-emulator-text-gray-300"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),e.jsx("h3",{className:`rcs-emulator-text-lg rcs-emulator-font-medium rcs-emulator-mb-2 ${k?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"No Conversation Data"}),e.jsxs("p",{className:`rcs-emulator-text-sm ${k?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:["Provide either"," ",e.jsx("code",{className:`rcs-emulator-code-inline ${$}`,children:"messages"})," ","or"," ",e.jsx("code",{className:`rcs-emulator-code-inline ${$}`,children:"jsonUrl"})," ","prop"]})]})})});exports.RcsEmulator=X;exports.WebViewRenderer=K;exports.default=X;exports.getFirstMessagePreview=Y;exports.getWebViewConfig=P;exports.isSuggestedAction=L;exports.isSuggestedReply=W;exports.isWebViewAction=re;exports.useJsonFetch=Z;exports.validateConversationFlow=J;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),n=require("react");function P(s){return"reply"in s}function L(s){return"action"in s}function oe(s){if(!L(s))return!1;const{urlAction:r}=s.action;return r?.openUrl?.application==="WEBVIEW"}function Y(s){const{urlAction:r}=s.action;return r?.openUrl?.application==="WEBVIEW"?r.openUrl:null}const le={name:"Business",verified:!1},ce={currentMessageId:null,chatHistory:[],isTyping:!1,error:null},Q=n.createContext(null);function Z({children:s,theme:r,device:t,businessInfo:a,state:o,showSuggestions:c,isProfileOpen:l,toggleProfile:i,onReply:m,onAction:u,webView:d,openWebView:h,closeWebView:j,toast:v,showToast:w,onBack:b}){const f={theme:r,device:t,businessInfo:{...le,...a},state:{...ce,...o},showSuggestions:c,isProfileOpen:l,toggleProfile:i,handleReply:m,handleAction:u,webView:d,openWebView:h,closeWebView:j,toast:v,showToast:w,handleBack:b};return e.jsx(Q.Provider,{value:f,children:s})}function k(){const s=n.useContext(Q);if(!s)throw new Error("useEmulator must be used within an EmulatorProvider");return s}function K(s){const r=Object.values(s.messages);return r.find(t=>t.is_first)||r[0]||null}function E(s,r){return s.messages[r]||null}function O(s,r){const t=s.responses?.keyword?.keyword_response?.choices;return t&&t[r]?.next_message||null}function V(s,r){const t=s.parts,a=[],o=Date.now();for(let c=0;c<t.length;c++){const l=t[c],i=ne(l),u=c===t.length-1?ue(t):void 0;a.push({id:`${s.id}-${r}-${c}-${o+c}`,sender:"business",content:i,timestamp:o+c,suggestions:u})}return a}function ne(s){const r=s.RCSMessage;if(r.textMessage)return{type:"text",text:r.textMessage};const t=r.richcardMessage?.message?.generalPurposeCard;if(t)return{type:"richcard",card:U(t.content,t.layout)};const a=r.richcardMessage?.message?.generalPurposeCardCarousel;return a?{type:"carousel",cards:a.content.map(o=>U(o,{cardOrientation:a.layout.cardOrientation||"VERTICAL",cardWidth:a.layout.cardWidth}))}:{type:"text",text:"[Unsupported message type]"}}function U(s,r){const t=()=>{if(s.media){if(s.media.mediaUrl)return s.media.mediaUrl;if(s.media.contentInfo?.fileUrl)return s.media.contentInfo.fileUrl}},a=()=>{if(s.media){if(s.media.thumbnailUri)return s.media.thumbnailUri;if(s.media.contentInfo?.thumbnailUrl)return s.media.contentInfo.thumbnailUrl}},o=t();return{title:s.title,description:s.description,media:o?{url:o,height:ie(s.media?.height||"MEDIUM_HEIGHT"),thumbnailUrl:a()}:void 0,suggestions:s.suggestions,layout:{orientation:r.cardOrientation==="HORIZONTAL"?"horizontal":"vertical",width:r.cardWidth==="SMALL_WIDTH"?"small":"medium",imageAlignment:r.imageAlignment==="RIGHT"?"right":"left"}}}function ie(s){switch(s){case"SHORT_HEIGHT":return"short";case"TALL_HEIGHT":return"tall";default:return"medium"}}function ue(s){const r=[];for(const t of s){const a=t.RCSMessage;a.suggestedChipList?.suggestions&&r.push(...a.suggestedChipList.suggestions)}return r}function me(s){return{id:`user-${Date.now()}`,sender:"user",content:{type:"userReply",text:s},timestamp:Date.now()}}function X(s){if(!s||typeof s!="object")return!1;const r=s;if(typeof r.name!="string"||!r.messages||typeof r.messages!="object")return!1;const t=Object.values(r.messages);if(t.length===0)return!1;for(const a of t){if(!a||typeof a!="object")return!1;const o=a;if(typeof o.id!="string"||!Array.isArray(o.parts))return!1}return!0}function ee(s){const r=K(s);if(!r||!r.parts.length)return"New message";const a=r.parts[0].RCSMessage;if(a.textMessage)return a.textMessage.slice(0,50)+(a.textMessage.length>50?"...":"");const o=a.richcardMessage?.message?.generalPurposeCard;if(o?.content.title)return o.content.title;const c=a.richcardMessage?.message?.generalPurposeCardCarousel;return c?.content[0]?.title?c.content[0].title:"New message"}const re={currentMessageId:null,chatHistory:[],isTyping:!1,error:null};function de(s,r){switch(r.type){case"INIT":return{...s,currentMessageId:r.messageId,error:null};case"ADD_BUSINESS_MESSAGE":return{...s,chatHistory:[...s.chatHistory,r.message],isTyping:!1};case"ADD_USER_REPLY":{const t=me(r.text),a=s.chatHistory.map((o,c)=>c===s.chatHistory.length-1?{...o,suggestions:void 0}:o);return{...s,chatHistory:[...a,t]}}case"SET_TYPING":return{...s,isTyping:r.isTyping};case"NAVIGATE_TO":return{...s,currentMessageId:r.messageId};case"SET_ERROR":return{...s,error:r.error,isTyping:!1};case"RESET":return re;default:return s}}function he({flow:s,onUserReply:r,typingDelay:t=800}){const[a,o]=n.useReducer(de,re),c=n.useRef(0),l=n.useRef(!1);n.useEffect(()=>{if(l.current)return;l.current=!0;const d=K(s);if(!d){o({type:"SET_ERROR",error:"No first message found in conversation flow"});return}o({type:"INIT",messageId:d.id}),V(d,c.current++).forEach(j=>{o({type:"ADD_BUSINESS_MESSAGE",message:j})})},[s]);const i=n.useCallback(d=>{if(!P(d))return;const{displayText:h,postback:j}=d.reply,v=j.data;o({type:"ADD_USER_REPLY",text:h,postbackData:v});const w={type:"reply",postbackData:v,displayText:h,timestamp:Date.now()};r(w);const b=a.currentMessageId?E(s,a.currentMessageId):null;if(!b){o({type:"SET_ERROR",error:"Current message not found"});return}const f=O(b,v);if(!f)return;const p=E(s,f);if(!p){o({type:"SET_ERROR",error:`Next message "${f}" not found`});return}o({type:"SET_TYPING",isTyping:!0}),o({type:"NAVIGATE_TO",messageId:f}),setTimeout(()=>{V(p,c.current++).forEach(g=>{o({type:"ADD_BUSINESS_MESSAGE",message:g})})},t)},[s,a.currentMessageId,r,t]),m=n.useCallback(d=>{if(!L(d))return;const{displayText:h,postback:j,openUrlAction:v}=d.action,w=j.data;if(v){const f={type:"action",postbackData:w,displayText:h,timestamp:Date.now(),actionData:{type:"openUrl",url:v.url}};r(f),window.open(v.url,"_blank","noopener,noreferrer")}const b=a.currentMessageId?E(s,a.currentMessageId):null;if(b){const f=O(b,w);if(f){const p=E(s,f);p&&(o({type:"ADD_USER_REPLY",text:h,postbackData:w}),o({type:"SET_TYPING",isTyping:!0}),o({type:"NAVIGATE_TO",messageId:f}),setTimeout(()=>{V(p,c.current++).forEach(g=>{o({type:"ADD_BUSINESS_MESSAGE",message:g})})},t))}}},[s,a.currentMessageId,r,t]),u=n.useCallback(()=>{l.current=!1,c.current=0,o({type:"RESET"})},[]);return{state:a,handleReply:i,handleAction:m,reset:u}}function te(s){const[r,t]=n.useState(null),[a,o]=n.useState(!1),[c,l]=n.useState(null),i=n.useCallback(async()=>{if(!s){t(null),l(null);return}o(!0),l(null);try{const m=await fetch(s,{method:"GET",headers:{Accept:"application/json"}});if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);const u=await m.json();if(!u||typeof u!="object")throw new Error("Invalid JSON: Expected an object");if(!u.messages||typeof u.messages!="object")throw new Error("Invalid RBM JSON: Missing 'messages' object");t(u)}catch(m){const u=m instanceof Error?m.message:"Failed to fetch JSON";l(u),t(null)}finally{o(!1)}},[s]);return n.useEffect(()=>{i()},[i]),{data:r,isLoading:a,error:c,refetch:i}}function xe(s){const r=n.useRef(null);return n.useEffect(()=>{r.current&&r.current.scrollTo({top:r.current.scrollHeight,behavior:"smooth"})},[s]),r}const fe=n.memo(function(){const{theme:r,businessInfo:t,toggleProfile:a,handleBack:o}=k(),c=r==="dark",l=c?"rcs-emulator-dark":"rcs-emulator-light",i=t.brandColor||"#1A73E8";return e.jsxs("header",{className:`rcs-emulator-header ${l}`,role:"banner","aria-label":`Chat with ${t.name}`,children:[e.jsx("button",{type:"button",onClick:o||void 0,className:`rcs-emulator-icon-btn rcs-emulator-p-1-5 rcs-emulator--ml-1 ${l} ${c?"rcs-emulator-text-white":"rcs-emulator-text-gray-700"}`,"aria-label":"Go back",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsxs("button",{onClick:a,className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-2-5 rcs-emulator-flex-1 rcs-emulator-min-w-0 rcs-emulator-text-left rcs-emulator-bg-transparent",style:{background:"transparent"},"aria-label":"View business info",children:[e.jsx("div",{className:`rcs-emulator-logo-avatar rcs-emulator-w-9 rcs-emulator-h-9 ${l}`,style:{backgroundColor:t.logo?void 0:i},children:t.logo?e.jsx("img",{src:t.logo,alt:`${t.name} logo`,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-text-sm rcs-emulator-font-bold rcs-emulator-text-white",children:t.name.charAt(0).toUpperCase()})}),e.jsx("h1",{className:`rcs-emulator-text-base rcs-emulator-font-medium rcs-emulator-truncate ${c?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.name})]}),e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-0-5",children:[t.verified&&e.jsx("button",{type:"button",className:`rcs-emulator-icon-btn rcs-emulator-p-2 ${l}`,"aria-label":"Verified business",children:e.jsxs("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:c?"#9ca3af":"#6b7280",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9 12l2 2 4-4",stroke:"#3b82f6",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("button",{type:"button",className:`rcs-emulator-icon-btn rcs-emulator-p-2 ${l} ${c?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,"aria-label":"More options",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]})]})}),pe=n.memo(function(){const{theme:r,businessInfo:t}=k(),a=r==="dark",o=a?"rcs-emulator-dark":"rcs-emulator-light",c=t.brandColor||"#0084ff";return e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-py-4 rcs-emulator-px-4",children:[e.jsxs("div",{className:"rcs-emulator-relative rcs-emulator-mb-3",children:[e.jsx("div",{className:`rcs-emulator-logo-avatar rcs-emulator-w-16 rcs-emulator-h-16 rcs-emulator-shadow-lg ${o}`,style:{backgroundColor:t.logo?void 0:c},children:t.logo?e.jsx("img",{src:t.logo,alt:`${t.name} logo`,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-text-2xl rcs-emulator-font-bold rcs-emulator-text-white",children:t.name.charAt(0).toUpperCase()})}),t.verified&&e.jsx("div",{className:"rcs-emulator-verified-badge",children:e.jsx("svg",{className:"rcs-emulator-w-3 rcs-emulator-h-3 rcs-emulator-text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"})})})]}),e.jsx("h1",{className:`rcs-emulator-text-lg rcs-emulator-font-semibold rcs-emulator-text-center ${a?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.name}),t.description&&e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-text-center rcs-emulator-mt-0-5 ${a?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:t.description})]})}),ge=n.memo(function({text:r,sender:t,timestamp:a}){const{theme:o,businessInfo:c}=k(),i=o==="dark"?"rcs-emulator-dark":"rcs-emulator-light",m=t==="business",u=c.brandColor||"#1A73E8",d=new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return m?e.jsxs("div",{className:"rcs-emulator-max-w-90 rcs-emulator-flex rcs-emulator-flex-col",children:[e.jsx("div",{className:`rcs-emulator-message-bubble rcs-emulator-business ${i}`,children:r}),e.jsx("span",{className:"rcs-emulator-sr-only",children:d})]}):e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-items-end rcs-emulator-gap-1-5 rcs-emulator-max-w-85 rcs-emulator-ml-auto",children:[e.jsx("div",{className:"rcs-emulator-message-bubble rcs-emulator-user",style:{backgroundColor:u},children:r}),e.jsx("div",{className:"rcs-emulator-delivery-status",style:{backgroundColor:u},children:e.jsx("svg",{className:"rcs-emulator-w-3 rcs-emulator-h-3 rcs-emulator-text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"rcs-emulator-sr-only",children:d})]})}),je=n.memo(function({text:r,timestamp:t}){const{businessInfo:a}=k(),o=a.brandColor||"#1A73E8",c=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-items-end rcs-emulator-gap-1-5 rcs-emulator-max-w-85 rcs-emulator-ml-auto",children:[e.jsx("div",{className:"rcs-emulator-message-bubble rcs-emulator-user rcs-emulator-shadow-sm",style:{backgroundColor:o,color:"white"},children:r}),e.jsx("div",{className:"rcs-emulator-delivery-status",style:{backgroundColor:o},children:e.jsx("svg",{className:"rcs-emulator-w-3 rcs-emulator-h-3 rcs-emulator-text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:"rcs-emulator-sr-only",children:c})]})}),be=n.memo(function({card:r,timestamp:t}){const{theme:a,handleReply:o,handleAction:c}=k(),l=a==="dark",i=l?"rcs-emulator-dark":"rcs-emulator-light",m=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),u=h=>{"reply"in h?o(h):c(h)},d={short:"rcs-emulator-h-36",medium:"rcs-emulator-h-44",tall:"rcs-emulator-h-56"};return e.jsxs("div",{className:"rcs-emulator-w-full",children:[e.jsxs("div",{className:`rcs-emulator-rich-card ${i}`,children:[r.media&&e.jsx("div",{className:`rcs-emulator-w-full rcs-emulator-overflow-hidden rcs-emulator-media-placeholder ${d[r.media.height]} ${l?"rcs-emulator-dark":"rcs-emulator-light"}`,style:{borderRadius:"12px 12px 0 0"},children:e.jsx("img",{src:r.media.url,alt:r.title||"Rich card media",className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover",loading:"lazy",onError:h=>{const j=h.target;j.style.display="none"}})}),e.jsxs("div",{className:"rcs-emulator-p-4",children:[r.title&&e.jsx("h3",{className:`rcs-emulator-text-base rcs-emulator-font-semibold rcs-emulator-leading-snug rcs-emulator-card-title ${l?"rcs-emulator-dark":"rcs-emulator-light"}`,children:r.title}),r.description&&e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-leading-relaxed rcs-emulator-mt-1-5 rcs-emulator-card-subtitle ${l?"rcs-emulator-dark":"rcs-emulator-light"}`,children:r.description}),r.suggestions&&r.suggestions.length>0&&e.jsx("div",{className:`rcs-emulator-card-actions rcs-emulator-mt-4 rcs-emulator-divide-y ${l?"rcs-emulator-divide-zinc-700":"rcs-emulator-divide-gray-100"} ${i}`,children:r.suggestions.map((h,j)=>e.jsx(Ne,{suggestion:h,onClick:()=>u(h),isDark:l},j))})]})]}),e.jsx("span",{className:"rcs-emulator-sr-only",children:m})]})}),T="rcs-emulator-w-5 rcs-emulator-h-5 rcs-emulator-text-gray-400",ve=()=>e.jsx("svg",{className:T,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),we=()=>e.jsx("svg",{className:T,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),ye=()=>e.jsxs("svg",{className:T,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),ke=()=>e.jsx("svg",{className:T,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),G=()=>e.jsx("svg",{className:T,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),Ne=n.memo(function({suggestion:r,onClick:t,isDark:a}){const o=L(r),c=o?r.action.displayText:r.reply.displayText,l=()=>{if(!o)return e.jsx(G,{});const{action:i}=r;return i.urlAction||i.openUrlAction?e.jsx(ve,{}):i.dialerAction||i.dialAction?e.jsx(we,{}):i.mapAction||i.viewLocationAction?e.jsx(ye,{}):i.calendarAction||i.createCalendarEventAction?e.jsx(ke,{}):e.jsx(G,{})};return e.jsxs("button",{onClick:t,className:`rcs-emulator-list-item ${a?"rcs-emulator-dark":"rcs-emulator-light"}`,style:{gap:"0.75rem",padding:"0.75rem 1rem"},children:[e.jsx("span",{className:"rcs-emulator-flex-shrink-0",children:l()}),e.jsx("span",{className:`rcs-emulator-text-sm ${a?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:c})]})}),Ce=n.memo(function({cards:r,timestamp:t}){const{theme:a,handleReply:o,handleAction:c}=k(),l=n.useRef(null),[i,m]=n.useState(!1),[u,d]=n.useState(r.length>1),h=a==="dark",j=h?"rcs-emulator-dark":"rcs-emulator-light",v=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),w=p=>{"reply"in p?o(p):c(p)},b=n.useCallback(()=>{if(l.current){const{scrollLeft:p,scrollWidth:N,clientWidth:g}=l.current;m(p>0),d(p<N-g-10)}},[]),f=p=>{l.current&&l.current.scrollBy({left:p==="left"?-200:200,behavior:"smooth"})};return e.jsxs("div",{className:"rcs-emulator-w-full rcs-emulator--mx-3",children:[e.jsxs("div",{className:"rcs-emulator-relative",children:[i&&e.jsx("button",{onClick:()=>f("left"),className:`rcs-emulator-carousel-arrow rcs-emulator-left ${j}`,"aria-label":"Scroll left",children:e.jsx("svg",{className:"rcs-emulator-w-4 rcs-emulator-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("div",{ref:l,onScroll:b,className:"rcs-emulator-flex rcs-emulator-gap-2-5 rcs-emulator-overflow-x-auto rcs-emulator-py-1 rcs-emulator-px-3 rcs-emulator-snap-x rcs-emulator-scrollbar-hide",children:r.map((p,N)=>e.jsx(Me,{card:p,isDark:h,onSuggestionClick:w},N))}),u&&e.jsx("button",{onClick:()=>f("right"),className:`rcs-emulator-carousel-arrow rcs-emulator-right ${j}`,"aria-label":"Scroll right",children:e.jsx("svg",{className:"rcs-emulator-w-4 rcs-emulator-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("span",{className:"rcs-emulator-sr-only",children:v})]})}),z="rcs-emulator-w-4 rcs-emulator-h-4 rcs-emulator-text-gray-400",Le=s=>{if(!L(s))return e.jsx("svg",{className:z,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});const{action:r}=s;return r.urlAction||r.openUrlAction?e.jsx("svg",{className:z,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}):r.dialerAction||r.dialAction?e.jsx("svg",{className:z,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}):r.mapAction||r.viewLocationAction?e.jsxs("svg",{className:z,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}):r.calendarAction||r.createCalendarEventAction?e.jsx("svg",{className:z,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e.jsx("svg",{className:z,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})},Me=n.memo(function({card:r,isDark:t,onSuggestionClick:a}){const o=r.layout.width==="small"?"rcs-emulator-w-44":"rcs-emulator-w-52",c=t?"rcs-emulator-dark":"rcs-emulator-light";return e.jsxs("div",{className:`rcs-emulator-carousel-card ${o} ${c}`,children:[r.media&&e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-32 rcs-emulator-bg-gray-200 rcs-emulator-overflow-hidden",children:e.jsx("img",{src:r.media.url,alt:r.title||"Carousel card media",className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover",loading:"lazy"})}),e.jsxs("div",{className:"rcs-emulator-p-3",children:[r.title&&e.jsx("h4",{className:`rcs-emulator-text-sm rcs-emulator-font-semibold rcs-emulator-leading-tight rcs-emulator-mb-1 rcs-emulator-line-clamp-2 ${t?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:r.title}),r.description&&e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-leading-relaxed rcs-emulator-line-clamp-3 ${t?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-700"}`,children:r.description}),r.suggestions&&r.suggestions.length>0&&e.jsx("div",{className:`rcs-emulator-carousel-actions rcs-emulator-mt-3 rcs-emulator-divide-y ${t?"rcs-emulator-divide-zinc-600":"rcs-emulator-divide-gray-100"} ${c}`,children:r.suggestions.map((l,i)=>{const u=L(l)?l.action.displayText:l.reply.displayText;return e.jsxs("button",{onClick:()=>a(l),className:`rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-2 rcs-emulator-px-3 rcs-emulator-py-2-5 rcs-emulator-text-xs rcs-emulator-transition-colors rcs-emulator-text-left rcs-emulator-border-none ${t?"rcs-emulator-hover-bg-zinc-700 rcs-emulator-text-white":"rcs-emulator-hover-bg-gray-50 rcs-emulator-text-gray-900"}`,children:[e.jsx("span",{className:"rcs-emulator-flex-shrink-0",children:Le(l)}),e.jsx("span",{className:"rcs-emulator-truncate",children:u})]},i)})})]})]})}),$e={text:({content:s,sender:r,timestamp:t})=>s.type!=="text"?null:e.jsx(ge,{text:s.text,sender:r,timestamp:t}),userReply:({content:s,timestamp:r})=>s.type!=="userReply"?null:e.jsx(je,{text:s.text,timestamp:r}),richcard:({content:s,timestamp:r})=>s.type!=="richcard"?null:e.jsx(be,{card:s.card,timestamp:r}),carousel:({content:s,timestamp:r})=>s.type!=="carousel"?null:e.jsx(Ce,{cards:s.cards,timestamp:r})},Ae=n.memo(function({message:r,isLast:t}){const{content:a,sender:o,timestamp:c}=r,l=$e[a.type];return l?e.jsx(l,{content:a,sender:o,timestamp:c,showSuggestions:t&&o==="business"}):(console.warn(`Unknown message type: ${a.type}`),e.jsx("div",{className:"rcs-emulator-px-4 rcs-emulator-py-2 rcs-emulator-text-gray-500 rcs-emulator-text-sm rcs-emulator-italic",children:"[Unsupported message type]"}))}),Ie=n.memo(function(){const{theme:r}=k(),t=r==="dark";return e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-items-start rcs-emulator-gap-2 rcs-emulator-px-4 rcs-emulator-py-2",role:"status","aria-label":"Business is typing",children:e.jsxs("div",{className:`rcs-emulator-inline-flex rcs-emulator-items-center rcs-emulator-gap-1 rcs-emulator-px-4 rcs-emulator-py-3 rcs-emulator-rounded-2xl rcs-emulator-rounded-bl-sm rcs-emulator-typing-bubble ${t?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("span",{className:`rcs-emulator-typing-dot rcs-emulator-w-2 rcs-emulator-h-2 rcs-emulator-rounded-full ${t?"rcs-emulator-bg-zinc-500":"rcs-emulator-bg-gray-400"}`}),e.jsx("span",{className:`rcs-emulator-typing-dot rcs-emulator-w-2 rcs-emulator-h-2 rcs-emulator-rounded-full ${t?"rcs-emulator-bg-zinc-500":"rcs-emulator-bg-gray-400"}`}),e.jsx("span",{className:`rcs-emulator-typing-dot rcs-emulator-w-2 rcs-emulator-h-2 rcs-emulator-rounded-full ${t?"rcs-emulator-bg-zinc-500":"rcs-emulator-bg-gray-400"}`})]})})}),ze=n.memo(function(){const{theme:r,state:t}=k(),{chatHistory:a,isTyping:o}=t,c=r==="dark",l=c?"rcs-emulator-dark":"rcs-emulator-light";return e.jsxs("div",{className:"rcs-emulator-px-3 rcs-emulator-pb-3 rcs-emulator-space-y-3",role:"log","aria-label":"Chat messages","aria-live":"polite",children:[a.length>0&&e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-py-2",children:e.jsx("span",{className:`rcs-emulator-text-xs rcs-emulator-font-medium rcs-emulator-px-3 rcs-emulator-py-1 ${c?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-500"}`,children:"Today"})}),e.jsxs("div",{className:`rcs-emulator-messages-container ${l}`,children:[a.length===0&&!o&&e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-py-12",children:e.jsx("p",{className:`rcs-emulator-text-sm ${c?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,children:"No messages yet"})}),e.jsxs("div",{className:"rcs-emulator-p-3 rcs-emulator-space-y-3",children:[a.map((i,m)=>e.jsx("div",{className:`rcs-emulator-flex ${i.sender==="user"?"rcs-emulator-justify-end":"rcs-emulator-justify-start"}`,children:e.jsx(Ae,{message:i,isLast:m===a.length-1&&!o})},i.id)),o&&e.jsx(Ie,{})]})]})]})}),Te=n.memo(function({suggestion:r,onClick:t,variant:a="bar"}){const{theme:o,businessInfo:c}=k(),l=o==="dark",i=L(r),m=i?r.action.displayText:r.reply.displayText,u=i?We(r):null,d=c.brandColor||"#1A73E8",h=l?"rcs-emulator-dark":"rcs-emulator-light";return a==="bar"?e.jsxs("button",{type:"button",onClick:t,className:`rcs-emulator-suggestion-chip rcs-emulator-inline-flex rcs-emulator-items-center rcs-emulator-gap-2 rcs-emulator-px-4 rcs-emulator-py-2 rcs-emulator-rounded-full rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-whitespace-nowrap rcs-emulator-transition-colors rcs-emulator-flex-shrink-0 rcs-emulator-border ${h}`,"aria-label":i?`${Ve(r)}: ${m}`:m,children:[u&&e.jsx("span",{style:{color:d},children:e.jsx(u,{className:"rcs-emulator-w-4 rcs-emulator-h-4"})}),e.jsx("span",{className:"rcs-emulator-text-sm rcs-emulator-font-medium",children:m})]}):a==="card"?e.jsxs("button",{type:"button",onClick:t,className:`rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-px-3 rcs-emulator-py-2-5 rcs-emulator-text-left rcs-emulator-transition-colors rcs-emulator-rounded-lg rcs-emulator-list-item rcs-emulator-border-none ${h}`,children:[u&&e.jsx("div",{className:"rcs-emulator-w-8 rcs-emulator-h-8 rcs-emulator-rounded-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-flex-shrink-0",style:{backgroundColor:`${d}15`},children:e.jsx(u,{className:"rcs-emulator-w-4 rcs-emulator-h-4",style:{color:d}})}),e.jsx("span",{className:`rcs-emulator-text-sm rcs-emulator-font-medium ${l?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:m})]}):e.jsx("button",{type:"button",onClick:t,className:`rcs-emulator-w-full rcs-emulator-px-3 rcs-emulator-py-2 rcs-emulator-rounded-lg rcs-emulator-text-xs rcs-emulator-font-medium rcs-emulator-text-center rcs-emulator-border rcs-emulator-transition-colors ${l?"rcs-emulator-border-zinc-600 rcs-emulator-hover-bg-zinc-700 rcs-emulator-text-white":"rcs-emulator-border-gray-300 rcs-emulator-hover-bg-gray-50 rcs-emulator-text-gray-900"}`,children:m})}),Se=({className:s,style:r})=>e.jsx("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),Ee=({className:s,style:r})=>e.jsx("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),Be=({className:s,style:r})=>e.jsxs("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),Re=({className:s,style:r})=>e.jsx("svg",{className:s,style:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})});function We(s){if(!L(s))return null;const{action:r}=s;return r.openUrlAction||r.urlAction?Se:r.dialAction||r.dialerAction?Ee:r.shareLocationAction||r.viewLocationAction||r.mapAction?Be:r.createCalendarEventAction||r.calendarAction?Re:null}function Ve(s){if(!L(s))return"Reply";const{action:r}=s;return r.openUrlAction||r.urlAction?"Open link":r.dialAction||r.dialerAction?"Call":r.shareLocationAction?"Share location":r.viewLocationAction||r.mapAction?"View location":r.createCalendarEventAction||r.calendarAction?"Add to calendar":"Action"}const He=n.memo(function({suggestions:r}){const{theme:t,handleReply:a,handleAction:o}=k(),c=t==="dark";if(!r||r.length===0)return null;const l=i=>{P(i)?a(i):L(i)&&o(i)};return e.jsx("div",{className:`rcs-emulator-suggestions-bar rcs-emulator-px-3 rcs-emulator-py-2 ${c?"rcs-emulator-dark":"rcs-emulator-light"}`,role:"group","aria-label":"Quick replies",children:e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-gap-2 rcs-emulator-overflow-x-auto rcs-emulator-pb-1 rcs-emulator--mx-1 rcs-emulator-px-1 rcs-emulator-scrollbar-hide",children:r.map((i,m)=>e.jsx(Te,{suggestion:i,onClick:()=>l(i),variant:"bar"},m))})})}),De=n.memo(function(){const{theme:r,state:t,showSuggestions:a}=k(),{chatHistory:o,isTyping:c,error:l}=t,i=xe([o.length,c]),m=r==="dark",u=m?"rcs-emulator-dark":"rcs-emulator-light",d=o[o.length-1],h=a&&d?.sender==="business"&&!c?d.suggestions:void 0;return e.jsxs("div",{className:`rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-h-full rcs-emulator-w-full rcs-emulator-overflow-hidden ${m?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx(fe,{}),l&&e.jsx("div",{className:"rcs-emulator-error-alert",role:"alert",children:e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-text-red-500",children:l})}),e.jsxs("div",{ref:i,className:"rcs-emulator-flex-1 rcs-emulator-overflow-y-auto rcs-emulator-scrollbar",children:[e.jsx(pe,{}),e.jsx(ze,{})]}),h&&h.length>0&&e.jsx(He,{suggestions:h}),e.jsxs("div",{className:`rcs-emulator-input-area ${u}`,children:[e.jsx("button",{type:"button",className:`rcs-emulator-add-btn ${u}`,"aria-label":"Add attachment",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),e.jsxs("div",{className:`rcs-emulator-input-container ${u}`,children:[e.jsx("span",{className:`rcs-emulator-flex-1 rcs-emulator-text-sm ${m?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,children:"RCS message"}),e.jsx("button",{type:"button",className:`rcs-emulator-p-1 ${m?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,"aria-label":"Emoji",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("button",{type:"button",className:`rcs-emulator-p-1 ${m?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,"aria-label":"Attach image",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),e.jsx("button",{type:"button",className:"rcs-emulator-voice-btn","aria-label":"Voice message",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1 1.93c-3.94-.49-7-3.85-7-7.93h2c0 3.31 2.69 6 6 6s6-2.69 6-6h2c0 4.08-3.06 7.44-7 7.93V20h4v2H8v-2h4v-4.07z"})})})]})]})}),_e=n.memo(function(){const{theme:r,businessInfo:t,toggleProfile:a}=k(),[o,c]=n.useState("info"),l=r==="dark",i=t.bannerImage||"https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=800&q=80",m=t.brandColor||"#0084ff";return e.jsxs("div",{className:`rcs-emulator-absolute rcs-emulator-inset-0 rcs-emulator-z-50 rcs-emulator-flex rcs-emulator-flex-col ${l?"rcs-emulator-bg-zinc-950":"rcs-emulator-bg-white"}`,children:[e.jsxs("header",{className:`rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-px-4 rcs-emulator-py-3 rcs-emulator-border-b ${l?"rcs-emulator-bg-zinc-900 rcs-emulator-border-zinc-800":"rcs-emulator-bg-white rcs-emulator-border-gray-200"}`,children:[e.jsx("button",{onClick:a,className:`rcs-emulator-p-1-5 rcs-emulator--ml-1-5 rcs-emulator-rounded-full rcs-emulator-transition-colors ${l?"rcs-emulator-hover-bg-zinc-800 rcs-emulator-text-white":"rcs-emulator-hover-bg-gray-100 rcs-emulator-text-gray-900"}`,"aria-label":"Go back",children:e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("span",{className:`rcs-emulator-text-base rcs-emulator-font-medium ${l?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"Info & options"})]}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-overflow-y-auto",children:[e.jsx("div",{className:"rcs-emulator-relative rcs-emulator-h-40 rcs-emulator-bg-gray-200",children:e.jsx("img",{src:i,alt:"Business banner",className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"})}),e.jsx("div",{className:"rcs-emulator-relative rcs-emulator-px-4",children:e.jsx("div",{className:`rcs-emulator-absolute rcs-emulator--top-10 rcs-emulator-left-1-2 rcs-emulator--translate-x-1-2 rcs-emulator-w-20 rcs-emulator-h-20 rcs-emulator-rounded-full rcs-emulator-overflow-hidden rcs-emulator-border-4 ${l?"rcs-emulator-border-zinc-950 rcs-emulator-bg-zinc-800":"rcs-emulator-border-white rcs-emulator-bg-gray-100"} rcs-emulator-shadow-lg`,children:t.logo?e.jsx("img",{src:t.logo,alt:`${t.name} logo`,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-text-2xl rcs-emulator-font-bold rcs-emulator-text-white",style:{backgroundColor:m},children:t.name.charAt(0).toUpperCase()})})}),e.jsxs("div",{className:"rcs-emulator-pt-12 rcs-emulator-pb-4 rcs-emulator-px-4 rcs-emulator-text-center",children:[e.jsx("h1",{className:`rcs-emulator-text-xl rcs-emulator-font-semibold ${l?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.name}),t.description&&e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-mt-1 ${l?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:t.description})]}),e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-gap-4 rcs-emulator-px-4 rcs-emulator-pb-4",children:[t.phoneNumbers&&t.phoneNumbers.length>0&&e.jsx(H,{icon:"phone",label:"Call",isDark:l,brandColor:m,onClick:()=>{const u=t.phoneNumbers?.[0]?.number;u&&(window.location.href=`tel:${u}`)}}),t.websites&&t.websites.length>0&&e.jsx(H,{icon:"globe",label:"Website",isDark:l,brandColor:m,onClick:()=>{const u=t.websites?.[0]?.url;u&&window.open(u,"_blank","noopener,noreferrer")}}),t.emails&&t.emails.length>0&&e.jsx(H,{icon:"mail",label:"Contact",isDark:l,brandColor:m,onClick:()=>{const u=t.emails?.[0]?.email;u&&(window.location.href=`mailto:${u}`)}})]}),e.jsxs("div",{className:`rcs-emulator-tabs-container rcs-emulator-flex rcs-emulator-mx-4 rcs-emulator-rounded-lg rcs-emulator-overflow-hidden rcs-emulator-border ${l?"rcs-emulator-border-zinc-700 rcs-emulator-bg-zinc-800":"rcs-emulator-border-gray-200 rcs-emulator-bg-gray-100"}`,children:[e.jsx(F,{active:o==="info",onClick:()=>c("info"),isDark:l,brandColor:m,children:"Info"}),e.jsx(F,{active:o==="options",onClick:()=>c("options"),isDark:l,brandColor:m,children:"Options"})]}),e.jsx("div",{className:"rcs-emulator-p-4",children:o==="info"?e.jsx(Pe,{isDark:l,brandColor:m}):e.jsx(Oe,{isDark:l})})]})]})}),H=n.memo(function({icon:r,label:t,isDark:a,brandColor:o,onClick:c}){const l={phone:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"}),globe:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"}),mail:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})};return e.jsxs("button",{onClick:c,className:`rcs-emulator-quick-action-btn rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-gap-2 rcs-emulator-px-6 rcs-emulator-py-3 rcs-emulator-rounded-xl rcs-emulator-border rcs-emulator-transition-colors ${a?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("svg",{className:"rcs-emulator-w-6 rcs-emulator-h-6",fill:"none",viewBox:"0 0 24 24",stroke:o,children:l[r]}),e.jsx("span",{className:`rcs-emulator-text-xs rcs-emulator-font-medium ${a?"rcs-emulator-text-zinc-300":"rcs-emulator-text-gray-600"}`,children:t})]})}),F=n.memo(function({active:r,onClick:t,isDark:a,brandColor:o,children:c}){return e.jsx("button",{onClick:t,className:`rcs-emulator-tab-btn rcs-emulator-flex-1 rcs-emulator-py-2-5 rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-transition-colors rcs-emulator-rounded-lg ${r?"rcs-emulator-active":`rcs-emulator-inactive ${a?"rcs-emulator-dark":"rcs-emulator-light"}`}`,style:r?{backgroundColor:o}:void 0,children:c})}),Pe=n.memo(function({isDark:r,brandColor:t}){const{businessInfo:a}=k();return a.phoneNumbers&&a.phoneNumbers.length>0||a.websites&&a.websites.length>0||a.emails&&a.emails.length>0?e.jsxs("div",{className:`rcs-emulator-profile-section rcs-emulator-rounded-xl rcs-emulator-overflow-hidden rcs-emulator-border rcs-emulator-divide-y ${r?"rcs-emulator-dark rcs-emulator-divide-zinc-800":"rcs-emulator-light rcs-emulator-divide-gray-200"}`,children:[a.phoneNumbers?.map((c,l)=>e.jsx(D,{icon:"phone",primary:c.number,secondary:c.label,isDark:r,brandColor:t,onClick:()=>window.location.href=`tel:${c.number}`},`phone-${l}`)),a.websites?.map((c,l)=>e.jsx(D,{icon:"globe",primary:c.url.replace(/^https?:\/\//,""),secondary:c.label||"Website",isDark:r,brandColor:t,onClick:()=>window.open(c.url,"_blank","noopener,noreferrer")},`web-${l}`)),a.emails?.map((c,l)=>e.jsx(D,{icon:"mail",primary:c.email,secondary:c.label||"Email",isDark:r,brandColor:t,onClick:()=>window.location.href=`mailto:${c.email}`},`email-${l}`))]}):e.jsx("div",{className:`rcs-emulator-text-center rcs-emulator-py-8 ${r?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,children:"No contact information available"})}),D=n.memo(function({icon:r,primary:t,secondary:a,isDark:o,onClick:c}){const l={phone:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z",globe:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9",mail:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"};return e.jsxs("button",{onClick:c,className:`rcs-emulator-list-item rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-4 rcs-emulator-px-4 rcs-emulator-py-3-5 rcs-emulator-text-left rcs-emulator-transition-colors ${o?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("svg",{className:`rcs-emulator-w-5 rcs-emulator-h-5 rcs-emulator-flex-shrink-0 ${o?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:l[r]})}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-min-w-0",children:[e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-truncate ${o?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t}),a&&e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-truncate ${o?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-500"}`,children:a})]})]})}),Oe=n.memo(function({isDark:r}){return e.jsxs("div",{className:`rcs-emulator-profile-section rcs-emulator-rounded-xl rcs-emulator-overflow-hidden rcs-emulator-border rcs-emulator-divide-y ${r?"rcs-emulator-dark rcs-emulator-divide-zinc-800":"rcs-emulator-light rcs-emulator-divide-gray-200"}`,children:[e.jsx(_,{icon:"bell",label:"Notifications",isDark:r}),e.jsx(_,{icon:"block",label:"Block & report spam",isDark:r}),e.jsx(_,{icon:"info",label:"About RCS",isDark:r})]})}),_=n.memo(function({icon:r,label:t,isDark:a}){const o={bell:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",block:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"};return e.jsxs("button",{className:`rcs-emulator-list-item rcs-emulator-w-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-4 rcs-emulator-px-4 rcs-emulator-py-3-5 rcs-emulator-text-left rcs-emulator-transition-colors ${a?"rcs-emulator-dark":"rcs-emulator-light"}`,children:[e.jsx("svg",{className:`rcs-emulator-w-5 rcs-emulator-h-5 rcs-emulator-flex-shrink-0 ${a?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:o[r]})}),e.jsx("span",{className:`rcs-emulator-text-sm rcs-emulator-font-medium ${a?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t})]})}),J={FULL:"rcs-emulator-webview-full",TALL:"rcs-emulator-webview-tall",HALF:"rcs-emulator-webview-half"},se=n.memo(function(){const{theme:r,businessInfo:t,webView:a,closeWebView:o}=k(),[c,l]=n.useState(!0),[i,m]=n.useState(!1),u=r==="dark",d=t.brandColor||"#0084ff";n.useEffect(()=>{a?.url&&(l(!0),m(!1))},[a?.url]);const h=n.useCallback(()=>{l(!1)},[]),j=n.useCallback(()=>{l(!1),m(!0)},[]),v=y=>{try{return new URL(y).hostname}catch{return"Web Page"}};if(!a||!a.isOpen)return null;const{url:w,viewMode:b,title:f,postbackData:p}=a,N=f||v(w),g=b==="FULL",C=b==="TALL"||b==="HALF",I=J[b]||J.TALL;return e.jsxs("div",{className:`rcs-emulator-webview-overlay ${g?"rcs-emulator-webview-full":"rcs-emulator-webview-bottom-sheet"} rcs-emulator-absolute rcs-emulator-inset-0 rcs-emulator-z-50 rcs-emulator-flex rcs-emulator-flex-col ${g?"":"rcs-emulator-justify-end"} ${u?"rcs-emulator-bg-black-60":"rcs-emulator-bg-black-40"}`,role:"dialog","aria-modal":"true","aria-label":`WebView: ${N}`,"data-postback":p,"data-view-mode":b,children:[C&&e.jsx("button",{type:"button",className:"rcs-emulator-absolute rcs-emulator-inset-0 rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-cursor-default",onClick:o,"aria-label":"Close WebView"}),e.jsxs("div",{className:`rcs-emulator-relative rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-overflow-hidden ${u?"rcs-emulator-bg-zinc-900":"rcs-emulator-bg-white"} ${I} rcs-emulator-w-full ${C?"rcs-emulator-rounded-t-2xl rcs-emulator-shadow-2xl":""}`,style:{position:"relative",zIndex:1},children:[e.jsxs("header",{className:`rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-px-2 rcs-emulator-py-2 rcs-emulator-flex-shrink-0 rcs-emulator-border-b ${u?"rcs-emulator-bg-zinc-900 rcs-emulator-border-zinc-800":"rcs-emulator-bg-white rcs-emulator-border-gray-200"}`,children:[e.jsx("button",{type:"button",onClick:o,className:`rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-rounded-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-transition-colors ${u?"rcs-emulator-text-white rcs-emulator-hover-bg-zinc-800":"rcs-emulator-text-gray-700 rcs-emulator-hover-bg-gray-100"}`,"aria-label":"Close WebView",children:e.jsx("svg",{className:"rcs-emulator-w-6 rcs-emulator-h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-min-w-0",children:[e.jsx("h2",{className:`rcs-emulator-text-base rcs-emulator-font-medium rcs-emulator-truncate ${u?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:N}),e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-truncate ${u?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:v(w)})]}),e.jsx("button",{type:"button",className:`rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-rounded-full rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center ${u?"rcs-emulator-text-zinc-400 rcs-emulator-hover-bg-zinc-800":"rcs-emulator-text-gray-500 rcs-emulator-hover-bg-gray-100"}`,"aria-label":"More options",children:e.jsxs("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})]}),c&&e.jsx("div",{className:"rcs-emulator-absolute rcs-emulator-top-14 rcs-emulator-left-0 rcs-emulator-right-0 rcs-emulator-h-1 rcs-emulator-overflow-hidden",style:{backgroundColor:`${d}20`},children:e.jsx("div",{className:"rcs-emulator-h-full rcs-emulator-animate-pulse rcs-emulator-webview-loading-bar",style:{backgroundColor:d,width:"30%"}})}),i&&e.jsxs("div",{className:`rcs-emulator-flex-1 rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-p-6 rcs-emulator-text-center ${u?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:[e.jsx("svg",{className:"rcs-emulator-w-16 rcs-emulator-h-16 rcs-emulator-mb-4 rcs-emulator-opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-font-medium rcs-emulator-mb-2",children:"Unable to load page"}),e.jsx("p",{className:"rcs-emulator-text-xs rcs-emulator-opacity-75 rcs-emulator-mb-4",children:"This content cannot be displayed in the emulator"}),e.jsx("button",{type:"button",onClick:o,className:`rcs-emulator-px-4 rcs-emulator-py-2 rcs-emulator-rounded-full rcs-emulator-text-sm rcs-emulator-font-medium ${u?"rcs-emulator-bg-zinc-800 rcs-emulator-text-white rcs-emulator-hover-bg-zinc-700":"rcs-emulator-bg-gray-100 rcs-emulator-text-gray-700 rcs-emulator-hover-bg-gray-200"}`,children:"Go Back"})]}),!i&&e.jsx("div",{className:"rcs-emulator-flex-1 rcs-emulator-overflow-hidden",children:e.jsx("iframe",{src:w,title:N,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-border-0",onLoad:h,onError:j,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",referrerPolicy:"no-referrer-when-downgrade",loading:"lazy"})}),C&&e.jsx("div",{className:`rcs-emulator-h-2 rcs-emulator-flex-shrink-0 ${u?"rcs-emulator-bg-zinc-900":"rcs-emulator-bg-white"}`})]})]})}),Ue=n.memo(function({onUnlock:r,messagePreview:t="New message"}){const{theme:a,businessInfo:o}=k(),[c,l]=n.useState(new Date),i=a==="dark";n.useEffect(()=>{const d=setInterval(()=>{l(new Date)},1e3);return()=>clearInterval(d)},[]);const m=c.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),u=c.toLocaleDateString([],{weekday:"short",month:"long",day:"numeric"});return e.jsxs("div",{className:`rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-h-full rcs-emulator-w-full rcs-emulator-select-none ${i?"rcs-emulator-bg-zinc-900":"rcs-emulator-bg-zinc-800"}`,children:[e.jsx("div",{className:"rcs-emulator-h-6"}),e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-mt-4",children:e.jsx("div",{className:"rcs-emulator-w-8 rcs-emulator-h-8 rcs-emulator-rounded-full rcs-emulator-bg-zinc-700 rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center",children:e.jsx("svg",{className:"rcs-emulator-w-4 rcs-emulator-h-4 rcs-emulator-text-zinc-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})})})}),e.jsx("div",{className:"rcs-emulator-mt-6 rcs-emulator-text-center",children:e.jsx("h1",{className:"rcs-emulator-text-5xl rcs-emulator-font-light rcs-emulator-text-white rcs-emulator-tracking-tight",children:m})}),e.jsx("div",{className:"rcs-emulator-mt-2 rcs-emulator-text-center",children:e.jsx("p",{className:"rcs-emulator-text-zinc-400 rcs-emulator-text-sm",children:u})}),e.jsx("div",{className:"rcs-emulator-h-24"}),e.jsx("div",{className:"rcs-emulator-px-4 rcs-emulator-pb-8",children:e.jsxs("button",{onClick:r,className:"rcs-emulator-notification-card rcs-emulator-w-full rcs-emulator-bg-white rcs-emulator-rounded-2xl rcs-emulator-p-3 rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-shadow-lg rcs-emulator-transition-transform rcs-emulator-active-scale-98 rcs-emulator-hover-shadow-xl",children:[e.jsx("div",{className:"rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-rounded-xl rcs-emulator-bg-zinc-900 rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-flex-shrink-0 rcs-emulator-overflow-hidden",children:o.logo?e.jsx("img",{src:o.logo,alt:o.name,className:"rcs-emulator-w-full rcs-emulator-h-full rcs-emulator-object-cover"}):e.jsx("div",{className:"rcs-emulator-text-white",children:e.jsxs("svg",{className:"rcs-emulator-w-7 rcs-emulator-h-7",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"6",r:"1"}),e.jsx("circle",{cx:"12",cy:"18",r:"1"}),e.jsx("circle",{cx:"6",cy:"12",r:"1"}),e.jsx("circle",{cx:"18",cy:"12",r:"1"}),e.jsx("circle",{cx:"8",cy:"8",r:"0.8"}),e.jsx("circle",{cx:"16",cy:"8",r:"0.8"}),e.jsx("circle",{cx:"8",cy:"16",r:"0.8"}),e.jsx("circle",{cx:"16",cy:"16",r:"0.8"}),e.jsx("circle",{cx:"6",cy:"6",r:"0.5"}),e.jsx("circle",{cx:"18",cy:"6",r:"0.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"0.5"}),e.jsx("circle",{cx:"18",cy:"18",r:"0.5"})]})})}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-text-left rcs-emulator-min-w-0",children:[e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-font-semibold rcs-emulator-text-gray-900 rcs-emulator-truncate rcs-emulator-mb-1",children:o.name}),e.jsx("p",{className:"rcs-emulator-text-sm rcs-emulator-text-gray-500 rcs-emulator-truncate rcs-emulator-line-clamp-2 rcs-emulator-mb-1",children:t})]}),e.jsx("span",{className:"rcs-emulator-text-xs rcs-emulator-text-gray-400 rcs-emulator-flex-shrink-0",children:"now"})]})}),e.jsx("div",{className:"rcs-emulator-flex-1"}),e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-justify-center rcs-emulator-pb-2",children:e.jsx("div",{className:"rcs-emulator-home-indicator rcs-emulator-w-32 rcs-emulator-h-1 rcs-emulator-rounded-full rcs-emulator-bg-zinc-600"})})]})}),Ge=()=>e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"})}),Fe=()=>e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),Je=()=>e.jsxs("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),qe=()=>e.jsx("svg",{className:"rcs-emulator-w-5 rcs-emulator-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),Ye=s=>{switch(s){case"dial":return e.jsx(Ge,{});case"calendar":return e.jsx(Fe,{});case"map":return e.jsx(Je,{});default:return e.jsx(qe,{})}},Qe=s=>{switch(s){case"dial":return"#4CAF50";case"calendar":return"#2196F3";case"map":return"#FF5722";default:return"#9E9E9E"}},Ze=n.memo(function(){const{theme:r,toast:t,showToast:a}=k();if(n.useEffect(()=>{if(t){const c=setTimeout(()=>{a(null)},3e3);return()=>clearTimeout(c)}},[t,a]),!t)return null;const o=r==="dark";return e.jsx("div",{className:"rcs-emulator-absolute rcs-emulator-bottom-20 rcs-emulator-left-4 rcs-emulator-right-4 rcs-emulator-z-50",role:"alert","aria-live":"polite",children:e.jsxs("div",{className:`rcs-emulator-flex rcs-emulator-items-center rcs-emulator-gap-3 rcs-emulator-p-4 rcs-emulator-rounded-2xl rcs-emulator-shadow-lg ${o?"rcs-emulator-bg-zinc-800":"rcs-emulator-bg-white"}`,style:{boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",animation:"rcs-toast-slide-up 0.3s ease-out"},children:[e.jsx("div",{className:"rcs-emulator-flex rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-rounded-full rcs-emulator-flex-shrink-0 rcs-emulator-text-white",style:{backgroundColor:Qe(t.type)},children:Ye(t.type)}),e.jsxs("div",{className:"rcs-emulator-flex-1 rcs-emulator-min-w-0",children:[e.jsx("p",{className:`rcs-emulator-text-sm rcs-emulator-font-medium ${o?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:t.message}),t.details&&e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-mt-0.5 rcs-emulator-truncate ${o?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:t.details})]}),e.jsx("span",{className:`rcs-emulator-text-xs rcs-emulator-px-2 rcs-emulator-py-1 rcs-emulator-rounded-full rcs-emulator-flex-shrink-0 ${o?"rcs-emulator-bg-zinc-700 rcs-emulator-text-zinc-300":"rcs-emulator-bg-gray-100 rcs-emulator-text-gray-500"}`,children:"Simulation"})]})})}),q={name:"Business",verified:!1},Ke=n.memo(function({flow:r,onUserReply:t,theme:a,device:o,businessInfo:c,showSuggestions:l,onBack:i}){const{state:m,handleReply:u,handleAction:d}=he({flow:r,onUserReply:t,typingDelay:800}),[h,j]=n.useState(!1),v=n.useCallback(()=>{j(y=>!y)},[]),[w,b]=n.useState(null),f=n.useCallback(y=>{b({...y,isOpen:!0})},[]),p=n.useCallback(()=>{b(null)},[]),[N,g]=n.useState(null),C=n.useCallback(y=>{g(y)},[]),I=n.useCallback(y=>{if(!L(y))return;const{action:x}=y,M=x.postback.data,$=x.displayText,A=Y(y);if(A){f({url:A.url,viewMode:A.webviewViewMode||"TALL",title:A.description||"",postbackData:M}),t({type:"action",postbackData:M,displayText:$,timestamp:Date.now(),actionData:{type:"webview",url:A.url,viewMode:A.webviewViewMode||"TALL",description:A.description}});return}const B=x.dialAction?.phoneNumber||x.dialerAction?.dialPhoneNumber?.phoneNumber;if(B){C({type:"dial",message:"Would call",details:B}),t({type:"action",postbackData:M,displayText:$,timestamp:Date.now(),actionData:{type:"dial",phoneNumber:B}}),d(y);return}const R=x.calendarAction?.createCalendarEvent||x.createCalendarEventAction;if(R){const S=R.title||"Event";C({type:"calendar",message:"Would add calendar event",details:S}),t({type:"action",postbackData:M,displayText:$,timestamp:Date.now(),actionData:{type:"createCalendarEvent",title:S,description:R.description}}),d(y);return}const W=x.mapAction?.showLocation?.location||x.viewLocationAction?.latLong;if(W||x.viewLocationAction){const S=x.mapAction?.showLocation?.location?.label||x.viewLocationAction?.label||"Location";C({type:"map",message:"Would open maps",details:S}),t({type:"action",postbackData:M,displayText:$,timestamp:Date.now(),actionData:{type:"viewLocation",latitude:W?.latitude,longitude:W?.longitude,query:x.viewLocationAction?.query}}),d(y);return}d(y)},[d,f,t,C]);return e.jsxs(Z,{theme:a,device:o,businessInfo:c,state:m,showSuggestions:l,isProfileOpen:h,toggleProfile:v,onReply:u,onAction:I,webView:w,openWebView:f,closeWebView:p,toast:N,showToast:C,onBack:i,children:[e.jsx(De,{}),h&&e.jsx(_e,{}),e.jsx(se,{}),e.jsx(Ze,{})]})}),ae=n.memo(function({messages:r,jsonUrl:t,onUserReply:a,theme:o="light",device:c="android",businessInfo:l,className:i="",width:m=375,height:u=667,showSuggestions:d=!0,showLockScreen:h=!1}){const[j,v]=n.useState(h),w=n.useCallback(()=>{v(!1)},[]),b=n.useCallback(()=>{v(!0)},[]),{data:f,isLoading:p,error:N}=te(t),g=t?f:r,C=n.useMemo(()=>g?X(g):!1,[g]),I=n.useMemo(()=>({...q,...l,name:l?.name||g?.name||q.name}),[l,g?.name]),y=n.useMemo(()=>g&&C?ee(g):"New message",[g,C]),x=o==="dark",M=x?"rcs-emulator-dark":"rcs-emulator-light",$=({children:A})=>e.jsx("div",{className:`rcs-emulator rcs-emulator-container ${M} ${i}`,style:{width:m,height:u},role:"application","aria-label":"RCS Message Emulator","data-theme":o,"data-device":c,children:A});return t&&p?e.jsx($,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6",children:[e.jsx("div",{className:`rcs-emulator-w-10 rcs-emulator-h-10 rcs-emulator-spinner rcs-emulator-mb-4 ${M}`}),e.jsx("p",{className:`rcs-emulator-text-sm ${x?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:"Loading conversation..."})]})}):t&&N?e.jsx($,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6 rcs-emulator-text-center",children:[e.jsx("svg",{className:"rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-mb-4 rcs-emulator-text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("h3",{className:`rcs-emulator-text-lg rcs-emulator-font-medium rcs-emulator-mb-2 ${x?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"Failed to Load"}),e.jsx("p",{className:`rcs-emulator-text-sm ${x?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:N}),e.jsx("p",{className:`rcs-emulator-text-xs rcs-emulator-mt-2 rcs-emulator-max-w-full ${x?"rcs-emulator-text-zinc-500":"rcs-emulator-text-gray-400"}`,style:{wordBreak:"break-all"},children:t})]})}):g?C?e.jsx($,{children:j?e.jsx(Z,{theme:o,device:c,businessInfo:I,state:{currentMessageId:null,chatHistory:[],isTyping:!1,error:null},showSuggestions:!1,isProfileOpen:!1,toggleProfile:()=>{},onReply:()=>{},onAction:()=>{},webView:null,openWebView:()=>{},closeWebView:()=>{},toast:null,showToast:()=>{},onBack:null,children:e.jsx(Ue,{onUnlock:w,messagePreview:y})}):e.jsx(Ke,{flow:g,onUserReply:a,theme:o,device:c,businessInfo:I,showSuggestions:d,onBack:h?b:null})}):e.jsx($,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6 rcs-emulator-text-center",children:[e.jsx("svg",{className:"rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-mb-4",style:{color:"#f59e0b"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("h3",{className:`rcs-emulator-text-lg rcs-emulator-font-medium rcs-emulator-mb-2 ${x?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"Invalid RBM JSON"}),e.jsx("p",{className:`rcs-emulator-text-sm ${x?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:"The conversation flow structure is not valid"})]})}):e.jsx($,{children:e.jsxs("div",{className:"rcs-emulator-flex rcs-emulator-flex-col rcs-emulator-items-center rcs-emulator-justify-center rcs-emulator-h-full rcs-emulator-p-6 rcs-emulator-text-center",children:[e.jsx("svg",{className:`rcs-emulator-w-12 rcs-emulator-h-12 rcs-emulator-mb-4 ${x?"rcs-emulator-text-zinc-600":"rcs-emulator-text-gray-300"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),e.jsx("h3",{className:`rcs-emulator-text-lg rcs-emulator-font-medium rcs-emulator-mb-2 ${x?"rcs-emulator-text-white":"rcs-emulator-text-gray-900"}`,children:"No Conversation Data"}),e.jsxs("p",{className:`rcs-emulator-text-sm ${x?"rcs-emulator-text-zinc-400":"rcs-emulator-text-gray-500"}`,children:["Provide either"," ",e.jsx("code",{className:`rcs-emulator-code-inline ${M}`,children:"messages"})," ","or"," ",e.jsx("code",{className:`rcs-emulator-code-inline ${M}`,children:"jsonUrl"})," ","prop"]})]})})});exports.RcsEmulator=ae;exports.WebViewRenderer=se;exports.default=ae;exports.getFirstMessagePreview=ee;exports.getWebViewConfig=Y;exports.isSuggestedAction=L;exports.isSuggestedReply=P;exports.isWebViewAction=oe;exports.useJsonFetch=te;exports.validateConversationFlow=X;
2
2
  //# sourceMappingURL=rcs-emulator.cjs.js.map