"use strict";var P=Object.create;var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var y=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of N(t))!F.call(e,s)&&s!==r&&p(e,s,{get:()=>t[s],enumerable:!(n=g(t,s))||n.enumerable});return e};var E=(e,t,r)=>(r=e!=null?P(S(e)):{},y(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),m=require("livekit-client"),O=require("./shared-BxKfPxqP.js");function K(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=K(h);function j(e={}){const[t,r]=l.useState(!1),[n,s]=l.useState(!1),[d,u]=l.useState(!1);let i=O.useLocalParticipant().microphoneTrack;const[a,b]=l.useState();e.trackRef&&(i=e.trackRef.publication);const k=l.useCallback(async c=>{if(c){const{KrispNoiseFilter:o,isKrispNoiseFilterSupported:f}=await import("@livekit/krisp-noise-filter");if(!f()){console.warn("Krisp noise filter is not supported in this browser");return}a||b(o(e.filterOptions))}r(o=>(o!==c&&s(!0),c))},[]);return l.useEffect(()=>{var c;if(i&&i.track instanceof m.LocalAudioTrack&&a){const o=i.track.getProcessor();o&&o.name==="livekit-noise-filter"?(s(!0),o.setEnabled(t).finally(()=>{s(!1),u(t)})):!o&&t&&(s(!0),(c=i==null?void 0:i.track)==null||c.setProcessor(a).then(()=>a.setEnabled(t)).then(()=>{u(!0)}).catch(f=>{u(!1),console.error(f)}).finally(()=>{s(!1)}))}},[t,i,a]),{setNoiseFilterEnabled:k,isNoiseFilterEnabled:d,isNoiseFilterPending:n,processor:a}}exports.useKrispNoiseFilter=j;
//# sourceMappingURL=krisp.js.map
