@johpaz/hive-agents 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +3 -3
  2. package/dist/hive.js +3741 -3150
  3. package/dist/tool-worker.js +25 -2
  4. package/dist/ui/assets/{A2UIPage-F1sUdZV7.js → A2UIPage-EDS7lN-K.js} +4 -4
  5. package/dist/ui/assets/{AgentCreateForm-CN5Gb9UN.js → AgentCreateForm-KvhVhAFP.js} +1 -1
  6. package/dist/ui/assets/AgentDetailPage-B2dCpO92.js +1 -0
  7. package/dist/ui/assets/{AgentNewPage-AGDjfAVf.js → AgentNewPage-CF2B4dbu.js} +1 -1
  8. package/dist/ui/assets/AgentsPage-CMvz-CtA.js +10 -0
  9. package/dist/ui/assets/{ApiClientPage-Dq4nPse4.js → ApiClientPage-tzzL3rZC.js} +1 -1
  10. package/dist/ui/assets/{ChannelsPage-BuWItmp-.js → ChannelsPage-fE2vRwup.js} +2 -2
  11. package/dist/ui/assets/DashboardPage-57SaHnBL.js +6 -0
  12. package/dist/ui/assets/{LoginPage-DBvwBCG6.js → LoginPage-Fag9Bp5h.js} +1 -1
  13. package/dist/ui/assets/{LogsPage-Bc-oTBwY.js → LogsPage-GVJd_a65.js} +1 -1
  14. package/dist/ui/assets/{MeetingPage-C2H5SxaQ.js → MeetingPage-TKQu8Nr-.js} +1 -1
  15. package/dist/ui/assets/{ModelSelector-D0aJvoD9.js → ModelSelector-DciHLo7R.js} +1 -1
  16. package/dist/ui/assets/{NotFound-PUg3gEO0.js → NotFound-D4ZlDVg9.js} +1 -1
  17. package/dist/ui/assets/Office3DPage-CQnO522l.js +727 -0
  18. package/dist/ui/assets/ProvidersPage-BsWFvzqz.js +1 -0
  19. package/dist/ui/assets/{RecoverPage-nq901JiE.js → RecoverPage-BkdOyljs.js} +1 -1
  20. package/dist/ui/assets/SettingsPage-D_43Rc2I.js +9 -0
  21. package/dist/ui/assets/{SetupPage-DeIGn-Uf.js → SetupPage-D6Z3SYZu.js} +1 -1
  22. package/dist/ui/assets/{Vignette-BcPWkNhm.js → Vignette-bSrGVyRd.js} +1 -1
  23. package/dist/ui/assets/{VoicePage-uLWdtoD4.css → VoicePage-CADecxhn.css} +1 -1
  24. package/dist/ui/assets/VoicePage-CCE2EOE9.js +307 -0
  25. package/dist/ui/assets/{WebChatPage-CRDN4OlP.js → WebChatPage-Dzk3FhiR.js} +4 -4
  26. package/dist/ui/assets/{bia-BFcUpOu3.glb → bia-csMImkVQ.glb} +0 -0
  27. package/dist/ui/assets/{conversationsStore-BIs0iMhp.js → conversationsStore-5hf5grlP.js} +1 -1
  28. package/dist/ui/assets/{core-B_5cyOSV.js → core-p4c5dns5.js} +1 -1
  29. package/dist/ui/assets/{dialog-DdbsUCv9.js → dialog-DKnsGLwr.js} +1 -1
  30. package/dist/ui/assets/{dist-js-q7C_AB0j.js → dist-js-CkNhvsFc.js} +1 -1
  31. package/dist/ui/assets/dist-js-jWCEHSkB.js +1 -0
  32. package/dist/ui/assets/headworklet.min-Bi87kUoI.mjs +1 -0
  33. package/dist/ui/assets/index-DmFPF9xQ.css +2 -0
  34. package/dist/ui/assets/{index-CpzwBwPg.js → index-mBw9Tl7u.js} +44 -4
  35. package/dist/ui/assets/model-en-mixed-CfUSaeKF.bin +0 -0
  36. package/dist/ui/assets/useAudioDevices-BYFaA0X-.js +1 -0
  37. package/dist/ui/assets/{useHiveAgentsModelLoad-29pOYRd9.js → useHiveAgentsModelLoad-RRQ6-ANC.js} +1 -1
  38. package/dist/ui/assets/{useProviders-CiBi4Dt6.js → useProviders-DXr4pJ57.js} +1 -1
  39. package/dist/ui/assets/{vendor-router-DP84b3LQ.js → vendor-router-DSMCk-Ka.js} +1 -1
  40. package/dist/ui/index.html +3 -3
  41. package/package.json +5 -3
  42. package/packages/core/src/agent/compaction.ts +162 -25
  43. package/packages/core/src/agent/context-compiler.ts +121 -8
  44. package/packages/core/src/agent/conversation-store.ts +43 -2
  45. package/packages/core/src/agent/handoff.ts +129 -0
  46. package/packages/core/src/agent/history-timeline.ts +133 -0
  47. package/packages/core/src/agent/message-memory.ts +148 -0
  48. package/packages/core/src/agent/summary-memory.ts +152 -0
  49. package/packages/core/src/agent/thread-store.ts +4 -0
  50. package/packages/core/src/config/loader.ts +37 -1
  51. package/packages/core/src/gateway/realtime/voice-session.ts +19 -0
  52. package/packages/core/src/storage/collections.ts +3 -0
  53. package/packages/core/src/tools/core/index.ts +19 -6
  54. package/packages/skills/src/bundled-data.generated.ts +756 -756
  55. package/dist/ui/assets/AgentDetailPage-CzBnoKtH.js +0 -1
  56. package/dist/ui/assets/AgentsPage-BgKr7pAZ.js +0 -10
  57. package/dist/ui/assets/DashboardPage-CB1aM87o.js +0 -6
  58. package/dist/ui/assets/Office3DPage-D5vwZkJa.js +0 -727
  59. package/dist/ui/assets/ProvidersPage-BBBt4Hcz.js +0 -1
  60. package/dist/ui/assets/SettingsPage-DQ5KZPAd.js +0 -9
  61. package/dist/ui/assets/VoicePage-DJYsOsaU.js +0 -307
  62. package/dist/ui/assets/dist-js-Dh18rcg9.js +0 -1
  63. package/dist/ui/assets/index-BD7hBA1d.css +0 -2
  64. package/dist/ui/assets/useAudioDevices-yU-wu-kt.js +0 -41
  65. /package/dist/ui/assets/{agentCapabilities-PfTEVxG1.js → agentCapabilities-CDSfJWhw.js} +0 -0
  66. /package/dist/ui/assets/{pause-Cm9LzIZK.js → pause-BAMsNQkh.js} +0 -0
  67. /package/dist/ui/assets/{pencil-L3Li7_pz.js → pencil-CKritjT_.js} +0 -0
  68. /package/dist/ui/assets/{play-zqogwA2l.js → play-Cwpe4tp6.js} +0 -0
  69. /package/dist/ui/assets/{plus-Bm08ABhc.js → plus-RD44ce15.js} +0 -0
  70. /package/dist/ui/assets/{radio-Cii1BjMt.js → radio-lFPMHi6-.js} +0 -0
  71. /package/dist/ui/assets/{refresh-cw-DXv3XgEt.js → refresh-cw-DtJMHRHO.js} +0 -0
  72. /package/dist/ui/assets/{rotate-ccw-LoM1AuqK.js → rotate-ccw-b3E_4PoX.js} +0 -0
  73. /package/dist/ui/assets/{search-BMwCI-pX.js → search-z2oZt00P.js} +0 -0
  74. /package/dist/ui/assets/{send-D6fgWV7m.js → send-CpoY_2F-.js} +0 -0
@@ -1 +1 @@
1
- import{r as e}from"./gateway-url-BALS_wVh.js";import{O as t}from"./index-CpzwBwPg.js";function n(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var r=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return r(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return r(t)(e)}}}},i=(e,t)=>(i,a,o)=>{let s={storage:n(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},c=!1,l=0,u=new Set,d=new Set,f=s.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),i(...e)},a,o);let p=()=>{let e=s.partialize({...a()});return f.setItem(s.name,{state:e,version:s.version})},m=o.setState;o.setState=(e,t)=>(m(e,t),p());let h=e((...e)=>(i(...e),p()),a,o);o.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++l;c=!1,u.forEach(e=>e(a()??h));let t=s.onRehydrateStorage?.call(s,a()??h)||void 0;return r(f.getItem.bind(f))(s.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==s.version){if(s.migrate){let t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==l)return;let[n,r]=t;if(g=s.merge(r,a()??h),i(g,!0),n)return p()}).then(()=>{e===l&&(t?.(a(),void 0),g=a(),c=!0,d.forEach(e=>e(g)))}).catch(n=>{e===l&&t?.(void 0,n)})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(f=e.storage)},clearStorage:()=>{f?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:e=>(u.add(e),()=>{u.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},s.skipHydration||_(),g||h};function a(e,t){return t.lastMessageAt-e.lastMessageAt}var o=e()(i((e,n)=>({conversations:[],activeId:null,isLoading:!1,error:null,fetchConversations:async()=>{e({isLoading:!0,error:null});try{let{conversations:r}=await t(`/api/conversations?channel=webchat`,{showError:!1}),i=[...r??[]].sort(a),{activeId:o}=n();e({conversations:i,activeId:o&&i.some(e=>e.id===o)?o:i[0]?.id??null,isLoading:!1})}catch(t){e({isLoading:!1,error:t.message})}},createConversation:async()=>{try{let{conversation:n}=await t(`/api/conversations`,{method:`POST`,body:{},showError:!1});return e(e=>({conversations:[n,...e.conversations],activeId:n.id})),n.id}catch(t){return e({error:t.message}),null}},selectConversation:t=>e({activeId:t}),renameConversation:async(r,i)=>{e(e=>({conversations:e.conversations.map(e=>e.id===r?{...e,title:i}:e)})),await t(`/api/conversations`,{method:`PATCH`,body:{threadId:r,title:i},showError:!1}).catch(()=>n().fetchConversations())},deleteConversation:async n=>{await t(`/api/conversations?threadId=${encodeURIComponent(n)}`,{method:`DELETE`,showError:!1}),e(e=>{let t=e.conversations.filter(e=>e.id!==n);return{conversations:t,activeId:e.activeId===n?t[0]?.id??null:e.activeId}})}}),{name:`hive-conversations`,partialize:e=>({activeId:e.activeId})}));export{i as n,o as t};
1
+ import{r as e}from"./gateway-url-BALS_wVh.js";import{N as t}from"./index-mBw9Tl7u.js";function n(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var r=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return r(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return r(t)(e)}}}},i=(e,t)=>(i,a,o)=>{let s={storage:n(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},c=!1,l=0,u=new Set,d=new Set,f=s.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),i(...e)},a,o);let p=()=>{let e=s.partialize({...a()});return f.setItem(s.name,{state:e,version:s.version})},m=o.setState;o.setState=(e,t)=>(m(e,t),p());let h=e((...e)=>(i(...e),p()),a,o);o.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++l;c=!1,u.forEach(e=>e(a()??h));let t=s.onRehydrateStorage?.call(s,a()??h)||void 0;return r(f.getItem.bind(f))(s.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==s.version){if(s.migrate){let t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==l)return;let[n,r]=t;if(g=s.merge(r,a()??h),i(g,!0),n)return p()}).then(()=>{e===l&&(t?.(a(),void 0),g=a(),c=!0,d.forEach(e=>e(g)))}).catch(n=>{e===l&&t?.(void 0,n)})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(f=e.storage)},clearStorage:()=>{f?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:e=>(u.add(e),()=>{u.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},s.skipHydration||_(),g||h};function a(e,t){return t.lastMessageAt-e.lastMessageAt}var o=e()(i((e,n)=>({conversations:[],activeId:null,isLoading:!1,error:null,fetchConversations:async()=>{e({isLoading:!0,error:null});try{let{conversations:r}=await t(`/api/conversations?channel=webchat`,{showError:!1}),i=[...r??[]].sort(a),{activeId:o}=n();e({conversations:i,activeId:o&&i.some(e=>e.id===o)?o:i[0]?.id??null,isLoading:!1})}catch(t){e({isLoading:!1,error:t.message})}},createConversation:async()=>{try{let{conversation:n}=await t(`/api/conversations`,{method:`POST`,body:{},showError:!1});return e(e=>({conversations:[n,...e.conversations],activeId:n.id})),n.id}catch(t){return e({error:t.message}),null}},selectConversation:t=>e({activeId:t}),renameConversation:async(r,i)=>{e(e=>({conversations:e.conversations.map(e=>e.id===r?{...e,title:i}:e)})),await t(`/api/conversations`,{method:`PATCH`,body:{threadId:r,title:i},showError:!1}).catch(()=>n().fetchConversations())},deleteConversation:async n=>{await t(`/api/conversations?threadId=${encodeURIComponent(n)}`,{method:`DELETE`,showError:!1}),e(e=>{let t=e.conversations.filter(e=>e.id!==n);return{conversations:t,activeId:e.activeId===n?t[0]?.id??null:e.activeId}})}}),{name:`hive-conversations`,partialize:e=>({activeId:e.activeId})}));export{i as n,o as t};
@@ -1 +1 @@
1
- function e(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function t(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var n,r,i,a,o,s=`__TAURI_TO_IPC_KEY__`;function c(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var l=class{constructor(o){n.set(this,void 0),r.set(this,0),i.set(this,[]),a.set(this,void 0),t(this,n,o||(()=>{}),`f`),this.id=c(o=>{let s=o.index;if(`end`in o){s==e(this,r,`f`)?this.cleanupCallback():t(this,a,s,`f`);return}let c=o.message;if(s==e(this,r,`f`)){for(e(this,n,`f`).call(this,c),t(this,r,e(this,r,`f`)+1,`f`);e(this,r,`f`)in e(this,i,`f`);){let a=e(this,i,`f`)[e(this,r,`f`)];e(this,n,`f`).call(this,a),delete e(this,i,`f`)[e(this,r,`f`)],t(this,r,e(this,r,`f`)+1,`f`)}e(this,r,`f`)===e(this,a,`f`)&&this.cleanupCallback()}else e(this,i,`f`)[s]=c})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){t(this,n,e,`f`)}get onmessage(){return e(this,n,`f`)}[(n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,s)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[s]()}};async function u(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var d=class{get rid(){return e(this,o,`f`)}constructor(e){o.set(this,void 0),t(this,o,e,`f`)}async close(){return u(`plugin:resources|close`,{rid:this.rid})}};o=new WeakMap;export{l as Channel,d as Resource,u as invoke};
1
+ function e(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function t(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var n,r,i,a,o,s=`__TAURI_TO_IPC_KEY__`;function c(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var l=class{constructor(o){n.set(this,void 0),r.set(this,0),i.set(this,[]),a.set(this,void 0),t(this,n,o||(()=>{}),`f`),this.id=c(o=>{let s=o.index;if(`end`in o){s==e(this,r,`f`)?this.cleanupCallback():t(this,a,s,`f`);return}let c=o.message;if(s==e(this,r,`f`)){for(e(this,n,`f`).call(this,c),t(this,r,e(this,r,`f`)+1,`f`);e(this,r,`f`)in e(this,i,`f`);){let a=e(this,i,`f`)[e(this,r,`f`)];e(this,n,`f`).call(this,a),delete e(this,i,`f`)[e(this,r,`f`)],t(this,r,e(this,r,`f`)+1,`f`)}e(this,r,`f`)===e(this,a,`f`)&&this.cleanupCallback()}else e(this,i,`f`)[s]=c})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){t(this,n,e,`f`)}get onmessage(){return e(this,n,`f`)}[(n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,s)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[s]()}},u=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return m(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(e,t,n){let r=new l(n);try{return await m(`plugin:${e}|register_listener`,{event:t,handler:r}),new u(e,t,r.id)}catch{return await m(`plugin:${e}|registerListener`,{event:t,handler:r}),new u(e,t,r.id)}}async function f(e){return m(`plugin:${e}|check_permissions`)}async function p(e){return m(`plugin:${e}|request_permissions`)}async function m(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function h(e,t=`asset`){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}var g=class{get rid(){return e(this,o,`f`)}constructor(e){o.set(this,void 0),t(this,o,e,`f`)}async close(){return m(`plugin:resources|close`,{rid:this.rid})}};o=new WeakMap;function _(){return!!(globalThis||window).isTauri}export{l as Channel,u as PluginListener,g as Resource,s as SERIALIZE_TO_IPC_FN,d as addPluginListener,f as checkPermissions,h as convertFileSrc,m as invoke,_ as isTauri,p as requestPermissions,c as transformCallback};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{dt as n,ft as r,gt as i,ht as a,lt as o,mt as s,pt as c,ut as l}from"./vendor-radix-DUug7irY.js";import{t as u}from"./vendor-react-kUOwxn0g.js";import{o as d}from"./vendor-query-Dj8xYhQD.js";import{t as f}from"./utils-DEmd_M8c.js";import{q as p}from"./index-CpzwBwPg.js";var m=u(),h=e(t(),1),g=d(),_=s,v=i,y=c,b=o,x=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=f(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(r,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});x.displayName=r.displayName;var S=h.forwardRef((e,t)=>{let n=(0,m.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let s;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(x,{className:`z-[9999]`}),n[4]=s):s=n[4];let c;n[5]===i?c=n[6]:(c=f(`fixed left-[50%] top-[50%] z-[10000] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg`,i),n[5]=i,n[6]=c);let u;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,g.jsxs)(o,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none`,children:[(0,g.jsx)(p,{className:`h-4 w-4`}),(0,g.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),n[7]=u):u=n[7];let d;return n[8]!==r||n[9]!==a||n[10]!==t||n[11]!==c?(d=(0,g.jsxs)(y,{children:[s,(0,g.jsxs)(l,{ref:t,className:c,...a,children:[r,u]})]}),n[8]=r,n[9]=a,n[10]=t,n[11]=c,n[12]=d):d=n[12],d});S.displayName=l.displayName;var C=e=>{let t=(0,m.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=f(`flex flex-col space-y-1.5 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,g.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};C.displayName=`DialogHeader`;var w=e=>{let t=(0,m.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=f(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,g.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};w.displayName=`DialogFooter`;var T=h.forwardRef((e,t)=>{let n=(0,m.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=f(`text-lg font-semibold leading-none tracking-tight`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(a,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});T.displayName=a.displayName;var E=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=f(`text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,g.jsx)(n,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});E.displayName=n.displayName;export{w as a,v as c,E as i,b as n,C as o,S as r,T as s,_ as t};
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{dt as n,ft as r,gt as i,ht as a,lt as o,mt as s,pt as c,ut as l}from"./vendor-radix-DUug7irY.js";import{t as u}from"./vendor-react-kUOwxn0g.js";import{o as d}from"./vendor-query-Dj8xYhQD.js";import{t as f}from"./utils-DEmd_M8c.js";import{Q as p}from"./index-mBw9Tl7u.js";var m=u(),h=e(t(),1),g=d(),_=s,v=i,y=c,b=o,x=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=f(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(r,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});x.displayName=r.displayName;var S=h.forwardRef((e,t)=>{let n=(0,m.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let s;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(x,{className:`z-[9999]`}),n[4]=s):s=n[4];let c;n[5]===i?c=n[6]:(c=f(`fixed left-[50%] top-[50%] z-[10000] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg`,i),n[5]=i,n[6]=c);let u;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,g.jsxs)(o,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none`,children:[(0,g.jsx)(p,{className:`h-4 w-4`}),(0,g.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),n[7]=u):u=n[7];let d;return n[8]!==r||n[9]!==a||n[10]!==t||n[11]!==c?(d=(0,g.jsxs)(y,{children:[s,(0,g.jsxs)(l,{ref:t,className:c,...a,children:[r,u]})]}),n[8]=r,n[9]=a,n[10]=t,n[11]=c,n[12]=d):d=n[12],d});S.displayName=l.displayName;var C=e=>{let t=(0,m.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=f(`flex flex-col space-y-1.5 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,g.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};C.displayName=`DialogHeader`;var w=e=>{let t=(0,m.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=f(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,g.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};w.displayName=`DialogFooter`;var T=h.forwardRef((e,t)=>{let n=(0,m.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let o;n[3]===r?o=n[4]:(o=f(`text-lg font-semibold leading-none tracking-tight`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(a,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});T.displayName=a.displayName;var E=h.forwardRef((e,t)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=f(`text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,g.jsx)(n,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});E.displayName=n.displayName;export{w as a,v as c,E as i,b as n,C as o,S as r,T as s,_ as t};
@@ -1 +1 @@
1
- import{Channel as e,Resource as t,invoke as n}from"./core-B_5cyOSV.js";var r=class extends t{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(r,i){a(i);let o=new e;r&&(o.onmessage=r);let s=await n(`plugin:updater|download`,{onEvent:o,rid:this.rid,...i});this.downloadedBytes=new t(s)}async install(){if(!this.downloadedBytes)throw Error(`Update.install called before Update.download`);await n(`plugin:updater|install`,{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(t,r){a(r);let i=new e;t&&(i.onmessage=t),await n(`plugin:updater|download_and_install`,{onEvent:i,rid:this.rid,...r})}async close(){await this.downloadedBytes?.close(),await super.close()}};async function i(e){a(e);let t=await n(`plugin:updater|check`,{...e});return t?new r(t):null}function a(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}export{i as check};
1
+ import{Channel as e,Resource as t,invoke as n}from"./core-p4c5dns5.js";var r=class extends t{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(r,i){a(i);let o=new e;r&&(o.onmessage=r);let s=await n(`plugin:updater|download`,{onEvent:o,rid:this.rid,...i});this.downloadedBytes=new t(s)}async install(){if(!this.downloadedBytes)throw Error(`Update.install called before Update.download`);await n(`plugin:updater|install`,{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(t,r){a(r);let i=new e;t&&(i.onmessage=t),await n(`plugin:updater|download_and_install`,{onEvent:i,rid:this.rid,...r})}async close(){await this.downloadedBytes?.close(),await super.close()}};async function i(e){a(e);let t=await n(`plugin:updater|check`,{...e});return t?new r(t):null}function a(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}export{i as check};
@@ -0,0 +1 @@
1
+ import{invoke as e}from"./core-p4c5dns5.js";async function t(){await e(`plugin:process|restart`)}export{t as relaunch};
@@ -0,0 +1 @@
1
+ var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=16e3,s=32,i=64,a=!0,n=.97,r=512,o=256,l=12,h=40,c=22,d=!1,u=!1,p=12,v=!0,m=1,f=15,g=14,b=0,M=2,w=8,y=p,k=56,F=78,A=368,E=92;class RingBuffer{constructor(t,e=void 0,s=!1){this.buf=Array.from({length:t},e),this.capacity=t,this.head=0,this.tail=0,this.count=s?t:0}add(t){const e=this.capacity;this.buf[this.tail]=t,this.tail=(this.tail+1)%e,this.count<e?this.count++:this.head=(this.head+1)%e}allocate(){const t=this.capacity,e=this.buf[this.tail];return this.tail=(this.tail+1)%t,this.count<t?this.count++:this.head=(this.head+1)%t,e}isAvailable(t){return this.count>=t}isFull(){return this.count===this.capacity}getHead(t=0){const e=this.capacity,s=(this.head+t%e+e)%e;return this.buf[s]}getTail(t=0){const e=this.capacity,s=(this.tail+(t-1)%e+e)%e;return this.buf[s]}getLatest(t,e=null){const s=t.length;if(s>this.count)return null;const i=this.capacity;this.head=(this.head+(this.count-s))%i;for(let e=0;e<s;e++){const s=(this.head+e)%i;t[e]=this.buf[s]}return null!==e&&e>=0&&e<=s&&(this.head=(this.head+e)%i,this.count=s-e),t}clear(t=0){this.count=t,this.tail=(this.head+t)%this.capacity}}class MFCC{constructor(t){const e=Object.assign({speakerMeanHz:150},t||{});this.cossin=this._buildCosSin(),this.bitrev=this._buildBitrev(),this.spectrum=new Float32Array(1024),this.powerSpec=new Float32Array(256),this.melFilters=Array.from({length:h},()=>new Float32Array(256)),this._buildMelFilterbank(e.speakerMeanHz),this.melEnergies=new Float32Array(h),this.hamming=this._buildWindowHamming(),this.dctMatrix=this._buildDCTMatrix(),this.lifter=this._buildLifter()}_buildCosSin(){const t=new Float32Array(1024),e=-2*Math.PI/r;for(let s=0;s<r;s++){const i=e*s;t[2*s]=Math.cos(i),t[2*s+1]=Math.sin(i)}return t}_buildBitrev(){const t=new Uint32Array(r),e=Math.log2(r);for(let s=0;s<r;s++){let i=0;for(let t=0;t<e;t++)i=i<<1|s>>t&1;t[s]=i}return t}_hammingAndFFT(t){const e=this.cossin,s=this.bitrev,i=this.hamming,a=this.spectrum;for(let e=0;e<r;e++){const n=s[e];a[2*n]=t[e]*i[e],a[2*n+1]=0}for(let t=1;t<r;t<<=1){const s=t<<1,i=r/s;for(let n=0;n<t;n++){const o=n*i*2,l=e[o],h=e[o+1];for(let e=n;e<r;e+=s){const s=e<<1,i=e+t<<1,n=a[s],r=a[s+1],o=a[i],c=a[i+1],d=o*l-c*h,u=o*h+c*l;a[s]=n+d,a[s+1]=r+u,a[i]=n-d,a[i+1]=r-u}}}}_buildWindowHamming(){return Float32Array.from({length:r},(t,e)=>.54-.46*Math.cos(2*Math.PI*e/511))}_buildMelFilterbank(t=150){const s=this.melFilters,i=150,a=Math.min(Math.max(t/i,.6),1.8),n=undefined,o=7800,l=t=>2595*Math.log10(1+t/700),c=t=>700*(Math.pow(10,t/2595)-1),d=l(30),u=undefined,p=l(o)-d,v=undefined,m=Float32Array.from({length:42},(t,e)=>{const s=undefined,i=undefined;return c(d+(d+p/41*e-d)*a)}).map(t=>Math.floor(t/e*r));for(let t=0;t<h;t++){const e=s[t];for(let s=m[t];s<m[t+1];s++)e[s]=(s-m[t])/(m[t+1]-m[t]);for(let s=m[t+1];s<m[t+2];s++)e[s]=(m[t+2]-s)/(m[t+2]-m[t+1])}}_buildDCTMatrix(){const t=[],e=Math.sqrt(.05);for(let s=0;s<=l;s++){const i=new Float32Array(h);for(let t=0;t<h;t++)i[t]=e*Math.cos(Math.PI*s*(t+.5)/h);t.push(i)}return t}_buildLifter(){const t=new Float32Array(l);for(let e=1;e<=l;e++)t[e-1]=1+11*Math.sin(Math.PI*e/c);return t}update(t){for(const e in t)if("speakerMeanHz"===e){const s=t[e];this._buildMelFilterbank(s)}}compute(t,e){const s=256;this._hammingAndFFT(t);const i=this.spectrum,a=this.powerSpec;let n=0;for(let t=0;t<s;t++){const e=i[2*t],s=i[2*t+1];a[t]=(e*e+s*s)/r,n+=a[t]}const o=Math.log10(n+1e-10),c=this.melFilters,d=this.melEnergies;for(let t=0;t<h;t++){const e=c[t],s=e.length;let i=0;for(let t=0;t<s;t++)i+=a[t]*e[t];d[t]=Math.log10(i+1e-10)}const u=this.dctMatrix,p=e||new Float32Array(l),v=this.lifter;for(let t=0;t<l;t++){const e=u[t+1];let s=0;for(let t=0;t<h;t++)s+=e[t]*d[t];p[t]=s*v[t]}return{le:o,mfcc:p}}}class VadGate{constructor(t){const e=Object.assign({vadGateActiveDb:-40,vadGateActiveMs:10,vadGateInactiveDb:-50,vadGateInactiveMs:10},t||{});this.activeLE=e.vadGateActiveDb/10,this.activeFrames=Math.max(1,Math.round(62.5*e.vadGateActiveMs/1e3)),this.inactiveLE=e.vadGateInactiveDb/10,this.inactiveFrames=Math.max(1,Math.round(62.5*e.vadGateInactiveMs/1e3)),this.active=0,this.inactive=1,this.preActive=0,this.preInactive=0}update(t){for(const e in t){const s=t[e];switch(e){case"vadGateActiveDb":this.activeLE=s/10;break;case"vadGateActiveMs":this.activeFrames=62.5*s/1e3;break;case"vadGateInactiveDb":this.inactiveLE=s/10;break;case"vadGateInactiveMs":this.inactiveFrames=62.5*s/1e3}}}process(t){return this.active?(this.active++,t<this.inactiveLE?(this.preInactive++,this.preInactive>=this.inactiveFrames&&(this.active=0,this.inactive=1,this.preActive=0)):this.preInactive>0&&this.preInactive--):(this.inactive++,t>this.activeLE?(this.preActive++,this.preActive>=this.activeFrames&&(this.active=1,this.inactive=0,this.preInactive=0)):this.preActive>0&&this.preActive--),{active:this.active,inactive:this.inactive}}}class Classifier{constructor(t){const e=Object.assign({silSensitivity:1.2},t||{});this.prototypes=[],this.prototypesN=0,this.vectorDiff=new Float32Array(p),this.indexSigmaInvLower=this._buildSigmaInvLowerLookup(),this.ringPredictions=new RingBuffer(6,()=>g,!0),this.counts=Array(f).fill(0),this.predictionLast=g,this.silSensitivity=e.silSensitivity}_buildSigmaInvLowerLookup(){const t=Array.from({length:p},()=>new Uint16Array(p));let e=0;for(let s=0;s<p;s++)for(let i=0;i<=s;i++)t[s][i]=e,t[i][s]=e,e++;return t}clear(){this.prototypes=[],this.prototypesN=0}import(t){t?.reset&&this.clear();const e=t?.model,s=e?.length||0,i=[];for(let t=0;t<s;t++){const s=e[t];s.hasOwnProperty("group")&&i.push(s.group)}i.length&&(this.prototypes=this.prototypes.filter(t=>!i.includes(t.group)));for(let t=0;t<s;t++){const s=e[t];this.prototypes.push(s)}this.prototypesN=this.prototypes.length,this.distances=Array(this.prototypesN).fill(1/0)}update(t){for(const e in t)if("silSentivity"===e){const s=t[e];this.silSensitivity=s}}distanceMahalanobis(t,e,s){let i=0;const a=this.indexSigmaInvLower,n=this.vectorDiff;for(let s=0;s<p;++s)n[s]=t[s]-e[s];for(let t=0;t<p;++t){const e=a[t][t],r=n[t];let o=s[e]*r*r;for(let e=0;e<t;++e){const i=undefined;o+=2*s[a[t][e]]*r*n[e]}i+=o}return i}predict(t){const e=this.prototypesN;if(0===e)return{viseme:null,distances:[]};const s=this.prototypes,i=this.distances;let a=1/0,n=0;for(let r=0;r<e;r++){const e=s[r];let o=this.distanceMahalanobis(t,e.mu,e.sigmaInvLower);e.viseme===g&&(o/=this.silSensitivity),i[r]=o,o<=a&&(a=o,n=r)}const r=this.ringPredictions,o=s[n].viseme;r.add(o);const l=r.capacity,h=this.counts.fill(0);for(let t=0;t<l;t++)h[r.buf[t]]++;let c=0,d=0;for(let t=0;t<f;t++){const e=h[t];e>=d&&(c=t,d=e)}return c===this.predictionLast&&c===g?c=null:this.predictionLast=c,{viseme:c,distances:i}}}class Processor{constructor(t,i=null){const a=Object.assign({vadEventsEnabled:!1,frameEventsEnabled:!1,featureEventsEnabled:!1,visemeEventsEnabled:!1},t?.processorOptions||{}),n=Object.assign({vadMode:1,vadGateActiveDb:-40,vadGateActiveMs:10,vadGateInactiveDb:-50,vadGateInactiveMs:10,silMode:1,silCalibrationWindowSec:3,silSensitivity:1.2},t?.parameterData||{});this.worklet=i||{port:{onmessage:null,postMessage:t=>{}}},this.sampleRate=t.sampleRate,this.samplesN=t.samplesN||r,this.samplesHop=t.samplesHop||o,this.preemphasisPrevValue=0,this.downsampleRatio=this.sampleRate/e,this.downsamplePhaseAccumulator=0,this.downsamplePolyFilter=this.designPolyphaseFilter(),this.ringPolyFilter=new RingBuffer(s,()=>0,!0),this.ringSamples=new RingBuffer(this.samplesN,()=>0),this.block=new Float32Array(this.samplesN),this.mfcc=new MFCC(t),this.ringVectors=new RingBuffer(3,()=>new Float32Array(p),!0),this.vectorDuration=this.samplesN/e,this.vadMode=n.vadMode,this.vadGate=new VadGate(n),this.isRunning=!0,this.isSpeaking=!1,this.silMode=n.silMode;const l=Math.max(100,Math.floor(n.silCalibrationWindowSec*o/e));this.ringCalibration=new RingBuffer(l),this.isCalibrationRunning=!1,this.frameEventsEnabled=!!a.frameEventsEnabled,this.vadEventsEnabled=!!a.vadEventsEnabled,this.featureEventsEnabled=!!a.featureEventsEnabled,this.visemeEventsEnabled=!!a.visemeEventsEnabled,this.frameEventsEnabled&&(this.ringFrame=new RingBuffer(128)),this.sampleCount=0,this.classifier=new Classifier(n)}_onmessage(t){const s=t.data;switch(s.event){case"stop":if(this.isRunning=!1,this.isSpeaking){this.isSpeaking=!1;const t=this.sampleCount/e;this.worklet.port.postMessage({event:"end",t})}this.ringVectors.clear();break;case"start":this.isRunning=!0;break;case"calibrate":this.ringCalibration.clear(),this.isCalibrationRunning=!0;break;case"model":this.classifier.import(s);break;case"reset":this.ringSamples.clear(),this.ringVectors.clear(),this.sampleCount=0;break;default:console.warn("Processor received an unknown message: '"+s.event+"'.")}}designPolyphaseFilter(){const t=[],e=15.5,a=.45;for(let n=0;n<i;n++){const r=n/i,o=new Float32Array(s);for(let t=0;t<s;t++){const s=t-e-r;o[t]=0===s?.9:Math.sin(2*Math.PI*a*s)/(Math.PI*s),o[t]*=.54-.46*Math.cos(2*Math.PI*t/31)}t.push(o)}return t}update(t){for(const s in t){const i=t[s];switch(s){case"vadMode":this.vadMode=i;break;case"silMode":this.silMode=i;break;case"silSensitivity":this.silSensitivity=i;break;case"silCalibrationWindowSec":const t=Math.max(100,Math.floor(i*o/e));this.ringCalibration=new RingBuffer(t);break;case"speakerMeanHz":this.mfcc.update({speakerMeanHz:i});break;case"timerReset":this.sampleCount=0;break;default:if(s.startsWith("vadGate")){const t={};t[s]=i,this.vadGate.update(t)}}}}process(t){const a=t.length;if(0!==a){this.frameEventsEnabled&&this.ringFrame.clear();for(let r=0;r<a;r++){let a=t[r];{const t=a;a-=n*this.preemphasisPrevValue,this.preemphasisPrevValue=t}for(this.ringPolyFilter.add(a),this.downsamplePhaseAccumulator+=1/this.downsampleRatio;this.downsamplePhaseAccumulator>=1;){const t=(this.downsamplePhaseAccumulator-1)*i,a=Math.floor(t),n=this.downsamplePolyFilter[a];let r=0;const o=this.ringPolyFilter;for(let t=0;t<s;t++)r+=o.getHead(t)*n[t];if(this.downsamplePhaseAccumulator-=1,this.frameEventsEnabled&&this.ringFrame.add(r),this.ringSamples.add(r),this.sampleCount++,this.isRunning&&this.ringSamples.isFull()){const t=this.sampleCount/e,s=this.block;this.ringSamples.getLatest(s,this.samplesHop);const i=this.ringVectors.allocate(),{le:a}=this.mfcc.compute(s,i);{const t=1;for(let e=0;e<l;++e){const s=i[e]*t;i[e]=1*Math.tanh(s)}}if(this.isCalibrationRunning&&1===this.silMode){const t=i.slice(),e=this.ringCalibration;e.add(t),e.isFull()&&(this.worklet.port.postMessage({event:"calibrated",vs:e.buf}),this.isCalibrationRunning=!1)}if(1===this.vadMode){const{active:e,inactive:s}=this.vadGate.process(a);if(this.vadEventsEnabled&&this.worklet.port.postMessage({event:"vad",active:e,inactive:s,db:10*a,t}),s){this.isSpeaking&&(this.isSpeaking=!1,this.worklet.port.postMessage({event:"ended",t}));continue}}this.featureEventsEnabled&&this.worklet.port.postMessage({event:"feature",vector:i,le:a,t:t-this.vectorDuration/2,d:this.vectorDuration});const{viseme:n,distances:r}=this.classifier.predict(i);if(this.isSpeaking?n===g&&(this.isSpeaking=!1,this.worklet.port.postMessage({event:"ended",t})):null!==n&&n!==g&&(this.isSpeaking=!0,this.worklet.port.postMessage({event:"started",t})),this.isSpeaking){let e={event:"viseme",viseme:n,t:t-this.vectorDuration/2,d:this.vectorDuration};this.visemeEventsEnabled&&(e.vector=i,e.distances=r),this.worklet.port.postMessage(e)}}}}if(this.frameEventsEnabled){const t=this.sampleCount/e,s=new Float32Array(this.ringFrame.count);this.ringFrame.getLatest(s),this.worklet.port.postMessage({event:"frame",frame:s,t})}}}}class HeadWorklet extends AudioWorkletProcessor{constructor(t){super(t),(t=t||{}).sampleRate=sampleRate,this.detectors={};for(const e of HeadWorklet.parameterDescriptors){const s=e.name,i=e.value;this.detectors[s]=i,t[s]=i}this.processor=new Processor(t,this),this.port.onmessage=this.processor._onmessage.bind(this.processor)}process(t,e,s){const i=t[0];if(!i)return!0;const a=i[0];if(!a)return!0;const n=undefined;if(!a.length)return!0;const r=this.detectors;let o=!1;const l={};for(const t in s){const e=undefined,i=s[t][0],a=undefined;i!==r[t]&&(o=!0,r[t]=l[t]=i)}return o&&this.processor.update(l),this.processor.process(a),!0}static get parameterDescriptors(){return[{name:"timerReset",defaultValue:-9999,automationRate:"k-rate"},{name:"vadMode",defaultValue:1,minValue:0,maxValue:1,automationRate:"k-rate"},{name:"vadGateActiveDb",defaultValue:-40,minValue:-100,maxValue:0,automationRate:"k-rate"},{name:"vadGateActiveMs",defaultValue:10,minValue:0,maxValue:1e3,automationRate:"k-rate"},{name:"vadGateInactiveDb",defaultValue:-50,minValue:-100,maxValue:0,automationRate:"k-rate"},{name:"vadGateInactiveMs",defaultValue:10,minValue:0,maxValue:1e3,automationRate:"k-rate"},{name:"silMode",defaultValue:1,minValue:0,maxValue:2,automationRate:"k-rate"},{name:"silCalibrationWindowSec",defaultValue:3,minValue:.1,maxValue:10,automationRate:"k-rate"},{name:"silSensitivity",defaultValue:1.2,minValue:0,maxValue:4,automationRate:"k-rate"},{name:"speakerMeanHz",defaultValue:150,minValue:50,maxValue:500,automationRate:"k-rate"}]}}registerProcessor("headworklet",HeadWorklet);export{HeadWorklet};