Files
roi-theme/_planeacion/theme_referencias/_old/Estimating_files/4-ac7fbb470ffd3313.js.descarga
FrankZamora ea38a12055 [NIVEL 2 AVANCE] Issues #49-#53 - Componentes Principales Verificados
Todos los componentes del NIVEL 2 ya están implementados correctamente:
-  Notification Bar (#49)
-  Navbar (#50)
-  Hero Section (#51)
-  Sidebar (#52)
-  Footer (#53)

Solo se actualizó notification-bar.css para usar variables CSS.

Próximo paso: NIVEL 3 (Refinamientos visuales)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 20:01:07 -06:00

1 line
74 KiB
Plaintext

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4],{6810:(e,t,a)=>{"use strict";a.d(t,{A:()=>l});var s=a(95155),n=a(43463),r=a(84158);function i(e){let{prompt:t,theme:a="light",onClick:r,className:i}=e,l=(0,n.A)("max-w-xs truncate inline-block flex-shrink-0 px-3 py-1 font-base transition-colors rounded-xl focus:outline-none",{"border hover:bg-secondary/50 text-primary":"light"===a,"text-slate-300 border border-slate-700 hover:text-slate-200 hover:bg-slate-700/20":"dark"===a},i);switch(t.type){case"ai":case"follow_up":return(0,s.jsx)("button",{type:"button",onClick:()=>r(t.prompt),className:l,children:t.name});case"redirect":case"follow_up_link":return(0,s.jsx)("a",{href:t.action,target:"_blank",rel:"noopener noreferrer",className:l,children:t.name});case"email":case"follow_up_email":return(0,s.jsx)("a",{href:"mailto:".concat(t.action),target:"_blank",rel:"noopener noreferrer",className:l,children:t.name});case"intercom":return(0,s.jsx)("button",{type:"button",onClick:()=>{window.parent.postMessage({openIntercom:!0,closeChat:!0},"*")},className:l,children:t.name});case"escalate":return(0,s.jsx)("button",{type:"button",onClick:()=>r("Please escalate this conversation to a human agent."),className:l,children:t.name})}}function l(e){let{settings:t,prompts:a,chatConfig:l,loading:o}=e,{append:c}=(0,r.Y_)(l);return(0,s.jsx)("div",{className:(0,n.A)("flex items-center gap-3",{"text-sm":"small"===t.font_size,"text-base":"medium"===t.font_size,"text-lg":"large"===t.font_size,"overflow-x-auto pb-4 -mb-4":t.scroll_smart_prompts,"flex-wrap justify-end":!t.scroll_smart_prompts}),children:a.map(e=>(0,s.jsx)(i,{prompt:e,theme:t.theme,onClick:e=>{o||c({role:"user",content:e})}},e.id))})}a(12115)},8405:(e,t,a)=>{"use strict";a.d(t,{A:()=>h});var s=a(95155),n=a(43463),r=a(40767),i=a(12115),l=a(77132),o=a(14085),c=a(43670),d=a(9955),u=a(15785),m=a(50745);function h(e){let{settings:t,onSubmit:a,onClose:h,activeLanguage:p="en",defaultLanguage:x="en"}=e,[g,f]=(0,i.useState)({}),[b,v]=(0,i.useState)(!1),y=e=>{let t="checkbox"===e.target.type?e.target.checked?"Yes":"No":e.target.value;f({...g,[e.target.name]:t})},j=(e,t)=>{f({...g,[t]:e?"Yes":"No"})},w=async e=>{e.preventDefault(),v(!0);try{await a(g)}finally{v(!1)}};return(0,s.jsxs)("div",{className:"flex absolute inset-0 z-50 justify-center items-center px-16 py-6 bg-white",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{window.parent.postMessage({closeChat:!0},"*"),h()},className:"inline-flex absolute top-5 right-5 justify-center items-center p-1 bg-transparent rounded-lg transition-all duration-150 hover:opacity-90 focus:opacity-90",children:(0,s.jsx)(r.A,{size:24,strokeWidth:1.75})}),(0,s.jsxs)("div",{className:"space-y-2 w-full max-w-sm",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-center",children:(0,l.NX)(t.localization,"enter_your_information",p,x)||"Enter your information"}),(0,s.jsx)("p",{className:"text-base text-center text-muted-foreground",children:(0,l.NX)(t.localization,"please_fill_in_your_information",p,x)||"Please fill in your information below to get started."}),(0,s.jsxs)("form",{className:"flex flex-col pt-8 space-y-4",onSubmit:w,children:[t.lead_capture_fields.filter(e=>e.enabled).sort((e,t)=>e.order-t.order).map(e=>{var a;return(0,s.jsxs)("div",{className:(0,n.A)("flex gap-2",{"justify-end items-start flex-row-reverse":"checkbox"===e.type,"flex-col":"checkbox"!==e.type}),children:[(0,s.jsxs)(u.J,{className:"block text-sm font-medium leading-6",htmlFor:e.name,children:[(0,l.NX)(t.localization,e.name,p,x)||e.name.replace(/_/g," ").replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()),e.required&&(0,s.jsx)("span",{className:"ml-1 text-sm text-zinc-400",children:"*"})]}),"checkbox"===e.type?(0,s.jsx)(c.S,{id:e.name,name:e.name,required:e.required,onCheckedChange:t=>j(t,e.name),className:"mt-1 shrink-0"}):"select"===e.type?(0,s.jsxs)(m.l6,{required:e.required,onValueChange:t=>f({...g,[e.name]:t}),children:[(0,s.jsx)(m.bq,{className:"w-full",children:(0,s.jsx)(m.yv,{placeholder:"Select an option..."})}),(0,s.jsx)(m.gC,{children:null===(a=e.options)||void 0===a?void 0:a.split(",").map((e,t)=>(0,s.jsx)(m.eb,{value:e.trim(),children:e.trim()},t))})]}):(0,s.jsx)(d.p,{type:e.type,id:e.name,name:e.name,required:e.required,onChange:y})]},e.name)}),(0,s.jsx)("div",{className:"pt-4",children:(0,s.jsx)(o.$,{type:"submit",disabled:b,className:"w-full",style:{background:t.accent_color,color:t.text_color},children:b?(0,l.NX)(t.localization,"submitting",p,x)||"Submitting...":(0,l.NX)(t.localization,"submit",p,x)||"Submit"})})]})]})]})}},9246:(e,t,a)=>{"use strict";a.d(t,{Bc:()=>i,ZI:()=>c,k$:()=>o,m_:()=>l});var s=a(95155);a(12115);var n=a(29602),r=a(72824);function i(e){let{delayDuration:t=700,...a}=e;return(0,s.jsx)(r.Kq,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function l(e){let{...t}=e;return(0,s.jsx)(i,{children:(0,s.jsx)(r.bL,{"data-slot":"tooltip",...t})})}function o(e){let{...t}=e;return(0,s.jsx)(r.l9,{"data-slot":"tooltip-trigger",...t})}function c(e){let{className:t,sideOffset:a=0,children:i,...l}=e;return(0,s.jsx)(r.ZL,{children:(0,s.jsx)(r.UC,{"data-slot":"tooltip-content",sideOffset:a,className:(0,n.cn)("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit rounded-lg px-3 py-2 text-xs text-balance",t),...l,children:i})})}},9955:(e,t,a)=>{"use strict";a.d(t,{p:()=>r});var s=a(95155);a(12115);var n=a(29602);function r(e){let{className:t,type:a,...r}=e;return(0,s.jsx)("input",{type:a,"data-slot":"input",className:(0,n.cn)("flex px-3 py-1 w-full min-w-0 h-9 text-base [@media(pointer:fine)]:text-sm bg-transparent rounded-md border transition-colors outline-none file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input shadow-xs file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","focus-visible:ring-1 focus-visible:ring-ring/30","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...r})}},10952:()=>{},13678:()=>{},14085:(e,t,a)=>{"use strict";a.d(t,{$:()=>o,r:()=>l});var s=a(95155),n=a(12317),r=a(31027);a(12115);var i=a(29602);let l=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{xs:"h-7 py-1 px-2",default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9",iconSm:"size-8",iconXs:"size-7",link:"p-0"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:a,size:r,asChild:o=!1,...c}=e,d=o?n.DX:"button";return(0,s.jsx)(d,{"data-slot":"button",className:(0,i.cn)(l({variant:a,size:r,className:t})),...c})}},15785:(e,t,a)=>{"use strict";a.d(t,{J:()=>i});var s=a(95155);a(12115);var n=a(46195),r=a(29602);function i(e){let{className:t,...a}=e;return(0,s.jsx)(n.b,{"data-slot":"label",className:(0,r.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...a})}},26308:()=>{},29602:(e,t,a)=>{"use strict";a.d(t,{cn:()=>r,eA:()=>o,eF:()=>l,pW:()=>i});var s=a(43463),n=a(69795);function r(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,n.QP)((0,s.$)(t))}function i(e,t){return e.replace(/{{\s*([\w\d_]+)\s*\|\s*([^}]+)\s*}}/g,(e,a,s)=>{let n=t[a];return null!=n&&""!==n?String(n):s.trim()})}function l(e,t){return null!=e&&!!e.welcome_messages&&"large"!==e.header_size&&"share"!==t}function o(e){return e.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/\*\*([^\*]+)\*\*/g,"$1").replace(/__([^_]+)__/g,"$1").replace(/\*([^\*]+)\*/g,"$1").replace(/_([^_]+)_/g,"$1").replace(/^#+\s*(.+)$/gm,"$1").replace(/\[([^\]]+)\]\([^\)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^\)]+\)/g,"$1").replace(/^>\s*(.+)$/gm,"$1").replace(/^[\s]*[-\*\+]\s+(.+)$/gm,"$1").replace(/^[\s]*\d+\.\s+(.+)$/gm,"$1").replace(/^[-\*_]{3,}$/gm,"")}},29645:()=>{},42250:()=>{},43670:(e,t,a)=>{"use strict";a.d(t,{S:()=>l});var s=a(95155);a(12115);var n=a(86352),r=a(98867),i=a(29602);function l(e){let{className:t,...a}=e;return(0,s.jsx)(n.bL,{"data-slot":"checkbox",className:(0,i.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:(0,s.jsx)(n.C1,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:(0,s.jsx)(r.A,{className:"size-3.5"})})})}},44573:()=>{},45356:(e,t,a)=>{"use strict";a.d(t,{A:()=>eg});var s=a(95155),n=a(43463),r=a(21079),i=a.n(r),l=a(12115),o=a(16664),c=a(14081),d=a(10400),u=a(68403),m=a(96246);let h=e=>[".mp4",".webm",".ogg",".mov",".avi",".mkv",".m4v"].some(t=>e.toLowerCase().includes(t)),p=e=>{let t=e.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/);return t?"https://www.youtube.com/embed/".concat(t[1]):null},x=e=>{let t=e.match(/vimeo\.com\/(\d+)/);return t?"https://player.vimeo.com/video/".concat(t[1]):null},g=(0,l.memo)(e=>{let{chatbotId:t,messageId:a,content:n,displayImages:r}=e,i=async e=>{if(a)try{fetch("/api/".concat(t,"/events"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"link-click",conversation_id:a,value:e})})}catch(e){console.error("Failed to track link click:",e)}window.open(e,"_blank")};return(0,s.jsx)(u.oz,{remarkPlugins:[m.A],components:{pre:e=>{let{children:t}=e;return(0,s.jsx)("pre",{className:"p-3 px-4 text-sm rounded-xl",children:t})},img:e=>{let{src:t,alt:a,...n}=e;if(t&&"string"==typeof t){if(!r)return(0,s.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:a||t});let e=p(t),n=x(t);if(e||n)return(0,s.jsx)("iframe",{src:e||n||"",className:"my-4 w-full rounded-xl aspect-video",allowFullScreen:!0});if(h(t))return(0,s.jsx)("video",{controls:!0,className:"max-w-full h-auto rounded-xl",preload:"metadata",src:t})}return(0,s.jsx)("img",{src:t,alt:a,className:"max-w-full h-auto rounded-xl",...n})},a(e){let t=e.href;return!t||(!t.includes("@")||t.includes("/")||t.startsWith("http")||t.startsWith("mailto:")?t.startsWith("http")||t.startsWith("mailto:")||(t="https://".concat(t)):t="mailto:".concat(t.replace("mailto:",""))),(0,s.jsx)("a",{href:t,target:"_blank",onClick:e=>{e.preventDefault(),i(t)},rel:"noopener noreferrer",children:e.children})}},children:n})},(e,t)=>e.content===t.content&&e.displayImages===t.displayImages);g.displayName="MemoizedMarkdownBlock";let f=(0,l.memo)(e=>{let{chatbotId:t,messageId:a,content:n,displayImages:r}=e,i="string"==typeof n?n:"";return(0,l.useMemo)(()=>d.xI.lexer(i).map(e=>e.raw),[i]).map((e,n)=>(0,s.jsx)(g,{chatbotId:t,messageId:a,content:e,displayImages:r},"".concat(a,"-block_").concat(n)))});f.displayName="MemoizedMarkdown";var b=a(35765);function v(e){let{size:t=21}=e;return(0,s.jsx)("svg",{width:t,height:t,className:"text-white",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{d:"M14.5417 3.42383H6.4571C2.89727 3.42383 0 6.31994 0 9.88093C0 11.8975 0.930358 13.7005 2.38361 14.8859C4.1289 16.4419 8.24163 19.5758 8.24163 19.5758L8.23124 16.3369H14.5417C18.1016 16.3369 20.9988 13.4396 20.9988 9.88093C20.9988 6.32225 18.1016 3.42383 14.5417 3.42383ZM10.631 12.612C6.7272 12.612 3.91997 10.9279 3.74452 10.8217L4.788 9.1214L5.82109 7.41767C6.00577 7.52733 10.4209 10.0991 15.3186 7.37843L17.2532 10.8655C14.8961 12.1745 12.621 12.612 10.6299 12.612H10.631Z",fill:"currentColor"})})}var y=a(98867),j=a(23920),w=a(21773);let _=e=>{let{size:t=24,fill:a="none",className:n}=e;return(0,s.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:a,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,children:[(0,s.jsx)("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}),(0,s.jsx)("path",{d:"M17 14V2"})]})},k=e=>{let{size:t=24,fill:a="none",className:n}=e;return(0,s.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:a,stroke:"currentColor",className:n,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}),(0,s.jsx)("path",{d:"M7 10v12"})]})};var N=a(9246),z=a(77132),C=a(14505);function S(){return(0,s.jsx)("div",{className:"relative flex items-center justify-center w-[15px] h-[15px]",children:(0,s.jsxs)("div",{className:"flex gap-[1px] items-center",children:[(0,s.jsx)("div",{className:"w-[1.5px] h-[3px] bg-current/90"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[8px] bg-current/90"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[11px] bg-current/90"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[5px] bg-current/90"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[9px] bg-current/90"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[3px] bg-current/90"})]})})}function A(){return(0,s.jsx)("div",{className:"relative flex items-center justify-center w-[15px] h-[15px]",children:(0,s.jsxs)("div",{className:"flex gap-[1px] items-center",children:[(0,s.jsx)("div",{className:"w-[1.5px] h-[3px] bg-current/90 animate-[soundbar_0.5s_ease-in-out_infinite_0.2s]"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[8px] bg-current/90 animate-[soundbar_0.5s_ease-in-out_infinite_0.3s]"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[11px] bg-current/90 animate-[soundbar_0.75s_ease-in-out_infinite_0.2s]"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[5px] bg-current/90 animate-[soundbar_0.5s_ease-in-out_infinite_0.6s]"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[9px] bg-current/90 animate-[soundbar_0.75s_ease-in-out_infinite_0.3s]"}),(0,s.jsx)("div",{className:"w-[1.5px] h-[3px] bg-current/90 animate-[soundbar_0.5s_ease-in-out_infinite_0.1s]"})]})})}var I=a(89097),M=a(29602);function F(e){let{content:t,settings:r,onPlayStateChange:i,activeLanguage:o,defaultLanguage:c}=e,{isPlaying:d,error:u,isLoading:m,startSpeaking:h,stopSpeaking:p}=function(e){let{content:t,settings:s,onPlayStateChange:n}=e,[r,i]=(0,l.useState)(!1),[o,c]=(0,l.useState)(!1),[d,u]=(0,l.useState)(null),m=(0,l.useRef)(null),h=(0,l.useRef)(null),p=(0,l.useRef)(null),x=(0,l.useCallback)(()=>{p.current&&(p.current.pause(),p.current.remove(),p.current=null),h.current&&(h.current.close(),h.current=null),m.current&&(m.current=null),i(!1),null==n||n(!1)},[n]),g=(0,l.useCallback)(async()=>{try{var e;let t=await (0,I.b)();if(!t)return!1;let r=await Promise.resolve().then(a.t.bind(a,10844,23)),l=r.SpeechConfig.fromAuthorizationToken(t,"eastus");l.speechSynthesisLanguage=s.speech_services_language,l.speechSynthesisVoiceName=(null===(e=s.speech_services_language)||void 0===e?void 0:e.replace(/, /g,"-"))||"en-US-JennyNeural",l.speechSynthesisOutputFormat=r.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3,m.current=l;let o=new r.SpeechSynthesizer(l,null);return h.current=o,o.synthesisCompleted=(e,t)=>{if(t.result.reason===r.ResultReason.SynthesizingAudioCompleted){let e=t.result.audioData,a=new Blob([e],{type:"audio/mp3"}),s=URL.createObjectURL(a),r=new Audio(s);r.onplay=()=>{c(!1),i(!0),null==n||n(!0)},r.onended=()=>{i(!1),null==n||n(!1),URL.revokeObjectURL(s),p.current=null,x()},r.onpause=()=>{i(!1),null==n||n(!1)},p.current=r,r.play().catch(()=>{u("Failed to play audio"),c(!1),i(!1),null==n||n(!1)})}},!0}catch(e){return console.error("Failed to setup speech config:",e),u(e instanceof Error?e.message:"Failed to setup speech"),!1}},[s.speech_services_language,n,x]);return(0,l.useEffect)(()=>(s.enable_text_to_speech&&g(),()=>{x()}),[s.enable_text_to_speech,g,x]),{isPlaying:r,isLoading:o,error:d,startSpeaking:async()=>{try{u(null),c(!0);let e=(0,M.eA)(t);if(!h.current&&!await g()){c(!1);return}if(!h.current){u("Speech synthesis not ready"),c(!1);return}h.current.speakTextAsync(e,()=>{},t=>{c(!1),"object"==typeof t&&("AuthenticationFailure"===t.name||"Unauthorized"===t.name)?(x(),g().then(t=>{t&&h.current&&h.current.speakTextAsync(e,()=>{},()=>{u("Failed to speak text after token refresh"),i(!1),null==n||n(!1)})})):(u("Failed to speak text"),i(!1),null==n||n(!1))})}catch(e){c(!1),u(e instanceof Error?e.message:"Failed to start speaking"),i(!1),null==n||n(!1)}},stopSpeaking:x}}({content:t,settings:r,onPlayStateChange:i});return r.enable_text_to_speech?(0,s.jsx)(N.Bc,{children:(0,s.jsxs)(N.m_,{children:[(0,s.jsx)(N.k$,{asChild:!0,children:(0,s.jsx)("button",{type:"button",disabled:!!u,onClick:()=>{d?p():h()},className:(0,n.A)("p-1 rounded-md",{"text-muted-foreground hover:bg-secondary":"light"===r.theme,"text-white/50 hover:text-slate-200 hover:bg-slate-700/60":"dark"===r.theme,"opacity-50 cursor-not-allowed":u}),children:m?(0,s.jsx)(C.A,{className:"animate-spin size-[15px]"}):d?(0,s.jsx)(A,{}):(0,s.jsx)(S,{})})}),(0,s.jsx)(N.ZI,{children:(0,s.jsx)("p",{children:d?(0,z.NX)(r.localization,"stop_listening",o,c)||"Stop":(0,z.NX)(r.localization,"listen_to_response",o,c)||"Listen to response"})})]})}):null}function L(e){let{settings:t,display:a,feedback:r,content:i,onFeedback:o,onRetry:c,onCopy:d,activeLanguage:u,defaultLanguage:m}=e,[h,p]=(0,l.useState)(!1),[x,g]=(0,l.useState)(r),f=e=>{g(e===x?void 0:e),o(e)},b="light"===t.theme?"#d4d4d8":"#475569";return(0,s.jsxs)("div",{className:(0,n.A)("flex gap-0.5 items-center mt-2 transition-opacity duration-200 w-fit absolute",{"opacity-100 -bottom-7 left-0":"always"===a,"p-0.5 opacity-0 group-hover:opacity-100 border rounded-lg -bottom-4 left-2":"hover"===a," bg-white":"light"===t.theme&&"hover"===a," bg-slate-800 border-slate-700":"dark"===t.theme&&"hover"===a}),children:[(0,s.jsxs)(N.Bc,{children:[(0,s.jsxs)(N.m_,{children:[(0,s.jsx)(N.k$,{asChild:!0,children:(0,s.jsx)("button",{onClick:()=>{d(),p(!0),setTimeout(()=>p(!1),2e3)},className:(0,n.A)("p-1 rounded-md hover:bg-secondary dark:hover:bg-zinc-700",{"text-muted-foreground hover:bg-secondary":"light"===t.theme,"text-white/50 hover:text-slate-200 hover:bg-slate-700/60":"dark"===t.theme}),children:h?(0,s.jsx)(y.A,{size:15}):(0,s.jsx)(j.A,{size:15})})}),(0,s.jsx)(N.ZI,{children:(0,s.jsx)("p",{children:(0,z.NX)(t.localization,"copy_to_clipboard",u,m)||"Copy to clipboard"})})]}),(0,s.jsxs)(N.m_,{children:[(0,s.jsx)(N.k$,{asChild:!0,children:(0,s.jsx)("button",{onClick:()=>f("positive"),className:(0,n.A)("p-1 rounded-md",{"text-muted-foreground hover:bg-secondary":"light"===t.theme,"text-white/50 hover:text-slate-200 hover:bg-slate-700/60":"dark"===t.theme}),children:(0,s.jsx)(k,{size:15,fill:"positive"===x?b:"none"})})}),(0,s.jsx)(N.ZI,{children:(0,s.jsx)("p",{children:(0,z.NX)(t.localization,"helpful_response",u,m)||"Helpful response"})})]}),(0,s.jsxs)(N.m_,{children:[(0,s.jsx)(N.k$,{asChild:!0,children:(0,s.jsx)("button",{onClick:()=>f("negative"),className:(0,n.A)("p-1 rounded-md hover:bg-secondary dark:hover:bg-zinc-700",{"text-muted-foreground hover:bg-secondary":"light"===t.theme,"text-white/50 hover:text-slate-200 hover:bg-slate-700/60":"dark"===t.theme}),children:(0,s.jsx)(_,{size:15,fill:"negative"===x?b:"none"})})}),(0,s.jsx)(N.ZI,{children:(0,s.jsx)("p",{children:(0,z.NX)(t.localization,"unhelpful_response",u,m)||"Unhelpful response"})})]}),"always"===a&&c&&(0,s.jsxs)(N.m_,{children:[(0,s.jsx)(N.k$,{asChild:!0,children:(0,s.jsx)("button",{onClick:c,className:(0,n.A)("p-1 rounded-md hover:bg-secondary dark:hover:bg-zinc-700",{"text-muted-foreground hover:bg-secondary":"light"===t.theme,"text-white/50 hover:text-slate-200 hover:bg-slate-700/60":"dark"===t.theme}),children:(0,s.jsx)(w.A,{size:15})})}),(0,s.jsx)(N.ZI,{children:(0,s.jsx)("p",{children:(0,z.NX)(t.localization,"regenerate_response",u,m)||"Regenerate response"})})]})]}),t.enable_text_to_speech&&(0,s.jsx)(F,{content:i,settings:t,activeLanguage:u,defaultLanguage:m})]})}function E(e){let{role:t,avatar:a,settings:r,loading:i,isCurrentlyStreaming:l,commandPalette:o,feedback:c,content:d,sources:u=[],onFeedback:m,onRetry:h,onCopy:p,toolRender:x,children:g,activeLanguage:f,defaultLanguage:y}=e;return(0,s.jsx)("div",{className:(0,n.A)("flex",{"justify-end pl-4":"user"===t,"justify-start pr-4":"assistant"===t}),children:(0,s.jsxs)("div",{className:"flex gap-3 items-end",children:["assistant"===t&&(0,s.jsx)("div",{className:"flex justify-center items-center p-0 bg-center bg-cover rounded-full w-[32px] h-[32px] shrink-0 shadow-xs",style:{background:a?"url(".concat(a,"), ").concat(r.accent_color):r.launcher_icon?"url(".concat(r.launcher_icon,"), ").concat(r.accent_color):r.accent_color,backgroundRepeat:"no-repeat",backgroundSize:"cover",backgroundPosition:"center"},children:!a&&!r.launcher_icon&&(0,s.jsx)(v,{size:20})}),"agent"===t&&(0,s.jsx)("div",{className:"w-[32px] h-[32px] bg-center bg-cover rounded-full shrink-0",style:{backgroundImage:"url(".concat(a,")")}}),(0,s.jsxs)("div",{className:"flex relative flex-col group",children:[(0,s.jsxs)("div",{className:(0,n.A)("p-4 flex-1 font-normal rounded-xl",{"rounded-bl-sm":"assistant"===t||"agent"===t,"rounded-br-sm":"user"===t,"bg-secondary border border-border/20":"light"===r.theme&&("assistant"===t||"agent"===t),"bg-[#2A3447] border border-slate-700/20":"dark"===r.theme&&("assistant"===t||"agent"===t),"text-white":"user"===t,"prose-sm text-sm":"small"===r.font_size,"prose-md text-base":"medium"===r.font_size,"prose-lg text-lg":"large"===r.font_size,"prose [word-break:break-word]":"assistant"===t,"prose-zinc":"assistant"===t&&"light"===r.theme,"prose-invert":"assistant"===t&&"dark"===r.theme}),style:"user"===t?{background:"#fff"!==r.accent_color&&"#ffffff"!==r.accent_color?r.accent_color:"#F8FAFC",color:r.text_color}:{},children:[g,("assistant"===t||"agent"===t)&&!l&&r.enable_sources&&u.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 text-xs font-medium text-muted-foreground",children:r.sources_label}),(0,s.jsx)("div",{className:"space-y-1",children:u.filter(e=>e.url&&""!==e.url.trim()).slice(0,3).map(e=>(0,s.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex gap-1 items-center text-xs text-muted-foreground",children:[(0,s.jsx)(b.A,{className:"w-3 h-3 shrink-0"}),(0,s.jsx)("span",{className:"line-clamp-1",children:e.url})]},e.id))})]})]}),x&&x,("assistant"===t||"agent"===t)&&"never"!==o&&!i&&m&&h&&p&&(0,s.jsx)(L,{settings:r,display:o,feedback:c,content:d||"",onFeedback:m,onRetry:a?void 0:h,onCopy:p,activeLanguage:f,defaultLanguage:y})]})]})})}var T=a(14085),R=a(93518),P=a(46967),D=a(62222);function q(e){let{className:t,classNames:a,showOutsideDays:n=!0,...r}=e;return(0,s.jsx)(D.hv,{showOutsideDays:n,className:(0,M.cn)("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:(0,M.cn)((0,T.r)({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:(0,M.cn)((0,T.r)({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...a},components:{IconLeft:e=>{let{className:t,...a}=e;return(0,s.jsx)(R.A,{className:(0,M.cn)("w-4 h-4",t),...a})},IconRight:e=>{let{className:t,...a}=e;return(0,s.jsx)(P.A,{className:(0,M.cn)("w-4 h-4",t),...a})}},...r})}q.displayName="Calendar";async function $(e,t){let{username:a,eventTypeSlug:s}=function(e){let[,t,a]=new URL(e).pathname.split("/");return{username:t,eventTypeSlug:a}}(e),n=await fetch("".concat("https://api.cal.com/v2","/bookings"),{method:"POST",headers:{"Content-Type":"application/json","cal-api-version":"2024-08-13"},body:JSON.stringify({eventTypeSlug:s,username:a,start:t.selectedTime,attendee:{name:t.name,email:t.email,timeZone:t.timeZone},bookingFieldsResponses:{notes:t.notes}})});if(!n.ok)throw Error("Failed to create booking");return n.json()}var O=a(32),W=a(87364),Z=a(12317),X=a(69606),U=a(15785);let B=X.Op,J=l.createContext({}),K=e=>{let{...t}=e;return(0,s.jsx)(J.Provider,{value:{name:t.name},children:(0,s.jsx)(X.xI,{...t})})},H=()=>{let e=l.useContext(J),t=l.useContext(Y),{getFieldState:a}=(0,X.xW)(),s=(0,X.lN)({name:e.name}),n=a(e.name,s);if(!e)throw Error("useFormField should be used within <FormField>");let{id:r}=t;return{id:r,name:e.name,formItemId:"".concat(r,"-form-item"),formDescriptionId:"".concat(r,"-form-item-description"),formMessageId:"".concat(r,"-form-item-message"),...n}},Y=l.createContext({});function G(e){let{className:t,...a}=e,n=l.useId();return(0,s.jsx)(Y.Provider,{value:{id:n},children:(0,s.jsx)("div",{"data-slot":"form-item",className:(0,M.cn)("grid gap-2",t),...a})})}function V(e){let{className:t,...a}=e,{error:n,formItemId:r}=H();return(0,s.jsx)(U.J,{"data-slot":"form-label","data-error":!!n,className:(0,M.cn)("data-[error=true]:text-destructive",t),htmlFor:r,...a})}function Q(e){let{...t}=e,{error:a,formItemId:n,formDescriptionId:r,formMessageId:i}=H();return(0,s.jsx)(Z.DX,{"data-slot":"form-control",id:n,"aria-describedby":a?"".concat(r," ").concat(i):"".concat(r),"aria-invalid":!!a,...t})}function ee(e){var t;let{className:a,...n}=e,{error:r,formMessageId:i}=H(),l=r?String(null!==(t=null==r?void 0:r.message)&&void 0!==t?t:""):n.children;return l?(0,s.jsx)("p",{"data-slot":"form-message",id:i,className:(0,M.cn)("text-destructive text-sm",a),...n,children:l}):null}var et=a(9955);function ea(e){let{className:t,...a}=e;return(0,s.jsx)("textarea",{"data-slot":"textarea",className:(0,M.cn)("flex px-3 py-2 w-full text-base [@media(pointer:fine)]:text-sm bg-transparent rounded-md border outline-none border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 field-sizing-content min-h-16 shadow-xs transition-color disabled:cursor-not-allowed disabled:opacity-50","focus-visible:ring-1 focus-visible:ring-ring/30",t),...a})}var es=a(85060),en=a(43415);let er=en.z.object({name:en.z.string().min(1,{message:"Name is required"}),email:en.z.string().email({message:"Invalid email address"}),notes:en.z.string().optional(),timeZone:en.z.string(),selectedTime:en.z.string()});function ei(e){let{settings:t,selectedTime:a,isLoading:n,onSubmit:r,onCancel:i}=e,l=(0,X.mN)({resolver:(0,es.u)(er),defaultValues:{name:"",email:"",notes:"",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTime:a}}),o=(0,O.GP)(new Date(a),"EEEE, MMMM d 'at' h:mm a");return(0,s.jsx)(B,{...l,children:(0,s.jsxs)("form",{onSubmit:l.handleSubmit(r),className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"flex overflow-y-auto flex-col gap-4 px-4 pb-4 mt-4 text-sm",children:[(0,s.jsxs)("div",{className:"mb-2 font-medium text-primary",children:["Your booking for ",o]}),(0,s.jsx)(K,{control:l.control,name:"name",render:e=>{let{field:t}=e;return(0,s.jsxs)(G,{children:[(0,s.jsx)(V,{children:"Name *"}),(0,s.jsx)(Q,{children:(0,s.jsx)(et.p,{placeholder:"Your name",...t})}),(0,s.jsx)(ee,{className:"mt-0 mb-0"})]})}}),(0,s.jsx)(K,{control:l.control,name:"email",render:e=>{let{field:t}=e;return(0,s.jsxs)(G,{children:[(0,s.jsx)(V,{children:"Email *"}),(0,s.jsx)(Q,{children:(0,s.jsx)(et.p,{placeholder:"Your email",...t})}),(0,s.jsx)(ee,{className:"mt-0 mb-0"})]})}}),(0,s.jsx)(K,{control:l.control,name:"notes",render:e=>{let{field:t}=e;return(0,s.jsxs)(G,{children:[(0,s.jsx)(V,{children:"Notes"}),(0,s.jsx)(Q,{children:(0,s.jsx)(ea,{placeholder:"Additional notes",...t})}),(0,s.jsx)(ee,{className:"mt-0 mb-0"})]})}})]}),(0,s.jsxs)("div",{className:"flex flex-1 gap-2 justify-end p-4 border-t",children:[(0,s.jsx)(T.$,{type:"button",variant:"outline",onClick:i,disabled:n,children:"Cancel"}),(0,s.jsx)(T.$,{type:"submit",disabled:n,style:{background:t.accent_color,color:t.text_color},children:n?(0,s.jsx)("span",{className:"mr-2",children:"Confirming..."}):"Confirm Booking"})]})]})})}function el(e){let{settings:t,slots:a,cal_com_event_url:n,append:r}=e,[i,o]=(0,l.useState)(),[c,d]=(0,l.useState)(),[u,m]=(0,l.useState)(!1),[h,p]=(0,l.useState)(!1),x=Object.keys(a).map(e=>new Date(e)),g=i&&a[(0,O.GP)(i,"yyyy-MM-dd")]||[],f=async e=>{m(!0);try{let t=await $(n,{...e,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTime:null!=c?c:""});r({id:"booking",role:"system",content:"Let the user know that their booking has been \n confirmed for ".concat((0,O.GP)(new Date(c),"EEEE, MMMM d 'at' h:mm a")," (").concat(e.timeZone,") \n and that they can join the meeting here: ").concat(t.data.meetingUrl,". Do not trigger any tool calls with this response.")}),p(!0)}catch(e){r({id:"booking",role:"system",content:"Let the user know that their booking has failed. Do not trigger any tool calls with this response."})}finally{m(!1)}};return(0,s.jsx)(s.Fragment,{children:!h&&(0,s.jsxs)("div",{className:"flex flex-col bg-white rounded-xl border w-[310px] h-[338px] mt-4",children:[!i&&!c&&(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(q,{mode:"single",selected:i,onSelect:o,disabled:e=>!x.some(t=>(0,O.GP)(t,"yyyy-MM-dd")===(0,O.GP)(e,"yyyy-MM-dd")),disableNavigation:!0,showOutsideDays:!1})}),i&&!c&&(0,s.jsx)("div",{className:"flex justify-start p-4",children:(0,s.jsxs)(T.$,{variant:"link",onClick:()=>{o(void 0),d(void 0)},size:"link",className:"hover:no-underline",children:[(0,s.jsx)(W.A,{className:"w-4 h-4"}),(0,s.jsx)("span",{children:"Back"})]})}),i&&!c&&(0,s.jsx)("div",{className:"overflow-y-auto px-4 pb-4",children:(0,s.jsx)("div",{className:"grid grid-cols-1 gap-2",children:g.map(e=>(0,s.jsx)(T.$,{variant:c===e.start?"default":"outline",onClick:()=>d(e.start),children:(0,O.GP)(new Date(e.start),"h:mm a")},e.start))})}),c&&(0,s.jsx)(ei,{settings:t,selectedTime:c,isLoading:u,onSubmit:f,onCancel:()=>{o(void 0),d(void 0)}})]})})}let eo={small:"text-sm",medium:"text-base",large:"text-lg"},ec={light:{button:"text-zinc-600 hover:text-zinc-800 disabled:text-zinc-300",input:"disabled:bg-white disabled:text-muted-foreground bg-white"},dark:{button:"text-white/50 hover:text-white",input:"bg-[#2A3447] border border-slate-700/20 focus:border-slate-600/50 hover:border-slate-600/50 disabled:bg-slate-700/50 disabled:text-muted-foreground text-slate-100"}};function ed(e){let{settings:t,message:a,visitorId:r,toolCallId:i,addToolResult:o}=e,[c,d]=(0,l.useState)(""),[u,m]=(0,l.useState)(""),[h,p]=(0,l.useState)(!1),x=async e=>{if(e.preventDefault(),m(""),!c.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)){m("Please enter a valid email address");return}p(!0);try{await fetch("/api/".concat(t.id,"/leads"),{method:"POST",body:JSON.stringify({email:c,escalation_notification:!0}),headers:{"Content-Type":"application/json","x-visitor-id":r}}),o({toolCallId:i,result:"Thanks we will contact you on ".concat(c)})}catch(e){o({toolCallId:i,result:"Sorry, there was an error submitting your request."})}finally{p(!1)}};return(0,s.jsxs)("form",{onSubmit:x,children:[(0,s.jsx)("div",{className:(0,n.A)("text-sm font-normal prose [word-break:break-word]",{"bg-secondary border border-border/20 prose-zinc":"light"===t.theme,"bg-[#2A3447] border border-slate-700/20 prose-invert":"dark"===t.theme,"prose-sm":"small"===t.font_size,"prose-md":"medium"===t.font_size,"prose-lg":"large"===t.font_size}),children:(0,s.jsx)("p",{children:a})}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 items-center mt-4 sm:flex-row",children:[(0,s.jsx)(et.p,{type:"email",value:c,onChange:e=>d(e.target.value),placeholder:"Enter your email",disabled:h,className:(0,n.A)(eo[t.font_size],ec[t.theme].input)}),(0,s.jsx)(T.$,{type:"submit",disabled:h,size:"sm",className:"ml-auto",style:{background:t.accent_color,color:t.text_color},children:h?"Submitting...":"Submit"})]}),u&&(0,s.jsx)("div",{className:"text-sm text-red-500",children:u})]})}var eu=a(43670),em=a(50745);let eh={small:"text-sm",medium:"text-base",large:"text-lg"},ep={light:{input:"bg-white border-gray-300 text-gray-900",button:"bg-gray-100 hover:bg-gray-200 text-gray-900"},dark:{input:"bg-slate-800 border-slate-600 text-white",button:"bg-slate-700 hover:bg-slate-600 text-white"}};function ex(e){let{settings:t,visitorId:a,toolCallId:r,addToolResult:i,config:o}=e,c=l.useMemo(()=>{try{let e=JSON.parse(o.custom_fields);return Array.isArray(e)?e.filter(e=>e.enabled):[]}catch(e){return[]}},[o.custom_fields]),d=l.useMemo(()=>{let e={};return c.forEach(t=>{"checkbox"===t.type?e[t.name]=t.required?en.z.boolean().refine(e=>!0===e,{message:"".concat(t.label," is required")}):en.z.boolean().optional():"email"===t.type?e[t.name]=t.required?en.z.string().min(1,"".concat(t.label," is required")).email("Please enter a valid email address"):en.z.string().email("Please enter a valid email address").optional().or(en.z.literal("")):(t.type,e[t.name]=t.required?en.z.string().min(1,"".concat(t.label," is required")):en.z.string().optional())}),en.z.object(e)},[c]),u=l.useMemo(()=>{let e={};return c.forEach(t=>{e[t.name]="checkbox"!==t.type&&""}),e},[c]),m=(0,X.mN)({resolver:(0,es.u)(d),defaultValues:u}),h=async e=>{try{let s={...e};c.forEach(t=>{"checkbox"===t.type&&(s[t.name]=e[t.name]?"Yes":"No")}),"1"===o.enable_email_notifications&&(s.lead_capture_notification=!0),await fetch("/api/".concat(t.id,"/leads"),{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json","x-visitor-id":a}}),i({toolCallId:r,result:o.submitted_message})}catch(e){i({toolCallId:r,result:"Sorry, there was an error submitting your information."})}};return(0,s.jsx)(B,{...m,children:(0,s.jsxs)("form",{onSubmit:m.handleSubmit(h),className:"flex flex-col h-full max-h-[338px]",children:[(0,s.jsx)("div",{className:"flex overflow-y-auto flex-col gap-4 px-4 pb-4 mt-4 text-sm",children:c.map(e=>{switch(e.type){case"checkbox":return(0,s.jsx)(K,{control:m.control,name:e.name,render:t=>{let{field:a}=t;return(0,s.jsxs)(G,{children:[(0,s.jsxs)("div",{className:"flex flex-row items-center space-x-2 space-y-0",children:[(0,s.jsx)(Q,{children:(0,s.jsx)(eu.S,{checked:a.value,onCheckedChange:a.onChange})}),(0,s.jsx)(V,{className:"text-sm font-medium",children:e.label})]}),(0,s.jsx)(ee,{className:"mt-0 mb-0"})]})}},e.name);case"select":return(0,s.jsx)(K,{control:m.control,name:e.name,render:a=>{var r;let{field:i}=a;return(0,s.jsxs)(G,{children:[(0,s.jsx)(V,{className:"text-sm font-medium",children:(0,s.jsxs)("span",{children:[e.label," ",e.required&&"*"]})}),(0,s.jsx)(Q,{children:(0,s.jsxs)(em.l6,{...i,required:e.required,onValueChange:e=>{i.onChange(e)},children:[(0,s.jsx)(em.bq,{className:(0,n.A)("w-full",eh[t.font_size],ep[t.theme].input),children:(0,s.jsx)(em.yv,{placeholder:"Select an option..."})}),(0,s.jsx)(em.gC,{children:null===(r=e.options)||void 0===r?void 0:r.split(",").map((e,t)=>(0,s.jsx)(em.eb,{value:e.trim(),children:e.trim()},t))})]})}),(0,s.jsx)(ee,{className:"mt-0 mb-0"})]})}},e.name);default:return(0,s.jsx)(K,{control:m.control,name:e.name,render:a=>{let{field:r}=a;return(0,s.jsxs)(G,{children:[(0,s.jsx)(V,{className:"text-sm font-medium",children:(0,s.jsxs)("span",{children:[e.label," ",e.required&&"*"]})}),(0,s.jsx)(Q,{children:(0,s.jsx)(et.p,{type:"phone"===e.type?"tel":e.type,placeholder:e.placeholder,...r,className:(0,n.A)(eh[t.font_size],ep[t.theme].input)})}),(0,s.jsx)(ee,{className:"mt-0 mb-0"})]})}},e.name)}})}),(0,s.jsxs)("div",{className:"flex flex-1 gap-2 justify-end p-4 border-t",children:[(0,s.jsx)(T.$,{type:"button",variant:"outline",onClick:()=>{i({toolCallId:r,result:o.dismissed_message})},disabled:m.formState.isSubmitting,children:(0,z.NX)(t.localization,"cancel","Cancel")}),(0,s.jsx)(T.$,{type:"submit",disabled:m.formState.isSubmitting,style:{background:t.accent_color,color:t.text_color},children:m.formState.isSubmitting?(0,z.NX)(t.localization,"submitting","Submitting..."):(0,z.NX)(t.localization,"submit","Submit")})]})]})})}function eg(e){let{messages:t,settings:a,status:r,append:d,onRetry:u,addToolResult:m,visitorId:h,activeLanguage:p,defaultLanguage:x}=e,g=e=>"welcome_message"===e.type,b=async e=>{try{i()(e)}catch(e){console.error("Failed to copy text: ",e)}},v=async(e,t)=>{fetch("/api/".concat(a.id,"/messages"),{method:"PUT",body:JSON.stringify({message_id:e,feedback:t})})},y=t[t.length-1],j=l.useMemo(()=>{var e;return!(("submitted"!==r||(null==y?void 0:y.role)!=="user")&&("streaming"!==r||(null==y?void 0:y.role)!=="assistant"||(null===(e=y.parts)||void 0===e?void 0:e.some(e=>"text"===e.type&&""!==e.text.trim()))))},[r,y]),w=e=>{let{toolName:t,state:n,result:r}=e;if("book_calcom_appointment"===t&&"result"===n){var i;return(0,s.jsx)(el,{settings:a,slots:null!==(i=r.slots)&&void 0!==i?i:{},append:d,cal_com_event_url:r.cal_com_event_url})}return null},_=e=>{if(!e.parts)return[];let t=[];return e.parts.forEach(e=>{var a;"tool-invocation"===e.type&&"result"===e.toolInvocation.state&&(null===(a=e.toolInvocation.result)||void 0===a?void 0:a.sources)&&t.push(...e.toolInvocation.result.sources)}),t};return(0,s.jsxs)("div",{className:"flex flex-col flex-1 gap-6",children:[t.filter(e=>!!["assistant","user","agent"].includes(e.role)&&(!j||(null==y?void 0:y.id)!==e.id||"assistant"!==e.role)).map(e=>{var t,i,o,d,j;let k="streaming"===r&&e.id===(null==y?void 0:y.id);return(0,s.jsxs)(E,{role:e.role,avatar:e.avatar,settings:a,loading:"ready"!==r,isCurrentlyStreaming:k,commandPalette:g(e)?"never":e.id===(null==y?void 0:y.id)?"always":"hover",feedback:e.feedback,content:"string"==typeof e.content?e.content:"",sources:a.enable_sources?_(e):[],onFeedback:t=>{v(e.id,t)},onRetry:u,onCopy:()=>{b("string"==typeof e.content?e.content:"")},activeLanguage:p,defaultLanguage:x,toolRender:(null===(i=e.parts)||void 0===i?void 0:null===(t=i.find(e=>"tool-invocation"===e.type&&"result"===e.toolInvocation.state))||void 0===t?void 0:t.type)==="tool-invocation"&&("streaming"!==r||e.id!==(null==y?void 0:y.id))?w(null===(o=e.parts.find(e=>"tool-invocation"===e.type))||void 0===o?void 0:o.toolInvocation):void 0,children:["string"==typeof e.content&&""!==e.content.trim()?(0,s.jsx)(f,{chatbotId:a.id,messageId:e.id,content:e.content,displayImages:a.display_images}):null===(d=e.parts)||void 0===d?void 0:d.map((t,n)=>{let r="message-".concat(e.id,"-part-").concat(n);if("text"===t.type)return(0,s.jsx)(l.Fragment,{children:(0,s.jsx)(f,{chatbotId:a.id,messageId:e.id,content:t.text,displayImages:a.display_images})},r);if("tool-invocation"===t.type){let{toolInvocation:e}=t,{toolName:n,toolCallId:r,state:c}=e;if("call"===c){var i,o;return(0,s.jsx)(l.Fragment,{children:"request_escalation"===n?(0,s.jsx)(ed,{settings:a,message:null!==(o=null===(i=e.args)||void 0===i?void 0:i.message)&&void 0!==o?o:"",visitorId:h,toolCallId:r,addToolResult:m},r):(()=>{var t,i,l;let o=null===(t=a.actions)||void 0===t?void 0:t.find(e=>e.config.name===n&&"capture_leads"===e.action.type);return o?(0,s.jsxs)("div",{children:[null!==(l=null===(i=e.args)||void 0===i?void 0:i.message)&&void 0!==l?l:"",(0,s.jsx)("div",{className:"flex flex-col bg-white rounded-xl border w-[310px] mt-4",children:(0,s.jsx)(ex,{settings:a,visitorId:h,toolCallId:r,addToolResult:m,config:{name:o.config.name,custom_fields:o.config.custom_fields,submitted_message:o.config.submitted_message,dismissed_message:o.config.dismissed_message,enable_email_notifications:o.config.enable_email_notifications}},r)})]}):null})()},r)}}return null}),"assistant"===e.role&&e.annotations&&e.annotations.map((t,n)=>{var r,i;return(0,s.jsx)(l.Fragment,{children:(0,s.jsx)(f,{chatbotId:a.id,messageId:e.id,displayImages:a.display_images,content:(null==t?void 0:null===(i=t.message)||void 0===i?void 0:null===(r=i.content)||void 0===r?void 0:r.map(e=>e.text).join(""))||String(t)})},n)}),null===(j=e.experimental_attachments)||void 0===j?void 0:j.map((t,r)=>{var i,l,o,d;return(0,s.jsx)("div",{className:"mt-2 max-w-[300px] sm:max-w-[400px]",children:(null===(i=t.contentType)||void 0===i?void 0:i.startsWith("image/"))?(0,s.jsx)("img",{src:t.url,alt:null!==(o=t.name)&&void 0!==o?o:"attachment-".concat(r),className:"max-w-full h-auto rounded-xl",style:{maxHeight:"300px"}}):(null===(l=t.contentType)||void 0===l?void 0:l.startsWith("application/pdf"))?(0,s.jsxs)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:(0,n.A)("p-3 rounded-xl border flex items-start gap-2 text-primary",{"bg-secondary border":"light"===a.theme,"bg-slate-700 border-slate-600":"dark"===a.theme}),children:[(0,s.jsx)(c.A,{className:"w-4 h-4 mt-0.5"}),(0,s.jsx)("span",{className:"text-sm truncate",children:null!==(d=t.name)&&void 0!==d?d:"PDF Document ".concat(r+1)})]}):null},"".concat(e.id,"-attachment-").concat(r))})]},e.id)}),j&&(0,s.jsx)(E,{role:"assistant",settings:a,commandPalette:"never",activeLanguage:p,defaultLanguage:x,children:(0,s.jsx)(o.A,{size:5,color:"#d4d4d8"})},"loading")]})}},46409:(e,t,a)=>{"use strict";a.d(t,{A:()=>g});var s=a(95155),n=a(43463),r=a(12115),i=a(4834),l=a(40767);function o(e){let{settings:t,title:a,showClose:r,onClear:o,onClose:c}=e;return(0,s.jsx)("div",{className:"flex flex-col w-full",children:(0,s.jsx)("div",{className:"px-5 py-6 shadow-sm shrink-0",style:{background:t.accent_color},children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 items-center",children:[t.header_icon&&(0,s.jsx)("img",{src:t.header_icon,alt:"Chatbot",className:"w-12 h-12"}),(0,s.jsx)("h1",{className:(0,n.A)("small"===t.font_size&&"text-lg","medium"===t.font_size&&"text-xl","large"===t.font_size&&"text-xl","font-medium"),style:{color:t.text_color},children:a||t.name||"Chatbot"}),(0,s.jsx)("div",{className:"text-base font-normal text-center opacity-95",style:{color:t.text_color},children:t.welcome_message.split("\n")[0]}),(0,s.jsxs)("div",{className:"flex absolute top-0 right-2 items-center py-3",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{o&&o()},className:"inline-flex justify-center items-center p-1 rounded-lg transition-all duration-150 bg-transpare hover:opacity-90 focus:opacity-90",style:{color:t.text_color},children:(0,s.jsx)(i.A,{size:20,strokeWidth:1.5})}),r&&(0,s.jsx)("button",{type:"button",onClick:()=>{window.parent.postMessage({closeChat:!0},"*"),c&&c()},className:"inline-flex justify-center items-center p-1 bg-transparent rounded-lg transition-all duration-150 hover:opacity-90 focus:opacity-90",style:{color:t.text_color},children:(0,s.jsx)(l.A,{size:24,strokeWidth:1.5})})]})]})})})}var c=a(77132),d=a(14085);function u(e){let{showClear:t,onClear:a,settings:r,activeLanguage:l,defaultLanguage:o}=e;return(0,s.jsx)("div",{className:(0,n.A)("w-full ring-1 shadow-xs",{"ring-primary/5":"light"===r.theme,"ring-white/5 bg-white/2":"dark"===r.theme}),children:(0,s.jsxs)("div",{className:"flex justify-between items-center px-5 mx-auto max-w-4xl h-12",children:[(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[r.share_icon&&(0,s.jsx)("img",{src:r.share_icon,alt:"Share icon",className:"size-6"}),(0,s.jsx)("h1",{className:"text-sm font-medium text-primary",style:{color:"dark"===r.theme?r.text_color:""},children:r.name})]}),t&&(0,s.jsx)(d.$,{variant:"outline",size:"xs",onClick:a,title:(0,c.NX)(r.localization,"clear_chat",l,o)||"Clear chat",className:(0,n.A)({"text-slate-300 border border-slate-700 hover:text-slate-200 hover:bg-slate-700/20 bg-transparent":"dark"===r.theme}),children:(0,s.jsx)(i.A,{size:20,strokeWidth:1.5})})]})})}var m=a(9246);function h(e){let{settings:t,title:a,showClose:r,onClear:o,onClose:d,activeLanguage:u,defaultLanguage:h}=e;return(0,s.jsx)("div",{className:"flex flex-col w-full",children:(0,s.jsx)("div",{className:"px-5 py-3.5 shrink-0 shadow-sm",style:{background:t.accent_color},children:(0,s.jsxs)("div",{className:"flex gap-2 justify-between items-center",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2 truncate",children:[t.header_icon&&(0,s.jsx)("img",{src:t.header_icon,alt:"Chatbot",className:"w-8 h-8"}),(0,s.jsx)("p",{className:(0,n.A)("small"===t.font_size&&"text-base","medium"===t.font_size&&"text-lg","large"===t.font_size&&"text-xl","flex-1 min-w-0 font-medium truncate"),style:{color:t.text_color},children:a||t.name||"Chatbot"})]}),(0,s.jsxs)("div",{className:"flex items-center py-1 -mr-3",children:[(0,s.jsx)(m.Bc,{children:(0,s.jsxs)(m.m_,{children:[(0,s.jsx)(m.k$,{asChild:!0,children:(0,s.jsx)("button",{type:"button",onClick:()=>{o&&o()},className:"inline-flex items-center justify-center p-1.5 transition-all duration-150 bg-transpare rounded-lg hover:opacity-90 focus:opacity-90",style:{color:t.text_color},children:(0,s.jsx)(i.A,{size:20,strokeWidth:1.5})})}),(0,s.jsx)(m.ZI,{children:(0,s.jsx)("p",{children:(0,c.NX)(t.localization,"clear_chat",u,h)||"Clear chat"})})]})}),r&&(0,s.jsx)("button",{type:"button",onClick:()=>{window.parent.postMessage({closeChat:!0},"*"),d&&d()},className:"inline-flex justify-center items-center p-1 bg-transparent rounded-lg transition-all duration-150 hover:opacity-90 focus:opacity-90",style:{color:t.text_color},children:(0,s.jsx)(l.A,{size:24,strokeWidth:1.5})})]})]})})})}var p=a(51719);function x(e){let{onClick:t,theme:a,className:r,style:i}=e;return(0,s.jsx)("button",{onClick:t,className:(0,n.A)("absolute rounded-full p-2 shadow-xs opacity-0 transition-all border duration-150",r,"light"===a?"bg-white hover:border-primary/20":"text-white/50 bg-slate-800 border border-slate-700 hover:text-slate-200 hover:bg-[#29384C]","animate-fade-in"),"aria-label":"Scroll to bottom",style:i,children:(0,s.jsx)(p.A,{className:(0,n.A)("light"===a?"text-muted-foreground":"text-white/50"),size:20})})}function g(e){let{mode:t,settings:a,title:i,showClose:l,showClear:c,onClose:d,onClear:m,children:p,textareaHeight:g,activeLanguage:f,defaultLanguage:b}=e,{scrollRef:v,showScrollButton:y,autoScroll:j,scrollToBottom:w,handleScroll:_}=function(){let e=(0,r.useRef)(null),[t,a]=(0,r.useState)(!1),[s,n]=(0,r.useState)(!0);return{scrollRef:e,showScrollButton:t,autoScroll:s,scrollToBottom:()=>{e.current&&e.current.scrollTo({top:e.current.scrollHeight,behavior:"smooth"})},handleScroll:()=>{if(!e.current)return;let{scrollTop:t,scrollHeight:s,clientHeight:r}=e.current,i=10>Math.abs(s-r-t);a(!(180>Math.abs(s-r-t))),n(i)}}}();return(0,r.useEffect)(()=>{j&&w()},[p,j,w]),(0,s.jsx)(s.Fragment,{children:a&&(0,s.jsxs)("div",{className:"flex absolute inset-0 flex-col min-h-screen",style:{background:a.background_color},children:["small"===a.header_size&&"embed"===t&&(0,s.jsx)(h,{settings:a,title:i,showClose:l,onClose:d,onClear:m,activeLanguage:f,defaultLanguage:b}),"large"===a.header_size&&"embed"===t&&(0,s.jsx)(o,{settings:a,title:i,showClose:l,onClose:d,onClear:m}),"share"===t&&(0,s.jsx)(u,{showClear:c,onClear:m,settings:a,activeLanguage:f,defaultLanguage:b}),(0,s.jsx)("div",{ref:v,onScroll:_,className:(0,n.A)("flex flex-col flex-1 overflow-y-scroll",{"pb-[4rem]":a.hide_powered_by,"pb-[6rem]":!a.hide_powered_by}),children:(0,s.jsx)("div",{className:(0,n.A)("flex-1",{"w-full max-w-2xl mx-auto":"share"===t}),children:p})}),y&&(0,s.jsx)(x,{onClick:w,theme:a.theme,className:"right-5",style:{bottom:"".concat(g+(a.hide_powered_by?46:76),"px")}})]})})}},50745:(e,t,a)=>{"use strict";a.d(t,{bq:()=>u,eb:()=>h,gC:()=>m,l6:()=>c,yv:()=>d});var s=a(95155),n=a(62058),r=a(51719),i=a(98867),l=a(91902);a(12115);var o=a(29602);function c(e){let{...t}=e;return(0,s.jsx)(n.bL,{"data-slot":"select",...t})}function d(e){let{...t}=e;return(0,s.jsx)(n.WT,{"data-slot":"select-value",...t})}function u(e){let{className:t,size:a="default",children:i,...l}=e;return(0,s.jsxs)(n.l9,{"data-slot":"select-trigger","data-size":a,className:(0,o.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","focus-visible:ring-1 focus-visible:ring-ring/30",t),...l,children:[i,(0,s.jsx)(n.In,{asChild:!0,children:(0,s.jsx)(r.A,{className:"opacity-50 size-4"})})]})}function m(e){let{className:t,children:a,position:r="popper",...i}=e;return(0,s.jsx)(n.ZL,{children:(0,s.jsxs)(n.UC,{"data-slot":"select-content",className:(0,o.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...i,children:[(0,s.jsx)(p,{}),(0,s.jsx)(n.LM,{className:(0,o.cn)("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),(0,s.jsx)(x,{})]})})}function h(e){let{className:t,children:a,...r}=e;return(0,s.jsxs)(n.q7,{"data-slot":"select-item",className:(0,o.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...r,children:[(0,s.jsx)("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,s.jsx)(n.VF,{children:(0,s.jsx)(i.A,{className:"size-4"})})}),(0,s.jsx)(n.p4,{children:a})]})}function p(e){let{className:t,...a}=e;return(0,s.jsx)(n.PP,{"data-slot":"select-scroll-up-button",className:(0,o.cn)("flex justify-center items-center py-1 cursor-default",t),...a,children:(0,s.jsx)(l.A,{className:"size-4"})})}function x(e){let{className:t,...a}=e;return(0,s.jsx)(n.wn,{"data-slot":"select-scroll-down-button",className:(0,o.cn)("flex justify-center items-center py-1 cursor-default",t),...a,children:(0,s.jsx)(r.A,{className:"size-4"})})}},72347:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});var s=a(95155),n=a(43463);function r(e){let{messages:t,settings:a,onSelect:r}=e,i=(0,n.A)("max-w-xs truncate inline-block flex-shrink-0 px-3 py-1 text-sm font-base transition-colors rounded-lg focus:outline-none cursor-pointer",{"border hover:bg-secondary/50 text-primary":"light"===a.theme,"text-slate-300 bg-[#2A3447] border border-slate-700/20 hover:text-slate-200 hover:bg-slate-700/60":"dark"===a.theme});return(0,s.jsx)("div",{className:(0,n.A)("flex items-center gap-3",{"text-sm":"small"===a.font_size,"text-base":"medium"===a.font_size,"text-lg":"large"===a.font_size,"overflow-x-auto pb-4 -mb-4":a.scroll_smart_prompts,"flex-wrap justify-end":!a.scroll_smart_prompts}),children:t.map((e,t)=>(0,s.jsx)("button",{type:"button",onClick:()=>r(e),className:i,children:e},t))})}},77132:(e,t,a)=>{"use strict";a.d(t,{NX:()=>s,od:()=>n});let s=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"en",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"en",r=arguments.length>4?arguments[4]:void 0;if(!e)return r;for(let l of e){if(l.key===t){var i;if(l.translations&&l.translations[a])return l.translations[a];if(l.translations&&a!==n&&l.translations[n])return l.translations[n];if(null!==l.value&&void 0!==l.value)return l.value;return null!==(i=l.default)&&void 0!==i?i:r}if(l.children){let e=s(l.children,t,a,n,r);if(e)return e}}return r},n=function(e,t,a){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"en";if(e&&a.includes(e))return e;if(t){let e=t.split("-")[0].toLowerCase();if(a.includes(e))return e}return s}},79214:(e,t,a)=>{"use strict";a.d(t,{B:()=>r});var s=a(77132),n=a(12115);function r(e,t){let a=(0,n.useMemo)(()=>{var a;if(!e)return"en";let n=e.enabled_languages||[{code:"en",name:"English",isDefault:!0}],r=(null===(a=n.find(e=>e.isDefault))||void 0===a?void 0:a.code)||"en",i=n.map(e=>e.code);return e.active_language&&"auto"!==e.active_language?e.active_language:(0,s.od)(t,"undefined"!=typeof navigator?navigator.language:void 0,i,r)},[e,t]),r=(0,n.useMemo)(()=>{var t;return e&&(null===(t=(e.enabled_languages||[{code:"en",name:"English",isDefault:!0}]).find(e=>e.isDefault))||void 0===t?void 0:t.code)||"en"},[e]);return{activeLanguage:a,defaultLanguage:r,t:(t,n)=>(null==e?void 0:e.localization)?(0,s.NX)(e.localization,t,a,r,n)||n||t:n||t}}},86530:(e,t,a)=>{"use strict";a.d(t,{t:()=>u});var s=a(76046),n=a(12389),r=a.n(n),i=a(12115),l=a(25658),o=a(13697),c=a(29602),d=a(84158);function u(e,t){let a=(0,s.useSearchParams)(),n=(null==a?void 0:a.get("title"))||"",u=(null==a?void 0:a.get("theme"))||"light",m=(null==a?void 0:a.has("nc"))||"share"===t||!1,h=(null==a?void 0:a.has("nf"))||!1,p=(null==a?void 0:a.get("pu"))||(null==a?void 0:a.get("pageUrl"))||"",x=(null==a?void 0:a.get("lang"))||"",g=function(e){let[t,a]=(0,i.useState)(void 0);return(0,i.useEffect)(()=>{if(!e)return;let t=e=>{var t;let s=window.location.hostname.includes("localhost"),n="";try{n=new URL(e.origin).hostname}catch(t){console.warn("\uD83D\uDEAB Invalid origin in postMessage:",e.origin);return}if(!(s?["localhost","127.0.0.1","sitespeakai.test"]:["sitespeak.ai","sitespeakai.test","chatbot.sitespeak.ai"]).includes(n)){console.warn("\uD83D\uDEAB Ignored postMessage from unauthorized origin:",e.origin);return}if((null===(t=e.data)||void 0===t?void 0:t.type)==="PLAYGROUND_SETTINGS"){let t,s;if(null===e.data.settings){a(void 0);return}let{model:n,instructions:r,temperature:i}=e.data.settings,l=n&&"string"==typeof n&&n.trim().length>0?n.trim():void 0;r&&"string"==typeof r&&0===(t=r.substring(0,1e4).replace(/<script[^>]*>.*?<\/script>/gi,"").replace(/javascript:/gi,"").replace(/data:.*?base64/gi,"").trim()).length&&(t=void 0),"number"==typeof i&&i>=0&&i<=2&&(s=Math.round(100*i)/100),a({model:l,instructions:t,temperature:s})}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e]),t}((null==a?void 0:a.has("playground"))||!1),f=function(){let[e,t]=(0,i.useState)("");return(0,i.useEffect)(()=>{let e=localStorage.getItem("visitor_id");if(e)t(e);else{let e=(0,o.A)();localStorage.setItem("visitor_id",e),t(e)}},[]),e}(),{sessionId:b,resetSession:v}=function(){let[e,t]=(0,i.useState)("");return(0,i.useEffect)(()=>{let e=sessionStorage.getItem("session_id");if(e)t(e);else{let e=(0,o.A)();sessionStorage.setItem("session_id",e),t(e)}},[]),{sessionId:e,resetSession:(0,i.useCallback)(()=>{let e=(0,o.A)();sessionStorage.setItem("session_id",e),t(e)},[])}}(),{identity:y,identify:j}=function(e){let[t,a]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let t=localStorage.getItem("identity-".concat(e));t&&a(JSON.parse(t))},[e]),{identity:t,identify:t=>{a(t),localStorage.setItem("identity-".concat(e),JSON.stringify(t))}}}(e),[w,_]=(0,i.useState)(()=>"share"===t||!(null==a?void 0:a.has("em"))),{settings:k,previousMessages:N,prompts:z,lead:C,leadData:S}=function(e,t,a){var s,n,r,i,o,c,d;let u=!(arguments.length>3)||void 0===arguments[3]||arguments[3],m=(0,l.E)({queries:[{queryKey:["chatbot",e,"settings"],queryFn:()=>fetch("/api/".concat(e,"/settings")).then(e=>e.json()),enabled:u},{queryKey:["chatbot",e,"prompts"],queryFn:()=>fetch("/api/".concat(e,"/prompts")).then(e=>e.json()),enabled:u},{queryKey:["messages",e,t,a],queryFn:()=>fetch("/api/".concat(e,"/messages?limit=50&include_sources=true&include_attachments=true"),{headers:{"x-visitor-id":t,"x-session-id":a}}).then(e=>e.json()),enabled:u&&!!t&&!!a},{queryKey:["lead",e,t],queryFn:()=>fetch("/api/".concat(e,"/leads"),{headers:{"x-visitor-id":t}}).then(e=>e.json()),enabled:u&&!!t}]});return{settings:null!==(r=m[0].data)&&void 0!==r?r:null,prompts:null!==(i=m[1].data)&&void 0!==i?i:[],previousMessages:null!==(o=m[2].data)&&void 0!==o?o:[],lead:null!==(c=null===(s=m[3].data)||void 0===s?void 0:s.exists)&&void 0!==c?c:void 0,leadData:null!==(d=null===(n=m[3].data)||void 0===n?void 0:n.lead)&&void 0!==d?d:void 0}}(e,f,b,w),A=(0,i.useMemo)(()=>{if(!k||!(0,c.eF)(k,t))return[];let e=(null==y?void 0:y.traits)||{};return k.welcome_messages.map(t=>({...t,content:"string"==typeof t.content?(0,c.pW)(t.content,e):t.content}))},[k,y,t]),I=function(e,t,a,s){var n;let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],i=arguments.length>5?arguments[5]:void 0,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"embed",d=arguments.length>7?arguments[7]:void 0,u=arguments.length>8?arguments[8]:void 0,m=(null==i?void 0:i.traits)||{},h=(null!==(n=null==s?void 0:s.welcome_messages)&&void 0!==n?n:[]).map(e=>({...e,content:"string"==typeof e.content?(0,c.pW)(e.content,m):e.content})),p=[...(0,c.eF)(s,l)?h:[],...null!=r?r:[]].map(e=>({...e,role:"agent"===e.role?"assistant":e.role}));return{id:t,api:d?"/api/".concat(e,"/chat?pu=").concat(encodeURIComponent(d)):"/api/".concat(e,"/chat"),generateId:()=>(0,o.A)(),sendExtraMessageFields:!0,maxSteps:5,initialMessages:p,experimental_prepareRequestBody(e){let{messages:t,id:n}=e;return{message:t[t.length-1],id:n,sessionId:a,topK:null==s?void 0:s.topK,topN:null==s?void 0:s.rerank_matches_topN,identity:i,tempSettings:u}}}}(e,f,b,k,N,y||void 0,t,p||void 0,g),{messages:M,status:F,setMessages:L,reload:E,addToolResult:T,append:R}=(0,d.Y_)(I),[P,D]=(0,i.useState)(!0),[q,$]=(0,i.useState)(!0),[O,W]=(0,i.useState)(!1),[Z,X]=(0,i.useState)(null),[U,B]=(0,i.useState)(16),J=(0,i.useCallback)(async t=>{await fetch("/api/".concat(e,"/leads"),{method:"POST",headers:{"Content-Type":"application/json","x-visitor-id":f},body:JSON.stringify(t)})},[e,f]),K=async e=>{try{await J({...e,notify:!1}),D(!1)}catch(e){throw console.error("Failed to submit lead:",e),e}},H=(0,i.useCallback)(()=>{"ready"===F&&(L(A),fetch("/api/".concat(e,"/messages"),{method:"DELETE",headers:{"x-visitor-id":f,"x-session-id":b}}),v())},[F,L,A,e,f,b,v]),Y=(0,i.useCallback)(()=>{window.parent.postMessage({closeChat:!0},"*")},[]),G=(0,i.useCallback)(()=>{"ready"===F&&0!==M.length&&"assistant"===M[M.length-1].role&&E()},[F,M,E]),V=(null==k?void 0:k.enable_lead_capture)&&!1===C,Q=(null==k?void 0:k.enable_notice)&&q,ee=(0,i.useMemo)(()=>{if("ready"!==F||0===M.length)return null;let e=[...M].reverse().find(e=>"assistant"===e.role);if(!(null==e?void 0:e.parts))return null;let t=e.parts.find(e=>{var t;return"tool-invocation"===e.type&&"result"===e.toolInvocation.state&&(null===(t=e.toolInvocation.result)||void 0===t?void 0:t.type)==="suggested_messages"});if((null==t?void 0:t.type)==="tool-invocation"){let e=t.toolInvocation;if("result"in e){var a;return(null===(a=e.result)||void 0===a?void 0:a.suggestedMessages)||null}}return null},[M,F]),et=(0,i.useMemo)(()=>{if(!z)return[];let e=z.filter(e=>"escalate"===e.type);if(!(M.filter(e=>"user"===e.role).length>0))return[...z.filter(e=>["ai","redirect","email","intercom"].includes(e.type)),...e];{let t=z.filter(e=>["follow_up","follow_up_link","follow_up_email"].includes(e.type));return t.length>0?[...t,...e]:[...z.filter(e=>["ai","redirect","email","intercom"].includes(e.type)),...e]}},[z,M]);return(0,i.useEffect)(()=>{if(null==k?void 0:k.background_color)return document.body.style.backgroundColor=k.background_color,()=>{document.body.style.backgroundColor=""}},[null==k?void 0:k.background_color]),(0,i.useEffect)(()=>{k&&z&&void 0!==C&&(W(!0),"embed"===t&&window.parent.postMessage({onChatReady:!0},"*"))},[k,z,C,t]),(0,i.useEffect)(()=>{S&&!y&&j({traits:{...S,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}})},[S,y,j]),(0,i.useEffect)(()=>{if("embed"!==t)return;let a=t=>{if(t.data.openChat&&_(!0),t.data.closeChat&&_(!1),"string"==typeof t.data.initialMessage){let e=t.data.initialMessage.trim();e.length>0&&(_(!0),O?R({role:"user",content:e}):X(e))}if(e&&f&&t.data.identify){let e=t.data.identify;j({...e,traits:{...e.traits,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}),J({internal_user_id:e.userId||"",email:e.traits.email||"",first_name:e.traits.first_name||"",last_name:e.traits.last_name||"",notify:!1})}};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[e,f,j,J,t,O,R]),(0,i.useEffect)(()=>{O&&Z&&(R({role:"user",content:Z}),X(null))},[O,Z,R]),(0,i.useEffect)(()=>{if(!e||!f)return;let t=new(r())("5c2db8a5c48ff0d33ac8",{cluster:"mt1",authEndpoint:"/api/pusher/auth"}),a=t.subscribe("private-chatbot.".concat(e,"-visitor.").concat(f));return a.bind("message-sent-agent",e=>{let t={id:e.messageId,role:"agent",avatar:e.avatar,content:e.message,createdAt:new Date};L(e=>[...e,t])}),()=>{a.unbind_all(),a.unsubscribe(),t.disconnect()}},[e,f,L]),{title:n,theme:u,noClose:m,noFocus:h,mode:t,langParam:x,settings:k,isReady:O,messages:M,status:F,prompts:z,showLeadCaptureForm:P,shouldShowLeadCapture:V,showNoticeForm:q,shouldShowNotice:Q,textareaHeight:U,processedWelcomeMessages:A,suggestedMessages:ee,filteredPrompts:et,hasConversation:M.length>0,shouldShowWelcomeMessage:0===M.length&&A.length>0,chatConfig:I,append:R,addToolResult:T,reload:E,setMessages:L,handleLeadCapture:K,handleNoticeAccept:()=>{$(!1)},handleClear:H,handleClose:Y,handleRetry:G,setTextareaHeight:B,visitorId:f}}},88511:(e,t,a)=>{"use strict";a.d(t,{G5:()=>_,Ay:()=>j});var s=a(95155),n=a(43463),r=a(40767),i=a(15015),l=a(28283),o=a(12115),c=a(68403),d=a(96246),u=a(77132),m=a(84158),h=a(26164),p=a(10844),x=a(89097);function g(e){let{language:t,theme:a,disabled:n,onTranscript:r,onTranscriptStart:i,onTranscriptEnd:l}=e;return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(f,{language:t,theme:a,disabled:n,onTranscript:r,onTranscriptStart:i,onTranscriptEnd:l})})}function f(e){let{language:t,theme:a,disabled:n,onTranscript:r,onTranscriptStart:i,onTranscriptEnd:l}=e,[c,d]=(0,o.useState)(!1),u=o.useRef(null);(0,o.useEffect)(()=>((async()=>{let e=await (0,x.b)();if(!e){console.error("No Azure token found");return}let a=p.SpeechConfig.fromAuthorizationToken(e,"eastus");a.speechRecognitionLanguage=t||"en-US",a.outputFormat=p.OutputFormat.Detailed,a.setProfanity(p.ProfanityOption.Raw),a.enableDictation();let s=p.AudioConfig.fromDefaultMicrophoneInput(),n=new p.SpeechRecognizer(a,s);n.recognizing=(e,t)=>{r(t.result.text)},n.recognized=(e,t)=>{t.result.reason===p.ResultReason.RecognizedSpeech?(l(t.result.text),d(!1)):t.result.reason===p.ResultReason.NoMatch&&(console.log("No speech recognized"),d(!1))},u.current=n})(),()=>{u.current&&(u.current.close(),u.current=null)}),[t,r,l]);let m=async()=>{if(u.current){d(!0),i();try{u.current.recognizeOnceAsync()}catch(e){console.error("Failed to start recognition:",e),d(!1)}}},h=async()=>{if(u.current&&c)try{u.current.close(),d(!1)}catch(e){console.error("Failed to stop recognition:",e),d(!1)}};return(0,s.jsx)(b,{theme:a||"light",disabled:n,listen:m,listening:c,stop:h})}function b(e){let{theme:t,disabled:a,listen:r,listening:i,stop:l}=e;return(0,s.jsx)("button",{type:"button",disabled:a,className:(0,n.A)("rounded-lg text-zinc-600 hover:text-zinc-800 focus:outline-none disabled:text-zinc-300 opacity-0 animate-fade-in",{"p-1":!i,"p-0.5":i,"text-zinc-600 hover:text-zinc-800 disabled:text-zinc-300":"light"===t,"text-white/50 hover:text-white":"dark"===t}),onClick:()=>{if(i)try{l()}catch(e){console.error(e)}else try{r()}catch(e){console.error(e)}},children:i?(0,s.jsxs)("span",{className:"flex relative justify-center items-center w-6 h-6 bg-rose-400 rounded-full",children:[(0,s.jsx)("span",{className:"inline-flex absolute w-full h-full text-white rounded-full animate-ping bg-rose-400/20"}),(0,s.jsx)(h.A,{size:20,strokeWidth:1.75,className:"text-white"})]}):(0,s.jsx)(h.A,{size:20,strokeWidth:1.75})})}let v={small:"pt-3 text-base [@media(pointer:fine)]:text-sm",medium:"pt-3 text-base",large:"pt-3 text-lg"},y={light:{button:"text-zinc-600 hover:text-zinc-800 disabled:text-zinc-300",input:"disabled:bg-white disabled:text-muted-foreground bg-white focus:border-primary/20 hover:border-primary/20",powered:"text-primary hover:text-primary/50"},dark:{button:"text-white/50 hover:text-white",input:"bg-[#2A3447] border border-slate-700/20 focus:border-slate-600/50 hover:border-slate-600/50 disabled:bg-slate-700/50 disabled:text-muted-foreground text-slate-100",powered:"text-white/50 hover:text-white"}},j=(0,o.memo)(function(e){let{mode:t,settings:a,chatConfig:c,loading:d,onHeightChange:u,position:h="fixed",autoFocus:p=!0,activeLanguage:x="en",defaultLanguage:f="en"}=e,{input:b,setInput:j,handleInputChange:k,handleSubmit:N,append:z}=(0,m.Y_)(c),[C,S]=(0,o.useState)(null),A=(0,o.useRef)(null),I=(0,o.useRef)(null),M=(0,o.useRef)(null),F=(0,o.useRef)(null),L=e=>{let t;if(e.preventDefault(),(b||C)&&!d){if(C){let e=new DataTransfer;e.items.add(C),t=e.files}N(e,{experimental_attachments:t}),S(null),A.current&&(A.current.value="")}},E=(0,o.useCallback)(e=>{j(e)},[j]),T=(0,o.useCallback)(()=>{j("")},[j]),R=(0,o.useCallback)(e=>{j(e),setTimeout(()=>{z({role:"user",content:e}),j("")},500)},[j,z]);return(0,o.useEffect)(()=>{let e=I.current;if(!e||!u)return;let t=()=>{var t;let a=e.getBoundingClientRect().height,s=(null===(t=F.current)||void 0===t?void 0:t.getBoundingClientRect().height)||0,n=0;"fixed"===h&&(n=s-10),u(a+n)},a=new ResizeObserver(()=>{t()});return a.observe(e),t(),()=>{a.disconnect()}},[u,h,a.hide_powered_by,a.footer_message]),(0,s.jsxs)("div",{ref:M,className:(0,n.A)("min-h-[46px]",{"fixed bottom-0 bg-gradient-to-b from-transparent z-10 pb-0":"fixed"===h,relative:"relative"===h,"left-5 right-5":"embed"===t,"right-5 left-5 md:right-auto md:left-auto md:w-full md:pr-10 max-w-2xl mx-auto":"share"===t&&"fixed"===h,"bg-white/50":a.hide_powered_by&&!a.footer_message,"bg-white/80":!a.hide_powered_by||a.footer_message,"to-white":"light"===a.theme,"to-slate-800/10":"dark"===a.theme}),style:{backgroundColor:"dark"===a.theme?"rgb(30, 41, 59, 0.95)":"auto"},children:[(0,s.jsxs)("div",{className:"relative min-h-[46px]",children:[(0,s.jsxs)("pre",{className:(0,n.A)(v[a.font_size],"text-transparent py-3 pl-4 pr-20 font-sans max-h-[200px] break-words whitespace-pre-wrap overflow-hidden",{"pb-14":C}),children:[b,(0,s.jsx)("br",{})]}),(0,s.jsxs)("form",{onSubmit:L,children:[(0,s.jsx)("textarea",{ref:I,id:"message",name:"message",placeholder:a.placeholder,className:(0,n.A)(v[a.font_size],y[a.theme].input,"shadow-xs border border-zinc-950/10 transition-colors absolute left-0 rounded-xl w-full h-full py-4 pl-4 font-normal overflow-hidden whitespace-pre-wrap appearance-none resize-none focus:outline-none break-words max-h-[200px]",{"bottom-5":"fixed"===h,"bottom-0":"relative"===h,"pr-28":a.enable_file_uploads&&a.enable_speech_to_text,"pr-18":!a.enable_file_uploads||!a.enable_speech_to_text}),"aria-label":a.placeholder,enterKeyHint:"enter",autoComplete:"off",autoFocus:p,value:b,maxLength:500,onChange:k,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),(b||C)&&!d&&L(new Event("submit")))}}),a.enable_file_uploads&&(0,s.jsx)("input",{ref:A,type:"file",accept:".pdf,image/*",onChange:e=>{if(e.target.files&&e.target.files.length>0){let t=e.target.files[0];if(t.size>1048576){alert("File size too large. Please upload files smaller than 1MB.");return}if(!["application/pdf","image/jpeg","image/png","image/gif","image/webp"].includes(t.type)){alert("File type not supported. Please upload PDF or image files only.");return}S(t)}},className:"hidden",disabled:d}),C&&(0,s.jsx)("div",{className:(0,n.A)("absolute left-2 w-fit px-2 py-1 rounded-lg border",{"bottom-7":"fixed"===h,"bottom-2":"relative"===h,"bg-gray-50 border-gray-200":"light"===a.theme,"bg-slate-700 border-slate-600":"dark"===a.theme}),children:(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsxs)("span",{className:"text-xs line-clamp-1 max-w-[150px]",children:[C.name," (",(C.size/1024).toFixed(1),"KB)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>{S(null),A.current&&(A.current.value="")},className:"ml-2 text-muted-foreground hover:text-primary",children:(0,s.jsx)(r.A,{size:14,strokeWidth:2})})]})}),(0,s.jsxs)("div",{className:(0,n.A)("absolute flex items-center gap-0.5 right-2",{"-top-2.5":"fixed"===h,"top-2.5":"relative"===h}),children:[a.enable_file_uploads&&(0,s.jsxs)("button",{type:"button",onClick:()=>{var e;return null===(e=A.current)||void 0===e?void 0:e.click()},disabled:d,className:(0,n.A)("p-1 rounded-lg focus:outline-none cursor-pointer transition-colors",{"text-zinc-600 hover:text-zinc-800 disabled:text-zinc-300":"light"===a.theme,"text-white/50 hover:text-white disabled:text-white/20":"dark"===a.theme}),title:C?"Replace file":"Upload file",children:[(0,s.jsx)(i.A,{size:18,strokeWidth:1.75}),(0,s.jsx)("span",{className:"sr-only",children:"Upload files"})]}),a.enable_speech_to_text&&!d&&(0,s.jsx)(g,{language:a.speech_services_language.split(",")[0],theme:a.theme,onTranscript:E,onTranscriptStart:T,onTranscriptEnd:R}),(b||C)&&!d&&(0,s.jsx)("button",{type:"submit",disabled:!b&&!C||d,className:(0,n.A)("p-1 rounded-lg focus:outline-none cursor-pointer opacity-0 animate-fade-in",{"text-zinc-600 hover:text-zinc-800 disabled:text-zinc-300":"light"===a.theme,"text-white/50 hover:text-white":"dark"===a.theme}),children:(0,s.jsx)(l.A,{size:18,strokeWidth:1.75})})]})]})]}),"fixed"===h&&!a.hide_powered_by&&(0,s.jsx)(_,{settings:a,activeLanguage:x,defaultLanguage:f}),"fixed"===h&&a.footer_message&&(0,s.jsx)(w,{settings:a,ref:F})]})});function w(e){let{settings:t,ref:a}=e;return t.footer_message?(0,s.jsx)("div",{ref:a,className:(0,n.A)("flex justify-center items-center px-4 pb-4 w-full",{"-mt-1":t.hide_powered_by}),children:(0,s.jsx)("div",{className:(0,n.A)("text-sm font-normal max-w-2xl text-center",{"text-muted-foreground/80":"light"===t.theme,"text-muted-foreground":"dark"===t.theme}),children:(0,s.jsx)(c.oz,{remarkPlugins:[d.A],components:{p:e=>{let{children:t}=e;return(0,s.jsx)("p",{className:"mb-1 text-center last:mb-0",children:t})},a:e=>{let{href:a,children:r}=e;return(0,s.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:(0,n.A)("underline transition-colors duration-150",{"text-primary hover:text-primary/50":"light"===t.theme,"text-white/70 hover:text-white":"dark"===t.theme}),children:r})},ul:e=>{let{children:t}=e;return(0,s.jsx)("ul",{className:"inline-block list-disc list-inside text-left",children:t})},ol:e=>{let{children:t}=e;return(0,s.jsx)("ol",{className:"inline-block list-decimal list-inside text-left",children:t})},li:e=>{let{children:t}=e;return(0,s.jsx)("li",{className:"mb-1",children:t})}},children:t.footer_message})})}):null}function _(e){let{settings:t,activeLanguage:a="en",defaultLanguage:r="en"}=e;return(0,s.jsx)("div",{className:(0,n.A)("flex gap-1 justify-center items-center w-full -mt-1",{"pb-4":!t.footer_message,"pb-2":t.footer_message}),children:(0,s.jsxs)("p",{className:(0,n.A)("text-sm font-normal",{"text-muted-foreground/80":"light"===t.theme,"text-muted-foreground":"dark"===t.theme}),children:[(0,s.jsxs)("span",{children:[(0,u.NX)(t.localization,"powered_by",a,r)||"Powered by"," "]}),(0,s.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://sitespeak.ai?via=widget&ref=".concat(t.id),className:(0,n.A)("transition-colors duration-150",{"text-primary hover:text-primary/50":"light"===t.theme,"text-white/50 hover:text-white":"dark"===t.theme}),children:"SiteSpeakAI"})]})})}},88632:()=>{},89097:(e,t,a)=>{"use strict";a.d(t,{b:()=>n});let s=null;async function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(s&&s.expiresAt>Date.now())return s.token;let a=0;for(;a<=e;)try{let t=await fetch("/api/azure/auth?v=".concat(Math.round(1e6*Math.random())),{method:"POST",headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(t.ok){let e=await t.json();return s={token:e.token,expiresAt:Date.now()+48e4},e.token}++a<=e&&await new Promise(e=>setTimeout(e,1e3*Math.pow(2,a-1)))}catch(t){++a<=e&&await new Promise(e=>setTimeout(e,1e3*Math.pow(2,a-1)))}return t||console.error("Failed to get Azure token after multiple attempts"),null}}}]);