@alexkroman1/aai-ui 1.13.1 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Sync-transport view: hold-to-talk button, transcript + reply output, and
3
- * the endpoint each utterance is POSTed to — one HTTP request per turn.
2
+ * Sync-transport view: a hands-free VAD-endpointed conversation, transcript
3
+ * + reply output, and the endpoint each utterance is POSTed to — one HTTP
4
+ * request per turn.
4
5
  *
5
6
  * @public
6
7
  */
@@ -1 +1 @@
1
- import{t as e}from"./index-CoMfLJMi.js";var t=1e3,n=65e3,r=250;async function i(e,t){let n=await new OfflineAudioContext(1,1,t).decodeAudioData(e),r=Math.ceil(n.duration*t),i=new OfflineAudioContext(1,r,t),a=i.createBufferSource();a.buffer=n,a.connect(i.destination),a.start();let o=(await i.startRendering()).getChannelData(0),s=new Int16Array(o.length),c=0;for(let e of o){let t=Math.max(-1,Math.min(1,e));s[c++]=t<0?t*32768:t*32767}return s}async function a(i){let{sttSampleRate:a,ttsSampleRate:o,captureWorkletSrc:s,playbackWorkletSrc:c,onMicData:l,onError:u}=i,d=o,f=new AudioContext({sampleRate:d,latencyHint:`playback`}),p=navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:`default`},echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,voiceIsolation:!0}}),m;try{[m]=await Promise.all([p,f.resume(),f.audioWorklet.addModule(s),f.audioWorklet.addModule(c)])}catch(e){throw p.then(e=>{for(let t of e.getTracks())t.stop()}).catch(()=>{}),await f.close().catch(e=>{console.warn(`AudioContext close failed:`,e)}),e}let h=f.createMediaStreamSource(m),g=new AudioWorkletNode(f,`capture-processor`,{channelCount:1,channelCountMode:`explicit`,processorOptions:{contextRate:d,sttSampleRate:a,bufferSeconds:e}});h.connect(g),g.onprocessorerror=()=>{let e=Error(`Audio capture worklet crashed`);console.error(`[aai-ui]`,e.message),u?.(e)},g.port.postMessage({event:`start`});let _=null;g.port.onmessage=e=>{e.data.event===`chunk`?l(e.data.buffer):e.data.event===`stopped`&&(_?.(),_=null)};let v=null,y=null,b=new AbortController;function x(){if(v)return v;let e=new AudioWorkletNode(f,`playback-processor`,{processorOptions:{sampleRate:d}});return e.connect(f.destination),e.port.onmessage=e=>{if(e.data.event===`stop`){if(e.data.reason===`interrupt`)return;y?.(),y=null}},e.onprocessorerror=()=>{let e=Error(`Audio playback worklet crashed`);console.error(`[aai-ui]`,e.message),y?.(),y=null,u?.(e)},v=e,e}let S={enqueue(e){b.signal.aborted||e.byteLength!==0&&x().port.postMessage({event:`write`,buffer:new Uint8Array(e)},[e])},done(){return!v||f.state!==`running`?Promise.resolve():new Promise(e=>{y?.();let r=()=>{clearInterval(i),clearTimeout(a),y===r&&(y=null),e()},i=setInterval(()=>{f.state!==`running`&&r()},t),a=setTimeout(r,n);y=r,v?.port.postMessage({event:`done`})})},flush(){v&&(y?.(),y=null,v.port.postMessage({event:`interrupt`}))},async close(){if(!b.signal.aborted){b.abort(),await new Promise(e=>{let t=setTimeout(e,r);_=()=>{clearTimeout(t),e()},g.port.postMessage({event:`stop`})}),h.disconnect(),g.disconnect(),v&&v.disconnect();for(let e of m.getTracks())e.stop();await f.close().catch(()=>{})}},async[Symbol.asyncDispose](){await S.close()}};return S}export{a as createVoiceIO,i as decodeAudioToPcm16};
1
+ import{t as e}from"./index-I5mZ1vB1.js";var t=1e3,n=65e3,r=250;async function i(e,t){let n=await new OfflineAudioContext(1,1,t).decodeAudioData(e),r=Math.ceil(n.duration*t),i=new OfflineAudioContext(1,r,t),a=i.createBufferSource();a.buffer=n,a.connect(i.destination),a.start();let o=(await i.startRendering()).getChannelData(0),s=new Int16Array(o.length),c=0;for(let e of o){let t=Math.max(-1,Math.min(1,e));s[c++]=t<0?t*32768:t*32767}return s}async function a(i){let{sttSampleRate:a,ttsSampleRate:o,captureWorkletSrc:s,playbackWorkletSrc:c,onMicData:l,onError:u}=i,d=o,f=new AudioContext({sampleRate:d,latencyHint:`playback`}),p=navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:`default`},echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,voiceIsolation:!0}}),m;try{[m]=await Promise.all([p,f.resume(),f.audioWorklet.addModule(s),f.audioWorklet.addModule(c)])}catch(e){throw p.then(e=>{for(let t of e.getTracks())t.stop()}).catch(()=>{}),await f.close().catch(e=>{console.warn(`AudioContext close failed:`,e)}),e}let h=f.createMediaStreamSource(m),g=new AudioWorkletNode(f,`capture-processor`,{channelCount:1,channelCountMode:`explicit`,processorOptions:{contextRate:d,sttSampleRate:a,bufferSeconds:e}});h.connect(g),g.onprocessorerror=()=>{let e=Error(`Audio capture worklet crashed`);console.error(`[aai-ui]`,e.message),u?.(e)},g.port.postMessage({event:`start`});let _=null;g.port.onmessage=e=>{e.data.event===`chunk`?l(e.data.buffer):e.data.event===`stopped`&&(_?.(),_=null)};let v=null,y=null,b=new AbortController;function x(){if(v)return v;let e=new AudioWorkletNode(f,`playback-processor`,{processorOptions:{sampleRate:d}});return e.connect(f.destination),e.port.onmessage=e=>{if(e.data.event===`stop`){if(e.data.reason===`interrupt`)return;y?.(),y=null}},e.onprocessorerror=()=>{let e=Error(`Audio playback worklet crashed`);console.error(`[aai-ui]`,e.message),y?.(),y=null,u?.(e)},v=e,e}let S={enqueue(e){b.signal.aborted||e.byteLength!==0&&x().port.postMessage({event:`write`,buffer:new Uint8Array(e)},[e])},done(){return!v||f.state!==`running`?Promise.resolve():new Promise(e=>{y?.();let r=()=>{clearInterval(i),clearTimeout(a),y===r&&(y=null),e()},i=setInterval(()=>{f.state!==`running`&&r()},t),a=setTimeout(r,n);y=r,v?.port.postMessage({event:`done`})})},flush(){v&&(y?.(),y=null,v.port.postMessage({event:`interrupt`}))},async close(){if(!b.signal.aborted){b.abort(),await new Promise(e=>{let t=setTimeout(e,r);_=()=>{clearTimeout(t),e()},g.port.postMessage({event:`stop`})}),h.disconnect(),g.disconnect(),v&&v.disconnect();for(let e of m.getTracks())e.stop();await f.close().catch(()=>{})}},async[Symbol.asyncDispose](){await S.close()}};return S}export{a as createVoiceIO,i as decodeAudioToPcm16};
@@ -0,0 +1,2 @@
1
+ /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-normal:400;--font-weight-medium:500;--tracking-wide:.025em;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-aai:"Monument Grotesk", "ABC Monument Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;--font-aai-serif:"Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, serif;--font-aai-mono:"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;--radius-aai:4px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}html,body{margin:0;padding:0}}@layer components;@layer utilities{.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:0}.mx-auto{margin-inline:auto}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mr-2{margin-right:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-4{height:calc(var(--spacing) * 4)}.h-9{height:calc(var(--spacing) * 9)}.h-11{height:calc(var(--spacing) * 11)}.h-\[7px\]{height:7px}.h-screen{height:100vh}.max-h-64{max-height:calc(var(--spacing) * 64)}.min-h-0{min-height:0}.min-h-5{min-height:calc(var(--spacing) * 5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-4{width:calc(var(--spacing) * 4)}.w-\[7px\]{width:7px}.w-fit{width:fit-content}.w-full{width:100%}.max-w-75{max-width:calc(var(--spacing) * 75)}.max-w-105{max-width:calc(var(--spacing) * 105)}.max-w-190{max-width:calc(var(--spacing) * 190)}.max-w-\[55\%\]{max-width:55%}.max-w-\[60\%\]{max-width:60%}.max-w-\[82\%\]{max-width:82%}.max-w-\[min\(78\%\,64ch\)\]{max-width:min(78%,64ch)}.min-w-0{min-width:0}.flex-1{flex:1}.shrink-0{flex-shrink:0}.rotate-90{rotate:90deg}.animate-pulse{animation:var(--animate-pulse)}.cursor-pointer{cursor:pointer}.\[scrollbar-width\:none\]{scrollbar-width:none}.appearance-none{appearance:none}.flex-col{flex-direction:column}.items-center{align-items:center}.items-end{align-items:flex-end}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-aai{border-radius:var(--radius-aai)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-transparent{background-color:#0000}.p-7{padding:calc(var(--spacing) * 7)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-7{padding-inline:calc(var(--spacing) * 7)}.px-10{padding-inline:calc(var(--spacing) * 10)}.py-1{padding-block:var(--spacing)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-12{padding-block:calc(var(--spacing) * 12)}.text-center{text-align:center}.text-left{text-align:left}.font-aai{font-family:var(--font-aai)}.font-aai-mono{font-family:var(--font-aai-mono)}.font-aai-serif{font-family:var(--font-aai-serif)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[15px\]{font-size:15px}.text-\[22px\]{font-size:22px}.text-\[32px\]{font-size:32px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-\[1\.2\]{--tw-leading:1.2;line-height:1.2}.leading-\[1\.15\]{--tw-leading:1.15;line-height:1.15}.leading-\[22px\]{--tw-leading:22px;line-height:22px}.leading-\[23px\]{--tw-leading:23px;line-height:23px}.leading-\[130\%\]{--tw-leading:130%;line-height:130%}.leading-none{--tw-leading:1;line-height:1}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.tracking-\[-0\.2px\]{--tw-tracking:-.2px;letter-spacing:-.2px}.tracking-\[1\.2px\]{--tw-tracking:1.2px;letter-spacing:1.2px}.tracking-\[1\.4px\]{--tw-tracking:1.4px;letter-spacing:1.4px}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-balance{text-wrap:balance}.wrap-break-word{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.uppercase{text-transform:uppercase}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (width>=40rem){.sm\:px-16{padding-inline:calc(var(--spacing) * 16)}.sm\:py-14{padding-block:calc(var(--spacing) * 14)}}}@keyframes aai-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.45;transform:scale(.82)}}@keyframes aai-bounce{0%,80%,to{opacity:.3;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}@keyframes aai-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.tool-shimmer{-webkit-text-fill-color:transparent;background:linear-gradient(90deg,currentColor 25%,#0000 50%,currentColor 75%) 0 0/200% 100%;-webkit-background-clip:text;background-clip:text;animation:2s infinite aai-shimmer}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}
@@ -70,11 +70,11 @@ Error generating stack: `+e.message+`
70
70
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=re,s=!p.jitless,c=s&&ie.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?xn([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function wn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ge(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>be(e,r,m())))}),t)}var Tn=u(`$ZodUnion`,(e,t)=>{k.init(e,t),S(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),S(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),S(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),S(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>y(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>wn(t,r,e,i)):wn(o,r,e,i)}}),En=u(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Tn.init(e,t);let n=e._zod.parse;S(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=_(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!re(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Dn=u(`$ZodIntersection`,(e,t)=>{k.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>kn(e,t,n)):kn(e,i,a)}});function On(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ae(e)&&ae(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=On(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=On(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function kn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),ge(e))return e;let o=On(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var An=u(`$ZodRecord`,(e,t)=>{k.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ae(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>be(e,r,m())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ve(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ve(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ht.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>be(e,r,m())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ve(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ve(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),jn=u(`$ZodEnum`,(e,t)=>{k.init(e,t);let n=h(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>se.has(typeof e)).map(e=>typeof e==`string`?ce(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Mn=u(`$ZodLiteral`,(e,t)=>{if(k.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ce(e):e?ce(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Nn=u(`$ZodTransform`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new f(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new d;return n.value=i,n.fallback=!0,n}});function Pn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Fn=u(`$ZodOptional`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${y(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Pn(e,r)):Pn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),In=u(`$ZodExactOptional`,(e,t)=>{Fn.init(e,t),S(e._zod,`values`,()=>t.innerType._zod.values),S(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ln=u(`$ZodNullable`,(e,t)=>{k.init(e,t),S(e._zod,`optin`,()=>t.innerType._zod.optin),S(e._zod,`optout`,()=>t.innerType._zod.optout),S(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${y(e.source)}|null)$`):void 0}),S(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Rn=u(`$ZodDefault`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>zn(e,t)):zn(r,t)}});function zn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Bn=u(`$ZodPrefault`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Vn=u(`$ZodNonOptional`,(e,t)=>{k.init(e,t),S(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Hn(t,e)):Hn(i,e)}});function Hn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Un=u(`$ZodCatch`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,S(e._zod,`optout`,()=>t.innerType._zod.optout),S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>be(e,n,m()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>be(e,n,m()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Wn=u(`$ZodPipe`,(e,t)=>{k.init(e,t),S(e._zod,`values`,()=>t.in._zod.values),S(e._zod,`optin`,()=>t.in._zod.optin),S(e._zod,`optout`,()=>t.out._zod.optout),S(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Gn(e,t.in,n)):Gn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Gn(e,t.out,n)):Gn(r,t.out,n)}});function Gn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Kn=u(`$ZodReadonly`,(e,t)=>{k.init(e,t),S(e._zod,`propValues`,()=>t.innerType._zod.propValues),S(e._zod,`values`,()=>t.innerType._zod.values),S(e._zod,`optin`,()=>t.innerType?._zod?.optin),S(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(qn):qn(r)}});function qn(e){return e.value=Object.freeze(e.value),e}var Jn=u(`$ZodCustom`,(e,t)=>{yt.init(e,t),k.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Yn(t,n,r,e));Yn(i,n,r,e)}});function Yn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Se(e))}}var Xn,Zn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Qn(){return new Zn}(Xn=globalThis).__zod_globalRegistry??(Xn.__zod_globalRegistry=Qn());var $n=globalThis.__zod_globalRegistry;function er(e,t){return new e({type:`string`,...T(t)})}function tr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}function nr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}function rr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}function ir(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}function sr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}function cr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}function lr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}function ur(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}function dr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}function fr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}function pr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}function mr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}function hr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}function gr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}function _r(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}function vr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}function yr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}function br(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}function xr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}function Sr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}function Cr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}function wr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}function Tr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}function Er(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}function Dr(e,t){return new e({type:`number`,checks:[],...T(t)})}function Or(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}function kr(e,t){return new e({type:`boolean`,...T(t)})}function Ar(e){return new e({type:`unknown`})}function jr(e,t){return new e({type:`never`,...T(t)})}function Mr(e,t){return new xt({check:`less_than`,...T(t),value:e,inclusive:!1})}function Nr(e,t){return new xt({check:`less_than`,...T(t),value:e,inclusive:!0})}function Pr(e,t){return new St({check:`greater_than`,...T(t),value:e,inclusive:!1})}function Fr(e,t){return new St({check:`greater_than`,...T(t),value:e,inclusive:!0})}function Ir(e,t){return new Ct({check:`multiple_of`,...T(t),value:e})}function Lr(e,t){return new Tt({check:`max_length`,...T(t),maximum:e})}function Rr(e,t){return new Et({check:`min_length`,...T(t),minimum:e})}function zr(e,t){return new Dt({check:`length_equals`,...T(t),length:e})}function Br(e,t){return new kt({check:`string_format`,format:`regex`,...T(t),pattern:e})}function Vr(e){return new At({check:`string_format`,format:`lowercase`,...T(e)})}function Hr(e){return new jt({check:`string_format`,format:`uppercase`,...T(e)})}function Ur(e,t){return new Mt({check:`string_format`,format:`includes`,...T(t),includes:e})}function Wr(e,t){return new Nt({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}function Gr(e,t){return new Pt({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}function Kr(e){return new Ft({check:`overwrite`,tx:e})}function qr(e){return Kr(t=>t.normalize(e))}function Jr(){return Kr(e=>e.trim())}function Yr(){return Kr(e=>e.toLowerCase())}function Xr(){return Kr(e=>e.toUpperCase())}function Zr(){return Kr(e=>te(e))}function Qr(e,t,n){return new e({type:`array`,element:t,...T(n)})}function $r(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}function ei(e,t){let n=ti(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Se(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Se(r))}},e(t.value,t)),t);return n}function ti(e,t){let n=new yt({check:`custom`,...T(t)});return n._zod.check=e,n}function ni(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??$n,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function j(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,j(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&ai(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ri(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
71
71
 
72
72
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ii(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:si(t,`input`,e.processors),output:si(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ai(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return ai(r.element,n);if(r.type===`set`)return ai(r.valueType,n);if(r.type===`lazy`)return ai(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return ai(r.innerType,n);if(r.type===`intersection`)return ai(r.left,n)||ai(r.right,n);if(r.type===`record`||r.type===`map`)return ai(r.keyType,n)||ai(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ai(r.in,n)||ai(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ai(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ai(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ai(e,n))return!0;return!!(r.rest&&ai(r.rest,n))}return!1}var oi=(e,t={})=>n=>{let r=ni({...n,processors:t});return j(e,r),ri(r,e),ii(r,e)},si=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ni({...i??{},target:a,io:t,processors:n});return j(e,o),ri(o,e),ii(o,e)},ci={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},li=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ci[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ui=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},di=(e,t,n,r)=>{n.type=`boolean`},fi=(e,t,n,r)=>{n.not={}},pi=(e,t,n,r)=>{let i=e._zod.def,a=h(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},mi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},hi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},_i=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=j(a.element,t,{...r,path:[...r.path,`items`]})},vi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=j(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=j(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},yi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>j(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},bi=(e,t,n,r)=>{let i=e._zod.def,a=j(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=j(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},xi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=j(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=j(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=j(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Si=(e,t,n,r)=>{let i=e._zod.def,a=j(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ci=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wi=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ti=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ei=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Di=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;j(o,t,r);let s=t.seen.get(e);s.ref=o},Oi=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ki=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ai=u(`ZodISODateTime`,(e,t)=>{Xt.init(e,t),I.init(e,t)});function ji(e){return Cr(Ai,e)}var Mi=u(`ZodISODate`,(e,t)=>{Zt.init(e,t),I.init(e,t)});function Ni(e){return wr(Mi,e)}var Pi=u(`ZodISOTime`,(e,t)=>{Qt.init(e,t),I.init(e,t)});function Fi(e){return Tr(Pi,e)}var Ii=u(`ZodISODuration`,(e,t)=>{$t.init(e,t),I.init(e,t)});function Li(e){return Er(Ii,e)}var Ri=u(`ZodError`,(e,t)=>{we.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>De(e,t)},flatten:{value:t=>Ee(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,g,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,g,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),zi=Oe(Ri),Bi=ke(Ri),M=Ae(Ri),N=Me(Ri),Vi=Pe(Ri),Hi=Fe(Ri),Ui=Ie(Ri),Wi=Le(Ri),Gi=Re(Ri),Ki=ze(Ri),qi=Be(Ri),Ji=Ve(Ri),Yi=new WeakMap;function Xi(e,t,n){let r=Object.getPrototypeOf(e),i=Yi.get(r);if(i||(i=new Set,Yi.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var P=u(`ZodType`,(e,t)=>(k.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:si(e,`input`),output:si(e,`output`)}}),e.toJSONSchema=oi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>zi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>M(e,t,n),e.parseAsync=async(t,n)=>Bi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>N(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Vi(e,t,n),e.decode=(t,n)=>Hi(e,t,n),e.encodeAsync=async(t,n)=>Ui(e,t,n),e.decodeAsync=async(t,n)=>Wi(e,t,n),e.safeEncode=(t,n)=>Gi(e,t,n),e.safeDecode=(t,n)=>Ki(e,t,n),e.safeEncodeAsync=async(t,n)=>qi(e,t,n),e.safeDecodeAsync=async(t,n)=>Ji(e,t,n),Xi(e,`ZodType`,{check(...e){let t=this.def;return this.clone(w(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return le(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(co(e,t))},superRefine(e,t){return this.check(lo(e,t))},overwrite(e){return this.check(Kr(e))},optional(){return Wa(this)},exactOptional(){return Ka(this)},nullable(){return Ja(this)},nullish(){return Wa(Ja(this))},nonoptional(e){return eo(this,e)},array(){return Oa(this)},or(e){return ja([this,e])},and(e){return Fa(this,e)},transform(e){return io(this,Ha(e))},default(e){return Xa(this,e)},prefault(e){return Qa(this,e)},catch(e){return no(this,e)},pipe(e){return io(this,e)},readonly(){return oo(this)},describe(e){let t=this.clone();return $n.add(t,{description:e}),t},meta(...e){if(e.length===0)return $n.get(this);let t=this.clone();return $n.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return $n.get(e)?.description},configurable:!0}),e)),Zi=u(`_ZodString`,(e,t)=>{Rt.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Xi(e,`_ZodString`,{regex(...e){return this.check(Br(...e))},includes(...e){return this.check(Ur(...e))},startsWith(...e){return this.check(Wr(...e))},endsWith(...e){return this.check(Gr(...e))},min(...e){return this.check(Rr(...e))},max(...e){return this.check(Lr(...e))},length(...e){return this.check(zr(...e))},nonempty(...e){return this.check(Rr(1,...e))},lowercase(e){return this.check(Vr(e))},uppercase(e){return this.check(Hr(e))},trim(){return this.check(Jr())},normalize(...e){return this.check(qr(...e))},toLowerCase(){return this.check(Yr())},toUpperCase(){return this.check(Xr())},slugify(){return this.check(Zr())}})}),Qi=u(`ZodString`,(e,t)=>{Rt.init(e,t),Zi.init(e,t),e.email=t=>e.check(tr($i,t)),e.url=t=>e.check(sr(na,t)),e.jwt=t=>e.check(Sr(_a,t)),e.emoji=t=>e.check(cr(ra,t)),e.guid=t=>e.check(nr(ea,t)),e.uuid=t=>e.check(rr(ta,t)),e.uuidv4=t=>e.check(ir(ta,t)),e.uuidv6=t=>e.check(ar(ta,t)),e.uuidv7=t=>e.check(or(ta,t)),e.nanoid=t=>e.check(lr(ia,t)),e.guid=t=>e.check(nr(ea,t)),e.cuid=t=>e.check(ur(aa,t)),e.cuid2=t=>e.check(dr(oa,t)),e.ulid=t=>e.check(fr(sa,t)),e.base64=t=>e.check(yr(ma,t)),e.base64url=t=>e.check(br(ha,t)),e.xid=t=>e.check(pr(ca,t)),e.ksuid=t=>e.check(mr(la,t)),e.ipv4=t=>e.check(hr(ua,t)),e.ipv6=t=>e.check(gr(da,t)),e.cidrv4=t=>e.check(_r(fa,t)),e.cidrv6=t=>e.check(vr(pa,t)),e.e164=t=>e.check(xr(ga,t)),e.datetime=t=>e.check(ji(t)),e.date=t=>e.check(Ni(t)),e.time=t=>e.check(Fi(t)),e.duration=t=>e.check(Li(t))});function F(e){return er(Qi,e)}var I=u(`ZodStringFormat`,(e,t)=>{A.init(e,t),Zi.init(e,t)}),$i=u(`ZodEmail`,(e,t)=>{Vt.init(e,t),I.init(e,t)}),ea=u(`ZodGUID`,(e,t)=>{zt.init(e,t),I.init(e,t)}),ta=u(`ZodUUID`,(e,t)=>{Bt.init(e,t),I.init(e,t)}),na=u(`ZodURL`,(e,t)=>{Ht.init(e,t),I.init(e,t)}),ra=u(`ZodEmoji`,(e,t)=>{Ut.init(e,t),I.init(e,t)}),ia=u(`ZodNanoID`,(e,t)=>{Wt.init(e,t),I.init(e,t)}),aa=u(`ZodCUID`,(e,t)=>{Gt.init(e,t),I.init(e,t)}),oa=u(`ZodCUID2`,(e,t)=>{Kt.init(e,t),I.init(e,t)}),sa=u(`ZodULID`,(e,t)=>{qt.init(e,t),I.init(e,t)}),ca=u(`ZodXID`,(e,t)=>{Jt.init(e,t),I.init(e,t)}),la=u(`ZodKSUID`,(e,t)=>{Yt.init(e,t),I.init(e,t)}),ua=u(`ZodIPv4`,(e,t)=>{en.init(e,t),I.init(e,t)}),da=u(`ZodIPv6`,(e,t)=>{tn.init(e,t),I.init(e,t)}),fa=u(`ZodCIDRv4`,(e,t)=>{nn.init(e,t),I.init(e,t)}),pa=u(`ZodCIDRv6`,(e,t)=>{rn.init(e,t),I.init(e,t)}),ma=u(`ZodBase64`,(e,t)=>{on.init(e,t),I.init(e,t)}),ha=u(`ZodBase64URL`,(e,t)=>{cn.init(e,t),I.init(e,t)}),ga=u(`ZodE164`,(e,t)=>{ln.init(e,t),I.init(e,t)}),_a=u(`ZodJWT`,(e,t)=>{dn.init(e,t),I.init(e,t)}),va=u(`ZodNumber`,(e,t)=>{fn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),Xi(e,`ZodNumber`,{gt(e,t){return this.check(Pr(e,t))},gte(e,t){return this.check(Fr(e,t))},min(e,t){return this.check(Fr(e,t))},lt(e,t){return this.check(Mr(e,t))},lte(e,t){return this.check(Nr(e,t))},max(e,t){return this.check(Nr(e,t))},int(e){return this.check(ba(e))},safe(e){return this.check(ba(e))},positive(e){return this.check(Pr(0,e))},nonnegative(e){return this.check(Fr(0,e))},negative(e){return this.check(Mr(0,e))},nonpositive(e){return this.check(Nr(0,e))},multipleOf(e,t){return this.check(Ir(e,t))},step(e,t){return this.check(Ir(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function L(e){return Dr(va,e)}var ya=u(`ZodNumberFormat`,(e,t)=>{pn.init(e,t),va.init(e,t)});function ba(e){return Or(ya,e)}var xa=u(`ZodBoolean`,(e,t)=>{mn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r)});function Sa(e){return kr(xa,e)}var Ca=u(`ZodUnknown`,(e,t)=>{hn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function wa(){return Ar(Ca)}var Ta=u(`ZodNever`,(e,t)=>{gn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r)});function Ea(e){return jr(Ta,e)}var Da=u(`ZodArray`,(e,t)=>{vn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r),e.element=t.element,Xi(e,`ZodArray`,{min(e,t){return this.check(Rr(e,t))},nonempty(e){return this.check(Rr(1,e))},max(e,t){return this.check(Lr(e,t))},length(e,t){return this.check(zr(e,t))},unwrap(){return this.element}})});function Oa(e,t){return Qr(Da,e,t)}var ka=u(`ZodObject`,(e,t)=>{Cn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),S(e,`shape`,()=>t.shape),Xi(e,`ZodObject`,{keyof(){return za(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:wa()})},loose(){return this.clone({...this._zod.def,catchall:wa()})},strict(){return this.clone({...this._zod.def,catchall:Ea()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return fe(this,e)},safeExtend(e){return pe(this,e)},merge(e){return me(this,e)},pick(e){return ue(this,e)},omit(e){return de(this,e)},partial(...e){return O(Ua,this,e[0])},required(...e){return he($a,this,e[0])}})});function R(e,t){return new ka({type:`object`,shape:e??{},...T(t)})}var Aa=u(`ZodUnion`,(e,t)=>{Tn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.options=t.options});function ja(e,t){return new Aa({type:`union`,options:e,...T(t)})}var Ma=u(`ZodDiscriminatedUnion`,(e,t)=>{Aa.init(e,t),En.init(e,t)});function Na(e,t,n){return new Ma({type:`union`,options:t,discriminator:e,...T(n)})}var Pa=u(`ZodIntersection`,(e,t)=>{Dn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r)});function Fa(e,t){return new Pa({type:`intersection`,left:e,right:t})}var Ia=u(`ZodRecord`,(e,t)=>{An.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function La(e,t,n){return!t||!t._zod?new Ia({type:`record`,keyType:F(),valueType:e,...T(t)}):new Ia({type:`record`,keyType:e,valueType:t,...T(n)})}var Ra=u(`ZodEnum`,(e,t)=>{jn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ra({...t,checks:[],...T(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ra({...t,checks:[],...T(r),entries:i})}});function za(e,t){return new Ra({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...T(t)})}var Ba=u(`ZodLiteral`,(e,t)=>{Mn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function z(e,t){return new Ba({type:`literal`,values:Array.isArray(e)?e:[e],...T(t)})}var Va=u(`ZodTransform`,(e,t)=>{Nn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new f(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Se(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Se(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ha(e){return new Va({type:`transform`,transform:e})}var Ua=u(`ZodOptional`,(e,t)=>{Fn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wa(e){return new Ua({type:`optional`,innerType:e})}var Ga=u(`ZodExactOptional`,(e,t)=>{In.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ka(e){return new Ga({type:`optional`,innerType:e})}var qa=u(`ZodNullable`,(e,t)=>{Ln.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ja(e){return new qa({type:`nullable`,innerType:e})}var Ya=u(`ZodDefault`,(e,t)=>{Rn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xa(e,t){return new Ya({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}var Za=u(`ZodPrefault`,(e,t)=>{Bn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qa(e,t){return new Za({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}var $a=u(`ZodNonOptional`,(e,t)=>{Vn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function eo(e,t){return new $a({type:`nonoptional`,innerType:e,...T(t)})}var to=u(`ZodCatch`,(e,t)=>{Un.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function no(e,t){return new to({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ro=u(`ZodPipe`,(e,t)=>{Wn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.in=t.in,e.out=t.out});function io(e,t){return new ro({type:`pipe`,in:e,out:t})}var ao=u(`ZodReadonly`,(e,t)=>{Kn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oo(e){return new ao({type:`readonly`,innerType:e})}var so=u(`ZodCustom`,(e,t)=>{Jn.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function co(e,t={}){return $r(so,e,t)}function lo(e,t){return ei(e,t)}var B=n(),uo=i(),fo=c(),V=[`local`,`internal`,`localhost`],H=/^(\d{1,3}\.){3}\d{1,3}$/;function U(e){return{valid:!1,reason:e}}function po(e){return e===``?U(`Pattern must not be empty.`):e.includes(`://`)?U(`Pattern must not include a protocol (e.g. remove 'https://').`):e.includes(`/`)?U(`Pattern must not include a path component (remove '/').`):e.includes(`?`)?U(`Pattern must not include a query string (remove '?').`):e.startsWith(`[`)||e.includes(`::`)?U(`IP address literals are not allowed in allowedHosts patterns.`):e.includes(`:`)?U(`Pattern must not include a port number (e.g. remove ':8080').`):null}function mo(e){return e.includes(`*`)?e===`*`||e===`**`?U(`Bare wildcard '*' is not allowed. Use '*.example.com' to allow all subdomains.`):e.indexOf(`*`)!==0||e[1]!==`.`?U(`Wildcard '*' may only appear as the leading segment (e.g. '*.example.com').`):e.lastIndexOf(`*`)===0?null:U(`Only a single leading wildcard segment is supported.`):null}function ho(e){if(H.test(e))return U(`IP address literals are not allowed in allowedHosts patterns.`);let t=e.split(`.`).at(-1)?.toLowerCase()??``;return V.includes(t)?U(`Patterns ending in '.${t}' are not allowed (private/special-use TLD).`):null}function go(e){let t=po(e);if(t!==null)return t;let n=mo(e);if(n!==null)return n;let r=ho(e.startsWith(`*.`)?e.slice(2):e);return r===null?{valid:!0}:r}var _o=Oa(F()).superRefine((e,t)=>{for(let n of e){let e=go(n);e.valid||t.addIssue({code:`custom`,message:`Invalid allowedHosts pattern "${n}": ${e.reason}`})}}),vo=4e3,yo=1e5,bo=1e4,xo=12*1024*1024,So=1e3,Co=32*1024,wo=.1,To=192e3;function Eo(e){if(e instanceof Error)return e.message;if(typeof e==`object`&&e&&`message`in e){let t=e.message;if(typeof t==`string`)return t}return String(e)}function Do(e){try{return JSON.parse(e)}catch{}}var Oo=za([`web_search`,`visit_webpage`,`get_page_design`,`fetch_json`,`run_code`,`think`,`remember`,`recall`,`calculate`]),ko=za([`auto`,`required`]),Ao=R({description:F(),parameters:La(F(),wa()).optional()}),jo=R({kind:F().min(1),options:La(F(),wa())});R({name:F().min(1),systemPrompt:F().optional(),greeting:F().optional(),sttPrompt:F().optional(),builtinTools:Oa(Oo).optional(),maxSteps:L().int().positive().optional(),toolChoice:za([`auto`,`required`]).optional(),idleTimeoutMs:L().int().nonnegative().optional(),silenceTimeoutMs:L().int().positive().optional(),silencePrompt:F().min(1).optional(),minBargeInWords:L().int().min(1).optional(),interruptionMinDurationMs:L().int().nonnegative().optional(),endpointSettleMs:L().int().nonnegative().optional(),completeSettleMs:L().int().nonnegative().optional(),holdPhrase:F().optional(),falseInterruptionTimeoutMs:L().int().nonnegative().optional(),theme:La(F(),F()).optional(),tools:La(F(),Ao).optional(),allowedHosts:_o.optional(),stt:jo.optional(),llm:jo.optional(),tts:jo.optional(),s2s:jo.optional(),kv:jo.optional(),vector:jo.optional(),send:jo.optional(),transport:za([`websocket`,`sync`]).optional()}),R({name:F().min(1),systemPrompt:F(),greeting:F(),sttPrompt:F().optional(),maxSteps:L().int().positive().optional(),toolChoice:ko.optional(),builtinTools:Oa(Oo).readonly().optional(),idleTimeoutMs:L().nonnegative().optional(),silenceTimeoutMs:L().positive().optional(),silencePrompt:F().optional(),minBargeInWords:L().int().min(1).optional(),interruptionMinDurationMs:L().int().nonnegative().optional(),endpointSettleMs:L().int().nonnegative().optional(),completeSettleMs:L().int().nonnegative().optional(),holdPhrase:F().optional(),falseInterruptionTimeoutMs:L().int().nonnegative().optional(),stt:jo.optional(),llm:jo.optional(),tts:jo.optional(),s2s:jo.optional(),mode:za([`s2s`,`pipeline`]).optional(),kv:jo.optional(),vector:jo.optional(),send:jo.optional(),transport:za([`websocket`,`sync`]).optional(),allowedHosts:_o.optional()});var Mo=R({type:z(`function`),name:F().min(1),description:F().min(1),parameters:La(F(),wa())});R({});var No=`client-config`,Po=R({transport:za([`websocket`,`sync`]).default(`websocket`),name:F().optional(),greeting:F().max(yo).optional()}),Fo=R({role:za([`user`,`assistant`]),content:F().max(yo)});R({text:F().min(1).max(yo).optional(),audio:F().min(1).max(Math.ceil(xo/3)*4,`audio exceeds the sync transcription cap`).optional(),sampleRate:L().int().positive().max(To).optional(),history:Oa(Fo).max(So).default([])}).superRefine((e,t)=>{e.text===void 0==(e.audio===void 0)&&t.addIssue({code:`custom`,message:`exactly one of text or audio must be set`}),e.audio!==void 0&&e.sampleRate===void 0&&t.addIssue({code:`custom`,message:`audio requires sampleRate`})});var Io=R({transcript:F(),reply:F(),audio:F().optional(),sampleRate:L().int().positive().optional(),ttsError:F().optional()}),Lo=R({type:F()}).passthrough();function Ro(e,t,n){let r=e.safeParse(t);if(r.success)return{ok:!0,data:r.data};let i=Lo.safeParse(t);return{ok:!1,malformed:!i.success||(n?.has(i.data.type)??!1),error:r.error.message}}function zo(e){let t=e.def.discriminator,n=new Set;for(let r of e.options){let e=r.shape[t];e instanceof Ba&&typeof e.value==`string`&&n.add(e.value)}return n}Na(`op`,[R({op:z(`get`),key:F().min(1)}),R({op:z(`set`),key:F().min(1),value:wa(),expireIn:L().int().positive().optional()}),R({op:z(`del`),key:F().min(1)})]),Na(`op`,[R({op:z(`upsert`),id:F().min(1),text:F().min(1),metadata:La(F(),wa()).optional()}),R({op:z(`query`),text:F().min(1),topK:L().int().positive().max(100).optional(),filter:La(F(),wa()).optional()}),R({op:z(`delete`),ids:ja([F().min(1),Oa(F().min(1)).max(1e3)])})]);var Bo=za([`stt`,`llm`,`tts`,`tool`,`protocol`,`connection`,`audio`,`internal`]),Vo=e=>R({type:z(e)}),Ho=Na(`type`,[Vo(`speech_started`),Vo(`speech_stopped`),R({type:z(`user_transcript`),text:F().max(yo)}),R({type:z(`user_transcript_partial`),text:F().max(yo)}),R({type:z(`agent_transcript`),text:F().max(yo)}),R({type:z(`tool_call`),toolCallId:F(),toolName:F(),args:La(F(),wa())}),R({type:z(`tool_call_done`),toolCallId:F(),result:F().max(vo)}),Vo(`reply_done`),Vo(`cancelled`),Vo(`reset`),Vo(`idle_timeout`),R({type:z(`error`),code:Bo,message:F().max(bo),fatal:Sa().optional()}),R({type:z(`custom_event`),event:F().min(1).max(256),data:wa()})]);R({audioFormat:za([`pcm16`]),sampleRate:L().int().positive(),ttsSampleRate:L().int().positive(),audioOut:Sa().optional()});var Uo=Na(`type`,[R({type:z(`config`),audioFormat:F(),sampleRate:L().int().positive().max(To),ttsSampleRate:L().int().positive().max(To),audioOut:Sa().optional(),sessionId:F().optional()}),Vo(`audio_done`),...Ho.options]);zo(Na(`type`,[Vo(`audio_ready`),Vo(`cancel`),Vo(`reset`),R({type:z(`history`),messages:Oa(R({role:za([`user`,`assistant`]),content:F().max(1e5)})).max(200)}),R({type:z(`tool_result`),toolCallId:F().min(1),result:F().max(vo),error:F().optional()}),R({type:z(`transcribe_file_start`),sampleRate:L().int().positive().max(To),byteLength:L().int().positive().max(xo,`audio exceeds the one-shot transcription cap`)}),Vo(`transcribe_file_end`)]));var Wo=R({systemPrompt:F().min(1),greeting:F().optional(),tools:Oa(Mo)});R({type:z(`config`),host:Wo,audioFormat:za([`pcm16`]).optional(),sampleRate:L().int().positive().optional(),ttsSampleRate:L().int().positive().optional()});function Go(e,t){return new URL(t,e.endsWith(`/`)?e:`${e}/`)}var Ko={transport:`websocket`};async function qo(e,t){let n=t??((e,t)=>globalThis.fetch(e,t));try{let t=await n(Go(e,No).href);if(!t.ok)return Ko;let r=Po.safeParse(await t.json());return r.success?r.data:Ko}catch{return Ko}}function Jo(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Jo(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Yo(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Jo(e))&&(r&&(r+=` `),r+=t);return r}var Xo=e((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Zo=e(((e,t)=>{t.exports=Xo()}))(),Qo={bg:`#FBF8F2`,primary:`#3F2BC1`,text:`#1B1A18`,surface:`#FFFFFF`,border:`#DCD7CC`},$o=(0,B.createContext)(null);function es({value:e,children:t}){return(0,B.createElement)($o.Provider,{value:e},t)}function ts(){let e=(0,B.useContext)($o);if(!e)throw Error(`Session hooks must be used within <SessionProvider>`);return e}function ns(e,t=Object.is){let n=ts();return(0,Zo.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getSnapshot,e,t)}var rs=(0,B.createContext)(Qo);function is({value:e,children:t}){let n=(0,B.useMemo)(()=>e?{...Qo,...e}:Qo,[e]);return as(n.bg),(0,B.createElement)(rs.Provider,{value:n},t)}function as(e){(0,B.useEffect)(()=>{if(typeof document>`u`)return;let{body:t,documentElement:n}=document,r={body:t.style.background,html:n.style.background};return t.style.background=e,n.style.background=e,()=>{t.style.background=r.body,n.style.background=r.html}},[e])}function os(){return(0,B.useContext)(rs)}var ss=`#57534B`,cs=`#6F6A60`,ls=`rgba(20,18,12,0.03)`,us=`#B3261E`;function ds(e,t,n){return`color-mix(in srgb, ${e} ${n}%, ${t})`}var fs=e((e=>{var t=Symbol.for(`react.transitional.element`);function n(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.jsx=n,e.jsxs=n})),W=e(((e,t)=>{t.exports=fs()}))(),ps=(0,B.memo)(function({size:e=20}){return(0,W.jsxs)(`svg`,{role:`img`,"aria-label":`AssemblyAI`,height:e,viewBox:`0 0 141 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{display:`block`,color:os().text},children:[(0,W.jsx)(`path`,{d:`M37.698 16.7132L38.9234 13.4518H44.334L45.5782 16.7132H47.897L42.9766 3.51665H40.3939L35.4546 16.7132H37.698ZM41.6193 5.85433L43.7307 11.6042H39.5267L41.6193 5.85433Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M48.9176 13.5272C48.9741 15.6198 50.7462 16.8263 53.329 16.8263C55.6667 16.8263 57.4199 15.6575 57.4199 13.81C57.4199 11.6608 55.6289 11.2083 53.4232 10.9444C52.0282 10.7936 51.1044 10.6805 51.1044 9.77558C51.1044 9.00264 51.8962 8.51249 53.1028 8.51249C54.3093 8.51249 55.1388 9.13461 55.2519 10.0207H57.2502C57.1183 8.04118 55.4404 6.94775 53.065 6.94775C50.7462 6.9289 49.1061 8.11659 49.1061 9.94525C49.1061 11.9436 50.8405 12.4149 53.0462 12.6788C54.5355 12.8673 55.4216 12.9428 55.4216 13.9796C55.4216 14.7526 54.5921 15.2427 53.329 15.2427C51.8585 15.2427 50.9913 14.5263 50.9159 13.5272H48.9176Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M58.9645 13.5272C59.021 15.6198 60.7931 16.8263 63.3759 16.8263C65.7135 16.8263 67.4668 15.6575 67.4668 13.81C67.4668 11.6608 65.6758 11.2083 63.4701 10.9444C62.0751 10.7936 61.1513 10.6805 61.1513 9.77558C61.1513 9.00264 61.9431 8.51249 63.1497 8.51249C64.3562 8.51249 65.1857 9.13461 65.2988 10.0207H67.2971C67.1652 8.04118 65.4873 6.94775 63.1119 6.94775C60.7931 6.9289 59.153 8.11659 59.153 9.94525C59.153 11.9436 60.8874 12.4149 63.0931 12.6788C64.5824 12.8673 65.4685 12.9428 65.4685 13.9796C65.4685 14.7526 64.639 15.2427 63.3759 15.2427C61.9054 15.2427 61.0382 14.5263 60.9628 13.5272H58.9645Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M74.1913 16.8263C76.5855 16.8263 78.2068 15.3747 78.5462 13.4706H76.5101C76.2273 14.5452 75.3224 15.1673 74.0782 15.1673C72.4757 15.1673 71.4389 14.0927 71.3823 12.4526V12.3206H78.6593C78.697 12.0567 78.7158 11.7928 78.7158 11.5477C78.6593 8.71986 76.7929 6.94775 74.0028 6.94775C71.1561 6.94775 69.252 8.92723 69.252 11.9059C69.252 14.8657 71.1561 16.8263 74.1913 16.8263ZM71.4577 10.8313C71.6085 9.4551 72.7208 8.5879 74.0216 8.5879C75.4355 8.5879 76.4347 9.39854 76.6044 10.8313H71.4577Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M92.0314 6.94775C90.4478 6.94775 89.3544 7.64529 88.7322 8.70101C88.1478 7.45676 87.0167 6.94775 85.7536 6.94775C84.302 6.96661 83.4725 7.60758 82.9258 8.32396L82.6995 7.06087H80.9274V16.7132H82.9635V11.5477C82.9635 9.83214 83.8307 8.70101 85.2257 8.70101C86.5642 8.70101 87.2618 9.58706 87.2618 11.2838V16.7132H89.3167V11.4911C89.3167 9.75673 90.2027 8.70101 91.5978 8.70101C92.9174 8.70101 93.615 9.58706 93.615 11.2838V16.7132H95.651V11.1518C95.651 8.09774 94.0297 6.94775 92.0314 6.94775Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M103.228 6.94775C101.738 6.94775 100.739 7.62643 100.098 8.49363V3.51665H98.0623V16.7132H99.8344L100.079 15.3181C100.683 16.1853 101.72 16.8263 103.228 16.8263C105.867 16.8263 107.79 14.8468 107.79 11.887C107.79 8.77642 105.867 6.94775 103.228 6.94775ZM102.888 15.1108C101.192 15.1108 100.079 13.7722 100.079 11.8682C100.079 10.0018 101.192 8.68216 102.888 8.68216C104.585 8.68216 105.716 10.0018 105.716 11.887C105.716 13.7911 104.585 15.1108 102.888 15.1108Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M109.987 16.7132H112.023V3.51665H109.987V16.7132Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M117.375 16.7697L116.998 17.7124C116.696 18.5041 116.507 18.6927 115.716 18.6927H114.283V20.4836H116.47C117.884 20.4836 118.298 19.7861 118.902 18.2214L123.275 7.06087H121.107L118.487 14.3944L115.791 7.06087H113.623L117.375 16.7697Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M125.769 16.7132L126.994 13.4518H132.405L133.649 16.7132H135.968L131.047 3.51665H128.465L123.525 16.7132H125.769ZM129.69 5.85433L131.801 11.6042H127.597L129.69 5.85433Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M137.887 16.7132H140.055V3.51665H137.887V16.7132Z`,fill:`currentColor`}),(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.2496 0C10.4867 0 8.90488 1.08157 8.26713 2.72302L0 24H6.28017L12.7874 7.25245H12.7902C12.9534 6.84425 13.353 6.55584 13.8199 6.55584C14.2869 6.55584 14.6864 6.84425 14.8497 7.25245H15.7167V3.85532H14.1073L15.6053 0H12.2496Z`,fill:`#2545D3`}),(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.2677 2.72302C8.87959 1.1483 10.3603 0.0888597 12.0361 0.00532694L12.034 0H12.2501H14.6661H15.4972C17.2601 0 18.8419 1.08157 19.4797 2.72302L27.7468 24H21.3592L13.3424 3.36747C12.8835 2.35631 11.864 1.65296 10.6801 1.65296C9.49331 1.65296 8.47176 2.35976 8.0144 3.37493L8.2677 2.72302Z`,fill:`#566DE8`})]})});function ms({variant:e=`default`,size:t=`default`,className:n,children:r,style:i,...a}){let o=os(),s;return s=e==="default"?{background:o.primary,color:o.surface,borderColor:`transparent`}:e===`secondary`?{background:`transparent`,color:o.primary,borderColor:o.primary}:{background:o.surface,color:o.text,borderColor:o.border},(0,W.jsx)(`button`,{type:`button`,style:{...s,...i},className:Yo(`inline-flex items-center justify-center appearance-none m-0 w-fit whitespace-nowrap`,t===`lg`?`h-11 px-7 text-xs`:`h-9 px-5 text-[11px]`,`rounded-aai font-aai font-medium tracking-[1.4px] uppercase leading-none`,`cursor-pointer border outline-none transition-colors duration-150`,`disabled:cursor-not-allowed disabled:opacity-50`,n),...a,children:r})}var hs=1500;function gs({label:e,url:t,hint:n,testId:r,className:i}){let a=os(),[o,s]=(0,B.useState)(!1),c=(0,B.useRef)(void 0);(0,B.useEffect)(()=>()=>clearTimeout(c.current),[]);function l(){navigator.clipboard?.writeText(t).then(()=>{s(!0),clearTimeout(c.current),c.current=setTimeout(()=>s(!1),hs)}).catch(()=>{})}return(0,W.jsxs)(`button`,{type:`button`,onClick:l,title:`${n} (click to copy)\n${t}`,className:Yo(`flex items-center gap-1.5 min-w-0 appearance-none m-0 px-2 py-1 rounded-aai border cursor-pointer outline-none text-[11px] leading-none font-aai-mono`,i),style:{background:ls,borderColor:a.border,color:cs},"data-testid":r,children:[(0,W.jsx)(`span`,{className:`uppercase tracking-wide shrink-0`,style:{color:ss},children:o?`Copied`:e}),(0,W.jsx)(`span`,{className:`truncate`,"data-testid":`${r}-url`,children:t})]})}function _s(){return typeof window>`u`?``:`${window.location.origin}${window.location.pathname}`}function vs({className:e}){return(0,W.jsx)(gs,{label:`UI`,url:_s(),hint:`Shareable UI`,testId:`ui-url-chip`,className:e})}function ys({className:e}){return(0,W.jsx)(gs,{label:`API`,url:ns(e=>e.apiUrl),hint:`API endpoint`,testId:`api-url-chip`,className:e})}function bs({className:e}){return(0,W.jsxs)(`div`,{className:Yo(`flex items-center gap-1.5 min-w-0`,e),children:[(0,W.jsx)(vs,{className:`min-w-0 flex-1`}),(0,W.jsx)(ys,{className:`min-w-0 flex-1`})]})}var xs=(0,B.memo)(function({className:e}){let t=ns(e=>e.running),{toggle:n,reset:r}=ts();return(0,W.jsxs)(`div`,{className:Yo(`flex items-center gap-3 shrink-0`,e),children:[(0,W.jsx)(ms,{variant:`secondary`,onClick:n,children:t?`Stop`:`Resume`}),(0,W.jsx)(ms,{variant:`ghost`,onClick:r,children:`New Conversation`}),(0,W.jsx)(bs,{className:`ml-auto max-w-[60%]`})]})});function Ss({children:e,className:t,style:n,...r}){let i=os();return(0,W.jsx)(`span`,{className:Yo(`inline-flex items-center gap-1.5 px-2 py-1 rounded-aai border leading-none`,`font-aai text-[10px] font-medium tracking-[1.2px] uppercase`,t),style:{borderColor:i.border,color:i.text,...n},...r,children:e})}function Cs(e){return e&&(Do(e)??e)}function ws(e,t=80){return e.length>t?`${e.slice(0,t)}...`:e}var Ts=(0,B.createContext)({});function Es(){return(0,B.useContext)(Ts)}function Ds(e){let t=Cs(e);return t===e?e:JSON.stringify(t,null,2)}var Os=(0,B.memo)(function({toolCall:e,className:t}){let[n,r]=(0,B.useState)(!1),i=os(),a=Es(),o=Object.hasOwn(a,e.name)?a[e.name]:void 0,s=e.status===`pending`,c=o?.label||e.name,l=o?.icon,u=!s&&!!e.result,d=(0,B.useMemo)(()=>e.result?Ds(e.result):``,[e.result]),f=(0,B.useMemo)(()=>{let t=e.args;if(e.name===`run_code`&&t.code)return ws(String(t.code).split(`
73
- `)[0]??``);for(let e of[`query`,`url`,`question`])if(t[e])return String(t[e]);return ws(JSON.stringify(t))},[e.name,e.args]);return(0,W.jsxs)(`div`,{className:Yo(`flex flex-col rounded-md border overflow-hidden`,t),style:{borderColor:i.border,background:i.bg},children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":u?n:void 0,disabled:s,className:Yo(`flex items-center gap-2.5 px-3.5 py-2.5 select-none text-left w-full appearance-none border-none bg-transparent`,u&&`cursor-pointer`),onClick:()=>{u&&r(!n)},children:[l?(0,W.jsx)(`span`,{className:`w-4 h-4 shrink-0 text-center leading-4`,children:l}):(0,W.jsx)(Ss,{className:`shrink-0`,style:{color:cs},children:`Tool`}),(0,W.jsx)(`span`,{className:Yo(`font-aai-mono text-[13px] font-medium`,s&&`tool-shimmer`),style:{color:i.text},children:c}),(0,W.jsx)(`span`,{className:`font-aai-mono text-[13px] truncate flex-1 min-w-0`,style:{color:cs},children:f}),u&&(0,W.jsx)(`span`,{className:Yo(`text-[10px] shrink-0 transition-transform duration-150`,n&&`rotate-90`),style:{color:`#6F6A60`},children:`▶`})]}),n&&(0,W.jsxs)(`div`,{className:`border-t max-h-64 overflow-auto`,style:{borderColor:i.border,background:i.surface},children:[e.name===`run_code`&&!!e.args.code&&(0,W.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word border-b`,style:{color:i.text,borderColor:i.border},children:String(e.args.code)}),d&&(0,W.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word`,style:{color:`#57534B`},children:d})]})]})}),ks=[0,.16,.32].map(e=>({animation:`aai-bounce 1.4s infinite ease-in-out both`,animationDelay:`${e}s`}));function As(){return(0,W.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-medium min-h-5`,style:{color:ss},children:ks.map((e,t)=>(0,W.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{...e,background:ss}},t))})}function js({theme:e,color:t,children:n}){return(0,W.jsx)(`div`,{className:`flex flex-col w-full items-end`,children:(0,W.jsx)(`div`,{className:`max-w-[min(78%,64ch)] border px-3.5 py-2.5 rounded-md whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[22px]`,style:{background:ds(e.primary,e.surface,7),borderColor:ds(e.primary,e.surface,16),color:t},children:n})})}var Ms=(0,B.memo)(function({message:e,theme:t}){return e.role===`user`?(0,W.jsx)(js,{theme:t,color:t.text,children:e.content}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[82%]`,children:[(0,W.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:cs},children:`Agent`}),(0,W.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:t.text},children:e.content})]})}),Ns=96;function Ps(e,t){let n=(0,B.useRef)(null),r=(0,B.useRef)(!0),i=(0,B.useRef)(!1),a=(0,B.useRef)(t);a.current=t;let o=(0,B.useCallback)(e=>{let t=e.currentTarget;r.current=t.scrollTop+t.clientHeight>=t.scrollHeight-Ns},[]);return(0,B.useEffect)(()=>{e===0||i.current||!r.current||(i.current=!0,requestAnimationFrame(()=>{i.current=!1,r.current&&n.current?.scrollIntoView({behavior:a.current?`instant`:`smooth`,block:`end`})}))},[e]),{anchorRef:n,onScroll:o}}function Fs(e,t,n,r){let i=[],a=0,o=e=>{let n=t[a];for(;n&&n.afterMessageId<=e;)i.push(r(n)),a++,n=t[a]},s=e[0];s&&o(s.id-1);for(let t of e)i.push(n(t)),o(t.id);return o(1/0),i}var Is=(0,B.memo)(function({className:e}){let t=ns(e=>e.state),n=ns(e=>e.messages),r=ns(e=>e.toolCalls),i=ns(e=>e.userTranscript),a=ns(e=>e.agentTranscript),o=ns(e=>e.contentVersion),s=os(),c=(0,B.useMemo)(()=>{if(t!==`thinking`)return!1;let e=r.at(-1);if(e?.status===`pending`)return!1;let i=n.at(-1);return!i||i.role===`user`||!!e},[t,r,n]),{anchorRef:l,onScroll:u}=Ps(o,i!==null),d=(0,B.useMemo)(()=>Fs(n,r,e=>(0,W.jsx)(Ms,{message:e,theme:s},e.id),e=>(0,W.jsx)(Os,{toolCall:e},e.callId)),[n,r,s]);return(0,W.jsx)(`div`,{role:`log`,className:Yo(`flex-1 overflow-y-auto [scrollbar-width:none]`,e),style:{background:s.surface},onScroll:u,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 p-7`,children:[d,a&&(0,W.jsx)(Ms,{message:{role:`assistant`,content:a},theme:s}),i!==null&&(0,W.jsx)(js,{theme:s,color:`#6F6A60`,children:i||(0,W.jsx)(As,{})}),c&&(0,W.jsx)(As,{}),(0,W.jsx)(`div`,{ref:l})]})})}),Ls=(0,B.memo)(function({className:e}){let t=ns(e=>e.recording),n=ns(e=>e.state),r=ts(),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),l=n!==`disconnected`&&n!==`connecting`&&n!==`error`;function u(){t?r.stopRecording():r.startRecording()}function d(e){!e||a||(o(!0),c(null),r.sendAudioFile(e).catch(e=>{c(Eo(e))}).finally(()=>{o(!1),i.current&&(i.current.value=``)}))}return(0,W.jsxs)(`div`,{className:Yo(`flex flex-col gap-1.5 shrink-0`,e),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(ms,{variant:t?`default`:`secondary`,onClick:u,disabled:!l||a,"aria-pressed":t,style:t?{background:us}:void 0,"data-testid":`record-button`,children:[(0,W.jsx)(`span`,{className:Yo(`w-2 h-2 rounded-full mr-2`,t&&`animate-pulse`),style:{background:t?`#fff`:us}}),t?`Stop recording`:`Record`]}),(0,W.jsx)(ms,{variant:`ghost`,onClick:()=>i.current?.click(),disabled:!l||a,"data-testid":`upload-button`,children:a?`Transcribing…`:`Upload audio`}),(0,W.jsx)(`input`,{ref:i,type:`file`,accept:`audio/*`,className:`hidden`,onChange:e=>d(e.target.files?.[0]),"data-testid":`upload-input`}),(0,W.jsx)(ms,{variant:`ghost`,onClick:r.reset,children:`New Conversation`}),(0,W.jsx)(bs,{className:`ml-auto max-w-[55%]`})]}),s&&(0,W.jsx)(`div`,{className:`text-[12px]`,style:{color:`#B3261E`},"data-testid":`upload-error`,children:s})]})}),Rs=new Set([`listening`,`speaking`]);function zs(e,t){switch(e){case`listening`:case`speaking`:case`ready`:return t;case`thinking`:return`#B98900`;case`error`:return us;default:return cs}}function Bs({icon:e,title:t,className:n}){let r=ns(e=>e.state),i=ns(e=>e.error),a=ns(e=>e.audioOut),o=os(),s=Rs.has(r);return(0,W.jsxs)(`div`,{className:Yo(`flex flex-col h-screen w-full max-w-190 mx-auto box-border px-6 py-8 gap-5 font-aai text-sm`,n),style:{background:o.bg,color:o.text},children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[e??(0,W.jsx)(ps,{size:22}),t&&(0,W.jsx)(`span`,{className:`font-aai-serif text-[22px] leading-[1.2] font-normal truncate`,style:{color:o.text},children:t})]}),(0,W.jsxs)(Ss,{className:`shrink-0`,"data-state":r,children:[(0,W.jsx)(`span`,{className:`w-[7px] h-[7px] rounded-full`,style:{background:zs(r,o.primary),animation:s?`aai-pulse 1.6s ease-in-out infinite`:`none`}}),r]})]}),i&&(0,W.jsx)(`div`,{className:`px-3.5 py-2.5 rounded-aai border text-[13px] leading-[130%] shrink-0`,style:{borderColor:`rgba(179,38,30,0.35)`,background:`rgba(179,38,30,0.06)`,color:`#B3261E`},children:i.message}),(0,W.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 border rounded-lg overflow-hidden`,style:{background:o.surface,borderColor:o.border,boxShadow:`0 1px 3px 0 rgb(20 18 12 / 0.06)`},children:(0,W.jsx)(Is,{})}),a?(0,W.jsx)(xs,{}):(0,W.jsx)(Ls,{})]})}function Vs({sidebar:e,children:t,sidebarWidth:n=`18rem`,sidebarPosition:r=`left`,className:i}){let a=os(),o=(0,W.jsx)(`div`,{className:`shrink-0 flex flex-col overflow-y-auto`,style:{width:n,...r===`left`?{borderRight:`1px solid ${a.border}`}:{borderLeft:`1px solid ${a.border}`}},children:e});return(0,W.jsxs)(`div`,{className:Yo(`flex h-screen`,i),style:{background:a.bg},children:[r===`left`&&o,(0,W.jsx)(`div`,{className:`flex-1 min-w-0`,children:t}),r===`right`&&o]})}function Hs({children:e,icon:t,title:n,subtitle:r,buttonText:i=`Start Conversation`,className:a}){let o=ns(e=>e.started),{start:s}=ts(),c=os();return o?e:(0,W.jsx)(`div`,{className:Yo(`flex items-center justify-center h-screen font-aai`,a),style:{background:c.bg},children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-5 border rounded-xl px-10 py-12 sm:px-16 sm:py-14 max-w-105 text-center`,style:{background:c.surface,borderColor:c.border,boxShadow:`0 4px 12px -2px rgb(20 18 12 / 0.08)`},children:[t??(0,W.jsx)(ps,{size:24}),(0,W.jsx)(Ss,{children:`Voice Agent`}),n&&(0,W.jsx)(`h1`,{className:`font-aai-serif font-normal text-[32px] leading-[1.15] tracking-[-0.2px] m-0 text-balance`,style:{color:c.text},children:n}),r&&(0,W.jsx)(`p`,{className:`text-[15px] leading-[22px] m-0 max-w-75`,style:{color:`#57534B`},children:r}),(0,W.jsx)(ms,{size:`lg`,className:`mt-2`,onClick:s,children:i})]})})}var Us=16e3,Ws=2048,Gs=`
73
+ `)[0]??``);for(let e of[`query`,`url`,`question`])if(t[e])return String(t[e]);return ws(JSON.stringify(t))},[e.name,e.args]);return(0,W.jsxs)(`div`,{className:Yo(`flex flex-col rounded-md border overflow-hidden`,t),style:{borderColor:i.border,background:i.bg},children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":u?n:void 0,disabled:s,className:Yo(`flex items-center gap-2.5 px-3.5 py-2.5 select-none text-left w-full appearance-none border-none bg-transparent`,u&&`cursor-pointer`),onClick:()=>{u&&r(!n)},children:[l?(0,W.jsx)(`span`,{className:`w-4 h-4 shrink-0 text-center leading-4`,children:l}):(0,W.jsx)(Ss,{className:`shrink-0`,style:{color:cs},children:`Tool`}),(0,W.jsx)(`span`,{className:Yo(`font-aai-mono text-[13px] font-medium`,s&&`tool-shimmer`),style:{color:i.text},children:c}),(0,W.jsx)(`span`,{className:`font-aai-mono text-[13px] truncate flex-1 min-w-0`,style:{color:cs},children:f}),u&&(0,W.jsx)(`span`,{className:Yo(`text-[10px] shrink-0 transition-transform duration-150`,n&&`rotate-90`),style:{color:`#6F6A60`},children:`▶`})]}),n&&(0,W.jsxs)(`div`,{className:`border-t max-h-64 overflow-auto`,style:{borderColor:i.border,background:i.surface},children:[e.name===`run_code`&&!!e.args.code&&(0,W.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word border-b`,style:{color:i.text,borderColor:i.border},children:String(e.args.code)}),d&&(0,W.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word`,style:{color:`#57534B`},children:d})]})]})}),ks=[0,.16,.32].map(e=>({animation:`aai-bounce 1.4s infinite ease-in-out both`,animationDelay:`${e}s`}));function As(){return(0,W.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-medium min-h-5`,style:{color:ss},children:ks.map((e,t)=>(0,W.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{...e,background:ss}},t))})}function js({theme:e,color:t,children:n}){return(0,W.jsx)(`div`,{className:`flex flex-col w-full items-end`,children:(0,W.jsx)(`div`,{className:`max-w-[min(78%,64ch)] border px-3.5 py-2.5 rounded-md whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[22px]`,style:{background:ds(e.primary,e.surface,7),borderColor:ds(e.primary,e.surface,16),color:t},children:n})})}var Ms=(0,B.memo)(function({message:e,theme:t}){return e.role===`user`?(0,W.jsx)(js,{theme:t,color:t.text,children:e.content}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[82%]`,children:[(0,W.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:cs},children:`Agent`}),(0,W.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:t.text},children:e.content})]})}),Ns=96;function Ps(e,t){let n=(0,B.useRef)(null),r=(0,B.useRef)(!0),i=(0,B.useRef)(!1),a=(0,B.useRef)(t);a.current=t;let o=(0,B.useCallback)(e=>{let t=e.currentTarget;r.current=t.scrollTop+t.clientHeight>=t.scrollHeight-Ns},[]);return(0,B.useEffect)(()=>{e===0||i.current||!r.current||(i.current=!0,requestAnimationFrame(()=>{i.current=!1,r.current&&n.current?.scrollIntoView({behavior:a.current?`instant`:`smooth`,block:`end`})}))},[e]),{anchorRef:n,onScroll:o}}function Fs(e,t,n,r){let i=[],a=0,o=e=>{let n=t[a];for(;n&&n.afterMessageId<=e;)i.push(r(n)),a++,n=t[a]},s=e[0];s&&o(s.id-1);for(let t of e)i.push(n(t)),o(t.id);return o(1/0),i}var Is=(0,B.memo)(function({className:e}){let t=ns(e=>e.state),n=ns(e=>e.messages),r=ns(e=>e.toolCalls),i=ns(e=>e.userTranscript),a=ns(e=>e.agentTranscript),o=ns(e=>e.contentVersion),s=os(),c=(0,B.useMemo)(()=>{if(t!==`thinking`)return!1;let e=r.at(-1);if(e?.status===`pending`)return!1;let i=n.at(-1);return!i||i.role===`user`||!!e},[t,r,n]),{anchorRef:l,onScroll:u}=Ps(o,i!==null),d=(0,B.useMemo)(()=>Fs(n,r,e=>(0,W.jsx)(Ms,{message:e,theme:s},e.id),e=>(0,W.jsx)(Os,{toolCall:e},e.callId)),[n,r,s]);return(0,W.jsx)(`div`,{role:`log`,className:Yo(`flex-1 overflow-y-auto [scrollbar-width:none]`,e),style:{background:s.surface},onScroll:u,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 p-7`,children:[d,a&&(0,W.jsx)(Ms,{message:{role:`assistant`,content:a},theme:s}),i!==null&&(0,W.jsx)(js,{theme:s,color:`#6F6A60`,children:i||(0,W.jsx)(As,{})}),c&&(0,W.jsx)(As,{}),(0,W.jsx)(`div`,{ref:l})]})})}),Ls=(0,B.memo)(function({className:e}){let t=ns(e=>e.recording),n=ns(e=>e.state),r=ts(),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),l=n!==`disconnected`&&n!==`connecting`&&n!==`error`;function u(){t?r.stopRecording():r.startRecording()}function d(e){!e||a||(o(!0),c(null),r.sendAudioFile(e).catch(e=>{c(Eo(e))}).finally(()=>{o(!1),i.current&&(i.current.value=``)}))}return(0,W.jsxs)(`div`,{className:Yo(`flex flex-col gap-1.5 shrink-0`,e),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(ms,{variant:t?`default`:`secondary`,onClick:u,disabled:!l||a,"aria-pressed":t,style:t?{background:us}:void 0,"data-testid":`record-button`,children:[(0,W.jsx)(`span`,{className:Yo(`w-2 h-2 rounded-full mr-2`,t&&`animate-pulse`),style:{background:t?`#fff`:us}}),t?`Stop recording`:`Record`]}),(0,W.jsx)(ms,{variant:`ghost`,onClick:()=>i.current?.click(),disabled:!l||a,"data-testid":`upload-button`,children:a?`Transcribing…`:`Upload audio`}),(0,W.jsx)(`input`,{ref:i,type:`file`,accept:`audio/*`,className:`hidden`,onChange:e=>d(e.target.files?.[0]),"data-testid":`upload-input`}),(0,W.jsx)(ms,{variant:`ghost`,onClick:r.reset,children:`New Conversation`}),(0,W.jsx)(bs,{className:`ml-auto max-w-[55%]`})]}),s&&(0,W.jsx)(`div`,{className:`text-[12px]`,style:{color:`#B3261E`},"data-testid":`upload-error`,children:s})]})}),Rs=new Set([`listening`,`speaking`]);function zs(e,t){switch(e){case`listening`:case`speaking`:case`ready`:return t;case`thinking`:return`#B98900`;case`error`:return us;default:return cs}}function Bs({icon:e,title:t,className:n}){let r=ns(e=>e.state),i=ns(e=>e.error),a=ns(e=>e.audioOut),o=os(),s=Rs.has(r);return(0,W.jsxs)(`div`,{className:Yo(`flex flex-col h-screen w-full max-w-190 mx-auto box-border px-6 py-8 gap-5 font-aai text-sm`,n),style:{background:o.bg,color:o.text},children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[e??(0,W.jsx)(ps,{size:22}),t&&(0,W.jsx)(`span`,{className:`font-aai-serif text-[22px] leading-[1.2] font-normal truncate`,style:{color:o.text},children:t})]}),(0,W.jsxs)(Ss,{className:`shrink-0`,"data-state":r,children:[(0,W.jsx)(`span`,{className:`w-[7px] h-[7px] rounded-full`,style:{background:zs(r,o.primary),animation:s?`aai-pulse 1.6s ease-in-out infinite`:`none`}}),r]})]}),i&&(0,W.jsx)(`div`,{className:`px-3.5 py-2.5 rounded-aai border text-[13px] leading-[130%] shrink-0`,style:{borderColor:`rgba(179,38,30,0.35)`,background:`rgba(179,38,30,0.06)`,color:`#B3261E`},children:i.message}),(0,W.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 border rounded-lg overflow-hidden`,style:{background:o.surface,borderColor:o.border,boxShadow:`0 1px 3px 0 rgb(20 18 12 / 0.06)`},children:(0,W.jsx)(Is,{})}),a?(0,W.jsx)(xs,{}):(0,W.jsx)(Ls,{})]})}function Vs({sidebar:e,children:t,sidebarWidth:n=`18rem`,sidebarPosition:r=`left`,className:i}){let a=os(),o=(0,W.jsx)(`div`,{className:`shrink-0 flex flex-col overflow-y-auto`,style:{width:n,...r===`left`?{borderRight:`1px solid ${a.border}`}:{borderLeft:`1px solid ${a.border}`}},children:e});return(0,W.jsxs)(`div`,{className:Yo(`flex h-screen`,i),style:{background:a.bg},children:[r===`left`&&o,(0,W.jsx)(`div`,{className:`flex-1 min-w-0`,children:t}),r===`right`&&o]})}function Hs({children:e,icon:t,title:n,subtitle:r,buttonText:i=`Start Conversation`,className:a}){let o=ns(e=>e.started),{start:s}=ts(),c=os();return o?e:(0,W.jsx)(`div`,{className:Yo(`flex items-center justify-center h-screen font-aai`,a),style:{background:c.bg},children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-5 border rounded-xl px-10 py-12 sm:px-16 sm:py-14 max-w-105 text-center`,style:{background:c.surface,borderColor:c.border,boxShadow:`0 4px 12px -2px rgb(20 18 12 / 0.08)`},children:[t??(0,W.jsx)(ps,{size:24}),(0,W.jsx)(Ss,{children:`Voice Agent`}),n&&(0,W.jsx)(`h1`,{className:`font-aai-serif font-normal text-[32px] leading-[1.15] tracking-[-0.2px] m-0 text-balance`,style:{color:c.text},children:n}),r&&(0,W.jsx)(`p`,{className:`text-[15px] leading-[22px] m-0 max-w-75`,style:{color:`#57534B`},children:r}),(0,W.jsx)(ms,{size:`lg`,className:`mt-2`,onClick:s,children:i})]})})}var Us=.015,Ws=3e4;function Gs(e){if(e.length===0)return 0;let t=0;for(let n of e){let e=n/32768;t+=e*e}return Math.sqrt(t/e.length)}function Ks(e){let t=0;for(let n of e)t+=n.length;let n=new Int16Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function qs(e){let{sampleRate:t,speechRms:n=Us,minSpeechMs:r=150,hangoverMs:i=700,prerollMs:a=300,maxUtteranceMs:o=Ws}=e,s=e=>e.length/t*1e3,c=[],l=0,u=[],d=0,f=!1,p=0,m=0;function h(){u=[],d=0,f=!1,p=0,m=0}function g(e){for(c.push(e),l+=s(e);c.length>0&&l-s(c[0])>=a;)l-=s(c.shift())}function _(e){u=[...c,e],d=l+s(e),c=[],l=0,p=s(e)}function v(){let e=Ks(u);return h(),e}function y(e,t){if(!t){g(e);return}_(e)}function b(e,t){if(!t){for(let e of u)g(e);h();return}u.push(e),d+=s(e),p+=s(e)}function x(e,t){return u.push(e),d+=s(e),m=t?0:m+s(e),m>=i?v():null}return{get speaking(){return f},push(e){if(e.length===0)return null;let t=Gs(e)>=n,i=null;return f?i=x(e,t):u.length>0?b(e,t):y(e,t),i||(!f&&p>=r&&(f=!0),f&&d>=o?v():null)},flush(){let e=f?v():null;return this.reset(),e},reset(){c=[],l=0,h()}}}var Js=2048,Ys=`
74
74
  registerProcessor("aai-sync-capture", class extends AudioWorkletProcessor {
75
75
  constructor(options) {
76
76
  super();
77
- const batch = (options && options.processorOptions && options.processorOptions.batchSamples) || ${Ws};
77
+ const batch = (options && options.processorOptions && options.processorOptions.batchSamples) || ${Js};
78
78
  this.buf = new Float32Array(batch);
79
79
  this.len = 0;
80
80
  }
@@ -97,7 +97,7 @@ registerProcessor("aai-sync-capture", class extends AudioWorkletProcessor {
97
97
  return true;
98
98
  }
99
99
  });
100
- `,Ks=URL.createObjectURL(new Blob([Gs],{type:`application/javascript`}));function qs(e){let t=new Int16Array(e.length),n=0;for(let r of e){let e=Math.max(-1,Math.min(1,r));t[n++]=e<0?e*32768:e*32767}return t}function Js(e=Us){let t=null,n=null,r=null,i=[],a=!1;async function o(){if(t)return;let o=navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),s=new AudioContext({sampleRate:e,latencyHint:`interactive`});try{let[e]=await Promise.all([o,s.resume(),s.audioWorklet.addModule(Ks)]);n=e}catch(e){throw o.then(e=>{for(let t of e.getTracks())t.stop()}).catch(()=>{}),await s.close().catch(()=>{}),e}let c=new AudioWorkletNode(s,`aai-sync-capture`,{channelCount:1,channelCountMode:`explicit`,processorOptions:{batchSamples:Ws}});c.port.onmessage=e=>{let t=e.data;a&&t.event===`chunk`&&t.samples&&i.push(t.samples)},s.createMediaStreamSource(n).connect(c),t=s,r=c}return{async start(){await o(),i=[],a=!0},async stop(){await new Promise(e=>setTimeout(e,150)),a=!1;let e=i.reduce((e,t)=>e+t.length,0),t=new Float32Array(e),n=0;for(let e of i)t.set(e,n),n+=e.length;return i=[],qs(t)},async close(){if(a=!1,r?.disconnect(),n)for(let e of n.getTracks())e.stop();await t?.close().catch(()=>{}),t=null,r=null,n=null}}}function Ys(e){let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}function Xs(e){let t=atob(e),n=t.length>>1,r=new Uint8Array(n*2);for(let e=0;e<r.length;e++)r[e]=t.charCodeAt(e);return new Int16Array(r.buffer,0,n)}function Zs(e){let t=e.fetch??((e,t)=>globalThis.fetch(e,t)),n=[],r=Promise.resolve();async function i(e){if(!e.ok){let t=Do(await e.text().catch(()=>``))??{};throw Error(`Sync turn failed: HTTP ${e.status}${t.error?` (${t.error})`:``}`)}let t=Io.safeParse(await e.json());if(!t.success)throw Error(`Sync turn failed: malformed server response`);return t.data}async function a(r){try{let a=await i(await t(e.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...r,history:[...n]})}));n.push({role:`user`,content:a.transcript}),a.reply.length>0&&n.push({role:`assistant`,content:a.reply});let o={...a,pcm:a.audio===void 0?null:Xs(a.audio)};return e.onTurn?.(o),o}catch(t){let n=t instanceof Error?t:Error(Eo(t));throw e.onError?.(n),n}}function o(e){let t=r.then(()=>a(e),()=>a(e));return r=t.catch(()=>void 0),t}return{get history(){return n},sendText(e){return o({text:e})},sendPcm16(e,t){return o({audio:Ys(e),sampleRate:t})},reset(){n.length=0}}}var Qs=Us/4;function $s(e,t){if(!(t.pcm&&t.sampleRate))return;e.current??=new AudioContext;let n=e.current,r=n.createBuffer(1,t.pcm.length,t.sampleRate),i=r.getChannelData(0);t.pcm.forEach((e,t)=>{i[t]=e/32768});let a=n.createBufferSource();a.buffer=r,a.connect(n.destination),a.start()}function ec(e,t,n){return n?`listening`:t?`thinking`:e?`error`:`ready`}function tc({syncUrl:e,title:t,greeting:n}){let r=os(),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(null),f=(0,B.useRef)(null),p=(0,B.useRef)(null),m=(0,B.useRef)(null),h=(0,B.useRef)(Zs({url:e,onTurn:e=>{a(t=>[...t,{id:t.length,heard:e.transcript,reply:e.reply}]),l(!1),d(e.ttsError?`TTS unavailable: ${e.ttsError}`:null),$s(f,e)},onError:e=>{l(!1),d(e.message)}}));(0,B.useEffect)(()=>()=>{p.current?.close(),f.current?.close()},[]);let g=i.length+ +!!c;(0,B.useEffect)(()=>{g!==0&&m.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[g]);async function _(){if(!(o||c))try{p.current??=Js(),await p.current.start(),s(!0),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}}async function v(){if(!(o&&p.current))return;s(!1),l(!0);let e=await p.current.stop();if(e.length<Qs){l(!1);return}h.current.sendPcm16(e,Us).catch(()=>{})}let y=ec(u,c,o),b=`Hold to talk`;return o?b=`Release to send`:c&&(b=`Sending…`),(0,W.jsxs)(`div`,{className:`flex flex-col h-screen w-full max-w-190 mx-auto box-border px-6 py-8 gap-5 font-aai text-sm`,style:{background:r.bg,color:r.text},children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,W.jsx)(ps,{size:22}),(0,W.jsx)(`span`,{className:`font-aai-serif text-[22px] leading-[1.2] font-normal truncate`,style:{color:r.text},children:t??`Voice Agent`})]}),(0,W.jsxs)(Ss,{className:`shrink-0`,"data-state":y,children:[(0,W.jsx)(`span`,{className:`w-[7px] h-[7px] rounded-full`,style:{background:zs(y,r.primary),animation:o?`aai-pulse 1.6s ease-in-out infinite`:`none`}}),y]})]}),u&&(0,W.jsx)(`div`,{className:`px-3.5 py-2.5 rounded-aai border text-[13px] leading-[130%] shrink-0`,style:{borderColor:`rgba(179,38,30,0.35)`,background:`rgba(179,38,30,0.06)`,color:`#B3261E`},children:u}),(0,W.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 border rounded-lg overflow-hidden`,style:{background:r.surface,borderColor:r.border,boxShadow:`0 1px 3px 0 rgb(20 18 12 / 0.06)`},children:(0,W.jsx)(`div`,{role:`log`,className:`flex-1 overflow-y-auto [scrollbar-width:none]`,style:{background:r.surface},children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5 p-7`,children:[n!==void 0&&n.length>0&&(0,W.jsx)(`p`,{className:`text-[15px] leading-[23px]`,style:{color:r.text},children:n}),i.length===0&&(0,W.jsx)(`p`,{className:`text-sm`,style:{color:`#57534B`},children:`Hold the button, speak, and release — the utterance goes out as one HTTP request to the endpoint below.`}),i.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:cs},children:`Heard`}),(0,W.jsx)(`p`,{className:`text-[15px] leading-[22px]`,style:{color:ss},children:e.heard}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none mt-1.5`,style:{color:cs},children:`Agent`}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:r.text},children:e.reply})]},e.id)),c&&(0,W.jsx)(`div`,{"data-testid":`thinking`,children:(0,W.jsx)(As,{})}),(0,W.jsx)(`div`,{ref:m})]})})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,W.jsxs)(ms,{size:`lg`,variant:o?`default`:`secondary`,disabled:c&&!o,className:`select-none touch-none`,style:o?{background:us,borderColor:`transparent`}:void 0,onPointerDown:()=>void _(),onPointerUp:()=>void v(),onPointerLeave:()=>void v(),"aria-pressed":o,title:`Hold to record — release to send`,children:[(0,W.jsx)(`span`,{className:Yo(`w-2 h-2 rounded-full mr-2`,o&&`animate-pulse`),style:{background:o?`#fff`:us}}),b]}),(0,W.jsx)(gs,{label:`Sync`,url:e,hint:`Each utterance is one POST to this endpoint`,testId:`sync-url-chip`,className:`ml-auto min-w-0 max-w-[55%]`})]})]})}var nc=`modulepreload`,rc=function(e,t){return new URL(e,t).href},ic={},ac=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=rc(t,n),t=s(t),t in ic)return;ic[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:nc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};async function oc(e,t,n,r){if(e.audioSetupInFlight)return;e.audioSetupInFlight=!0;let i=e.generation,a=()=>e.generation!==i||!e.ws||e.ws.readyState!==1,o=e=>{r?n.updateState({state:`error`,error:{code:`audio`,message:e},running:!1,recording:!1}):(n.cleanupAudio(),n.updateState({error:{code:`audio`,message:e},recording:!1}))};try{let[{createVoiceIO:r},s,c]=await Promise.all([ac(()=>import(`./audio-Bx1LT4Do.js`),[],import.meta.url),ac(()=>import(`./capture-processor-UlKEKyIW.js`).then(e=>e.default),[],import.meta.url),ac(()=>import(`./playback-processor-C5HVRVbu.js`).then(e=>e.default),[],import.meta.url)]),l=await r({sttSampleRate:t.sampleRate,ttsSampleRate:t.ttsSampleRate,captureWorkletSrc:s,playbackWorkletSrc:c,onMicData:e=>{try{n.sendAudio(new Uint8Array(e))}catch{console.debug(`[aai-ui] sendAudio dropped: connection closed`)}},onError:t=>{e.generation===i&&o(t.message)}});if(a()){l.close().catch(()=>{});return}if(e.voiceIO?.close().catch(()=>{}),e.voiceIO=l,e.preInitAudio.length>0){for(let t of e.preInitAudio)l.enqueue(t.buffer);e.preInitAudio=[]}n.sendJson({type:`audio_ready`}),n.updateState({recording:!0}),e.preInitDone?(e.preInitDone=!1,n.settleWhenAudioDrained(l)):n.updateState({state:`listening`})}catch(e){if(a())return;o(`Microphone access failed: ${Eo(e)}`)}finally{e.generation===i&&(e.audioSetupInFlight=!1)}}var sc=200,cc=200,lc=100,uc={messages:[],toolCalls:[],customEvents:[],userTranscript:null,agentTranscript:null,error:null};function dc(e,t,n){if(e.length<n)return[...e,t];let r=e.slice(e.length-n+1);return r.push(t),r}function fc(e){let{getSnapshot:t,updateState:n,conn:r,discardUpload:i,cleanupAudio:a}=e,o=0,s=0,c=0,l=0;function u(e,r){n({customEvents:dc(t().customEvents,{id:++s,event:e,data:r},sc)})}function d(e){o++,n({userTranscript:null,messages:dc(t().messages,{id:++c,role:`user`,content:e},cc),state:`thinking`})}function f(e){n({agentTranscript:null,messages:dc(t().messages,{id:++c,role:`assistant`,content:e},cc)})}function p(){let e=t();e.state===`error`?n({state:`listening`,error:null}):e.error!==null&&n({error:null})}function m(e){console.error(`Agent error:`,e.message),e.fatal===!1?n({error:{code:e.code,message:e.message}}):(a(),n({state:`error`,error:{code:e.code,message:e.message},running:!1,recording:!1}))}function h(e){switch(e.type!==`error`&&p(),e.type){case`speech_started`:n({userTranscript:``});break;case`speech_stopped`:break;case`user_transcript`:d(e.text);break;case`user_transcript_partial`:n({userTranscript:e.text});break;case`agent_transcript`:f(e.text);break;case`tool_call`:n({toolCalls:dc(t().toolCalls,{callId:e.toolCallId,name:e.toolName,args:e.args??{},status:`pending`,seq:++l,afterMessageId:t().messages.at(-1)?.id??-1},cc)});break;case`tool_call_done`:{let r=t().toolCalls,i=r.findIndex(t=>t.callId===e.toolCallId);if(i!==-1){let t=[...r],a=t[i];a&&(t[i]={...a,status:`done`,result:e.result}),n({toolCalls:t})}break}case`reply_done`:n({state:`listening`});break;case`cancelled`:o++,r.voiceIO?.flush(),n({userTranscript:null,agentTranscript:null,state:`listening`});break;case`reset`:o++,i(),r.voiceIO?.flush(),n({...uc,state:`listening`});break;case`custom_event`:u(e.event,e.data);break;case`error`:m(e);break;case`idle_timeout`:break;default:break}}function g(e){let i=t();i.state===`error`||i.state===`disconnected`&&i.error!==null||(i.state!==`speaking`&&n({state:`speaking`}),r.voiceIO?r.voiceIO.enqueue(e.buffer):r.preInitAudio.length<lc&&r.preInitAudio.push(e))}function _(e){let t=o;e.done().then(()=>{o===t&&n({state:`listening`})}).catch(e=>{console.warn(`Audio playback done failed:`,e)})}function v(){let e=r.voiceIO;e?_(e):(r.preInitDone=!0,n({state:`listening`}))}function y(e){if(e instanceof ArrayBuffer){g(new Uint8Array(e));return}if(typeof e!=`string`){console.warn(`session-core: non-string, non-binary frame received; dropping`);return}let t=Do(e);if(t===void 0){console.warn(`session-core: invalid JSON; dropping`);return}let n=Ro(Uo,t);if(!n.ok){n.malformed&&console.warn(`session-core: malformed server message`,n.error);return}let r=n.data;if(r.type===`config`)return{sampleRate:r.sampleRate,ttsSampleRate:r.ttsSampleRate,audioOut:r.audioOut,sid:r.sessionId};if(r.type===`audio_done`){v();return}h(r)}return{handleMessage:y,settleWhenAudioDrained:_}}(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
100
+ `,Xs=URL.createObjectURL(new Blob([Ys],{type:`application/javascript`}));function Zs(e){let t=new Int16Array(e.length),n=0;for(let r of e){let e=Math.max(-1,Math.min(1,r));t[n++]=e<0?e*32768:e*32767}return t}async function Qs(e){let t=e.sampleRate??16e3,n=qs({sampleRate:t,...e.vad}),r=t=>{e.onError?.(t instanceof Error?t:Error(Eo(t)))},i=navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),a=new AudioContext({sampleRate:t,latencyHint:`interactive`}),o;try{[o]=await Promise.all([i,a.resume(),a.audioWorklet.addModule(Xs)])}catch(e){throw i.then(e=>{for(let t of e.getTracks())t.stop()}).catch(()=>{}),await a.close().catch(()=>{}),e}let s=a.createMediaStreamSource(o),c=new AudioWorkletNode(a,`aai-sync-capture`,{channelCount:1,channelCountMode:`explicit`,processorOptions:{batchSamples:Js}});s.connect(c);let l=!1,u=!1;function d(n){n&&(e.onSpeechEnd?.(),e.session.sendPcm16(n,t).catch(r))}function f(t){l||(d(n.push(Zs(t))),n.speaking&&!u&&e.onSpeechStart?.(),u=n.speaking)}return c.port.onmessage=e=>{let t=e.data;t.event===`chunk`&&t.samples&&f(t.samples)},c.onprocessorerror=()=>r(Error(`Sync capture worklet crashed`)),{get speaking(){return n.speaking},async stop(){if(!l){l=!0,d(n.flush()),s.disconnect(),c.disconnect();for(let e of o.getTracks())e.stop();await a.close().catch(()=>{})}}}}function $s(e){let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}function ec(e){let t=atob(e),n=t.length>>1,r=new Uint8Array(n*2);for(let e=0;e<r.length;e++)r[e]=t.charCodeAt(e);return new Int16Array(r.buffer,0,n)}function tc(e){let t=e.fetch??((e,t)=>globalThis.fetch(e,t)),n=[],r=Promise.resolve();async function i(e){if(!e.ok){let t=Do(await e.text().catch(()=>``))??{};throw Error(`Sync turn failed: HTTP ${e.status}${t.error?` (${t.error})`:``}`)}let t=Io.safeParse(await e.json());if(!t.success)throw Error(`Sync turn failed: malformed server response`);return t.data}async function a(r){try{let a=await i(await t(e.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...r,history:[...n]})}));n.push({role:`user`,content:a.transcript}),a.reply.length>0&&n.push({role:`assistant`,content:a.reply});let o={...a,pcm:a.audio===void 0?null:ec(a.audio)};return e.onTurn?.(o),o}catch(t){let n=t instanceof Error?t:Error(Eo(t));throw e.onError?.(n),n}}function o(e){let t=r.then(()=>a(e),()=>a(e));return r=t.catch(()=>void 0),t}return{get history(){return n},sendText(e){return o({text:e})},sendPcm16(e,t){return o({audio:$s(e),sampleRate:t})},reset(){n.length=0}}}function nc(e,t,n){if(!(t.pcm&&t.sampleRate))return;e.current??=new AudioContext;let r=e.current,i=r.createBuffer(1,t.pcm.length,t.sampleRate),a=i.getChannelData(0);t.pcm.forEach((e,t)=>{a[t]=e/32768});let o=r.createBufferSource();o.buffer=i,o.connect(r.destination),o.onended=()=>n(!1),n(!0),o.start()}function rc(e){return e.pending>0?`thinking`:e.agentSpeaking?`speaking`:e.live?`listening`:e.error?`error`:`ready`}function ic({syncUrl:e,title:t,greeting:n}){let r=os(),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(0),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(null),g=(0,B.useRef)(null),_=(0,B.useRef)(null),v=(0,B.useRef)(!1),y=(0,B.useRef)(null),b=(0,B.useRef)(tc({url:e,onTurn:e=>{a(t=>[...t,{id:t.length,heard:e.transcript,reply:e.reply}]),d(e=>Math.max(0,e-1)),h(e.ttsError?`TTS unavailable: ${e.ttsError}`:null),nc(g,e,p)},onError:e=>{d(e=>Math.max(0,e-1)),h(e.message)}}));(0,B.useEffect)(()=>()=>{_.current?.stop(),g.current?.close()},[]);let x=i.length+ +(u>0);(0,B.useEffect)(()=>{x!==0&&y.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[x]);async function S(){if(!v.current){v.current=!0;try{if(_.current){let e=_.current;_.current=null,s(!1),l(!1),await e.stop();return}_.current=await Qs({session:b.current,onSpeechStart:()=>l(!0),onSpeechEnd:()=>{l(!1),d(e=>e+1)},onError:e=>h(e.message)}),s(!0),h(null)}catch(e){h(e instanceof Error?e.message:String(e))}finally{v.current=!1}}}let C=rc({error:m,live:o,pending:u,agentSpeaking:f}),w=o?`End conversation`:`Start conversation`,ee=c||f;return(0,W.jsxs)(`div`,{className:`flex flex-col h-screen w-full max-w-190 mx-auto box-border px-6 py-8 gap-5 font-aai text-sm`,style:{background:r.bg,color:r.text},children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,W.jsx)(ps,{size:22}),(0,W.jsx)(`span`,{className:`font-aai-serif text-[22px] leading-[1.2] font-normal truncate`,style:{color:r.text},children:t??`Voice Agent`})]}),(0,W.jsxs)(Ss,{className:`shrink-0`,"data-state":C,children:[(0,W.jsx)(`span`,{className:`w-[7px] h-[7px] rounded-full`,style:{background:zs(C,r.primary),animation:ee?`aai-pulse 1.6s ease-in-out infinite`:`none`}}),C]})]}),m&&(0,W.jsx)(`div`,{className:`px-3.5 py-2.5 rounded-aai border text-[13px] leading-[130%] shrink-0`,style:{borderColor:`rgba(179,38,30,0.35)`,background:`rgba(179,38,30,0.06)`,color:`#B3261E`},children:m}),(0,W.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 border rounded-lg overflow-hidden`,style:{background:r.surface,borderColor:r.border,boxShadow:`0 1px 3px 0 rgb(20 18 12 / 0.06)`},children:(0,W.jsx)(`div`,{role:`log`,className:`flex-1 overflow-y-auto [scrollbar-width:none]`,style:{background:r.surface},children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5 p-7`,children:[n!==void 0&&n.length>0&&(0,W.jsx)(`p`,{className:`text-[15px] leading-[23px]`,style:{color:r.text},children:n}),i.length===0&&(0,W.jsx)(`p`,{className:`text-sm`,style:{color:`#57534B`},children:`Start the conversation and just talk — each pause endpoints an utterance, which goes out as one HTTP request to the endpoint below.`}),i.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:cs},children:`Heard`}),(0,W.jsx)(`p`,{className:`text-[15px] leading-[22px]`,style:{color:ss},children:e.heard}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none mt-1.5`,style:{color:cs},children:`Agent`}),(0,W.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:r.text},children:e.reply})]},e.id)),u>0&&(0,W.jsx)(`div`,{"data-testid":`thinking`,children:(0,W.jsx)(As,{})}),(0,W.jsx)(`div`,{ref:y})]})})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,W.jsxs)(ms,{size:`lg`,variant:o?`default`:`secondary`,className:`select-none`,style:o?{background:us,borderColor:`transparent`}:void 0,onClick:()=>void S(),"aria-pressed":o,title:`Start or end the conversation`,children:[(0,W.jsx)(`span`,{className:Yo(`w-2 h-2 rounded-full mr-2`,ee&&`animate-pulse`),style:{background:o?`#fff`:us}}),w]}),(0,W.jsx)(gs,{label:`Sync`,url:e,hint:`Each utterance is one POST to this endpoint`,testId:`sync-url-chip`,className:`ml-auto min-w-0 max-w-[55%]`})]})]})}var ac=`modulepreload`,oc=function(e,t){return new URL(e,t).href},sc={},cc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=oc(t,n),t=s(t),t in sc)return;sc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ac,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};async function lc(e,t,n,r){if(e.audioSetupInFlight)return;e.audioSetupInFlight=!0;let i=e.generation,a=()=>e.generation!==i||!e.ws||e.ws.readyState!==1,o=e=>{r?n.updateState({state:`error`,error:{code:`audio`,message:e},running:!1,recording:!1}):(n.cleanupAudio(),n.updateState({error:{code:`audio`,message:e},recording:!1}))};try{let[{createVoiceIO:r},s,c]=await Promise.all([cc(()=>import(`./audio-CTPVKBQ_.js`),[],import.meta.url),cc(()=>import(`./capture-processor-UlKEKyIW.js`).then(e=>e.default),[],import.meta.url),cc(()=>import(`./playback-processor-C5HVRVbu.js`).then(e=>e.default),[],import.meta.url)]),l=await r({sttSampleRate:t.sampleRate,ttsSampleRate:t.ttsSampleRate,captureWorkletSrc:s,playbackWorkletSrc:c,onMicData:e=>{try{n.sendAudio(new Uint8Array(e))}catch{console.debug(`[aai-ui] sendAudio dropped: connection closed`)}},onError:t=>{e.generation===i&&o(t.message)}});if(a()){l.close().catch(()=>{});return}if(e.voiceIO?.close().catch(()=>{}),e.voiceIO=l,e.preInitAudio.length>0){for(let t of e.preInitAudio)l.enqueue(t.buffer);e.preInitAudio=[]}n.sendJson({type:`audio_ready`}),n.updateState({recording:!0}),e.preInitDone?(e.preInitDone=!1,n.settleWhenAudioDrained(l)):n.updateState({state:`listening`})}catch(e){if(a())return;o(`Microphone access failed: ${Eo(e)}`)}finally{e.generation===i&&(e.audioSetupInFlight=!1)}}var uc=200,dc=200,fc=100,pc={messages:[],toolCalls:[],customEvents:[],userTranscript:null,agentTranscript:null,error:null};function mc(e,t,n){if(e.length<n)return[...e,t];let r=e.slice(e.length-n+1);return r.push(t),r}function hc(e){let{getSnapshot:t,updateState:n,conn:r,discardUpload:i,cleanupAudio:a}=e,o=0,s=0,c=0,l=0;function u(e,r){n({customEvents:mc(t().customEvents,{id:++s,event:e,data:r},uc)})}function d(e){o++,n({userTranscript:null,messages:mc(t().messages,{id:++c,role:`user`,content:e},dc),state:`thinking`})}function f(e){n({agentTranscript:null,messages:mc(t().messages,{id:++c,role:`assistant`,content:e},dc)})}function p(){let e=t();e.state===`error`?n({state:`listening`,error:null}):e.error!==null&&n({error:null})}function m(e){console.error(`Agent error:`,e.message),e.fatal===!1?n({error:{code:e.code,message:e.message}}):(a(),n({state:`error`,error:{code:e.code,message:e.message},running:!1,recording:!1}))}function h(e){switch(e.type!==`error`&&p(),e.type){case`speech_started`:n({userTranscript:``});break;case`speech_stopped`:break;case`user_transcript`:d(e.text);break;case`user_transcript_partial`:n({userTranscript:e.text});break;case`agent_transcript`:f(e.text);break;case`tool_call`:n({toolCalls:mc(t().toolCalls,{callId:e.toolCallId,name:e.toolName,args:e.args??{},status:`pending`,seq:++l,afterMessageId:t().messages.at(-1)?.id??-1},dc)});break;case`tool_call_done`:{let r=t().toolCalls,i=r.findIndex(t=>t.callId===e.toolCallId);if(i!==-1){let t=[...r],a=t[i];a&&(t[i]={...a,status:`done`,result:e.result}),n({toolCalls:t})}break}case`reply_done`:n({state:`listening`});break;case`cancelled`:o++,r.voiceIO?.flush(),n({userTranscript:null,agentTranscript:null,state:`listening`});break;case`reset`:o++,i(),r.voiceIO?.flush(),n({...pc,state:`listening`});break;case`custom_event`:u(e.event,e.data);break;case`error`:m(e);break;case`idle_timeout`:break;default:break}}function g(e){let i=t();i.state===`error`||i.state===`disconnected`&&i.error!==null||(i.state!==`speaking`&&n({state:`speaking`}),r.voiceIO?r.voiceIO.enqueue(e.buffer):r.preInitAudio.length<fc&&r.preInitAudio.push(e))}function _(e){let t=o;e.done().then(()=>{o===t&&n({state:`listening`})}).catch(e=>{console.warn(`Audio playback done failed:`,e)})}function v(){let e=r.voiceIO;e?_(e):(r.preInitDone=!0,n({state:`listening`}))}function y(e){if(e instanceof ArrayBuffer){g(new Uint8Array(e));return}if(typeof e!=`string`){console.warn(`session-core: non-string, non-binary frame received; dropping`);return}let t=Do(e);if(t===void 0){console.warn(`session-core: invalid JSON; dropping`);return}let n=Ro(Uo,t);if(!n.ok){n.malformed&&console.warn(`session-core: malformed server message`,n.error);return}let r=n.data;if(r.type===`config`)return{sampleRate:r.sampleRate,ttsSampleRate:r.ttsSampleRate,audioOut:r.audioOut,sid:r.sessionId};if(r.type===`audio_done`){v();return}h(r)}return{handleMessage:y,settleWhenAudioDrained:_}}(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
101
101
  PartySocket requires a global 'EventTarget' class to be available!
102
102
  You can polyfill this global by adding this to your code before any partysocket imports:
103
103
 
@@ -105,7 +105,7 @@ registerProcessor("aai-sync-capture", class extends AudioWorkletProcessor {
105
105
  import 'partysocket/event-target-polyfill';
106
106
  \`\`\`
107
107
  Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
108
- `);var pc=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},mc=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}},hc={Event,ErrorEvent:pc,CloseEvent:mc};function gc(e,t){if(!e)throw Error(t)}function _c(e){return new e.constructor(e.type,e)}function vc(e){return`data`in e?new MessageEvent(e.type,e):`code`in e||`reason`in e?new mc(e.code||1999,e.reason||`unknown reason`,e):`error`in e?new pc(e.error,e):new Event(e.type,e)}var yc=typeof process<`u`&&process.versions?.node!==void 0,bc=typeof navigator<`u`&&navigator.product===`ReactNative`,xc=yc||bc?vc:_c,Sc={maxReconnectionDelay:1e4,minReconnectionDelay:3e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},Cc=!1;function wc(){}var Tc=class e extends EventTarget{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType=`blob`;_closeCalled=!1;_didWarnAboutClosedSend=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,n={}){super(),this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>(typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:``}get protocol(){return this._ws?this._ws.protocol:``}get readyState(){return this._closeCalled?e.CLOSED:this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:``}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug(`close enqueued: no ws instance`);return}if(this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING){this._debug(`close: already closing or closed`);return}this._disconnect(e,t)}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._didWarnAboutClosedSend=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING||this._disconnect(e,t),this._connect()}send(e){if(this._ws&&this._ws.readyState===this.OPEN)return this._debug(`send`,e),this._ws.send(e),!0;this._closeCalled&&!this._didWarnAboutClosedSend&&(this._didWarnAboutClosedSend=!0,console.warn(`ReconnectingWebSocket: send() was called after close(). The message has been buffered, but it will only be delivered if reconnect() is called on this socket. If this socket has been discarded, the message is lost — this usually means a stale socket reference is being used.`));let{maxEnqueuedMessages:t=Sc.maxEnqueuedMessages}=this._options;return this._messageQueue.length<t&&(this._debug(`enqueue`,e),this._messageQueue.push(e)),!1}drainQueuedMessages(){let e=this._messageQueue;return this._messageQueue=[],e}_debug(...e){this._options.debug&&this._debugLogger(`RWS>`,...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=Sc.reconnectionDelayGrowFactor,minReconnectionDelay:t=Sc.minReconnectionDelay,maxReconnectionDelay:n=Sc.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=t*e**(this._retryCount-1),r>n&&(r=n)),this._debug(`next delay`,r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextProtocols(e){if(!e)return Promise.resolve(null);if(typeof e==`string`||Array.isArray(e))return Promise.resolve(e);if(typeof e==`function`){let t=e();if(!t)return Promise.resolve(null);if(typeof t==`string`||Array.isArray(t))return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid protocols`)}_getNextUrl(e){if(typeof e==`string`)return Promise.resolve(e);if(typeof e==`function`){let t=e();if(typeof t==`string`)return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid URL`)}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:e=Sc.maxRetries,connectionTimeout:t=Sc.connectionTimeout}=this._options;if(this._retryCount>=e){this._debug(`max retries reached`,this._retryCount,`>=`,e),this._connectLock=!1;return}this._retryCount++,this._debug(`connect`,this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([e,n])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>`u`&&!Cc&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.
108
+ `);var gc=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},_c=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}},vc={Event,ErrorEvent:gc,CloseEvent:_c};function yc(e,t){if(!e)throw Error(t)}function bc(e){return new e.constructor(e.type,e)}function xc(e){return`data`in e?new MessageEvent(e.type,e):`code`in e||`reason`in e?new _c(e.code||1999,e.reason||`unknown reason`,e):`error`in e?new gc(e.error,e):new Event(e.type,e)}var Sc=typeof process<`u`&&process.versions?.node!==void 0,Cc=typeof navigator<`u`&&navigator.product===`ReactNative`,wc=Sc||Cc?xc:bc,Tc={maxReconnectionDelay:1e4,minReconnectionDelay:3e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},Ec=!1;function Dc(){}var Oc=class e extends EventTarget{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType=`blob`;_closeCalled=!1;_didWarnAboutClosedSend=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,n={}){super(),this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>(typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:``}get protocol(){return this._ws?this._ws.protocol:``}get readyState(){return this._closeCalled?e.CLOSED:this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:``}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug(`close enqueued: no ws instance`);return}if(this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING){this._debug(`close: already closing or closed`);return}this._disconnect(e,t)}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._didWarnAboutClosedSend=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING||this._disconnect(e,t),this._connect()}send(e){if(this._ws&&this._ws.readyState===this.OPEN)return this._debug(`send`,e),this._ws.send(e),!0;this._closeCalled&&!this._didWarnAboutClosedSend&&(this._didWarnAboutClosedSend=!0,console.warn(`ReconnectingWebSocket: send() was called after close(). The message has been buffered, but it will only be delivered if reconnect() is called on this socket. If this socket has been discarded, the message is lost — this usually means a stale socket reference is being used.`));let{maxEnqueuedMessages:t=Tc.maxEnqueuedMessages}=this._options;return this._messageQueue.length<t&&(this._debug(`enqueue`,e),this._messageQueue.push(e)),!1}drainQueuedMessages(){let e=this._messageQueue;return this._messageQueue=[],e}_debug(...e){this._options.debug&&this._debugLogger(`RWS>`,...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=Tc.reconnectionDelayGrowFactor,minReconnectionDelay:t=Tc.minReconnectionDelay,maxReconnectionDelay:n=Tc.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=t*e**(this._retryCount-1),r>n&&(r=n)),this._debug(`next delay`,r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextProtocols(e){if(!e)return Promise.resolve(null);if(typeof e==`string`||Array.isArray(e))return Promise.resolve(e);if(typeof e==`function`){let t=e();if(!t)return Promise.resolve(null);if(typeof t==`string`||Array.isArray(t))return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid protocols`)}_getNextUrl(e){if(typeof e==`string`)return Promise.resolve(e);if(typeof e==`function`){let t=e();if(typeof t==`string`)return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid URL`)}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:e=Tc.maxRetries,connectionTimeout:t=Tc.connectionTimeout}=this._options;if(this._retryCount>=e){this._debug(`max retries reached`,this._retryCount,`>=`,e),this._connectLock=!1;return}this._retryCount++,this._debug(`connect`,this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([e,n])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>`u`&&!Ec&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.
109
109
 
110
110
  For example, if you're using node.js, run \`npm install ws\`, and then in your code:
111
111
 
@@ -118,4 +118,4 @@ const partysocket = new PartySocket({
118
118
  WebSocket: WS
119
119
  });
120
120
 
121
- `),Cc=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new hc.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new hc.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new hc.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=Sc.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),gc(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(xc(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(xc(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(xc(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(xc(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,wc))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},Ec={minReconnectionDelay:1e3,maxReconnectionDelay:15e3,reconnectionDelayGrowFactor:2,maxRetries:10};function Dc(e){return new Tc(e,void 0,Ec)}function Oc(e){return e instanceof Tc&&e.shouldReconnect&&e.retryCount<Ec.maxRetries}function kc(e){let{conn:t,getSnapshot:n,sendJson:r}=e,i=!1,a=0;async function o(e,n){for(let r=0;r<e.byteLength;r+=Co){for(;n===a&&t.ws&&t.ws.readyState===1&&t.ws.bufferedAmount>65536;)await new Promise(e=>setTimeout(e,50));if(n!==a)throw Error(`sendAudioFile: session was reset mid-send`);if(!t.ws||t.ws.readyState!==1)throw Error(`sendAudioFile: connection closed mid-send`);t.ws.send(e.subarray(r,r+Co))}}function s(){let e=t.readyConfig;if(!(e&&t.ws)||t.ws.readyState!==1)throw Error(`sendAudioFile: session is not connected`);let r=n();if(r.audioOut)throw Error(`sendAudioFile is only available in text-only sessions (tts: none()) — voice sessions stream the microphone instead`);if(r.recording)throw Error(`sendAudioFile: stop recording before uploading a file`);if(i)throw Error(`sendAudioFile: another upload is already in progress`);return e}async function c(e){let c=s();i=!0;let l=a;try{let{decodeAudioToPcm16:i}=await ac(async()=>{let{decodeAudioToPcm16:e}=await import(`./audio-Bx1LT4Do.js`);return{decodeAudioToPcm16:e}},[],import.meta.url),s=await i(await e.arrayBuffer(),c.sampleRate);if(n().recording||t.audioSetupInFlight)throw Error(`sendAudioFile: stop recording before uploading a file`);if(l!==a)throw Error(`sendAudioFile: session was reset mid-send`);if(s.length/c.sampleRate<=120){let e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);r({type:`transcribe_file_start`,sampleRate:c.sampleRate,byteLength:e.byteLength}),await o(e,l),r({type:`transcribe_file_end`});return}let u=new Int16Array(s.length+c.sampleRate);u.set(s),await o(new Uint8Array(u.buffer),l)}finally{i=!1}}return{sendAudioFile:c,inFlight:()=>i,discard:()=>{a++}}}function Ac(e,t,n){let r=new URL(`websocket`,e.endsWith(`/`)?e:`${e}/`);return r.protocol=r.protocol===`https:`?`wss:`:`ws:`,n?r.searchParams.set(`sessionId`,n):t&&r.searchParams.set(`resume`,`1`),r}function jc(e){let t={...uc,state:`disconnected`,contentVersion:0,started:!1,running:!1,audioOut:!0,recording:!1,apiUrl:Ac(e.platformUrl,!1).toString()},n=new Set;function r(){for(let e of n)e()}let i=[`messages`,`toolCalls`,`userTranscript`,`agentTranscript`];function a(e){t=i.some(n=>n in e&&e[n]!==t[n])?{...t,...e,contentVersion:t.contentVersion+1}:{...t,...e},r()}function o(){return t}function s(e){return n.add(e),()=>{n.delete(e)}}let c={ws:null,voiceIO:null,audioSetupInFlight:!1,generation:0,preInitAudio:[],preInitDone:!1,readyConfig:null},l=null,u=!1;function d(){h.discard(),c.audioSetupInFlight=!1,c.voiceIO?.close().catch(()=>{}),c.voiceIO=null,c.preInitAudio=[],c.preInitDone=!1}function f(){a(uc)}function p(e){c.ws&&c.ws.readyState===1&&c.ws.send(JSON.stringify(e))}function m(e){!c.ws||c.ws.readyState!==1||c.ws.bufferedAmount>65536||c.ws.send(e)}let h=kc({conn:c,getSnapshot:o,sendJson:p}),{handleMessage:g,settleWhenAudioDrained:_}=fc({getSnapshot:o,updateState:a,conn:c,discardUpload:h.discard,cleanupAudio:d}),v={sendJson:p,sendAudio:m,updateState:a,settleWhenAudioDrained:_,cleanupAudio:d};function y(){l?.abort(),l=null,d(),c.ws?.close(),c.ws=null}function b(n){n.sid&&e.onSessionId?.(n.sid);let r=u;u=!0,c.readyConfig={sampleRate:n.sampleRate,ttsSampleRate:n.ttsSampleRate};let i=n.audioOut!==!1;a({audioOut:i}),i?oc(c,n,v,!0):(p({type:`audio_ready`}),a({state:`listening`})),r&&t.messages.length>0&&p({type:`history`,messages:t.messages.map(e=>({role:e.role,content:e.content}))})}function x(){let t=u?void 0:e.resumeSessionId;return Ac(e.platformUrl,u,t).toString()}function S(){return e.WebSocket?new e.WebSocket(x()):Dc(x)}function C(e){if(e?.signal?.aborted){te();return}a({state:`connecting`,error:null}),y(),c.generation++;let n=new AbortController;l=n;let{signal:r}=n;e?.signal&&e.signal.addEventListener(`abort`,()=>te(),{signal:r});let i=S();i.binaryType=`arraybuffer`,c.ws=i;let o=!1;i.addEventListener(`open`,()=>{a({state:`ready`})},{signal:r}),i.addEventListener(`message`,e=>{let t=g(e.data);t&&b(t)},{signal:r}),i.addEventListener(`error`,()=>{o=!0},{signal:r}),i.addEventListener(`close`,()=>{if(!r.aborted){if(d(),Oc(i)){c.generation++,o=!1,a({state:`connecting`,recording:!1});return}n.abort(),i.close(),c.ws=null,o?a({state:`error`,error:{code:`connection`,message:`WebSocket connection error`},running:!1,recording:!1}):t.state===`error`?a({running:!1,recording:!1}):a({state:`disconnected`,error:null,running:!1,recording:!1})}},{signal:r})}function w(){!c.ws||c.ws.readyState!==1||(c.voiceIO?.flush(),a({state:`listening`}),p({type:`cancel`}))}function ee(){if(h.discard(),c.voiceIO?.flush(),c.ws&&c.ws.readyState===1){p({type:`reset`});return}f(),te(),a({running:!0}),C()}function te(){y(),a({state:`disconnected`,running:!1,recording:!1})}function ne(){if(t.audioOut||t.recording||c.audioSetupInFlight||h.inFlight())return;let e=c.readyConfig;!(e&&c.ws)||c.ws.readyState!==1||oc(c,e,v,!1)}function re(){t.audioOut||!t.recording||(d(),a({recording:!1}))}function ie(){a({started:!0,running:!0}),C()}function ae(){t.running?te():(a({running:!0}),C())}return{getSnapshot:o,subscribe:s,connect:C,cancel:w,resetState:f,reset:ee,disconnect:te,start:ie,toggle:ae,startRecording:ne,stopRecording:re,sendAudioFile:h.sendAudioFile,[Symbol.dispose](){te()}}}function Mc(e=`#app`){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}function Nc({name:e,Sidebar:t,sidebarWidth:n}){let r=(0,W.jsx)(Bs,{title:e});return(0,W.jsx)(Hs,{title:e,children:t?(0,W.jsx)(Vs,{sidebar:(0,W.jsx)(t,{}),sidebarWidth:n,children:r}):r})}function Pc({platformUrl:e,transport:t,name:n,Sidebar:r,sidebarWidth:i}){let[a,o]=(0,B.useState)(t===void 0?null:{transport:t});return(0,B.useEffect)(()=>{if(t!==void 0)return;let n=!1;return qo(e).then(e=>{n||o(e)}),()=>{n=!0}},[e,t]),a?.transport===`sync`?(0,W.jsx)(tc,{syncUrl:Go(e,`sync`).href,title:n??a.name,greeting:a.greeting}):(0,W.jsx)(Nc,{name:n,Sidebar:r,sidebarWidth:i})}function Fc(e){let t=Mc(e.target),n=e.platformUrl??globalThis.location.origin+globalThis.location.pathname,r=jc({platformUrl:n,onSessionId:e.onSessionId,resumeSessionId:e.resumeSessionId,WebSocket:e.WebSocket}),i=e.component?(0,B.createElement)(e.component):(0,B.createElement)(Pc,{platformUrl:n,transport:e.transport,name:e.name,Sidebar:e.sidebar,sidebarWidth:e.sidebarWidth}),a=e.tools??{},o=(0,fo.createRoot)(t);(0,uo.flushSync)(()=>{o.render((0,B.createElement)(Ts.Provider,{value:a},(0,B.createElement)(is,{value:e.theme},(0,B.createElement)(es,{value:r},i))))});let s={session:r,dispose(){o.unmount(),r[Symbol.dispose]()},[Symbol.dispose](){s.dispose()}};return s}Fc({});export{wo as t};
121
+ `),Ec=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new vc.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new vc.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new vc.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=Tc.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),yc(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(wc(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(wc(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(wc(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(wc(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,Dc))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},kc={minReconnectionDelay:1e3,maxReconnectionDelay:15e3,reconnectionDelayGrowFactor:2,maxRetries:10};function Ac(e){return new Oc(e,void 0,kc)}function jc(e){return e instanceof Oc&&e.shouldReconnect&&e.retryCount<kc.maxRetries}function Mc(e){let{conn:t,getSnapshot:n,sendJson:r}=e,i=!1,a=0;async function o(e,n){for(let r=0;r<e.byteLength;r+=Co){for(;n===a&&t.ws&&t.ws.readyState===1&&t.ws.bufferedAmount>65536;)await new Promise(e=>setTimeout(e,50));if(n!==a)throw Error(`sendAudioFile: session was reset mid-send`);if(!t.ws||t.ws.readyState!==1)throw Error(`sendAudioFile: connection closed mid-send`);t.ws.send(e.subarray(r,r+Co))}}function s(){let e=t.readyConfig;if(!(e&&t.ws)||t.ws.readyState!==1)throw Error(`sendAudioFile: session is not connected`);let r=n();if(r.audioOut)throw Error(`sendAudioFile is only available in text-only sessions (tts: none()) — voice sessions stream the microphone instead`);if(r.recording)throw Error(`sendAudioFile: stop recording before uploading a file`);if(i)throw Error(`sendAudioFile: another upload is already in progress`);return e}async function c(e){let c=s();i=!0;let l=a;try{let{decodeAudioToPcm16:i}=await cc(async()=>{let{decodeAudioToPcm16:e}=await import(`./audio-CTPVKBQ_.js`);return{decodeAudioToPcm16:e}},[],import.meta.url),s=await i(await e.arrayBuffer(),c.sampleRate);if(n().recording||t.audioSetupInFlight)throw Error(`sendAudioFile: stop recording before uploading a file`);if(l!==a)throw Error(`sendAudioFile: session was reset mid-send`);if(s.length/c.sampleRate<=120){let e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);r({type:`transcribe_file_start`,sampleRate:c.sampleRate,byteLength:e.byteLength}),await o(e,l),r({type:`transcribe_file_end`});return}let u=new Int16Array(s.length+c.sampleRate);u.set(s),await o(new Uint8Array(u.buffer),l)}finally{i=!1}}return{sendAudioFile:c,inFlight:()=>i,discard:()=>{a++}}}function Nc(e,t,n){let r=new URL(`websocket`,e.endsWith(`/`)?e:`${e}/`);return r.protocol=r.protocol===`https:`?`wss:`:`ws:`,n?r.searchParams.set(`sessionId`,n):t&&r.searchParams.set(`resume`,`1`),r}function Pc(e){let t={...pc,state:`disconnected`,contentVersion:0,started:!1,running:!1,audioOut:!0,recording:!1,apiUrl:Nc(e.platformUrl,!1).toString()},n=new Set;function r(){for(let e of n)e()}let i=[`messages`,`toolCalls`,`userTranscript`,`agentTranscript`];function a(e){t=i.some(n=>n in e&&e[n]!==t[n])?{...t,...e,contentVersion:t.contentVersion+1}:{...t,...e},r()}function o(){return t}function s(e){return n.add(e),()=>{n.delete(e)}}let c={ws:null,voiceIO:null,audioSetupInFlight:!1,generation:0,preInitAudio:[],preInitDone:!1,readyConfig:null},l=null,u=!1;function d(){h.discard(),c.audioSetupInFlight=!1,c.voiceIO?.close().catch(()=>{}),c.voiceIO=null,c.preInitAudio=[],c.preInitDone=!1}function f(){a(pc)}function p(e){c.ws&&c.ws.readyState===1&&c.ws.send(JSON.stringify(e))}function m(e){!c.ws||c.ws.readyState!==1||c.ws.bufferedAmount>65536||c.ws.send(e)}let h=Mc({conn:c,getSnapshot:o,sendJson:p}),{handleMessage:g,settleWhenAudioDrained:_}=hc({getSnapshot:o,updateState:a,conn:c,discardUpload:h.discard,cleanupAudio:d}),v={sendJson:p,sendAudio:m,updateState:a,settleWhenAudioDrained:_,cleanupAudio:d};function y(){l?.abort(),l=null,d(),c.ws?.close(),c.ws=null}function b(n){n.sid&&e.onSessionId?.(n.sid);let r=u;u=!0,c.readyConfig={sampleRate:n.sampleRate,ttsSampleRate:n.ttsSampleRate};let i=n.audioOut!==!1;a({audioOut:i}),i?lc(c,n,v,!0):(p({type:`audio_ready`}),a({state:`listening`})),r&&t.messages.length>0&&p({type:`history`,messages:t.messages.map(e=>({role:e.role,content:e.content}))})}function x(){let t=u?void 0:e.resumeSessionId;return Nc(e.platformUrl,u,t).toString()}function S(){return e.WebSocket?new e.WebSocket(x()):Ac(x)}function C(e){if(e?.signal?.aborted){te();return}a({state:`connecting`,error:null}),y(),c.generation++;let n=new AbortController;l=n;let{signal:r}=n;e?.signal&&e.signal.addEventListener(`abort`,()=>te(),{signal:r});let i=S();i.binaryType=`arraybuffer`,c.ws=i;let o=!1;i.addEventListener(`open`,()=>{a({state:`ready`})},{signal:r}),i.addEventListener(`message`,e=>{let t=g(e.data);t&&b(t)},{signal:r}),i.addEventListener(`error`,()=>{o=!0},{signal:r}),i.addEventListener(`close`,()=>{if(!r.aborted){if(d(),jc(i)){c.generation++,o=!1,a({state:`connecting`,recording:!1});return}n.abort(),i.close(),c.ws=null,o?a({state:`error`,error:{code:`connection`,message:`WebSocket connection error`},running:!1,recording:!1}):t.state===`error`?a({running:!1,recording:!1}):a({state:`disconnected`,error:null,running:!1,recording:!1})}},{signal:r})}function w(){!c.ws||c.ws.readyState!==1||(c.voiceIO?.flush(),a({state:`listening`}),p({type:`cancel`}))}function ee(){if(h.discard(),c.voiceIO?.flush(),c.ws&&c.ws.readyState===1){p({type:`reset`});return}f(),te(),a({running:!0}),C()}function te(){y(),a({state:`disconnected`,running:!1,recording:!1})}function ne(){if(t.audioOut||t.recording||c.audioSetupInFlight||h.inFlight())return;let e=c.readyConfig;!(e&&c.ws)||c.ws.readyState!==1||lc(c,e,v,!1)}function re(){t.audioOut||!t.recording||(d(),a({recording:!1}))}function ie(){a({started:!0,running:!0}),C()}function ae(){t.running?te():(a({running:!0}),C())}return{getSnapshot:o,subscribe:s,connect:C,cancel:w,resetState:f,reset:ee,disconnect:te,start:ie,toggle:ae,startRecording:ne,stopRecording:re,sendAudioFile:h.sendAudioFile,[Symbol.dispose](){te()}}}function Fc(e=`#app`){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}function Ic({name:e,Sidebar:t,sidebarWidth:n}){let r=(0,W.jsx)(Bs,{title:e});return(0,W.jsx)(Hs,{title:e,children:t?(0,W.jsx)(Vs,{sidebar:(0,W.jsx)(t,{}),sidebarWidth:n,children:r}):r})}function G({platformUrl:e,transport:t,name:n,Sidebar:r,sidebarWidth:i}){let[a,o]=(0,B.useState)(t===void 0?null:{transport:t});return(0,B.useEffect)(()=>{if(t!==void 0)return;let n=!1;return qo(e).then(e=>{n||o(e)}),()=>{n=!0}},[e,t]),a?.transport===`sync`?(0,W.jsx)(ic,{syncUrl:Go(e,`sync`).href,title:n??a.name,greeting:a.greeting}):(0,W.jsx)(Ic,{name:n,Sidebar:r,sidebarWidth:i})}function Lc(e){let t=Fc(e.target),n=e.platformUrl??globalThis.location.origin+globalThis.location.pathname,r=Pc({platformUrl:n,onSessionId:e.onSessionId,resumeSessionId:e.resumeSessionId,WebSocket:e.WebSocket}),i=e.component?(0,B.createElement)(e.component):(0,B.createElement)(G,{platformUrl:n,transport:e.transport,name:e.name,Sidebar:e.sidebar,sidebarWidth:e.sidebarWidth}),a=e.tools??{},o=(0,fo.createRoot)(t);(0,uo.flushSync)(()=>{o.render((0,B.createElement)(Ts.Provider,{value:a},(0,B.createElement)(is,{value:e.theme},(0,B.createElement)(es,{value:r},i))))});let s={session:r,dispose(){o.unmount(),r[Symbol.dispose]()},[Symbol.dispose](){s.dispose()}};return s}Lc({});export{wo as t};
@@ -6,8 +6,8 @@
6
6
  <title>aai</title>
7
7
  <link rel="icon" href="data:," />
8
8
  <style>html, body { background: #FBF8F2; margin: 0; }</style>
9
- <script type="module" crossorigin src="./assets/index-CoMfLJMi.js"></script>
10
- <link rel="stylesheet" crossorigin href="./assets/index-CU-aTa-M.css">
9
+ <script type="module" crossorigin src="./assets/index-I5mZ1vB1.js"></script>
10
+ <link rel="stylesheet" crossorigin href="./assets/index-CF3RKVUo.css">
11
11
  </head>
12
12
  <body>
13
13
  <main id="app"></main>
@@ -494,12 +494,14 @@ function createSyncSession(opts) {
494
494
  /**
495
495
  * Default shell for sync-transport agents (`agent({ transport: "sync" })`).
496
496
  *
497
- * Not a chat interface: one **push-to-talk** button. Recording runs exactly
498
- * while the button is held (no VAD releasing the button endpoints the
499
- * utterance), and each release sends one `POST /sync` request through
500
- * `createSyncSession`. The view shows what was heard, the agent's reply,
501
- * and via the endpoint chip next to the button exactly where each
502
- * utterance is being sent. Spoken replies play from the response.
497
+ * A hands-free voice agent: one toggle starts the conversation, and from
498
+ * then on the mic stays open `startSyncMicrophone` runs the WebRTC
499
+ * voice-processing capture through the energy VAD (`sync-vad.ts`), which
500
+ * endpoints each utterance automatically and sends it as one `POST /sync`
501
+ * request through `createSyncSession`. No button per turn: speak, pause,
502
+ * and the reply comes back and plays. The view shows what was heard, the
503
+ * agent's reply, and — via the endpoint chip next to the toggle — exactly
504
+ * where each utterance is being sent.
503
505
  *
504
506
  * Visually it is the same "voice agent console" as the WebSocket
505
507
  * {@link ChatView}: header with logo + live-status eyebrow, the output on a
@@ -511,10 +513,12 @@ function createSyncSession(opts) {
511
513
  * `transport: "sync"`; also exported for custom clients that want the stock
512
514
  * sync UI with their own chrome around it.
513
515
  */
514
- /** Sub-quarter-second presses are button fumbles, not speech. */
515
- const MIN_UTTERANCE_SAMPLES = DEFAULT_SYNC_MIC_SAMPLE_RATE / 4;
516
- /** Play one reply's PCM16 through a shared AudioContext. */
517
- function playReply(ctxRef, turn) {
516
+ /**
517
+ * Play one reply's PCM16 through a shared AudioContext. `onPlaying`
518
+ * tracks playback so the eyebrow can show "speaking" while the reply is
519
+ * audible.
520
+ */
521
+ function playReply(ctxRef, turn, onPlaying) {
518
522
  if (!(turn.pcm && turn.sampleRate)) return;
519
523
  ctxRef.current ??= new AudioContext();
520
524
  const ctx = ctxRef.current;
@@ -526,32 +530,41 @@ function playReply(ctxRef, turn) {
526
530
  const source = ctx.createBufferSource();
527
531
  source.buffer = buffer;
528
532
  source.connect(ctx.destination);
533
+ source.onended = () => onPlaying(false);
534
+ onPlaying(true);
529
535
  source.start();
530
536
  }
531
537
  /**
532
- * Map the push-to-talk lifecycle onto the same states the WebSocket eyebrow
533
- * shows, so the status chip reads identically across transports.
538
+ * Map the hands-free conversation lifecycle onto the same states the
539
+ * WebSocket eyebrow shows, so the status chip reads identically across
540
+ * transports: an endpointed utterance in flight is "thinking", an audible
541
+ * reply is "speaking", a live mic is "listening".
534
542
  */
535
- function syncState(error, busy, holding) {
536
- if (holding) return "listening";
537
- if (busy) return "thinking";
538
- if (error) return "error";
543
+ function syncState(opts) {
544
+ if (opts.pending > 0) return "thinking";
545
+ if (opts.agentSpeaking) return "speaking";
546
+ if (opts.live) return "listening";
547
+ if (opts.error) return "error";
539
548
  return "ready";
540
549
  }
541
550
  /**
542
- * Sync-transport view: hold-to-talk button, transcript + reply output, and
543
- * the endpoint each utterance is POSTed to — one HTTP request per turn.
551
+ * Sync-transport view: a hands-free VAD-endpointed conversation, transcript
552
+ * + reply output, and the endpoint each utterance is POSTed to — one HTTP
553
+ * request per turn.
544
554
  *
545
555
  * @public
546
556
  */
547
557
  function SyncChatView({ syncUrl, title, greeting }) {
548
558
  const theme = useTheme();
549
559
  const [exchanges, setExchanges] = useState([]);
550
- const [holding, setHolding] = useState(false);
551
- const [busy, setBusy] = useState(false);
560
+ const [live, setLive] = useState(false);
561
+ const [userSpeaking, setUserSpeaking] = useState(false);
562
+ const [pending, setPending] = useState(0);
563
+ const [agentSpeaking, setAgentSpeaking] = useState(false);
552
564
  const [error, setError] = useState(null);
553
565
  const playbackCtx = useRef(null);
554
- const recorder = useRef(null);
566
+ const mic = useRef(null);
567
+ const toggling = useRef(false);
555
568
  const anchorRef = useRef(null);
556
569
  const sessionRef = useRef(createSyncSession({
557
570
  url: syncUrl,
@@ -561,20 +574,20 @@ function SyncChatView({ syncUrl, title, greeting }) {
561
574
  heard: turn.transcript,
562
575
  reply: turn.reply
563
576
  }]);
564
- setBusy(false);
577
+ setPending((n) => Math.max(0, n - 1));
565
578
  setError(turn.ttsError ? `TTS unavailable: ${turn.ttsError}` : null);
566
- playReply(playbackCtx, turn);
579
+ playReply(playbackCtx, turn, setAgentSpeaking);
567
580
  },
568
581
  onError: (err) => {
569
- setBusy(false);
582
+ setPending((n) => Math.max(0, n - 1));
570
583
  setError(err.message);
571
584
  }
572
585
  }));
573
586
  useEffect(() => () => {
574
- recorder.current?.close();
587
+ mic.current?.stop();
575
588
  playbackCtx.current?.close();
576
589
  }, []);
577
- const contentCount = exchanges.length + (busy ? 1 : 0);
590
+ const contentCount = exchanges.length + (pending > 0 ? 1 : 0);
578
591
  useEffect(() => {
579
592
  if (contentCount === 0) return;
580
593
  anchorRef.current?.scrollIntoView({
@@ -582,32 +595,43 @@ function SyncChatView({ syncUrl, title, greeting }) {
582
595
  block: "end"
583
596
  });
584
597
  }, [contentCount]);
585
- async function pressStart() {
586
- if (holding || busy) return;
598
+ async function toggleConversation() {
599
+ if (toggling.current) return;
600
+ toggling.current = true;
587
601
  try {
588
- recorder.current ??= createPttRecorder();
589
- await recorder.current.start();
590
- setHolding(true);
602
+ if (mic.current) {
603
+ const handle = mic.current;
604
+ mic.current = null;
605
+ setLive(false);
606
+ setUserSpeaking(false);
607
+ await handle.stop();
608
+ return;
609
+ }
610
+ mic.current = await startSyncMicrophone({
611
+ session: sessionRef.current,
612
+ onSpeechStart: () => setUserSpeaking(true),
613
+ onSpeechEnd: () => {
614
+ setUserSpeaking(false);
615
+ setPending((n) => n + 1);
616
+ },
617
+ onError: (err) => setError(err.message)
618
+ });
619
+ setLive(true);
591
620
  setError(null);
592
621
  } catch (err) {
593
622
  setError(err instanceof Error ? err.message : String(err));
623
+ } finally {
624
+ toggling.current = false;
594
625
  }
595
626
  }
596
- async function pressEnd() {
597
- if (!(holding && recorder.current)) return;
598
- setHolding(false);
599
- setBusy(true);
600
- const pcm = await recorder.current.stop();
601
- if (pcm.length < MIN_UTTERANCE_SAMPLES) {
602
- setBusy(false);
603
- return;
604
- }
605
- sessionRef.current.sendPcm16(pcm, DEFAULT_SYNC_MIC_SAMPLE_RATE).catch(() => {});
606
- }
607
- const state = syncState(error, busy, holding);
608
- let buttonLabel = "Hold to talk";
609
- if (holding) buttonLabel = "Release to send";
610
- else if (busy) buttonLabel = "Sending…";
627
+ const state = syncState({
628
+ error,
629
+ live,
630
+ pending,
631
+ agentSpeaking
632
+ });
633
+ const buttonLabel = live ? "End conversation" : "Start conversation";
634
+ const pulsing = userSpeaking || agentSpeaking;
611
635
  return /* @__PURE__ */ jsxs("div", {
612
636
  className: "flex flex-col h-screen w-full max-w-190 mx-auto box-border px-6 py-8 gap-5 font-aai text-sm",
613
637
  style: {
@@ -631,7 +655,7 @@ function SyncChatView({ syncUrl, title, greeting }) {
631
655
  className: "w-[7px] h-[7px] rounded-full",
632
656
  style: {
633
657
  background: stateColor(state, theme.primary),
634
- animation: holding ? "aai-pulse 1.6s ease-in-out infinite" : "none"
658
+ animation: pulsing ? "aai-pulse 1.6s ease-in-out infinite" : "none"
635
659
  }
636
660
  }), state]
637
661
  })]
@@ -667,7 +691,7 @@ function SyncChatView({ syncUrl, title, greeting }) {
667
691
  exchanges.length === 0 && /* @__PURE__ */ jsx("p", {
668
692
  className: "text-sm",
669
693
  style: { color: "#57534B" },
670
- children: "Hold the button, speak, and releasethe utterance goes out as one HTTP request to the endpoint below."
694
+ children: "Start the conversation and just talk each pause endpoints an utterance, which goes out as one HTTP request to the endpoint below."
671
695
  }),
672
696
  exchanges.map((ex) => /* @__PURE__ */ jsxs("div", {
673
697
  className: "flex flex-col gap-1.5",
@@ -694,7 +718,7 @@ function SyncChatView({ syncUrl, title, greeting }) {
694
718
  })
695
719
  ]
696
720
  }, ex.id)),
697
- busy && /* @__PURE__ */ jsx("div", {
721
+ pending > 0 && /* @__PURE__ */ jsx("div", {
698
722
  "data-testid": "thinking",
699
723
  children: /* @__PURE__ */ jsx(ThinkingDots, {})
700
724
  }),
@@ -707,21 +731,18 @@ function SyncChatView({ syncUrl, title, greeting }) {
707
731
  className: "flex items-center gap-2 shrink-0",
708
732
  children: [/* @__PURE__ */ jsxs(Button, {
709
733
  size: "lg",
710
- variant: holding ? "default" : "secondary",
711
- disabled: busy && !holding,
712
- className: "select-none touch-none",
713
- style: holding ? {
734
+ variant: live ? "default" : "secondary",
735
+ className: "select-none",
736
+ style: live ? {
714
737
  background: ERROR_COLOR,
715
738
  borderColor: "transparent"
716
739
  } : void 0,
717
- onPointerDown: () => void pressStart(),
718
- onPointerUp: () => void pressEnd(),
719
- onPointerLeave: () => void pressEnd(),
720
- "aria-pressed": holding,
721
- title: "Hold to record — release to send",
740
+ onClick: () => void toggleConversation(),
741
+ "aria-pressed": live,
742
+ title: "Start or end the conversation",
722
743
  children: [/* @__PURE__ */ jsx("span", {
723
- className: clsx("w-2 h-2 rounded-full mr-2", holding && "animate-pulse"),
724
- style: { background: holding ? "#fff" : ERROR_COLOR }
744
+ className: clsx("w-2 h-2 rounded-full mr-2", pulsing && "animate-pulse"),
745
+ style: { background: live ? "#fff" : ERROR_COLOR }
725
746
  }), buttonLabel]
726
747
  }), /* @__PURE__ */ jsx(UrlChip, {
727
748
  label: "Sync",
@@ -1,4 +1,4 @@
1
- import { t as client } from "./define-client-71qQ7sHx.js";
1
+ import { t as client } from "./define-client-Dx4JaWzL.js";
2
2
  import "./context.js";
3
3
  import "./components/sidebar-layout.js";
4
4
  import "./components/start-screen.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as pcm16ToBase64, c as createPttRecorder, d as createUtteranceDetector, f as buildAgentUrl, i as createSyncSession, l as floatToPcm16, n as SyncChatView, o as CAPTURE_WORKLET_MODULE_URL, p as fetchClientConfig, r as base64ToPcm16, s as DEFAULT_SYNC_MIC_SAMPLE_RATE, t as client, u as startSyncMicrophone } from "./define-client-71qQ7sHx.js";
1
+ import { a as pcm16ToBase64, c as createPttRecorder, d as createUtteranceDetector, f as buildAgentUrl, i as createSyncSession, l as floatToPcm16, n as SyncChatView, o as CAPTURE_WORKLET_MODULE_URL, p as fetchClientConfig, r as base64ToPcm16, s as DEFAULT_SYNC_MIC_SAMPLE_RATE, t as client, u as startSyncMicrophone } from "./define-client-Dx4JaWzL.js";
2
2
  import { SessionProvider, ThemeProvider, useSession, useSessionSelector, useTheme } from "./context.js";
3
3
  import { Button } from "./components/button.js";
4
4
  import { i as UiUrlChip, n as ApiUrlChip, r as SessionUrlChips, t as Controls } from "./controls-BbZcmnJf.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-ui",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -20,7 +20,7 @@
20
20
  "clsx": "^2.1.1",
21
21
  "partysocket": "^1.3.0",
22
22
  "use-sync-external-store": "^1.6.0",
23
- "@alexkroman1/aai": "1.13.1"
23
+ "@alexkroman1/aai": "1.14.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^19.0.0",
@@ -1,2 +0,0 @@
1
- /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
- @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-normal:400;--font-weight-medium:500;--tracking-wide:.025em;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-aai:"Monument Grotesk", "ABC Monument Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;--font-aai-serif:"Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, serif;--font-aai-mono:"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;--radius-aai:4px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}html,body{margin:0;padding:0}}@layer components;@layer utilities{.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:0}.mx-auto{margin-inline:auto}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mr-2{margin-right:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-4{height:calc(var(--spacing) * 4)}.h-9{height:calc(var(--spacing) * 9)}.h-11{height:calc(var(--spacing) * 11)}.h-\[7px\]{height:7px}.h-screen{height:100vh}.max-h-64{max-height:calc(var(--spacing) * 64)}.min-h-0{min-height:0}.min-h-5{min-height:calc(var(--spacing) * 5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-4{width:calc(var(--spacing) * 4)}.w-\[7px\]{width:7px}.w-fit{width:fit-content}.w-full{width:100%}.max-w-75{max-width:calc(var(--spacing) * 75)}.max-w-105{max-width:calc(var(--spacing) * 105)}.max-w-190{max-width:calc(var(--spacing) * 190)}.max-w-\[55\%\]{max-width:55%}.max-w-\[60\%\]{max-width:60%}.max-w-\[82\%\]{max-width:82%}.max-w-\[min\(78\%\,64ch\)\]{max-width:min(78%,64ch)}.min-w-0{min-width:0}.flex-1{flex:1}.shrink-0{flex-shrink:0}.rotate-90{rotate:90deg}.animate-pulse{animation:var(--animate-pulse)}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.\[scrollbar-width\:none\]{scrollbar-width:none}.appearance-none{appearance:none}.flex-col{flex-direction:column}.items-center{align-items:center}.items-end{align-items:flex-end}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-aai{border-radius:var(--radius-aai)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-transparent{background-color:#0000}.p-7{padding:calc(var(--spacing) * 7)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-7{padding-inline:calc(var(--spacing) * 7)}.px-10{padding-inline:calc(var(--spacing) * 10)}.py-1{padding-block:var(--spacing)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-12{padding-block:calc(var(--spacing) * 12)}.text-center{text-align:center}.text-left{text-align:left}.font-aai{font-family:var(--font-aai)}.font-aai-mono{font-family:var(--font-aai-mono)}.font-aai-serif{font-family:var(--font-aai-serif)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[15px\]{font-size:15px}.text-\[22px\]{font-size:22px}.text-\[32px\]{font-size:32px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-\[1\.2\]{--tw-leading:1.2;line-height:1.2}.leading-\[1\.15\]{--tw-leading:1.15;line-height:1.15}.leading-\[22px\]{--tw-leading:22px;line-height:22px}.leading-\[23px\]{--tw-leading:23px;line-height:23px}.leading-\[130\%\]{--tw-leading:130%;line-height:130%}.leading-none{--tw-leading:1;line-height:1}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.tracking-\[-0\.2px\]{--tw-tracking:-.2px;letter-spacing:-.2px}.tracking-\[1\.2px\]{--tw-tracking:1.2px;letter-spacing:1.2px}.tracking-\[1\.4px\]{--tw-tracking:1.4px;letter-spacing:1.4px}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.text-balance{text-wrap:balance}.wrap-break-word{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.uppercase{text-transform:uppercase}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (width>=40rem){.sm\:px-16{padding-inline:calc(var(--spacing) * 16)}.sm\:py-14{padding-block:calc(var(--spacing) * 14)}}}@keyframes aai-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.45;transform:scale(.82)}}@keyframes aai-bounce{0%,80%,to{opacity:.3;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}@keyframes aai-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.tool-shimmer{-webkit-text-fill-color:transparent;background:linear-gradient(90deg,currentColor 25%,#0000 50%,currentColor 75%) 0 0/200% 100%;-webkit-background-clip:text;background-clip:text;animation:2s infinite aai-shimmer}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}