@seams/voiceid 0.52.0 → 0.54.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,640 +0,0 @@
1
- import{WorkerDeferred as e,createCspStylesheetManager as t,getDefaultCspNonce as n,isPlainObject as r,readVoiceMicrophonePreference as i,saveVoiceMicrophonePreference as a}from"../voiceid-host.js";var o=class extends Error{constructor(e){super(s(e)),this.name=`VoiceSpeakerMismatchError`}};function s(e){return e.microphoneSelection===`replacement`?`Your microphone changed to ${e.microphone}. Reconnect your usual microphone or try again.`:e.noise===`high`?`Your voice did not match. Background noise is high. Move closer and try again.`:`Your voice did not match. Read the next sentence naturally and try again.`}const c=3e4;var l=class extends Error{constructor(e,t,n){super(t,n),this.kind=e,this.name=`VoiceIdLoadError`}};async function u(){try{return await caches.open(`seams-voiceid-models-v1`)}catch{return null}}var d=class{pending=null;progress={kind:`checking_cache`};listeners=new Set;constructor(e){this.asset=e}get size(){return this.asset.bytes}async download(e){e&&(this.listeners.add(e),e(this.progress));try{this.pending||=this.bytes().catch(this.failed);let e=await this.pending;return this.publish({kind:`ready`}),e}finally{e&&this.listeners.delete(e)}}failed=e=>{throw this.pending=null,this.progress={kind:`checking_cache`},e};publish(e){this.progress=e;for(let t of this.listeners)t(e)}async valid(e){if(e.byteLength!==this.asset.bytes)return!1;let t=new Uint8Array(await crypto.subtle.digest(`SHA-256`,e)),n=``;for(let e of t)n+=e.toString(16).padStart(2,`0`);return n===this.asset.sha256}async bytes(){let{path:e,sha256:t}=this.asset;this.publish({kind:`checking_cache`});let n=await u(),r=new URL(`${e}?sha256=${t}`,location.origin).href;try{let e=await n?.match(r);if(e){let t=await e.arrayBuffer();if(await this.valid(t))return t;await n?.delete(r)}}catch{}let i;try{i=await this.fetchBytes()}catch(e){if(!(e instanceof l)||e.kind!==`connection`)throw e;i=await this.fetchBytes()}if(n)try{await n.put(r,new Response(i,{headers:{"Content-Type":`application/octet-stream`}}))}catch{}return i}async fetchBytes(){let{label:e,path:t}=this.asset,n=new AbortController,r=setTimeout(f.bind(null,n),c);this.publish({kind:`downloading`,received:0});try{let i=await fetch(t,{credentials:`omit`,cache:`reload`,signal:n.signal});if(!i.ok||!i.body){let t=[408,429,500,502,503,504].includes(i.status);throw new l(t?`connection`:`unavailable`,t?`${e} download was interrupted. Check your connection and retry.`:`${e} is unavailable from this Wallet. Reload the page or use a passkey.`)}let a=i.body.getReader(),o=new Uint8Array(this.asset.bytes),s=0;try{for(;;){let t=await a.read();if(t.done)break;if(clearTimeout(r),r=setTimeout(f.bind(null,n),c),s+t.value.length>o.length)throw new l(`integrity`,`${e} size is invalid. Retry loading.`);o.set(t.value,s),s+=t.value.length,this.publish({kind:`downloading`,received:s})}}finally{await a.cancel().catch(p),a.releaseLock()}if(s!==o.length||!await this.valid(o.buffer))throw new l(`integrity`,`${e} integrity check failed. Retry loading.`);return o.buffer}catch(t){throw t instanceof l?t:new l(`connection`,`${e} download was interrupted. Check your connection and retry.`,{cause:t})}finally{clearTimeout(r),n.abort()}}};function f(e){e.abort()}function p(){}const m=new d({path:`/sdk/voiceid/ort-wasm-simd-threaded.wasm`,sha256:`3398c10d07d229bd91b364548e130e0e51a8e5704b88c7c083ebbeb78842dee2`,bytes:14239897,label:`VoiceID engine`});var h=class{asset;session=null;constructor(e){this.asset=new d(e)}prepare(){return this.session||=this.load().catch(this.failed),this.session}failed=e=>{throw this.session=null,e};async load(){try{let e=await import(`./ort.wasm.bundle.min-7y-hlRN8.js`);e.env.wasm.numThreads=1,e.env.wasm.wasmPaths=new URL(`/sdk/voiceid/`,location.origin).href,e.env.wasm.wasmBinary=await m.download();let t=await this.asset.download();return await e.InferenceSession.create(t,{executionProviders:[`wasm`]})}catch(e){throw e instanceof l?e:(console.error(`[VoiceID] inference engine could not start`,e),new l(`initialization`,`VoiceID could not start. Retry loading. If it still fails, reload the page or use a passkey.`,{cause:e}))}}};const g=`please sign this trade now.confirm my order for today.please review my order.dump on them slowly.send this order to market.i'm here for the tech.keep this trade on track.the market is open.if you panic panic early.i check the latest quote.exit liquidity for all passengers.no crying in the casino.this trade fits my plan.approve this transfer at once.check the price before trading.let this trade go through.be retarded when others are fearful.be fearful when others are retarded.life is short go long to hedge.sign this swap right now.sign this swap with care.sign this swap today.check my order right now.check my order with care.check my order today.confirm the trade right now.confirm the trade with care.confirm the trade today.review this transfer right now.review this transfer with care.review this transfer today`.split(`.`),_={sale:[`please confirm this sale`,`the sale is ready`],purchase:[`this purchase has my approval`,`please confirm my purchase`],swap:[`confirm my swap today`,`the swap is ready to proceed`],transfer:[`confirm this transfer today`,`please send this transfer now`]},v=[...g,..._.sale,..._.purchase,..._.swap,..._.transfer],y=`.<unk>.▁t.he.▁a.▁the.in.▁s.▁w.▁o.re.nd.▁b.▁h.er.▁m.▁i.ou.▁c.▁f.at.ed.▁and.en.▁to.▁of.on.is.▁d.ing.▁th.▁p.▁he.or.▁l.es.▁in.ll.it.ar.as.an.▁n.▁g.om.▁be.▁ha.▁e.le.ot.▁y.ut.ow.ic.▁wh.▁it.ld.ve.▁that.ly.▁was.id.se.st.▁on.gh.ent.▁re.▁you.im.ce.▁u.ver.ion.▁as.et.▁for.ay.▁we.▁his.ith.al.ir.▁r.▁with.▁st.ad.ur.ght.▁an.▁her.▁not.▁had.▁is.ter.her.ac.am.▁at.oo.▁but.ould.▁she.▁k.▁se.▁sa.▁sh.▁fr.▁him.▁so.ill.▁me.ain.▁su.ight.ch.red.ct.all.ro.ke.ess.il.ore.▁de.▁they.▁my.▁whe.▁all.ich.▁ne.ri.▁by.▁have.ome.pp.▁this.▁li.▁do.▁con.us.▁which.▁ch.ul.qu.▁j.▁up.▁said.▁from.ard.ge.▁or.▁v.▁one.th.▁no.▁ex.▁were.▁there.pe.and.est.▁man.▁who.ble.ant.ie.▁al.res.ous.ust.very.ation.▁fe.▁them.lf.▁when.ind.nt.ame.ra.▁go.ers.ast.fe.ood.▁kn.▁int.ist.art.▁are.out.▁would.▁le.os.▁their.ong.▁what.our.▁if.ound.▁com.▁ab.▁out.▁wor.em.▁will.ak.▁mis.ate.ol.um.un.itt.ough.ked.ap.ig.one.▁been.own.ive.▁then.▁br.ven.if.▁ar.▁tr.self.▁.e.t.a.o.n.i.h.s.r.d.l.u.m.c.w.f.g.y.p.b.v.k.'.x.j.q.z`.split(`.`),b=`[PAD].[UNK].[CLS].[SEP].[MASK].'.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.##i.##s.##r.##o.##b.##n.##g.##m.##e.##d.##t.##a.##u.##p.##x.##c.##l.##z.##y.##v.##k.##h.##f.##q.##w.##j.th.the.##er.##nd.##in.##ed.##ou.##at.##en.and.##or.##es.to.of.##on.##is.##ing.##ar.##it.##as.##an.##ll.in.##re.wh.he.##om.be.ha.##le.##ot.##ow.##ic.##ut.it.##ld.that.sh.##ly.was.##gh.##id.##se.on.##ve.##et.##ent.you.##im.##st.##ce.##ith.for.##ir.##ion.as.##ay.his.##al.with.##ur.st.##ter.her.##ver.##ch.re.##ad.##ght.an.not.is.had.sa.at.##oo.##her.but.##ould.she.##ct.##ess.fr.se.##am.pr.we.him.so.##ill.##ain.su.##ight.me.##ere.##all.##ke.##il.de.my.they.all.##est.ch.##ich.ne.by.have.##ome.##pp.##ck.li.this.do.##ore.con.##us.which.##ri.##ul.up.said.from.##th.##ard.##ge.##ra.or.one.no.ex.were.there.##os.##pe.man.##ble.who.al.##ant.##ie.##ous.##ust.##ation.fe.##and.them.##ers.##lf.when.##ind.##ast.go.##ood.kn.##un.##our.##ist.##em.are.##out.would.##art.what.le.their.##ong.en.if.un.##if.com.##ound.ab.out.wor.##ol.will.int.br.##ak.mis.##ate.##op.##um.##ough.##la.##itt.ar.##ook.##ish.##one.##ap.been.##own.##ame.then.##ven`.split(`.`),x=new h({path:`/sdk/voiceid/aurora-int8.onnx`,sha256:`83ed6f3856458cd96d49a70d8c5175aeec18ba8c184e5367e089cd424eebefd6`,bytes:1342384,label:`Phrase recognition`}),S=new h({path:`/sdk/voiceid/citrinet-int8.onnx`,sha256:`875f58df0e2a593017ac9550c8fab68c4343cd1fbb2a042290450aa125441ed5`,bytes:10483704,label:`Phrase recognition`});function C(e){switch(e){case`aurora`:return x;case`citrinet`:return S;default:return E(e)}}let w=null;function T(e){return ee(g,e)}function E(e){throw Error(`Unexpected VoiceID state: ${String(e)}`)}function ee(e,t){let n=e.filter(te.bind(null,t)),r=n.filter(te.bind(null,w)),i=r.length>0?r:n;if(i.length===0)throw Error(`No fresh VoiceID challenge is available.`);let a=new Uint32Array(1);crypto.getRandomValues(a);let o=i[a[0]%i.length];return w=o,o}function te(e,t){return t!==e}const D=new Map([[`sea`,`see`],[`here`,`hear`],[`meat`,`meet`],[`whether`,`weather`],[`son`,`sun`],[`wood`,`would`],[`two`,`to`],[`too`,`to`],[`eye`,`i`],[`sail`,`sale`]]),O=new Set([`no`,`not`,`never`,`cannot`,`can't`,`don't`,`doesn't`,`isn't`,`aren't`,`wasn't`,`weren't`,`won't`,`wouldn't`,`shouldn't`,`without`]);function k(e){return e.toLowerCase().replace(/’/g,`'`).match(/[a-z0-9]+(?:'[a-z]+)?/g)??[]}function ne(e){return e!==`a`&&e!==`an`&&e!==`the`}function A(e){return D.get(e)??e}function j(e){return e.filter(ne).map(A).join(` `).replace(/\bto day\b/g,`today`)}function re(e){return O.has(e)}function ie(e,t){let n=Array.from({length:t.length+1},M);for(let r=0;r<e.length;r+=1){let i=[r+1];for(let a=0;a<t.length;a+=1)i.push(Math.min(i[a]+1,n[a+1]+1,n[a]+(e[r]===t[a]?0:1)));n=i}return n[t.length]}function M(e,t){return t}function N(e){let t=k(e),n=j(t);if(!n)return{kind:`empty`};let r=v[0],i=1/0,a=1/0;for(let e of v){let t=j(k(e)),o=ie(n,t)/Math.max(n.length,t.length);o<i?(a=i,i=o,r=e):a=Math.min(a,o)}let o=a-i;if(t.filter(re).join(` `)!==k(r).filter(re).join(` `))return{kind:`uncertain`,candidate:r,difference:i,margin:o,decodedText:e,reason:`negated`};let s=k(r).length;return i>.3||Math.abs(t.length-s)>2?{kind:`uncertain`,candidate:r,difference:i,margin:o,decodedText:e,reason:`different`}:o<.1?{kind:`uncertain`,candidate:r,difference:i,margin:o,decodedText:e,reason:`ambiguous`}:{kind:`recognized`,phrase:r,difference:i,margin:o,decodedText:e}}var P=class extends Error{constructor(){super(`The phrase was not clear. Try the new phrase at your normal pace.`),this.name=`VoicePhraseMismatchError`}};function ae(e,t,n){let r=n===`aurora`?0:256,i=[],a=-1;for(let n=0;n<t;n+=1){let t=n*257,o=-1/0,s=r;for(let n=0;n<257;n+=1){let r=e[t+n];if(!Number.isFinite(r))throw Error(`Phrase model returned invalid scores.`);r>o&&(o=r,s=n)}s!==r&&s!==a&&i.push(s),a=s}if(i.length===0)return``;switch(n){case`aurora`:return i.map(ce).join(``).replace(/▁/g,` `).trim().replace(/\s+/g,` `);case`citrinet`:return oe(i);default:return E(n)}}function oe(e){let t=``,n=!1;for(let r of e){let e=b[r];if(!e.startsWith(`[`)){if(e.startsWith(`##`))t+=e.slice(2);else if(e===`'`){t+=e,n=!0;continue}else t+=(n||t.length===0?``:` `)+e;n=!1}}return t.trim()}function se(e,t){let n=N(e);return n.kind===`recognized`&&n.phrase===t?{kind:`matched`,recognition:n}:{kind:`mismatch`,recognition:n}}function ce(e){return y[e]}async function le(e,t,n){let r=await C(n).prepare(),i=new(await(import(`./ort.wasm.bundle.min-7y-hlRN8.js`))).Tensor(`float32`,e,[1,e.length]);try{let e=await r.run({samples:i});try{let r=e.logits;if(!r||!(r.data instanceof Float32Array)||r.dims.length!==3||r.dims[0]!==1||r.dims[2]!==257||r.data.length!==r.dims[1]*257)throw Error(`Phrase model returned an invalid result.`);return se(ae(r.data,r.dims[1],n),t)}finally{for(let t of Object.values(e))t.dispose()}}finally{i.dispose()}}const ue=new h({path:`/sdk/voiceid/silero-vad.onnx`,sha256:`2623a2953f6ff3d2c1e61740c6cdb7168133479b267dfef114a4a3cc5bdd788f`,bytes:2327524,label:`Speech detection`});async function de(){return new fe(await ue.prepare(),await import(`./ort.wasm.bundle.min-7y-hlRN8.js`))}var fe=class{state=new Float32Array(256);context=new Float32Array(64);constructor(e,t){this.session=e,this.ort=t}async probability(e){if(e.length!==512)throw Error(`Speech detection requires a 512-sample frame.`);let t=new Float32Array(576);t.set(this.context),t.set(e,64);let n=new this.ort.Tensor(`float32`,t,[1,576]),r=new this.ort.Tensor(`float32`,this.state,[2,1,128]),i=new this.ort.Tensor(`int64`,BigInt64Array.of(16000n),[]);try{let t=await this.session.run({input:n,state:r,sr:i});try{let n=t.output?.data,r=t.stateN?.data;if(!(n instanceof Float32Array)||n.length!==1||!Number.isFinite(n[0])||n[0]<0||n[0]>1||!(r instanceof Float32Array)||r.length!==256)throw Error(`Speech detection returned an invalid result.`);return this.state.set(r),this.context.set(e.subarray(448)),n[0]}finally{for(let e of Object.values(t))e.dispose()}}finally{n.dispose(),r.dispose(),i.dispose(),t.fill(0)}}clear(){this.state.fill(0),this.context.fill(0)}};let F={kind:`unread`};function pe(e){return typeof e==`string`&&e.length>0&&e!==`default`&&e!==`communications`}async function me(){if(F.kind!==`unread`)return F;let e={kind:`system_default`};try{let t=await i();r(t)&&t.kind===`device`&&pe(t.deviceId)&&(e={kind:`device`,deviceId:t.deviceId})}catch{}return F.kind===`unread`&&(F=e),F}function he(e){let t={channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return e.kind===`device`&&(t.deviceId={exact:e.deviceId}),{audio:t,video:!1}}async function ge(e){if(pe(e.deviceId))return{kind:`device`,deviceId:e.deviceId};if(e.groupId)try{let t=await navigator.mediaDevices.enumerateDevices();for(let n of t)if(n.kind===`audioinput`&&n.groupId===e.groupId&&pe(n.deviceId))return{kind:`device`,deviceId:n.deviceId}}catch{}return{kind:`system_default`}}async function _e(e){e.throwIfAborted();let t=await me();e.throwIfAborted();let n,r=t.kind===`device`?`preferred`:`default`;try{n=await navigator.mediaDevices.getUserMedia(he(t))}catch(i){if(e.throwIfAborted(),t.kind!==`device`||!(i instanceof DOMException)||i.name!==`OverconstrainedError`&&i.name!==`NotFoundError`)throw i;n=await navigator.mediaDevices.getUserMedia(he({kind:`system_default`})),r=`replacement`}let i=ve.bind(null,n);e.addEventListener(`abort`,i,{once:!0});try{e.throwIfAborted();let t=n.getAudioTracks()[0];if(!t||t.readyState!==`live`)throw new Se;let i=t.getSettings(),a=await ge(i);if(e.throwIfAborted(),t.readyState!==`live`)throw new Se;return{stream:n,preference:a,selection:r,label:t.label||`Default microphone`,processing:{noiseSuppression:i.noiseSuppression??null,echoCancellation:i.echoCancellation??null,autoGainControl:i.autoGainControl??null,sampleRate:i.sampleRate??null}}}catch(e){throw i(),e}finally{e.removeEventListener(`abort`,i)}}function ve(e){for(let t of e.getTracks())t.stop()}async function ye(e){e.preference.kind!==`device`||e.selection===`replacement`||await xe(e.preference)}async function be(){await xe({kind:`system_default`})}async function xe(e){F=e;try{await a(e)}catch{}}var Se=class extends Error{constructor(){super(`The microphone disconnected or stopped. Check your microphone and try again.`),this.name=`VoiceMicrophoneInterruptedError`}};function Ce(e){return e.noise===`high`?`Background noise is high. Move closer to the microphone and try again.`:`Audio too brief or quiet: ${(e.voicedMs/1e3).toFixed(2)} of ${(e.requiredVoicedMs/1e3).toFixed(2)} seconds detected.`}var we=class extends Error{constructor(e){super(Ce(e)),this.quality=e,this.name=`InsufficientVoiceAudioError`}};const I=16e3,Te=.006,Ee=8e3;function De(){if(Oe(),!navigator.userActivation.isActive)throw Error(`Open the Wallet and select Record to use VoiceID.`)}function Oe(){if(document.visibilityState!==`visible`||!document.hasFocus())throw Error(`Keep the Wallet open and focused to use VoiceID.`)}async function ke(e,t){if(e.aborted)throw Error(`VoiceID recording was cancelled.`);let n=crypto.randomUUID();t({kind:`opening`});let r=await _e(e),{stream:i}=r;try{if(e.aborted)throw Error(`VoiceID recording was cancelled.`);let a=await new Ae(i,e,t).result.finally(t.bind(null,{kind:`processing`}));if(e.aborted)throw Error(`VoiceID recording was cancelled.`);let o=await new OfflineAudioContext(1,I,I).decodeAudioData(a.bytes),s=new OfflineAudioContext(1,Math.ceil(o.duration*I),I),c=s.createBufferSource();c.buffer=o,c.connect(s.destination),c.start();try{let i=await s.startRendering();try{if(e.aborted)throw Error(`VoiceID recording was cancelled.`);let o=i.getChannelData(0),s=await je(o,e),c={attemptId:n,capturedAtMs:Date.now(),durationMs:i.duration*1e3,recordingMs:a.recordingMs,endedBy:a.endedBy,voicedMs:s.voicedMs,peakFrameRms:s.peakFrameRms,levelThreshold:Te,requiredVoicedMs:600,microphone:r.label,microphoneSelection:r.selection,processing:r.processing,backgroundRms:s.backgroundRms,speechToBackgroundDb:s.speechToBackgroundDb,noise:s.noise};if(t({kind:`measured`,quality:c}),s.kind===`insufficient_audio`)return{kind:`insufficient_audio`,quality:c};let l=o.slice(Math.max(0,s.first-3200),Math.min(o.length,s.last+3200));return await ye(r),e.aborted&&(l.fill(0),e.throwIfAborted()),{kind:`captured`,samples:l,quality:c}}finally{Me(i)}}finally{Me(o)}}finally{for(let e of i.getTracks())e.stop()}}var Ae=class{recorder;chunks=[];timer=null;completion=new e;startedAtMs=performance.now();ended=null;activity={kind:`waiting`,activeMs:0};audioContext=null;worklet=null;detector=null;pending=Promise.resolve();queuedFrames=0;closed=!1;result=this.completion.promise;constructor(e,t,n){this.stream=e,this.signal=t,this.onCapture=n,this.recorder=new MediaRecorder(e),this.recorder.addEventListener(`dataavailable`,this.data),this.recorder.addEventListener(`stop`,this.stopped),this.recorder.addEventListener(`error`,this.failed);for(let t of e.getAudioTracks())t.addEventListener(`ended`,this.interrupted),t.addEventListener(`mute`,this.interrupted);t.addEventListener(`abort`,this.cancelled,{once:!0}),this.timer=setTimeout(this.startupFailed,Ee),this.start()}async start(){try{if(await this.startPauseDetection(),this.signal.throwIfAborted(),this.startedAtMs=performance.now(),this.closed)return;this.recorder.start(),this.timer!==null&&clearTimeout(this.timer),this.timer=setTimeout(this.stop.bind(this,`limit`),Ee),this.onCapture({kind:`listening`})}catch(e){this.cleanup(),this.completion.reject(e instanceof Error?e:Error(`Speech detection could not start.`))}}data=e=>{this.chunks.push(e.data)};stop=e=>{this.recorder.state!==`inactive`&&(this.ended={endedBy:e,recordingMs:performance.now()-this.startedAtMs},this.recorder.stop(),this.stopTracks())};cancelled=()=>{if(this.recorder.state===`inactive`){this.cleanup(),this.completion.reject(Error(`VoiceID recording was cancelled.`));return}this.stop(`stream_ended`)};startupFailed=()=>{this.cleanup(),this.completion.reject(Error(`Speech detection startup timed out. Please try again.`))};detectorFailed=e=>{this.cleanup(),this.completion.reject(e instanceof Error?e:Error(`Speech detection failed.`))};failed=()=>{this.cleanup(),this.completion.reject(Error(`VoiceID could not record this microphone.`))};interrupted=()=>{this.cleanup(),this.completion.reject(new Se)};stopped=()=>{let e=this.ended;if(this.cleanup(),this.signal.aborted){this.completion.reject(Error(`VoiceID recording was cancelled.`));return}if(e===null){this.completion.reject(new Se);return}new Blob(this.chunks,{type:this.recorder.mimeType}).arrayBuffer().then(this.complete.bind(this,e),this.completion.reject.bind(this.completion))};complete=(e,t)=>{if(this.signal.aborted){this.completion.reject(Error(`VoiceID recording was cancelled.`));return}this.completion.resolve({bytes:t,recordingMs:e.recordingMs,endedBy:e.endedBy})};async startPauseDetection(){let e=new AudioContext({sampleRate:I});this.audioContext=e;let t=e.resume();if(this.detector=await de(),this.signal.throwIfAborted(),e.sampleRate!==I)throw Error(`Speech detection requires 16 kHz audio.`);await e.audioWorklet.addModule(`/sdk/voiceid/voice-activity-worklet.js`),this.signal.throwIfAborted();let n=new AudioWorkletNode(e,`voice-activity-frames`);this.worklet=n,n.port.onmessage=this.receiveFrame,e.createMediaStreamSource(this.stream).connect(n),n.connect(e.destination),await t}receiveFrame=e=>{if(!(e.data instanceof Float32Array)||e.data.length!==512){this.failed();return}if(this.closed||this.recorder.state!==`recording`){e.data.fill(0);return}if(++this.queuedFrames>32){e.data.fill(0),this.failed();return}this.pending=this.pending.then(this.processFrame.bind(this,e.data)).catch(this.detectorFailed)};async processFrame(e){let t=this.detector;try{if(this.closed||!t)return;let n=await t.probability(e);if(this.closed){t.clear();return}let r=0;for(let t of e)r+=t*t;let i=Math.sqrt(r/e.length),a=n>=.5&&i>=Te;this.updateActivity(a),this.onCapture({kind:`activity`,rms:i,speech:a})}finally{e.fill(0),--this.queuedFrames}}updateActivity(e){let t=performance.now();switch(this.activity.kind){case`waiting`:{let n=e?this.activity.activeMs+32:0;this.activity=n>=100?{kind:`speaking`,lastSoundAtMs:t}:{kind:`waiting`,activeMs:n};return}case`speaking`:e?this.activity={kind:`speaking`,lastSoundAtMs:t}:t-this.activity.lastSoundAtMs>=1500&&this.stop(`pause`);return;default:return Pe(this.activity)}}stopPauseDetection=()=>{this.closed=!0,this.worklet&&(this.worklet.port.onmessage=null,this.worklet.port.close(),this.worklet.disconnect()),this.worklet=null,this.detector?.clear(),this.detector=null;let e=this.audioContext;this.audioContext=null,e&&e.close().catch(Ne)};stopTracks(){for(let e of this.stream.getTracks())e.stop()}cleanup(){for(let e of this.stream.getAudioTracks())e.removeEventListener(`ended`,this.interrupted),e.removeEventListener(`mute`,this.interrupted);this.stopPauseDetection(),this.stopTracks(),this.timer!==null&&clearTimeout(this.timer),this.signal.removeEventListener(`abort`,this.cancelled),this.recorder.removeEventListener(`dataavailable`,this.data),this.recorder.removeEventListener(`stop`,this.stopped),this.recorder.removeEventListener(`error`,this.failed)}};async function je(e,t){let n=await de(),r=-1,i=0,a=0,o=0,s=0,c=0,l=0,u=new Float32Array(512);try{for(let d=0;d<e.length;d+=u.length){t.throwIfAborted(),u.fill(0);let f=Math.min(u.length,e.length-d);u.set(e.subarray(d,d+f));let p=0;for(let e of u)p+=e*e;let m=Math.sqrt(p/f);if(o=Math.max(o,m),!(await n.probability(u)>=.5&&m>=Te)){s+=p,c+=f;continue}r<0&&(r=d),i=d+f,a+=f,l+=p}}finally{u.fill(0),n.clear()}let d=Math.sqrt(s/Math.max(1,c)),f=Math.sqrt(l/Math.max(1,a)),p=a&&c?20*Math.log10(Math.max(f,1e-8)/Math.max(d,1e-8)):null,m={backgroundRms:d,speechToBackgroundDb:p,noise:d>=Te&&(p===null||p<10)?`high`:c?`normal`:`unknown`},h=a/I*1e3;return r<0||h<600?{kind:`insufficient_audio`,voicedMs:h,peakFrameRms:o,...m}:{kind:`captured`,first:r,last:i,voicedMs:h,peakFrameRms:o,...m}}function Me(e){for(let t=0;t<e.numberOfChannels;t+=1)e.getChannelData(t).fill(0)}function Ne(){}function Pe(e){throw Error(`Unexpected speech activity: ${String(e)}`)}var Fe,L,Ie,R,Le,Re,z,B,ze,Be,V,H,Ve,He,Ue={},We=[],Ge=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ke=Array.isArray;function U(e,t){for(var n in t)e[n]=t[n];return e}function qe(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Je(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Fe.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Ye(e,o,r,i,null)}function Ye(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ie,__i:-1,__u:0};return i==null&&L.vnode!=null&&L.vnode(a),a}function Xe(e){return e.children}function W(e,t){this.props=e,this.context=t}function Ze(e,t){if(t==null)return e.__?Ze(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?Ze(e):null}function Qe(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=U({},t);a.__v=t.__v+1,L.vnode&&L.vnode(a),ut(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ze(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ft(r,a,i),t.__e=t.__=null,a.__e!=n&&$e(a)}}function $e(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),$e(e)}function et(e){(!e.__d&&(e.__d=!0)&&R.push(e)&&!tt.__r++||Le!=L.debounceRendering)&&((Le=L.debounceRendering)||Re)(tt)}function tt(){try{for(var e,t=1;R.length;)R.length>t&&R.sort(z),e=R.shift(),t=R.length,Qe(e)}finally{R.length=tt.__r=0}}function nt(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||We,v=t.length;for(c=rt(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||Ue,p.__i=d,g=ut(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ht(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=it(p,c,e),f.__e&&=null):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function rt(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=Ye(null,o,null,null,null):Ke(o)?o=e.__k[a]=Ye(Xe,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Ye(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ot(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=Ze(s)),gt(s,s));return r}function it(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=it(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Ze(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function at(e,t){return t||=[],e==null||typeof e==`boolean`||(Ke(e)?e.some(function(e){at(e,t)}):t.push(e)),t}function ot(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function st(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||Ge.test(t)?n:n+`px`}function ct(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||st(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||st(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(V,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[Be]=r[Be]:(n[Be]=H,e.addEventListener(t,a?He:Ve,a)):e.removeEventListener(t,a?He:Ve,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function lt(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[ze]==null)t[ze]=H++;else if(t[ze]<n[Be])return;return n(L.event?L.event(t):t)}}}function ut(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=L.__b)&&u(t);n:if(typeof E==`function`){d=o.length;try{if(v=t.props,y=E.prototype&&E.prototype.render,b=(u=E.contextType)&&r[u.__c],x=u?b?b.props.value:u.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new E(v,x):(t.__c=f=new W(v,x),f.constructor=E,f.render=_t),b&&b.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&E.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=U({},f.__s)),U(f.__s,E.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&E.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&E.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),We.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f),s=Ze(n);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__e=!1,S=L.__r,C=0,y)f.state=f.__s,f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),We.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,S&&S(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++C<25);f.state=f.__s,f.getChildContext!=null&&(r=U(U({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),w=u!=null&&u.type===Xe&&u.key==null?pt(u.props.children):u,s=nt(e,Ke(w)?w:[w],t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(T=a.length;T--;)qe(a[T])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||dt(t),L.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=mt(n.__e,t,n,r,i,a,o,c,l);return(u=L.diffed)&&u(t),128&t.__u?void 0:s}function dt(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(dt))}function ft(e,t,n){for(var r=0;r<n.length;r++)ht(n[r],n[++r],n[++r]);L.__c&&L.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){L.__e(e,t.__v)}})}function pt(e){return typeof e!=`object`||!e||e.__b>0?e:Ke(e)?e.map(pt):e.constructor===void 0?U({},e):null}function mt(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||Ue,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(L.__m&&L.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&Fe.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||ct(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||ct(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),nt(t.type==`template`?e.content:e,Ke(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&Ze(n,0),s,c),a!=null)for(l=a.length;l--;)qe(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&ct(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&ct(e,l,h,g[l],i))}return e}function ht(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){L.__e(e,n)}}function gt(e,t,n){var r,i;if(L.unmount&&L.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||ht(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){L.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&gt(r[i],t,n||typeof e.type!=`function`);n||qe(e.__e),e.__c=e.__=e.__e=void 0}function _t(e,t,n){return this.constructor(e,n)}function vt(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),L.__&&L.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],ut(t,e=(!r&&n||t).__k=Je(Xe,null,[e]),i||Ue,Ue,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Fe.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ft(a,e,o),e.props.children=null}Fe=We.slice,L={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},Ie=0,W.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=U({},this.state);typeof e==`function`&&(e=e(U({},n),this.props)),e&&U(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),et(this))},W.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),et(this))},W.prototype.render=Xe,R=[],Re=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,z=function(e,t){return e.__v.__b-t.__v.__b},tt.__r=0,B=Math.random().toString(8),ze=`__d`+B,Be=`__a`+B,V=/(PointerCapture)$|Capture$/i,H=0,Ve=lt(!1),He=lt(!0);var yt,G,bt,xt,St=0,Ct=[],K=L,wt=K.__b,Tt=K.__r,Et=K.diffed,Dt=K.__c,Ot=K.unmount,kt=K.__;function At(e,t){K.__h&&K.__h(G,e,St||t),St=0;var n=G.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function jt(e){return St=1,Mt(Wt,e)}function Mt(e,t,n){var r=At(yt++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Wt(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=G,!G.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};G.__f=!0;var a=G.shouldComponentUpdate,o=G.componentWillUpdate;G.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},G.shouldComponentUpdate=i}return r.__N||r.__}function Nt(e,t){var n=At(yt++,3);!K.__s&&Ut(n.__H,t)&&(n.__=e,n.u=t,G.__H.__h.push(n))}function Pt(e){return St=5,Ft(function(){return{current:e}},[])}function Ft(e,t){var n=At(yt++,7);return Ut(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function It(e,t){return St=8,Ft(function(){return e},t)}function Lt(){var e=At(yt++,11);if(!e.__){for(var t=G.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||=[0,0];e.__=`P`+n[0]+`-`+ n[1]++}return e.__}function Rt(){for(var e;e=Ct.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Vt),t.__h.some(Ht),t.__h=[]}catch(n){t.__h=[],K.__e(n,e.__v)}}}K.__b=function(e){G=null,wt&&wt(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),kt&&kt(e,t)},K.__r=function(e){Tt&&Tt(e),yt=0;var t=(G=e.__c).__H;t&&(bt===G?(t.__h=[],G.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Vt),t.__h.some(Ht),t.__h=[],yt=0)),bt=G},K.diffed=function(e){Et&&Et(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ct.push(t)!==1&&xt===K.requestAnimationFrame||((xt=K.requestAnimationFrame)||Bt)(Rt)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),bt=G=null},K.__c=function(e,t){t.some(function(e){try{e.__h.some(Vt),e.__h=e.__h.filter(function(e){return!e.__||Ht(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],K.__e(n,e.__v)}}),Dt&&Dt(e,t)},K.unmount=function(e){Ot&&Ot(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Vt(e)}catch(e){t=e}}),n.__H=void 0,t&&K.__e(t,n.__v))};var zt=typeof requestAnimationFrame==`function`;function Bt(e){var t,n=function(){clearTimeout(r),zt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);zt&&(t=requestAnimationFrame(n))}function Vt(e){var t=G,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),G=t}function Ht(e){var t=G;e.__c=e.__(),G=t}function Ut(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Wt(e,t){return typeof t==`function`?t(e):t}function Gt(e,t){for(var n in t)e[n]=t[n];return e}function Kt(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function q(e,t){this.props=e,this.context=t}(q.prototype=new W).isPureReactComponent=!0,q.prototype.shouldComponentUpdate=function(e,t){return Kt(this.props,e)||Kt(this.state,t)};var qt=L.__b;L.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),qt&&qt(e)};var Jt=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.forward_ref`)||3911;function Yt(e){function t(t){var n=Gt({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=Jt,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=`ForwardRef(`+(e.displayName||e.name)+`)`,t}var Xt=L.__e;L.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}Xt(e,t,n,r)};var Zt=L.unmount;function Qt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Gt({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Qt(e,t,n)})),e}function $t(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return $t(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function en(){this.__u=0,this.o=null,this.__b=null}function tn(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function nn(){this.i=null,this.l=null}L.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Zt&&Zt(e)},(en.prototype=new W).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=tn(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=$t(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},en.prototype.componentWillUnmount=function(){this.o=[]},en.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Qt(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&Je(Xe,null,e.fallback);return i&&(i.__u&=-33),[Je(Xe,null,t.__a?null:e.children),i]};var rn=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(nn.prototype=new W).__a=function(e){var t=this,n=tn(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),rn(t,e,r)):i()};n?n(a):a()}},nn.prototype.render=function(e){this.i=null,this.l=new Map;var t=at(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},nn.prototype.componentDidUpdate=nn.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){rn(e,n,t)})};var an=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,on=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,sn=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,cn=/[A-Z0-9]/g,ln=typeof document<`u`,un=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};W.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(W.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var dn=L.event;L.event=function(e){return dn&&(e=dn(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var fn={configurable:!0,get:function(){return this.class}},pn=L.vnode;L.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||ln&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||un(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:sn.test(a)&&(a=s):s=a=`oninput`:i&&on.test(a)?a=a.replace(cn,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=at(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=at(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,fn)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=an,pn&&pn(e)};var mn=L.__r;L.__r=function(e){mn&&mn(e),e.__c};var hn=L.diffed;L.diffed=function(e){hn&&hn(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};var gn=0;Array.isArray;function J(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gn,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return L.vnode&&L.vnode(l),l}function _n(e){let t=e.trim(),n=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(n){let e=n[1].length===3?n[1].split(``).map(e=>e+e).join(``):n[1];return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}let r=t.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);return r?[Math.round(+r[1]),Math.round(+r[2]),Math.round(+r[3])]:null}function vn(e){let t=_n(e);return t?`rgb(${t[0]}, ${t[1]}, ${t[2]})`:null}function yn(e){let t=_n(e);return t?`${t[0]}, ${t[1]}, ${t[2]}`:null}const bn={dark:{strokeOpacity:1.16,innerOpacity:.47,bloomOpacity:.89,innerShadow:`rgba(255, 255, 255, 0.1)`,saturation:1.2,brightness:1.1},light:{strokeOpacity:1.2,innerOpacity:.85,bloomOpacity:.5,innerShadow:`rgba(0, 0, 0, 0.08)`,saturation:1.6,brightness:.95,hueRange:40,hueDuration:8.5,hueBase:5,strength:.8,bandStrength:1.7}},xn=[{x:0,w:74,h:46,band:0},{x:-36,w:54,h:40,band:1},{x:36,w:54,h:40,band:1},{x:-72,w:48,h:32,band:2},{x:72,w:48,h:32,band:2},{x:-108,w:42,h:26,band:1},{x:108,w:42,h:26,band:1}],Sn=36*xn.length,Cn={colorful:{dark:[`rgb(255, 70, 120)`,`rgb(60, 190, 255)`,`rgb(175, 70, 255)`,`rgb(60, 220, 130)`,`rgb(255, 150, 40)`,`rgb(90, 100, 255)`,`rgb(40, 200, 190)`],light:[`rgb(255, 201, 21)`,`rgb(126, 196, 255)`,`rgb(180, 40, 230)`,`rgb(235, 100, 160)`,`rgb(255, 176, 122)`,`rgb(154, 160, 255)`,`rgb(127, 217, 238)`]},mono:{dark:[`rgb(215, 215, 215)`,`rgb(180, 180, 180)`,`rgb(190, 190, 190)`,`rgb(160, 160, 160)`,`rgb(170, 170, 170)`,`rgb(150, 150, 150)`,`rgb(155, 155, 155)`],light:[`rgb(60, 60, 60)`,`rgb(90, 90, 90)`,`rgb(85, 85, 85)`,`rgb(110, 110, 110)`,`rgb(105, 105, 105)`,`rgb(125, 125, 125)`,`rgb(120, 120, 120)`]},ocean:{dark:[`rgb(80, 140, 255)`,`rgb(40, 200, 230)`,`rgb(120, 90, 255)`,`rgb(30, 170, 210)`,`rgb(160, 80, 240)`,`rgb(60, 110, 255)`,`rgb(40, 190, 180)`],light:[`rgb(40, 100, 240)`,`rgb(20, 160, 200)`,`rgb(90, 60, 230)`,`rgb(20, 130, 180)`,`rgb(130, 50, 220)`,`rgb(40, 80, 230)`,`rgb(20, 150, 150)`]},sunset:{dark:[`rgb(255, 110, 60)`,`rgb(255, 180, 40)`,`rgb(255, 60, 90)`,`rgb(255, 210, 80)`,`rgb(240, 70, 140)`,`rgb(255, 140, 50)`,`rgb(230, 50, 110)`],light:[`rgb(235, 80, 30)`,`rgb(230, 150, 10)`,`rgb(230, 30, 70)`,`rgb(225, 175, 30)`,`rgb(215, 40, 110)`,`rgb(235, 110, 20)`,`rgb(205, 30, 90)`]},forest:{dark:[`rgb(70, 220, 120)`,`rgb(40, 200, 180)`,`rgb(140, 230, 80)`,`rgb(30, 170, 140)`,`rgb(190, 235, 70)`,`rgb(50, 190, 110)`,`rgb(30, 150, 120)`],light:[`rgb(30, 170, 80)`,`rgb(20, 150, 130)`,`rgb(90, 180, 30)`,`rgb(20, 130, 100)`,`rgb(130, 180, 20)`,`rgb(30, 150, 80)`,`rgb(20, 120, 90)`]},candy:{dark:[`rgb(255, 90, 170)`,`rgb(255, 120, 220)`,`rgb(210, 80, 255)`,`rgb(255, 150, 190)`,`rgb(180, 110, 255)`,`rgb(255, 70, 140)`,`rgb(230, 100, 240)`],light:[`rgb(235, 40, 140)`,`rgb(230, 70, 190)`,`rgb(180, 40, 230)`,`rgb(235, 100, 160)`,`rgb(150, 70, 230)`,`rgb(230, 30, 110)`,`rgb(200, 60, 210)`]},ice:{dark:[`rgb(150, 230, 255)`,`rgb(90, 200, 255)`,`rgb(190, 240, 255)`,`rgb(120, 190, 255)`,`rgb(160, 220, 250)`,`rgb(80, 170, 255)`,`rgb(200, 235, 255)`],light:[`rgb(30, 160, 220)`,`rgb(20, 130, 210)`,`rgb(60, 180, 230)`,`rgb(40, 120, 220)`,`rgb(50, 160, 220)`,`rgb(20, 110, 220)`,`rgb(70, 170, 230)`]},gold:{dark:[`rgb(255, 200, 70)`,`rgb(255, 170, 40)`,`rgb(255, 220, 110)`,`rgb(240, 150, 30)`,`rgb(255, 235, 140)`,`rgb(230, 160, 40)`,`rgb(250, 210, 90)`],light:[`rgb(200, 140, 10)`,`rgb(190, 120, 0)`,`rgb(210, 160, 30)`,`rgb(180, 110, 0)`,`rgb(205, 170, 40)`,`rgb(175, 115, 5)`,`rgb(195, 150, 20)`]}};function wn(e,t){let n=e.match(/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);return n?`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t.toFixed(2)})`:e}function Tn(e,t=1){return Math.max(.5,Math.round(e*t*100)/100)}function En(e,t){return`calc(50% + (var(--vb-cx-${t}) + var(--vb-x${e}-${t})) * var(--vb-w-${t}) * var(--vb-z-${t}, 1))`}function Dn({id:e,colors:t,alpha:n,sw:r,sh:i,y:a,fade:o,count:s}){return(s?xn.slice(0,s):xn).map((s,c)=>{let l=n>=1?t[c%t.length]:wn(t[c%t.length],n),u=`calc(${Math.round(s.w*r)}px * var(--vb-w-${e}) * var(--vb-z-${e}, 1))`,d=`calc(${Math.round(s.h*i)}px * var(--vb-h-${e}) * var(--vb-l${c}-${e}) * var(--vb-z-${e}, 1))`,f=`calc(100% + (${a}px + var(--vb-y${c}-${e})) * var(--vb-z-${e}, 1))`;return`radial-gradient(ellipse ${u} ${d} at ${En(c,e)} ${f}, ${l} 0%, transparent ${o}%)`}).join(`,
2
- `)}function On(e){let{id:t,borderRadius:n,borderWidth:r,strokeOpacity:i,innerOpacity:a,bloomOpacity:o,innerShadow:s,colorVariant:c,colors:l,brightness:u,saturation:d,theme:f,hueBase:p=0,glowSize:m=1,glowWidth:h=1,glowHeight:g=1,strokeScale:_=1,innerScale:v=1,innerHeight:y=1,bloomScale:b=1,bloomHeight:x=1,coreSize:S=1,coreLight:C=0,coreLightWidth:w=1,coreLightHeight:T=1,rangeWidth:E=1,rangeHeight:ee=1,softness:te=1,distortion:D=!1,scale:O=1}=e,k=Math.round(28*O*10)/10,ne=Math.round(9*O*10)/10,A=Math.max(0,n-r),j=Math.round(Math.max(40,Math.min(95,70*te))),re=e=>h*e,ie=e=>g*e,M=e=>Math.round(e*10)/10,N=`var(--vb-z-${t}, 1)`,P=e=>`calc(${M(e)}px * ${N})`,ae=f===`dark`,oe=Cn[c][ae?`dark`:`light`].map((e,t)=>{let n=l?.[t];return n&&vn(n)||e}),se=c===`mono`?.6:1,ce=(i*se).toFixed(2),le=(a*se).toFixed(2),ue=(o*se).toFixed(2),de=u.toFixed(2),fe=d.toFixed(2),F=`hue-rotate(calc(var(--voice-hue-base, ${p}deg) + var(--vb-hue-${t})))`,pe=D?` url(#vb-distort-${t})`:``,me=`filter: ${F} brightness(${de}) saturate(${fe});`,he=`filter: ${F} brightness(${de}) saturate(${fe})${pe};`,ge=`filter: blur(${P(Tn(10,m))}) ${F} brightness(${de}) saturate(${fe});`,_e=`filter: blur(${P(Tn(10,m))}) ${F} brightness(${de}) saturate(${fe})${pe};`,ve=`calc(50% + var(--vb-cx-${t}) * var(--vb-w-${t}) * ${N})`,ye=`calc(100% + (2px + var(--vb-cy-${t})) * ${N})`,be=ae?`radial-gradient(ellipse calc(${M(30*S)}px * var(--vb-w-${t}) * ${N}) calc(${M(30*S)}px * var(--vb-h-${t}) * ${N}) at ${ve} ${ye}, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.14) 30%, transparent 65%)`:`radial-gradient(ellipse calc(${M(40*S)}px * var(--vb-w-${t}) * ${N}) calc(${M(30*S)}px * var(--vb-h-${t}) * ${N}) at ${ve} ${ye}, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.22) 35%, transparent 70%)`,xe=Dn({id:t,colors:oe,alpha:1,sw:re(_),sh:ie(_),y:2,fade:j}),Se=Dn({id:t,colors:oe,alpha:.46,sw:re(.9*v),sh:ie(.9*v*y),y:0,fade:j}),Ce=Dn({id:t,colors:oe,alpha:ae?.9:.7,sw:re(1.15*b),sh:ie(1.5*b*x),y:0,fade:Math.min(95,j+2)}),we=(e,n,r,i=0)=>`radial-gradient(ellipse calc(${M(e*E)}px * var(--vb-w-${t}) * var(--vb-mw-${t}) * ${N}) calc((${M(n*ee)}px * var(--vb-h-${t}) + var(--vb-bh-${t})) * ${N}) at ${ve} calc(100% + var(--vb-cy-${t}) * ${N}), white 0%, rgba(255, 255, 255, 0.5) ${r}%${i>0?`, rgba(255, 255, 255, ${i}) 85%`:``}, transparent 100%)`,I=(e,n)=>`opacity: calc(var(--vb-opacity-${t}, 1) * var(--vb-glow-${t}) * ${n} * var(--voice-${e}-opacity, 1) * var(--voice-strength, 1));`,Te=(e,t,r,i)=>`${e} {
3
- ${t}
4
- position: absolute;
5
- inset: 0;
6
- border-radius: ${P(n)};
7
- background: ${Se};
8
- box-shadow: inset 0 0 ${P(ne)} 1px ${s};
9
- -webkit-mask-image:
10
- ${we(170,64,45,.3)},
11
- linear-gradient(white, transparent ${P(k)}, transparent calc(100% - ${k}px * ${N}), white),
12
- linear-gradient(to right, white, transparent ${P(k)}, transparent calc(100% - ${k}px * ${N}), white);
13
- -webkit-mask-composite: source-in, source-over;
14
- mask-image:
15
- ${we(170,64,45,.3)},
16
- linear-gradient(white, transparent ${P(k)}, transparent calc(100% - ${k}px * ${N}), white),
17
- linear-gradient(to right, white, transparent ${P(k)}, transparent calc(100% - ${k}px * ${N}), white);
18
- mask-composite: intersect, add;
19
- pointer-events: none;
20
- /* Its own compositing layer: WebKit otherwise re-rasterizes the
21
- filtered layer into the parent every frame on the CPU (a phone-sized
22
- host runs at a sixth of the frame rate without this). */
23
- will-change: transform;
24
- z-index: 1;
25
- ${r}
26
- ${I(`inner`,le)}
27
- ${i}
28
- }`;return`
29
- @property --vb-opacity-${t} {
30
- syntax: "<number>";
31
- initial-value: 0;
32
- inherits: true;
33
- }
34
-
35
- [data-voice-beam="${t}"] {
36
- position: relative;
37
- border-radius: ${n}px;
38
- overflow: hidden;
39
- --vb-h-${t}: 0.8;
40
- --vb-w-${t}: 1;
41
- ${xn.map((e,n)=>` --vb-x${n}-${t}: ${e.x}px;
42
- --vb-l${n}-${t}: 1;
43
- --vb-y${n}-${t}: 0px;`).join(`
44
- `)}
45
- --vb-glow-${t}: 0.4;
46
- --vb-z-${t}: 1;
47
- --vb-cx-${t}: 0px;
48
- --vb-cy-${t}: 0px;
49
- --vb-bh-${t}: 0px;
50
- --vb-bendA-${t}: 0;
51
- --vb-mw-${t}: 1;
52
- --vb-hue-${t}: 0deg;
53
- --vb-level-${t}: 0;
54
- }
55
-
56
- [data-voice-beam="${t}"][data-active] {
57
- animation: vb-fade-in-${t} 0.6s ease forwards;
58
- }
59
-
60
- [data-voice-beam="${t}"][data-fading] {
61
- animation: vb-fade-out-${t} 0.5s ease forwards;
62
- }
63
-
64
- /* Stroke — the colours painted into the 1px edge ring, masked to the centred ellipse. */
65
- [data-voice-beam="${t}"][data-active]::after,
66
- [data-voice-beam="${t}"][data-fading]::after {
67
- content: "";
68
- position: absolute;
69
- inset: 0;
70
- border-radius: ${P(A)};
71
- padding: ${P(r)};
72
- clip-path: inset(0 round ${P(n)});
73
- background:
74
- ${be},
75
- ${xe};
76
- -webkit-mask:
77
- ${we(170,64,45)},
78
- linear-gradient(#fff 0 0) content-box,
79
- linear-gradient(#fff 0 0);
80
- -webkit-mask-composite: source-in, xor;
81
- mask:
82
- ${we(170,64,45)},
83
- linear-gradient(#fff 0 0) content-box,
84
- linear-gradient(#fff 0 0);
85
- mask-composite: intersect, exclude;
86
- pointer-events: none;
87
- /* Its own compositing layer: WebKit otherwise re-rasterizes the
88
- filtered layer into the parent every frame on the CPU (a phone-sized
89
- host runs at a sixth of the frame rate without this). */
90
- will-change: transform;
91
- z-index: 2;
92
- ${I(`stroke`,ce)}
93
- ${me}
94
- }
95
-
96
- /* Inner glow — soft light inside the element, faded off at the corners.
97
- With distortion on, this copy is clipped to ABOVE the band line (the
98
- polygon the driver writes each frame) and a mirror layer below carries
99
- the displacement filter, so only the glow under the line warps. */
100
- ${Te(`[data-voice-beam="${t}"][data-active]::before,
101
- [data-voice-beam="${t}"][data-fading]::before`,`content: "";`,D?`clip-path: var(--vb-clip-above-${t}, inset(0 round ${n}px));`:`clip-path: inset(0 round ${n}px);`,me)}
102
- ${D?Te(`[data-voice-beam="${t}"][data-active] [data-voice-beam-warp="inner"],
103
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-warp="inner"]`,`display: block;`,`clip-path: var(--vb-clip-below-${t}, inset(0 round ${n}px));`,he):``}
104
-
105
- /* Bloom — the blurred halo, tallest of the three, above the content. */
106
- [data-voice-beam="${t}"] [data-voice-beam-bloom],
107
- [data-voice-beam="${t}"] [data-voice-beam-warp] {
108
- display: none;
109
- position: absolute;
110
- inset: 0;
111
- border-radius: ${P(A)};
112
- pointer-events: none;
113
- /* Its own compositing layer: WebKit otherwise re-rasterizes the
114
- filtered layer into the parent every frame on the CPU (a phone-sized
115
- host runs at a sixth of the frame rate without this). */
116
- will-change: transform;
117
- opacity: 0;
118
- }
119
-
120
- [data-voice-beam="${t}"] [data-voice-beam-bloom],
121
- [data-voice-beam="${t}"] [data-voice-beam-warp="bloom"] {
122
- -webkit-mask: ${we(200,130,35)};
123
- mask: ${we(200,130,35)};
124
- background: ${Ce};
125
- z-index: 3;
126
- }
127
-
128
- [data-voice-beam="${t}"][data-active] [data-voice-beam-bloom],
129
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-bloom] {
130
- display: block;
131
- clip-path: ${D?`var(--vb-clip-above-${t}, inset(0 round ${n}px))`:`inset(0 round ${n}px)`};
132
- ${I(`bloom`,ue)}
133
- ${ge}
134
- }
135
- ${D?`
136
- [data-voice-beam="${t}"][data-active] [data-voice-beam-warp="bloom"],
137
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-warp="bloom"] {
138
- display: block;
139
- clip-path: var(--vb-clip-below-${t}, inset(0 round ${n}px));
140
- ${I(`bloom`,ue)}
141
- ${_e}
142
- }
143
-
144
- /* Processing drops the distortion: the driver marks the wrapper once the
145
- warp has faded out, the warp layers leave the paint and the base layers
146
- give up their split at the band line. */
147
- [data-voice-beam="${t}"][data-voice-warp="off"]::before,
148
- [data-voice-beam="${t}"][data-voice-warp="off"] [data-voice-beam-bloom] {
149
- clip-path: inset(0 round ${n}px);
150
- }
151
-
152
- [data-voice-beam="${t}"][data-voice-warp="off"] [data-voice-beam-warp] {
153
- display: none;
154
- }`:``}
155
-
156
- /* Epicentre — a soft white wash at the source, under the band line (the
157
- driver's clip; unclipped when no line is drawn), sitting above every
158
- glow layer and the band's halo so the centre reads lighter than the
159
- band (same z as the band canvases, painted after them). Sized by the voice like the
160
- other layers; off unless \`coreLight\` is set (the light theme sets it).
161
- Up to 1 it is the wash's opacity; past 1 the solid white core widens
162
- too, for a centre that stays lighter than a strong band. It follows the
163
- glow's presence but not \`strength\`, which would only dim it. */
164
- ${C>0?(()=>{let e=Math.max(0,Math.min(2,C-1)),n=Math.min(1,e),r=Math.max(0,e-1),i=1+.3*e,a=M(45*n+27*r),o=M(40+25*n+15*r),s=Math.min(1,.55+.35*n+.1*r).toFixed(2),c=M(72+14*n+8*r);return`[data-voice-beam="${t}"] [data-voice-beam-core] {
165
- display: none;
166
- position: absolute;
167
- inset: 0;
168
- border-radius: ${P(A)};
169
- overflow: hidden;
170
- pointer-events: none;
171
- /* Its own compositing layer: WebKit otherwise re-rasterizes the
172
- filtered layer into the parent every frame on the CPU (a phone-sized
173
- host runs at a sixth of the frame rate without this). */
174
- will-change: transform;
175
- /* The blur sits on this wrapper and the band-line clip on the child,
176
- so the cut edge is blurred too rather than left hard. */
177
- filter: blur(${P(Tn(8,m))});
178
- z-index: 4;
179
- }
180
-
181
- [data-voice-beam="${t}"] [data-voice-beam-core] > div {
182
- position: absolute;
183
- inset: 0;
184
- background: radial-gradient(ellipse calc(${M(120*w*i*O)}px * var(--vb-w-${t}) * ${N}) calc((${M(70*T*i*O)}px * var(--vb-h-${t}) + var(--vb-bh-${t})) * ${N}) at ${ve} calc(100% + var(--vb-cy-${t}) * ${N}), white 0%, white ${a}%, rgba(255, 255, 255, ${s}) ${o}%, transparent ${c}%);
185
- clip-path: var(--vb-clip-below-${t}, none);
186
- }
187
-
188
- [data-voice-beam="${t}"][data-active] [data-voice-beam-core],
189
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-core] {
190
- display: block;
191
- opacity: calc(var(--vb-opacity-${t}, 1) * min(1, var(--vb-glow-${t}) * ${Math.min(1,C).toFixed(2)} * ${(1.6+1.4*e).toFixed(2)}) * var(--voice-core-light-opacity, 1));
192
- }
193
- `})():``}
194
- /* Band — the canvas the driver draws the bend's contour on: an organic
195
- bell with chromatic fringes. Fades with the root, follows the strength
196
- and turns with the hue drift like the other layers. */
197
- [data-voice-beam="${t}"] [data-voice-beam-band],
198
- [data-voice-beam="${t}"] [data-voice-beam-band-halo] {
199
- display: none;
200
- position: absolute;
201
- inset: 0;
202
- width: 100%;
203
- height: 100%;
204
- pointer-events: none;
205
- /* Its own compositing layer: WebKit otherwise re-rasterizes the
206
- filtered layer into the parent every frame on the CPU (a phone-sized
207
- host runs at a sixth of the frame rate without this). */
208
- will-change: transform;
209
- z-index: 4;
210
- }
211
-
212
- [data-voice-beam="${t}"][data-active] [data-voice-beam-band],
213
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-band],
214
- [data-voice-beam="${t}"][data-active] [data-voice-beam-band-halo],
215
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-band-halo] {
216
- display: block;
217
- opacity: calc(var(--vb-opacity-${t}, 1) * var(--voice-band-opacity, 1) * var(--voice-strength, 1));
218
- /* The blur vars are 0 where the canvas blurs its own strokes; where the
219
- 2D context has no filter (WebKit) the driver sets them and the layers
220
- are blurred here instead — the ridge on the band canvas, its wider
221
- halo on the canvas beneath. */
222
- filter: blur(var(--vb-band-blur-${t}, 0px)) ${F} brightness(${de}) saturate(${fe});
223
- }
224
-
225
- [data-voice-beam="${t}"][data-active] [data-voice-beam-band-halo],
226
- [data-voice-beam="${t}"][data-fading] [data-voice-beam-band-halo] {
227
- filter: blur(var(--vb-band-halo-blur-${t}, 0px)) ${F} brightness(${de}) saturate(${fe});
228
- }
229
-
230
- /* Resolution. The soft layers — inner light and its warp mirror, bloom and
231
- its mirror, the epicentre — are rastered at half size and scaled back
232
- up by the compositor: the box is halved, every length inside rides the
233
- layer's factor \`--vb-z\` at 0.5 (the driver also writes the band-line
234
- clips at half scale), and the will-change transform is rastered
235
- pre-scale where the engine does that (Chromium, Safari 18). For blurred
236
- gradients that is the same picture at a quarter of the raster and
237
- filter work, which is what a phone at 3x runs out of. The 1px stroke
238
- stays full-res on every screen: at half size it is half a CSS pixel,
239
- which a 3x phone rasters into a faint smear instead of the hairline,
240
- and the layer is cheap (no blur). The component sets
241
- \`data-voice-halfres\`. */
242
- [data-voice-beam="${t}"][data-voice-halfres]::before,
243
- [data-voice-beam="${t}"][data-voice-halfres] [data-voice-beam-warp],
244
- [data-voice-beam="${t}"][data-voice-halfres] [data-voice-beam-bloom],
245
- [data-voice-beam="${t}"][data-voice-halfres] [data-voice-beam-core] {
246
- --vb-z-${t}: 0.5;
247
- inset: auto;
248
- left: 0;
249
- top: 0;
250
- width: 50%;
251
- height: 50%;
252
- transform: translateZ(0) scale(2);
253
- transform-origin: 0 0;
254
- }
255
- ${D?`[data-voice-beam="${t}"][data-voice-halfres][data-active]::before,
256
- [data-voice-beam="${t}"][data-voice-halfres][data-fading]::before,
257
- [data-voice-beam="${t}"][data-voice-halfres][data-active] [data-voice-beam-bloom],
258
- [data-voice-beam="${t}"][data-voice-halfres][data-fading] [data-voice-beam-bloom] {
259
- clip-path: var(--vb-clip-above-z-${t}, inset(0 round ${P(n)}));
260
- }
261
- [data-voice-beam="${t}"][data-voice-halfres][data-active] [data-voice-beam-warp],
262
- [data-voice-beam="${t}"][data-voice-halfres][data-fading] [data-voice-beam-warp] {
263
- clip-path: var(--vb-clip-below-z-${t}, inset(0 round ${P(n)}));
264
- }
265
- /* Processing (warp off): the mirrors are gone, so the base layers paint
266
- the whole box again — this must outweigh the split above. */
267
- [data-voice-beam="${t}"][data-voice-halfres][data-voice-warp="off"]::before,
268
- [data-voice-beam="${t}"][data-voice-halfres][data-voice-warp="off"] [data-voice-beam-bloom] {
269
- clip-path: inset(0 round ${P(n)});
270
- }`:`[data-voice-beam="${t}"][data-voice-halfres][data-active]::before,
271
- [data-voice-beam="${t}"][data-voice-halfres][data-fading]::before,
272
- [data-voice-beam="${t}"][data-voice-halfres][data-active] [data-voice-beam-bloom],
273
- [data-voice-beam="${t}"][data-voice-halfres][data-fading] [data-voice-beam-bloom] {
274
- clip-path: inset(0 round ${P(n)});
275
- }`}
276
- [data-voice-beam="${t}"][data-voice-halfres] [data-voice-beam-core] > div {
277
- clip-path: var(--vb-clip-below-z-${t}, none);
278
- }
279
- @keyframes vb-fade-in-${t} {
280
- to { --vb-opacity-${t}: 1; }
281
- }
282
-
283
- @keyframes vb-fade-out-${t} {
284
- from { --vb-opacity-${t}: 1; }
285
- to { --vb-opacity-${t}: 0; }
286
- }
287
-
288
- [data-voice-beam="${t}"][data-paused],
289
- [data-voice-beam="${t}"][data-paused]::after,
290
- [data-voice-beam="${t}"][data-paused]::before,
291
- [data-voice-beam="${t}"][data-paused] [data-voice-beam-bloom] {
292
- animation-play-state: paused !important;
293
- }
294
- `}let kn=null;function An(){if(typeof window>`u`)return null;let e=window;return e.AudioContext??e.webkitAudioContext??null}function jn(){let e=An();return e?(kn||=new e,kn.state===`suspended`&&kn.resume().catch(()=>{}),kn):null}const Mn=new WeakMap;function Nn(e){let t=jn();if(!t||e.getAudioTracks().length===0)return null;let n=Mn.get(e);n||(n={node:t.createMediaStreamSource(e),refs:0},Mn.set(e,n)),n.refs+=1;let r=t.createAnalyser();r.fftSize=1024,r.smoothingTimeConstant=.5,n.node.connect(r);let i=!1;return{analyser:r,release:()=>{if(!i){i=!0;try{n.node.disconnect(r)}catch{}if(--n.refs,n.refs<=0){try{n.node.disconnect()}catch{}Mn.delete(e)}}}}}const Pn=new WeakMap;function Fn(e){let t=Pn.get(e);return t||(t={level:0,bands:[0,0,0],phase:0,scanA:0,scanT:0,t:0,lastTs:0,warp:1},Pn.set(e,t)),t}const In=new Set;let Ln=null,Rn=0,zn=0,Bn=!1,Vn=!1,Hn=0,Un=0;const Wn=Math.PI*2,Gn=[[80,300],[300,2e3],[2e3,6e3]];function Kn(e){return e<0?0:e>1?1:e}function qn(e,t){let n=t/2;return((e+n)%t+t)%t-n}function Jn(e,t){let n=e/(t/2+4);return Math.max(0,1-n*n)}function Yn(e,t){if(e<=t)return 0;let n=(e-t)/Math.max(.001,1-t);return Kn((1-Math.exp(-3*n))/(1-Math.exp(-3)))}function Xn(e,t,n,r,i){let a=t>e?r:i,o=1-Math.exp(-n/Math.max(.001,a));return e+(t-e)*o}const Zn=!(typeof navigator<`u`&&/AppleWebKit/.test(navigator.userAgent)&&!/Chrome\/|Chromium\/|Edg\/|OPR\//.test(navigator.userAgent)),Qn=.05,$n=.1;function er(e,t,n,r){let i=e<0?1-r:1+r,a=Math.max(.05,n*i),o=Math.exp(-((Math.abs(e)/a)**+t)),s=Math.exp(-((1/a)**t));return Math.max(0,(o-s)/(1-s))}function tr(e,t,n,r,i){if(n<=0||t<=0)return 0;let a=t*Math.max(0,Math.min(.98,r));return e<=a?0:n*Math.min(1,(e-a)/Math.max(1,t-a))**+Math.max(.5,i)}function nr(e,t,n){return Math.max(0,Math.min(e,t/2,n/2))}function rr(e,t,n,r=0){if(n<=0)return 0;let i=Math.min(e,t-e)-r;if(i>=n)return 0;if(i<=0)return n;let a=n-i;return n-Math.sqrt(Math.max(0,n*n-a*a))}function ir(e,t,n,r){let i=n/2+t.cx*t.w,a=170*e.rangeWidth*t.w*t.mw,o=r*.82*Math.min(1,e.scale),s=Math.min(o,(64*e.rangeHeight*t.h+t.lift)*e.bandPosition),c=r-e.bandOffset,l=Math.min(1,t.corner*4),u=e.bandTail*(1-l*l*(3-2*l)),d=u>.001,f=d?e.bandTailOverflow:0,p=d?-f:i-a,m=d?n+f:i+a,h=[];for(let o=0;o<=56;o++){let l=p+(m-p)*o/56,d=Math.max(-1,Math.min(1,(l-i)/Math.max(1,a))),g=(l<i?i:n-i)+f,_=er(d,e.bandCurve,e.bandSpread,e.bandSkew)+tr(Math.abs(l-i),g,u,e.bandTailPosition,e.bandTailCurve),v=t.corner>0?rr(l,n,nr(e.radius,n,r))*t.corner:0;h.push([l,c-s*_-v])}return h}function ar(e,t,n,r,i){for(let[a,o]of[[``,1],[`-z`,.5]]){let s=e=>(e*o).toFixed(1)+`px`,c=n.map(([e,t])=>`${s(e)} ${s(t)}`),l=`polygon(0 ${s(i)}, ${c.join(`, `)}, ${s(r)} ${s(i)})`,u=`polygon(0 0, ${s(r)} 0, ${s(r)} ${s(i)}, ${c.slice().reverse().join(`, `)}, 0 ${s(i)})`;e.style.setProperty(`--vb-clip-below${a}-${t}`,l),e.style.setProperty(`--vb-clip-above${a}-${t}`,u)}}function or(e,t,n){let r=n;for(let e=0;e<t.length;e++)t[e][1]<r&&(r=t[e][1]);let i=Math.max(0,Math.min(.9,Math.floor((r-6)/n/Qn)*Qn));if(i===e.filterTop)return;e.filterTop=i;let a=1+Math.max(.1,12/n),o=e.filter;o.setAttribute(`x`,`${-$n*100}%`),o.setAttribute(`width`,`${(1+2*$n)*100}%`),o.setAttribute(`y`,`${(i*100).toFixed(0)}%`),o.setAttribute(`height`,`${((a-i)*100).toFixed(1)}%`)}function sr(e,t,n){let{canvas:r,ctx:i,el:a,config:o}=e;if(!r||!i)return;let s=a.clientWidth,c=a.clientHeight;if(!s||!c)return;let l=Math.min(2,typeof window<`u`&&window.devicePixelRatio||1),u=Math.round(s*l),d=Math.round(c*l);(r.width!==u||r.height!==d)&&(r.width=u,r.height=d),i.setTransform(l,0,0,l,0,0),i.clearRect(0,0,s,c);let f=e.haloCanvas,p=e.haloCtx;f&&p&&((f.width!==u||f.height!==d)&&(f.width=u,f.height=d),p.setTransform(l,0,0,l,0,0),p.clearRect(0,0,s,c));let m=Math.min(1,.6*o.bandStrength*t.strength);if(m<.005||o.bandWidth<=0)return;let h=o.theme===`dark`,g=o.bandWidth*(1+.35*t.level),_=o.bandAberration*(.35+.65*t.level),v=(4+12*_)*o.scale,y=4*_*o.scale,b=(e,t)=>{i.beginPath(),i.moveTo(n[0][0]+e,n[0][1]+t);for(let r=1;r<n.length;r++)i.lineTo(n[r][0]+e,n[r][1]+t)},x={r:o.bandColors.above,g:o.bandColors.mid,c:o.bandColors.core,b:o.bandColors.below},S=(h?.42:.4)*m,C=14*g,w=3.5*o.bandWidth/2,T=w*l,E=typeof i.filter==`string`,ee=E?`0px`:`${w.toFixed(2)}px`;e.cssBlur!==ee&&(a.style.setProperty(`--vb-band-blur-${o.id}`,ee),a.style.setProperty(`--vb-band-halo-blur-${o.id}`,E?`0px`:`${(w*3).toFixed(2)}px`),e.cssBlur=ee);let te=[[1,.16],[.72,.2],[.46,.26],[.22,.34]],D=[{rgb:x.r,a:1,ox:y,oy:-v},{rgb:x.g,a:.55,ox:y*.35,oy:-v*.35},{rgb:x.b,a:1,ox:-y,oy:v},{rgb:x.c,a:.9,ox:0,oy:0}];i.lineCap=`round`,i.lineJoin=`round`,i.globalCompositeOperation=`source-over`;let O=n[0][0],k=n[n.length-1][0],ne=(e,t)=>{let n=i.createLinearGradient(O,0,k,0),r=o.bandTail>0?.015:.18;return n.addColorStop(0,`rgba(${e}, 0)`),n.addColorStop(r,`rgba(${e}, ${t.toFixed(3)})`),n.addColorStop(1-r,`rgba(${e}, ${t.toFixed(3)})`),n.addColorStop(1,`rgba(${e}, 0)`),n},A=!E&&p?p:i;E&&(i.filter=`blur(${(T*3).toFixed(1)}px)`),A.lineCap=`round`,A.lineJoin=`round`,A.strokeStyle=ne(x.c,S*.3),A.lineWidth=C*2.2,A.beginPath(),A.moveTo(n[0][0],n[0][1]);for(let e=1;e<n.length;e++)A.lineTo(n[e][0],n[e][1]);A.stroke(),E&&(i.filter=`blur(${T.toFixed(1)}px)`);for(let e of D)for(let[t,n]of te)i.strokeStyle=ne(e.rgb,S*e.a*n),i.lineWidth=Math.max(.6,C*t),b(e.ox,e.oy),i.stroke();E&&(i.filter=`none`),i.globalCompositeOperation=`source-over`}function cr(e){return(1-Math.cos(Wn*e))/2}function lr(e,t){let n=e.analyser,r=e.time,i=e.freq;n.getFloatTimeDomainData(r);let a=0;for(let e=0;e<r.length;e++)a+=r[e]*r[e];t.level=Math.sqrt(a/r.length)*5*e.config.sensitivity,n.getByteFrequencyData(i);let o=n.context.sampleRate/n.fftSize;for(let n=0;n<3;n++){let[r,a]=Gn[n],s=Math.max(0,Math.floor(r/o)),c=Math.min(i.length-1,Math.ceil(a/o)),l=0;for(let e=s;e<=c;e++)l+=i[e];let u=c>=s?l/(c-s+1)/255:0;t.bands[n]=u*1.7*e.config.sensitivity}}const ur={level:0,bands:[0,0,0]};function dr(e){Ln=requestAnimationFrame(dr);let t=zn?e-zn:0;if(zn=e,Bn){if(Vn=!Vn,Vn)return;e>=Un&&(Bn=!1,Hn=0)}else t>22?Hn?e-Hn>500&&(Bn=!0,Vn=!1,Un=e+4e3):Hn=e:Hn=0;e-Rn<14.666666666666668||(Rn=e,In.forEach(t=>{var n;let{el:r,config:i,source:a,s:o}=t,s=i.paused;if(s&&t.paintedConfig===i)return;let c=s?0:o.lastTs?Math.min(.05,(e-o.lastTs)/1e3):1/60;o.lastTs=e,o.t+=c;let l=o.t;if(!s)if(t.analyser)lr(t,ur);else{let e=a.getLevel?Kn(a.getLevel()):0;ur.level=e,ur.bands[0]=e,ur.bands[1]=e*(.72+.28*Math.sin(l*9.1)),ur.bands[2]=e*(.6+.4*Math.sin(l*13.7+2))}let u=Yn(ur.level,i.threshold);o.level=Xn(o.level,u,c,i.attack,i.release);for(let e=0;e<3;e++){let t=Yn(ur.bands[e],i.threshold*.6);o.bands[e]=Xn(o.bands[e],t,c,i.attack,i.release*1.15)}let d=Sn*i.lobeSpacing;i.processing&&o.scanA<.001&&o.scanT===0&&(o.scanT=Math.max(.05,i.processingDuration)/2);let f=Math.max(.05,i.processingEase);o.scanA=Xn(o.scanA,i.processing?1:0,c,f*.9,f*.8),i.processing?o.scanT+=c:o.scanA<.001&&(o.scanT=0);let p=o.scanA*o.scanA*(3-2*o.scanA),m=r.clientWidth,h=r.clientHeight,g=d/2*i.processingTravel,_=o.scanT/Math.max(.05,i.processingDuration),v=Math.floor(_),y=_-v,b=Math.max(1,i.processingCurve),x=y<.5?.5*(2*y)**b:1-.5*(2-2*y)**b,S=i.reducedMotion?0:v%2==0?2*x-1:1-2*x,C=p*g*S,w=1-p*.6,T=1-p*.45,E=1+p*.3*(1-S*S),ee=i.reducedMotion?.5:.5+.5*Math.sin(Wn*l/i.breatheDuration),te=o.level+(1-o.level)*i.idle*ee,D=Math.max(0,Math.min(1,(p-.25)/.75)),O=D*D*(3-2*D),k=Math.max(te,i.processingLevel*O),ne=.15+.85*k,A=.5+i.reach*k,j=(.85+i.spread*k)*E;i.flow!==0&&!i.reducedMotion&&(o.phase=((o.phase+i.flow*k*c)%d+d)%d),r.style.setProperty(`--vb-level-${i.id}`,o.level.toFixed(3)),r.style.setProperty(`--vb-cx-${i.id}`,`${C.toFixed(1)}px`),r.style.setProperty(`--vb-mw-${i.id}`,T.toFixed(3));let re=i.bend*k;r.style.setProperty(`--vb-bh-${i.id}`,`${Math.max(0,re).toFixed(1)}px`);let ie=i.bend>0?Math.min(1,re/i.bend):0;r.style.setProperty(`--vb-bendA-${i.id}`,ie.toFixed(3));let M={cx:C,w:j,h:A,mw:T,lift:re,strength:ie,level:o.level,corner:p},N=m/2+C*j,P=30*i.scale*j,ae=nr(i.radius,m,h),oe=p*i.cornerFollow;r.style.setProperty(`--vb-cy-${i.id}`,`${(-rr(N,m,ae,P*1.4)*oe).toFixed(1)}px`),o.warp=Xn(o.warp,i.processing?0:1,c,.35,.06);let se=o.warp,ce=t.displace!=null&&se<.03;if(ce!==t.warpOff&&(t.warpOff=ce,ce?r.setAttribute(`data-voice-warp`,`off`):r.removeAttribute(`data-voice-warp`)),m&&h&&(t.ctx||t.displace)){let e=ir(i,M,m,h);(t.displace&&!ce||i.coreLight>0)&&ar(r,i.id,e,m,h),t.filter&&!ce&&Zn&&or(t,e,h),t.ctx&&sr(t,M,e)}if(t.displace&&!ce){let e=i.reducedMotion?0:i.distortion*120*i.scale*(.15+.85*k)*se;t.displace.scale.baseVal=e,t.noiseShift&&(t.noiseShift.dx.baseVal=8*i.scale*Math.sin(l*.9),t.noiseShift.dy.baseVal=4*i.scale*Math.sin(l*.6+1.3))}r.style.setProperty(`--vb-glow-${i.id}`,ne.toFixed(3)),r.style.setProperty(`--vb-h-${i.id}`,A.toFixed(3)),r.style.setProperty(`--vb-w-${i.id}`,j.toFixed(3));for(let e=0;e<xn.length;e++){let t=xn[e],n=qn(t.x*i.lobeSpacing+o.phase,d),a=i.bands?.6+.7*o.bands[t.band]:1;r.style.setProperty(`--vb-x${e}-${i.id}`,`${(n*w).toFixed(1)}px`),r.style.setProperty(`--vb-l${e}-${i.id}`,(a*Jn(n,d)).toFixed(3));let s=m/2+(C+n*w)*j;r.style.setProperty(`--vb-y${e}-${i.id}`,`${(-rr(s,m,ae,P)*oe).toFixed(1)}px`)}let le=i.staticColors||i.reducedMotion||i.hueRange===0?0:-i.hueRange+2*i.hueRange*cr(l/i.hueDuration);r.style.setProperty(`--vb-hue-${i.id}`,`${le.toFixed(2)}deg`),(n=t.onLevel)==null||n.call(t,o.level),t.paintedConfig=i}))}function fr(){Ln??=(Rn=0,zn=0,Hn=0,requestAnimationFrame(dr))}function pr(){In.size===0&&Ln!=null&&(cancelAnimationFrame(Ln),Ln=null)}function mr(e,t,n,r){let i={el:e,config:t,source:n,onLevel:r,analyser:null,releaseAnalyser:null,time:null,freq:null,canvas:null,ctx:null,haloCanvas:null,haloCtx:null,displace:null,noiseShift:null,filter:null,filterTop:-1,s:Fn(e),paintedConfig:null,cssBlur:null,warpOff:e.hasAttribute(`data-voice-warp`)};t.distortion>0&&(i.displace=e.querySelector(`:scope > svg feDisplacementMap`),i.noiseShift=e.querySelector(`:scope > svg feOffset`),i.filter=e.querySelector(`:scope > svg filter`));let a=e.querySelector(`:scope > [data-voice-beam-band]`);if(a){i.canvas=a,i.ctx=a.getContext(`2d`);let t=e.querySelector(`:scope > [data-voice-beam-band-halo]`);t&&(i.haloCanvas=t,i.haloCtx=t.getContext(`2d`))}if(i.s.lastTs=0,n.stream){let e=Nn(n.stream);e&&(i.analyser=e.analyser,i.releaseAnalyser=e.release,i.time=new Float32Array(e.analyser.fftSize),i.freq=new Uint8Array(e.analyser.frequencyBinCount))}return In.add(i),fr(),()=>{var e;In.delete(i),(e=i.releaseAnalyser)==null||e.call(i),pr()}}const hr={scale:1,glowSize:1,processingDuration:1.1,processingLevel:.55,processingTravel:1.55,processingCurve:2.1,cornerFollow:.45,strokeOpacity:1,innerOpacity:1,bloomOpacity:1,idle:.18,reach:1.2,spread:1.05,flow:48,bend:60,bandStrength:1.55,bandWidth:2.15,bandPosition:.35,bandCurve:1.75,bandSpread:.87,bandSkew:.12,bandOffset:-27,bandTail:.59,bandTailPosition:.67,bandTailCurve:2.4,bandTailOverflow:15,bandAberration:.89,distortion:.62,distortionDetail:2.3,glowWidth:.65,glowHeight:1.25,lobeSpacing:.85,rangeWidth:.75,rangeHeight:1,softness:1.07,coreSize:1,coreLight:0,coreLightWidth:1,coreLightHeight:1,strokeScale:1,innerScale:1,innerHeight:1,bloomScale:1,bloomHeight:1},gr={default:{},pill:{scale:.45,glowSize:.95,strokeOpacity:1.2,innerOpacity:.85,reach:1.35,spread:1.1,flow:0,bend:23,bandStrength:1.55,bandWidth:1.85,bandCurve:1.95,bandSpread:.38,bandOffset:-16,bandTail:0,processingTravel:2,cornerFollow:0,distortion:.45,distortionDetail:3,glowWidth:.65,glowHeight:.95,lobeSpacing:.45,rangeWidth:.8,rangeHeight:.7,softness:.88,coreSize:.25,strokeScale:1.25,innerScale:.95,bloomScale:1.05,bloomHeight:2.25},mobile:{scale:1.25,spread:.45,reach:3,flow:60,bend:70,bandWidth:2.4,bandCurve:1.55,bandSpread:.9,bandOffset:-50,bandTail:.62,bandTailPosition:.42,bandTailCurve:2.7,bandTailOverflow:22,processingDuration:1.05,processingLevel:.35,processingTravel:1,cornerFollow:.4,bandStrength:1.8,distortionDetail:2,glowWidth:1.15,glowHeight:2.1,lobeSpacing:1.35,rangeWidth:1.25,rangeHeight:1.2,softness:1.1}},_r={default:{brightness:1.15},pill:{brightness:1.35,saturation:1.5},mobile:{strength:1,brightness:1.2,saturation:1.5}},vr={default:{},pill:{},mobile:{strength:1}};function yr(e=`default`,t=`dark`){return(t===`light`?vr[e]:void 0)??_r[e]}const br={default:{bandStrength:1.7},pill:{bandStrength:2},mobile:{bandStrength:1.7}};function xr(e=`default`,t=`dark`){let n=gr[e],r={};return t===`light`&&(n.reach===void 0&&(r.reach=1.8),n.spread===void 0&&(r.spread=.8),n.coreLight===void 0&&(r.coreLight=1.8)),{...hr,...r,...n,...t===`light`?br[e]:void 0}}const Sr={dark:{core:`255, 255, 255`,above:`255, 70, 80`,mid:`90, 255, 150`,below:`80, 140, 255`},light:{core:`197, 139, 255`,above:`255, 122, 182`,mid:`126, 196, 255`,below:`45, 255, 171`}},Cr=typeof navigator<`u`&&/AppleWebKit/.test(navigator.userAgent)&&!/Chrome\/|Chromium\/|Edg\/|OPR\//.test(navigator.userAgent),wr=(()=>{if(typeof document>`u`)return!0;let e=document.createElement(`canvas`).getContext(`2d`);return!!e&&typeof e.filter==`string`})();function Tr(){let[e,t]=jt(()=>typeof window>`u`||window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return Nt(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=e=>t(e.matches?`dark`:`light`);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function Er(){let[e,t]=jt(()=>typeof window>`u`||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches);return Nt(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function Dr(e,t){return e===`auto`?t:e}const Or=Yt(function({children:e,type:t=`default`,scale:n,stream:r=null,level:i=0,sensitivity:a=3.1,threshold:o=.015,attack:s=.325,release:c=.86,idle:l,breatheDuration:u=5.2,reach:d,spread:f,bands:p=!0,flow:m,processing:h=!1,processingDuration:g,processingLevel:_,processingTravel:v,processingCurve:y,cornerFollow:b,processingEase:x=.6,colorVariant:S=`colorful`,colors:C,bandColors:w,theme:T=`dark`,staticColors:E=!1,hueRange:ee,hueDuration:te,active:D=!0,paused:O=!1,borderRadius:k,brightness:ne,saturation:A,glowSize:j,strokeOpacity:re,innerOpacity:ie,bloomOpacity:M,bend:N,bandStrength:P,bandWidth:ae,bandPosition:oe,bandCurve:se,bandSpread:ce,bandSkew:le,bandOffset:ue,bandTail:de,bandTailPosition:fe,bandTailCurve:F,bandTailOverflow:pe,bandAberration:me,distortion:he,distortionDetail:ge,glowWidth:_e,glowHeight:ve,lobeSpacing:ye,rangeWidth:be,rangeHeight:xe,softness:Se,coreSize:Ce,coreLight:we,coreLightWidth:I,coreLightHeight:Te,strokeScale:Ee,innerScale:De,innerHeight:Oe,bloomScale:ke,bloomHeight:Ae,strength:je,className:Me,style:Ne,css:Pe,onLevel:Fe,onActivate:L,onDeactivate:Ie,onAnimationEnd:R,...Le},Re){let z=Lt().replace(/:/g,`-`),B=Dr(T,Tr()),ze=C?C.join(`|`):``,Be=w?[w.core,w.above,w.mid,w.below].join(`|`):``,V=xr(t,B),H=Math.max(.05,n??V.scale),Ve=j??V.glowSize,He=re??V.strokeOpacity,Ue=ie??V.innerOpacity,We=M??V.bloomOpacity,Ge=g??V.processingDuration,Ke=_??V.processingLevel,U=v??V.processingTravel,qe=y??V.processingCurve,Je=b??V.cornerFollow,Ye=l??V.idle,W=d??V.reach,Ze=f??V.spread,Qe=(m??V.flow)*H,$e=(N??V.bend)*H,et=P??V.bandStrength,tt=(ae??V.bandWidth)*H,nt=oe??V.bandPosition,rt=se??V.bandCurve,it=ce??V.bandSpread,at=le??V.bandSkew,ot=(ue??V.bandOffset)*H,st=de??V.bandTail,ct=fe??V.bandTailPosition,lt=F??V.bandTailCurve,ut=(pe??V.bandTailOverflow)*H,dt=me??V.bandAberration,ft=he??V.distortion,pt=(ge??V.distortionDetail)/H,mt=(_e??V.glowWidth)*H,ht=(ve??V.glowHeight)*H,gt=(ye??V.lobeSpacing)*H,_t=(be??V.rangeWidth)*H,vt=(xe??V.rangeHeight)*H,yt=Se??V.softness,G=(Ce??V.coreSize)*H,bt=Math.max(0,Math.min(3,we??V.coreLight)),xt=I??V.coreLightWidth,St=Te??V.coreLightHeight,Ct=Ee??V.strokeScale,K=De??V.innerScale,wt=Oe??V.innerHeight,Tt=ke??V.bloomScale,Et=Ae??V.bloomHeight,Dt=Er(),Ot=Pt(null),[kt,At]=jt(D),[Mt,Rt]=jt(!1),[zt,Bt]=jt(!0),[Vt,Ht]=jt(null),[Ut,Wt]=jt(0);Nt(()=>{if(!Cr)return;let e=Ot.current;if(!e)return;let t=()=>Wt(e.clientWidth*e.clientHeight);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let Gt=Cr&&Ut>6e4?0:ft;Nt(()=>{if(k!=null)return;let e=Ot.current;if(!e)return;let t=()=>{let t=e.firstElementChild;if(!t)return;let n=getComputedStyle(t),r=parseFloat(n.borderTopLeftRadius);!isNaN(r)&&r>0&&Ht(r)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!1}),()=>n.disconnect()},[k,e]),Nt(()=>{D&&!kt&&!Mt?At(!0):!D&&kt&&!Mt&&Rt(!0)},[D,kt,Mt]),Nt(()=>{let e=Ot.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{for(let t of e)Bt(t.isIntersecting)},{rootMargin:`256px`});return t.observe(e),()=>t.disconnect()},[]);let Kt=It(e=>{let t=e.animationName;t.includes(`fade-out`)?(At(!1),Rt(!1),Ie?.()):t.includes(`fade-in`)&&L?.(),R?.(e)},[L,Ie,R]),q=bn[B],qt=k??Vt??16,Jt=yr(t,B),Yt=je??Jt.strength??q.strength??1,Xt=ee??q.hueRange??24,Zt=te??q.hueDuration??12,Qt=ne??Jt.brightness??q.brightness,$t=A??Jt.saturation??q.saturation,en=Ft(()=>On({id:z,borderRadius:qt,borderWidth:1,strokeOpacity:q.strokeOpacity*He,innerOpacity:q.innerOpacity*Ue,bloomOpacity:q.bloomOpacity*We,innerShadow:q.innerShadow,colorVariant:S,colors:C,brightness:Qt,saturation:$t,theme:B,hueBase:q.hueBase??0,glowSize:Ve*H,glowWidth:mt,glowHeight:ht,strokeScale:Ct,innerScale:K,innerHeight:wt,bloomScale:Tt,bloomHeight:Et,coreSize:G,coreLight:bt,coreLightWidth:xt,coreLightHeight:St,rangeWidth:_t,rangeHeight:vt,softness:yt,distortion:Gt>0,scale:H}),[z,qt,q,S,ze,Qt,$t,B,V,Ve,He,Ue,We,H,mt,ht,Ct,K,wt,Tt,Et,G,bt,xt,St,_t,vt,yt,Gt>0]),tn=Ft(()=>({id:z,sensitivity:Math.max(0,a),threshold:Math.max(0,Math.min(.95,o)),attack:Math.max(0,s),release:Math.max(0,c),idle:Math.max(0,Math.min(1,Ye)),breatheDuration:Math.max(.2,u),reach:Math.max(0,W),spread:Math.max(0,Ze),bands:p,flow:Qe,lobeSpacing:Math.max(.1,gt),bend:Math.max(0,$e),bandStrength:Math.max(0,et),bandWidth:Math.max(0,tt),bandPosition:Math.max(0,nt),bandCurve:Math.max(.3,rt),bandSpread:Math.max(.05,it),bandSkew:Math.max(-.9,Math.min(.9,at)),bandOffset:ot,bandTail:Math.max(0,Math.min(1.5,st)),bandTailPosition:Math.max(0,Math.min(.98,ct)),bandTailCurve:Math.max(.5,lt),bandTailOverflow:Math.max(0,ut),bandAberration:Math.max(0,Math.min(1,dt)),rangeWidth:_t,rangeHeight:vt,theme:B,bandColors:{core:w?.core&&yn(w.core)||Sr[B].core,above:w?.above&&yn(w.above)||Sr[B].above,mid:w?.mid&&yn(w.mid)||Sr[B].mid,below:w?.below&&yn(w.below)||Sr[B].below},distortion:Math.max(0,Math.min(1,Gt)),coreLight:bt,scale:H,radius:qt,processing:h,processingDuration:Math.max(.05,Ge),processingLevel:Math.max(0,Math.min(1,Ke)),processingEase:Math.max(.05,x),processingTravel:Math.max(0,U),processingCurve:Math.max(1,qe),cornerFollow:Math.max(0,Math.min(1,Je)),hueRange:Math.max(0,Xt),hueDuration:Math.max(.5,Zt),staticColors:S===`mono`?!0:E,reducedMotion:Dt,paused:O}),[z,a,o,s,c,Ye,u,W,Ze,p,Qe,gt,$e,et,tt,nt,rt,it,at,ot,st,ct,lt,ut,dt,_t,vt,B,Be,Gt,bt,H,qt,h,Ge,Ke,x,U,qe,Je,Xt,Zt,E,S,Dt,O]),nn=Pt(i);nn.current=i;let rn=Pt(Fe);rn.current=Fe,Nt(()=>{if(!(kt||Mt)||!zt)return;let e=Ot.current;return e?mr(e,tn,{stream:r,getLevel:()=>{let e=nn.current;return typeof e==`function`?e():e}},e=>rn.current?.call(rn,e)):void 0},[tn,r,kt,Mt,zt]);let an=It(e=>{Ot.current=e,typeof Re==`function`?Re(e):Re&&(Re.current=e)},[Re]),on={...Ne??{},"--voice-strength":Math.max(0,Math.min(1,Yt))};return J(Xe,{children:[J(`style`,{children:Pe?`${en}
295
- ${Pe.split(`{id}`).join(z)}`:en}),J(`div`,{...Le,ref:an,"data-voice-beam":z,"data-voice-type":t,"data-voice-halfres":``,"data-active":kt&&!Mt?``:void 0,"data-fading":Mt?``:void 0,"data-paused":kt&&!Mt&&(!zt||O)?``:void 0,"data-listening":r?``:void 0,"data-processing":h?``:void 0,className:Me,style:on,onAnimationEnd:Kt,children:[e,J(`div`,{"data-voice-beam-bloom":!0}),Gt>0&&J(Xe,{children:[J(`div`,{"data-voice-beam-warp":`inner`}),J(`div`,{"data-voice-beam-warp":`bloom`})]}),!wr&&J(`canvas`,{"data-voice-beam-band-halo":!0,"aria-hidden":`true`}),J(`canvas`,{"data-voice-beam-band":!0,"aria-hidden":`true`}),bt>0&&J(`div`,{"data-voice-beam-core":!0,children:J(`div`,{})}),Gt>0&&J(`svg`,{"aria-hidden":`true`,width:`0`,height:`0`,style:{position:`absolute`,pointerEvents:`none`},children:J(`filter`,{id:`vb-distort-${z}`,x:`-20%`,y:`-20%`,width:`140%`,height:`140%`,colorInterpolationFilters:`sRGB`,children:[J(`feTurbulence`,{type:`fractalNoise`,baseFrequency:`${(.012*pt).toFixed(4)} ${(.05*pt).toFixed(4)}`,numOctaves:2,seed:7,result:`noise`}),J(`feOffset`,{in:`noise`,dx:`0`,dy:`0`,result:`moved`}),J(`feColorMatrix`,{in:`moved`,type:`matrix`,values:`1 0 0 0 0 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 1`,result:`map`}),J(`feDisplacementMap`,{in:`SourceGraphic`,in2:`map`,scale:0,xChannelSelector:`R`,yChannelSelector:`G`})]})})]})]})}),kr=`http://www.w3.org/2000/svg`,Y=Math.PI*2,X=21.5,Ar=Math.sqrt(12)*X,jr=154-Ar,Z=Gr(),Mr=jr+Z.length,Nr=.56*Y*X/2,Pr=.75,Fr=.35,Ir=.55,Lr=22.5,Rr=Jr(.65,0,.35,1),zr=Jr(.4,0,.2,1),Br=Jr(.34,1.56,.64,1),Vr=Jr(.2,0,0,1);var Hr=class{element;lines=[];ripple;track;middle;top;bottom;seal;check;motion=matchMedia(`(prefers-reduced-motion: reduce)`);phase=`idle`;stage={kind:`line`};settleSuccess=null;successBegun=null;frame=0;previousTime=0;position=0;target=0;level=0;stopped=!1;constructor(e,t=`ring`){this.checking=t,this.element=e.createElementNS(kr,`svg`),this.element.classList.add(`seams-voiceid-ribbon`),this.element.setAttribute(`viewBox`,`0 0 308 64`),this.element.setAttribute(`aria-hidden`,`true`),this.ripple=this.append(e,`circle`,`1.5`),this.track=this.append(e,`circle`,`2`),this.middle=this.append(e,`path`,`1`),this.top=this.append(e,`path`,`2`),this.bottom=this.append(e,`path`,`2`),this.seal=this.append(e,`circle`,`0`),this.seal.setAttribute(`fill`,`currentColor`),this.seal.setAttribute(`stroke`,`none`),this.check=this.append(e,`path`,`2.6`),this.check.classList.add(`seams-voiceid-ribbon-check`),this.check.setAttribute(`d`,`M161 26.8 151.4 36.3 147.1 32`),this.check.setAttribute(`stroke-linejoin`,`round`),this.check.setAttribute(`pathLength`,`1`),this.check.setAttribute(`stroke-dasharray`,`1`);for(let e of[this.ripple,this.track,this.seal])e.setAttribute(`cx`,`154`),e.setAttribute(`cy`,`32`);if(this.track.setAttribute(`r`,`21.5`),t===`segments`){this.element.dataset.seamsProgressLine=``;for(let[e,t]of[this.top,this.middle,this.bottom].entries())t.dataset.seamsProgressSegment=String(e)}for(let t=3;t>=0;--t)this.lines.push(this.append(e,`path`,t===0?`1`:`0.65`));this.paint(performance.now())}readLevel=()=>this.level;setPhase(e){if(e===`processing`&&this.stage.kind===`line`){let e=Math.max(this.level,this.idleAmplitude(performance.now()));this.stage={kind:this.checking===`segments`?`segments`:`capture`,startedAt:performance.now(),amplitude:e}}else e!==`processing`&&(this.stage={kind:`line`},this.settle());this.phase=e,this.target=0,this.element.dataset.phase=e,this.wake()}succeed(e){if(this.stopped||this.stage.kind===`sealed`)return Promise.resolve();this.stage.kind===`line`&&this.setPhase(`processing`);let t=new Promise(this.awaitSuccess);return this.successBegun=e,this.stage.kind===`spin`&&this.beginSuccess(performance.now()),this.wake(),t}add(e){if(this.phase!==`listening`||this.stopped)return;let t=Math.max(0,e.rms-.003);this.target=(t/(t+.055))**.65*(e.speech?1:.15),this.element.dataset.speech=String(e.speech),this.wake()}dispose(){this.stopped=!0,cancelAnimationFrame(this.frame),this.frame=0,this.level=0,this.target=0,this.settle()}awaitSuccess=e=>{this.settle(),this.settleSuccess=e};settle(){let e=this.settleSuccess;this.settleSuccess=null,this.successBegun=null,e?.()}append(e,t,n){let r=e.createElementNS(kr,t);return r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,n),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`vector-effect`,`non-scaling-stroke`),r.setAttribute(`opacity`,`0`),this.element.append(r),r}wake(){!this.stopped&&this.frame===0&&(this.previousTime=performance.now(),this.frame=requestAnimationFrame(this.draw))}draw=e=>{if(this.frame=0,this.stopped)return;let t=Math.min(50,Math.max(0,e-this.previousTime));this.previousTime=e,this.level+=(this.target-this.level)*(1-Math.exp(-t/(this.target>this.level?55:200))),this.motion.matches||(this.position+=t*(.0012+this.level*.003)),this.paint(e),!this.element.isConnected||this.stage.kind===`sealed`||this.stage.kind===`line`&&this.phase===`idle`&&this.level<=.001||(this.frame=requestAnimationFrame(this.draw))};idleAmplitude(e){return this.phase!==`listening`||this.motion.matches?0:.085*(.72+.28*Math.sin(e/2600*Y))}paint(e){for(let e of[this.ripple,this.track,this.middle,this.top,this.bottom,this.seal,this.check])e.setAttribute(`opacity`,`0`);for(let e of this.lines)e.setAttribute(`opacity`,`0`);switch(this.stage.kind){case`line`:this.paintLine(Math.max(this.level,this.idleAmplitude(e)));return;case`capture`:this.paintCapture(e,this.stage);return;case`segments`:this.paintSegments(e,this.stage);return;case`spin`:this.paintArc(this.spinnerArc(e,this.stage),1);return;case`success`:this.paintSuccess(e,this.stage);return;case`sealed`:this.paintSeal({start:0,sweep:Y},1,1);return}}paintLine(e){for(let t=0;t<this.lines.length;t+=1){let n=3-t;this.lines[t].setAttribute(`d`,this.linePath(n,e,0,308,1)),this.lines[t].setAttribute(`opacity`,String(n===0?Ir+e*.4:.1+e*.1))}}paintSegments(e,t){let n=e-t.startedAt;if(!this.motion.matches&&n<200){this.paintLine(t.amplitude*(1-Vr(n/200)));return}let r=n-200,i=8*(this.motion.matches?1:Vr(Q(r/200))),a=(308-2*i)/3;for(let[e,t]of[this.top,this.middle,this.bottom].entries()){let n=e*(a+i);t.setAttribute(`d`,`M${n.toFixed(2)} 32H${(n+a).toFixed(2)}`),t.setAttribute(`stroke-width`,`1`),t.setAttribute(`opacity`,this.segmentOpacity(r,e))}}segmentOpacity(e,t){if(this.motion.matches)return`0.8`;let n=.5+.5*Math.cos(Y*(e-t*150)/900);return $(Ir,Fr+(1-Fr)*n,Vr(Q(e/200))).toFixed(3)}paintCapture(e,t){let n=this.motion.matches?920:e-t.startedAt;if(n>=560){this.paintJoin(e,Math.min(n-560,360));return}let r=t.amplitude,i=n/560,a=1-Vr(Q(n/150)),o=Rr(Q(i/.6)),s=Ur(!1)*X*560,c=qr(i,Mr,s),l=jr+qr(i,Mr+Nr-jr,s),u=Ir+r*.4;for(let[e,t]of[[this.top,!1],[this.bottom,!0]])e.setAttribute(`d`,this.halfPath(c,l,t,r,a)),e.setAttribute(`stroke-width`,$(1,2,o).toFixed(2)),e.setAttribute(`opacity`,$(u,1,o).toFixed(3));this.middle.setAttribute(`d`,this.linePath(0,r,jr,308-jr,a)),this.middle.setAttribute(`opacity`,(u*(1-Vr(Q(n/180)))).toFixed(3));for(let e=0;e<3;e+=1){let t=3-e;this.lines[e].setAttribute(`d`,this.linePath(t,r,0,308,a)),this.lines[e].setAttribute(`opacity`,((.1+r*.1)*(1-Q(n/200))).toFixed(3))}this.track.setAttribute(`opacity`,(.1*Q((i-.4)/.6)).toFixed(3))}paintJoin(e,t){let n=(1-Math.cos(Math.PI*t/360))/2,r=-Math.PI/2+Ur(!1)*t,i=Nr/X,a=Math.PI-i,o=this.motion.matches?-Math.PI/2:r+Pr*a*n;if(this.motion.matches||t>=360){this.stage={kind:`spin`,startedAt:e,base:o-Y*.14},this.settleSuccess&&this.beginSuccess(e),this.paint(e);return}this.track.setAttribute(`opacity`,`0.1`);for(let[e,t]of[[this.top,o],[this.bottom,r+Math.PI-(1-Pr)*a*n]])e.setAttribute(`d`,Kr({start:t,sweep:i})),e.setAttribute(`stroke-width`,`2`),e.setAttribute(`opacity`,`1`)}spinnerArc(e,t){let n=e-t.startedAt,r=this.motion.matches?2600:1500,i=(n+r/2)%r/r,a=i<.5,o=zr(a?i/.5:(i-.5)/.5),s=a?$(1,56,o):$(56,1,o),c=a?$(0,-14,o):$(-14,-99,o);return{start:t.base+Ur(this.motion.matches)*n-Y*c/100,sweep:Y*s/100}}beginSuccess(e){if(this.stage.kind!==`spin`)return;this.stage={kind:`success`,startedAt:e,from:this.spinnerArc(e,this.stage)};let t=this.successBegun;this.successBegun=null,t?.()}paintSuccess(e,t){let n=e-t.startedAt;if(n>=1140){this.stage={kind:`sealed`},this.settle(),this.paint(e);return}let r=Q(n/650),i=this.motion.matches?0:Ur(!1)*650*(r-r*r/2),a=Rr(Q((n-150)/500));this.paintSeal({start:t.from.start+i,sweep:$(t.from.sweep,Y,a)},Br(Q((n-600)/420)),Rr(Q((n-820)/320)));let o=Q((n-700)/700);if(!this.motion.matches&&o>0&&o<1){let e=Vr(o);this.ripple.setAttribute(`r`,$(Lr,34,e).toFixed(2)),this.ripple.setAttribute(`opacity`,((1-e)*.45).toFixed(3))}}paintSeal(e,t,n){this.paintArc(e,1),this.seal.setAttribute(`r`,(Lr*Math.max(0,t)).toFixed(2)),this.seal.setAttribute(`opacity`,t>0?`1`:`0`),this.check.setAttribute(`stroke-dashoffset`,(1-n).toFixed(3)),this.check.setAttribute(`opacity`,n>0?`1`:`0`)}paintArc(e,t){this.track.setAttribute(`opacity`,String(.1*t)),this.top.setAttribute(`d`,Kr(e)),this.top.setAttribute(`stroke-width`,`2`),this.top.setAttribute(`opacity`,`1`)}displacement(e,t,n){let r=n/308,i=Math.sin(Math.PI*r)**1.7;if(this.motion.matches)return t*5*i;let a=Math.sin(r*Math.PI*4-this.position+e*.5)*.7+Math.sin(r*Math.PI*7+this.position*.7+e)*.3;return t*(26-e*4)*i*a}linePath(e,t,n,r,i){let a=``,o=Math.max(2,Math.ceil((r-n)/2));for(let s=0;s<=o;s+=1){let c=n+(r-n)*s/o,l=32+this.displacement(e,t,c)*i;a+=`${s===0?`M`:`L`}${c.toFixed(2)},${l.toFixed(2)} `}return a}halfPath(e,t,n,r,i){let a=``,o=Math.max(2,Math.ceil((t-e)/1.5));for(let s=0;s<=o;s+=1){let c=Wr(e+(t-e)*s/o),l=n?308-c.x:c.x,u=n?64-c.y:c.y;c.onLine&&(u+=this.displacement(0,r,l)*i),a+=`${s===0?`M`:`L`}${l.toFixed(2)},${u.toFixed(2)} `}return a}};function Ur(e){return Y/(e?3200:1800)}function Wr(e){if(e<=jr)return{x:e,y:32,onLine:!0};if(e<Mr){let t=e-jr,n=0,r=Z.lengths.length-1;for(;r-n>1;){let e=n+r>>1;Z.lengths[e]<t?n=e:r=e}let i=(t-Z.lengths[n])/(Z.lengths[r]-Z.lengths[n]||1);return{x:$(Z.points[n][0],Z.points[r][0],i),y:$(Z.points[n][1],Z.points[r][1],i),onLine:!1}}let t=-Math.PI/2+(e-Mr)/X;return{x:154+X*Math.cos(t),y:32+X*Math.sin(t),onLine:!1}}function Gr(){let e=[[jr,32]],t=[0],n=0;for(let r=1;r<=240;r+=1){let i=r/240,a=[jr+Ar*i,32-X*(4*i**3-3*i**4)],o=e[e.length-1];n+=Math.hypot(a[0]-o[0],a[1]-o[1]),e.push(a),t.push(n)}return{points:e,lengths:t,length:n}}function Kr(e){let t=Math.max(2,Math.ceil(80*e.sweep/Y)),n=``;for(let r=0;r<=t;r+=1){let i=e.start+e.sweep*r/t,a=154+X*Math.cos(i),o=32+X*Math.sin(i);n+=`${r===0?`M`:`L`}${a.toFixed(2)},${o.toFixed(2)} `}return n}function qr(e,t,n){let r=e*e;return t*(3*r-2*r*e)+n*(r*e-r)}function Jr(e,t,n,r){let i=(e,t,n)=>((1-3*n+3*t)*e+(3*n-6*t))*e*e+3*t*e,a=(e,t,n)=>3*(1-3*n+3*t)*e*e+2*(3*n-6*t)*e+3*t;return o=>{if(o<=0)return 0;if(o>=1)return 1;let s=o;for(let t=0;t<6;t+=1){let t=a(s,e,n);if(t===0)break;s-=(i(s,e,n)-o)/t}return i(Q(s),t,r)}}function Q(e){return e<0?0:e>1?1:e}function $(e,t,n){return e+(t-e)*n}const Yr=Or;var Xr=class{element;glow;ribbon;prompt;themeObserver;phase=`idle`;disposed=!1;constructor(e,t,r){this.prompt=t,this.ribbon=new Hr(e,r),this.element=this.ribbon.element,this.glow=e.createElement(`div`),this.glow.className=`seams-voiceid-glow`,this.glow.setAttribute(`aria-hidden`,`true`),this.render();let i=n();if(i)for(let e of this.glow.querySelectorAll(`style`))e.nonce=i;this.themeObserver=new MutationObserver(this.render),this.themeObserver.observe(e.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),this.themeObserver.observe(e.body,{attributes:!0,attributeFilter:[`data-theme`]})}listen(){this.setPhase(`listening`)}add(e){this.ribbon.add(e)}checking(){this.setPhase(`processing`)}accept(){this.setPhase(`idle`)}ready(){this.setPhase(`idle`)}succeed(e){return this.disposed?Promise.resolve():(this.phase=`idle`,this.render(),this.ribbon.succeed(e))}stop(){this.disposed||(this.disposed=!0,this.themeObserver.disconnect(),this.ribbon.dispose(),vt(null,this.glow))}setPhase(e){this.disposed||(this.phase=e,this.ribbon.setPhase(e),this.render())}render=()=>{this.disposed||vt(Je(Yr,{className:`seams-voiceid-beam`,theme:(this.prompt.closest(`[data-theme]`)?.getAttribute(`data-theme`)??this.prompt.ownerDocument.documentElement.getAttribute(`data-theme`))===`light`?`light`:`dark`,level:this.ribbon.readLevel,processing:this.phase===`processing`,active:this.phase!==`idle`,staticColors:!0,colorVariant:`ocean`,borderRadius:Number.parseFloat(getComputedStyle(this.prompt).borderRadius)||16,children:null}),this.glow)}};const Zr=new WeakMap,Qr=new Map([[`if you panic panic early`,`if you panic, panic early`],[`life is short go long to hedge`,`life is short, go long to hedge`]]);var $r=class{element;title;phrase;status;record;cancel;progress;microphone;microphoneRequested=!1;visual;disposed=!1;constructor(e,r,i,a=`ring`){let o=Zr.get(e);o||(o=t({doc:e,baseCss:`
296
- .seams-voiceid-activation-surface { width: min(100%, 26.25rem); margin: 0 auto; background: transparent; }
297
- /* Inside an operation's card the card is the frame: the prompt fills it edge to edge. */
298
- .seams-voiceid-activation-surface.seams-voiceid-in-card { width: 100%; }
299
- .seams-voiceid-in-card .seams-voiceid-prompt {
300
- width: 100%;
301
- padding-top: 0.75rem;
302
- border: 0;
303
- border-radius: 0;
304
- background: transparent;
305
- }
306
-
307
- .seams-voiceid-prompt {
308
- box-sizing: border-box;
309
- position: relative;
310
- width: min(100%, 26.25rem);
311
- margin: 0 auto;
312
- padding: 3.5rem 1.5rem 1.5rem;
313
- display: grid;
314
- grid-template-rows: auto minmax(6rem, auto) 5rem minmax(3.375rem, auto) minmax(5rem, auto);
315
- border: 1px solid var(--seams-colors-borderPrimary, #303b41);
316
- border-radius: var(--seams-shape-card, 16px);
317
- background: var(--seams-colors-colorBackground, #192024);
318
- color: var(--seams-colors-textPrimary, #eff2f3);
319
- text-align: center;
320
- font-family: var(--seams-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
321
- -webkit-font-smoothing: antialiased;
322
- }
323
- .seams-voiceid-prompt {
324
- transition: opacity 180ms var(--seams-ease-out, cubic-bezier(0.23, 1, 0.32, 1)), transform 180ms var(--seams-ease-out, cubic-bezier(0.23, 1, 0.32, 1));
325
- }
326
- @starting-style {
327
- .seams-voiceid-prompt { opacity: 0; transform: translateY(4px); }
328
- }
329
- .seams-voiceid-progress-slot { grid-row: 5; grid-column: 1; min-width: 0; align-self: center; }
330
- .seams-voiceid-progress-slot:empty { visibility: hidden; }
331
- .seams-voiceid-activation-surface[data-preparation="loading"] .seams-voiceid-record-slot { visibility: hidden; }
332
- @media (prefers-reduced-motion: reduce) {
333
- .seams-voiceid-prompt { transform: none; transition: opacity 150ms ease; }
334
- @starting-style { .seams-voiceid-prompt { transform: none; } }
335
- .seams-voiceid-ribbon { transition: none !important; }
336
- }
337
- .seams-voiceid-prompt h2 {
338
- font-size: 0.85rem;
339
- line-height: 1.4;
340
- font-weight: 500;
341
- color: var(--seams-colors-textSecondary, #9cabb3);
342
- margin: 0.5rem 0 1rem;
343
- }
344
- .seams-voiceid-prompt.seams-voiceid-management {
345
- display: flex;
346
- flex-direction: column;
347
- gap: 0.75rem;
348
- padding: 1.25rem 1.25rem 1.375rem;
349
- border-radius: var(--seams-shape-card, 1.5rem);
350
- text-align: start;
351
- font-size: 0.875rem;
352
- line-height: 1.5;
353
- }
354
- .seams-voiceid-management-header {
355
- display: flex;
356
- align-items: center;
357
- gap: 0.25rem;
358
- margin-inline-start: -0.5rem;
359
- }
360
- .seams-voiceid-management h2 {
361
- margin: 0;
362
- color: var(--seams-colors-textPrimary, #eff2f3);
363
- font-size: 1.375rem;
364
- font-weight: 600;
365
- letter-spacing: -0.02em;
366
- line-height: 1.25;
367
- }
368
- .seams-voiceid-management .seams-voiceid-management-intro {
369
- margin: -0.125rem 0 0.25rem;
370
- color: var(--seams-colors-textSecondary, #9cabb3);
371
- }
372
- .seams-voiceid-management button {
373
- appearance: none;
374
- margin: 0;
375
- color: var(--seams-colors-textPrimary, #eff2f3);
376
- font: inherit;
377
- transition: background-color 140ms ease;
378
- }
379
- .seams-voiceid-management button:disabled { opacity: 0.5; cursor: default; }
380
- .seams-voiceid-management .seams-voiceid-management-back {
381
- display: grid;
382
- place-items: center;
383
- width: 2.25rem;
384
- height: 2.25rem;
385
- padding: 0;
386
- border: 0;
387
- border-radius: var(--seams-shape-control, 10px);
388
- background: transparent;
389
- }
390
- .seams-voiceid-management-enrollment {
391
- display: grid;
392
- grid-template-columns: minmax(0, 1fr) auto;
393
- align-items: center;
394
- gap: 0.125rem 0.75rem;
395
- padding: 0.75rem 0.875rem;
396
- border-radius: 0.75rem;
397
- background: var(--seams-colors-surface, #202b31);
398
- color: var(--seams-colors-textSecondary, #9cabb3);
399
- }
400
- .seams-voiceid-management-summary { text-align: end; }
401
- .seams-voiceid-management-value { color: var(--seams-colors-textPrimary, #eff2f3); font-weight: 500; }
402
- .seams-voiceid-management-enrollment-detail:not(:empty)::before { content: ' · '; }
403
- .seams-voiceid-management-enrollment[data-enrollment="adapted"] > .seams-voiceid-management-summary {
404
- grid-area: 2 / 1;
405
- text-align: start;
406
- font-size: 0.8125rem;
407
- }
408
- .seams-voiceid-management-enrollment > .seams-voiceid-management-reset { grid-area: 1 / 2 / 3; }
409
- .seams-voiceid-management-enrollment[data-state] .seams-voiceid-management-value { display: none; }
410
- .seams-voiceid-management-enrollment[data-state] .seams-voiceid-management-enrollment-detail::before { content: none; }
411
- .seams-voiceid-management .seams-voiceid-management-reset {
412
- padding: 0.375rem 0.75rem;
413
- border: 1px solid var(--seams-colors-borderPrimary, #303b41);
414
- border-radius: var(--seams-shape-control, 10px);
415
- background: transparent;
416
- font-size: 0.8125rem;
417
- font-weight: 600;
418
- }
419
- .seams-voiceid-management .seams-voiceid-management-action {
420
- display: grid;
421
- grid-template-columns: minmax(0, 1fr) auto;
422
- align-items: center;
423
- gap: 0.75rem;
424
- width: 100%;
425
- min-height: 44px;
426
- padding: 0.75rem 0.875rem;
427
- border: 1px solid var(--seams-colors-borderPrimary, #303b41);
428
- border-radius: 0.75rem;
429
- background: transparent;
430
- text-align: start;
431
- }
432
- .seams-voiceid-management-action > svg { color: var(--seams-colors-textSecondary, #9cabb3); }
433
- .seams-voiceid-management-action-heading {
434
- display: flex;
435
- flex-wrap: wrap;
436
- align-items: center;
437
- gap: 0.25rem 0.5rem;
438
- font-weight: 600;
439
- }
440
- .seams-voiceid-management-chip {
441
- padding: 0.125rem 0.5rem;
442
- border-radius: 6px;
443
- background: color-mix(in srgb, var(--seams-colors-textPrimary, #eff2f3), transparent 93%);
444
- font-size: 0.75rem;
445
- font-weight: 500;
446
- }
447
- .seams-voiceid-management-action-detail {
448
- display: block;
449
- margin-top: 0.125rem;
450
- color: var(--seams-colors-textSecondary, #9cabb3);
451
- font-size: 0.8125rem;
452
- }
453
- .seams-voiceid-management .seams-voiceid-management-action[data-state="pending"] {
454
- opacity: 1;
455
- border-color: var(--seams-colors-borderHover, #46545b);
456
- background: var(--seams-colors-surface, #202b31);
457
- }
458
- .seams-voiceid-management-action[data-state="pending"] > svg { visibility: hidden; }
459
- .seams-voiceid-management [data-state="pending"] .seams-voiceid-management-action-detail,
460
- .seams-voiceid-management [data-state="pending"] .seams-voiceid-management-enrollment-detail {
461
- color: var(--seams-colors-textPrimary, #eff2f3);
462
- }
463
- .seams-voiceid-management [data-state="error"] .seams-voiceid-management-action-detail,
464
- .seams-voiceid-management [data-state="error"] .seams-voiceid-management-enrollment-detail {
465
- color: var(--seams-colors-error, oklch(0.74 0.166 19));
466
- }
467
- .seams-voiceid-management .seams-voiceid-management-section {
468
- margin: 0.5rem 0 -0.25rem;
469
- padding-inline-start: 0.125rem;
470
- color: var(--seams-colors-textSecondary, #9cabb3);
471
- font-size: 0.6875rem;
472
- font-weight: 600;
473
- letter-spacing: 0.08em;
474
- text-transform: uppercase;
475
- }
476
- /* The status line is read by assistive technology; a message for a hidden row is also shown. */
477
- .seams-voiceid-prompt.seams-voiceid-management > [role="status"] {
478
- position: absolute;
479
- width: 1px;
480
- height: 1px;
481
- margin: -1px;
482
- overflow: hidden;
483
- clip-path: inset(50%);
484
- white-space: nowrap;
485
- }
486
- .seams-voiceid-prompt.seams-voiceid-management > [role="status"][data-placement="dialog"] {
487
- position: relative;
488
- width: auto;
489
- height: auto;
490
- margin: 0;
491
- overflow: visible;
492
- clip-path: none;
493
- white-space: normal;
494
- color: var(--seams-colors-error, oklch(0.74 0.166 19));
495
- font-size: 0.8125rem;
496
- overflow-wrap: anywhere;
497
- }
498
- [dir='rtl'] .seams-voiceid-management svg { transform: scaleX(-1); }
499
- @media (hover: hover) {
500
- .seams-voiceid-management button:hover:not(:disabled) {
501
- background: var(--seams-colors-surface2, var(--seams-colors-surface, #202b31));
502
- }
503
- }
504
- .seams-voiceid-prompt .seams-voiceid-phrase {
505
- font-size: clamp(1.75rem, 6vw, 2.25rem);
506
- font-weight: 600;
507
- line-height: 1.17;
508
- letter-spacing: -0.035em;
509
- text-wrap: balance;
510
- max-width: 21rem;
511
- align-self: center;
512
- margin: 0 auto;
513
- transition: opacity 180ms var(--seams-ease-out, cubic-bezier(0.23, 1, 0.32, 1));
514
- }
515
- .seams-voiceid-ribbon {
516
- display: block;
517
- width: 308px;
518
- max-width: 100%;
519
- height: 64px;
520
- margin: auto;
521
- overflow: visible;
522
- }
523
- .seams-voiceid-ribbon .seams-voiceid-ribbon-check { stroke: var(--seams-colors-colorBackground, #192024); }
524
- .seams-voiceid-prompt .seams-voiceid-phrase.seams-voiceid-success-headline {
525
- display: grid;
526
- align-content: end;
527
- font-size: 18px;
528
- letter-spacing: normal;
529
- line-height: 1.4;
530
- }
531
- .seams-voiceid-prompt .seams-voiceid-status.seams-voiceid-success-message { font-size: 0.8125rem; }
532
- /* The glow is decorative and cannot intercept record, retry or cancel controls. */
533
- .seams-voiceid-glow { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; z-index: 0; }
534
- .seams-voiceid-beam { width: 100%; height: 100%; border-radius: inherit; }
535
- .seams-voiceid-prompt > :not(.seams-voiceid-glow) { position: relative; z-index: 1; }
536
- .seams-voiceid-prompt > .seams-voiceid-close { position: absolute; }
537
- .seams-voiceid-prompt .seams-voiceid-status {
538
- font-size: 0.75rem;
539
- line-height: 1.5;
540
- min-height: 3.375rem;
541
- color: var(--seams-colors-textSecondary, #9cabb3);
542
- margin: 0;
543
- }
544
- .seams-voiceid-prompt button {
545
- font: inherit;
546
- cursor: pointer;
547
- touch-action: manipulation;
548
- }
549
- .seams-voiceid-prompt button:focus-visible {
550
- outline: 2px solid currentColor;
551
- outline-offset: 2px;
552
- }
553
- .seams-voiceid-prompt .seams-voiceid-close {
554
- position: absolute;
555
- right: 0.75rem;
556
- top: 0.75rem;
557
- width: 2.5rem;
558
- height: 2.5rem;
559
- background: transparent;
560
- border: 0;
561
- border-radius: var(--seams-shape-control, 10px);
562
- color: inherit;
563
- display: grid;
564
- place-items: center;
565
- color: var(--seams-colors-textSecondary, #9cabb3);
566
- }
567
- .seams-voiceid-prompt .seams-voiceid-record-slot {
568
- grid-row: 5;
569
- grid-column: 1;
570
- align-self: center;
571
- width: 100%;
572
- box-sizing: border-box;
573
- }
574
- .seams-voiceid-prompt .seams-voiceid-primary {
575
- width: 100%;
576
- min-height: var(--seams-shape-controlHeight, 44px);
577
- padding: 0.75rem 1rem;
578
- font-size: 0.875rem;
579
- font-weight: 500;
580
- border: 0;
581
- border-radius: var(--seams-shape-control, 10px);
582
- background: var(--seams-colors-textPrimary, #eff2f3);
583
- color: var(--seams-colors-colorBackground, #192024);
584
- }
585
- .seams-voiceid-prompt .seams-voiceid-primary:disabled {
586
- opacity: 0.5;
587
- cursor: wait;
588
- }
589
- .seams-voiceid-prompt .seams-voiceid-microphone {
590
- margin-top: 0.5rem;
591
- padding: 0.25rem;
592
- border: 0;
593
- background: transparent;
594
- color: var(--seams-colors-textSecondary, #9cabb3);
595
- font-size: 0.75rem;
596
- }
597
- .seams-voiceid-prompt button[hidden],
598
- .seams-voiceid-prompt [hidden] {
599
- display: none !important;
600
- }
601
- /* While VoiceID loads, its bar takes the answer line's place, its message the status line's,
602
- and its retry the record button's. */
603
- .seams-voiceid-progress-slot:has(> .seams-voiceid-model-download),
604
- .seams-voiceid-progress-slot > .seams-voiceid-model-download { display: contents; }
605
- .seams-voiceid-model-download > * { position: relative; z-index: 1; grid-column: 1; align-self: center; }
606
- .seams-voiceid-prompt:has(.seams-voiceid-model-download:not([data-state="ready"])) > .seams-voiceid-ribbon,
607
- .seams-voiceid-prompt:has(.seams-voiceid-model-download:not([data-state="ready"])) > .seams-voiceid-status { visibility: hidden; }
608
- .seams-voiceid-prompt:has(.seams-voiceid-model-download:not([data-state="ready"])) > .seams-voiceid-phrase { opacity: 0.35; }
609
- .seams-voiceid-prompt:has(.seams-voiceid-model-download[data-state="failed"]) > .seams-voiceid-record-slot { display: none; }
610
- .seams-voiceid-model-download progress {
611
- grid-row: 3;
612
- justify-self: center;
613
- appearance: none;
614
- display: block;
615
- width: min(100%, 308px);
616
- height: 6px;
617
- border: 0;
618
- border-radius: 999px;
619
- overflow: hidden;
620
- background: var(--seams-colors-surface, #202b31);
621
- color: var(--seams-colors-textPrimary, #eff2f3);
622
- }
623
- .seams-voiceid-model-download progress::-webkit-progress-bar { background: var(--seams-colors-surface, #202b31); }
624
- .seams-voiceid-model-download progress::-webkit-progress-value { background: var(--seams-colors-textPrimary, #eff2f3); border-radius: 999px; transition: width 200ms linear; }
625
- .seams-voiceid-model-download progress::-moz-progress-bar { background: var(--seams-colors-textPrimary, #eff2f3); border-radius: 999px; }
626
- .seams-voiceid-model-download p {
627
- grid-row: 4;
628
- align-self: start;
629
- margin: 0;
630
- font-size: 0.75rem;
631
- line-height: 1.5;
632
- color: var(--seams-colors-textSecondary, #9cabb3);
633
- font-variant-numeric: tabular-nums;
634
- }
635
- .seams-voiceid-model-download button { grid-row: 5; }
636
- @media (hover: hover) and (pointer: fine) {
637
- .seams-voiceid-close:hover { background: var(--seams-colors-surface, #202b31); }
638
- .seams-voiceid-primary:hover:not(:disabled) { opacity: 0.9; }
639
- }
640
- `,nonce:n}),Zr.set(e,o)),o.ensureBase(),this.element=e.createElement(`section`),this.element.className=`seams-voiceid-prompt`,this.element.setAttribute(`aria-label`,r),this.title=e.createElement(`h2`),this.title.textContent=`Read aloud`,this.phrase=e.createElement(`p`),this.phrase.className=`seams-voiceid-phrase`,this.phrase.dataset.voiceidPhrase=``,this.phrase.setAttribute(`aria-live`,`polite`),this.setPhrase(i),this.visual=new Xr(e,this.element,a),this.status=e.createElement(`p`),this.status.className=`seams-voiceid-status`,this.status.setAttribute(`role`,`status`),this.record=e.createElement(`button`),this.record.type=`button`,this.record.className=`seams-voiceid-primary`,this.record.textContent=`Record`,this.cancel=e.createElement(`button`),this.cancel.type=`button`,this.cancel.className=`seams-voiceid-close`;let s=e.createElementNS(`http://www.w3.org/2000/svg`,`svg`);s.setAttribute(`viewBox`,`0 0 24 24`),s.setAttribute(`width`,`20`),s.setAttribute(`height`,`20`),s.setAttribute(`aria-hidden`,`true`);let c=e.createElementNS(`http://www.w3.org/2000/svg`,`path`);c.setAttribute(`d`,`M6 6l12 12M18 6L6 18`),c.setAttribute(`fill`,`none`),c.setAttribute(`stroke`,`currentColor`),c.setAttribute(`stroke-width`,`1.75`),c.setAttribute(`stroke-linecap`,`round`),s.append(c),this.cancel.append(s),this.cancel.setAttribute(`aria-label`,`Cancel`),this.progress=e.createElement(`div`),this.progress.className=`seams-voiceid-progress-slot`;let l=e.createElement(`div`);l.className=`seams-voiceid-record-slot`,this.microphone=e.createElement(`button`),this.microphone.type=`button`,this.microphone.className=`seams-voiceid-microphone`,this.microphone.textContent=`Use system microphone`,this.microphone.hidden=!0,this.microphone.addEventListener(`click`,this.changeMicrophone),l.append(this.record,this.microphone),this.element.append(this.visual.glow,this.cancel,this.title,this.phrase,this.visual.element,this.status,l,this.progress)}setPhrase(e){let t=Qr.get(e)??e;this.phrase.textContent=t.charAt(0).toUpperCase()+t.slice(1)+`.`,this.phrase.dataset.voiceidPhrase=e}capture=e=>{if(!this.disposed)switch(e.kind){case`opening`:this.microphoneRequested=!0,this.microphone.hidden=!0;return;case`listening`:this.microphone.hidden=!0,this.element.dataset.capture=`listening`,this.record.hidden=!0,this.status.textContent=`Listening`,this.visual.listen();return;case`activity`:this.visual.add(e);return;case`measured`:e.quality.noise===`high`&&(this.status.textContent=`Background noise is high. Move closer to the microphone.`);return;case`processing`:this.element.dataset.capture=`processing`,this.lockLayout(),this.visual.checking(),this.status.textContent=`Checking your voice…`;return;default:return ai(e)}};accepted(){this.visual.accept()}async succeed(e,t,n=this.element.getBoundingClientRect()){this.disposed||(this.element.dataset.capture=`succeeded`,this.record.hidden=!0,this.microphone.hidden=!0,await this.visual.succeed(this.beginSuccess.bind(this,e,t,n)))}ready(e){this.unlockLayout(),this.visual.ready(),this.element.dataset.capture=`ready`,this.status.textContent=e,this.record.hidden=!1,this.record.disabled=!1,this.microphone.hidden=!this.microphoneRequested}changeMicrophone=()=>{this.useSystemMicrophone()};async useSystemMicrophone(){this.record.disabled=!0,this.microphone.disabled=!0,await be(),!this.disposed&&(this.status.textContent=`The next recording will use your system microphone.`,this.record.disabled=!1,this.microphone.disabled=!1,this.microphone.hidden=!0,this.record.focus())}dispose(){this.disposed=!0,this.microphone.removeEventListener(`click`,this.changeMicrophone),this.visual.stop()}lockLayout(){for(let e of[this.element,this.phrase,this.status])e.style.minHeight=`${e.getBoundingClientRect().height}px`;this.element.style.height=this.element.style.minHeight}async beginSuccess(e,t,n){if(this.disposed)return;let r=this.visual.element.getBoundingClientRect(),i=(n.top+n.bottom-r.top-r.bottom)/2;if(this.visual.element.animate([{translate:`0 0`},{translate:`0 ${i}px`}],{duration:600,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`forwards`}),await Promise.all([this.title,this.phrase,this.status].map(ri)),this.disposed)return;this.phrase.textContent=e,this.phrase.classList.add(`seams-voiceid-success-headline`),this.status.textContent=t,this.status.classList.add(`seams-voiceid-success-message`);let a=matchMedia(`(prefers-reduced-motion: reduce)`).matches;for(let[e,t]of[this.phrase,this.status].entries())t.style.translate=`0 ${i}px`,ii(t,a,ti-ei+e*ni)}unlockLayout(){for(let e of[this.element,this.phrase,this.status])e.style.minHeight=``;this.element.style.height=``}};const ei=150,ti=450,ni=40;function ri(e){return e.animate([{opacity:1},{opacity:0}],{duration:150,easing:`ease-in`,fill:`forwards`}).finished}function ii(e,t,n){e.animate([{opacity:0,transform:t?`none`:`translateY(4px)`},{opacity:1,transform:`none`}],{delay:n,duration:300,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`both`})}function ai(e){throw Error(`Unexpected capture event: ${String(e)}`)}export{m as _,ke as a,Ce as c,P as d,le as f,l as g,h,we as i,Se as l,T as m,vt as n,Oe as o,C as p,Je as r,De as s,$r as t,ue as u,o as v};