@botuyo/chat-widget-standalone 1.7.9 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"MessageBubble.d.ts","sourceRoot":"","sources":["../../../../src/chat-widget/components/MessageBubble.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAQb,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAQlD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,WAAW,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yDAAyD;IACzD,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;IACnE,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,KAAK,IAAI,CAAA;CAC9E;AAgGD,eAAO,MAAM,aAAa,0DAkgBzB,CAAA"}
1
+ {"version":3,"file":"MessageBubble.d.ts","sourceRoot":"","sources":["../../../../src/chat-widget/components/MessageBubble.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAQb,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAQlD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,WAAW,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yDAAyD;IACzD,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;IACnE,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,KAAK,IAAI,CAAA;CAC9E;AAgGD,eAAO,MAAM,aAAa,0DAuhBzB,CAAA"}
@@ -26,33 +26,33 @@ return y("div",{className:"w-full my-2 rounded-2xl border shadow-sm overflow-hid
26
26
  /* @__PURE__ */y("button",{type:"button",onClick:()=>{d||(c("cancelled"),o?.(e.proposalId))},"data-testid":"tool-proposal-cancel",className:"flex-1 flex items-center justify-center gap-1.5 py-3 text-xs font-bold transition-colors hover:bg-muted/50 active:scale-[0.98]",style:{color:"hsl(var(--muted-foreground))"},children:[
27
27
  /* @__PURE__ */b(he,{size:14,strokeWidth:2.5}),a("cancel")]}),
28
28
  /* @__PURE__ */y("button",{type:"button",onClick:()=>{p||(c("confirmed"),r?.(e.proposalId))},disabled:p,"data-testid":"tool-proposal-confirm",className:"flex-1 flex items-center justify-center gap-1.5 py-3 text-xs font-black text-white transition-all active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed disabled:active:scale-100",style:{backgroundColor:s},children:[
29
- /* @__PURE__ */b(H,{size:14,strokeWidth:3}),a("confirm")]})]})]})}const Bl=p(()=>import("./AudioPlayer-CFy6hynT.js").then(e=>({default:e.AudioPlayer}))),Ul=p(()=>import("./Gallery-Chv5QFcX.js").then(e=>({default:e.Gallery})));function ql({message:e,brandColor:t,onButtonClick:n}){const[r,o]=i(e.selectedId||null);/* @__PURE__ */
29
+ /* @__PURE__ */b(H,{size:14,strokeWidth:3}),a("confirm")]})]})]})}const Bl=p(()=>import("./AudioPlayer-DpCbdKqM.js").then(e=>({default:e.AudioPlayer}))),Ul=p(()=>import("./Gallery-p8KVosWr.js").then(e=>({default:e.Gallery})));function ql({message:e,brandColor:t,onButtonClick:n}){const[r,o]=i(e.selectedId||null);/* @__PURE__ */
30
30
  return y("div",{className:"space-y-3",children:[
31
31
  /* @__PURE__ */b("div",{className:Ot("prose prose-sm max-w-none break-words leading-relaxed dark:prose-invert text-foreground"),children:/* @__PURE__ */b(La,{remarkPlugins:[Al],rehypePlugins:[[Rl,{tagNames:["p","strong","em","br","span"],attributes:{}}]],components:{p:({children:e})=>/* @__PURE__ */b("p",{className:"mb-0 last:mb-0",children:e})},children:e.content})}),
32
32
  /* @__PURE__ */b("div",{className:"flex flex-col gap-2",children:e.buttons.map((i,a)=>{const s=r===i.id;/* @__PURE__ */
33
33
  return b("button",{type:"button",onClick:()=>(t=>{r||(o(t.id),n?.(t.label,e))})(i),disabled:null!==r,className:Ot("w-full text-left px-4 py-3 rounded-xl border text-sm font-semibold","transition-all duration-200 cursor-pointer",s?"scale-[0.98] ring-2 shadow-md":null===r||s?"hover:scale-[1.02] hover:shadow-md active:scale-[0.97]":"opacity-40 cursor-default"),style:{backgroundColor:s?`${t}15`:"hsl(var(--muted) / 0.5)",borderColor:s?t:"hsl(var(--border))",color:s?t:"hsl(var(--foreground))",...s?{ringColor:t}:{}},children:/* @__PURE__ */y("span",{className:"flex items-center gap-3",children:[
34
34
  /* @__PURE__ */b("span",{className:"flex items-center justify-center w-6 h-6 rounded-full text-xs font-black shrink-0",style:{backgroundColor:s?t:"hsl(var(--muted))",color:s?"white":"hsl(var(--muted-foreground))"},children:String.fromCharCode(65+a)}),
35
- /* @__PURE__ */b("span",{children:i.label})]})},i.id)})})]})}const Vl=d(function({message:e,primaryColor:t,botAvatar:n,botName:r="BotUyo",avatars:i,isFirst:a=!0,isLast:s=!0,index:l=0,onButtonClick:c,onProposalAction:d}){const{t:p}=F("extracted"),f="user"===e.sender,m="system"===e.type||"system"===e.sender,g=!f&&!m,w=Lt({primaryColor:t}),x=function(){const e=o(Rt);return e.enabled&&"none"!==e.messageEntry?{slide:"animate-message-slide",fade:"animate-message-fade",scale:"animate-message-scale",spring:"animate-message-spring"}[e.messageEntry]||"animate-message-spring":""}(),k=u(()=>{if(f)return null;if("text"===e.type){const t=e;if(t.emotion&&i?.[t.emotion])return i[t.emotion]}return n},[e,i,n,f]),_=({href:e,children:t})=>{if(!e)return null;const n=String(t).toLowerCase(),r=String(e).startsWith("mailto:"),o=String(e).startsWith("tel:"),i=!r&&!o&&(n.includes("reservar")||n.includes("ver")||n.includes("pagar")),a=e.includes("maps.google")||e.includes("goo.gl")||e.includes("google.com/maps");let s=!1;try{s=new URL(e,window.location.origin).hostname===window.location.hostname}catch{}const l=s?t=>{t.preventDefault(),window.location.href=e}:void 0,c=s?void 0:"_blank",u=s?void 0:"noopener noreferrer";return a?/* @__PURE__ */b("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"block my-2 no-underline group",children:/* @__PURE__ */y("span",{className:"flex items-center gap-3 p-3 border rounded-xl shadow-sm group-hover:border-primary/30 transition-all",style:{backgroundColor:"hsl(var(--card))",borderColor:"hsl(var(--border))"},children:[
36
- /* @__PURE__ */b("span",{className:"flex-shrink-0 p-2 rounded-full",style:{backgroundColor:`${w}1a`,color:w},children:/* @__PURE__ */b(ee,{size:16,strokeWidth:2.5})}),
37
- /* @__PURE__ */b("span",{className:"flex flex-col min-w-0 flex-1 text-[11px] font-bold text-foreground leading-tight uppercase tracking-tight",children:p("ver_ubicacion")}),
38
- /* @__PURE__ */b(J,{size:12,className:"text-muted-foreground/40 group-hover:text-primary"})]})}):i?/* @__PURE__ */y("a",{href:e,target:c,rel:u,onClick:l,className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 mt-2 mx-1 text-[11px] font-black w-[calc(100%-0.5rem)] sm:w-auto rounded-xl shadow-md uppercase tracking-widest transition-transform active:scale-95 text-white",style:{backgroundColor:w},children:[t," ",
39
- /* @__PURE__ */b(V,{size:14})]}):/* @__PURE__ */b("a",{href:e,target:c,rel:u,onClick:l,className:"font-bold underline decoration-primary/30 hover:decoration-primary transition-all break-words",style:{color:f?"inherit":w},children:t})},S=({src:e,alt:t})=>e?/* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"my-3 animate-pulse",children:/* @__PURE__ */b("div",{className:"w-full h-48 bg-muted rounded-xl"})}),children:/* @__PURE__ */b(Ul,{images:[{src:e,alt:t}],radius:"rounded-xl"})}):null;return"tool_proposal"===e.type?/* @__PURE__ */b($l,{message:e,primaryColor:t,onConfirm:e=>d?.(e,"confirm"),onCancel:e=>d?.(e,"reject")}):m?/* @__PURE__ */b("div",{className:"flex justify-center my-4 animate-in fade-in zoom-in-95 w-full",children:/* @__PURE__ */b("span",{className:"px-3 py-1 border rounded-full text-[9px] font-black uppercase tracking-widest",style:{backgroundColor:"hsl(var(--muted))",borderColor:"hsl(var(--border))",color:"hsl(var(--muted-foreground))"},children:e.content})}):/* @__PURE__ */y("div",{className:Ot("flex w-full mb-0.5 group",x,f?"justify-end":"justify-start gap-3",a&&"mt-3",s&&"mb-3"),style:{animationDelay:50*l+"ms"},children:[!f&&/* @__PURE__ */b("div",{className:"w-9 shrink-0 flex flex-col justify-end pb-1",children:/* @__PURE__ */b("div",s?{className:"h-9 w-9 rounded-full overflow-hidden border shadow-sm",style:{borderColor:"hsl(var(--border))",backgroundColor:"hsl(var(--background))"},children:k?/* @__PURE__ */b("img",{src:k,alt:r,className:"h-full w-full object-cover"}):/* @__PURE__ */b("div",{className:"h-full w-full flex items-center justify-center text-white text-[10px] font-black uppercase",style:{backgroundColor:w},children:r.charAt(0)})}:{className:"w-9"})}),
40
- /* @__PURE__ */y("div",{className:Ot("max-w-[85%] shadow-sm transition-all duration-300 relative",f?"text-primary-foreground":"border",f?Ot("rounded-[18px]",a&&"rounded-tr-[4px]",!s&&"rounded-br-[4px]",!a&&!s&&"rounded-r-[4px]"):Ot("rounded-[18px]",a&&"rounded-tl-[4px]",!s&&"rounded-bl-[4px]",!a&&!s&&"rounded-l-[4px]")),style:f?{padding:"var(--spacing-4) var(--spacing-5)",backgroundColor:w,boxShadow:s?`0 8px 20px -6px ${w}33`:"none"}:{padding:"var(--spacing-4) var(--spacing-5)",backgroundColor:"hsl(var(--card))",borderColor:"hsl(var(--border) / 0.6)",color:"hsl(var(--foreground))"},children:[(()=>{switch(e.type){case"audio":/* @__PURE__ */
35
+ /* @__PURE__ */b("span",{children:i.label})]})},i.id)})})]})}const Vl=d(function({message:e,primaryColor:t,botAvatar:n,botName:r="BotUyo",avatars:a,isFirst:s=!0,isLast:l=!0,index:c=0,onButtonClick:d,onProposalAction:p}){const{t:f}=F("extracted"),m="user"===e.sender,g="system"===e.type||"system"===e.sender,w=!m&&!g,x=Lt({primaryColor:t}),[k,_]=i(!1),S=function(){const e=o(Rt);return e.enabled&&"none"!==e.messageEntry?{slide:"animate-message-slide",fade:"animate-message-fade",scale:"animate-message-scale",spring:"animate-message-spring"}[e.messageEntry]||"animate-message-spring":""}(),C=u(()=>{if(m)return null;if("text"===e.type){const t=e;if(t.emotion&&a?.[t.emotion])return a[t.emotion]}return n},[e,a,n,m]),E=u(()=>!(!C||"undefined"===C||"null"===C||k),[C,k]),z=({href:e,children:t})=>{if(!e)return null;const n=String(t).toLowerCase(),r=String(e).startsWith("mailto:"),o=String(e).startsWith("tel:"),i=!r&&!o&&(n.includes("reservar")||n.includes("ver")||n.includes("pagar")),a=e.includes("maps.google")||e.includes("goo.gl")||e.includes("google.com/maps");let s=!1;try{s=new URL(e,window.location.origin).hostname===window.location.hostname}catch{}const l=s?t=>{t.preventDefault(),window.location.href=e}:void 0,c=s?void 0:"_blank",u=s?void 0:"noopener noreferrer";return a?/* @__PURE__ */b("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"block my-2 no-underline group",children:/* @__PURE__ */y("span",{className:"flex items-center gap-3 p-3 border rounded-xl shadow-sm group-hover:border-primary/30 transition-all",style:{backgroundColor:"hsl(var(--card))",borderColor:"hsl(var(--border))"},children:[
36
+ /* @__PURE__ */b("span",{className:"flex-shrink-0 p-2 rounded-full",style:{backgroundColor:`${x}1a`,color:x},children:/* @__PURE__ */b(ee,{size:16,strokeWidth:2.5})}),
37
+ /* @__PURE__ */b("span",{className:"flex flex-col min-w-0 flex-1 text-[11px] font-bold text-foreground leading-tight uppercase tracking-tight",children:f("ver_ubicacion")}),
38
+ /* @__PURE__ */b(J,{size:12,className:"text-muted-foreground/40 group-hover:text-primary"})]})}):i?/* @__PURE__ */y("a",{href:e,target:c,rel:u,onClick:l,className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 mt-2 mx-1 text-[11px] font-black w-[calc(100%-0.5rem)] sm:w-auto rounded-xl shadow-md uppercase tracking-widest transition-transform active:scale-95 text-white",style:{backgroundColor:x},children:[t," ",
39
+ /* @__PURE__ */b(V,{size:14})]}):/* @__PURE__ */b("a",{href:e,target:c,rel:u,onClick:l,className:"font-bold underline decoration-primary/30 hover:decoration-primary transition-all break-words",style:{color:m?"inherit":x},children:t})},A=({src:e,alt:t})=>e?/* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"my-3 animate-pulse",children:/* @__PURE__ */b("div",{className:"w-full h-48 bg-muted rounded-xl"})}),children:/* @__PURE__ */b(Ul,{images:[{src:e,alt:t}],radius:"rounded-xl"})}):null;return"tool_proposal"===e.type?/* @__PURE__ */b($l,{message:e,primaryColor:t,onConfirm:e=>p?.(e,"confirm"),onCancel:e=>p?.(e,"reject")}):g?/* @__PURE__ */b("div",{className:"flex justify-center my-4 animate-in fade-in zoom-in-95 w-full",children:/* @__PURE__ */b("span",{className:"px-3 py-1 border rounded-full text-[9px] font-black uppercase tracking-widest",style:{backgroundColor:"hsl(var(--muted))",borderColor:"hsl(var(--border))",color:"hsl(var(--muted-foreground))"},children:e.content})}):/* @__PURE__ */y("div",{className:Ot("flex w-full mb-0.5 group",S,m?"justify-end":"justify-start gap-3",s&&"mt-3",l&&"mb-3"),style:{animationDelay:50*c+"ms"},children:[!m&&/* @__PURE__ */b("div",{className:"w-9 shrink-0 flex flex-col justify-end pb-1",children:/* @__PURE__ */b("div",l?{className:"h-9 w-9 rounded-full overflow-hidden border shadow-sm",style:{borderColor:"hsl(var(--border))",backgroundColor:"hsl(var(--background))"},children:E?/* @__PURE__ */b("img",{src:C||"",alt:r,className:"h-full w-full object-cover",onError:()=>_(!0)}):/* @__PURE__ */b("div",{className:"h-full w-full flex items-center justify-center bg-muted text-muted-foreground",children:/* @__PURE__ */b("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:/* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})})}:{className:"w-9"})}),
40
+ /* @__PURE__ */y("div",{className:Ot("max-w-[85%] shadow-sm transition-all duration-300 relative",m?"text-primary-foreground":"border",m?Ot("rounded-[18px]",s&&"rounded-tr-[4px]",!l&&"rounded-br-[4px]",!s&&!l&&"rounded-r-[4px]"):Ot("rounded-[18px]",s&&"rounded-tl-[4px]",!l&&"rounded-bl-[4px]",!s&&!l&&"rounded-l-[4px]")),style:m?{padding:"var(--spacing-4) var(--spacing-5)",backgroundColor:x,boxShadow:l?`0 8px 20px -6px ${x}33`:"none"}:{padding:"var(--spacing-4) var(--spacing-5)",backgroundColor:"hsl(var(--card))",borderColor:"hsl(var(--border) / 0.6)",color:"hsl(var(--foreground))"},children:[(()=>{switch(e.type){case"audio":/* @__PURE__ */
41
41
  return b(h,{fallback:/* @__PURE__ */y("div",{className:"flex items-center gap-3 py-1 min-w-[200px] animate-pulse",children:[
42
42
  /* @__PURE__ */b("div",{className:"w-8 h-8 rounded-full bg-muted"}),
43
43
  /* @__PURE__ */b("div",{className:"flex-1 space-y-1",children:/* @__PURE__ */b("div",{className:"h-1 w-full bg-muted rounded-full"})})]}),children:/* @__PURE__ */y("div",{children:[
44
- /* @__PURE__ */b(Bl,{url:e.content,isBot:g,primaryColor:t}),e.text&&/* @__PURE__ */b("p",{style:{fontSize:"0.8rem",opacity:.7,marginTop:"4px",fontStyle:"italic",lineHeight:1.3},children:e.text})]})});case"image":{const t=e;/* @__PURE__ */
44
+ /* @__PURE__ */b(Bl,{url:e.content,isBot:w,primaryColor:t}),e.text&&/* @__PURE__ */b("p",{style:{fontSize:"0.8rem",opacity:.7,marginTop:"4px",fontStyle:"italic",lineHeight:1.3},children:e.text})]})});case"image":{const t=e;/* @__PURE__ */
45
45
  return y("div",{className:"my-1",children:[
46
- /* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"my-3 animate-pulse",children:/* @__PURE__ */b("div",{className:"w-full h-48 bg-muted rounded-xl"})}),children:/* @__PURE__ */b(Ul,{images:[{src:t.imageUrl||t.content,alt:t.altText||"Imagen"}],radius:"rounded-xl"})}),t.caption&&/* @__PURE__ */b("p",{className:"mt-1.5 text-sm leading-snug",children:t.caption}),t.attribution&&/* @__PURE__ */b("p",{className:"mt-1 text-[11px] leading-snug opacity-60",children:t.sourceUrl?/* @__PURE__ */b(_,{href:t.sourceUrl,children:t.attribution}):t.attribution})]})}case"location":{const t=e;/* @__PURE__ */
47
- return b(_,{href:`https://www.google.com/maps/search/?api=1&query=${t.latitude},${t.longitude}`,children:"Ver ubicación"})}case"file":{const t=e,n=t.fileName?.split(".").pop()?.toLowerCase()||"",r=t.fileSize?`${(t.fileSize/1024/1024).toFixed(2)} MB`:"";/* @__PURE__ */
48
- return y("a",{href:t.fileUrl,download:t.fileName,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 border rounded-xl transition-all hover:scale-[1.02] group",style:{backgroundColor:f?"rgba(255,255,255,0.1)":"hsl(var(--muted))",borderColor:f?"rgba(255,255,255,0.2)":"hsl(var(--border))"},children:[
49
- /* @__PURE__ */b("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg shrink-0",style:{backgroundColor:f?"rgba(255,255,255,0.2)":`${w}1a`,color:f?"white":w},children:/* @__PURE__ */b(K,{size:20,strokeWidth:2.5})}),
46
+ /* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"my-3 animate-pulse",children:/* @__PURE__ */b("div",{className:"w-full h-48 bg-muted rounded-xl"})}),children:/* @__PURE__ */b(Ul,{images:[{src:t.imageUrl||t.content,alt:t.altText||"Imagen"}],radius:"rounded-xl"})}),t.caption&&/* @__PURE__ */b("p",{className:"mt-1.5 text-sm leading-snug",children:t.caption}),t.attribution&&/* @__PURE__ */b("p",{className:"mt-1 text-[11px] leading-snug opacity-60",children:t.sourceUrl?/* @__PURE__ */b(z,{href:t.sourceUrl,children:t.attribution}):t.attribution})]})}case"location":{const t=e;/* @__PURE__ */
47
+ return b(z,{href:`https://www.google.com/maps/search/?api=1&query=${t.latitude},${t.longitude}`,children:"Ver ubicación"})}case"file":{const t=e,n=t.fileName?.split(".").pop()?.toLowerCase()||"",r=t.fileSize?`${(t.fileSize/1024/1024).toFixed(2)} MB`:"";/* @__PURE__ */
48
+ return y("a",{href:t.fileUrl,download:t.fileName,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 border rounded-xl transition-all hover:scale-[1.02] group",style:{backgroundColor:m?"rgba(255,255,255,0.1)":"hsl(var(--muted))",borderColor:m?"rgba(255,255,255,0.2)":"hsl(var(--border))"},children:[
49
+ /* @__PURE__ */b("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg shrink-0",style:{backgroundColor:m?"rgba(255,255,255,0.2)":`${x}1a`,color:m?"white":x},children:/* @__PURE__ */b(K,{size:20,strokeWidth:2.5})}),
50
50
  /* @__PURE__ */y("div",{className:"flex-1 min-w-0",children:[
51
51
  /* @__PURE__ */b("p",{className:"text-sm font-bold truncate",children:t.fileName}),r&&/* @__PURE__ */y("p",{className:"text-xs opacity-60 mt-0.5",children:[n?.toUpperCase()," • ",r]})]}),
52
52
  /* @__PURE__ */b(Z,{size:18,className:"shrink-0 opacity-60 group-hover:opacity-100 transition-opacity"})]})}case"buttons":/* @__PURE__ */
53
- return b(ql,{message:e,brandColor:w,onButtonClick:c});default:{const t=e.content||"",n=/!\[([^\]]*)\]\(([^)]+)\)/g,r=[];let o;for(;null!==(o=n.exec(t));)r.push({src:o[2],alt:o[1]||"Foto"});const i=r.length>1?t.replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/---\s*\n?\s*---/g,"").trim():t;/* @__PURE__ */
54
- return y(v,{children:[r.length>1&&/* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"my-3 animate-pulse",children:/* @__PURE__ */b("div",{className:"w-full h-48 bg-muted rounded-xl"})}),children:/* @__PURE__ */b(Ul,{images:r,radius:"rounded-xl"})}),i&&/* @__PURE__ */b("div",{className:Ot("prose prose-sm max-w-none break-words leading-relaxed dark:prose-invert",f?"text-primary-foreground prose-p:text-white":"text-foreground"),children:/* @__PURE__ */b(La,{remarkPlugins:[Al],rehypePlugins:[[Rl,{tagNames:["p","a","img","strong","em","ul","ol","li","br","span"],attributes:{a:["href","target","rel"],img:["src","alt"],span:["className"]},protocols:{a:{href:["http","https","mailto","tel"]},img:{src:["http","https","data"]}}}]],components:{a:_,img:S,p:({children:e})=>/* @__PURE__ */b("p",{className:"mb-0 last:mb-0",children:e})},children:i})})]})}}})(),s&&/* @__PURE__ */y("div",{className:Ot("flex items-center gap-1 mt-1.5 opacity-50 select-none text-[9px]",f?"justify-end":"justify-start"),children:[
55
- /* @__PURE__ */b("span",{className:"font-bold tabular-nums uppercase tracking-tighter",children:(e=>{const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})})(e.timestamp)}),f&&/* @__PURE__ */b(W,{className:"h-2.5 w-2.5"})]})]}),g&&s&&"text"===e.type&&e.sources&&/* @__PURE__ */b(Fl,{sources:e.sources})]})},(e,t)=>e.message.id===t.message.id&&e.message.timestamp===t.message.timestamp&&e.message.status===t.message.status&&e.primaryColor===t.primaryColor&&e.botAvatar===t.botAvatar&&e.botName===t.botName&&e.isFirst===t.isFirst&&e.isLast===t.isLast&&JSON.stringify(e.styles)===JSON.stringify(t.styles)),Wl=d(function(){/* @__PURE__ */
53
+ return b(ql,{message:e,brandColor:x,onButtonClick:d});default:{const t=e.content||"",n=/!\[([^\]]*)\]\(([^)]+)\)/g,r=[];let o;for(;null!==(o=n.exec(t));)r.push({src:o[2],alt:o[1]||"Foto"});const i=r.length>1?t.replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/---\s*\n?\s*---/g,"").trim():t;/* @__PURE__ */
54
+ return y(v,{children:[r.length>1&&/* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"my-3 animate-pulse",children:/* @__PURE__ */b("div",{className:"w-full h-48 bg-muted rounded-xl"})}),children:/* @__PURE__ */b(Ul,{images:r,radius:"rounded-xl"})}),i&&/* @__PURE__ */b("div",{className:Ot("prose prose-sm max-w-none break-words leading-relaxed dark:prose-invert",m?"text-primary-foreground prose-p:text-white":"text-foreground"),children:/* @__PURE__ */b(La,{remarkPlugins:[Al],rehypePlugins:[[Rl,{tagNames:["p","a","img","strong","em","ul","ol","li","br","span"],attributes:{a:["href","target","rel"],img:["src","alt"],span:["className"]},protocols:{a:{href:["http","https","mailto","tel"]},img:{src:["http","https","data"]}}}]],components:{a:z,img:A,p:({children:e})=>/* @__PURE__ */b("p",{className:"mb-0 last:mb-0",children:e})},children:i})})]})}}})(),l&&/* @__PURE__ */y("div",{className:Ot("flex items-center gap-1 mt-1.5 opacity-50 select-none text-[9px]",m?"justify-end":"justify-start"),children:[
55
+ /* @__PURE__ */b("span",{className:"font-bold tabular-nums uppercase tracking-tighter",children:(e=>{const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})})(e.timestamp)}),m&&/* @__PURE__ */b(W,{className:"h-2.5 w-2.5"})]})]}),w&&l&&"text"===e.type&&e.sources&&/* @__PURE__ */b(Fl,{sources:e.sources})]})},(e,t)=>e.message.id===t.message.id&&e.message.timestamp===t.message.timestamp&&e.message.status===t.message.status&&e.primaryColor===t.primaryColor&&e.botAvatar===t.botAvatar&&e.botName===t.botName&&e.isFirst===t.isFirst&&e.isLast===t.isLast&&JSON.stringify(e.styles)===JSON.stringify(t.styles)),Wl=d(function(){/* @__PURE__ */
56
56
  return b("div",{style:{display:"flex",alignItems:"center",alignSelf:"flex-start",maxWidth:"85%",animation:"message-fade 0.2s ease-out forwards"},children:/* @__PURE__ */b("div",{style:{backgroundColor:"hsl(var(--card, 0 0% 100%))",border:"1px solid hsl(var(--border, 0 0% 90%))",borderRadius:"18px",borderTopLeftRadius:"4px",padding:"14px 20px",boxShadow:"0 1px 3px rgba(0,0,0,0.06)"},children:/* @__PURE__ */b("div",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[0,1,2].map(e=>/* @__PURE__ */b("span",{className:"animate-typing-dots",style:{display:"inline-block",height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"hsl(var(--primary, 250 84% 54%) / 0.6)",animationDelay:200*e+"ms"}},e))})})})});function Hl(e,t){const n=e.getTime()-t.getTime();return Math.floor(n/1e3/60)}function Zl(e){return new Intl.DateTimeFormat("es-ES",{hour:"2-digit",minute:"2-digit"}).format(e)}const Jl=d(function({messages:e,isTyping:r,welcomeMessage:o="¡Hola! ¿En qué puedo ayudarte?",primaryColor:s,logoUrl:l,botName:c="BotUyo",bubbleStyles:u,avatars:d,onButtonClick:p,onProposalAction:h}){const m=f(null),g=f(null),[v,x]=i(!1),[k,_]=i(!1),S=Lt({primaryColor:s}),C=e.length>100,E=(z={count:e.length,getScrollElement:()=>g.current,estimateSize:()=>80,overscan:5,enabled:C},function({useFlushSync:e=!0,...n}){const r=t.useReducer(()=>({}),{})[1],o={...n,onChange:(t,o)=>{var i;e&&o?w(r):r(),null==(i=n.onChange)||i.call(n,t,o)}},[i]=t.useState(()=>new en(o));return i.setOptions(o),nn(()=>i._didMount(),[]),nn(()=>i._willUpdate()),i}({observeElementRect:Jt,observeElementOffset:Yt,scrollToFn:Xt,...z}));var z;a(()=>{x(!0)},[]),a(()=>{if(v&&(e.length>0||r)){const t=setTimeout(()=>{C?E.scrollToIndex(e.length-1,{align:"end",behavior:e.length<=1?"auto":"smooth"}):m.current?.scrollIntoView({behavior:e.length<=1?"auto":"smooth",block:"end"})},100);return()=>clearTimeout(t)}},[e.length,r,v,C,E]);const A=e=>{const t=new Date(e);return isNaN(t.getTime())?"":function(e){return function(e){const t=/* @__PURE__ */new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(e)?`Hoy, ${Zl(e)}`:function(e){const t=/* @__PURE__ */new Date;return t.setDate(t.getDate()-1),e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(e)?`Ayer, ${Zl(e)}`:function(e){return new Intl.DateTimeFormat("es-ES",{day:"numeric",month:"long",hour:"2-digit",minute:"2-digit"}).format(e)}(e)}(t)};if(!v)/* @__PURE__ */return b("div",{className:"flex-1 bg-background"});if(C)/* @__PURE__ */
57
57
  return y("div",{ref:g,className:"flex-1 overflow-y-auto scroll-smooth scrollbar-none",style:{padding:"var(--spacing-5)",scrollbarWidth:"none",msOverflowStyle:"none"},children:[
58
58
  /* @__PURE__ */b("div",{style:{height:`${E.getTotalSize()}px`,width:"100%",position:"relative"},children:E.getVirtualItems().map(t=>{const n=e[t.index],r=t.index,o=e[r-1],i=e[r+1],a=o&&Hl(new Date(n.timestamp),new Date(o.timestamp))>15,f=o&&o.sender===n.sender&&Hl(new Date(n.timestamp),new Date(o.timestamp))<5&&!a,m=i&&i.sender===n.sender&&Hl(new Date(i.timestamp),new Date(n.timestamp))<5;/* @__PURE__ */
@@ -107,7 +107,7 @@ return b("div",{"data-testid":"quiz-dock",className:"shrink-0 border-t animate-i
107
107
  /* @__PURE__ */b("p",{className:"text-sm font-semibold mb-2 text-foreground break-words leading-snug",children:e.content}),
108
108
  /* @__PURE__ */b("div",{className:"flex flex-col gap-2",children:e.buttons.map((e,t)=>/* @__PURE__ */b("button",{type:"button",onClick:()=>n(e.label,e.id),className:"w-full text-left px-4 py-3 rounded-xl border text-sm font-semibold transition-all duration-200 cursor-pointer hover:scale-[1.02] hover:shadow-md active:scale-[0.97]",style:{backgroundColor:"hsl(var(--background))",borderColor:"hsl(var(--border))",color:"hsl(var(--foreground))"},children:/* @__PURE__ */y("span",{className:"flex items-center gap-3",children:[
109
109
  /* @__PURE__ */b("span",{className:"flex items-center justify-center w-6 h-6 rounded-full text-xs font-black shrink-0",style:{backgroundColor:r,color:"white"},children:String.fromCharCode(65+t)}),
110
- /* @__PURE__ */b("span",{children:e.label})]})},e.id))})]})})}function nc(e,t){let n=0,r=null;return function(...o){const i=Date.now(),a=i-n,s=()=>{n=i,e(...o)};a>=t?(r&&(clearTimeout(r),r=null),s()):r||(r=setTimeout(()=>{s(),r=null},t-a))}}function rc(e=640){const[t,n]=i(()=>"undefined"!=typeof window&&window.innerWidth<e);return a(()=>{const t=nc(()=>{n(window.innerWidth<e)},250);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),t}const oc="24px",ic={sampleRate:16e3,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},ac=85,sc=.7,lc=200,cc=.5,uc=3e3,dc=1,pc=6,hc=7500,fc=.7,mc=-20,gc=8,bc=6,yc=.002,vc=.12,wc={openThreshold:.0125,floorGain:.12,attackStep:1,releaseStep:.16},xc={off:{openThreshold:0,floorGain:1,attackStep:1,releaseStep:1},low:{openThreshold:.008,floorGain:.25,attackStep:1,releaseStep:.12},standard:{...wc},high:{openThreshold:.02,floorGain:.05,attackStep:1,releaseStep:.2}};function kc(e=wc,t="voice-pcm-processor",n=1600){return`\nclass VoicePCMProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.buffer = new Float32Array(${n});\n this.bufferIndex = 0;\n this.gain = 1; // current applied gain — starts open\n }\n process(inputs) {\n const input = inputs[0]?.[0];\n if (!input) return true;\n for (let i = 0; i < input.length; i++) {\n this.buffer[this.bufferIndex++] = input[i];\n if (this.bufferIndex >= ${n}) {\n // 1. Frame RMS — near-field speaker vs. background energy\n let sumSq = 0;\n for (let j = 0; j < ${n}; j++) sumSq += this.buffer[j] * this.buffer[j];\n const rms = Math.sqrt(sumSq / ${n});\n\n // 2. Downward-expander target + smoothed gain (fast attack, slow release)\n const target = rms >= ${e.openThreshold} ? 1 : ${e.floorGain};\n let nextGain;\n if (target >= this.gain) {\n nextGain = Math.min(target, this.gain + ${e.attackStep});\n } else {\n nextGain = Math.max(target, this.gain - ${e.releaseStep});\n }\n\n // 3. Apply gain with a per-sample ramp (click-free) → Int16 PCM\n const int16 = new Int16Array(${n});\n const gStep = (nextGain - this.gain) / ${n};\n let g = this.gain;\n for (let j = 0; j < ${n}; j++) {\n g += gStep;\n const s = Math.max(-1, Math.min(1, this.buffer[j] * g));\n int16[j] = s < 0 ? s * 0x8000 : s * 0x7FFF;\n }\n this.gain = nextGain;\n\n // 4. ALWAYS post PCM + this frame's RMS. The client VAD gate decides\n // per frame what actually reaches the provider.\n this.port.postMessage({ pcm: int16.buffer, rms: rms }, [int16.buffer]);\n\n this.buffer = new Float32Array(${n});\n this.bufferIndex = 0;\n }\n }\n return true;\n }\n}\nregisterProcessor('${t}', VoicePCMProcessor);\n`}const _c={low:{positiveSpeechThreshold:.4,negativeSpeechThreshold:.3,nearFieldRms:.012,bargeInRms:.022,onsetFrames:1,redemptionFrames:10},standard:{positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,nearFieldRms:.02,bargeInRms:.035,onsetFrames:2,redemptionFrames:8},high:{positiveSpeechThreshold:.6,negativeSpeechThreshold:.45,nearFieldRms:.032,bargeInRms:.055,onsetFrames:3,redemptionFrames:6}};function Sc(e){return void 0===e||"standard"===e?{..._c.standard}:"string"==typeof e?{..._c[e]??_c.standard}:{..._c.standard,...e}}class Cc{config;_state="silence";onsetCount=0;redemptionCount=0;constructor(e={}){this.config={..._c.standard,...e}}get state(){return this._state}reset(){this._state="silence",this.onsetCount=0,this.redemptionCount=0}process(e){return"silence"===this._state?this.processSilence(e):this.processSpeech(e)}processSilence(e){const t=e.botSpeaking?this.config.bargeInRms:this.config.nearFieldRms;return(this.config.energyOnly||e.speechProb>=this.config.positiveSpeechThreshold)&&e.rms>=t?(this.onsetCount+=1,this.onsetCount<this.config.onsetFrames?{shouldStream:!1,state:"silence"}:(this._state="speech",this.onsetCount=0,this.redemptionCount=0,{shouldStream:!0,state:"speech",event:e.botSpeaking?"barge_in":"speech_start"})):(this.onsetCount=0,{shouldStream:!1,state:"silence"})}processSpeech(e){const t=.5*this.config.nearFieldRms;return(this.config.energyOnly||e.speechProb>=this.config.negativeSpeechThreshold)&&e.rms>=t?(this.redemptionCount=0,{shouldStream:!0,state:"speech"}):(this.redemptionCount+=1,this.redemptionCount<this.config.redemptionFrames?{shouldStream:!0,state:"speech"}:(this._state="silence",this.redemptionCount=0,{shouldStream:!1,state:"silence",event:"speech_end"}))}}const Ec="0.0.30",zc=`https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@${Ec}/dist/`,Ac=`https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@${Ec}/+esm`;function Nc(e){if(0===e.length)return 0;let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t/e.length)}async function Tc(){return await import(Ac)}class Ic{constructor(e){this.instance=e}_running=!1;get running(){return this._running}async start(){await this.instance.start(),this._running=!0}destroy(){try{this.instance.destroy()}catch(e){O.warn("[VAD] error while destroying detector",e)}this._running=!1}}const Oc=p(()=>import("./Avatar3D-gsz-STJM.js")),Mc={happy:"😊",wink:"😉",thinking:"🤔",sad:"😢",excited:"🤩",love:"❤️",laugh:"😄",surprised:"😲",angry:"😠",confused:"😕",sorry:"😔",default:"💬"},Pc={idle:"Llamada de voz",connecting:"Conectando...",listening:"Escuchando...",thinking:"Pensando...",speaking:"Hablando..."},Lc={tagNames:["p","a","img","strong","em","ul","ol","li","br","span","code","hr"],attributes:{a:["href","target","rel"],img:["src","alt"],span:["className"],code:["className"]},protocols:{a:{href:["http","https","mailto","tel"]},img:{src:["http","https","data"]}}},Dc=24e3;function jc(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++)n+=String.fromCharCode(t[r]);return btoa(n)}class Rc extends m{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){O.warn("[Avatar3D] Three.js failed, falling back to 2D orb:",e.message),this.props.onError()}render(){return this.state.hasError?null:this.props.children}}function Fc({avatars:e,logoUrl:t,avatar3dUrl:n,emotion:r,callState:o,audioLevel:a,config:s}){const l=e&&Object.keys(e).length>0,c=!!t,[d,p]=i(!1),f=u(()=>l||c?l?e[r||"default"]||e.default||t||null:t||null:null,[l,c,e,r,t]),m="listening"===o||"speaking"===o,g="speaking"===o?s.speakingColor:"thinking"===o?s.thinkingColor:"listening"===o?s.listeningColor:"#ffffff20",v="speaking"===o?s.speakingScale:"thinking"===o?s.thinkingScale:1,w=s.orbSize;/* @__PURE__ */
110
+ /* @__PURE__ */b("span",{children:e.label})]})},e.id))})]})})}function nc(e,t){let n=0,r=null;return function(...o){const i=Date.now(),a=i-n,s=()=>{n=i,e(...o)};a>=t?(r&&(clearTimeout(r),r=null),s()):r||(r=setTimeout(()=>{s(),r=null},t-a))}}function rc(e=640){const[t,n]=i(()=>"undefined"!=typeof window&&window.innerWidth<e);return a(()=>{const t=nc(()=>{n(window.innerWidth<e)},250);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),t}const oc="24px",ic={sampleRate:16e3,channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},ac=85,sc=.7,lc=200,cc=.5,uc=3e3,dc=1,pc=6,hc=7500,fc=.7,mc=-20,gc=8,bc=6,yc=.002,vc=.12,wc={openThreshold:.0125,floorGain:.12,attackStep:1,releaseStep:.16},xc={off:{openThreshold:0,floorGain:1,attackStep:1,releaseStep:1},low:{openThreshold:.008,floorGain:.25,attackStep:1,releaseStep:.12},standard:{...wc},high:{openThreshold:.02,floorGain:.05,attackStep:1,releaseStep:.2}};function kc(e=wc,t="voice-pcm-processor",n=1600){return`\nclass VoicePCMProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.buffer = new Float32Array(${n});\n this.bufferIndex = 0;\n this.gain = 1; // current applied gain — starts open\n }\n process(inputs) {\n const input = inputs[0]?.[0];\n if (!input) return true;\n for (let i = 0; i < input.length; i++) {\n this.buffer[this.bufferIndex++] = input[i];\n if (this.bufferIndex >= ${n}) {\n // 1. Frame RMS — near-field speaker vs. background energy\n let sumSq = 0;\n for (let j = 0; j < ${n}; j++) sumSq += this.buffer[j] * this.buffer[j];\n const rms = Math.sqrt(sumSq / ${n});\n\n // 2. Downward-expander target + smoothed gain (fast attack, slow release)\n const target = rms >= ${e.openThreshold} ? 1 : ${e.floorGain};\n let nextGain;\n if (target >= this.gain) {\n nextGain = Math.min(target, this.gain + ${e.attackStep});\n } else {\n nextGain = Math.max(target, this.gain - ${e.releaseStep});\n }\n\n // 3. Apply gain with a per-sample ramp (click-free) → Int16 PCM\n const int16 = new Int16Array(${n});\n const gStep = (nextGain - this.gain) / ${n};\n let g = this.gain;\n for (let j = 0; j < ${n}; j++) {\n g += gStep;\n const s = Math.max(-1, Math.min(1, this.buffer[j] * g));\n int16[j] = s < 0 ? s * 0x8000 : s * 0x7FFF;\n }\n this.gain = nextGain;\n\n // 4. ALWAYS post PCM + this frame's RMS. The client VAD gate decides\n // per frame what actually reaches the provider.\n this.port.postMessage({ pcm: int16.buffer, rms: rms }, [int16.buffer]);\n\n this.buffer = new Float32Array(${n});\n this.bufferIndex = 0;\n }\n }\n return true;\n }\n}\nregisterProcessor('${t}', VoicePCMProcessor);\n`}const _c={low:{positiveSpeechThreshold:.4,negativeSpeechThreshold:.3,nearFieldRms:.012,bargeInRms:.022,onsetFrames:1,redemptionFrames:10},standard:{positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,nearFieldRms:.02,bargeInRms:.035,onsetFrames:2,redemptionFrames:8},high:{positiveSpeechThreshold:.6,negativeSpeechThreshold:.45,nearFieldRms:.032,bargeInRms:.055,onsetFrames:3,redemptionFrames:6}};function Sc(e){return void 0===e||"standard"===e?{..._c.standard}:"string"==typeof e?{..._c[e]??_c.standard}:{..._c.standard,...e}}class Cc{config;_state="silence";onsetCount=0;redemptionCount=0;constructor(e={}){this.config={..._c.standard,...e}}get state(){return this._state}reset(){this._state="silence",this.onsetCount=0,this.redemptionCount=0}process(e){return"silence"===this._state?this.processSilence(e):this.processSpeech(e)}processSilence(e){const t=e.botSpeaking?this.config.bargeInRms:this.config.nearFieldRms;return(this.config.energyOnly||e.speechProb>=this.config.positiveSpeechThreshold)&&e.rms>=t?(this.onsetCount+=1,this.onsetCount<this.config.onsetFrames?{shouldStream:!1,state:"silence"}:(this._state="speech",this.onsetCount=0,this.redemptionCount=0,{shouldStream:!0,state:"speech",event:e.botSpeaking?"barge_in":"speech_start"})):(this.onsetCount=0,{shouldStream:!1,state:"silence"})}processSpeech(e){const t=.5*this.config.nearFieldRms;return(this.config.energyOnly||e.speechProb>=this.config.negativeSpeechThreshold)&&e.rms>=t?(this.redemptionCount=0,{shouldStream:!0,state:"speech"}):(this.redemptionCount+=1,this.redemptionCount<this.config.redemptionFrames?{shouldStream:!0,state:"speech"}:(this._state="silence",this.redemptionCount=0,{shouldStream:!1,state:"silence",event:"speech_end"}))}}const Ec="0.0.30",zc=`https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@${Ec}/dist/`,Ac=`https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@${Ec}/+esm`;function Nc(e){if(0===e.length)return 0;let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t/e.length)}async function Tc(){return await import(Ac)}class Ic{constructor(e){this.instance=e}_running=!1;get running(){return this._running}async start(){await this.instance.start(),this._running=!0}destroy(){try{this.instance.destroy()}catch(e){O.warn("[VAD] error while destroying detector",e)}this._running=!1}}const Oc=p(()=>import("./Avatar3D-q_CqO8mU.js")),Mc={happy:"😊",wink:"😉",thinking:"🤔",sad:"😢",excited:"🤩",love:"❤️",laugh:"😄",surprised:"😲",angry:"😠",confused:"😕",sorry:"😔",default:"💬"},Pc={idle:"Llamada de voz",connecting:"Conectando...",listening:"Escuchando...",thinking:"Pensando...",speaking:"Hablando..."},Lc={tagNames:["p","a","img","strong","em","ul","ol","li","br","span","code","hr"],attributes:{a:["href","target","rel"],img:["src","alt"],span:["className"],code:["className"]},protocols:{a:{href:["http","https","mailto","tel"]},img:{src:["http","https","data"]}}},Dc=24e3;function jc(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++)n+=String.fromCharCode(t[r]);return btoa(n)}class Rc extends m{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){O.warn("[Avatar3D] Three.js failed, falling back to 2D orb:",e.message),this.props.onError()}render(){return this.state.hasError?null:this.props.children}}function Fc({avatars:e,logoUrl:t,avatar3dUrl:n,emotion:r,callState:o,audioLevel:a,config:s}){const l=e&&Object.keys(e).length>0,c=!!t,[d,p]=i(!1),f=u(()=>l||c?l?e[r||"default"]||e.default||t||null:t||null:null,[l,c,e,r,t]),m="listening"===o||"speaking"===o,g="speaking"===o?s.speakingColor:"thinking"===o?s.thinkingColor:"listening"===o?s.listeningColor:"#ffffff20",v="speaking"===o?s.speakingScale:"thinking"===o?s.thinkingScale:1,w=s.orbSize;/* @__PURE__ */
111
111
  return y("div",n&&!d?{className:"relative flex flex-col items-center gap-4",children:[
112
112
  /* @__PURE__ */b(Rc,{onError:()=>p(!0),children:/* @__PURE__ */b(h,{fallback:/* @__PURE__ */b("div",{className:"rounded-full flex items-center justify-center animate-pulse",style:{width:`${s.orbSize}px`,height:`${s.orbSize}px`,background:`radial-gradient(circle at 35% 35%, ${s.speakingColor}40, ${s.speakingColor}10 60%, transparent 80%)`,boxShadow:`0 0 30px ${s.speakingColor}15`}}),children:/* @__PURE__ */b(Oc,{modelUrl:n,emotion:r,callState:o,audioLevel:a,primaryColor:s.speakingColor,size:s.orbSize})})}),s.showWaveform&&/* @__PURE__ */b($c,{isActive:"listening"===o||"speaking"===o,audioLevel:a,color:"speaking"===o?s.speakingColor:"thinking"===o?s.thinkingColor:s.listeningColor})]}:f?{className:"relative flex flex-col items-center gap-4",children:[
113
113
  /* @__PURE__ */y("div",{className:Ot("relative rounded-full flex items-center justify-center","transition-all duration-500 ease-out"),style:{width:`${w}px`,height:`${w}px`,boxShadow:m?`0 0 0 4px ${g}40, 0 0 30px ${g}30, 0 0 60px ${g}15`:`0 0 0 2px ${g}20`,transform:`scale(${v})`},children:[
@@ -216,4 +216,4 @@ return y("div",{className:`relative h-full w-full overflow-hidden ${t}`,children
216
216
  /* @__PURE__ */b(Kb,{url:e,autoRotate:S,hasCustomCamera:_,frameRef:v,onLoaded:w,onError:x})]},e),"loading"===g&&/* @__PURE__ */y("div",{className:"pointer-events-none absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 text-gray-400",children:[
217
217
  /* @__PURE__ */b("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-current border-t-transparent opacity-70"}),c&&/* @__PURE__ */b("span",{className:"text-xs",children:c})]}),"error"===g&&/* @__PURE__ */y("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-1 px-3 text-center text-gray-400",children:[
218
218
  /* @__PURE__ */b(de,{className:"h-5 w-5","aria-hidden":!0}),u&&/* @__PURE__ */b("span",{className:"text-xs",children:u})]})]})}const Xb="https://api.botuyo.com";class ey extends m{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error("[BotUyoChat] Widget error:",e,t)}render(){return this.state.hasError?null:this.props.children}}const ty={"--background":"240 10% 3.9%","--foreground":"0 0% 98%","--card":"240 10% 3.9%","--card-foreground":"0 0% 98%","--primary":"160 84% 39%","--primary-foreground":"0 0% 100%","--muted":"240 3.7% 15.9%","--muted-foreground":"240 5% 64.9%","--border":"240 3.7% 15.9%"},ny=p(()=>Promise.resolve().then(()=>Vb).then(e=>({default:e.ChatWidgetWithProviders})));class ry{root=null;container=null;shadowRoot=null;mountPoint=null;darkModeObserver=null;darkModeMediaQuery=null;config=null;init(e){return this.config={...e,apiBaseUrl:e.apiBaseUrl||Xb},this.render(),this.setupDarkModeDetection(),this}render(){if(!this.config)return void console.error("[BotUyoChat] No configuration provided");if(!this.container){this.container=document.createElement("div"),this.container.id="botuyo-chat-widget-root",document.body.appendChild(this.container),this.shadowRoot=this.container.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=R.replace(/:root/g,":host"),this.shadowRoot.appendChild(e),this.mountPoint=document.createElement("div"),this.mountPoint.id="botuyo-chat-widget-root",this.shadowRoot.appendChild(this.mountPoint)}if(this.config.theme?.cssVariables&&this.mountPoint){const e=this.config.theme.cssVariables;[["--background",e.background],["--foreground",e.foreground],["--card",e.card],["--card-foreground",e.cardForeground],["--primary",e.primary],["--primary-foreground",e.primaryForeground],["--muted",e.muted],["--muted-foreground",e.mutedForeground],["--border",e.border],["--destructive",e.destructive],["--radius",e.radius],["--window-border-radius",e.windowBorderRadius],["--launcher-border-radius",e.launcherBorderRadius],["--window-height",e.windowHeight],["--window-bottom",e.windowBottom],["--spacing-1",e.spacing1],["--spacing-2",e.spacing2],["--spacing-3",e.spacing3],["--spacing-4",e.spacing4],["--spacing-5",e.spacing5],["--spacing-6",e.spacing6],["--spacing-7",e.spacing7],["--spacing-8",e.spacing8]].forEach(([e,t])=>{void 0!==t&&this.mountPoint.style.setProperty(e,t)})}this.mountPoint&&!this.config.theme?.cssVariables&&(!function(){const e=document.documentElement.getAttribute("data-theme");return"dark"===e||"light"!==e&&window.matchMedia("(prefers-color-scheme: dark)").matches}()?Object.keys(ty).forEach(e=>{this.mountPoint.style.removeProperty(e)}):Object.entries(ty).forEach(([e,t])=>{this.mountPoint.style.setProperty(e,t)})),!this.root&&this.mountPoint&&(this.root=e(this.mountPoint));const t={apiKey:this.config.apiKey,apiBaseUrl:this.config.apiBaseUrl||Xb,agentId:this.config.agentId,theme:{botName:"Asistente Virtual",position:"bottom-right",welcomeMessage:"¡Hola! 👋 ¿En qué puedo ayudarte?",inputPlaceholder:"Escribe tu mensaje...",cssVariables:{primary:"160 84% 39%",windowBorderRadius:"24px",launcherBorderRadius:"50%"},...this.config.theme},userContext:this.config.userContext,pageContext:this.config.pageContext,includeSEOMetadata:this.config.includeSEOMetadata??!1,mediaConfig:this.config.mediaConfig,onNavigate:this.config.onNavigate,onLogin:this.config.onLogin,onEvent:this.config.onEvent,onStateChange:this.config.onStateChange},r=n.createElement(h,{fallback:n.createElement("div",{style:{position:"fixed",bottom:"24px",right:"24px",width:"60px",height:"60px",borderRadius:"50%",backgroundColor:"#10b981",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",cursor:"wait"}},n.createElement("div",{style:{width:"24px",height:"24px",border:"3px solid rgba(255, 255, 255, 0.3)",borderTopColor:"#fff",borderRadius:"50%",animation:"spin 1s linear infinite"}}))},n.createElement(ny,t));this.root.render(n.createElement(ey,null,n.createElement(D,{defaultLocale:this.config.theme?.defaultLocale,children:r}))),console.log("[BotUyoChat] Widget initialized",t)}update(e){this.config?(this.config={...this.config,...e,theme:{...this.config.theme,...e.theme}},this.render()):console.error("[BotUyoChat] Widget not initialized")}destroy(){this.darkModeObserver&&(this.darkModeObserver.disconnect(),this.darkModeObserver=null),this.darkModeMediaQuery&&(this.darkModeMediaQuery.removeEventListener("change",this.handleDarkModeChange),this.darkModeMediaQuery=null),this.root&&(this.root.unmount(),this.root=null),this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null,this.shadowRoot=null,this.mountPoint=null),this.config=null,console.log("[BotUyoChat] Widget destroyed")}setupDarkModeDetection(){this.config?.theme?.cssVariables||(this.handleDarkModeChange=()=>this.render(),this.darkModeObserver=new MutationObserver(this.handleDarkModeChange),this.darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),this.darkModeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.darkModeMediaQuery.addEventListener("change",this.handleDarkModeChange))}handleDarkModeChange=()=>{};open(){window.dispatchEvent(new CustomEvent("botuyo-chat:open"))}close(){window.dispatchEvent(new CustomEvent("botuyo-chat:close"))}startCall(){window.dispatchEvent(new CustomEvent("botuyo-chat:start-call"))}sendMessage(e){window.dispatchEvent(new CustomEvent("botuyo-chat:send-message",{detail:{message:e}}))}getState(){return null}}const oy=new ry;window.BotUyoChat=oy;export{Qb as A,ry as B,qb as C,X as L,Wb as P,he as X,q as a,Ot as b,Hb as c,Db as d,Ub as e,D as f,Lt as g,jb as h,oy as i,j,O as l,Jb as s,F as u};
219
- //# sourceMappingURL=standalone-CtwhFXSD.js.map
219
+ //# sourceMappingURL=standalone-BibwLA1S.js.map