robopark 3.3.36 → 3.3.38

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.
Files changed (50) hide show
  1. package/dist/robopark/add-robot.js +2 -2
  2. package/dist/robopark/add-robot.js.map +1 -1
  3. package/dist/robopark/audio-select.js +128 -0
  4. package/dist/robopark/audio-select.js.map +1 -0
  5. package/dist/robopark/device-preempt.js +185 -0
  6. package/dist/robopark/device-preempt.js.map +1 -0
  7. package/dist/robopark/kiosk-browser.js +145 -0
  8. package/dist/robopark/kiosk-browser.js.map +1 -0
  9. package/dist/robopark/start.js +455 -0
  10. package/dist/robopark/start.js.map +1 -0
  11. package/dist/robopark/voice-list.js +23 -12
  12. package/dist/robopark/voice-list.js.map +1 -1
  13. package/dist/robopark-cli.js +25 -0
  14. package/dist/robopark-cli.js.map +1 -1
  15. package/package.json +7 -3
  16. package/scheduler/main.py +150 -30
  17. package/scheduler/static/voice-join.html +48 -2
  18. package/ui/standalone/.next/BUILD_ID +1 -1
  19. package/ui/standalone/.next/app-build-manifest.json +72 -72
  20. package/ui/standalone/.next/app-path-routes-manifest.json +16 -16
  21. package/ui/standalone/.next/build-manifest.json +2 -2
  22. package/ui/standalone/.next/server/app/api/robovoice/robots/[robotId]/media-health/route.js +1 -1
  23. package/ui/standalone/.next/server/app/fed/[...path]/route.js +2 -2
  24. package/ui/standalone/.next/server/app/fed/media/robots/[robotId]/video_feed/route.js +1 -1
  25. package/ui/standalone/.next/server/app/robopark/[...path]/route.js +1 -1
  26. package/ui/standalone/.next/server/app/robopark/api/robots/[robotId]/stream/route.js +1 -1
  27. package/ui/standalone/.next/server/app-paths-manifest.json +16 -16
  28. package/ui/standalone/.next/server/functions-config-manifest.json +1 -1
  29. package/ui/standalone/.next/server/pages/500.html +1 -1
  30. package/ui/standalone/public/voice-join.html +48 -2
  31. package/scheduler/__pycache__/main.cpython-312.pyc +0 -0
  32. package/ui/standalone/.next/server/chunks/5123.js +0 -11
  33. package/ui/standalone/.next/server/chunks/7661.js +0 -11
  34. package/ui/standalone/.next/static/ULHwbueNr3RGevy8FSrTW/_buildManifest.js +0 -1
  35. package/ui/standalone/.next/static/ULHwbueNr3RGevy8FSrTW/_ssgManifest.js +0 -1
  36. package/ui/standalone/.next/static/Xg-e8h70WpdFcsZ2vcfOG/_buildManifest.js +0 -1
  37. package/ui/standalone/.next/static/Xg-e8h70WpdFcsZ2vcfOG/_ssgManifest.js +0 -1
  38. package/ui/standalone/.next/static/chunks/app/(app)/voice/page-d98593eea4888404.js +0 -1
  39. package/ui/standalone/.next/static/chunks/app/_not-found/page-9f0acae7481c60bb.js +0 -1
  40. package/ui/standalone/.next/static/chunks/app/layout-4829e027e68fded4.js +0 -1
  41. package/ui/standalone/.next/static/chunks/app/voice-tester/page-f5ad3acef9248b78.js +0 -1
  42. package/ui/standalone/.next/static/chunks/main-app-f2b2a716b0f3924b.js +0 -1
  43. package/ui/standalone/.next/static/gGysrZrp8HXGK_0MbZa9v/_buildManifest.js +0 -1
  44. package/ui/standalone/.next/static/gGysrZrp8HXGK_0MbZa9v/_ssgManifest.js +0 -1
  45. package/ui/standalone/.next/static/tDI_bBJ7vZjqqxcXg1GZn/_buildManifest.js +0 -1
  46. package/ui/standalone/.next/static/tDI_bBJ7vZjqqxcXg1GZn/_ssgManifest.js +0 -1
  47. package/ui/standalone/.next/static/zAWQgn-m46BFpT3z33lh-/_buildManifest.js +0 -1
  48. package/ui/standalone/.next/static/zAWQgn-m46BFpT3z33lh-/_ssgManifest.js +0 -1
  49. /package/ui/standalone/.next/static/{KwY1YC79lI9nQqOVYXOmY → 2zW74Q0KZAsncyNMwT9yQ}/_buildManifest.js +0 -0
  50. /package/ui/standalone/.next/static/{KwY1YC79lI9nQqOVYXOmY → 2zW74Q0KZAsncyNMwT9yQ}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[978],{2180:(e,t,a)=>{"use strict";a.d(t,{Bc:()=>o,m_:()=>u});var s=a(5155),r=a(2115),n=a(2990),l=a(7091);let o=n.Kq,i=n.bL,d=n.l9,c=r.forwardRef((e,t)=>{let{className:a,sideOffset:r=4,...o}=e;return(0,s.jsx)(n.ZL,{children:(0,s.jsx)(n.UC,{ref:t,sideOffset:r,className:(0,l.cn)("bg-primary text-primary-foreground z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs","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",a),...o})})});function u(e){let{children:t,content:a,side:r="top",delayDuration:n=300}=e;return(0,s.jsxs)(i,{delayDuration:n,children:[(0,s.jsx)(d,{asChild:!0,children:t}),(0,s.jsx)(c,{side:r,children:a})]})}c.displayName=n.UC.displayName},4601:(e,t,a)=>{"use strict";a.d(t,{Z:()=>o,t:()=>i});var s=a(5155),r=a(2115),n=a(9064);let l=(0,r.createContext)(null);function o(e){let{children:t}=e,[a,o]=(0,r.useState)(n.a),[i,d]=(0,r.useState)(!0),[c,u]=(0,r.useState)(null),m=(0,r.useCallback)(async()=>{d(!0),u(null);try{let e=await fetch("/api/settings");if(e.ok){let t=(await e.json()).settings||n.a;t.characters&&0!==t.characters.length||(t.characters=[n.o],t.active_character_id=n.o.id),o(t)}else o(n.a)}catch(e){console.error("Failed to load settings:",e),u("Failed to load settings")}finally{d(!1)}},[]);(0,r.useEffect)(()=>{m()},[m]);let p=async e=>{try{if(o(e),!(await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:e})})).ok)throw Error("Failed to save settings")}catch(e){throw console.error("Failed to update settings:",e),u("Failed to save settings"),m(),e}},x=async e=>{let t={...a,active_character_id:e};await p(t)},h=a.characters.find(e=>e.id===a.active_character_id)||a.characters[0]||n.o;return(0,s.jsx)(l.Provider,{value:{settings:a,activeCharacter:h,loading:i,error:c,updateSettings:p,setActiveCharacterId:x,reloadSettings:m},children:t})}function i(){let e=(0,r.useContext)(l);if(!e)throw Error("useSettings must be used within a SettingsProvider");return e}},5945:(e,t,a)=>{"use strict";a.d(t,{App:()=>tU});var s,r=a(5155),n=a(2115),l=a(3094),o=a(226),i=a(4219),d=a(8818);function c(){let e=(0,n.useRef)(null),t=(0,d.f)(),a=(0,o.t)([l.CC.Source.Microphone,l.CC.Source.ScreenShareAudio,l.CC.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!1}).filter(e=>!e.participant.isLocal&&e.publication.kind===l.CC.Kind.Audio&&(e.participant.isAgent||e.participant.identity.startsWith("agent-")));return(0,n.useEffect)(()=>{let e=()=>{t.state===l.KN.Connected&&t.startAudio().catch(e=>{console.warn("[AgentAudio] Browser blocked automatic playback:",e)})},a=()=>{t.remoteParticipants.forEach(e=>{(e.isAgent||e.identity.startsWith("agent-"))&&e.audioTrackPublications.forEach(e=>{e.isSubscribed||e.setSubscribed(!0)})}),e()};return a(),t.on(l.u9.Connected,a),t.on(l.u9.ParticipantConnected,a),t.on(l.u9.TrackPublished,a),t.on(l.u9.TrackSubscribed,e),t.on(l.u9.AudioPlaybackStatusChanged,e),()=>{t.off(l.u9.Connected,a),t.off(l.u9.ParticipantConnected,a),t.off(l.u9.TrackPublished,a),t.off(l.u9.TrackSubscribed,e),t.off(l.u9.AudioPlaybackStatusChanged,e)}},[t]),(0,n.useEffect)(()=>{let t=t=>{var a,s;let r=Number(null!=(s=window.localStorage.getItem("robopark:playback-volume-percent"))?s:100),n=Math.max(0,Math.min(100,Number.isFinite(t)?Number(t):r));window.localStorage.setItem("robopark:playback-volume-percent",String(n)),null==(a=e.current)||a.querySelectorAll("audio").forEach(e=>{e.volume=n/100,e.muted=0===n})},a=e=>{var a;return t(Number(null==(a=e.detail)?void 0:a.volume_percent))},s=new MutationObserver(()=>t());return e.current&&s.observe(e.current,{childList:!0,subtree:!0}),window.addEventListener("robopark:playback-volume",a),t(),()=>{s.disconnect(),window.removeEventListener("robopark:playback-volume",a)}},[]),(0,r.jsx)("div",{ref:e,"aria-hidden":!0,className:"pointer-events-none fixed h-px w-px overflow-hidden opacity-0",children:a.map(e=>(0,r.jsx)(i.s,{trackRef:e},"".concat(e.participant.identity,"-").concat(e.publication.trackSid)))})}var u=a(8382),m=a(6497),p=a(7091);let x=u.P.create("div"),h=u.P.create(e=>{let{name:t,locale:a,timestamp:s,message:n,messageOrigin:l,hasBeenEdited:o=!1,className:i,...d}=e,c=new Date(s),u=c.toLocaleTimeString(a,{timeStyle:"full"}),m="local"===l;return(0,r.jsx)("li",{title:u,"data-lk-message-origin":l,className:(0,p.cn)("group flex w-full",m?"justify-end":"justify-start",i),...d,children:(0,r.jsxs)("div",{className:(0,p.cn)("flex flex-col gap-0.5 max-w-[85%] sm:max-w-[75%]",m?"items-end":"items-start"),children:[!m&&(0,r.jsx)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-primary/60 ml-3 mb-0.5",children:t||"AI"}),(0,r.jsx)("div",{className:(0,p.cn)("relative px-3.5 py-2 text-[13px] sm:text-sm leading-relaxed",m?"bg-primary/15 border border-primary/25 rounded-2xl rounded-br-md text-foreground":"bg-white/[0.04] border border-white/[0.08] rounded-2xl rounded-bl-md text-foreground/90"),children:(0,r.jsx)("span",{className:"whitespace-pre-wrap break-words",children:n})}),(0,r.jsxs)("span",{className:(0,p.cn)("text-[10px] font-mono text-muted-foreground/40 px-3","opacity-0 group-hover:opacity-100 transition-opacity duration-200"),children:[o&&"✎ ",c.toLocaleTimeString(a,{timeStyle:"short"})]})]})})}),g={variants:{hidden:{opacity:0,transition:{ease:"easeOut",duration:.2,staggerChildren:.05,staggerDirection:-1}},visible:{opacity:1,transition:{delay:.1,ease:"easeOut",duration:.2,staggerChildren:.06,staggerDirection:1}}},initial:"hidden",animate:"visible",exit:"hidden"},b={variants:{hidden:{opacity:0,translateY:8,scale:.98},visible:{opacity:1,translateY:0,scale:1}},transition:{duration:.2}};function v(e){let{hidden:t=!1,messages:a=[],...s}=e;return(0,r.jsx)(m.N,{children:!t&&(0,r.jsx)(x,{...g,...s,children:(0,r.jsx)("ul",{className:"flex flex-col gap-2.5",children:a.map(e=>{var t,a;let{id:s,timestamp:n,from:l,message:o}=e,i=null!=(a=null==(t=navigator)?void 0:t.language)?a:"en-US",d=(null==l?void 0:l.isLocal)?"local":"remote",c="chatMessage"===e.type&&!!e.editTimestamp;return(0,r.jsx)(h,{locale:i,timestamp:n,message:o,messageOrigin:d,hasBeenEdited:c,...b},s)})})})})}let f={vixen:"/static/robopark/bmw.png",bmw:"/static/robopark/bmw.png",jaguar:"/static/robopark/jaguar.png",panda:"/static/robopark/panda.png",robopanda:"/static/robopark/panda.png",tesla:"/static/robopark/tesla.png",volt:"/static/robopark/volt.png"};function w(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];for(let t of["character_presets","characters","robots","items","data"])if(Array.isArray(e[t]))return e[t];return[]}async function y(e){var t;let[a,s,r,n]=await Promise.allSettled([fetch("/api/device-character",{cache:"no-store",signal:e}).then(async e=>{if(!e.ok)throw Error("device binding unavailable");return e.json()}),fetch("/robopark/api/character-presets",{cache:"no-store",signal:e}).then(async e=>{if(!e.ok)throw Error("dashboard presets unavailable");return e.json()}),fetch("/robopark/api/telemetry",{cache:"no-store",signal:e}).then(async e=>{if(!e.ok)throw Error("dashboard telemetry unavailable");return e.json()}),fetch("/api/settings",{cache:"no-store",signal:e}).then(async e=>{if(!e.ok)throw Error("native settings unavailable");return e.json()})]);if("fulfilled"!==a.status)return null;let l=a.value||{},o="string"==typeof l.character_id?l.character_id:"";if(!o)return null;let i="fulfilled"===s.status?w(s.value):[],d="fulfilled"===r.status?w(r.value):[],c=[l.device_id,l.device_name,l.name].filter(Boolean).map(e=>String(e).toLowerCase()),u=d.find(e=>[e.robot_id,e.device_id,e.name].filter(Boolean).some(e=>c.includes(String(e).toLowerCase()))),m=String((null==u?void 0:u.character_id)||o),p=i.find(e=>String(e.id||"").toLowerCase()===m.toLowerCase()),x="fulfilled"===n.status?n.value:{},h=w((null==x?void 0:x.settings)||x).find(e=>String(e.id||"").toLowerCase()===o.toLowerCase()),g=String((null==u?void 0:u.character_name)||(null==p?void 0:p.name)||(null==h?void 0:h.name)||m);return{characterId:m,characterName:g,robotName:String((null==u?void 0:u.name)||l.device_name||l.name||"RoboPark robot"),imageUrl:(t=(null==u?void 0:u.character_img)||(null==p?void 0:p.img)||(null==h?void 0:h.img),"string"==typeof t&&t.startsWith("/static/robopark/")?t:f[m.toLowerCase()]||"")}}function j(e){let{agentState:t,chatOpen:a,className:s}=e,[l,o]=(0,n.useState)(null),[i,d]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=null,t=!1,a=()=>{null==e||e.abort(),y((e=new AbortController).signal).then(e=>{!t&&e&&o(e)}).catch(e=>{t||(null==e?void 0:e.name)==="AbortError"||console.warn("[RoboPark] identity refresh failed:",e)})};a();let s=window.setInterval(a,15e3);return window.addEventListener("focus",a),window.addEventListener("robovoice:identity-changed",a),()=>{t=!0,null==e||e.abort(),window.clearInterval(s),window.removeEventListener("focus",a),window.removeEventListener("robovoice:identity-changed",a)}},[]),(0,n.useEffect)(()=>d(!1),[null==l?void 0:l.imageUrl]);let c="speaking"===t||"thinking"===t||"listening"===t;return(0,r.jsxs)("div",{className:(0,p.cn)("pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]",s),children:[(0,r.jsx)("div",{className:(0,p.cn)("absolute inset-0 bg-[radial-gradient(circle_at_50%_35%,rgba(245,200,92,0.18),rgba(4,4,3,0.92)_72%)] transition-opacity duration-500",c?"opacity-100":"opacity-70")}),(null==l?void 0:l.imageUrl)&&!i?(0,r.jsx)("img",{src:l.imageUrl,alt:l.characterName,onError:()=>d(!0),className:(0,p.cn)("absolute left-1/2 top-1/2 max-h-[82%] max-w-[82%] -translate-x-1/2 -translate-y-1/2 object-contain opacity-90 drop-shadow-[0_18px_28px_rgba(0,0,0,0.7)] transition-all duration-500",c&&"scale-[1.04] opacity-100",a&&"max-h-[68%] max-w-[68%]")}):null,l?(0,r.jsxs)("div",{className:"absolute inset-x-1 bottom-1 truncate rounded bg-black/55 px-1.5 py-0.5 text-center text-[7px] font-semibold uppercase tracking-[0.16em] text-amber-100/85 backdrop-blur-sm",children:[l.robotName," / ",l.characterName]}):null]})}let _=u.P.create("div"),N={type:"spring",stiffness:675,damping:75,mass:1},k={grid:["h-full w-full","grid gap-x-2 place-content-center","grid-cols-[1fr_1fr] grid-rows-[90px_1fr_90px]"],agentChatOpenWithSecondTile:["col-start-1 row-start-1","self-center justify-self-end"],agentChatOpenWithoutSecondTile:["col-start-1 row-start-1","col-span-2","place-content-center"],agentChatClosed:["col-start-1 row-start-1","col-span-2 row-span-3","place-content-center"],secondTileChatOpen:["col-start-2 row-start-1","self-center justify-self-start"],secondTileChatClosed:["col-start-2 row-start-3","place-content-end"]};function C(e){var t,a,s,d,c,u,x,h,g,b,v,f,w,y,C,S;let{chatOpen:T,fullscreenCamera:E=!1}=e,{state:P,audioTrack:I,videoTrack:A}=(0,o.X)(),[O]=(0,o.t)([l.CC.Source.ScreenShare]),L=function(e){let{localParticipant:t}=(0,o.C)(),a=t.getTrackPublication(e);return(0,n.useMemo)(()=>a?{source:e,participant:t,publication:a}:void 0,[e,a,t])}(l.CC.Source.Camera),M=L&&!L.publication.isMuted,z=O&&!O.publication.isMuted,R=M||z,D=.15*!T,q=void 0!==A,F=null!=(x=null==A||null==(t=A.publication.dimensions)?void 0:t.width)?x:0,U=null!=(h=null==A||null==(a=A.publication.dimensions)?void 0:a.height)?h:0;return E?(0,r.jsxs)("div",{className:"pointer-events-none fixed inset-0 z-20 overflow-hidden bg-black",children:[R?(0,r.jsx)(i.V,{trackRef:L||O,width:null!=(w=null==(b=L||O)||null==(g=b.publication.dimensions)?void 0:g.width)?w:0,height:null!=(y=null==(f=L||O)||null==(v=f.publication.dimensions)?void 0:v.height)?y:0,className:"h-full w-full object-cover"}):(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-sm font-mono text-white/50",children:"CAMERA FEED UNAVAILABLE"}),(0,r.jsx)("div",{className:"absolute inset-0 bg-gradient-to-b from-black/45 via-transparent to-black/70"}),(0,r.jsxs)("div",{className:"absolute inset-5 border border-primary/25 sm:inset-8",children:[(0,r.jsx)("div",{className:"absolute -left-px -top-px h-10 w-10 border-l-2 border-t-2 border-primary/80"}),(0,r.jsx)("div",{className:"absolute -right-px -top-px h-10 w-10 border-r-2 border-t-2 border-primary/80"}),(0,r.jsx)("div",{className:"absolute -bottom-px -left-px h-10 w-10 border-b-2 border-l-2 border-primary/80"}),(0,r.jsx)("div",{className:"absolute -bottom-px -right-px h-10 w-10 border-b-2 border-r-2 border-primary/80"})]}),(0,r.jsxs)("div",{className:"absolute left-1/2 top-1/2 h-8 w-8 -translate-x-1/2 -translate-y-1/2 opacity-35",children:[(0,r.jsx)("div",{className:"absolute left-1/2 top-0 h-full w-px bg-primary"}),(0,r.jsx)("div",{className:"absolute left-0 top-1/2 h-px w-full bg-primary"})]}),(0,r.jsxs)("div",{className:"absolute left-8 top-12 flex items-center gap-2 rounded-full border border-green-400/30 bg-black/45 px-3 py-1.5 font-mono text-[10px] text-green-300 backdrop-blur-md sm:left-12",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-400"})," LIVE CAMERA"]})]}):(0,r.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-8 bottom-32 z-50 md:top-12 md:bottom-40",children:(0,r.jsx)("div",{className:"relative mx-auto h-full max-w-2xl px-4 md:px-0",children:(0,r.jsxs)("div",{className:(0,p.cn)(k.grid),children:[(0,r.jsx)("div",{className:(0,p.cn)(["grid",!T&&k.agentChatClosed,T&&R&&k.agentChatOpenWithSecondTile,T&&!R&&k.agentChatOpenWithoutSecondTile]),children:(0,r.jsxs)(m.N,{mode:"popLayout",children:[!q&&(0,r.jsxs)(_,{layoutId:"agent",initial:{opacity:0,scale:0},animate:{opacity:1,scale:T?1:5},transition:{...N,delay:D},className:(0,p.cn)("bg-background relative aspect-square h-[90px] overflow-hidden rounded-md border border-transparent transition-[border,drop-shadow]",T&&"border-input/50 drop-shadow-lg/10 delay-200"),children:[(0,r.jsx)(j,{agentState:P,chatOpen:T}),(0,r.jsx)(i.B,{barCount:5,state:P,options:{minHeight:5},trackRef:I,className:(0,p.cn)("relative z-10 flex h-full items-center justify-center gap-1"),children:(0,r.jsx)("span",{className:(0,p.cn)(["bg-muted min-h-2.5 w-2.5 rounded-full","origin-center transition-colors duration-250 ease-linear","data-[lk-highlighted=true]:bg-foreground data-[lk-muted=true]:bg-muted"])})})]},"agent"),q&&(0,r.jsx)(_,{layoutId:"avatar",initial:{scale:1,opacity:1,maskImage:"radial-gradient(circle, rgba(0, 0, 0, 1) 0, rgba(0, 0, 0, 1) 20px, transparent 20px)",filter:"blur(20px)"},animate:{maskImage:"radial-gradient(circle, rgba(0, 0, 0, 1) 0, rgba(0, 0, 0, 1) 500px, transparent 500px)",filter:"blur(0px)",borderRadius:T?6:12},transition:{...N,delay:D,maskImage:{duration:1},filter:{duration:1}},className:(0,p.cn)("overflow-hidden bg-black drop-shadow-xl/80",T?"h-[90px]":"h-auto w-full"),children:(0,r.jsx)(i.V,{width:F,height:U,trackRef:A,className:(0,p.cn)(T&&"size-[90px] object-cover")})},"avatar")]})}),(0,r.jsx)("div",{className:(0,p.cn)(["grid",T&&k.secondTileChatOpen,!T&&k.secondTileChatClosed]),children:(0,r.jsx)(m.N,{children:(L&&M||O&&z)&&(0,r.jsx)(_,{layout:"position",layoutId:"camera",initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},exit:{opacity:0,scale:0},transition:{...N,delay:D},className:"drop-shadow-lg/20",children:(0,r.jsx)(i.V,{trackRef:L||O,width:null!=(C=null==(d=L||O)||null==(s=d.publication.dimensions)?void 0:s.width)?C:0,height:null!=(S=null==(u=L||O)||null==(c=u.publication.dimensions)?void 0:c.height)?S:0,className:"bg-muted aspect-square w-[90px] rounded-md object-cover"})},"camera")})})]})})})}var S=a(3670),T=a(583),E=a(6973),P=a(5012),I=a(2180);function A(e){let{className:t}=e,a=function(){let e=(0,d.f)(),[t,a]=(0,n.useState)(null);return(0,n.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/wake-word/status");e.ok&&(await e.json()).enabled&&a("listening")}catch(e){console.error("[useWakeWordState] Failed to fetch initial state:",e)}})()},[]),(0,n.useEffect)(()=>{if(!e)return;let t=(e,t,s,r)=>{if("wakeword_state"===r)try{let t=new TextDecoder,s=JSON.parse(t.decode(e));"wakeword_state"===s.type&&s.state&&a(s.state)}catch(e){console.error("[useWakeWordState] Failed to parse wake word state:",e)}};return e.on(l.u9.DataReceived,t),()=>{e.off(l.u9.DataReceived,t)}},[e]),t}(),[s,o]=n.useState("");n.useEffect(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{var t,a;o(((a=(null==(t=e.settings)?void 0:t.wake_word_model)||"models/hey_cal.onnx").split("/").pop()||a).replace(".onnx","").replace(/_/g," ").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "))}).catch(()=>o("Hey Cal"))},[]);let i=null===a,c="listening"===a,u=i?E.a:P.H;return(0,r.jsx)(I.m_,{content:i?"Wake word detection disabled":c?'Waiting for wake word - say "'.concat(s,'"'):"Listening - speak now",children:(0,r.jsx)("div",{className:(0,p.cn)("inline-flex size-9 items-center justify-center rounded-full","text-sm font-medium","cursor-default transition-[color,box-shadow,background-color] outline-none","active"===a?"bg-purple-500/20 text-purple-700 dark:text-purple-300":c?"bg-pink-500/20 text-pink-700 dark:text-pink-300":"bg-muted text-muted-foreground",t),children:(0,r.jsx)(u,{weight:"bold",className:"size-4 shrink-0"})})})}var O=a(3113),L=a(4521),M=a(6786),z=a(6844),R=a(6237),D=a(3134),q=a(3101),F=a(1887);let U=(0,q.F)(["inline-flex items-center justify-center gap-2 rounded-full","text-sm font-medium whitespace-nowrap","cursor-pointer outline-none transition-[color,box-shadow,background-color]","hover:bg-muted hover:text-muted-foreground","disabled:pointer-events-none disabled:opacity-50","data-[state=on]:bg-accent data-[state=on]:text-accent-foreground","focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:border-ring","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ","[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"bg-transparent",primary:"bg-muted data-[state=on]:bg-muted hover:text-foreground text-destructive hover:text-foreground hover:bg-foreground/10 hover:data-[state=on]:bg-foreground/10",secondary:"bg-muted data-[state=on]:bg-muted hover:text-foreground hover:bg-foreground/10 hover:data-[state=on]:bg-foreground/10 data-[state=on]:bg-blue-500/20 data-[state=on]:hover:bg-blue-500/30 data-[state=on]:text-blue-700 dark:data-[state=on]:text-blue-300",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function V(e){let{className:t,variant:a,size:s,...n}=e;return(0,r.jsx)(F.b,{"data-slot":"toggle",className:(0,p.cn)(U({variant:a,size:s,className:t})),...n})}function W(e){let{source:t,pressed:a,pending:s,className:o,...i}=e,d=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(a)return O.N;switch(e){case l.CC.Source.Microphone:return t?L.c:M.z;case l.CC.Source.Camera:return t?z.U:R.h;case l.CC.Source.ScreenShare:return D.G;default:return n.Fragment}}(t,null!=a&&a,s);return(0,r.jsxs)(V,{pressed:a,"aria-label":"Toggle ".concat(t),className:(0,p.cn)(o),...i,children:[(0,r.jsx)(d,{weight:"bold",className:(0,p.cn)(s&&"animate-spin")}),i.children]})}var H=a(2467);let G=(0,q.F)(["text-xs font-bold tracking-wider uppercase whitespace-nowrap","inline-flex items-center justify-center gap-2 shrink-0 rounded-full cursor-pointer outline-none transition-colors duration-300","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","disabled:pointer-events-none disabled:opacity-50","aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40 ","[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"bg-muted text-foreground hover:bg-muted focus:bg-muted hover:bg-foreground/10",destructive:["bg-destructive/10 text-destructive","hover:bg-destructive/20 focus:bg-destructive/20 focus-visible:ring-destructive/20","dark:focus-visible:ring-destructive/40"],outline:["border border-input bg-background","hover:bg-accent hover:text-accent-foreground","dark:bg-input/30 dark:border-input dark:hover:bg-input/50"],primary:"bg-primary text-primary-foreground hover:bg-primary/70 focus:bg-primary/70",secondary:"bg-foreground/15 text-secondary-foreground hover:bg-foreground/20",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function B(e){let{className:t,variant:a,size:s,asChild:n=!1,...l}=e,o=n?H.DX:"button";return(0,r.jsx)(o,{"data-slot":"button",className:(0,p.cn)(G({variant:a,size:s,className:t})),...l})}var J=a(7552);function K(e){let{chatOpen:t,isAgentAvailable:a=!1,onSend:s=async()=>{}}=e,l=(0,n.useRef)(null),[o,i]=(0,n.useState)(!1),[d,c]=(0,n.useState)(""),m=async e=>{e.preventDefault();try{i(!0),await s(d),c("")}catch(e){console.error(e)}finally{i(!1)}},p=o||!a||0===d.trim().length;return(0,n.useEffect)(()=>{var e;t&&a||null==(e=l.current)||e.focus()},[t,a]),(0,r.jsx)(u.P.div,{initial:"hidden",animate:t?"visible":"hidden",variants:{hidden:{height:0,opacity:0,marginBottom:0},visible:{height:"auto",opacity:1,marginBottom:8}},transition:{duration:.25},className:"flex w-full items-start overflow-hidden",children:(0,r.jsxs)("form",{onSubmit:m,className:"flex grow items-center gap-1.5 rounded-xl bg-white/[0.04] border border-white/[0.06] px-3 py-1 text-sm",children:[(0,r.jsx)("input",{autoFocus:!0,ref:l,type:"text",value:d,disabled:!t,placeholder:"Type a message...",onChange:e=>c(e.target.value),className:"h-9 flex-1 bg-transparent focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 text-foreground placeholder:text-muted-foreground/40 text-sm"}),(0,r.jsx)(B,{size:"icon",type:"submit",disabled:p,variant:p?"secondary":"primary",title:o?"Sending...":"Send",className:"h-8 w-8 flex-shrink-0",children:o?(0,r.jsx)(O.N,{className:"animate-spin h-3.5 w-3.5",weight:"bold"}):(0,r.jsx)(J.S,{className:"h-3.5 w-3.5",weight:"bold"})})]})})}var X=a(8232),Z=a(446),Y=a(7053),$=a(2455);function Q(e){let{...t}=e;return(0,r.jsx)($.bL,{"data-slot":"select",...t})}function ee(e){let{...t}=e;return(0,r.jsx)($.WT,{"data-slot":"select-value",...t})}function et(e){let{className:t,size:a="default",children:s,...n}=e;return(0,r.jsxs)($.l9,{"data-slot":"select-trigger","data-size":a,className:(0,p.cn)(["flex w-fit cursor-pointer items-center justify-between gap-2","rounded-full px-3 py-2 text-sm whitespace-nowrap","bg-muted transition-[color,border,background-color]","disabled:cursor-not-allowed disabled:opacity-50","focus-visible:border-ring focus-visible:ring-ring/50 hover:bg-foreground/10 focus:bg-foreground/10 outline-none focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive","data-[placeholder]:text-muted-foreground","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","[&:not([class*='text-'])_svg:not([class*='text-'])]:text-muted-foreground","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],t),...n,children:[s,(0,r.jsx)($.In,{asChild:!0,children:(0,r.jsx)(X.b,{weight:"bold",className:"size-4 transition-colors"})})]})}function ea(e){let{className:t,children:a,position:s="popper",...n}=e;return(0,r.jsx)($.ZL,{children:(0,r.jsxs)($.UC,{"data-slot":"select-content",className:(0,p.cn)(["bg-popover text-popover-foreground relative z-50 overflow-x-hidden overflow-y-auto rounded-md border drop-shadow-xl/5","max-h-(--radix-select-content-available-height) min-w-[8rem]","origin-(--radix-select-content-transform-origin)","data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=top]:slide-in-from-bottom-2","data-[side=right]:slide-in-from-left-2","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2"],"popper"===s&&"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:s,...n,children:[(0,r.jsx)(er,{}),(0,r.jsx)($.LM,{className:(0,p.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),(0,r.jsx)(en,{})]})})}function es(e){let{className:t,children:a,...s}=e;return(0,r.jsxs)($.q7,{"data-slot":"select-item",className:(0,p.cn)(["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","cursor-pointer disabled:cursor-not-allowed","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2","[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],t),...s,children:[(0,r.jsx)("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,r.jsx)($.VF,{children:(0,r.jsx)(Z.S,{className:"size-4",weight:"bold"})})}),(0,r.jsx)($.p4,{children:a})]})}function er(e){let{className:t,...a}=e;return(0,r.jsx)($.PP,{"data-slot":"select-scroll-up-button",className:(0,p.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,r.jsx)(Y.S,{className:"size-4",weight:"bold"})})}function en(e){let{className:t,...a}=e;return(0,r.jsx)($.wn,{"data-slot":"select-scroll-down-button",className:(0,p.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,r.jsx)(X.b,{className:"size-4",weight:"bold"})})}let el=(0,q.F)("w-full rounded-full px-3 py-2 text-sm cursor-pointer disabled:not-allowed",{variants:{size:{default:"w-[180px]",sm:"w-auto"}},defaultVariants:{size:"default"}});function eo(e){let{kind:t,track:a,size:s="default",requestPermissions:l=!1,tooltip:i,onMediaDeviceError:c,onDeviceListChange:u,onActiveDeviceChange:m,...x}=e,h=(0,d.w)(),[g,b]=(0,n.useState)(!1),[v,f]=(0,n.useState)(l),{devices:w,activeDeviceId:y,setActiveMediaDevice:j}=(0,o.e)({room:h,kind:t,track:a,requestPermissions:v,onError:c});(0,n.useEffect)(()=>{null==u||u(w)},[w,u]),(0,n.useLayoutEffect)(()=>{g&&f(!0)},[g]);let _=(0,n.useMemo)(()=>w.filter(e=>""!==e.deviceId),[w]);if(_.length<2)return null;let N=i||("audioinput"===t?"Select microphone":"Select camera"),k=(0,r.jsx)(et,{className:(0,p.cn)(el({size:s}),x.className),children:"sm"!==s&&(0,r.jsx)(ee,{className:"font-mono text-sm",placeholder:"Select a ".concat(t)})});return(0,r.jsxs)(Q,{open:g,value:y,onOpenChange:b,onValueChange:e=>{j(e);try{window.localStorage.setItem("robopark:media-device:".concat(t),e)}catch(e){}null==m||m(e)},children:[(0,r.jsx)(I.m_,{content:N,children:k}),(0,r.jsx)(ea,{children:_.map(e=>(0,r.jsx)(es,{value:e.deviceId,className:"font-mono text-xs",children:e.label},e.deviceId))})]})}function ei(e){let{kind:t,source:a,pressed:s,pending:n,disabled:l,className:o,audioTrackRef:d,onPressedChange:c,onMediaDeviceError:u,onActiveDeviceChange:m}=e;return(0,r.jsxs)("div",{className:(0,p.cn)("flex items-center gap-0",o),children:[(0,r.jsx)(W,{size:"icon",variant:"primary",source:a,pressed:s,pending:n,disabled:l,onPressedChange:c,className:"peer/track group/track has-[.audiovisualizer]:w-auto has-[.audiovisualizer]:px-3 has-[~_button]:rounded-r-none has-[~_button]:pr-2 has-[~_button]:pl-3",children:d&&(0,r.jsx)(i.B,{barCount:3,options:{minHeight:5},trackRef:d,className:"audiovisualizer flex h-6 w-auto items-center justify-center gap-0.5",children:(0,r.jsx)("span",{className:(0,p.cn)(["h-full w-0.5 origin-center rounded-2xl","group-data-[state=on]/track:bg-foreground group-data-[state=off]/track:bg-destructive","data-lk-muted:bg-muted"])})})}),(0,r.jsx)("hr",{className:"bg-border peer-data-[state=off]/track:bg-destructive/20 relative z-10 -mr-px hidden h-4 w-px border-none has-[~_button]:block"}),(0,r.jsx)(eo,{size:"sm",kind:t,requestPermissions:!1,onMediaDeviceError:u,onActiveDeviceChange:m,className:(0,p.cn)(["rounded-l-none pl-2","peer-data-[state=off]/track:text-destructive","hover:text-foreground focus:text-foreground","hover:peer-data-[state=off]/track:text-foreground","focus:peer-data-[state=off]/track:text-destructive"])})]})}function ed(e){var t,a,s,i,d;let{controls:c,saveUserChoices:u=!0,className:m,isConnected:x=!1,onDisconnect:h,onDeviceError:g,onChatOpenChange:b,...v}=e,{send:f}=(0,o.w)(),w=(0,o.M)(),[y,j]=(0,n.useState)(!1),_=function(){var e;let t=(0,o.A)(),a=e=>!!(null==t?void 0:t.canPublish)&&(0===t.canPublishSources.length||t.canPublishSources.includes((e=>{switch(e){case l.CC.Source.Camera:return 1;case l.CC.Source.Microphone:return 2;case l.CC.Source.ScreenShare:return 3;default:return 0}})(e)));return{camera:a(l.CC.Source.Camera),microphone:a(l.CC.Source.Microphone),screenShare:a(l.CC.Source.ScreenShare),data:null!=(e=null==t?void 0:t.canPublishData)&&e}}(),{micTrackRef:N,cameraToggle:k,microphoneToggle:C,screenShareToggle:E,handleAudioDeviceChange:P,handleVideoDeviceChange:O,handleMicrophoneDeviceSelectError:L,handleCameraDeviceSelectError:M}=function(){let{saveUserChoices:e=!0,onDeviceError:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{microphoneTrack:a,localParticipant:s}=(0,o.C)(),r=(0,o.h)({source:l.CC.Source.Microphone,onDeviceError:e=>null==t?void 0:t({source:l.CC.Source.Microphone,error:e})}),i=(0,o.h)({source:l.CC.Source.Camera,onDeviceError:e=>null==t?void 0:t({source:l.CC.Source.Camera,error:e})}),d=(0,o.h)({source:l.CC.Source.ScreenShare,onDeviceError:e=>null==t?void 0:t({source:l.CC.Source.ScreenShare,error:e})}),c=(0,n.useMemo)(()=>({participant:s,source:l.CC.Source.Microphone,publication:a}),[s,a]),{saveAudioInputEnabled:u,saveVideoInputEnabled:m,saveAudioInputDeviceId:p,saveVideoInputDeviceId:x}=(0,o.x)({preventSave:!e}),h=(0,n.useCallback)(e=>{p(null!=e?e:"default")},[p]),g=(0,n.useCallback)(e=>{x(null!=e?e:"default")},[x]),b=(0,n.useCallback)(async e=>{d.enabled&&d.toggle(!1),await i.toggle(e),m(!i.enabled)},[i,d,m]),v=(0,n.useCallback)(async e=>{await r.toggle(e),u(!r.enabled)},[r,u]),f=(0,n.useCallback)(async e=>{i.enabled&&i.toggle(!1),await d.toggle(e)},[i,d]),w=(0,n.useCallback)(e=>null==t?void 0:t({source:l.CC.Source.Microphone,error:e}),[t]),y=(0,n.useCallback)(e=>null==t?void 0:t({source:l.CC.Source.Camera,error:e}),[t]);return{micTrackRef:c,cameraToggle:{...i,toggle:b},microphoneToggle:{...r,toggle:v},screenShareToggle:{...d,toggle:f},handleAudioDeviceChange:h,handleVideoDeviceChange:g,handleMicrophoneDeviceSelectError:w,handleCameraDeviceSelectError:y}}({onDeviceError:g,saveUserChoices:u}),z=async e=>{await f(e)},R=(0,n.useCallback)(e=>{j(e),null==b||b(e)},[b,j]),D={leave:null==(t=null==c?void 0:c.leave)||t,microphone:null!=(a=null==c?void 0:c.microphone)?a:_.microphone,screenShare:null!=(s=null==c?void 0:c.screenShare)?s:_.screenShare,camera:null!=(i=null==c?void 0:c.camera)?i:_.camera,chat:null!=(d=null==c?void 0:c.chat)?d:_.data},q=w.some(e=>e.isAgent);return(0,r.jsxs)("div",{"aria-label":"Voice assistant controls",className:(0,p.cn)("bg-black/80 border border-white/[0.08] backdrop-blur-xl flex flex-col rounded-2xl p-2 sm:p-2.5 shadow-[0_8px_32px_rgba(0,0,0,0.6)] transition-all duration-300 hover:border-primary/30",m),...v,children:[D.chat&&(0,r.jsx)(K,{chatOpen:y,isAgentAvailable:q,onSend:z}),(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsxs)("div",{className:"flex grow gap-1",children:[D.microphone&&(0,r.jsx)(ei,{kind:"audioinput","aria-label":"Toggle microphone",source:l.CC.Source.Microphone,pressed:C.enabled,disabled:C.pending,audioTrackRef:N,onPressedChange:C.toggle,onMediaDeviceError:L,onActiveDeviceChange:P}),(0,r.jsx)(A,{}),D.camera&&(0,r.jsx)(ei,{kind:"videoinput","aria-label":"Toggle camera",source:l.CC.Source.Camera,pressed:k.enabled,pending:k.pending,disabled:k.pending,onPressedChange:k.toggle,onMediaDeviceError:M,onActiveDeviceChange:O}),D.screenShare&&(0,r.jsx)(I.m_,{content:"Screen share",children:(0,r.jsx)(W,{size:"icon",variant:"secondary","aria-label":"Toggle screen share",source:l.CC.Source.ScreenShare,pressed:E.enabled,disabled:E.pending,onPressedChange:E.toggle})}),(0,r.jsx)(I.m_,{content:"Transcript",children:(0,r.jsx)(V,{size:"icon",variant:"secondary","aria-label":"Toggle transcript",pressed:y,onPressedChange:R,children:(0,r.jsx)(S.$,{weight:"bold"})})})]}),D.leave&&(0,r.jsx)(I.m_,{content:"End session",children:(0,r.jsxs)(B,{variant:"destructive",onClick:h,disabled:!x,className:"font-mono",children:[(0,r.jsx)(T.c,{weight:"bold"}),(0,r.jsx)("span",{className:"hidden md:inline",children:"END CALL"}),(0,r.jsx)("span",{className:"inline md:hidden",children:"END"})]})})]})]})}let ec=(0,n.forwardRef)(function(e,t){var a;let{className:s,children:l}=e,o=(0,n.useRef)(null);a=o.current,(0,n.useEffect)(()=>{function e(){a&&a.scrollHeight-a.clientHeight-a.scrollTop<100&&(a.scrollTop=a.scrollHeight)}if(a&&a.firstElementChild){let t=new ResizeObserver(e);return t.observe(a.firstElementChild),e(),()=>t.disconnect()}},[a]);let i=(0,n.useCallback)(e=>{o.current=e,"function"==typeof t?t(e):t&&(t.current=e)},[t]);return(0,r.jsx)("div",{ref:i,className:(0,p.cn)("overflow-y-scroll scroll-smooth",s),children:(0,r.jsx)("div",{children:l})})});var eu=a(4601);let em=["Warming up the model…","Loading neural weights…","Calibrating voice…","Almost ready…"],ep={robopanda:"\uD83D\uDC3C",cal:"\uD83E\uDD16",default:"\uD83E\uDD16"};function ex(){var e;let t=function(){let e=(0,d.f)(),[t,a]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(!e)return;let t=(e,t,s,r)=>{if("model_loading_status"===r)try{let t=new TextDecoder,s=JSON.parse(t.decode(e));"boolean"==typeof s.is_loading&&a(s.is_loading)}catch(e){console.error("[useModelLoadingStatus] Failed to parse status:",e)}};return e.on(l.u9.DataReceived,t),()=>{e.off(l.u9.DataReceived,t)}},[e]),t}(),{activeCharacter:a}=(0,eu.t)(),[s,o]=n.useState(0);n.useEffect(()=>{if(!t)return void o(0);let e=setInterval(()=>{o(e=>(e+1)%em.length)},1800);return()=>clearInterval(e)},[t]);let i=null!=(e=ep[(a.id||a.name||"default").toLowerCase().replace(/\s+/g,"")])?e:"",c=(a.name||"?").trim().charAt(0).toUpperCase(),p=a.name||"Assistant";return(0,r.jsx)(m.N,{children:t&&(0,r.jsx)(u.P.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:(0,r.jsxs)(u.P.div,{initial:{y:12,scale:.96},animate:{y:0,scale:1},exit:{y:8,scale:.96},transition:{type:"spring",stiffness:220,damping:22},className:"relative pointer-events-auto rounded-3xl p-7 max-w-[20rem] text-center shadow-2xl border border-primary/20 bg-black/85 backdrop-blur-xl",children:[(0,r.jsx)(u.P.div,{"aria-hidden":!0,className:"absolute -inset-6 rounded-full bg-gradient-to-br from-primary/30 via-purple-500/20 to-fuchsia-500/30 blur-3xl -z-10",animate:{opacity:[.4,.85,.4],scale:[.9,1.08,.9]},transition:{duration:2.6,repeat:1/0,ease:"easeInOut"}}),(0,r.jsxs)("div",{className:"relative mx-auto mb-3 h-24 w-24",children:[[0,1,2].map(e=>(0,r.jsx)(u.P.div,{"aria-hidden":!0,className:"absolute inset-0 rounded-full border border-primary/30",style:{transform:"scale(".concat(.55+.22*e,")")},animate:{opacity:[.2,.6,.2],rotate:e%2==0?[0,360]:[360,0]},transition:{opacity:{duration:2.4,delay:.3*e,repeat:1/0,ease:"easeInOut"},rotate:{duration:8+3*e,repeat:1/0,ease:"linear"}}},"ring-".concat(e))),(0,r.jsx)(u.P.div,{className:"absolute inset-0 flex items-center justify-center",animate:{scale:[1,1.06,1]},transition:{duration:2.2,repeat:1/0,ease:"easeInOut"},children:i?(0,r.jsx)("span",{className:"text-5xl leading-none select-none drop-shadow-[0_0_18px_rgba(160,32,240,0.55)]",children:i}):(0,r.jsx)("span",{className:"font-mono text-4xl font-black tracking-tight bg-gradient-to-br from-primary via-purple-300 to-fuchsia-300 bg-clip-text text-transparent drop-shadow-[0_0_18px_rgba(160,32,240,0.55)] select-none",children:c})}),[0,1,2].map(e=>(0,r.jsx)(u.P.span,{"aria-hidden":!0,className:"absolute left-1/2 top-1/2 h-1.5 w-1.5 rounded-full bg-primary shadow-[0_0_10px_rgba(160,32,240,0.9)]",style:{marginLeft:-3,marginTop:-3},animate:{rotate:[0,360]},transition:{duration:3.2+.6*e,repeat:1/0,ease:"linear",delay:.4*e},initial:{x:36+4*e,y:0}},"orbit-".concat(e)))]}),(0,r.jsx)("div",{className:"flex items-center justify-center gap-1.5 mb-3 h-3",children:[0,1,2].map(e=>(0,r.jsx)(u.P.span,{className:"block w-2 h-2 rounded-full bg-primary shadow-[0_0_8px_rgba(160,32,240,0.7)]",animate:{y:[0,-6,0],opacity:[.4,1,.4]},transition:{duration:.9,delay:.15*e,repeat:1/0,ease:"easeInOut"}},e))}),(0,r.jsxs)("h3",{className:"font-mono font-bold text-base sm:text-lg text-foreground tracking-tight uppercase",children:[(0,r.jsx)("span",{className:"bg-gradient-to-r from-primary via-purple-300 to-fuchsia-300 bg-clip-text text-transparent",children:p})," ",(0,r.jsx)("span",{className:"text-muted-foreground/80",children:"is waking up"})]}),(0,r.jsx)("div",{className:"h-5 mt-1 relative overflow-hidden",children:(0,r.jsx)(m.N,{mode:"wait",children:(0,r.jsx)(u.P.p,{initial:{y:8,opacity:0},animate:{y:0,opacity:1},exit:{y:-8,opacity:0},transition:{duration:.35},className:"text-xs sm:text-sm text-muted-foreground absolute inset-0 font-mono tracking-wide",children:em[s]},s)})})]})})})}var eh=a(4437);function eg(e){return e<800?{label:"snappy",color:"text-emerald-300",bar:"bg-emerald-400"}:e<1600?{label:"good",color:"text-lime-300",bar:"bg-lime-400"}:e<2500?{label:"okay",color:"text-amber-300",bar:"bg-amber-400"}:e<4e3?{label:"slow",color:"text-orange-300",bar:"bg-orange-400"}:{label:"sluggish",color:"text-rose-300",bar:"bg-rose-400"}}function eb(e){let{label:t,ms:a,total:s,color:n}=e,l=s>0?Math.max(2,Math.round(a/s*100)):0;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-16 shrink-0 font-mono text-[10px] uppercase tracking-wider text-muted-foreground",children:t}),(0,r.jsx)("div",{className:"relative h-1.5 flex-1 overflow-hidden rounded-full bg-white/5",children:(0,r.jsx)(u.P.div,{className:(0,p.cn)("absolute inset-y-0 left-0 rounded-full",n),initial:{width:0},animate:{width:"".concat(l,"%")},transition:{duration:.5,ease:"easeOut"}})}),(0,r.jsxs)("span",{className:"w-10 shrink-0 text-right font-mono text-[10px] font-semibold tabular-nums text-foreground/80",children:[a,"ms"]})]})}function ev(){let{latest:e,avg_ms:t}=function(){let e=(0,d.f)(),[t,a]=(0,n.useState)(null),[s,r]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(!e)return;let t=(e,t,s,n)=>{if("response_latency"===n)try{let t=JSON.parse(new TextDecoder().decode(e));if("number"!=typeof t.total_ms)return;a(t),r(e=>[...e,t].slice(-10))}catch(e){console.error("[useResponseLatency] parse failed:",e)}};return e.on(l.u9.DataReceived,t),()=>{e.off(l.u9.DataReceived,t)}},[e]);let o=s.length>0?Math.round(s.reduce((e,t)=>e+t.total_ms,0)/s.length):null;return{latest:t,history:s,avg_ms:o}}(),[a,s]=n.useState(!1),[o,i]=n.useState(!1),c=n.useRef(0);if(n.useEffect(()=>{if(!e||e.ts===c.current)return;c.current=e.ts,s(!0);let t=setTimeout(()=>{o||s(!1)},5e3);return()=>clearTimeout(t)},[e,o]),!e)return null;let x=eg(e.total_ms),h=eg(e.stt_to_llm_ms).bar,g=x.bar;return(0,r.jsx)("div",{className:"pointer-events-auto fixed bottom-24 right-4 z-40 sm:bottom-28 sm:right-6",onMouseEnter:()=>{i(!0),s(!0)},onMouseLeave:()=>i(!1),children:(0,r.jsxs)(u.P.div,{layout:!0,transition:{type:"spring",stiffness:260,damping:26},className:(0,p.cn)("overflow-hidden rounded-2xl border border-white/10 bg-black/80 backdrop-blur-xl shadow-[0_8px_32px_rgba(0,0,0,0.6)]","hover:border-primary/30 transition-colors duration-200"),children:[(0,r.jsx)(m.N,{mode:"wait",initial:!1,children:a?(0,r.jsxs)(u.P.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"w-64 p-3",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(eh.C,{weight:"fill",className:(0,p.cn)("h-3.5 w-3.5",x.color)}),(0,r.jsx)("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-widest text-muted-foreground",children:"response time"})]}),(0,r.jsx)("span",{className:(0,p.cn)("rounded-full px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase tracking-wider",x.color,"bg-white/5"),children:x.label})]}),(0,r.jsxs)("div",{className:"mb-2 flex items-baseline gap-1",children:[(0,r.jsx)("span",{className:(0,p.cn)("font-mono text-2xl font-black tabular-nums leading-none",x.color),children:e.total_ms}),(0,r.jsx)("span",{className:"font-mono text-[10px] uppercase tracking-wider text-muted-foreground",children:"ms total"}),null!==t&&(0,r.jsxs)("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground/70",children:["avg ",t,"ms"]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(eb,{label:"stt→llm",ms:e.stt_to_llm_ms,total:e.total_ms,color:h}),(0,r.jsx)(eb,{label:"llm→tts",ms:e.llm_to_tts_ms,total:e.total_ms,color:g})]})]},"expanded"):(0,r.jsxs)(u.P.button,{type:"button",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:()=>s(!0),className:"flex items-center gap-1.5 px-3 py-1.5","aria-label":"Show response latency",children:[(0,r.jsx)(eh.C,{weight:"fill",className:(0,p.cn)("h-3 w-3",x.color)}),(0,r.jsxs)("span",{className:(0,p.cn)("font-mono text-[11px] font-bold tabular-nums",x.color),children:[e.total_ms,"ms"]})]},"collapsed")}),(0,r.jsx)(ef,{latest:e,color:x.bar})]})})}function ef(e){let{latest:t,color:a}=e,[s,l]=n.useState(0),o=n.useRef(0);return n.useEffect(()=>{t.ts!==o.current&&(o.current=t.ts,l(e=>e+1))},[t]),(0,r.jsx)(m.N,{children:(0,r.jsx)(u.P.span,{"aria-hidden":!0,className:(0,p.cn)("pointer-events-none absolute inset-0 rounded-2xl border-2",a,"border-current opacity-60"),initial:{opacity:.7,scale:1},animate:{opacity:0,scale:1.1},exit:{opacity:0},transition:{duration:.9,ease:"easeOut"}},s)})}var ew=a(8717);function ey(e){let{className:t}=e,{settings:a,activeCharacter:s,setActiveCharacterId:l,loading:o}=(0,eu.t)(),[i,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)(null);if((0,n.useEffect)(()=>{let e=!1;return fetch("/api/device-character").then(e=>e.json()).then(t=>{e||"string"!=typeof t.character_id||u(t.character_id)}).catch(()=>void 0),()=>{e=!0}},[]),o||!s)return null;let m=async e=>{if(!(await fetch("/api/device-character",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({character_id:e})})).ok)throw Error("Failed to bind character to this device");u(e),await l(e),window.dispatchEvent(new Event("robovoice:identity-changed"))};return(0,r.jsx)("div",{className:(0,p.cn)("relative z-20",t),children:(0,r.jsxs)("div",{className:"relative flex items-center gap-2 glass gradient-border rounded-full pl-3 pr-8 py-1.5 hover:bg-white/[0.06] transition-all cursor-pointer group pointer-events-auto",children:[(0,r.jsx)(ew.G,{className:"w-5 h-5 text-blue-300 drop-shadow-[0_0_6px_rgba(96,165,250,0.5)]",weight:"fill"}),(0,r.jsx)("select",{value:c||s.id,onChange:e=>void m(e.target.value),className:"relative z-10 bg-transparent border-none text-sm font-medium focus:ring-0 cursor-pointer appearance-none py-0 pl-1 outline-none text-foreground",title:"Switch Character",children:a.characters.map(e=>(0,r.jsx)("option",{value:e.id,className:"text-foreground bg-popover",children:e.name},e.id))}),(0,r.jsx)(X.a,{className:"w-3 h-3 text-blue-200/60 absolute right-3 pointer-events-none"})]})})}var ej=a(9416),e_=a(9371),eN=a(5e3),ek=a(36);let eC="robopark:last-automatic-camera-page-recovery",eS="robopark:automatic-camera-page-recovery-count",eT="robopark:microphone-processing";function eE(){let e=(0,d.aB)(),{settings:t}=(0,eu.t)(),[a,s]=(0,n.useState)("starting"),o=(0,n.useRef)(0);return((0,n.useEffect)(()=>{let a,r,n,i,d,c,u,m;if(!t.always_on_session_enabled||!e.isConnected||!e.room)return;let p=!1,x=!1,h=0,g=[],b=0,v=!1,f=!1,w=!1,y=!1,j=0,_=0,N=!1,k=-1,C=0,S=0,T=e.room,E="robopark:last-motion-greeting:".concat(T.name),P=Number(window.localStorage.getItem(E)||0);o.current=Math.max(o.current,P);let I=e=>{var t;let a=e.detail||{};window.localStorage.setItem(eT,JSON.stringify(a));let r=Math.max(0,Math.min(2,Number(null!=(t=a.mic_gain_percent)?t:100)/100));(async()=>{var e,t,n,o;if(0===r){await T.localParticipant.setMicrophoneEnabled(!1),s("microphone muted");return}let i=null==(t=Array.from(T.localParticipant.audioTrackPublications.values()).find(e=>e.source===l.CC.Source.Microphone))||null==(e=t.track)?void 0:e.mediaStreamTrack;if(!i||"live"!==i.readyState){let e=window.localStorage.getItem("robopark:media-device:audioinput")||void 0;await T.localParticipant.setMicrophoneEnabled(!0,e?{deviceId:e}:void 0),i=null==(o=Array.from(T.localParticipant.audioTrackPublications.values()).find(e=>e.source===l.CC.Source.Microphone))||null==(n=o.track)?void 0:n.mediaStreamTrack}i&&await i.applyConstraints({echoCancellation:!1!==a.echo_cancellation,noiseSuppression:!1!==a.noise_suppression,autoGainControl:!0===a.auto_gain_control,volume:r})})().catch(e=>console.warn("[AlwaysOn] microphone processing update failed:",e))};window.addEventListener("robopark:microphone-processing",I);let A=()=>{a&&clearInterval(a),a=void 0,d&&(d.pause(),d.srcObject=null,d=void 0)},O=()=>{n&&clearInterval(n),n=void 0,h=0,i&&i.close().catch(()=>void 0),i=void 0,f=!1},L=async e=>{if(!p&&!x){x=!0,console.warn("[AlwaysOn] Recreating stale microphone track: ".concat(e)),s("microphone reconnecting"),O();try{await T.localParticipant.setMicrophoneEnabled(!1),await new Promise(e=>window.setTimeout(e,350)),g.length>1&&(b=(b+1)%g.length);let e=g[b];await T.localParticipant.setMicrophoneEnabled(!0,e?{deviceId:e}:void 0),x=!1,p||await u()}catch(e){console.error("[AlwaysOn] Microphone recovery failed:",e),p||window.setTimeout(()=>void L("retry"),3e3)}finally{x=!1}}};u=async()=>{var e;O();let t=Array.from(T.localParticipant.audioTrackPublications.values()).find(e=>e.source===l.CC.Source.Microphone),a=null==t||null==(e=t.track)?void 0:e.mediaStreamTrack;if(!a||"ended"===a.readyState)return void await L("track unavailable");a.addEventListener("ended",()=>void L("track ended"),{once:!0}),a.addEventListener("mute",()=>void L("source muted"),{once:!0});let s=a.getSettings().deviceId;if(s){let e=g.indexOf(s);e>=0&&(b=e)}let r=(i=new AudioContext).createMediaStreamSource(new MediaStream([a])),o=i.createAnalyser();o.fftSize=512,r.connect(o);let d=new Uint8Array(o.fftSize);i.resume().catch(()=>void 0),f=!1,n=setInterval(()=>{if(p||x||(null==i?void 0:i.state)!=="running")return;o.getByteTimeDomainData(d);let e=0;for(let t of d)e=Math.max(e,Math.abs(t-128));e<=1?h+=1:(h=0,f=!0),h>=12&&L("sustained digital silence")},500)};let M=async()=>{var e;let t=Array.from(T.localParticipant.audioTrackPublications.values()).find(e=>e.source===l.CC.Source.Microphone),a=null==t||null==(e=t.track)?void 0:e.mediaStreamTrack;t&&!t.isMuted&&a&&!a.muted&&a.enabled&&"live"===a.readyState&&f||await L("pre-greeting validation");let s=Date.now();for(;!p&&!f&&Date.now()-s<4e3;)await new Promise(e=>window.setTimeout(e,100));return f},z=async()=>{w=!0,f||M(),y=!0,j=Date.now(),o.current=Date.now(),window.localStorage.setItem(E,String(o.current)),s("motion detected");let e=new AbortController,a=window.setTimeout(()=>e.abort(),5e3);try{let a=await fetch("/api/wake",{method:"POST",headers:{"Content-Type":"application/json"},signal:e.signal,body:JSON.stringify({room_name:T.name,greeting:function(e){let t=e;for(let e=0;e<3&&/[ÃÂ×]/.test(t);e+=1)try{let e=Uint8Array.from(Array.from(t),e=>255&e.charCodeAt(0)),a=new TextDecoder("utf-8",{fatal:!0}).decode(e);if(!a||a===t)break;t=a}catch(e){break}return t}(t.motion_greeting||"שלום! איך אפשר לעזור?")})});if(!a.ok)throw Error(await a.text());s("conversation active")}catch(e){console.error("[AlwaysOn] Failed to trigger greeting:",e),y=!1,s("greeting retry armed")}finally{window.clearTimeout(a),w=!1}},R=async e=>{let t,a;try{t=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e},echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1},video:!1}),a=new AudioContext,await a.resume().catch(()=>void 0);let s=a.createMediaStreamSource(t),r=a.createAnalyser();r.fftSize=512,s.connect(r);let n=new Uint8Array(r.fftSize),l=0,o=0;for(let e=0;e<8;e+=1){await new Promise(e=>window.setTimeout(e,75)),r.getByteTimeDomainData(n);let e=0;for(let t of n){let a=t-128;l=Math.max(l,Math.abs(a)),e+=a*a}o+=e/n.length}return l<=1?0:Math.sqrt(o/8)}catch(t){return console.warn("[AlwaysOn] Microphone activity probe failed:",e,t),0}finally{null==t||t.getTracks().forEach(e=>e.stop()),a&&await a.close().catch(()=>void 0)}},D=()=>{if(p||r)return;S+=1,A(),s("camera reconnecting");let e=Number(window.localStorage.getItem(eC)||0);if(S>=5&&Date.now()-e>=3e5){window.localStorage.setItem(eC,String(Date.now()));let e=Number(window.localStorage.getItem(eS)||0)+1;window.localStorage.setItem(eS,String(e)),s("camera self-healing");let t=new URLSearchParams(window.location.search).get("device_id")||"";(e>=2&&t?fetch("/api/robopark/devices/".concat(encodeURIComponent(t),"/control"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"kill-media-competitors"})}):fetch("/api/kiosk-diagnostic",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_id:t,stage:"camera_self_heal",status:"reloading",detail:"failures=".concat(S,";cycle=").concat(e)})})).catch(()=>void 0).finally(()=>{if(!p){let e=new URL(window.location.href);e.searchParams.set("_camera_recovery",String(Date.now())),window.location.replace(e.toString())}});return}r=setTimeout(()=>{r=void 0,m()},3e3)},q=()=>{p||(s("camera recovery requested"),r&&clearTimeout(r),r=void 0,A(),T.localParticipant.setCameraEnabled(!1).catch(()=>void 0).finally(()=>{p||(r=setTimeout(()=>{r=void 0,m()},900))}))};return window.addEventListener("robopark:recover-camera",q),(m=async()=>{try{var e,r,n,i,m,x,h,b;A(),c=void 0,k=-1,C=0,s("requesting camera");let f=(await navigator.mediaDevices.enumerateDevices()).filter(e=>"audioinput"===e.kind&&e.deviceId),E=window.localStorage.getItem("robopark:media-device:audioinput"),P=f.map(e=>({device:e,score:(e=>{let t=e.label.toLowerCase(),a=0;return/usb|microphone|\bmic\b|webcam|camera/.test(t)&&(a+=20),/analog|built-in/.test(t)&&(a+=5),/monitor|loopback|hdmi|output/.test(t)&&(a-=50),"default"===e.deviceId&&(a-=2),a})(e)})).sort((e,t)=>t.score-e.score),I=P.filter(e=>{let{device:t}=e;return"default"!==t.deviceId});g=(I.length>0?I:P).filter(e=>{let{score:t}=e;return t>-20}).map(e=>{let{device:t}=e;return t.deviceId});let O=P.find(e=>{let{device:t}=e;return t.deviceId===E});if(E&&O&&O.score>-20&&g.includes(E)&&(g=[E,...g.filter(e=>e!==E)]),!v&&g.length>0){s("testing microphones"),await T.localParticipant.setMicrophoneEnabled(!1);let e=[];for(let[t,a]of g.entries())e.push({deviceId:a,index:t,level:await R(a)});e.sort((e,t)=>t.level-e.level||e.index-t.index);let t=e.filter(e=>{let{level:t}=e;return t>0});g=(t.length>0?t:e).map(e=>{let{deviceId:t}=e;return t}),v=!0;let a=g[0];t.length>0&&a&&window.localStorage.setItem("robopark:media-device:audioinput",a)}let L=g[0],M={};try{M=JSON.parse(window.localStorage.getItem(eT)||"{}")}catch(e){}let q=Math.max(0,Math.min(200,Number(null!=(b=M.mic_gain_percent)?b:100))),F=null==(r=Array.from(T.localParticipant.audioTrackPublications.values()).find(e=>e.source===l.CC.Source.Microphone))||null==(e=r.track)?void 0:e.mediaStreamTrack;0===q?(await T.localParticipant.setMicrophoneEnabled(!1),s("microphone muted")):(!F||"live"!==F.readyState||F.muted||L&&F.getSettings().deviceId!==L)&&(await T.localParticipant.setMicrophoneEnabled(!1),await T.localParticipant.setMicrophoneEnabled(!0,L?{deviceId:L}:void 0));let U=null==(i=Array.from(T.localParticipant.audioTrackPublications.values()).find(e=>e.source===l.CC.Source.Microphone))||null==(n=i.track)?void 0:n.mediaStreamTrack;q>0&&U&&(await U.applyConstraints({echoCancellation:!1!==M.echo_cancellation,noiseSuppression:!1!==M.noise_suppression,autoGainControl:!0===M.auto_gain_control,volume:q/100}).catch(()=>void 0),await u());let V=window.localStorage.getItem("robopark:media-device:videoinput"),W=(await navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind&&e.deviceId);if(0===W.length)throw Error("No camera device is currently enumerated");let H=W.some(e=>e.deviceId===V)?V||void 0:null==(m=W[0])?void 0:m.deviceId;if(await T.localParticipant.setCameraEnabled(!1).catch(()=>void 0),await new Promise(e=>window.setTimeout(e,700)),p||(await T.localParticipant.setCameraEnabled(!0,H?{deviceId:H}:void 0),p))return;let G=Array.from(T.localParticipant.videoTrackPublications.values()).find(e=>e.source===l.CC.Source.Camera);(null==G||null==(x=G.track)?void 0:x.mediaStreamTrack.readyState)==="ended"&&(await T.localParticipant.setCameraEnabled(!1),await T.localParticipant.setCameraEnabled(!0,H?{deviceId:H}:void 0),G=Array.from(T.localParticipant.videoTrackPublications.values()).find(e=>e.source===l.CC.Source.Camera));let B=null==G||null==(h=G.track)?void 0:h.mediaStreamTrack;if(!B||"ended"===B.readyState)throw Error("Camera track unavailable");B.addEventListener("ended",D,{once:!0}),(d=document.createElement("video")).muted=!0,d.playsInline=!0,d.srcObject=new MediaStream([B]),await d.play();let J=document.createElement("canvas");J.width=64,J.height=48;let K=J.getContext("2d",{willReadFrequently:!0,alpha:!1});if(!K)throw Error("Canvas motion detector unavailable");s("armed"),S=0,window.localStorage.removeItem(eS),a=setInterval(()=>{if(!p&&!N&&d&&!(d.readyState<HTMLMediaElement.HAVE_CURRENT_DATA)){N=!0;try{if(.001>Math.abs(d.currentTime-k)?C+=1:(C=0,k=d.currentTime),C>=32){console.warn("[AlwaysOn] Camera frames stopped advancing; recreating track"),D();return}K.drawImage(d,0,0,64,48);let e=K.getImageData(0,0,64,48).data;if(c){let a=0;for(let t=0;t<e.length;t+=4)(Math.abs(e[t]-c[t])+Math.abs(e[t+1]-c[t+1])+Math.abs(e[t+2]-c[t+2]))/3>22&&(a+=1);let r=a/3072,n=t.motion_threshold||.06,l=Math.max(1e4,1e3*Math.max(5,t.motion_cooldown_seconds||10)),i=Date.now()-o.current>=l;y&&Date.now()-j>=15e3&&(y=!1,_=0,s("armed")),r<.35*n?(_+=1)>=8&&(y=!1,s("armed")):_=0,r>=n&&i&&!y&&!w?z():!i||y||w||s("armed")}c=new Uint8ClampedArray(e)}finally{N=!1}}},250)}catch(e){console.error("[AlwaysOn] Camera monitor failed; retrying:",e),D()}})(),()=>{p=!0,r&&clearTimeout(r),A(),O(),window.removeEventListener("robopark:recover-camera",q),window.removeEventListener("robopark:microphone-processing",I)}},[e.isConnected,e.room,t.always_on_session_enabled,t.motion_cooldown_seconds,t.motion_greeting,t.motion_threshold]),t.always_on_session_enabled)?(0,r.jsxs)("div",{className:"fixed left-1/2 top-9 z-[70] -translate-x-1/2 rounded-full border border-emerald-400/20 bg-black/70 px-3 py-1 text-[10px] font-mono uppercase tracking-wider text-emerald-300",children:["Always on \xb7 ",a]}):null}let eP=u.P.create("div");function eI(e){let{conversationFullscreen:t,onToggleConversationFullscreen:a}=e,s=(0,d.aB)(),{settings:n,updateSettings:l}=(0,eu.t)(),o=async()=>{await l({...n,always_on_session_enabled:!1}),await s.end()};return(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-50 flex items-center justify-between px-4 py-1.5 bg-black/60 border-b border-primary/10 backdrop-blur-md",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[10px] font-mono text-primary/70",children:[(0,r.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-400 shadow-[0_0_4px_rgba(74,222,128,0.6)]"}),(0,r.jsx)("span",{children:"CONNECTED"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[10px] font-mono text-muted-foreground/50",children:[(0,r.jsxs)("button",{type:"button",onClick:a,"aria-pressed":t,className:(0,p.cn)("flex items-center gap-1.5 rounded-full border px-3 py-1 font-semibold transition-colors",t?"border-primary/50 bg-primary/20 text-primary":"border-primary/30 bg-primary/10 text-primary/90 hover:bg-primary/20"),title:t?"Exit fullscreen conversation":"Open fullscreen conversation",children:[t?(0,r.jsx)(ej.O,{size:12}):(0,r.jsx)(e_.j,{size:12}),(0,r.jsx)("span",{children:t?"EXIT CONVERSATION":"FULLSCREEN CONVERSATION"})]}),n.always_on_session_enabled&&(0,r.jsx)("button",{type:"button",onClick:()=>void o(),className:"rounded-full border border-emerald-400/30 bg-emerald-400/10 px-2.5 py-1 text-emerald-300 hover:bg-red-400/10 hover:text-red-300",title:"Turn off Always On and end this session",children:"ALWAYS ON \xb7 TURN OFF"}),(0,r.jsx)(eN.Q,{size:10}),(0,r.jsx)("span",{children:"LIVE"})]})]})}function eA(e){let{isExpanded:t,onToggle:a,messageCount:s}=e;return(0,r.jsxs)("button",{onClick:a,className:"flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono text-muted-foreground/60 hover:text-primary/80 transition-colors",children:[(0,r.jsx)(ek.l,{size:14}),(0,r.jsxs)("span",{children:[s," messages"]}),t?(0,r.jsx)(X.a,{size:10}):(0,r.jsx)(Y.Z,{size:10})]})}let eO={variants:{visible:{opacity:1,translateY:"0%"},hidden:{opacity:0,translateY:"100%"}},initial:"hidden",animate:"visible",exit:"hidden",transition:{duration:.3,delay:.3}};var eL=a(2923),eM=a(3701),ez=a(1886),eR=a(4009),eD=a(1092),eq=a(4162),eF=a(2861),eU=a(6955),eV=a(1096),eW=a(4053),eH=a(2613);let eG={llm:{label:"LLM",icon:ez.j,color:"#60a5fa"},stt:{label:"STT",icon:eR.t,color:"#3b82f6"},tts:{label:"TTS",icon:eD.o,color:"#93c5fd"}},eB={ready:{label:"Ready",className:"text-blue-300",dotClass:"bg-blue-300 shadow-[0_0_6px_rgba(147,197,253,0.7)]"},loading:{label:"Loading...",className:"text-sky-300",dotClass:"bg-sky-300 animate-pulse shadow-[0_0_6px_rgba(125,211,252,0.7)]"},idle:{label:"Not loaded",className:"text-zinc-500",dotClass:"bg-zinc-500"},error:{label:"Error",className:"text-red-400",dotClass:"bg-red-400 shadow-[0_0_6px_rgba(248,113,113,0.6)]"},unavailable:{label:"Offline",className:"text-red-500",dotClass:"bg-red-500"}};function eJ(e){let{svc:t,onPreload:a,isPreloading:s}=e,n=eG[t.service]||{label:t.service,icon:ez.j,color:"#888"},l=eB[t.status]||eB.idle,o=n.icon,i="idle"===t.status||"error"===t.status||"unavailable"===t.status,d="groq"===t.provider||"elevenlabs"===t.provider;return(0,r.jsxs)("div",{className:"relative group flex flex-col gap-2 rounded-xl glass gradient-border px-4 py-3 transition-all hover:bg-white/[0.05]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg",style:{backgroundColor:"".concat(n.color,"15")},children:(0,r.jsx)(o,{className:"h-4 w-4",style:{color:n.color},weight:"bold"})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-white/90",children:n.label}),(0,r.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wider text-white/30",children:t.provider})]}),(0,r.jsx)("p",{className:"text-xs text-white/40 truncate max-w-[180px]",title:t.model,children:t.model})]})]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:"loading"===t.status||s?(0,r.jsx)(eq.N,{className:"h-4 w-4 text-sky-300 animate-spin"}):"ready"===t.status?(0,r.jsx)(eF.r,{className:"h-4 w-4 text-blue-300",weight:"fill"}):"error"===t.status||"unavailable"===t.status?(0,r.jsx)(eU.t,{className:"h-4 w-4 text-red-400",weight:"fill"}):(0,r.jsx)("div",{className:"h-2.5 w-2.5 rounded-full ".concat(l.dotClass)})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("div",{className:"h-1.5 w-1.5 rounded-full ".concat(l.dotClass)}),(0,r.jsx)("span",{className:"text-[11px] font-medium ".concat(l.className),children:s?"Loading...":l.label})]}),i&&!d&&!s&&(0,r.jsxs)("button",{onClick:()=>a(t.service),className:"flex items-center gap-1 rounded-md bg-white/[0.06] px-2 py-0.5 text-[11px] font-medium text-white/60 transition-all hover:bg-white/[0.12] hover:text-white/90 active:scale-95",children:[(0,r.jsx)(eV.p,{className:"h-3 w-3"}),"Load"]}),d&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-white/25",children:[(0,r.jsx)(eW.l,{className:"h-3 w-3",weight:"fill"}),"Cloud"]})]}),t.error&&"ready"!==t.status&&(0,r.jsx)("p",{className:"text-[10px] text-red-400/70 truncate",title:t.error,children:t.error}),("loading"===t.status||s)&&(0,r.jsx)("div",{className:"absolute inset-0 rounded-xl overflow-hidden pointer-events-none",children:(0,r.jsx)("div",{className:"absolute inset-x-0 bottom-0 h-[2px] bg-gradient-to-r from-transparent via-sky-300/70 to-transparent animate-shimmer"})})]})}function eK(){let[e,t]=(0,n.useState)([]),[a,s]=(0,n.useState)(!0),[l,o]=(0,n.useState)(null),[i,d]=(0,n.useState)(new Set),c=(0,n.useRef)(null),u=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/model-status",{cache:"no-store"});if(!e.ok)throw Error("HTTP ".concat(e.status));let a=await e.json();t(a.services||[]),o(a.error||null),d(e=>{let t=new Set(e);for(let e of a.services||[])("ready"===e.status||"error"===e.status)&&t.delete(e.service);return t})}catch(e){o(e instanceof Error?e.message:"Failed to fetch")}finally{s(!1)}},[]),m=(0,n.useCallback)(async e=>{d(t=>new Set(t).add(e));try{await fetch("/api/model-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({service:e})})}catch(e){}},[]),p=(0,n.useCallback)(()=>{s(!0),u()},[u]);(0,n.useEffect)(()=>(u(),c.current&&clearInterval(c.current),c.current=setInterval(u,i.size>0?3e3:1e4),()=>{c.current&&clearInterval(c.current)}),[u,i.size]),(0,n.useEffect)(()=>(c.current&&clearInterval(c.current),c.current=setInterval(u,i.size>0?3e3:1e4),()=>{c.current&&clearInterval(c.current)}),[i.size,u]);let x=e.length>0&&e.every(e=>"ready"===e.status);return a&&0===e.length?(0,r.jsx)("div",{className:"w-full max-w-sm mx-auto mt-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-white/30 text-sm py-4",children:[(0,r.jsx)(eq.N,{className:"h-4 w-4 animate-spin"}),"Checking models..."]})}):(0,r.jsxs)("div",{className:"w-full max-w-sm mx-auto mt-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3 px-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-white/40",children:"Model Status"}),x&&(0,r.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-blue-400/10 border border-blue-400/20 px-2 py-0.5 text-[10px] font-medium text-blue-300",children:[(0,r.jsx)(eF.r,{className:"h-3 w-3",weight:"fill"}),"All Ready"]})]}),(0,r.jsx)("button",{onClick:p,className:"rounded-md p-1 text-white/30 transition-colors hover:text-white/60 hover:bg-white/[0.06]",title:"Refresh status",children:(0,r.jsx)(eH.S,{className:"h-3.5 w-3.5 ".concat(a?"animate-spin":"")})})]}),l&&(0,r.jsx)("div",{className:"mb-2 rounded-lg bg-red-500/10 border border-red-500/20 px-3 py-2 text-xs text-red-400",children:l}),(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>(0,r.jsx)(eJ,{svc:e,onPreload:m,isPreloading:i.has(e.service)},e.service))}),!x&&e.some(e=>"idle"===e.status||"error"===e.status)&&(0,r.jsx)("button",{onClick:()=>{e.filter(e=>"idle"===e.status||"error"===e.status||"unavailable"===e.status).filter(e=>"groq"!==e.provider&&"elevenlabs"!==e.provider).forEach(e=>m(e.service))},disabled:i.size>0,className:"mt-3 w-full rounded-lg bg-white/[0.06] py-2 text-xs font-medium text-white/60 transition-all hover:bg-white/[0.10] hover:text-white/80 disabled:opacity-40 disabled:cursor-not-allowed",children:i.size>0?(0,r.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)(eq.N,{className:"h-3.5 w-3.5 animate-spin"}),"Loading models..."]}):(0,r.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)(eV.p,{className:"h-3.5 w-3.5"}),"Load All Models"]})})]})}function eX(){return(0,r.jsxs)("div",{className:"relative mb-7",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-blue-500/30 blur-3xl rounded-full scale-150 animate-[pulse-glow_3s_ease-in-out_infinite]"}),(0,r.jsx)("div",{className:"absolute inset-0 bg-sky-300/20 blur-2xl rounded-full scale-125"}),(0,r.jsx)("div",{className:"relative size-20 sm:size-24 rounded-full glass-strong gradient-border gradient-border-strong flex items-center justify-center",children:(0,r.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"size-9 sm:size-11 drop-shadow-[0_0_14px_rgba(96,165,250,0.6)]",children:[(0,r.jsx)("defs",{children:(0,r.jsxs)("linearGradient",{id:"waveGrad",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[(0,r.jsx)("stop",{offset:"0%",stopColor:"#93c5fd"}),(0,r.jsx)("stop",{offset:"55%",stopColor:"#3b82f6"}),(0,r.jsx)("stop",{offset:"100%",stopColor:"#60a5fa"})]})}),(0,r.jsx)("path",{d:"M15 24V40C15 40.7957 14.6839 41.5587 14.1213 42.1213C13.5587 42.6839 12.7956 43 12 43C11.2044 43 10.4413 42.6839 9.87868 42.1213C9.31607 41.5587 9 40.7957 9 40V24C9 23.2044 9.31607 22.4413 9.87868 21.8787C10.4413 21.3161 11.2044 21 12 21C12.7956 21 13.5587 21.3161 14.1213 21.8787C14.6839 22.4413 15 23.2044 15 24ZM22 5C21.2044 5 20.4413 5.31607 19.8787 5.87868C19.3161 6.44129 19 7.20435 19 8V56C19 56.7957 19.3161 57.5587 19.8787 58.1213C20.4413 58.6839 21.2044 59 22 59C22.7956 59 23.5587 58.6839 24.1213 58.1213C24.6839 57.5587 25 56.7957 25 56V8C25 7.20435 24.6839 6.44129 24.1213 5.87868C23.5587 5.31607 22.7956 5 22 5ZM32 13C31.2044 13 30.4413 13.3161 29.8787 13.8787C29.3161 14.4413 29 15.2044 29 16V48C29 48.7957 29.3161 49.5587 29.8787 50.1213C30.4413 50.6839 31.2044 51 32 51C32.7956 51 33.5587 50.6839 34.1213 50.1213C34.6839 49.5587 35 48.7957 35 48V16C35 15.2044 34.6839 14.4413 34.1213 13.8787C33.5587 13.3161 32.7956 13 32 13ZM42 21C41.2043 21 40.4413 21.3161 39.8787 21.8787C39.3161 22.4413 39 23.2044 39 24V40C39 40.7957 39.3161 41.5587 39.8787 42.1213C40.4413 42.6839 41.2043 43 42 43C42.7957 43 43.5587 42.6839 44.1213 42.1213C44.6839 41.5587 45 40.7957 45 40V24C45 23.2044 44.6839 22.4413 44.1213 21.8787C43.5587 21.3161 42.7957 21 42 21ZM52 17C51.2043 17 50.4413 17.3161 49.8787 17.8787C49.3161 18.4413 49 19.2044 49 20V44C49 44.7957 49.3161 45.5587 49.8787 46.1213C50.4413 46.6839 51.2043 47 52 47C52.7957 47 53.5587 46.6839 54.1213 46.1213C54.6839 45.5587 55 44.7957 55 44V20C55 19.2044 54.6839 18.4413 54.1213 17.8787C53.5587 17.3161 52.7957 17 52 17Z",fill:"url(#waveGrad)"})]})})]})}function eZ(){return(0,r.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full glass border border-blue-400/15 px-3 py-1 text-[10px] font-mono uppercase tracking-[0.18em] text-blue-200/80 mb-5",children:[(0,r.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,r.jsx)("span",{className:"absolute inset-0 rounded-full bg-blue-400 animate-ping opacity-75"}),(0,r.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-blue-300"})]}),"System Online"]})}var eY=a(7650),e$=a(3086),eQ=a(5700),e0=a(54),e1=a(3991),e2=a(1095),e5=a(3289),e3=a(2320),e4=a(5660),e8=a(9064);let e6=[{id:"character",label:"Character"},{id:"providers",label:"Providers"},{id:"llm",label:"LLM Parameters"},{id:"vision",label:"Vision"}];function e9(e){var t,a,s,l,o,i,d,c,u,m,p;let{isOpen:x,onClose:h}=e,{settings:g,updateSettings:b}=(0,eu.t)(),[v,f]=(0,n.useState)("character"),[w,y]=(0,n.useState)(e8.a);(0,n.useEffect)(()=>{x&&y(g)},[x,g]);let[j,_]=(0,n.useState)([]),[N,k]=(0,n.useState)([]),[C,S]=(0,n.useState)([]),[T,E]=(0,n.useState)([]),[P,I]=(0,n.useState)(!1),[A,O]=(0,n.useState)(!1),[L,M]=(0,n.useState)(""),[z,R]=(0,n.useState)(null),[D,q]=(0,n.useState)(!1),[F,U]=(0,n.useState)(""),[V,W]=(0,n.useState)(""),[H,G]=(0,n.useState)(""),J=(0,n.useRef)(null),K=w.characters.find(e=>e.id===w.active_character_id)||w.characters[0]||e8.o;(0,n.useEffect)(()=>{x&&(async()=>{try{let e=K.tts_provider||"kokoro",t="/api/voices?provider=".concat(e);"elevenlabs"===e&&w.elevenlabs_api_key&&(t+="&api_key=".concat(encodeURIComponent(w.elevenlabs_api_key)));let[a,s]=await Promise.all([fetch(t),fetch("/api/wake-word/models")]);if(a.ok){let e=((await a.json()).voices||[]).map(e=>"string"==typeof e?{id:e,name:e}:e),t=K.tts_voice_elevenlabs;t&&!e.find(e=>e.id===t)&&(e=[...e,{id:t,name:"".concat(t," (Saved)")}]),_(e)}if(s.ok){let e=await s.json();k(e.models||[])}}catch(e){console.error("Failed to fetch dependencies",e)}})()},[x,K.tts_provider,w.elevenlabs_api_key]);let[X,Y]=(0,n.useState)({status:"idle",error:null}),[$,Q]=(0,n.useState)({status:"idle",error:null}),[ee,et]=(0,n.useState)({status:"idle",error:null,info:null}),[ea,es]=(0,n.useState)({status:"idle",error:null,info:null}),er=(0,n.useCallback)(async()=>{if(w.ollama_host){Y({status:"testing",error:null});try{let t=await fetch("/api/setup/test-ollama",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:w.ollama_host})}),a=await t.json();if(a.success){var e;Y({status:"success",error:null}),S(a.models||[]),!w.ollama_model&&(null==(e=a.models)?void 0:e.length)>0&&y(e=>({...e,ollama_model:a.models[0]}))}else Y({status:"error",error:a.error||"Connection failed"})}catch(e){Y({status:"error",error:"Failed to connect"})}}},[w.ollama_host,w.ollama_model]),en=(0,n.useCallback)(async()=>{if(w.groq_api_key){Q({status:"testing",error:null});try{let t=await fetch("/api/setup/test-groq",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:w.groq_api_key})}),a=await t.json();if(a.success){var e;if(Q({status:"success",error:null}),E(a.models||[]),!w.groq_model&&(null==(e=a.models)?void 0:e.length)>0){let e="llama-3.3-70b-versatile",t=a.models.includes(e)?e:a.models[0];y(e=>({...e,groq_model:t}))}}else Q({status:"error",error:a.error||"Invalid API key"})}catch(e){Q({status:"error",error:"Failed to validate"})}}},[w.groq_api_key,w.groq_model]);(0,n.useEffect)(()=>{x&&w.groq_api_key&&0===T.length&&!P&&en()},[x,w.groq_api_key,T.length,P,en]),(0,n.useEffect)(()=>{x&&w.ollama_host&&0===C.length&&!P&&er()},[x,w.ollama_host,C.length,P,er]);let el=async()=>{if(!F.trim())return void alert("Please enter a name for the wake word");I(!0);let e=new FormData;e.append("custom_name",F.trim());try{let t=await fetch("/api/wake-word/upload",{method:"POST",body:e});if(t.ok){let e=await t.json();k(e.models||[]);let a=F.trim().toLowerCase().replace(/[^a-z0-9]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,""),s="models/".concat(a,".onnx");e.models.includes(s)&&ex({wake_word_model:s}),q(!1),U("")}else{let e=await t.json();alert(e.detail||"Failed to add wake word")}}catch(e){console.error("Error uploading wake word model",e),alert("Error uploading model")}finally{I(!1)}},ei=(0,n.useCallback)(async()=>{if(w.hass_host&&w.hass_token){et({status:"testing",error:null,info:null});try{let e=await fetch("/api/setup/test-hass",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:w.hass_host,token:w.hass_token})}),t=await e.json();t.success?et({status:"success",error:null,info:"Connected - ".concat(t.device_count," entities")}):et({status:"error",error:t.error||"Connection failed",info:null})}catch(e){et({status:"error",error:"Failed to connect",info:null})}}},[w.hass_host,w.hass_token]),ed=(0,n.useCallback)(async()=>{if(!w.n8n_url||!w.n8n_token)return;es({status:"testing",error:null,info:null});let e=ep(w.n8n_url);try{let t=await fetch("/api/setup/test-n8n",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,token:w.n8n_token})}),a=await t.json();a.success?es({status:"success",error:null,info:"Connected"}):es({status:"error",error:a.error||"Connection failed",info:null})}catch(e){es({status:"error",error:"Failed to connect",info:null})}},[w.n8n_url,w.n8n_token]),ec=async()=>{O(!0),M("Saving..."),R(null);try{let e={...w,n8n_url:w.n8n_enabled?ep(w.n8n_url):w.n8n_url};await b(e);let t=e.characters.find(t=>t.id===e.active_character_id);t&&"piper"===t.tts_provider&&t.tts_voice_piper&&(M("Downloading voice model..."),await fetch("/api/download-piper-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model_id:t.tts_voice_piper})})),M("Saved!"),setTimeout(()=>{M(""),h()},1e3)}catch(e){console.error("Error saving settings:",e),R(e instanceof Error?e.message:"Failed to save")}finally{O(!1)}},em=async e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];if(e.target.value="",a){R(null);try{let e=await a.text(),t=JSON.parse(e);if(!t||"object"!=typeof t)throw Error("Config file is not a JSON object");if(!Array.isArray(t.characters)||0===t.characters.length)throw Error("Config file is missing a characters array");let s={...e8.a,...t};s.characters.find(e=>e.id===s.active_character_id)||(s.active_character_id=s.characters[0].id),y(s),M("Loaded — click Save to apply"),setTimeout(()=>M(""),2500)}catch(e){console.error("Error importing settings:",e),R(e instanceof Error?"Import failed: ".concat(e.message):"Import failed")}}},ep=e=>{if(!e)return"";let t=e.replace(/\/$/,"");return t.includes("/mcp-server")?t:"".concat(t,"/mcp-server/http")},ex=e=>{y(t=>{let a=t.characters.map(a=>a.id===t.active_character_id?{...a,...e}:a);return{...t,characters:a}})},eh=async e=>{if(e!==K.tts_provider){ex({tts_provider:e});try{let t="/api/voices?provider=".concat(e);"elevenlabs"===e&&w.elevenlabs_api_key&&(t+="&api_key=".concat(encodeURIComponent(w.elevenlabs_api_key)));let a=await fetch(t);if(a.ok){let e=((await a.json()).voices||[]).map(e=>"string"==typeof e?{id:e,name:e}:e);_(e)}}catch(e){console.error("Failed to fetch voices for provider:",e)}}},eg=async()=>{try{I(!0);let e=K.tts_provider,t="piper"===e?K.tts_voice_piper:"elevenlabs"===e?K.tts_voice_elevenlabs:K.tts_voice_kokoro,a=await fetch("/api/test-tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,voice_id:t,api_key:w.elevenlabs_api_key,text:H||"Hello there! This is a test of my voice.",speed:K.tts_speed||1})});if(!a.ok){let e=await a.json();throw Error(e.detail||"Test failed")}let s=await a.blob(),r=URL.createObjectURL(s);new Audio(r).play()}catch(e){console.error(e),alert("TTS Test Failed: "+(e instanceof Error?e.message:String(e)))}finally{I(!1)}},eb=e=>{let{status:t}=e;switch(t){case"testing":return(0,r.jsx)(eM.N,{className:"h-4 w-4 animate-spin text-blue-500"});case"success":return(0,r.jsx)(Z.J,{className:"h-4 w-4 text-purple-500",weight:"bold"});case"error":return(0,r.jsx)(e$.X,{className:"h-4 w-4 text-red-500",weight:"bold"});default:return null}},ev=e=>{let{enabled:t,onToggle:a,disabled:s=!1}=e;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,onClick:a,disabled:s,className:"relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ".concat(t?"bg-primary":"bg-muted"),children:(0,r.jsx)("span",{className:"pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ".concat(t?"translate-x-5":"translate-x-0")})})};return x?(0,eY.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/80 backdrop-blur-sm sm:p-4 font-mono",children:(0,r.jsxs)("div",{className:"bg-black/90 text-foreground border border-primary/30 shadow-[0_0_50px_rgba(160,32,240,0.15)] flex h-[95vh] sm:h-[85vh] w-full sm:max-w-4xl flex-col overflow-hidden sm:rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b px-4 sm:px-6 py-3 sm:py-4 shrink-0",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-bold",children:"Settings"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[L&&(0,r.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-purple-500 hidden sm:inline",children:L}),(0,r.jsx)("input",{ref:J,type:"file",accept:"application/json,.json",className:"hidden",onChange:em}),(0,r.jsx)("button",{type:"button",onClick:()=>{try{let e=new Blob([JSON.stringify(w,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a"),s=new Date().toISOString().replace(/[:.]/g,"-");a.href=t,a.download="caal-settings-".concat(s,".json"),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(t),M("Exported"),setTimeout(()=>M(""),1500)}catch(e){console.error("Error exporting settings:",e),R(e instanceof Error?e.message:"Failed to export")}},title:"Export config to JSON file",className:"hover:bg-muted rounded-full p-2 transition-colors",children:(0,r.jsx)(e2.z,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>{var e;null==(e=J.current)||e.click()},title:"Load config from JSON file",className:"hover:bg-muted rounded-full p-2 transition-colors",children:(0,r.jsx)(e5.C,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>{window.confirm("Reset all settings to defaults? This will replace every character and provider config in the editor. Nothing is saved until you click Save.")&&(y(e8.a),R(null),M("Reset — click Save to apply"),setTimeout(()=>M(""),2500))},title:"Reset to default config",className:"hover:bg-muted rounded-full p-2 transition-colors",children:(0,r.jsx)(e3.o,{className:"h-5 w-5"})}),(0,r.jsxs)(B,{size:"sm",disabled:A,onClick:ec,className:"gap-1.5 sm:gap-2 text-xs sm:text-sm px-2.5 sm:px-3",children:[(0,r.jsx)(e4.g,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:A?"Saving...":"Save Changes"}),(0,r.jsx)("span",{className:"sm:hidden",children:A?"...":"Save"})]}),(0,r.jsx)("button",{onClick:h,className:"hover:bg-muted rounded-full p-2 transition-colors",children:(0,r.jsx)(e$.X,{className:"h-5 w-5"})})]})]}),z&&(0,r.jsx)("div",{className:"bg-red-500/10 text-red-500 px-4 sm:px-6 py-2 text-sm text-center shrink-0",children:z}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row flex-1 overflow-hidden",children:[(0,r.jsx)("div",{className:"sm:hidden border-b shrink-0 overflow-x-auto",children:(0,r.jsx)("nav",{className:"flex px-2 py-1.5 gap-1 min-w-max",children:e6.map(e=>(0,r.jsx)("button",{onClick:()=>f(e.id),className:"whitespace-nowrap px-3 py-2 text-sm font-bold transition-all border-b-2 ".concat(v===e.id?"border-primary text-primary bg-primary/10":"border-transparent text-muted-foreground hover:text-foreground"),children:e.label},e.id))})}),(0,r.jsx)("div",{className:"hidden sm:block bg-muted/30 w-48 border-r p-4 shrink-0",children:(0,r.jsx)("nav",{className:"space-y-1",children:e6.map(e=>(0,r.jsx)("button",{onClick:()=>f(e.id),className:"w-full text-left px-3 py-2 text-sm font-bold transition-all border-l-2 ".concat(v===e.id?"border-primary text-primary bg-primary/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-white/5"),children:e.label},e.id))})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:P?(0,r.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,r.jsx)(eM.N,{className:"text-muted-foreground h-8 w-8 animate-spin"})}):(0,r.jsxs)(r.Fragment,{children:["character"===v&&(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-3 border-b pb-6",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Selected Character"}),(0,r.jsx)("select",{value:w.active_character_id,onChange:e=>{let t=e.target.value;y(e=>({...e,active_character_id:t}))},className:"border-input bg-background w-full rounded-lg border px-4 py-2 text-sm font-medium",children:w.characters.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{onClick:()=>{let e={...e8.o,id:crypto.randomUUID(),name:"New Character"};y(t=>({...t,characters:[...t.characters,e],active_character_id:e.id}))},className:"bg-primary text-primary-foreground hover:bg-primary/90 h-[38px] rounded-lg px-3 text-sm font-medium shadow transition-colors",title:"Create New Character",children:"New"}),(0,r.jsx)("button",{onClick:()=>{let e={...K,id:crypto.randomUUID(),name:"".concat(K.name," (Copy)")};y(t=>({...t,characters:[...t.characters,e],active_character_id:e.id}))},className:"bg-muted hover:bg-muted/80 h-[38px] rounded-lg px-3 text-sm font-medium transition-colors",title:"Duplicate Character",children:"Copy"}),(0,r.jsx)("button",{onClick:()=>{var e;return e=w.active_character_id,void(!(w.characters.length<=1)&&y(t=>{let a=t.characters.filter(t=>t.id!==e),s=t.active_character_id===e?a[0].id:t.active_character_id;return{...t,characters:a,active_character_id:s}}))},disabled:w.characters.length<=1,className:"bg-red-500/10 text-red-500 hover:bg-red-500/20 disabled:opacity-50 h-[38px] rounded-lg px-3 text-sm font-medium transition-colors",title:"Delete Character",children:"Delete"})]})]}),(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:gap-4 sm:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,r.jsx)("input",{type:"text",value:K.name,onChange:e=>ex({name:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",placeholder:"Agent Name"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Description"}),(0,r.jsx)("input",{type:"text",value:K.description,onChange:e=>ex({description:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",placeholder:"Brief description"})]})]}),(0,r.jsxs)("div",{className:"border-t pt-4",children:[(0,r.jsx)("h3",{className:"mb-4 text-sm font-semibold text-muted-foreground uppercase tracking-wider text-xs",children:"Voice Configuration"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"TTS Provider"}),(0,r.jsxs)("div",{className:"bg-muted inline-flex flex-wrap rounded-lg p-1 gap-0.5",children:[(0,r.jsxs)("button",{onClick:()=>eh("kokoro"),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("kokoro"===K.tts_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Kokoro"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Kokoro (High Quality, Slower)"})]}),(0,r.jsxs)("button",{onClick:()=>eh("piper"),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("piper"===K.tts_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Piper"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Piper (Fast, Lower Quality)"})]}),(0,r.jsx)("button",{onClick:()=>eh("elevenlabs"),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("elevenlabs"===K.tts_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:"ElevenLabs"})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{className:"text-sm font-medium",children:["Voice Model ","elevenlabs"===K.tts_provider&&"(Paste Voice ID)"]}),(0,r.jsx)("div",{className:"w-full",children:"elevenlabs"===K.tts_provider?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("select",{value:K.tts_voice_elevenlabs||"",onChange:e=>ex({tts_voice_elevenlabs:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"",disabled:!0,children:"Select a voice..."}),0===j.length&&(0,r.jsx)("option",{disabled:!0,children:"No voices found (Check API Key)"}),j.map((e,t)=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id||t))]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:V,onChange:e=>W(e.target.value),placeholder:"Enter Valid Voice ID (e.g. 21m00...)",className:"border-input bg-background flex-1 rounded-lg border px-3 py-2 text-sm"}),(0,r.jsx)("button",{onClick:()=>{if(!V.trim())return;let e=V.trim(),t=e.match(/[a-zA-Z0-9]{18,22}/);if(!(e=t?t[0]:e.replace(/[^a-zA-Z0-9_-]/g,"")))return;let a={id:e,name:"".concat(e," (Custom)")};_(e=>[...e,a]),ex({tts_voice_elevenlabs:a.id}),W("")},className:"bg-primary text-primary-foreground hover:bg-primary/90 h-[38px] rounded-lg px-3 text-sm font-medium shadow transition-colors",disabled:!V.trim(),children:"Add"})]}),(0,r.jsxs)("div",{className:"space-y-2 pt-2 border-t",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"ElevenLabs Model"}),(0,r.jsxs)("select",{value:w.elevenlabs_model_id||"eleven_v3",onChange:e=>y(t=>({...t,elevenlabs_model_id:e.target.value})),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"eleven_multilingual_v2",children:"Multilingual v2 (Legacy)"}),(0,r.jsx)("option",{value:"eleven_turbo_v2_5",children:"Turbo v2.5 (Fast, Multilingual)"}),(0,r.jsx)("option",{value:"eleven_v3",children:"Eleven v3 (Best, Alpha)"}),(0,r.jsx)("option",{value:"eleven_flash_v2_5",children:"Flash v2.5 (Fastest)"}),(0,r.jsx)("option",{value:"eleven_flash_v2",children:"Flash v2"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select 'Eleven v3' or 'Turbo v2.5' for Hebrew. v3 = best quality but higher latency."})]}),(0,r.jsxs)("div",{className:"space-y-2 pt-2 border-t",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Audio Quality"}),(0,r.jsxs)("select",{value:w.elevenlabs_encoding||"mp3_44100_128",onChange:e=>y(t=>({...t,elevenlabs_encoding:e.target.value})),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"mp3_44100_192",children:"Studio (44.1kHz 192kbps) — Best"}),(0,r.jsx)("option",{value:"mp3_44100_128",children:"High (44.1kHz 128kbps) — Recommended"}),(0,r.jsx)("option",{value:"mp3_44100_96",children:"Medium (44.1kHz 96kbps)"}),(0,r.jsx)("option",{value:"mp3_44100_64",children:"Low (44.1kHz 64kbps)"}),(0,r.jsx)("option",{value:"mp3_22050_32",children:"Minimal (22kHz 32kbps) — Fastest"}),(0,r.jsx)("option",{value:"pcm_24000",children:"PCM Raw (24kHz) — Lossless"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Higher quality = larger audio, slightly more latency. Default plugin was 22kHz/32kbps (Minimal)."})]}),(0,r.jsxs)("div",{className:"space-y-2 pt-2 border-t",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"TTS Language"}),(0,r.jsxs)("select",{value:w.elevenlabs_language||"",onChange:e=>y(t=>({...t,elevenlabs_language:e.target.value})),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"",children:"Auto-detect"}),(0,r.jsx)("option",{value:"heb",children:"Hebrew (עברית)"}),(0,r.jsx)("option",{value:"eng",children:"English"}),(0,r.jsx)("option",{value:"ara",children:"Arabic (العربية)"}),(0,r.jsx)("option",{value:"rus",children:"Russian (Русский)"}),(0,r.jsx)("option",{value:"fra",children:"French (Fran\xe7ais)"}),(0,r.jsx)("option",{value:"deu",children:"German (Deutsch)"}),(0,r.jsx)("option",{value:"spa",children:"Spanish (Espa\xf1ol)"}),(0,r.jsx)("option",{value:"jpn",children:"Japanese (日本語)"}),(0,r.jsx)("option",{value:"cmn",children:"Mandarin Chinese (中文)"}),(0,r.jsx)("option",{value:"kor",children:"Korean (한국어)"}),(0,r.jsx)("option",{value:"por",children:"Portuguese (Portugu\xeas)"}),(0,r.jsx)("option",{value:"ita",children:"Italian (Italiano)"}),(0,r.jsx)("option",{value:"tur",children:"Turkish (T\xfcrk\xe7e)"}),(0,r.jsx)("option",{value:"hin",children:"Hindi (हिन्दी)"}),(0,r.jsx)("option",{value:"pol",children:"Polish (Polski)"}),(0,r.jsx)("option",{value:"nld",children:"Dutch (Nederlands)"}),(0,r.jsx)("option",{value:"swe",children:"Swedish (Svenska)"}),(0,r.jsx)("option",{value:"ukr",children:"Ukrainian (Українська)"}),(0,r.jsx)("option",{value:"vie",children:"Vietnamese (Tiếng Việt)"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Set explicitly for best multilingual quality. Auto-detect can misidentify mixed-language text."})]}),(0,r.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Voice Settings"}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,r.jsx)("span",{children:"Stability"}),(0,r.jsx)("span",{children:null!=(a=w.elevenlabs_stability)?a:.5})]}),(0,r.jsx)("input",{type:"range",min:"0",max:"1",step:"0.05",value:null!=(s=w.elevenlabs_stability)?s:.5,onChange:e=>y(t=>({...t,elevenlabs_stability:parseFloat(e.target.value)})),className:"w-full accent-primary"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Lower = more expressive/variable. Higher = more consistent."})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,r.jsx)("span",{children:"Similarity Boost"}),(0,r.jsx)("span",{children:null!=(l=w.elevenlabs_similarity_boost)?l:.75})]}),(0,r.jsx)("input",{type:"range",min:"0",max:"1",step:"0.05",value:null!=(o=w.elevenlabs_similarity_boost)?o:.75,onChange:e=>y(t=>({...t,elevenlabs_similarity_boost:parseFloat(e.target.value)})),className:"w-full accent-primary"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"How closely to match the original voice. Higher = closer match."})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,r.jsx)("span",{children:"Style (Expressiveness)"}),(0,r.jsx)("span",{children:null!=(i=w.elevenlabs_style)?i:0})]}),(0,r.jsx)("input",{type:"range",min:"0",max:"1",step:"0.05",value:null!=(d=w.elevenlabs_style)?d:0,onChange:e=>y(t=>({...t,elevenlabs_style:parseFloat(e.target.value)})),className:"w-full accent-primary"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Amplifies voice style. Best with v3 model. Can increase latency."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",id:"elevenlabs_speaker_boost",checked:null==(c=w.elevenlabs_speaker_boost)||c,onChange:e=>y(t=>({...t,elevenlabs_speaker_boost:e.target.checked})),className:"accent-primary"}),(0,r.jsx)("label",{htmlFor:"elevenlabs_speaker_boost",className:"text-sm",children:"Speaker Boost (enhances clarity)"})]})]})]}):(0,r.jsx)("select",{value:"piper"===K.tts_provider?K.tts_voice_piper:K.tts_voice_kokoro,onChange:e=>{"piper"===K.tts_provider?ex({tts_voice_piper:e.target.value}):ex({tts_voice_kokoro:e.target.value})},className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:j.length>0?j.map((e,t)=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id||t)):(0,r.jsx)("option",{value:"piper"===K.tts_provider?K.tts_voice_piper:K.tts_voice_kokoro,children:"Loading or Default..."})})}),(0,r.jsxs)("div",{className:"flex gap-2 items-center pt-2 mt-2 border-t border-transparent",children:[(0,r.jsx)("input",{type:"text",value:H,onChange:e=>G(e.target.value),placeholder:"Text to speak...",className:"border-input bg-background rounded-lg border px-3 py-2 text-sm flex-1",title:"Text to speak"}),(0,r.jsxs)("button",{type:"button",onClick:eg,disabled:P,className:"bg-muted hover:bg-muted/80 text-foreground px-4 py-2 rounded-lg flex items-center gap-2 font-medium disabled:opacity-50 min-w-[100px] justify-center h-[38px]",title:"Test Voice",children:[P?(0,r.jsx)(eM.N,{className:"animate-spin w-4 h-4"}):(0,r.jsx)(eQ.o,{className:"w-4 h-4"}),"Test"]})]})]}),(0,r.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Audio Output Device"}),(0,r.jsx)(eo,{kind:"audiooutput",className:"w-full border-input bg-background rounded-lg border px-4 py-3 text-sm h-auto",onActiveDeviceChange:e=>console.log("Audio device changed to",e)})]})]})]}),(0,r.jsxs)("div",{className:"border-t pt-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider text-xs",children:"Wake Word"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Enabled"}),(0,r.jsx)(ev,{enabled:w.wake_word_enabled,onToggle:()=>y({...w,wake_word_enabled:!w.wake_word_enabled})})]})]}),w.wake_word_enabled&&(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),!D&&(0,r.jsxs)("button",{onClick:()=>q(!0),className:"text-xs text-primary flex items-center gap-1 hover:underline",children:[(0,r.jsx)(e0.F,{className:"w-3 h-3"}),"Add New"]})]}),D?(0,r.jsxs)("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3 border",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:'Phrase Name (e.g. "Hey Jarvis")'}),(0,r.jsx)("input",{type:"text",value:F,onChange:e=>U(e.target.value),className:"border-input bg-background w-full rounded px-3 py-2 text-sm",placeholder:"Hey Jarvis"}),(0,r.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"Must be a supported OpenWakeWord model name."})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,r.jsx)("button",{onClick:()=>{q(!1),U("")},className:"px-3 py-1.5 text-xs font-medium hover:bg-muted rounded",children:"Cancel"}),(0,r.jsxs)("button",{onClick:el,disabled:!F||P,className:"bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium rounded hover:bg-primary/90 disabled:opacity-50 flex items-center gap-1.5",children:[P&&(0,r.jsx)(eM.N,{className:"w-3 h-3 animate-spin"}),"Save & Use"]})]})]}):(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("select",{value:K.wake_word_model,onChange:e=>ex({wake_word_model:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm appearance-none",children:N.length>0?N.map(e=>(0,r.jsx)("option",{value:e,children:(null==e?void 0:e.replace("models/","").replace(".onnx","").replace(/_/g," "))||e},e)):(0,r.jsx)("option",{value:K.wake_word_model,children:(null==(t=K.wake_word_model)?void 0:t.replace("models/","").replace(".onnx",""))||"Unknown"})}),(0,r.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-4 text-muted-foreground",children:(0,r.jsx)("svg",{className:"h-4 w-4 fill-current",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]})]})}),(0,r.jsxs)("div",{className:"border-t pt-4 space-y-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider text-xs",children:"System Prompt"}),(0,r.jsx)("textarea",{value:K.system_prompt,onChange:e=>ex({system_prompt:e.target.value}),rows:12,className:"border-input bg-background w-full rounded-lg border px-4 py-3 font-mono text-sm leading-relaxed",placeholder:"You are a helpful assistant..."})]})]})]})]}),"providers"===v&&(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs font-bold tracking-wide uppercase",children:"STT Provider"}),(0,r.jsxs)("div",{className:"bg-muted inline-flex flex-wrap rounded-lg p-1 gap-0.5",children:[(0,r.jsxs)("button",{onClick:()=>y({...w,stt_provider:"speaches"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("speaches"===w.stt_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Speaches"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Speaches (Local)"})]}),(0,r.jsxs)("button",{onClick:()=>y({...w,stt_provider:"vibevoice"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("vibevoice"===w.stt_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"VibeVoice"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"VibeVoice (Local)"})]}),(0,r.jsxs)("button",{onClick:()=>y({...w,stt_provider:"groq"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("groq"===w.stt_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Groq"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Groq (Cloud)"})]})]}),"speaches"===w.stt_provider&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Whisper Model (Speaches / Local)"}),(0,r.jsxs)("select",{value:w.stt_model_speaches||"Systran/faster-whisper-small",onChange:e=>y({...w,stt_model_speaches:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsxs)("optgroup",{label:"Hebrew-tuned (ivrit-ai)",children:[(0,r.jsx)("option",{value:"ivrit-ai/whisper-large-v3-turbo-ct2",children:"ivrit-ai/whisper-large-v3-turbo-ct2 — best Hebrew, fast (~1.6GB VRAM)"}),(0,r.jsx)("option",{value:"ivrit-ai/whisper-large-v3-ct2",children:"ivrit-ai/whisper-large-v3-ct2 — best Hebrew accuracy (~3GB VRAM)"})]}),(0,r.jsxs)("optgroup",{label:"Multilingual",children:[(0,r.jsx)("option",{value:"deepdml/faster-whisper-large-v3-turbo-ct2",children:"deepdml/faster-whisper-large-v3-turbo-ct2 — fast multilingual (~1.6GB VRAM)"}),(0,r.jsx)("option",{value:"Systran/faster-whisper-large-v3",children:"Systran/faster-whisper-large-v3 — best multilingual (~3GB VRAM)"}),(0,r.jsx)("option",{value:"Systran/faster-whisper-medium",children:"Systran/faster-whisper-medium — balanced (~1.5GB VRAM)"}),(0,r.jsx)("option",{value:"Systran/faster-whisper-small",children:"Systran/faster-whisper-small — fast, English-leaning (~500MB)"}),(0,r.jsx)("option",{value:"Systran/faster-whisper-tiny",children:"Systran/faster-whisper-tiny — fastest, lowest accuracy"})]})]}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["For Hebrew, use the ",(0,r.jsx)("code",{children:"ivrit-ai"})," finetunes — significantly better than vanilla Whisper. Speaches downloads the model on first use."]})]}),"groq"===w.stt_provider&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Whisper Model (Groq / Cloud)"}),(0,r.jsxs)("select",{value:w.stt_model_groq||"whisper-large-v3-turbo",onChange:e=>y({...w,stt_model_groq:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"whisper-large-v3-turbo",children:"whisper-large-v3-turbo — fast, multilingual (recommended)"}),(0,r.jsx)("option",{value:"whisper-large-v3",children:"whisper-large-v3 — highest quality, slightly slower"}),(0,r.jsx)("option",{value:"distil-whisper-large-v3-en",children:"distil-whisper-large-v3-en — English only, fastest"})]}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["For Hebrew/Russian use ",(0,r.jsx)("code",{children:"whisper-large-v3-turbo"})," or ",(0,r.jsx)("code",{children:"whisper-large-v3"}),". Requires a Groq API key (set under LLM Provider → Groq)."]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Input Language"}),(0,r.jsxs)("select",{value:w.stt_language||"auto",onChange:e=>y({...w,stt_language:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"auto",children:"Auto-detect (Default)"}),(0,r.jsx)("option",{value:"en",children:"English (en)"}),(0,r.jsx)("option",{value:"he",children:"Hebrew (he)"}),(0,r.jsx)("option",{value:"ru",children:"Russian (ru)"}),(0,r.jsx)("option",{value:"es",children:"Spanish (es)"}),(0,r.jsx)("option",{value:"fr",children:"French (fr)"}),(0,r.jsx)("option",{value:"de",children:"German (de)"}),(0,r.jsx)("option",{value:"it",children:"Italian (it)"}),(0,r.jsx)("option",{value:"pt",children:"Portuguese (pt)"}),(0,r.jsx)("option",{value:"ar",children:"Arabic (ar)"}),(0,r.jsx)("option",{value:"zh",children:"Chinese (zh)"}),(0,r.jsx)("option",{value:"ja",children:"Japanese (ja)"}),(0,r.jsx)("option",{value:"ko",children:"Korean (ko)"})]}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:'Using "Auto-detect" works best for English. For other languages or accents, explicitly setting the language improves accuracy.'})]})]}),(0,r.jsx)("div",{className:"border-t border-border/50 my-6"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs font-bold tracking-wide uppercase",children:"LLM Provider"}),(0,r.jsxs)("div",{className:"bg-muted inline-flex flex-wrap rounded-lg p-1 gap-0.5",children:[(0,r.jsx)("button",{onClick:()=>y({...w,llm_provider:"ollama"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("ollama"===w.llm_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:"Ollama"}),(0,r.jsx)("button",{onClick:()=>y({...w,llm_provider:"groq"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("groq"===w.llm_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:"Groq"}),(0,r.jsx)("button",{onClick:()=>y({...w,llm_provider:"gemini"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("gemini"===w.llm_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:"Gemini"})]}),"ollama"===w.llm_provider?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Host URL"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:w.ollama_host,onChange:e=>y({...w,ollama_host:e.target.value}),placeholder:"http://localhost:11434",className:"border-input bg-background flex-1 rounded-lg border px-4 py-3 text-sm"}),(0,r.jsxs)("button",{onClick:er,disabled:!w.ollama_host||"testing"===X.status,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium disabled:opacity-50",children:[(0,r.jsx)(eb,{status:X.status}),"Test"]})]}),X.error&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:X.error}),"success"===X.status&&(0,r.jsxs)("p",{className:"text-xs text-purple-500",children:[C.length," models available"]})]}),(C.length>0||w.ollama_model)&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),(0,r.jsx)("select",{value:w.ollama_model,onChange:e=>y({...w,ollama_model:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:C.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("option",{value:"",children:"Select a model..."}),C.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}):(0,r.jsx)("option",{value:w.ollama_model,children:w.ollama_model})}),0===C.length&&w.ollama_model&&(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Test connection to see all available models"})]})]}):"gemini"===w.llm_provider?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"bg-blue-500/10 text-blue-500 rounded-lg p-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium",children:"Get your Gemini API Key"}),(0,r.jsxs)("a",{href:"https://aistudio.google.com/app/apikey",target:"_blank",rel:"noreferrer",className:"hover:underline flex items-center gap-1 mt-1",children:["Google AI Studio ",(0,r.jsx)(e1.B,{className:"w-3 h-3"})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"API Key"}),(0,r.jsx)("input",{type:"password",value:w.gemini_api_key,onChange:e=>y({...w,gemini_api_key:e.target.value}),placeholder:"AIza...",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),(0,r.jsxs)("select",{value:w.gemini_model||"gemini-1.5-flash",onChange:e=>y({...w,gemini_model:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsxs)("optgroup",{label:"Gemini 3 (Preview)",children:[(0,r.jsx)("option",{value:"gemini-3-pro-preview",children:"Gemini 3 Pro (Preview)"}),(0,r.jsx)("option",{value:"gemini-3-flash-preview",children:"Gemini 3 Flash (Preview)"})]}),(0,r.jsx)("optgroup",{label:"Gemini 2.5",children:(0,r.jsx)("option",{value:"gemini-2.5-flash",children:"Gemini 2.5 Flash — Enhanced Speed"})}),(0,r.jsxs)("optgroup",{label:"Gemini 1.5 (Stable)",children:[(0,r.jsx)("option",{value:"gemini-1.5-pro",children:"Gemini 1.5 Pro"}),(0,r.jsx)("option",{value:"gemini-1.5-flash",children:"Gemini 1.5 Flash"})]})]})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"API Key"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"password",value:w.groq_api_key,onChange:e=>y({...w,groq_api_key:e.target.value}),placeholder:"gsk_...",className:"border-input bg-background flex-1 rounded-lg border px-4 py-3 text-sm"}),(0,r.jsxs)("button",{onClick:en,disabled:!w.groq_api_key||"testing"===$.status,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium disabled:opacity-50",children:[(0,r.jsx)(eb,{status:$.status}),"Test"]})]}),$.error&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:$.error}),"success"===$.status&&(0,r.jsxs)("p",{className:"text-xs text-purple-500",children:[T.length," models available"]}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["Get your API key at"," ",(0,r.jsx)("a",{href:"https://console.groq.com/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"console.groq.com"})]})]}),(T.length>0||w.groq_model)&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),(0,r.jsx)("select",{value:w.groq_model,onChange:e=>y({...w,groq_model:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:T.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("option",{value:"",children:"Select a model..."}),[...T].sort().map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}):(0,r.jsx)("option",{value:w.groq_model,children:w.groq_model})}),0===T.length&&w.groq_model&&(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Enter API key and test to see all available models"})]})]}),(0,r.jsxs)("div",{className:"space-y-4 pt-4 border-t border-border/50",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs font-bold tracking-wide uppercase",children:"Services"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"ElevenLabs API Key"}),(0,r.jsx)("input",{type:"password",value:w.elevenlabs_api_key||"",onChange:e=>y({...w,elevenlabs_api_key:e.target.value}),placeholder:"xi_...",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]})]})]})]}),"llm"===v&&(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Temperature"}),(0,r.jsx)("span",{className:"text-muted-foreground text-sm",children:w.temperature})]}),(0,r.jsx)("input",{type:"range",min:"0",max:"2",step:"0.1",value:w.temperature,onChange:e=>y({...w,temperature:parseFloat(e.target.value)}),className:"bg-muted accent-primary h-2 w-full cursor-pointer appearance-none rounded-lg"}),(0,r.jsxs)("div",{className:"text-muted-foreground flex justify-between text-xs",children:[(0,r.jsx)("span",{children:"Precise"}),(0,r.jsx)("span",{children:"Creative"})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Context Size"}),(0,r.jsx)("input",{type:"number",min:"1024",max:"131072",step:"1024",value:w.num_ctx,onChange:e=>y({...w,num_ctx:parseInt(e.target.value)||8192}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Max Turns"}),(0,r.jsx)("input",{type:"number",min:"1",max:"100",value:w.max_turns,onChange:e=>y({...w,max_turns:parseInt(e.target.value)||20}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Tool Cache Size"}),(0,r.jsx)("input",{type:"number",min:"0",max:"10",value:w.tool_cache_size,onChange:e=>y({...w,tool_cache_size:parseInt(e.target.value)||3}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"border-t pt-6",children:[(0,r.jsx)("h3",{className:"mb-4 text-sm font-semibold",children:"Turn Detection"}),(0,r.jsx)("p",{className:"text-muted-foreground mb-4 text-xs",children:"Control how the agent detects when you're done speaking"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Allow Interruptions"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Interrupt the agent while speaking"})]}),(0,r.jsx)(ev,{enabled:w.allow_interruptions,onToggle:()=>y({...w,allow_interruptions:!w.allow_interruptions})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Endpointing Delay"}),(0,r.jsxs)("span",{className:"text-muted-foreground text-sm",children:[w.min_endpointing_delay,"s"]})]}),(0,r.jsx)("input",{type:"range",min:"0.1",max:"1.0",step:"0.1",value:w.min_endpointing_delay,onChange:e=>y({...w,min_endpointing_delay:parseFloat(e.target.value)}),className:"bg-muted accent-primary h-2 w-full cursor-pointer appearance-none rounded-lg"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"How long to wait after you stop speaking before responding"})]}),(0,r.jsx)("div",{className:"border-t pt-4",children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Global Wake Word Settings"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Threshold"}),(0,r.jsx)("input",{type:"number",min:"0",max:"1",step:"0.05",value:w.wake_word_threshold,onChange:e=>y({...w,wake_word_threshold:parseFloat(e.target.value)||.5}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Silence Timeout (s)"}),(0,r.jsx)("input",{type:"number",min:"1",max:"30",step:"0.5",value:w.wake_word_timeout,onChange:e=>y({...w,wake_word_timeout:parseFloat(e.target.value)||3}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]})]})]})})]})]})]}),"vision"===v&&(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs font-bold tracking-wide uppercase",children:"Vision Provider"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs -mt-2",children:"Independent from voice LLM. Cloud (Groq) is ~4\xd7 faster than local Ollama for image questions."}),(0,r.jsxs)("div",{className:"bg-muted inline-flex flex-wrap rounded-lg p-1 gap-0.5",children:[(0,r.jsxs)("button",{onClick:()=>y({...w,vision_provider:"ollama"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("ollama"===w.vision_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Ollama"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Ollama (Local)"})]}),(0,r.jsxs)("button",{onClick:()=>y({...w,vision_provider:"groq"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("groq"===w.vision_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Groq"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Groq (Cloud)"})]}),(0,r.jsx)("button",{onClick:()=>y({...w,vision_provider:"ollama_cloud"}),className:"rounded-md px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium transition-colors ".concat("ollama_cloud"===w.vision_provider?"bg-background text-foreground shadow":"text-muted-foreground hover:text-foreground"),children:"Ollama Cloud"})]}),"ollama"===w.vision_provider&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Vision Model (Ollama)"}),(0,r.jsx)("input",{type:"text",value:w.vision_model_ollama||"",onChange:e=>y({...w,vision_model_ollama:e.target.value}),placeholder:"gemma4:e4b",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm font-mono"}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["Must be a vision-capable Ollama model. Defaults to"," ",(0,r.jsx)("code",{children:"gemma4:e4b"})," (multimodal, 8B)."]})]}),"groq"===w.vision_provider&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Vision Model (Groq)"}),(0,r.jsxs)("select",{value:w.vision_model_groq||"meta-llama/llama-4-scout-17b-16e-instruct",onChange:e=>y({...w,vision_model_groq:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm",children:[(0,r.jsx)("option",{value:"meta-llama/llama-4-scout-17b-16e-instruct",children:"llama-4-scout-17b — fastest vision (recommended)"}),(0,r.jsx)("option",{value:"meta-llama/llama-4-maverick-17b-128e-instruct",children:"llama-4-maverick-17b — larger context, slightly slower"})]}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Uses your existing Groq API key from the Providers tab."})]}),"ollama_cloud"===w.vision_provider&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Ollama Cloud API Key"}),(0,r.jsx)("input",{type:"password",value:w.ollama_cloud_api_key||"",onChange:e=>y({...w,ollama_cloud_api_key:e.target.value}),placeholder:"Ollama API key",autoComplete:"off",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Vision Model (Ollama Cloud)"}),(0,r.jsx)("input",{type:"text",list:"ollama-cloud-vision-models",value:w.vision_model_ollama_cloud||"",onChange:e=>y({...w,vision_model_ollama_cloud:e.target.value}),placeholder:"gemma4:cloud",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm font-mono"}),(0,r.jsxs)("datalist",{id:"ollama-cloud-vision-models",children:[(0,r.jsx)("option",{value:"gemma4:cloud"}),(0,r.jsx)("option",{value:"gemma4:31b-cloud"}),(0,r.jsx)("option",{value:"qwen3-vl:235b-cloud"}),(0,r.jsx)("option",{value:"qwen3-vl:30b-cloud"}),(0,r.jsx)("option",{value:"gemma3:27b-cloud"})]}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Choose a vision-capable cloud model or enter another model name from your Ollama account."})]})]})]}),(0,r.jsxs)("div",{className:"space-y-4 rounded-xl border p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"text-sm font-semibold",children:"Always-on motion session"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Keeps camera and microphone connected, detects motion locally, greets once, and stays ready for conversation."})]}),(0,r.jsx)(ev,{enabled:w.always_on_session_enabled,onToggle:()=>y({...w,always_on_session_enabled:!w.always_on_session_enabled})})]}),w.always_on_session_enabled&&(0,r.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-2 sm:col-span-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Greeting phrase"}),(0,r.jsx)("input",{type:"text",value:w.motion_greeting||"",onChange:e=>y({...w,motion_greeting:e.target.value}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Motion sensitivity"}),(0,r.jsx)("input",{type:"range",min:"0.03",max:"0.35",step:"0.01",value:null!=(u=w.motion_threshold)?u:.12,onChange:e=>y({...w,motion_threshold:Number(e.target.value)}),className:"w-full"}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["Threshold: ",Math.round((null!=(m=w.motion_threshold)?m:.12)*100),"%"]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Re-arm cooldown (seconds)"}),(0,r.jsx)("input",{type:"number",min:"5",max:"600",value:null!=(p=w.motion_cooldown_seconds)?p:30,onChange:e=>y({...w,motion_cooldown_seconds:Number(e.target.value)}),className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]})]})]}),(0,r.jsx)("div",{className:"space-y-3 rounded-xl border p-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"text-sm font-semibold",children:"Direct-to-speech for vision answers"}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["When on, the answer from ",(0,r.jsx)("code",{children:"see()"})," goes straight to TTS instead of being re-summarized by the voice LLM. Saves 0.5–1s per vision question."]})]}),(0,r.jsx)(ev,{enabled:w.vision_terminal,onToggle:()=>y({...w,vision_terminal:!w.vision_terminal})})]})})]}),"integrations"===v&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border",children:[(0,r.jsxs)("div",{className:"bg-muted/50 flex items-center justify-between border-b px-4 py-3",children:[(0,r.jsx)("span",{className:"font-semibold",children:"Home Assistant"}),(0,r.jsx)(ev,{enabled:w.hass_enabled,onToggle:()=>y({...w,hass_enabled:!w.hass_enabled})})]}),w.hass_enabled&&(0,r.jsxs)("div",{className:"space-y-4 p-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Host URL"}),(0,r.jsx)("input",{type:"text",value:w.hass_host,onChange:e=>y({...w,hass_host:e.target.value}),placeholder:"http://homeassistant.local:8123",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Long-lived Access Token"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"password",value:w.hass_token,onChange:e=>y({...w,hass_token:e.target.value}),placeholder:"eyJ0eX...",className:"border-input bg-background flex-1 rounded-lg border px-4 py-3 text-sm"}),(0,r.jsxs)("button",{onClick:ei,disabled:!w.hass_host||!w.hass_token||"testing"===ee.status,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium disabled:opacity-50",children:[(0,r.jsx)(eb,{status:ee.status}),"Test"]})]}),ee.error&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:ee.error}),ee.info&&(0,r.jsx)("p",{className:"text-xs text-purple-500",children:ee.info})]})]})]}),(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border ".concat(w.n8n_enabled?"":"opacity-60"),children:[(0,r.jsxs)("div",{className:"bg-muted/50 flex items-center justify-between border-b px-4 py-3",children:[(0,r.jsx)("span",{className:"font-semibold",children:"n8n"}),(0,r.jsx)(ev,{enabled:w.n8n_enabled,onToggle:()=>y({...w,n8n_enabled:!w.n8n_enabled})})]}),w.n8n_enabled&&(0,r.jsxs)("div",{className:"space-y-4 p-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Host URL"}),(0,r.jsx)("input",{type:"text",value:w.n8n_url,onChange:e=>y({...w,n8n_url:e.target.value}),placeholder:"http://n8n:5678",className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"/mcp-server/http will be appended automatically"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Access Token"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"password",value:w.n8n_token,onChange:e=>y({...w,n8n_token:e.target.value}),placeholder:"n8n_api_...",className:"border-input bg-background flex-1 rounded-lg border px-4 py-3 text-sm"}),(0,r.jsxs)("button",{onClick:ed,disabled:!w.n8n_url||!w.n8n_token||"testing"===ea.status,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium disabled:opacity-50",children:[(0,r.jsx)(eb,{status:ea.status}),"Test"]})]}),ea.error&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:ea.error}),ea.info&&(0,r.jsx)("p",{className:"text-xs text-purple-500",children:ea.info})]})]})]})]})]})})]})]})}),document.body):null}let e7=u.P.create(e=>{let{startButtonText:t,isConnecting:a,connectionError:s,onStartCall:n,onOpenSettings:l,ref:o}=e,{settings:i,updateSettings:d}=(0,eu.t)(),c=e=>{i.always_on_session_enabled!==e&&d({...i,always_on_session_enabled:e})};return(0,r.jsxs)("div",{ref:o,className:"relative min-h-svh flex flex-col bg-background overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 aurora-bg pointer-events-none",children:(0,r.jsx)("div",{className:"aurora-orb"})}),(0,r.jsx)("div",{className:"absolute inset-0 line-grid opacity-40 pointer-events-none [mask-image:radial-gradient(ellipse_at_center,black_30%,transparent_75%)]"}),(0,r.jsx)("div",{className:"absolute inset-0 dot-grid opacity-50 pointer-events-none [mask-image:radial-gradient(ellipse_at_center,black_20%,transparent_70%)]"}),(0,r.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-blue-400/40 to-transparent pointer-events-none"}),(0,r.jsx)("div",{className:"fixed top-4 right-4 z-40",children:l&&(0,r.jsx)("button",{type:"button",onClick:l,className:"glass rounded-full p-2.5 text-blue-100/60 hover:text-white hover:bg-white/[0.08] transition-all",title:"Settings",children:(0,r.jsx)(eL.O,{className:"h-5 w-5",weight:"bold"})})}),(0,r.jsxs)("div",{className:"fixed top-4 left-4 z-40 hidden sm:flex items-center gap-2 text-[10px] font-mono uppercase tracking-[0.2em] text-blue-200/40",children:[(0,r.jsx)("span",{className:"inline-block size-1.5 rounded-full bg-blue-400 shadow-[0_0_8px_rgba(96,165,250,0.8)]"}),"ROBOPARK / TEST INTERFACE"]}),(0,r.jsxs)("section",{className:"relative z-10 flex-1 flex flex-col items-center justify-center text-center px-6 py-12",children:[(0,r.jsx)(eX,{}),(0,r.jsx)(eZ,{}),(0,r.jsxs)("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-glow",children:[(0,r.jsx)("span",{className:"bg-gradient-to-br from-white via-blue-50 to-blue-200 bg-clip-text text-transparent",children:"RoboPark"})," ",(0,r.jsx)("span",{className:"bg-gradient-to-br from-blue-200 via-blue-300 to-blue-500 bg-clip-text text-transparent",children:"Test Interface"})]}),(0,r.jsx)("p",{className:"mt-3 text-sm sm:text-base text-blue-100/50 max-w-sm leading-relaxed",children:"Voice control bay for RoboPark units"}),(0,r.jsx)("div",{className:"mt-9 w-full max-w-md",children:(0,r.jsx)("div",{className:"relative glass gradient-border rounded-2xl p-6 sm:p-7",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-5",children:[(0,r.jsxs)("div",{className:"w-full flex flex-col items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] font-mono uppercase tracking-[0.18em] text-blue-200/40",children:"Active Unit"}),(0,r.jsx)(ey,{className:"mx-auto"})]}),(0,r.jsx)("div",{className:"w-full h-px bg-gradient-to-r from-transparent via-blue-400/20 to-transparent"}),(0,r.jsxs)("div",{className:"w-full space-y-2",children:[(0,r.jsx)("span",{className:"block text-[10px] font-mono uppercase tracking-[0.18em] text-blue-200/50",children:"Session Mode"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 rounded-xl border border-blue-400/15 bg-black/25 p-1.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>c(!1),className:"rounded-lg px-3 py-3 text-left transition-all ".concat(i.always_on_session_enabled?"text-blue-100/55 hover:bg-white/[0.05] hover:text-white":"bg-blue-500 text-white shadow-[0_0_18px_rgba(59,130,246,0.35)]"),children:[(0,r.jsx)("span",{className:"block text-sm font-semibold",children:"Manual"}),(0,r.jsx)("span",{className:"mt-0.5 block text-[10px] opacity-70",children:"Tap to begin"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>c(!0),className:"rounded-lg px-3 py-3 text-left transition-all ".concat(i.always_on_session_enabled?"bg-emerald-500 text-emerald-950 shadow-[0_0_18px_rgba(52,211,153,0.35)]":"text-blue-100/55 hover:bg-white/[0.05] hover:text-white"),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,r.jsx)("span",{className:"size-2 rounded-full ".concat(i.always_on_session_enabled?"bg-emerald-950 animate-pulse":"bg-blue-200/40")}),"Always On"]}),(0,r.jsx)("span",{className:"mt-0.5 block text-[10px] opacity-70",children:"Motion greeting"})]})]})]}),(0,r.jsxs)(B,{type:"button",variant:"primary",size:"lg",onClick:n,disabled:a,className:"w-full sm:w-72 font-mono touch-manipulation relative overflow-hidden group glow-on-hover border shadow-lg ".concat(i.always_on_session_enabled?"bg-gradient-to-br from-emerald-500 to-emerald-600 hover:from-emerald-400 hover:to-emerald-500 border-emerald-300/30":"bg-gradient-to-br from-blue-500 to-blue-600 hover:from-blue-400 hover:to-blue-500 border-blue-300/30 shadow-[0_8px_24px_-8px_rgba(59,130,246,0.6)]"),children:[a&&(0,r.jsx)(eM.N,{className:"h-4 w-4 animate-spin"}),(0,r.jsx)("span",{className:"relative z-10",children:a?"Connecting...":i.always_on_session_enabled?"Activate Always On":t}),(0,r.jsx)("div",{className:"absolute inset-y-0 -left-1/2 w-1/2 bg-gradient-to-r from-transparent via-white/30 to-transparent skew-x-[-12deg] -translate-x-full group-hover:translate-x-[300%] transition-transform duration-1000 ease-out"})]}),i.always_on_session_enabled&&(0,r.jsx)("div",{className:"w-full rounded-xl border border-emerald-400/20 bg-emerald-400/10 px-4 py-3 text-sm text-emerald-200",children:"Camera monitoring starts only after you activate it."}),s&&(0,r.jsx)("p",{className:"text-xs text-red-300/80 max-w-xs",children:s})]})})}),(0,r.jsx)("div",{className:"mt-7 w-full max-w-md",children:(0,r.jsx)(eK,{})})]}),(0,r.jsx)("div",{className:"relative z-10 pb-4 text-center text-[10px] font-mono uppercase tracking-[0.2em] text-blue-200/25",children:"v2.0 \xb7 LiveKit + Local Voice Stack"})]})}),te=u.P.create(e=>{let{appConfig:t,...a}=e,s=(0,d.aB)(),{messages:o}=function(){let e=(0,d.f)(),[t,a]=(0,n.useState)([]);return(0,n.useEffect)(()=>{if(!e)return;let t=(e,t,s,r)=>{if("lk-chat-topic"===r)try{let t=JSON.parse(new TextDecoder().decode(e)),s={id:"".concat(t.timestamp,"-").concat(t.role),timestamp:t.timestamp,message:t.message,from:{identity:"user"===t.role?"user":"agent",name:"user"===t.role?"You":"Agent",isLocal:"user"===t.role},type:"chatMessage"};a(e=>[...e,s])}catch(e){console.error("[useTranscriptions] Failed to parse transcription:",e)}};return e.on(l.u9.DataReceived,t),()=>{e.off(l.u9.DataReceived,t)}},[e]),{messages:t}}(),[i,c]=(0,n.useState)(!1),[x,h]=(0,n.useState)(!1),g=(0,n.useRef)(null),b=async()=>{let e=!x;if(h(e),e){c(!0);try{var t,a;await (null==(t=(a=document.documentElement).requestFullscreen)?void 0:t.call(a))}catch(e){}}else if(document.fullscreenElement)try{await document.exitFullscreen()}catch(e){}};(0,n.useEffect)(()=>{let e=()=>{document.fullscreenElement||h(!1)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);let f={leave:!0,microphone:!0,chat:t.supportsChatInput,camera:t.supportsVideoInput,screenShare:t.supportsVideoInput};return(0,n.useEffect)(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[o]),(0,n.useEffect)(()=>{o.length>0&&!i&&c(!0)},[o.length]),(0,r.jsxs)("section",{className:"bg-background relative z-10 h-full w-full overflow-hidden selection:bg-primary/30",...a,children:[(0,r.jsx)("div",{className:"fixed inset-0 pointer-events-none z-[60] opacity-[0.08]",style:{backgroundImage:"linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.15) 50%)",backgroundSize:"100% 3px"}}),(0,r.jsx)(eI,{conversationFullscreen:x,onToggleConversationFullscreen:()=>void b()}),(0,r.jsx)(eE,{}),x&&(0,r.jsx)(C,{chatOpen:!1,fullscreenCamera:!0}),(0,r.jsxs)("div",{className:"relative z-30 h-full w-full flex flex-col pt-8 pb-0",children:[(0,r.jsx)("div",{className:(0,p.cn)("relative flex-shrink-0 items-center justify-center px-4 py-3 sm:py-6",x?"hidden":"flex"),children:(0,r.jsxs)("div",{className:(0,p.cn)("relative w-full max-w-lg transition-all duration-500",i?"h-[100px] sm:h-[120px]":"h-[35vh] sm:h-[45vh] max-h-[400px]"),children:[(0,r.jsxs)("div",{className:"absolute inset-0 rounded-2xl border border-primary/15 bg-black/30 backdrop-blur-sm overflow-hidden shadow-[0_0_30px_rgba(160,32,240,0.08)]",children:[(0,r.jsx)("div",{className:"absolute top-0 left-0 w-5 h-5 border-t border-l border-primary/40 rounded-tl-xl"}),(0,r.jsx)("div",{className:"absolute top-0 right-0 w-5 h-5 border-t border-r border-primary/40 rounded-tr-xl"}),(0,r.jsx)("div",{className:"absolute bottom-0 left-0 w-5 h-5 border-b border-l border-primary/40 rounded-bl-xl"}),(0,r.jsx)("div",{className:"absolute bottom-0 right-0 w-5 h-5 border-b border-r border-primary/40 rounded-br-xl"})]}),!x&&(0,r.jsx)(C,{chatOpen:i})]})}),(0,r.jsx)("div",{className:(0,p.cn)("justify-center px-4 -mt-1 mb-1",x?"hidden":"flex"),children:(0,r.jsx)(ey,{})}),(0,r.jsxs)("div",{className:(0,p.cn)("flex-1 flex flex-col min-h-0 transition-all duration-500",i?"opacity-100":"opacity-60"),children:[(0,r.jsx)("div",{className:(0,p.cn)("justify-center",x?"hidden":"flex"),children:(0,r.jsx)(eA,{isExpanded:i,onToggle:()=>c(!i),messageCount:o.length})}),(0,r.jsx)(m.N,{children:(i||x)&&(0,r.jsx)(u.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},className:(0,p.cn)("flex-1 min-h-0",x?"flex items-end px-5 pb-2 sm:px-12":"px-3 sm:px-6"),children:(0,r.jsx)(ec,{ref:g,className:(0,p.cn)("h-full w-full mx-auto pb-4",x?"max-h-[42vh] max-w-2xl rounded-2xl border border-white/10 bg-black/70 p-3 text-base shadow-2xl sm:p-5 sm:text-lg":"max-h-[calc(100vh-340px)] max-w-2xl sm:max-h-[calc(100vh-380px)]"),children:(0,r.jsx)(v,{messages:x?o.slice(-6):o,className:"px-1"})})})}),!i&&!x&&o.length>0&&(0,r.jsx)("div",{className:"px-6 sm:px-12 max-w-2xl mx-auto w-full",children:(0,r.jsx)("div",{className:"relative h-20 overflow-hidden mask-gradient-t",children:(0,r.jsx)(v,{messages:o.slice(-2),className:"text-xs opacity-50"})})})]}),(0,r.jsx)(eP,{...eO,className:"flex-shrink-0 pb-3 sm:pb-5 pt-2 flex justify-center px-3",children:(0,r.jsx)("div",{className:"w-full max-w-md",children:(0,r.jsx)(ed,{controls:f,isConnected:s.isConnected,onDisconnect:s.end,onChatOpenChange:c,className:"w-full"})})})]}),(0,r.jsx)(ex,{}),(0,r.jsx)(ev,{})]})}),tt={variants:{visible:{opacity:1},hidden:{opacity:0}},initial:"hidden",animate:"visible",exit:"hidden",transition:{duration:.5,ease:"linear"}};function ta(e){let{appConfig:t}=e,{isConnected:a,start:s}=(0,d.aB)(),[l,o]=(0,n.useState)(!1),[i,c]=(0,n.useState)(!1),[u,p]=(0,n.useState)(null),x=(0,n.useRef)(!1),h=(0,n.useCallback)(async()=>{c(!0),p(null);try{await s()}catch(e){console.error("[ViewController] Failed to start session:",e),p(e instanceof Error?e.message:"Failed to connect. Check your network and try again."),c(!1)}},[s]);return(0,n.useEffect)(()=>{if("1"!==new URLSearchParams(window.location.search).get("autostart")||a||x.current)return;let e=!1;return x.current=!0,(async()=>{for(;!e&&(await h(),!e);)await new Promise(e=>window.setTimeout(e,5e3))})(),()=>{e=!0,x.current=!1}},[h,a]),a&&i&&c(!1),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(m.N,{mode:"wait",children:[!a&&(0,r.jsx)(e7,{...tt,startButtonText:i?"Connecting...":t.startButtonText,isConnecting:i,connectionError:u,onStartCall:h,onOpenSettings:()=>o(!0)},"welcome"),a&&(0,r.jsx)(te,{...tt,appConfig:t},"session-view")]}),(0,r.jsx)(e9,{isOpen:l,onClose:()=>o(!1)})]})}var ts=a(2080),tr=a(4128);let tn=(0,n.createContext)(null);function tl(e){let{children:t,accessKey:a,keywordPath:s,sensitivity:l=.5,onWakeWordDetected:o,defaultEnabled:i=!1}=e,[d,c]=(0,n.useState)(i),{isListening:u,isReady:m,error:p,startListening:x,stopListening:h}=function(e){let{accessKey:t,keywordPath:a,modelPath:s="/porcupine_params.pv",sensitivity:r=.5,onWakeWord:l,enabled:o=!0}=e,[i,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),x=(0,n.useRef)(null),h=(0,n.useRef)(l);(0,n.useEffect)(()=>{h.current=l},[l]),(0,n.useEffect)(()=>{if(!o||!t)return;let e=!0;return async function(){try{p(null);let n=await ts.k.create(t,{publicPath:a,label:"hey_cal",sensitivity:r},t=>{t.index>=0&&e&&(console.log("[WakeWord] Detected:",t.label),h.current())},{publicPath:s});e?(x.current=n,u(!0),console.log("[WakeWord] Porcupine initialized")):await n.release()}catch(t){console.error("[WakeWord] Init error:",t),e&&p(t instanceof Error?t.message:"Failed to initialize wake word")}}(),()=>{e=!1,x.current&&(tr.n8.unsubscribe(x.current).catch(()=>{}),x.current.release(),x.current=null),u(!1),d(!1)}},[t,a,s,r,o]);let g=(0,n.useCallback)(async()=>{if(!x.current||!c)return void console.warn("[WakeWord] Cannot start - not ready");try{await tr.n8.subscribe(x.current),d(!0),console.log("[WakeWord] Started listening")}catch(e){console.error("[WakeWord] Start error:",e),p(e instanceof Error?e.message:"Failed to start listening")}},[c]);return{isListening:i,isReady:c,error:m,startListening:g,stopListening:(0,n.useCallback)(async()=>{if(x.current)try{await tr.n8.unsubscribe(x.current),d(!1),console.log("[WakeWord] Stopped listening")}catch(e){console.error("[WakeWord] Stop error:",e)}},[])}}({accessKey:a,keywordPath:s,sensitivity:l,onWakeWord:(0,n.useCallback)(()=>{d&&(console.log("[WakeWordProvider] Wake word detected, triggering callback"),o())},[d,o]),enabled:d});return(0,n.useEffect)(()=>{d&&m&&!u&&x()},[d,m,u,x]),(0,n.useEffect)(()=>{!d&&u&&h()},[d,u,h]),(0,r.jsx)(tn.Provider,{value:{isEnabled:d,setEnabled:c,isListening:u,isReady:m,error:p,startListening:x,stopListening:h},children:t})}var to=a(5379),ti=a(8720),td=a(8687);function tc(e){let{...t}=e,{theme:a="system"}=(0,to.D)();return(0,r.jsx)(ti.l$,{theme:a,className:"toaster group",position:"top-center",icons:{warning:(0,r.jsx)(td.i,{weight:"bold"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t})}function tu(e){let{data:t,updateData:a}=e,[s,l]=(0,n.useState)({status:"idle",error:null,info:null}),[o,i]=(0,n.useState)({status:"idle",error:null,info:null}),d=(0,n.useCallback)(async()=>{if(t.hass_host&&t.hass_token){l({status:"testing",error:null,info:null});try{let e=await fetch("/api/setup/test-hass",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:t.hass_host,token:t.hass_token})}),a=await e.json();a.success?l({status:"success",error:null,info:"Connected - ".concat(a.device_count," entities")}):l({status:"error",error:a.error||"Connection failed",info:null})}catch(e){l({status:"error",error:"Failed to connect",info:null})}}},[t.hass_host,t.hass_token]),c=(0,n.useCallback)(async()=>{if(!t.n8n_url||!t.n8n_token)return;i({status:"testing",error:null,info:null});let e=(e=>{if(!e)return"";let t=e.replace(/\/$/,"");return t.includes("/mcp-server")?t:"".concat(t,"/mcp-server/http")})(t.n8n_url);try{let a=await fetch("/api/setup/test-n8n",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,token:t.n8n_token})}),s=await a.json();s.success?i({status:"success",error:null,info:"Connected"}):i({status:"error",error:s.error||"Connection failed",info:null})}catch(e){i({status:"error",error:"Failed to connect",info:null})}},[t.n8n_url,t.n8n_token]),u=e=>{let{status:t}=e;switch(t){case"testing":return(0,r.jsx)(eM.N,{className:"h-4 w-4 animate-spin text-blue-500"});case"success":return(0,r.jsx)(Z.J,{className:"h-4 w-4 text-green-500",weight:"bold"});case"error":return(0,r.jsx)(e$.X,{className:"h-4 w-4 text-red-500",weight:"bold"});default:return null}},m=e=>{let{enabled:t,onToggle:a}=e;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,onClick:a,className:"relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:ring-2 focus:ring-offset-2 focus:outline-none ".concat(t?"bg-primary":"bg-muted"),children:(0,r.jsx)("span",{className:"pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ".concat(t?"translate-x-5":"translate-x-0")})})};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-muted-foreground text-sm",children:"Configure optional integrations. You can add or change these later in Settings."}),(0,r.jsxs)("div",{className:"border-input dark:border-muted space-y-3 rounded-lg border p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-medium",children:"Home Assistant"}),(0,r.jsx)("div",{className:"text-muted-foreground text-xs",children:"Control your smart home"})]}),(0,r.jsx)(m,{enabled:t.hass_enabled,onToggle:()=>a({hass_enabled:!t.hass_enabled})})]}),t.hass_enabled&&(0,r.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs",children:"Host URL"}),(0,r.jsx)("input",{type:"text",value:t.hass_host,onChange:e=>a({hass_host:e.target.value}),placeholder:"http://homeassistant.local:8123",className:"border-input bg-background w-full rounded-md border px-3 py-2 text-sm"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs",children:"Long-Lived Access Token"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"password",value:t.hass_token,onChange:e=>a({hass_token:e.target.value}),placeholder:"eyJ0eX...",className:"border-input bg-background flex-1 rounded-md border px-3 py-2 text-sm"}),(0,r.jsxs)("button",{onClick:d,disabled:!t.hass_host||!t.hass_token||"testing"===s.status,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-md px-3 py-2 text-sm disabled:opacity-50",children:[(0,r.jsx)(u,{status:s.status}),"Test"]})]}),s.error&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:s.error}),s.info&&(0,r.jsx)("p",{className:"text-xs text-green-500",children:s.info})]})]})]}),(0,r.jsxs)("div",{className:"border-input dark:border-muted space-y-3 rounded-lg border p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-medium",children:"n8n Workflows"}),(0,r.jsx)("div",{className:"text-muted-foreground text-xs",children:"Connect custom automations"})]}),(0,r.jsx)(m,{enabled:t.n8n_enabled,onToggle:()=>a({n8n_enabled:!t.n8n_enabled})})]}),t.n8n_enabled&&(0,r.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs",children:"n8n Host URL"}),(0,r.jsx)("input",{type:"text",value:t.n8n_url,onChange:e=>a({n8n_url:e.target.value}),placeholder:"http://n8n:5678",className:"border-input bg-background w-full rounded-md border px-3 py-2 text-sm"}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"/mcp-server/http will be appended automatically"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-muted-foreground text-xs",children:"Access Token"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"password",value:t.n8n_token,onChange:e=>a({n8n_token:e.target.value}),placeholder:"n8n_api_...",className:"border-input bg-background flex-1 rounded-md border px-3 py-2 text-sm"}),(0,r.jsxs)("button",{onClick:c,disabled:!t.n8n_url||!t.n8n_token||"testing"===o.status,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-md px-3 py-2 text-sm disabled:opacity-50",children:[(0,r.jsx)(u,{status:o.status}),"Test"]})]}),o.error&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:o.error}),o.info&&(0,r.jsx)("p",{className:"text-xs text-green-500",children:o.info})]})]})]})]})}function tm(e){let{data:t,updateData:a}=e,[s,l]=(0,n.useState)([]),[o,i]=(0,n.useState)([]),[d,c]=(0,n.useState)("idle"),[u,m]=(0,n.useState)(null),p=(0,n.useCallback)(async()=>{if(t.ollama_host){c("testing"),m(null);try{let s=await fetch("/api/setup/test-ollama",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:t.ollama_host})}),r=await s.json();if(r.success){var e;c("success"),l(r.models||[]),!t.ollama_model&&(null==(e=r.models)?void 0:e.length)>0&&a({ollama_model:r.models[0]})}else c("error"),m(r.error||"Connection failed")}catch(e){c("error"),m("Failed to connect")}}},[t.ollama_host,t.ollama_model,a]),x=(0,n.useCallback)(async()=>{if(t.groq_api_key){c("testing"),m(null);try{let s=await fetch("/api/setup/test-groq",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:t.groq_api_key})}),r=await s.json();if(r.success){var e;if(c("success"),i(r.models||[]),!t.groq_model&&(null==(e=r.models)?void 0:e.length)>0){let e="openai/gpt-oss-20b",t=r.models.includes(e)?e:r.models[0];a({groq_model:t})}}else c("error"),m(r.error||"Invalid API key")}catch(e){c("error"),m("Failed to validate")}}},[t.groq_api_key,t.groq_model,a]);(0,n.useEffect)(()=>{c("idle"),m(null)},[t.llm_provider]);let h=()=>{switch(d){case"testing":return(0,r.jsx)(eM.N,{className:"h-4 w-4 animate-spin text-blue-500"});case"success":return(0,r.jsx)(Z.J,{className:"h-4 w-4 text-green-500",weight:"bold"});case"error":return(0,r.jsx)(e$.X,{className:"h-4 w-4 text-red-500",weight:"bold"});default:return null}};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"AI Provider"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,r.jsxs)("button",{onClick:()=>a({llm_provider:"ollama"}),className:"rounded-lg border p-4 text-left transition-colors ".concat("ollama"===t.llm_provider?"border-primary bg-primary/5":"border-input hover:border-muted-foreground"),children:[(0,r.jsx)("div",{className:"font-medium",children:"Ollama"}),(0,r.jsx)("div",{className:"text-muted-foreground text-xs",children:"Local, private, free"})]}),(0,r.jsxs)("button",{onClick:()=>a({llm_provider:"groq"}),className:"rounded-lg border p-4 text-left transition-colors ".concat("groq"===t.llm_provider?"border-primary bg-primary/5":"border-input hover:border-muted-foreground"),children:[(0,r.jsx)("div",{className:"font-medium",children:"Groq"}),(0,r.jsx)("div",{className:"text-muted-foreground text-xs",children:"Fast cloud inference"})]})]})]}),"ollama"===t.llm_provider&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Ollama Host"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:t.ollama_host,onChange:e=>a({ollama_host:e.target.value}),placeholder:"http://localhost:11434",className:"border-input bg-background flex-1 rounded-md border px-3 py-2"}),(0,r.jsxs)("button",{onClick:p,disabled:!t.ollama_host||"testing"===d,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-md px-3 py-2 text-sm disabled:opacity-50",children:[(0,r.jsx)(h,{}),"Test"]})]}),u&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:u}),"success"===d&&(0,r.jsxs)("p",{className:"text-xs text-green-500",children:["Connected - ",s.length," models available"]})]}),s.length>0&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),(0,r.jsxs)("select",{value:t.ollama_model,onChange:e=>a({ollama_model:e.target.value}),className:"border-input bg-background w-full rounded-md border px-3 py-2",children:[(0,r.jsx)("option",{value:"",children:"Select a model..."}),s.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Using Ollama also enables local speech-to-text via Speaches."})]}),"groq"===t.llm_provider&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Groq API Key"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"password",value:t.groq_api_key,onChange:e=>a({groq_api_key:e.target.value}),placeholder:"gsk_...",className:"border-input bg-background flex-1 rounded-md border px-3 py-2"}),(0,r.jsxs)("button",{onClick:x,disabled:!t.groq_api_key||"testing"===d,className:"bg-muted hover:bg-muted/80 flex items-center gap-2 rounded-md px-3 py-2 text-sm disabled:opacity-50",children:[(0,r.jsx)(h,{}),"Test"]})]}),u&&(0,r.jsx)("p",{className:"text-xs text-red-500",children:u}),"success"===d&&(0,r.jsxs)("p",{className:"text-xs text-green-500",children:["Connected - ",o.length," models available"]}),(0,r.jsxs)("p",{className:"text-muted-foreground text-xs",children:["Get your API key at"," ",(0,r.jsx)("a",{href:"https://console.groq.com/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"console.groq.com"})]})]}),o.length>0&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Model"}),(0,r.jsxs)("select",{value:t.groq_model,onChange:e=>a({groq_model:e.target.value}),className:"border-input bg-background w-full rounded-md border px-3 py-2",children:[(0,r.jsx)("option",{value:"",children:"Select a model..."}),o.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"Using Groq also enables fast cloud speech-to-text via Whisper."})]})]})}function tp(e){let{data:t,updateData:a}=e,[s,l]=(0,n.useState)([]),[o,i]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{i(!0);try{let e=await fetch("/api/voices?provider=".concat(t.tts_provider));if(e.ok){let t=((await e.json()).voices||[]).map(e=>"string"==typeof e?{id:e,name:e}:e);l(t)}}catch(e){console.error("Failed to fetch voices:",e)}finally{i(!1)}})()},[t.tts_provider]);let d="piper"===t.tts_provider?t.tts_voice_piper:t.tts_voice_kokoro;return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Text-to-Speech Engine"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,r.jsxs)("button",{onClick:()=>a({tts_provider:"kokoro"}),className:"rounded-lg border p-4 text-left transition-colors ".concat("kokoro"===t.tts_provider?"border-primary bg-primary/5":"border-input hover:border-muted-foreground"),children:[(0,r.jsx)("div",{className:"font-medium",children:"Kokoro"}),(0,r.jsx)("div",{className:"text-muted-foreground text-xs",children:"GPU-accelerated, high quality neural TTS"})]}),(0,r.jsxs)("button",{onClick:()=>a({tts_provider:"piper"}),className:"rounded-lg border p-4 text-left transition-colors ".concat("piper"===t.tts_provider?"border-primary bg-primary/5":"border-input hover:border-muted-foreground"),children:[(0,r.jsx)("div",{className:"font-medium",children:"Piper"}),(0,r.jsx)("div",{className:"text-muted-foreground text-xs",children:"CPU-friendly, lightweight with 35+ languages"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Voice"}),(0,r.jsx)("select",{value:d,onChange:e=>{var s;return s=e.target.value,void("piper"===t.tts_provider?a({tts_voice_piper:s}):a({tts_voice_kokoro:s}))},disabled:o,className:"border-input bg-background w-full rounded-lg border px-4 py-3 text-sm disabled:opacity-50",children:s.length>0?s.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id)):(0,r.jsx)("option",{value:d,children:d})})]}),(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:"kokoro"===t.tts_provider?"Kokoro requires a GPU for optimal performance.":"Piper runs on CPU and supports many languages."})]})}let tx={llm_provider:"ollama",ollama_host:"http://localhost:11434",ollama_model:"",groq_api_key:"",groq_model:"",tts_provider:"kokoro",tts_voice_kokoro:"am_puck",tts_voice_piper:"speaches-ai/piper-en_US-ryan-high",hass_enabled:!1,hass_host:"",hass_token:"",n8n_enabled:!1,n8n_url:"",n8n_token:""};function th(e){let{onComplete:t}=e,[a,s]=(0,n.useState)(1),[l,o]=(0,n.useState)(tx),[i,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(null),x=e=>{o(t=>({...t,...e}))},h=async()=>{d(!0),p(null);let e={...l,n8n_url:l.n8n_enabled?(e=>{if(!e)return"";let t=e.replace(/\/$/,"");return t.includes("/mcp-server")?t:"".concat(t,"/mcp-server/http")})(l.n8n_url):l.n8n_url};try{let a=await fetch("/api/setup/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await a.json();if(!s.success)throw Error(s.message||"Setup failed");"ollama"===e.llm_provider&&fetch("/api/prewarm",{method:"POST"}).catch(()=>{}),"piper"===e.tts_provider&&e.tts_voice_piper&&(u("Downloading voice model..."),await fetch("/api/download-piper-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model_id:e.tts_voice_piper})})),t()}catch(e){p(e instanceof Error?e.message:"Setup failed")}finally{d(!1)}},g=()=>{if(1===a)if("ollama"===l.llm_provider)return l.ollama_host&&l.ollama_model;else return l.groq_api_key&&l.groq_model;return 2!==a||("piper"===l.tts_provider?!!l.tts_voice_piper:!!l.tts_voice_kokoro)},b=3===a;return(0,eY.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:(0,r.jsxs)("div",{className:"bg-background border-input dark:border-muted flex max-h-[85vh] w-full max-w-lg flex-col rounded-lg border shadow-xl",children:[(0,r.jsxs)("div",{className:"border-input dark:border-muted shrink-0 border-b p-4",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Welcome to CAAL"}),(0,r.jsxs)("p",{className:"text-muted-foreground text-sm",children:["Step ",a," of ",3," — ",(()=>{switch(a){case 1:return"Choose your AI provider";case 2:return"Choose your voice";case 3:return"Configure integrations";default:return""}})()]}),(0,r.jsx)("div",{className:"bg-muted mt-3 h-1 w-full rounded-full",children:(0,r.jsx)("div",{className:"bg-primary h-1 rounded-full transition-all duration-300",style:{width:"".concat(a/3*100,"%")}})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[m&&(0,r.jsx)("div",{className:"mb-4 rounded-md bg-red-500/10 p-3 text-red-500",children:m}),1===a&&(0,r.jsx)(tm,{data:l,updateData:x}),2===a&&(0,r.jsx)(tp,{data:l,updateData:x}),3===a&&(0,r.jsx)(tu,{data:l,updateData:x})]}),(0,r.jsxs)("div",{className:"border-input dark:border-muted flex shrink-0 justify-between border-t p-4",children:[(0,r.jsx)("div",{children:a>1&&(0,r.jsx)(B,{variant:"secondary",onClick:()=>{s(e=>e-1)},disabled:i,children:"Back"})}),(0,r.jsx)("div",{className:"flex gap-2",children:b?(0,r.jsx)(B,{variant:"primary",onClick:h,disabled:i||!g(),children:i?c||"Saving...":"Finish Setup"}):(0,r.jsx)(B,{variant:"primary",onClick:()=>{s(e=>e+1)},disabled:!g(),children:"Continue"})})]})]})}),document.body)}let tg=(0,q.F)(["relative w-full rounded-lg border px-4 py-3 text-sm grid grid-cols-[0_1fr] gap-y-0.5 items-start","has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current"],{variants:{variant:{default:"bg-card text-card-foreground",destructive:["text-destructive bg-destructive/10 border-destructive/20","[&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"]}},defaultVariants:{variant:"default"}});function tb(e){let{className:t,variant:a,...s}=e;return(0,r.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,p.cn)(tg({variant:a}),t),...s})}function tv(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"alert-title",className:(0,p.cn)("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...a})}function tf(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"alert-description",className:(0,p.cn)("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...a})}function tw(e){let{title:t,description:a,id:s}=e;return(0,r.jsxs)(tb,{onClick:()=>ti.oR.dismiss(s),className:"bg-accent w-full md:w-[364px]",children:[(0,r.jsx)(td.i,{weight:"bold"}),(0,r.jsx)(tv,{children:t}),a&&(0,r.jsx)(tf,{children:a})]})}let ty=function(){var e,t;let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=(0,d.f)(),r=null!=(e=a.logLevel)?e:"debug",o=null==(t=a.enabled)||t;n.useEffect(()=>o?((0,l.He)(null!=r?r:"debug"),window.__lk_room=s,()=>{window.__lk_room=void 0,(0,l.He)("silent")}):void(0,l.He)("silent"),[s,o,r])};function tj(e){let{children:t}=e,{settings:a,loading:s}=(0,eu.t)(),[l,o]=(0,n.useState)("loading"),[i,d]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[x,h]=(0,n.useState)(""),[g,b]=(0,n.useState)(!1),v=async()=>{o("loading"),h("");try{var e;let t=new URLSearchParams(window.location.search).get("device_id"),s=window.localStorage.getItem("robopanda_device_id"),r=t||s,n=r?"?device_id=".concat(encodeURIComponent(r)):"",l=await fetch("/api/device-character".concat(n),{cache:"no-store"}),i=await l.json();if(!l.ok)throw Error(i.error||"Device registry unavailable");d(i.device_id||""),i.device_id&&window.localStorage.setItem("robopanda_device_id",i.device_id),u(i.device_name||"RoboPark ".concat((i.device_id||"").slice(0,6))),p(i.character_id||(a.characters.some(e=>"robopanda"===e.id)?"robopanda":(null==(e=a.characters[0])?void 0:e.id)||"")),o(i.bound?"bound":"unbound")}catch(e){h(e instanceof Error?e.message:"Could not load device registry"),o("error")}};(0,n.useEffect)(()=>{s||v()},[s]);let f=async()=>{if(m&&c.trim()){b(!0),h("");try{let e=await fetch("/api/device-character",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({character_id:m,device_name:c,device_id:i})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to bind device");window.location.reload()}catch(e){h(e instanceof Error?e.message:"Failed to bind device"),b(!1)}}};return(0,r.jsxs)(r.Fragment,{children:["bound"===l?t:null,"bound"!==l&&(0,r.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/80 p-4 backdrop-blur-md",children:(0,r.jsx)("div",{className:"w-full max-w-md rounded-2xl border border-blue-400/25 bg-slate-950 p-6 shadow-2xl shadow-blue-500/20",children:"loading"===l?(0,r.jsxs)("div",{className:"flex items-center justify-center gap-3 py-12 text-blue-200",children:[(0,r.jsx)(eM.N,{className:"size-5 animate-spin"})," Loading device registry…"]}):"error"===l?(0,r.jsxs)("div",{className:"space-y-4 text-center",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold text-white",children:"Device registry unavailable"}),(0,r.jsx)("p",{className:"text-sm text-red-300",children:x}),(0,r.jsx)("button",{onClick:()=>void v(),className:"rounded-lg bg-blue-500 px-5 py-2.5 font-semibold text-white",children:"Retry"})]}):(0,r.jsxs)("div",{className:"space-y-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-mono uppercase tracking-[0.2em] text-blue-300/60",children:"New RoboPark device"}),(0,r.jsx)("h2",{className:"mt-2 text-2xl font-semibold text-white",children:"Choose this device’s character"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-blue-100/55",children:"This binding is saved in the registry and restored automatically on every visit."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm text-blue-100/75",children:"Device name"}),(0,r.jsx)("input",{value:c,onChange:e=>u(e.target.value),className:"w-full rounded-lg border border-blue-400/20 bg-black/30 px-4 py-3 text-white"}),(0,r.jsxs)("p",{className:"text-[10px] font-mono text-blue-200/35",children:["ID: ",i]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm text-blue-100/75",children:"Character"}),(0,r.jsx)("select",{value:m,onChange:e=>p(e.target.value),className:"w-full rounded-lg border border-blue-400/20 bg-slate-900 px-4 py-3 text-white",children:a.characters.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id))})]}),x&&(0,r.jsx)("p",{className:"text-sm text-red-300",children:x}),(0,r.jsxs)("button",{disabled:g||!c.trim()||!m,onClick:()=>void f(),className:"flex w-full items-center justify-center gap-2 rounded-xl bg-blue-500 px-5 py-3 font-semibold text-white disabled:opacity-50",children:[g&&(0,r.jsx)(eM.N,{className:"size-4 animate-spin"})," Bind this device"]})]})})})]})}let t_="robopark:media-device:audioinput",tN="robopark:media-device:videoinput",tk="robopark:media-device:audiooutput",tC="robopark:hardware-profile-version",tS="physical-media-v3",tT="robopark:hardware-profile-revision",tE="robopark:device-control-revision",tP="robopark:device-restart-revision",tI="robopark:camera-recovery-revision";function tA(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";fetch("/api/kiosk-diagnostic",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_id:new URLSearchParams(window.location.search).get("device_id")||"",stage:e,status:t,detail:a})}).catch(()=>void 0)}function tO(e){let t=e.label.toLowerCase(),a=0;return/usb|microphone|\bmic\b|webcam|camera/.test(t)&&(a+=30),/built-in|analog/.test(t)&&(a+=5),/monitor|loopback|stereo mix|hdmi|output/.test(t)&&(a-=100),"default"===e.deviceId&&(a-=5),a}function tL(e){let t=e.label.toLowerCase(),a=0;return/usb|webcam|camera|video/.test(t)&&(a+=20),/virtual|obs|screen/.test(t)&&(a-=80),"default"===e.deviceId&&(a-=5),a}function tM(e){let t=e.label.toLowerCase(),a=0;return/usb|speaker|headphone|analog/.test(t)&&(a+=30),/hdmi|display|monitor/.test(t)&&(a-=100),"default"===e.deviceId&&(a-=5),a}function tz(e,t,a){return e.filter(e=>e.kind===t&&e.deviceId).sort((e,t)=>a(t)-a(e)).map((e,a)=>({deviceId:e.deviceId,label:e.label||"".concat("audioinput"===t?"Microphone":"Camera"," ").concat(a+1)}))}function tR(e){let{children:t}=e,[a,s]=(0,n.useState)("checking"),[l,o]=(0,n.useState)([]),[i,d]=(0,n.useState)([]),[c,u]=(0,n.useState)([]),[m,p]=(0,n.useState)(""),[x,h]=(0,n.useState)(""),[g,b]=(0,n.useState)(""),[v,f]=(0,n.useState)(""),w=(0,n.useCallback)(async()=>{var e;let t,a;if(window.localStorage.getItem(tC)!==tS&&(window.localStorage.removeItem(t_),window.localStorage.removeItem(tN),window.localStorage.removeItem(tk),window.localStorage.setItem(tC,tS),tA("hardware_profile","reset",tS)),tA("hardware_check","started","secure=".concat(window.isSecureContext)),s("checking"),f(""),!(null==(e=navigator.mediaDevices)?void 0:e.getUserMedia)||!window.isSecureContext){f("Camera and microphone require this kiosk to use HTTPS."),tA("hardware_check","blocked","mediaDevices/getUserMedia unavailable or insecure context"),s("error");return}try{t=await Promise.race([navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),new Promise((e,t)=>window.setTimeout(()=>t(Error("Microphone permission timed out. Check browser policy and reconnect the USB audio device.")),12e3))]);try{a=await Promise.race([navigator.mediaDevices.getUserMedia({audio:!1,video:!0}),new Promise((e,t)=>window.setTimeout(()=>t(Error("Camera check timed out.")),8e3))])}catch(e){console.warn("[HardwareDeviceGate] Camera unavailable; continuing audio-first session",e)}let e=await navigator.mediaDevices.enumerateDevices(),r=tz(e,"audioinput",tO).filter(t=>tO(e.find(e=>e.deviceId===t.deviceId))>-50),n=tz(e,"videoinput",tL).filter(t=>tL(e.find(e=>e.deviceId===t.deviceId))>-50),l=e.filter(e=>"audiooutput"===e.kind&&e.deviceId).sort((e,t)=>tM(t)-tM(e));if(!r.length)throw Error("Missing microphone hardware.");let i=new URLSearchParams(window.location.search).get("device_id")||"",c=null;if(i)try{let e=await fetch("/api/kiosk-hardware?device_id=".concat(encodeURIComponent(i)),{cache:"no-store"});e.ok&&(c=(await e.json()).hardware)}catch(e){}let m=window.localStorage.getItem(t_)||"",x=window.localStorage.getItem(tN)||"",g=window.localStorage.getItem(tk)||"",v=(null==c?void 0:c.desired)||{},f=(e,t,a)=>{var s;return e.some(e=>e.deviceId===t)?t:e.some(e=>e.deviceId===a)?a:(null==(s=e[0])?void 0:s.deviceId)||""},w=f(r,v.audioinput||"",m),y=f(n,v.videoinput||"",x),j=f(l,v.audiooutput||"",g);o(r),d(n),u(l.map((e,t)=>({deviceId:e.deviceId,label:e.label||"Speaker ".concat(t+1)}))),p(w),h(y),b(j);let _=m===w&&(!n.length||x===y),N="1"===new URLSearchParams(window.location.search).get("hardware_autobind");if(_||N||1===r.length&&n.length<=1){window.localStorage.setItem(t_,w),y&&window.localStorage.setItem(tN,y),j&&window.localStorage.setItem(tk,j);let e=Number((null==c?void 0:c.revision)||0);window.localStorage.setItem(tT,String(e)),s("ready"),tA("hardware_check","ready","microphones=".concat(r.length,";cameras=").concat(n.length,";outputs=").concat(l.length,";output=").concat(j||"system-default"))}else s("selecting"),tA("hardware_check","selecting","microphones=".concat(r.length,";cameras=").concat(n.length));i&&fetch("/api/kiosk-hardware",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_id:i,devices:e.filter(e=>e.deviceId).map(e=>({deviceId:e.deviceId,kind:e.kind,label:e.label})),selected:{audioinput:w,videoinput:y,audiooutput:j},applied_revision:Number((null==c?void 0:c.revision)||0),secure:window.isSecureContext})}).catch(()=>void 0)}catch(t){let e=t instanceof Error?t.message:"Camera or microphone permission failed.";f(e),s("error"),tA("hardware_check","error",e)}finally{null==t||t.getTracks().forEach(e=>e.stop()),null==a||a.getTracks().forEach(e=>e.stop())}},[]);(0,n.useEffect)(()=>{w()},[w]),(0,n.useEffect)(()=>{if("ready"!==a)return;let e=new URLSearchParams(window.location.search).get("device_id")||"";if(!e)return;let t=!1,s=async()=>{if(!t){t=!0;try{let t=await fetch("/api/kiosk-hardware?device_id=".concat(encodeURIComponent(e)),{cache:"no-store"});if(!t.ok)return;let a=(await t.json()).hardware,s=Number((null==a?void 0:a.revision)||0),r=Number(window.localStorage.getItem(tT)||0);if(s<=r||!(null==a?void 0:a.desired))return;let n=a.desired;n.audioinput&&window.localStorage.setItem(t_,n.audioinput),n.videoinput&&window.localStorage.setItem(tN,n.videoinput),n.audiooutput&&window.localStorage.setItem(tk,n.audiooutput),window.localStorage.setItem(tT,String(s)),window.location.reload()}finally{t=!1}}},r=window.setInterval(()=>void s(),3e3);return()=>window.clearInterval(r)},[a]),(0,n.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get("device_id")||"";if(!e)return;let t=!1,a=async()=>{if(!t){t=!0;try{let t=await fetch("/api/robopark/devices/".concat(encodeURIComponent(e),"/control"),{cache:"no-store"});if(!t.ok)return;let r=(await t.json()).control||{},n=Number(r.revision||0);if(n>Number(window.localStorage.getItem(tE)||-1)){var a,s;let e=Math.max(0,Math.min(100,Number(null!=(a=r.volume_percent)?a:100)));window.localStorage.setItem("robopark:playback-volume-percent",String(e)),window.localStorage.setItem(tE,String(n)),window.dispatchEvent(new CustomEvent("robopark:playback-volume",{detail:{volume_percent:e}}));let t={mic_gain_percent:Math.max(0,Math.min(200,Number(null!=(s=r.mic_gain_percent)?s:100))),echo_cancellation:!1!==r.echo_cancellation,noise_suppression:!1!==r.noise_suppression,auto_gain_control:!0===r.auto_gain_control};window.localStorage.setItem("robopark:microphone-processing",JSON.stringify(t)),window.dispatchEvent(new CustomEvent("robopark:microphone-processing",{detail:t}))}let l=Number(r.restart_revision||0);if(l>Number(window.localStorage.getItem(tP)||0)){window.localStorage.setItem(tP,String(l)),tA("remote_restart","applying","revision=".concat(l));let e=new URL(window.location.href);e.searchParams.set("_restart",String(Date.now())),window.location.replace(e.toString())}let o=Number(r.camera_recovery_revision||0);o>Number(window.localStorage.getItem(tI)||0)&&(window.localStorage.setItem(tI,String(o)),tA("camera_recovery","applying","revision=".concat(o)),window.dispatchEvent(new CustomEvent("robopark:recover-camera",{detail:{revision:o}})))}catch(e){}finally{t=!1}}};a();let s=window.setInterval(()=>void a(),2e3);return()=>window.clearInterval(s)},[]);let y=async()=>{if(!m)return;window.localStorage.setItem(t_,m),x&&window.localStorage.setItem(tN,x),g&&window.localStorage.setItem(tk,g);let e=new URLSearchParams(window.location.search).get("device_id")||"";if(e){let a=await fetch("/api/kiosk-hardware",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_id:e,selection:{audioinput:m,videoinput:x,audiooutput:g}})});if(a.ok){var t;let e=await a.json();window.localStorage.setItem(tT,String((null==(t=e.hardware)?void 0:t.revision)||0))}}s("ready")};return"ready"===a?t:(0,r.jsx)("div",{className:"fixed inset-0 z-[210] grid place-items-center bg-black/90 p-4 backdrop-blur-xl",children:(0,r.jsxs)("div",{className:"w-full max-w-xl rounded-3xl border border-amber-300/25 bg-[#0c0b08] p-7 shadow-2xl shadow-amber-500/10",children:[(0,r.jsx)("p",{className:"font-mono text-[10px] uppercase tracking-[0.28em] text-amber-300/65",children:"Production hardware check"}),(0,r.jsx)("h2",{className:"mt-3 text-2xl font-semibold text-white",children:"Camera and microphone"}),"checking"===a&&(0,r.jsxs)("div",{className:"flex items-center gap-3 py-10 text-amber-100/75",children:[(0,r.jsx)(eM.N,{className:"size-5 animate-spin"})," Requesting permissions and detecting hardware…"]}),"error"===a&&(0,r.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,r.jsx)("p",{className:"rounded-xl border border-red-400/20 bg-red-950/20 p-4 text-sm text-red-200",children:v}),(0,r.jsx)("button",{onClick:()=>void w(),className:"rounded-xl bg-amber-300 px-5 py-3 font-semibold text-black",children:"Retry hardware check"})]}),"selecting"===a&&(0,r.jsxs)("div",{className:"mt-6 space-y-5",children:[(0,r.jsx)("p",{className:"text-sm text-white/55",children:"Select the physical devices for this robot. The choices are saved in this kiosk profile and applied before LiveKit publishes any tracks."}),(0,r.jsxs)("label",{className:"block space-y-2",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm text-amber-100",children:[(0,r.jsx)(L.t,{})," Microphone"]}),(0,r.jsx)("select",{value:m,onChange:e=>p(e.target.value),className:"w-full rounded-xl border border-white/10 bg-black px-4 py-3 text-white",children:l.map(e=>(0,r.jsx)("option",{value:e.deviceId,children:e.label},e.deviceId))})]}),(0,r.jsxs)("label",{className:"block space-y-2",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm text-amber-100",children:[(0,r.jsx)(z.n,{})," Camera"]}),(0,r.jsx)("select",{value:x,onChange:e=>h(e.target.value),className:"w-full rounded-xl border border-white/10 bg-black px-4 py-3 text-white",children:i.map(e=>(0,r.jsx)("option",{value:e.deviceId,children:e.label},e.deviceId))})]}),(0,r.jsxs)("label",{className:"block space-y-2",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm text-amber-100",children:[(0,r.jsx)(eQ.o,{})," Speaker"]}),(0,r.jsx)("select",{value:g,onChange:e=>b(e.target.value),className:"w-full rounded-xl border border-white/10 bg-black px-4 py-3 text-white",children:c.map(e=>(0,r.jsx)("option",{value:e.deviceId,children:e.label},e.deviceId))})]}),(0,r.jsx)("button",{onClick:()=>void y(),className:"w-full rounded-xl bg-amber-300 px-5 py-3 font-semibold text-black",children:"Save devices and join session"})]})]})})}var tD=a(5704);let tq=null!=(s=tD.env.NEXT_PUBLIC_PORCUPINE_ACCESS_KEY)?s:"";function tF(){ty({enabled:!1});let e=(0,d.f)();return(0,n.useEffect)(()=>{if(!e)return;let t=(e,t,a,s)=>{if("mcp_error"===s)try{var n;let t=new TextDecoder,a=JSON.parse(t.decode(e));"mcp_error"===a.type&&Array.isArray(a.errors)&&(n={title:"Connection Error",description:(0,r.jsx)("ul",{className:"list-inside list-disc",children:a.errors.map((e,t)=>(0,r.jsx)("li",{children:e},t))})},ti.oR.custom(e=>(0,r.jsx)(tw,{id:e,title:n.title,description:n.description}),{duration:1e4}))}catch(e){console.error("[useConnectionErrors] Failed to parse error:",e)}};return e.on(l.u9.DataReceived,t),()=>{e.off(l.u9.DataReceived,t)}},[e]),null}function tU(e){let{appConfig:t}=e,[a,s]=(0,n.useState)(null);(0,n.useEffect)(()=>{(async()=>{try{var e;let t=await fetch("/api/setup/status"),a=await t.json();s(null!=(e=a.completed)&&e)}catch(e){s(!1)}})()},[]);let d=(0,n.useMemo)(()=>"string"==typeof tD.env.NEXT_PUBLIC_CONN_DETAILS_ENDPOINT?(0,p.Eq)(t):l.xX.endpoint("/api/connection-details"),[t]),u=(0,n.useMemo)(()=>{let e=new l.Wv,t=e.connect.bind(e);return e.connect=async(e,a,s)=>{var r;let n=[];try{let e=await fetch("/api/turn-credentials");e.ok&&(n=(await e.json()).iceServers||[],console.log("[TURN] Loaded",n.length,"ICE servers for cross-network relay"))}catch(e){console.warn("[TURN] Failed to fetch TURN credentials, using defaults:",e)}return t(e,a,{...s,rtcConfig:{...(null==s?void 0:s.rtcConfig)||{},iceServers:[...(null==s||null==(r=s.rtcConfig)?void 0:r.iceServers)||[],...n]}})},e},[]),m=(0,o.a3)(d,{room:u,...t.agentName?{agentName:t.agentName}:{}});(0,n.useEffect)(()=>{let e=()=>{m.end()};return window.addEventListener("beforeunload",e),window.addEventListener("pagehide",e),()=>{window.removeEventListener("beforeunload",e),window.removeEventListener("pagehide",e)}},[m]);let x=(0,n.useCallback)(async()=>{var e,t,a,s;console.log("[App] Wake word detected");let r=null==(e=Array.from((null==(a=m.room)||null==(t=a.localParticipant)?void 0:t.audioTrackPublications.values())||[]).find(e=>"microphone"===e.source))?void 0:e.track;r&&r.isMuted&&(console.log("[App] Unmuting microphone"),await r.unmute());try{let e=await fetch("/api/wake",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({room_name:null==(s=m.room)?void 0:s.name})});e.ok||console.error("[App] Wake endpoint failed:",e.status)}catch(e){console.error("[App] Wake endpoint error:",e)}},[m]);return null===a?(0,r.jsx)("main",{className:"grid h-svh grid-cols-1 place-content-center",children:(0,r.jsx)("div",{className:"text-muted-foreground text-center",children:"Loading..."})}):a?(0,r.jsx)(eu.Z,{children:(0,r.jsx)(tj,{children:(0,r.jsx)(tR,{children:(0,r.jsx)(i.z,{session:m,children:(0,r.jsxs)(tl,{accessKey:tq,keywordPath:"/hey_cal.ppn",onWakeWordDetected:x,defaultEnabled:!1,children:[(0,r.jsx)(tF,{}),(0,r.jsx)("main",{className:"grid h-svh grid-cols-1 place-content-center",children:(0,r.jsx)(ta,{appConfig:t})}),(0,r.jsx)(i.q,{label:"Start Audio"}),(0,r.jsx)(c,{}),(0,r.jsx)(tc,{}),(0,r.jsxs)("a",{href:"/robopark",className:"fixed bottom-4 left-4 z-50 flex items-center gap-2 px-4 py-2 bg-gray-800/90 hover:bg-gray-700 text-white text-sm rounded-full shadow-lg transition-all border border-gray-700 hover:border-gray-600",children:[(0,r.jsx)("span",{children:"\uD83E\uDD16"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"RoboPark"})]})]})})})})}):(0,r.jsx)(th,{onComplete:()=>{s(!0),window.location.reload()}})}},6141:(e,t,a)=>{Promise.resolve().then(a.bind(a,5945))},7091:(e,t,a)=>{"use strict";a.d(t,{cn:()=>u,Eq:()=>m});var s=a(2115),r=a(2821),n=a(3094),l=a(5889);let o={companyName:"RoboPark",pageTitle:"RoboPark Test Interface",pageDescription:"Voice control bay for RoboPark units",supportsChatInput:!0,supportsVideoInput:!0,supportsScreenShare:!0,isPreConnectBufferEnabled:!0,logo:"/cwl-logo-round.png",accent:"#3b82f6",logoDark:"/cwl-logo-round.png",accentDark:"#60a5fa",startButtonText:"Initialize Session",sandboxId:void 0,agentName:void 0};var i=a(5704);let d=i.env.NEXT_PUBLIC_APP_CONFIG_ENDPOINT,c=i.env.SANDBOX_ID;function u(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,l.QP)((0,r.$)(t))}function m(e){return n.xX.custom(async()=>{var t;let a=new URL(i.env.NEXT_PUBLIC_CONN_DETAILS_ENDPOINT,window.location.origin),s=null!=(t=e.sandboxId)?t:"",r=e.agentName?{agents:[{agent_name:e.agentName}]}:void 0;try{let e=await fetch(a.toString(),{method:"POST",headers:{"Content-Type":"application/json","X-Sandbox-Id":s},body:JSON.stringify({room_config:r})});return await e.json()}catch(e){throw console.error("Error fetching connection details:",e),Error("Error fetching connection details!")}})}(0,s.cache)(async e=>{if(d){var t;let a=null!=(t=null!=c?c:e.get("x-sandbox-id"))?t:"";try{if(!a)throw Error("Sandbox ID is required");let e=await fetch(d,{cache:"no-store",headers:{"X-Sandbox-ID":a}});if(e.ok){let t=await e.json(),s={...o,sandboxId:a};for(let[e,a]of Object.entries(t))null!==a&&(e in o&&void 0===o[e]||typeof s[e]===a.type&&typeof s[e]==typeof a.value)&&(s[e]=a.value);return s}console.error("ERROR: querying config endpoint failed with status ".concat(e.status,": ").concat(e.statusText))}catch(e){console.error("ERROR: getAppConfig() - lib/utils.ts",e)}}return o})},9064:(e,t,a)=>{"use strict";a.d(t,{a:()=>r,o:()=>s});let s={id:"default",name:"Cal",description:"Default assistant",system_prompt:"You are a helpful AI assistant.",wake_word_model:"models/hey_jarvis.onnx",tts_provider:"kokoro",tts_voice_kokoro:"am_puck",tts_voice_piper:"speaches-ai/piper-en_US-ryan-high",tts_voice_elevenlabs:"21m00Tcm4TlvDq8ikWAM",tts_speed:1},r={first_launch_completed:!1,characters:[s],active_character_id:"default",device_registry:{},stt_provider:"speaches",stt_language:"auto",stt_model_speaches:"Systran/faster-whisper-small",stt_model_groq:"whisper-large-v3-turbo",llm_provider:"ollama",ollama_host:"http://localhost:11434",ollama_model:"",groq_api_key:"",groq_model:"",gemini_api_key:"",gemini_model:"gemini-1.5-flash",elevenlabs_api_key:"",elevenlabs_model_id:"eleven_v3",elevenlabs_encoding:"mp3_44100_128",elevenlabs_language:"",elevenlabs_stability:.5,elevenlabs_similarity_boost:.75,elevenlabs_style:0,elevenlabs_speaker_boost:!0,hass_enabled:!1,hass_host:"",hass_token:"",n8n_enabled:!1,n8n_url:"",n8n_token:"",wake_word_enabled:!0,wake_word_threshold:.5,wake_word_timeout:3,allow_interruptions:!0,min_endpointing_delay:.5,vision_provider:"ollama_cloud",vision_model_ollama:"gemma4:e4b",vision_model_ollama_cloud:"gemma4:cloud",ollama_cloud_api_key:"",vision_model_groq:"meta-llama/llama-4-scout-17b-16e-instruct",vision_terminal:!0,always_on_session_enabled:!1,motion_greeting:"שלום! איך אפשר לעזור?",motion_threshold:.06,motion_cooldown_seconds:10,temperature:.7,num_ctx:8192,max_turns:20,tool_cache_size:3}}},e=>{e.O(0,[7501,392,5054,9880,2333,8441,1255,7358],()=>e(e.s=6141)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9492],{4585:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"styles",{enumerable:!0,get:function(){return l}});let l={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},desc:{display:"inline-block"},h1:{display:"inline-block",margin:"0 20px 0 0",padding:"0 23px 0 0",fontSize:24,fontWeight:500,verticalAlign:"top",lineHeight:"49px"},h2:{fontSize:14,fontWeight:400,lineHeight:"49px",margin:0}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6848:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/_not-found/page",function(){return l(9520)}])},8886:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"HTTPAccessErrorFallback",{enumerable:!0,get:function(){return o}});let r=l(5155),n=l(4585);function o(e){let{status:t,message:l}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:t+": "+l}),(0,r.jsx)("div",{style:n.styles.error,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}),(0,r.jsx)("h1",{className:"next-error-h1",style:n.styles.h1,children:t}),(0,r.jsx)("div",{style:n.styles.desc,children:(0,r.jsx)("h2",{style:n.styles.h2,children:l})})]})})]})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},9520:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let r=l(5155),n=l(8886),o=function(){return(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)(n.HTTPAccessErrorFallback,{status:404,message:"This page could not be found."})})})};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=6848)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{1901:e=>{e.exports={style:{fontFamily:"'commitMono', 'commitMono Fallback'"},className:"__className_b9b7d3",variable:"__variable_b9b7d3"}},2180:(e,t,o)=>{"use strict";o.d(t,{Bc:()=>s,m_:()=>u});var a=o(5155),r=o(2115),n=o(2990),i=o(7091);let s=n.Kq,l=n.bL,d=n.l9,c=r.forwardRef((e,t)=>{let{className:o,sideOffset:r=4,...s}=e;return(0,a.jsx)(n.ZL,{children:(0,a.jsx)(n.UC,{ref:t,sideOffset:r,className:(0,i.cn)("bg-primary text-primary-foreground z-50 overflow-hidden rounded-md px-3 py-1.5 text-xs","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",o),...s})})});function u(e){let{children:t,content:o,side:r="top",delayDuration:n=300}=e;return(0,a.jsxs)(l,{delayDuration:n,children:[(0,a.jsx)(d,{asChild:!0,children:t}),(0,a.jsx)(c,{side:r,children:o})]})}c.displayName=n.UC.displayName},2193:(e,t,o)=>{Promise.resolve().then(o.bind(o,5233)),Promise.resolve().then(o.t.bind(o,5757,23)),Promise.resolve().then(o.t.bind(o,1901,23)),Promise.resolve().then(o.t.bind(o,3677,23))},3677:()=>{},5233:(e,t,o)=>{"use strict";o.d(t,{ThemeProvider:()=>i});var a=o(5155);o(2115);var r=o(5379),n=o(2180);function i(e){let{children:t,...o}=e;return(0,a.jsx)(r.N,{...o,children:(0,a.jsx)(n.Bc,{delayDuration:300,children:t})})}},5757:e=>{e.exports={style:{fontFamily:"'Public Sans', 'Public Sans Fallback'",fontStyle:"normal"},className:"__className_3a41d0",variable:"__variable_3a41d0"}},7091:(e,t,o)=>{"use strict";o.d(t,{cn:()=>u,Eq:()=>f});var a=o(2115),r=o(2821),n=o(3094),i=o(5889);let s={companyName:"RoboPark",pageTitle:"RoboPark Test Interface",pageDescription:"Voice control bay for RoboPark units",supportsChatInput:!0,supportsVideoInput:!0,supportsScreenShare:!0,isPreConnectBufferEnabled:!0,logo:"/cwl-logo-round.png",accent:"#3b82f6",logoDark:"/cwl-logo-round.png",accentDark:"#60a5fa",startButtonText:"Initialize Session",sandboxId:void 0,agentName:void 0};var l=o(5704);let d=l.env.NEXT_PUBLIC_APP_CONFIG_ENDPOINT,c=l.env.SANDBOX_ID;function u(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return(0,i.QP)((0,r.$)(t))}function f(e){return n.xX.custom(async()=>{var t;let o=new URL(l.env.NEXT_PUBLIC_CONN_DETAILS_ENDPOINT,window.location.origin),a=null!=(t=e.sandboxId)?t:"",r=e.agentName?{agents:[{agent_name:e.agentName}]}:void 0;try{let e=await fetch(o.toString(),{method:"POST",headers:{"Content-Type":"application/json","X-Sandbox-Id":a},body:JSON.stringify({room_config:r})});return await e.json()}catch(e){throw console.error("Error fetching connection details:",e),Error("Error fetching connection details!")}})}(0,a.cache)(async e=>{if(d){var t;let o=null!=(t=null!=c?c:e.get("x-sandbox-id"))?t:"";try{if(!o)throw Error("Sandbox ID is required");let e=await fetch(d,{cache:"no-store",headers:{"X-Sandbox-ID":o}});if(e.ok){let t=await e.json(),a={...s,sandboxId:o};for(let[e,o]of Object.entries(t))null!==o&&(e in s&&void 0===s[e]||typeof a[e]===o.type&&typeof a[e]==typeof o.value)&&(a[e]=o.value);return a}console.error("ERROR: querying config endpoint failed with status ".concat(e.status,": ").concat(e.statusText))}catch(e){console.error("ERROR: getAppConfig() - lib/utils.ts",e)}}return s})}},e=>{e.O(0,[7338,6138,7501,9880,8441,1255,7358],()=>e(e.s=2193)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4461],{1128:(e,t,a)=>{Promise.resolve().then(a.bind(a,6960))},3701:(e,t,a)=>{"use strict";a.d(t,{N:()=>i});var l=a(2115),s=a(7065),r=a(4413);let n=l.forwardRef((e,t)=>l.createElement(s.A,{ref:t,...e,weights:r.A}));n.displayName="CircleNotchIcon";let i=n},4413:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var l=a(2115);let s=new Map([["bold",l.createElement(l.Fragment,null,l.createElement("path",{d:"M236,128a108,108,0,0,1-216,0c0-42.52,24.73-81.34,63-98.9A12,12,0,1,1,93,50.91C63.24,64.57,44,94.83,44,128a84,84,0,0,0,168,0c0-33.17-19.24-63.43-49-77.09A12,12,0,1,1,173,29.1C211.27,46.66,236,85.48,236,128Z"}))],["duotone",l.createElement(l.Fragment,null,l.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),l.createElement("path",{d:"M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z"}))],["fill",l.createElement(l.Fragment,null,l.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,176A72,72,0,0,1,92,65.64a8,8,0,0,1,8,13.85,56,56,0,1,0,56,0,8,8,0,0,1,8-13.85A72,72,0,0,1,128,200Z"}))],["light",l.createElement(l.Fragment,null,l.createElement("path",{d:"M230,128a102,102,0,0,1-204,0c0-40.18,23.35-76.86,59.5-93.45a6,6,0,0,1,5,10.9C58.61,60.09,38,92.49,38,128a90,90,0,0,0,180,0c0-35.51-20.61-67.91-52.5-82.55a6,6,0,0,1,5-10.9C206.65,51.14,230,87.82,230,128Z"}))],["regular",l.createElement(l.Fragment,null,l.createElement("path",{d:"M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z"}))],["thin",l.createElement(l.Fragment,null,l.createElement("path",{d:"M228,128a100,100,0,0,1-200,0c0-39.4,22.9-75.37,58.33-91.63a4,4,0,1,1,3.34,7.27C57.07,58.6,36,91.71,36,128a92,92,0,0,0,184,0c0-36.29-21.07-69.4-53.67-84.36a4,4,0,1,1,3.34-7.27C205.1,52.63,228,88.6,228,128Z"}))]])},4601:(e,t,a)=>{"use strict";a.d(t,{Z:()=>i,t:()=>o});var l=a(5155),s=a(2115),r=a(9064);let n=(0,s.createContext)(null);function i(e){let{children:t}=e,[a,i]=(0,s.useState)(r.a),[o,c]=(0,s.useState)(!0),[d,m]=(0,s.useState)(null),h=(0,s.useCallback)(async()=>{c(!0),m(null);try{let e=await fetch("/api/settings");if(e.ok){let t=(await e.json()).settings||r.a;t.characters&&0!==t.characters.length||(t.characters=[r.o],t.active_character_id=r.o.id),i(t)}else i(r.a)}catch(e){console.error("Failed to load settings:",e),m("Failed to load settings")}finally{c(!1)}},[]);(0,s.useEffect)(()=>{h()},[h]);let u=async e=>{try{if(i(e),!(await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:e})})).ok)throw Error("Failed to save settings")}catch(e){throw console.error("Failed to update settings:",e),m("Failed to save settings"),h(),e}},_=async e=>{let t={...a,active_character_id:e};await u(t)},v=a.characters.find(e=>e.id===a.active_character_id)||a.characters[0]||r.o;return(0,l.jsx)(n.Provider,{value:{settings:a,activeCharacter:v,loading:o,error:d,updateSettings:u,setActiveCharacterId:_,reloadSettings:h},children:t})}function o(){let e=(0,s.useContext)(n);if(!e)throw Error("useSettings must be used within a SettingsProvider");return e}},6960:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>d});var l=a(5155),s=a(2115),r=a(4601),n=a(3701),i=a(7065);let o=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M234.49,111.07,90.41,22.94A20,20,0,0,0,60,39.87V216.13a20,20,0,0,0,30.41,16.93l144.08-88.13a19.82,19.82,0,0,0,0-33.86ZM84,208.85V47.15L216.16,128Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M228.23,134.69,84.15,222.81A8,8,0,0,1,72,216.12V39.88a8,8,0,0,1,12.15-6.69l144.08,88.12A7.82,7.82,0,0,1,228.23,134.69Z",opacity:"0.2"}),s.createElement("path",{d:"M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M231.36,116.19,87.28,28.06a14,14,0,0,0-14.18-.27A13.69,13.69,0,0,0,66,39.87V216.13a13.69,13.69,0,0,0,7.1,12.08,14,14,0,0,0,14.18-.27l144.08-88.13a13.82,13.82,0,0,0,0-23.62Zm-6.26,13.38L81,217.7a2,2,0,0,1-2.06,0,1.78,1.78,0,0,1-1-1.61V39.87a1.78,1.78,0,0,1,1-1.61A2.06,2.06,0,0,1,80,38a2,2,0,0,1,1,.31L225.1,126.43a1.82,1.82,0,0,1,0,3.14Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M230.32,117.9,86.24,29.79a11.91,11.91,0,0,0-12.17-.23A11.71,11.71,0,0,0,68,39.89V216.11a11.71,11.71,0,0,0,6.07,10.33,11.91,11.91,0,0,0,12.17-.23L230.32,138.1a11.82,11.82,0,0,0,0-20.2Zm-4.18,13.37L82.06,219.39a4,4,0,0,1-4.07.07,3.77,3.77,0,0,1-2-3.35V39.89a3.77,3.77,0,0,1,2-3.35,4,4,0,0,1,4.07.07l144.08,88.12a3.8,3.8,0,0,1,0,6.54Z"}))]]),c=s.forwardRef((e,t)=>s.createElement(i.A,{ref:t,...e,weights:o}));function d(){return(0,l.jsx)(r.Z,{children:(0,l.jsx)(m,{})})}function m(){var e,t;let{settings:a}=(0,r.t)(),i=(null==(e=a.characters)?void 0:e.find(e=>e.id===a.active_character_id))||(null==(t=a.characters)?void 0:t[0]),[o,d]=(0,s.useState)("Hello! This is a test of my voice with the selected model."),[m,h]=(0,s.useState)(""),[u,_]=(0,s.useState)(""),[v,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[f,w]=(0,s.useState)(null),[x,y]=(0,s.useState)("");(0,s.useEffect)(()=>{if(a.elevenlabs_api_key&&!x&&y(a.elevenlabs_api_key),!m){let e=localStorage.getItem("tester_voice_id");e?h(e):(null==i?void 0:i.tts_voice_elevenlabs)?h(i.tts_voice_elevenlabs):h("21m00Tcm4TlvDq8ikWAM")}if(!u){let e=localStorage.getItem("tester_model_id");e?_(e):a.elevenlabs_model_id?_(a.elevenlabs_model_id):_("eleven_v3")}},[a.elevenlabs_api_key,i,a.elevenlabs_model_id,x,m,u]),(0,s.useEffect)(()=>{m&&localStorage.setItem("tester_voice_id",m)},[m]),(0,s.useEffect)(()=>{u&&localStorage.setItem("tester_model_id",u)},[u]);let E=async()=>{let e=x||a.elevenlabs_api_key;if(!e)return void w("Please enter an ElevenLabs API Key.");p(!0),w(null),b(null);try{let t=await fetch("/api/test-tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:"elevenlabs",text:o,voice_id:m,model_id:u,api_key:e})});if(!t.ok){let e=await t.json();throw Error(e.details||e.error||"Generation failed")}let a=await t.blob(),l=URL.createObjectURL(a);b(l)}catch(e){w(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,l.jsx)("div",{className:"min-h-screen bg-black text-white p-8 font-sans",children:(0,l.jsxs)("div",{className:"max-w-2xl mx-auto space-y-8",children:[(0,l.jsxs)("header",{className:"border-b border-white/10 pb-6",children:[(0,l.jsx)("h1",{className:"text-3xl font-light tracking-tight",children:"ElevenLabs Voice Tester"}),(0,l.jsx)("p",{className:"text-white/50 mt-2",children:"Compare models and voices directly."})]}),(0,l.jsxs)("div",{className:"space-y-6 bg-white/5 p-6 rounded-2xl border border-white/10",children:[(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-white/70",children:"API Key"}),(0,l.jsx)("input",{type:"password",value:x,onChange:e=>y(e.target.value),className:"w-full bg-black/50 border border-white/10 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-white/20 font-mono",placeholder:"sk_..."})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-white/70",children:"Voice ID"}),(0,l.jsx)("input",{type:"text",value:m,onChange:e=>h(e.target.value),className:"w-full bg-black/50 border border-white/10 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-white/20",placeholder:"e.g. 21m00Tcm4TlvDq8ikWAM"})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-white/70",children:"Model"}),(0,l.jsxs)("select",{value:u,onChange:e=>_(e.target.value),className:"w-full bg-black/50 border border-white/10 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-white/20 appearance-none",children:[(0,l.jsx)("option",{value:"eleven_multilingual_v2",children:"Multilingual v2"}),(0,l.jsx)("option",{value:"eleven_turbo_v2_5",children:"Turbo v2.5"}),(0,l.jsx)("option",{value:"eleven_v3",children:"Eleven v3 (Alpha)"}),(0,l.jsx)("option",{value:"eleven_flash_v2_5",children:"Flash v2.5"}),(0,l.jsx)("option",{value:"eleven_flash_v2",children:"Flash v2"})]})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-white/70",children:"Text"}),(0,l.jsx)("textarea",{value:o,onChange:e=>d(e.target.value),rows:4,className:"w-full bg-black/50 border border-white/10 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-white/20 resize-none"})]}),f&&(0,l.jsx)("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm",children:f}),(0,l.jsxs)("div",{className:"flex items-center gap-4 pt-4 border-t border-white/10",children:[(0,l.jsxs)("button",{onClick:E,disabled:v,className:"flex items-center gap-2 px-6 py-3 bg-white text-black rounded-full font-medium hover:bg-white/90 disabled:opacity-50 transition-all",children:[v?(0,l.jsx)(n.N,{className:"animate-spin w-5 h-5"}):(0,l.jsx)(c,{weight:"fill",className:"w-5 h-5"}),v?"Generating...":"Generate Audio"]}),g&&(0,l.jsx)("audio",{controls:!0,autoPlay:!0,src:g,className:"flex-1 h-10"})]})]}),(0,l.jsx)("div",{className:"text-xs text-white/30 text-center",children:"Note: This uses the API Key saved in your Settings panel by default."})]})})}c.displayName="PlayIcon"},7065:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var l=a(2115);let s=l.forwardRef((e,t)=>{let{alt:a,color:s="currentColor",size:r="1em",weight:n="regular",mirrored:i=!1,children:o,weights:c,...d}=e;return l.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,fill:s,viewBox:"0 0 256 256",transform:i?"scale(-1, 1)":void 0,...d},!!a&&l.createElement("title",null,a),o,c.get(n))});s.displayName="SSRBase"},9064:(e,t,a)=>{"use strict";a.d(t,{a:()=>s,o:()=>l});let l={id:"default",name:"Cal",description:"Default assistant",system_prompt:"You are a helpful AI assistant.",wake_word_model:"models/hey_jarvis.onnx",tts_provider:"kokoro",tts_voice_kokoro:"am_puck",tts_voice_piper:"speaches-ai/piper-en_US-ryan-high",tts_voice_elevenlabs:"21m00Tcm4TlvDq8ikWAM",tts_speed:1},s={first_launch_completed:!1,characters:[l],active_character_id:"default",device_registry:{},stt_provider:"speaches",stt_language:"auto",stt_model_speaches:"Systran/faster-whisper-small",stt_model_groq:"whisper-large-v3-turbo",llm_provider:"ollama",ollama_host:"http://localhost:11434",ollama_model:"",groq_api_key:"",groq_model:"",gemini_api_key:"",gemini_model:"gemini-1.5-flash",elevenlabs_api_key:"",elevenlabs_model_id:"eleven_v3",elevenlabs_encoding:"mp3_44100_128",elevenlabs_language:"",elevenlabs_stability:.5,elevenlabs_similarity_boost:.75,elevenlabs_style:0,elevenlabs_speaker_boost:!0,hass_enabled:!1,hass_host:"",hass_token:"",n8n_enabled:!1,n8n_url:"",n8n_token:"",wake_word_enabled:!0,wake_word_threshold:.5,wake_word_timeout:3,allow_interruptions:!0,min_endpointing_delay:.5,vision_provider:"ollama_cloud",vision_model_ollama:"gemma4:e4b",vision_model_ollama_cloud:"gemma4:cloud",ollama_cloud_api_key:"",vision_model_groq:"meta-llama/llama-4-scout-17b-16e-instruct",vision_terminal:!0,always_on_session_enabled:!1,motion_greeting:"שלום! איך אפשר לעזור?",motion_threshold:.06,motion_cooldown_seconds:10,temperature:.7,num_ctx:8192,max_turns:20,tool_cache_size:3}}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=1128)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7358],{5673:(e,s,n)=>{Promise.resolve().then(n.t.bind(n,7150,23)),Promise.resolve().then(n.t.bind(n,1959,23)),Promise.resolve().then(n.t.bind(n,7989,23)),Promise.resolve().then(n.t.bind(n,3886,23)),Promise.resolve().then(n.t.bind(n,9766,23)),Promise.resolve().then(n.t.bind(n,5278,23)),Promise.resolve().then(n.t.bind(n,8924,23)),Promise.resolve().then(n.t.bind(n,4431,23)),Promise.resolve().then(n.bind(n,622))},9393:()=>{}},e=>{var s=s=>e(e.s=s);e.O(0,[8441,1255],()=>(s(1666),s(5673))),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST=function(e,a,s,r,t){return{__rewrites:{afterFiles:[{has:s,source:"/api/announce",destination:s},{has:s,source:"/api/reload-tools",destination:s},{has:s,source:"/api/wake",destination:s},{has:s,source:"/api/health",destination:s},{has:s,source:"/api/prompt",destination:s},{has:s,source:"/api/voices",destination:s},{has:s,source:"/api/models",destination:s},{has:s,source:"/api/wake-word/:path*",destination:s},{has:s,source:"/api/metrics",destination:s}],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:43,errorRate:1e-4,numBits:825,numHashes:14,bitArray:[1,1,e,e,0,0,a,e,e,a,a,a,a,e,e,a,a,e,a,a,e,e,e,a,e,e,e,a,a,e,a,e,e,a,a,e,a,a,e,e,e,a,e,e,e,a,a,a,a,e,e,a,e,a,e,e,e,a,e,e,a,e,e,e,e,e,e,a,e,a,a,e,a,a,a,a,a,a,a,a,e,e,a,a,e,e,a,a,a,a,e,e,e,e,a,a,a,a,e,a,e,e,e,e,e,a,a,e,a,a,e,e,a,a,a,a,a,e,e,e,a,e,a,a,a,e,a,e,e,a,e,e,a,e,a,e,e,a,a,e,e,a,e,a,e,e,e,e,a,e,a,e,e,a,a,a,a,e,a,e,a,a,a,e,e,e,e,e,e,a,a,e,a,e,e,a,a,a,e,e,a,e,e,a,a,e,a,a,a,a,e,e,e,e,a,e,a,a,e,e,e,e,a,a,e,e,e,e,e,e,e,e,a,e,e,e,a,e,a,a,a,e,e,e,a,e,a,a,e,a,a,e,a,a,e,a,a,a,e,a,a,a,a,a,a,e,e,a,a,e,a,e,e,a,a,a,a,e,a,e,a,a,e,e,a,e,e,e,a,a,e,a,e,a,e,e,a,a,e,a,a,e,a,e,a,a,a,a,a,e,a,e,e,e,a,a,e,e,a,e,a,a,e,e,e,e,a,e,e,e,e,a,e,e,a,a,e,e,e,a,e,a,a,a,a,a,e,e,e,a,a,e,a,a,a,e,a,e,a,e,a,a,e,a,a,e,a,e,a,e,a,e,e,e,e,a,e,e,e,e,a,e,a,e,a,a,e,e,a,e,e,e,e,a,e,e,e,a,a,e,a,e,a,e,e,e,e,e,e,e,e,a,e,a,a,a,a,e,a,e,a,a,a,a,e,e,e,e,a,e,a,e,e,e,a,a,e,e,a,a,a,a,e,e,e,e,e,a,a,a,a,e,e,e,e,e,e,a,e,e,e,e,e,a,a,e,a,a,a,e,e,a,a,e,e,e,a,e,e,a,e,e,e,a,e,a,a,a,a,a,a,a,a,e,a,e,e,a,e,a,a,e,e,e,e,a,e,a,a,a,e,a,a,a,a,a,a,a,a,e,a,e,a,e,a,e,a,e,e,e,a,e,a,e,a,e,e,e,a,a,a,a,a,a,e,a,e,e,a,a,e,a,e,a,e,e,a,a,e,a,a,e,a,a,a,a,e,e,e,e,a,e,a,a,a,e,a,e,e,e,e,a,e,e,e,a,a,e,e,e,e,a,a,e,e,e,a,a,e,e,a,e,e,e,a,e,e,e,a,a,a,a,a,e,e,a,a,a,a,e,e,e,e,e,e,a,a,a,a,a,e,a,a,a,a,e,a,a,a,e,a,e,e,a,e,e,e,e,e,a,e,e,e,a,e,e,e,a,e,e,e,e,a,e,e,e,e,a,e,a,a,a,a,a,e,a,a,e,a,e,e,a,a,a,a,e,a,e,e,a,a,a,a,a,a,a,e,e,a,e,e,e,e,a,a,e,e,e,a,e,e,a,a,e,a,e,e,e,a,e,a,e,e,e,e,a,e,e,e,a,e,e,a,a,a,a,a,e,e,a,a,e,e,a,a,a,e,e,e,a,a,e,a,a,e,e,e,a,e,a,a,e,a,a,a,e,a,e,a,a,e,e,e,a,a,a,a,e,a,e,e,e,a,e,e,a,a,a,e,a,a,e,a,e,e,e,a,a,a,a,e,e,a,a,a,a,a,e,e,e,e,e,a,a,e,a,a,e,e,e,e,e,e,e,e,e,e,e,a,a,e,a,a,a,e,e,a,a,a,a,a,a,a,a,e]},__routerFilterDynamic:{numItems:11,errorRate:1e-4,numBits:211,numHashes:14,bitArray:[a,a,a,a,a,a,a,a,a,e,a,e,a,a,e,e,a,a,a,a,e,e,e,e,a,e,e,e,e,e,a,e,e,e,e,e,a,e,e,e,a,e,e,a,e,a,e,e,a,e,a,a,e,e,e,a,e,e,a,a,a,a,e,a,e,a,a,e,a,a,e,a,a,e,a,e,e,e,e,a,a,a,a,e,e,a,a,a,e,e,e,a,a,e,e,e,e,e,e,a,e,e,e,e,a,a,a,a,e,e,a,e,a,a,e,e,a,e,a,a,a,a,e,a,a,e,e,e,a,e,a,a,e,e,e,e,a,a,a,a,e,a,a,e,a,a,e,e,a,e,a,a,e,e,a,a,e,e,a,e,e,a,e,a,e,a,a,e,a,e,e,a,a,e,e,a,e,a,e,a,e,e,a,a,a,a,e,a,a,e,a,a,e,e,a,a,e,e,e,e,e,e,e,a,a,a,a,e,e,a,a]},"/_error":["static/chunks/pages/_error-e4ba546eb376bdf4.js"],sortedPages:["/_app","/_error"]}}(1,0,void 0,1e-4,14),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1 +0,0 @@
1
- self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST=function(e,a,s,r,t){return{__rewrites:{afterFiles:[{has:s,source:"/api/announce",destination:s},{has:s,source:"/api/reload-tools",destination:s},{has:s,source:"/api/wake",destination:s},{has:s,source:"/api/health",destination:s},{has:s,source:"/api/prompt",destination:s},{has:s,source:"/api/voices",destination:s},{has:s,source:"/api/models",destination:s},{has:s,source:"/api/wake-word/:path*",destination:s},{has:s,source:"/api/metrics",destination:s}],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:43,errorRate:1e-4,numBits:825,numHashes:14,bitArray:[1,1,e,e,0,0,a,e,e,a,a,a,a,e,e,a,a,e,a,a,e,e,e,a,e,e,e,a,a,e,a,e,e,a,a,e,a,a,e,e,e,a,e,e,e,a,a,a,a,e,e,a,e,a,e,e,e,a,e,e,a,e,e,e,e,e,e,a,e,a,a,e,a,a,a,a,a,a,a,a,e,e,a,a,e,e,a,a,a,a,e,e,e,e,a,a,a,a,e,a,e,e,e,e,e,a,a,e,a,a,e,e,a,a,a,a,a,e,e,e,a,e,a,a,a,e,a,e,e,a,e,e,a,e,a,e,e,a,a,e,e,a,e,a,e,e,e,e,a,e,a,e,e,a,a,a,a,e,a,e,a,a,a,e,e,e,e,e,e,a,a,e,a,e,e,a,a,a,e,e,a,e,e,a,a,e,a,a,a,a,e,e,e,e,a,e,a,a,e,e,e,e,a,a,e,e,e,e,e,e,e,e,a,e,e,e,a,e,a,a,a,e,e,e,a,e,a,a,e,a,a,e,a,a,e,a,a,a,e,a,a,a,a,a,a,e,e,a,a,e,a,e,e,a,a,a,a,e,a,e,a,a,e,e,a,e,e,e,a,a,e,a,e,a,e,e,a,a,e,a,a,e,a,e,a,a,a,a,a,e,a,e,e,e,a,a,e,e,a,e,a,a,e,e,e,e,a,e,e,e,e,a,e,e,a,a,e,e,e,a,e,a,a,a,a,a,e,e,e,a,a,e,a,a,a,e,a,e,a,e,a,a,e,a,a,e,a,e,a,e,a,e,e,e,e,a,e,e,e,e,a,e,a,e,a,a,e,e,a,e,e,e,e,a,e,e,e,a,a,e,a,e,a,e,e,e,e,e,e,e,e,a,e,a,a,a,a,e,a,e,a,a,a,a,e,e,e,e,a,e,a,e,e,e,a,a,e,e,a,a,a,a,e,e,e,e,e,a,a,a,a,e,e,e,e,e,e,a,e,e,e,e,e,a,a,e,a,a,a,e,e,a,a,e,e,e,a,e,e,a,e,e,e,a,e,a,a,a,a,a,a,a,a,e,a,e,e,a,e,a,a,e,e,e,e,a,e,a,a,a,e,a,a,a,a,a,a,a,a,e,a,e,a,e,a,e,a,e,e,e,a,e,a,e,a,e,e,e,a,a,a,a,a,a,e,a,e,e,a,a,e,a,e,a,e,e,a,a,e,a,a,e,a,a,a,a,e,e,e,e,a,e,a,a,a,e,a,e,e,e,e,a,e,e,e,a,a,e,e,e,e,a,a,e,e,e,a,a,e,e,a,e,e,e,a,e,e,e,a,a,a,a,a,e,e,a,a,a,a,e,e,e,e,e,e,a,a,a,a,a,e,a,a,a,a,e,a,a,a,e,a,e,e,a,e,e,e,e,e,a,e,e,e,a,e,e,e,a,e,e,e,e,a,e,e,e,e,a,e,a,a,a,a,a,e,a,a,e,a,e,e,a,a,a,a,e,a,e,e,a,a,a,a,a,a,a,e,e,a,e,e,e,e,a,a,e,e,e,a,e,e,a,a,e,a,e,e,e,a,e,a,e,e,e,e,a,e,e,e,a,e,e,a,a,a,a,a,e,e,a,a,e,e,a,a,a,e,e,e,a,a,e,a,a,e,e,e,a,e,a,a,e,a,a,a,e,a,e,a,a,e,e,e,a,a,a,a,e,a,e,e,e,a,e,e,a,a,a,e,a,a,e,a,e,e,e,a,a,a,a,e,e,a,a,a,a,a,e,e,e,e,e,a,a,e,a,a,e,e,e,e,e,e,e,e,e,e,e,a,a,e,a,a,a,e,e,a,a,a,a,a,a,a,a,e]},__routerFilterDynamic:{numItems:11,errorRate:1e-4,numBits:211,numHashes:14,bitArray:[a,a,a,a,a,a,a,a,a,e,a,e,a,a,e,e,a,a,a,a,e,e,e,e,a,e,e,e,e,e,a,e,e,e,e,e,a,e,e,e,a,e,e,a,e,a,e,e,a,e,a,a,e,e,e,a,e,e,a,a,a,a,e,a,e,a,a,e,a,a,e,a,a,e,a,e,e,e,e,a,a,a,a,e,e,a,a,a,e,e,e,a,a,e,e,e,e,e,e,a,e,e,e,e,a,a,a,a,e,e,a,e,a,a,e,e,a,e,a,a,a,a,e,a,a,e,e,e,a,e,a,a,e,e,e,e,a,a,a,a,e,a,a,e,a,a,e,e,a,e,a,a,e,e,a,a,e,e,a,e,e,a,e,a,e,a,a,e,a,e,e,a,a,e,e,a,e,a,e,a,e,e,a,a,a,a,e,a,a,e,a,a,e,e,a,a,e,e,e,e,e,e,e,a,a,a,a,e,e,a,a]},"/_error":["static/chunks/pages/_error-e4ba546eb376bdf4.js"],sortedPages:["/_app","/_error"]}}(1,0,void 0,1e-4,14),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1 +0,0 @@
1
- self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()