@seams/voiceid 0.46.0 → 0.49.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.
- package/README.md +1 -1
- package/dist/esm/capture/prompt.js +29 -12
- package/dist/public/sdk/voiceid/{addVoiceId-eGEbWa1n.js → addVoiceId-DgFmNO4V.js} +1 -1
- package/dist/public/sdk/voiceid/deviceBridge-Cqb5arWN.js +1 -0
- package/dist/public/sdk/voiceid/host.js +2 -2
- package/dist/public/sdk/voiceid/{operation-C2wM5i7x.js → operation-B-Hwg9al.js} +1 -1
- package/dist/public/sdk/voiceid/{prompt-BMATEY7H.js → prompt-bUX1mWKl.js} +30 -13
- package/dist/public/sdk/voiceid/{unlock-C1jW7c3K.js → unlock-Zmv1aA7R.js} +1 -1
- package/package.json +2 -2
- package/dist/public/sdk/voiceid/deviceBridge-DTN7sn5D.js +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ and the trusted host API. Existing voice enrollments keep their storage identity
|
|
|
10
10
|
Install matching Wallet and VoiceID versions, then import the descriptor:
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
pnpm add @seams/wallet@0.
|
|
13
|
+
pnpm add @seams/wallet@0.49.0 @seams/voiceid@0.49.0
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
```ts
|
|
@@ -220,6 +220,7 @@ const CSS = `
|
|
|
220
220
|
max-width: 21rem;
|
|
221
221
|
align-self: center;
|
|
222
222
|
margin: 0 auto;
|
|
223
|
+
transition: opacity 180ms var(--seams-ease-out, cubic-bezier(0.23, 1, 0.32, 1));
|
|
223
224
|
}
|
|
224
225
|
.seams-voiceid-ribbon {
|
|
225
226
|
display: block;
|
|
@@ -307,25 +308,41 @@ const CSS = `
|
|
|
307
308
|
.seams-voiceid-prompt [hidden] {
|
|
308
309
|
display: none !important;
|
|
309
310
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
.seams-voiceid-
|
|
311
|
+
/* While VoiceID loads, its bar takes the answer line's place, its message the status line's,
|
|
312
|
+
and its retry the record button's. */
|
|
313
|
+
.seams-voiceid-progress-slot:has(> .seams-voiceid-model-download),
|
|
314
|
+
.seams-voiceid-progress-slot > .seams-voiceid-model-download { display: contents; }
|
|
315
|
+
.seams-voiceid-model-download > * { position: relative; z-index: 1; grid-column: 1; align-self: center; }
|
|
316
|
+
.seams-voiceid-prompt:has(.seams-voiceid-model-download:not([data-state="ready"])) > .seams-voiceid-ribbon,
|
|
317
|
+
.seams-voiceid-prompt:has(.seams-voiceid-model-download:not([data-state="ready"])) > .seams-voiceid-status { visibility: hidden; }
|
|
318
|
+
.seams-voiceid-prompt:has(.seams-voiceid-model-download:not([data-state="ready"])) > .seams-voiceid-phrase { opacity: 0.35; }
|
|
319
|
+
.seams-voiceid-prompt:has(.seams-voiceid-model-download[data-state="failed"]) > .seams-voiceid-record-slot { display: none; }
|
|
320
|
+
.seams-voiceid-model-download progress {
|
|
321
|
+
grid-row: 3;
|
|
322
|
+
justify-self: center;
|
|
315
323
|
appearance: none;
|
|
316
324
|
display: block;
|
|
317
|
-
width: 100
|
|
318
|
-
height:
|
|
325
|
+
width: min(100%, 308px);
|
|
326
|
+
height: 6px;
|
|
319
327
|
border: 0;
|
|
320
|
-
border-radius:
|
|
328
|
+
border-radius: 999px;
|
|
321
329
|
overflow: hidden;
|
|
322
330
|
background: var(--seams-colors-surface, #202b31);
|
|
323
|
-
|
|
331
|
+
color: var(--seams-colors-textPrimary, #eff2f3);
|
|
324
332
|
}
|
|
325
|
-
.seams-voiceid-model-download p { margin: 0 0 0.75rem; color: var(--seams-colors-textSecondary, #9cabb3); font-variant-numeric: tabular-nums; }
|
|
326
333
|
.seams-voiceid-model-download progress::-webkit-progress-bar { background: var(--seams-colors-surface, #202b31); }
|
|
327
|
-
.seams-voiceid-model-download progress::-webkit-progress-value { background: var(--seams-colors-textPrimary, #eff2f3); border-radius:
|
|
328
|
-
.seams-voiceid-model-download progress::-moz-progress-bar { background: var(--seams-colors-textPrimary, #eff2f3); }
|
|
334
|
+
.seams-voiceid-model-download progress::-webkit-progress-value { background: var(--seams-colors-textPrimary, #eff2f3); border-radius: 999px; transition: width 200ms linear; }
|
|
335
|
+
.seams-voiceid-model-download progress::-moz-progress-bar { background: var(--seams-colors-textPrimary, #eff2f3); border-radius: 999px; }
|
|
336
|
+
.seams-voiceid-model-download p {
|
|
337
|
+
grid-row: 4;
|
|
338
|
+
align-self: start;
|
|
339
|
+
margin: 0;
|
|
340
|
+
font-size: 0.75rem;
|
|
341
|
+
line-height: 1.5;
|
|
342
|
+
color: var(--seams-colors-textSecondary, #9cabb3);
|
|
343
|
+
font-variant-numeric: tabular-nums;
|
|
344
|
+
}
|
|
345
|
+
.seams-voiceid-model-download button { grid-row: 5; }
|
|
329
346
|
@media (hover: hover) and (pointer: fine) {
|
|
330
347
|
.seams-voiceid-close:hover { background: var(--seams-colors-surface, #202b31); }
|
|
331
348
|
.seams-voiceid-primary:hover:not(:disabled) { opacity: 0.9; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./prompt-
|
|
1
|
+
import"./prompt-bUX1mWKl.js";import{a as e,i as t,o as n,s as r,t as i}from"./deviceBridge-Cqb5arWN.js";import{WorkerDeferred as a,prepareVoiceOwner as o,toError as s}from"../voiceid-host.js";const c=`http://www.w3.org/2000/svg`;async function l(e,t,n,r,i){let a=new u(e,t,n,r,i);try{await a.result}finally{a.dispose()}}var u=class{completion=new a;result=this.completion.promise;document;element;enrollment;enrollmentValue;enrollmentSummary;startOver;status;actions;busy=!1;closed=!1;constructor(e,t,n,r,i){this.parent=e,this.confirmChange=t,this.scope=n,this.signal=r,this.model=i,this.document=e.ownerDocument,this.element=this.document.createElement(`div`),this.enrollment=this.document.createElement(`div`),this.enrollmentValue=this.document.createElement(`span`),this.enrollmentSummary=this.document.createElement(`span`),this.startOver=this.document.createElement(`p`),this.status=this.document.createElement(`p`),this.element.className=`seams-voiceid-prompt seams-voiceid-management`;let a=this.document.createElement(`div`);a.className=`seams-voiceid-management-header`;let o=this.document.createElement(`button`);o.type=`button`,o.className=`seams-voiceid-management-back`,o.setAttribute(`aria-label`,`Back`),o.append(d(this.document,`M15 6l-6 6 6 6`,20)),o.addEventListener(`click`,this.cancel);let s=this.document.createElement(`h2`);s.textContent=`Manage voice`,a.append(o,s);let c=this.document.createElement(`p`);c.className=`seams-voiceid-management-intro`,c.textContent=`Voice unlock on this device. Each change asks for your passkey.`,this.element.append(a,c,this.enrollmentRow()),this.actions={reset:this.resetAction(),improve:this.action(`improve`,`Improve recognition`,!0),import:this.action(`import`,`Use saved enrollment`,!1),replace:this.startOverAction()},this.status.setAttribute(`role`,`status`),this.element.append(this.status),this.enrollmentValue.textContent=`Checking…`,this.actions.import.button.hidden=!0,this.render(null,!1,!1),this.parent.replaceChildren(this.element),this.signal.addEventListener(`abort`,this.cancel,{once:!0}),this.refresh(),o.focus()}enrollmentRow(){this.enrollment.className=`seams-voiceid-management-enrollment`;let e=this.document.createElement(`span`);return e.textContent=`Enrollment`,this.enrollmentValue.className=`seams-voiceid-management-value`,this.enrollmentSummary.className=`seams-voiceid-management-summary`,this.enrollmentSummary.append(this.enrollmentValue),this.enrollment.append(e,this.enrollmentSummary),this.enrollment}resetAction(){let e=this.document.createElement(`button`);e.type=`button`,e.className=`seams-voiceid-management-reset`,e.textContent=`Reset`,e.setAttribute(`aria-label`,`Reset improvements`),e.addEventListener(`click`,this.begin.bind(this,`reset`));let t=this.document.createElement(`span`);return t.className=`seams-voiceid-management-enrollment-detail`,this.enrollmentSummary.append(t),this.enrollment.append(e),{button:e,title:e,detail:t,frame:this.enrollment}}startOverAction(){return this.startOver.className=`seams-voiceid-management-section`,this.startOver.textContent=`Start over`,this.element.append(this.startOver),this.action(`replace`,`Record voice again`,!1)}action(e,t,n){let r=this.document.createElement(`button`);r.type=`button`,r.className=`seams-voiceid-management-action`;let i=this.document.createElement(`span`),a=this.document.createElement(`span`);a.className=`seams-voiceid-management-action-heading`;let o=this.document.createElement(`span`);o.id=`seams-voiceid-management-${e}-title`,o.textContent=t,a.append(o);let s=[];if(n){let t=this.document.createElement(`span`);t.id=`seams-voiceid-management-${e}-chip`,t.className=`seams-voiceid-management-chip`,t.textContent=`Experimental`,a.append(t),s.push(t.id)}let c=this.document.createElement(`span`);return c.id=`seams-voiceid-management-${e}-detail`,c.className=`seams-voiceid-management-action-detail`,s.push(c.id),i.append(a,c),r.append(i,d(this.document,`M9 6l6 6-6 6`,16)),r.setAttribute(`aria-labelledby`,o.id),r.setAttribute(`aria-describedby`,s.join(` `)),r.disabled=!0,r.addEventListener(`click`,this.begin.bind(this,e)),this.element.append(r),{button:r,title:o,detail:c,frame:r}}async refresh(){try{let e=await r(this.scope),t=e?null:await n();if(this.closed)return;this.render(e,t!==null,!0)}catch(e){this.completion.reject(s(e))}}render(e,t,n){let r=e?.adaptation??null,{improve:i,reset:a,import:o,replace:s}=this.actions;n&&(this.enrollment.dataset.enrollment=r?.kind??`missing`,this.enrollmentValue.textContent=r===null?`Not on this device`:r.kind===`adapted`?`Improved`:`Original`,i.button.hidden=e===null,o.button.hidden=!t),a.button.hidden=r?.kind!==`adapted`,a.detail.textContent=r?.kind===`adapted`?`Saved on this device`:``,i.title.textContent=r?.kind===`adapted`?`Improve again`:`Improve recognition`,i.detail.textContent=r?.kind===`adapted`?`Replace the added samples. Your original enrollment stays.`:`Add three samples. They stay until you replace or reset them.`,o.detail.textContent=`Import the voice enrollment saved in this browser.`,s.detail.textContent=r?.kind===`adapted`?`Replace your enrollment and remove improvements.`:`Replace your enrollment with three new samples.`,this.startOver.hidden=i.button.hidden&&o.button.hidden;for(let e of Object.values(this.actions))delete e.frame.dataset.state,e.button.disabled=!n;this.status.textContent=``,delete this.status.dataset.placement}show(e,t,n){let r=this.actions[e];if(this.status.textContent=n,r.button.hidden){this.status.dataset.placement=`dialog`;return}r.frame.dataset.state=t,r.detail.textContent=n}begin(e){if(!(this.busy||this.closed)){this.busy=!0;for(let e of Object.values(this.actions))e.button.disabled=!0;this.show(e,`pending`,`Confirm with your passkey to continue.`),this.perform(e)}}async perform(n){try{let i=await o(this.scope,`enrolled`),a=await r(this.scope),s=await f(n,i,a?{kind:`present`,enrollment:a}:{kind:`missing`},this.signal),c=await this.confirmChange(s);switch(this.signal.throwIfAborted(),s.kind){case`improve`:await t(this.parent,{kind:`improve`,scope:this.scope,guard:s.guard,snapshot:s.snapshot,confirmation:c},this.signal,this.model);break;case`replace`:await t(this.parent,{kind:`replace`,scope:this.scope,guard:s.guard,snapshot:s.snapshot,confirmation:c},this.signal,this.model);break;case`reset`:await e({kind:`reset`,scope:this.scope,guard:s.guard,snapshot:s.snapshot,confirmation:c,signal:this.signal});break;case`import`:await e({kind:`import`,scope:this.scope,guard:s.guard,snapshot:s.snapshot,baseline:s.baseline,confirmation:c,signal:this.signal});break;default:return p(s)}this.closed||this.completion.resolve()}catch(e){if(this.closed)return;this.parent.replaceChildren(this.element),await this.refresh(),this.closed||this.show(n,`error`,e instanceof Error?e.message:`VoiceID could not be updated.`)}finally{this.busy=!1}}cancel=()=>{this.closed||(this.closed=!0,this.parent.dispatchEvent(new Event(`cancel`,{bubbles:!0})),this.completion.reject(Error(`VoiceID management was cancelled.`)))};dispose(){this.closed=!0,this.signal.removeEventListener(`abort`,this.cancel),this.element.remove()}};function d(e,t,n){let r=e.createElementNS(c,`svg`);r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`width`,String(n)),r.setAttribute(`height`,String(n)),r.setAttribute(`aria-hidden`,`true`);let i=e.createElementNS(c,`path`);return i.setAttribute(`d`,t),i.setAttribute(`fill`,`none`),i.setAttribute(`stroke`,`currentColor`),i.setAttribute(`stroke-width`,`1.75`),i.setAttribute(`stroke-linecap`,`round`),i.setAttribute(`stroke-linejoin`,`round`),r.append(i),r}async function f(e,t,r,i){switch(e){case`replace`:return{kind:e,guard:t,snapshot:r,signal:i};case`import`:{if(r.kind!==`missing`)throw Error(`The previous enrollment is unavailable.`);let a=await n();if(!a)throw Error(`The previous enrollment is unavailable.`);return{kind:e,guard:t,snapshot:r,signal:i,baseline:a}}case`improve`:case`reset`:if(r.kind!==`present`)throw Error(`Record or import your original voice first.`);return{kind:e,guard:t,snapshot:r,signal:i};default:return p(e)}}function p(e){throw Error(`Unsupported VoiceID enrollment management action.`)}async function m(e,t,n,r){t.throwIfAborted();let i=await e.prepareActivation();return t.throwIfAborted(),i.kind===`enroll_existing`?{kind:`management`,action:h.bind(null,r,i,n)}:{kind:`recording`,action:g.bind(null,r,i,n),expiresAtMs:null}}async function h(e,t,n,r){return await l(n,t.confirmChange,t.scope,r,e),r.throwIfAborted(),{kind:`activated`,walletId:t.scope.walletId,walletAuthMethodId:t.scope.walletAuthMethodId}}function g(e,t,n,r,a,o){return t.activate(i.bind(null,e,{parent:n,onCapture:a,phrase:o}),r)}export{m as prepareActivationSurface};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,m as c,o as ee,p as l,s as u,t as d,u as f,v as p}from"./prompt-bUX1mWKl.js";import{WorkerDeferred as m,assertVoiceOwner as h,base64UrlEncode as g,createBrowserVoiceDevice as _,isFiniteNumber as v,openBrowserVoiceFactor as y,parseVoiceIdDeviceAssertion as te,parseVoiceIdOperationAssertion as b,prepareVoiceOwner as x,readBrowserVoiceDevice as S,requireRecord as C,resolveActivatingVoiceEnrollmentScope as w,resolveVoiceEnrollmentScope as T,toError as E,voiceEnrollmentStorage as D,voiceIdOperationStatementBytes as O,voiceIdWalletSessionChallengeBytes as k}from"../voiceid-host.js";const A=`e04dd7a6a1e23fc7b89e47682ea9d0a3946cf7bc59d07922c3db3efc52ae4269`,j=`redimnet-b1:${A}`,M=new o({path:`/sdk/voiceid/redimnet-b1.onnx`,sha256:A,bytes:8859593,label:`Speaker verification`});async function N(e){let t=await M.prepare(),n=new(await(import(`./ort.wasm.bundle.min-7y-hlRN8.js`))).Tensor(`float32`,e,[1,e.length]);try{let e=await t.run({samples:n});try{let t=e.embedding;if(!t||!(t.data instanceof Float32Array))throw Error(`VoiceID model returned an invalid embedding.`);return P(Array.from(t.data))}finally{for(let t of Object.values(e))t.dispose()}}finally{n.dispose()}}function P(e){if(e.length!==192)throw Error(`VoiceID template dimensions are invalid.`);let t=0;for(let n of e){if(!Number.isFinite(n))throw Error(`VoiceID template is invalid.`);t+=n*n}if(t<1e-12)throw Error(`VoiceID template contains no signal.`);let n=Math.sqrt(t),r=[];for(let t of e)r.push(t/n);return r}function F(e,t){if(e.length!==192||t.length!==192)throw Error(`VoiceID templates are incompatible.`);let n=0;for(let r=0;r<e.length;r+=1)n+=e[r]*t[r];return n}function I(e){return e.asset}function L(e,t){return e+t.size}var R=class{element=document.createElement(`section`);status=document.createElement(`p`);meter=document.createElement(`progress`);retryButton=document.createElement(`button`);retry=null;cancelled=new m;reveal;received=new Map;models;assets;total;constructor(t,n,r){this.parent=t,this.signal=n,this.models=[M,l(r),f],this.assets=[e,...this.models.map(I)],this.total=this.assets.reduce(L,0),this.element.className=`seams-voiceid-model-download`,this.status.setAttribute(`role`,`status`),this.status.setAttribute(`aria-live`,`polite`),this.meter.setAttribute(`aria-label`,`VoiceID download`),this.meter.style.width=`100%`,this.retryButton.type=`button`,this.retryButton.className=`seams-voiceid-primary`,this.retryButton.textContent=`Retry loading`,this.retryButton.hidden=!0,this.retryButton.addEventListener(`click`,this.retryLoading),this.element.append(this.status,this.meter,this.retryButton),this.status.textContent=`Loading saved VoiceID…`,this.reveal=setTimeout(t.append.bind(t,this.element),300),n.addEventListener(`abort`,this.abort,{once:!0})}settle=()=>{clearTimeout(this.reveal),this.signal.removeEventListener(`abort`,this.abort),this.retryButton.removeEventListener(`click`,this.retryLoading)};abort=()=>{let e=new DOMException(`VoiceID preparation was cancelled.`,`AbortError`);this.cancelled.reject(e),this.retry?.reject(e)};retryLoading=()=>{this.retry?.resolve(),this.retry=null};async prepare(){this.signal.throwIfAborted(),await Promise.race([this.prepareUntilReady(),this.cancelled.promise])}async prepareUntilReady(){for(;;){this.signal.throwIfAborted(),this.retryButton.hidden=!0,this.meter.hidden=!1;try{for(let e of this.assets)await e.download(this.update.bind(this,e)),this.signal.throwIfAborted();this.preparing();for(let e of this.models)await e.prepare(),this.signal.throwIfAborted();this.ready();return}catch(e){if(this.signal.throwIfAborted(),!(e instanceof a))throw e;clearTimeout(this.reveal),this.parent.append(this.element),this.element.dataset.state=`failed`,this.meter.hidden=!0,this.status.textContent=e.message,this.retry=new m,this.retryButton.hidden=!1,this.retryButton.focus(),await this.retry.promise}}}update=(e,t)=>{switch(t.kind){case`checking_cache`:return;case`downloading`:this.received.set(e,t.received),this.element.dataset.state=`downloading`;break;case`ready`:this.received.set(e,e.size);break;default:}if(this.element.dataset.state!==`downloading`)return;let n=0;for(let e of this.received.values())n+=e;this.meter.max=this.total,this.meter.value=n,this.status.textContent=`Downloading VoiceID: ${(n/1e6).toFixed(1)} of ${(this.total/1e6).toFixed(1)} MB · ${Math.floor(n/this.total*100)}%`};preparing(){this.element.dataset.state=`preparing`,this.meter.removeAttribute(`value`),this.status.textContent=`Preparing VoiceID…`}ready(){this.element.dataset.state=`ready`,this.meter.hidden=!0,this.status.textContent=`VoiceID is ready.`}};async function z(e,t,n){let r=new R(e,t,n);try{await r.prepare()}finally{r.settle()}}const B=.2,V=D({model:j,parseEnrollment:U});function H(e){if(!Array.isArray(e)||!e.every(v))throw Error(`VoiceID template is invalid.`);let t=P(e);for(let n=0;n<e.length;n+=1)if(Math.abs(e[n]-t[n])>1e-6)throw Error(`VoiceID template is not normalized.`);return e.slice()}function U(e,t){if(e===void 0)return null;let n=C(e,`VoiceID enrollment`),r=C(n.scope,`VoiceID enrollment scope`);if(n.kind!==`browser_voiceid_enrollment_v2`||r.walletId!==t.walletId||r.authorityId!==t.authorityId||r.walletAuthMethodId!==t.walletAuthMethodId||r.deviceKeyId!==t.deviceKeyId||typeof n.generation!=`string`||!n.generation||typeof n.revision!=`number`||!Number.isSafeInteger(n.revision)||n.revision<0)throw Error(`VoiceID enrollment identity is invalid.`);if(n.model!==j)return null;let i=H(n.baseline),a={kind:`baseline`};try{let e=C(n.adaptation,`VoiceID improvements`);if(e.kind===`adapted`&&Array.isArray(e.samples)&&e.samples.length===3){let t=e.samples.map(H);G(i,t),a={kind:`adapted`,samples:t}}}catch{a={kind:`baseline`}}return{kind:`browser_voiceid_enrollment_v2`,scope:t,model:j,generation:n.generation,revision:n.revision,baseline:i,adaptation:a}}function W(e,t){let n=Array(192).fill(0);for(let e of t)for(let r=0;r<n.length;r+=1)n[r]+=e[r]/t.length;let r=P(n);for(let t=0;t<n.length;t+=1)n[t]=(1-B)*e[t]+B*r[t];return P(n)}function G(e,t){if(t.length!==3)throw Error(`Record three samples before saving voice improvements.`);for(let n of t)if(F(e,n)<.45)throw Error(`This sample differs from your original voice. Try again or re-record your enrollment.`);if(F(e,W(e,t))<.98)throw Error(`These samples differ too much from your original voice. Re-record your enrollment instead.`)}function K(e){return V.read(e)}async function q(e,t){let n=await V.readTemplate(e,t),r=n.adaptation;return{template:r.kind===`adapted`?W(n.baseline,r.samples):[...n.baseline],baseline:[...n.baseline],kind:r.kind}}async function J(){let e=await V.readImportable();if(e===void 0)return null;let t=C(e,`Previous VoiceID enrollment`);return t.kind!==`browser_voiceid_enrollment_v1`||t.model!==j?null:H(t.template)}async function Y(e){let{scope:t,signal:n}=e;switch(e.kind){case`activate`:return V.commit({kind:`activate`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,baseline:H(e.baseline)});case`import`:return V.commit({kind:`import`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation,baseline:H(e.baseline)});case`replace`:return V.commit({kind:`replace`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation,baseline:H(e.baseline)});case`improve`:return G(e.snapshot.enrollment.baseline,e.samples),V.commit({kind:`improve`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation,samples:e.samples});case`reset`:return V.commit({kind:`reset`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation});default:return X(e)}}function X(e){throw Error(`Unsupported VoiceID enrollment change.`)}async function Z(e,t,n,r){n.throwIfAborted();let i=new ne(e,t,n,r);try{await Promise.race([i.prepare(),i.result]),await i.result}finally{i.dispose()}}var ne=class{completion=new m;result=this.completion.promise;status;prompt;phrase=c(null);record;cancel;samples=[];phase=`loading`;get closed(){return this.phase===`closed`}controller=new AbortController;guardTimer;checkingGuard=!1;constructor(e,t,n,r){this.plan=t,this.signal=n,this.model=r,this.prompt=new d(e.ownerDocument,`Enroll your voice in this browser`,this.phrase),this.prompt.title.textContent=`Read aloud · 0 of 3 accepted`,this.status=this.prompt.status,this.record=this.prompt.record,this.cancel=this.prompt.cancel,this.record.textContent=`Record sample 1`,this.record.addEventListener(`click`,this.capture),this.cancel.setAttribute(`aria-label`,`Cancel enrollment`),this.cancel.addEventListener(`click`,this.cancelled),this.prompt.ready(t.kind===`improve`?`Read naturally. Your original enrollment stays unchanged.`:`Read the full phrase at your normal pace.`),this.record.disabled=!0,e.replaceChildren(this.prompt.element),n.addEventListener(`abort`,this.cancelled,{once:!0}),this.guardTimer=setInterval(this.checkGuard,250),n.aborted?this.cancelled():this.cancel.focus()}async prepare(){await z(this.prompt.progress,this.controller.signal,this.model),this.phase===`loading`&&(this.prompt.progress.replaceChildren(),this.phase=`ready`,this.record.disabled=!1,this.record.focus())}capture=()=>{this.collect()};async collect(){if(this.phase!==`ready`)return;let e=this.samples.length+1;try{u(),this.phase=`recording`,this.record.disabled=!0,this.status.textContent=`Opening microphone…`;let e=await t(this.controller.signal,this.prompt.capture);if(this.signal.aborted||this.closed){e.kind===`captured`&&e.samples.fill(0);return}if(e.kind===`insufficient_audio`){this.status.textContent=n(e.quality);return}if(this.plan.kind===`improve`&&e.quality.noise!==`normal`){e.samples.fill(0),this.status.textContent=`Use a quiet place to improve your voice enrollment.`;return}let a;try{if(await h(this.plan.scope,this.plan.guard),this.status.textContent=`Checking your voice…`,(await i(e.samples,this.phrase,this.model)).kind===`mismatch`)throw new r;a=await N(e.samples)}finally{e.samples.fill(0)}if(this.signal.aborted||this.closed){a.fill(0);return}if(this.plan.kind===`improve`&&F(this.plan.snapshot.enrollment.baseline,a)<.45)throw a.fill(0),Error(`Your voice did not match the original enrollment. To replace it, return to Manage voice and choose Record voice again.`);for(let e of this.samples)if(F(e,a)<.45)throw a.fill(0),Error(`This sample differs from the earlier samples. Use the same microphone and try again.`);if(this.samples.push(a),this.samples.length<3){this.prompt.accepted(),this.status.textContent=`Sample ${this.samples.length} accepted. Record the next sample.`,this.record.textContent=`Record sample ${this.samples.length+1}`;return}let o=Array(192).fill(0);for(let e of this.samples)for(let t=0;t<o.length;t+=1)o[t]+=e[t]/3;this.phase=`committing`,this.prompt.title.textContent=`3 of 3 accepted`,this.status.textContent=`Saving voice enrollment…`;let s=this.plan;switch(s.kind){case`activate`:await Y({kind:`activate`,scope:s.scope,guard:s.guard,snapshot:s.snapshot,baseline:P(o),signal:this.controller.signal});break;case`replace`:await Y({kind:`replace`,scope:s.scope,guard:s.guard,snapshot:s.snapshot,baseline:P(o),confirmation:s.confirmation,signal:this.controller.signal});break;case`improve`:await Y({kind:`improve`,scope:s.scope,guard:s.guard,snapshot:s.snapshot,samples:this.samples,confirmation:s.confirmation,signal:this.controller.signal});break;default:return re(s)}if(this.signal.aborted||this.closed)return;this.phase=`closed`,this.prompt.accepted(),this.status.textContent=`Voice enrollment saved.`,this.completion.resolve()}catch(e){if(!this.closed&&this.phase===`committing`){this.phase=`closed`,this.controller.abort(),this.completion.reject(E(e));return}!this.closed&&this.samples.length===3&&this.samples.pop()?.fill(0),this.closed||(this.status.textContent=e instanceof Error?e.message:`VoiceID enrollment failed.`)}finally{this.closed||(this.samples.length<e&&(this.record.textContent=`Retry sample ${e}`,this.status.textContent=`Sample ${e} was not accepted. ${this.status.textContent??``}`),this.phrase=c(this.phrase),this.prompt.setPhrase(this.phrase),this.prompt.title.textContent=`Read aloud · ${this.samples.length} of 3 accepted`,this.prompt.ready(this.status.textContent??``),this.phase=`ready`,this.record.disabled=!1)}}cancelled=()=>{this.closed||(this.phase=`closed`,this.completion.reject(Error(`VoiceID enrollment was cancelled.`)),this.controller.abort())};checkGuard=()=>{this.closed||this.checkingGuard||(this.checkingGuard=!0,this.validateGuard())};async validateGuard(){try{await h(this.plan.scope,this.plan.guard)}catch(e){this.closed||(this.phase=`closed`,this.controller.abort(),this.completion.reject(E(e)))}finally{this.checkingGuard=!1}}dispose(){this.phase=`closed`,this.controller.abort(),clearInterval(this.guardTimer),this.signal.removeEventListener(`abort`,this.cancelled),this.prompt.dispose(),this.record.removeEventListener(`click`,this.capture),this.cancel.removeEventListener(`click`,this.cancelled);for(let e of this.samples)e.fill(0)}};function re(e){throw Error(`Unsupported VoiceID enrollment capture.`)}async function Q(e,n,r,a,o){let s=await t(n,r);if(s.kind===`insufficient_audio`)return n.throwIfAborted(),s;try{n.throwIfAborted();let t=await i(s.samples,a,o),r=await N(s.samples),c;try{n.throwIfAborted();let t=await q(e,n);try{c=F(r,t.template)}finally{t.template.fill(0),t.baseline.fill(0)}}finally{r.fill(0)}return c<.45?{kind:`mismatch`,quality:s.quality}:t.kind===`matched`?{kind:`matched`}:{kind:`phrase_mismatch`}}finally{s.samples.fill(0)}}async function ie(e,t,n){u();let r=await _(n.walletId,n.walletAuthMethodId),i=await w(r);if(await K(i))await $({kind:`activation`,scope:i,owner:await x(i,`activating`)},n.signal,t.onCapture,t.phrase,e);else{let r=await x(i,`activating`);await Z(t.parent,{kind:`activate`,scope:i,guard:r,snapshot:{kind:`missing`}},n.signal,e)}n.signal.throwIfAborted();let a=await y(r);if(n.signal.aborted)throw a.fill(0),Error(`VoiceID activation was cancelled.`);return{kind:`activated`,publicKeyB64u:r.publicKeyB64u,deviceKeyId:r.deviceKeyId,factorSecret32:a}}async function ae(e,t,n){ee();let{challenge:r}=n;if(r.requestOrigin!==location.origin||r.expiresAtMs<=Date.now())throw Error(`VoiceID challenge is expired or belongs to another Wallet origin.`);let i=await S(r.walletId,r.walletAuthMethodId);if(!i||i.deviceKeyId!==r.deviceKeyId)throw Error(`VoiceID device key is unavailable in this browser.`);if(await $({kind:`active`,scope:await T(r.walletId,r.walletAuthMethodId)},n.signal,t.onCapture,t.phrase,e),n.signal.throwIfAborted(),r.expiresAtMs<=Date.now())throw Error(`VoiceID challenge expired. Start unlock again.`);let a=await crypto.subtle.sign(`Ed25519`,i.privateKey,k(r)),o=await y(i);if(n.signal.aborted||r.expiresAtMs<=Date.now())throw o.fill(0),Error(`VoiceID unlock expired or was cancelled.`);return{kind:`unlocked`,assertion:te({kind:`voiceid_device_assertion_v1`,challenge:r,signatureB64u:g(new Uint8Array(a))}),factorSecret32:o}}async function oe(e,t,n){u();let{statement:r}=n;if(r.requestOrigin!==location.origin||r.expiresAtMs<=Date.now())throw Error(`VoiceID check is expired or belongs to another Wallet origin.`);let i=await S(r.walletId,r.walletAuthMethodId);if(!i||i.deviceKeyId!==r.deviceKeyId)throw Error(`VoiceID device key is unavailable in this browser.`);if(await $({kind:`active`,scope:await T(r.walletId,r.walletAuthMethodId)},n.signal,t.onCapture,t.phrase,e),n.signal.throwIfAborted(),r.expiresAtMs<=Date.now())throw Error(`VoiceID check expired. Start again.`);let a=await crypto.subtle.sign(`Ed25519`,i.privateKey,O(r)),o=await y(i);if(n.signal.aborted||r.expiresAtMs<=Date.now())throw o.fill(0),Error(`VoiceID check expired or was cancelled.`);return{kind:`confirmed`,assertion:b({kind:`voiceid_operation_assertion_v1`,statement:r,signatureB64u:g(new Uint8Array(a))}),factorSecret32:o}}async function $(e,t,n,i,a){let o=await Q(e,t,n,i,a);switch(o.kind){case`matched`:return;case`insufficient_audio`:throw new s(o.quality);case`mismatch`:throw new p(o.quality);case`phrase_mismatch`:throw new r;default:return se(o)}}function se(e){throw Error(`Unexpected voice result: ${String(e)}`)}export{Y as a,z as c,Z as i,oe as n,J as o,ae as r,K as s,ie as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,i as t,l as n,m as r,n as i,r as a,t as o,v as s}from"./prompt-
|
|
1
|
+
import{d as e,i as t,l as n,m as r,n as i,r as a,t as o,v as s}from"./prompt-bUX1mWKl.js";import{SeamsWordmark as c,VOICE_ID_HOST_API_VERSION as l,WorkerDeferred as u,authMenuSuccessCopy as d,backIcon as f,createCspStylesheetManager as p,createWalletIframeSurfaceMeasurementReporter as m,getDefaultCspNonce as h,toError as g}from"../voiceid-host.js";const _=new WeakMap;var v=class{footer;constructor(e,t){this.prompt=t;let n=e.ownerDocument,r=_.get(n);r||(r=p({doc:n,baseCss:`
|
|
2
2
|
.seams-voiceid-activation-surface.seams-voiceid-unlock {
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
overflow: hidden;
|
|
@@ -78,4 +78,4 @@ import{d as e,i as t,l as n,m as r,n as i,r as a,t as o,v as s}from"./prompt-BMA
|
|
|
78
78
|
color: var(--seams-colors-textPrimary, #eff2f3);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
`,nonce:h}),_.set(n,r)),r.ensureBase(),e.classList.add(`seams-voiceid-unlock`);let o=n.createElement(`div`);o.className=`seams-voiceid-unlock-header`,t.cancel.className=`seams-voiceid-unlock-back`,t.cancel.setAttribute(`aria-label`,`Back`),t.cancel.replaceChildren(),i(f(),t.cancel),o.append(t.cancel),e.prepend(o),this.footer=n.createElement(`div`),this.footer.className=`seams-voiceid-unlock-footer`,i([a(`span`,null,`Secured by`),` `,a(c,{})],this.footer),e.append(this.footer)}succeed(){let e=this.prompt.cancel;return e.animate([{opacity:1},{opacity:0}],{duration:150,easing:`ease-in`,fill:`forwards`}),{top:e.getBoundingClientRect().top,bottom:this.footer.getBoundingClientRect().top}}dispose(){i(null,this.prompt.cancel),i(null,this.footer)}};const y={activation:`Activate VoiceID`,unlock:`Unlock with VoiceID`,export:`Export keys with VoiceID`};var b=class{result;completion=new u;controller=new AbortController;element;activateButton;cancelButton;status;prompt;unlockFrame;autoStartUnlock;unlockSuccess;unmountCapture;measurement;phrase=r(null);state={kind:`preparing`};settlement=`closed`;expiryTimer=null;constructor(e,t,n,r,i){this.unlockSuccess=r;let a=y[t],s=document.getElementById(`root`)??document.body;if(!s)throw Error(`Wallet activation surface has no mount root.`);this.element=document.createElement(`section`),this.element.className=`seams-wallet-ui seams-auth-method-activation-surface seams-voiceid-activation-surface`,this.element.setAttribute(`role`,`dialog`),this.element.setAttribute(`aria-modal`,`true`),this.element.setAttribute(`aria-label`,a);let c=t===`unlock`&&r===`skip`&&i!==void 0;this.prompt=new o(document,a,this.phrase,c?`segments`:`ring`),this.element.append(this.prompt.element),this.unlockFrame=t===`unlock`&&!c?new v(this.element,this.prompt):null,this.autoStartUnlock=t===`unlock`&&i!==void 0,c&&(this.element.classList.add(`seams-voiceid-in-card`),this.prompt.cancel.hidden=!0),this.status=this.prompt.status,this.status.textContent=`Loading VoiceID…`,this.prompt.title.textContent=`VoiceID`,this.element.dataset.preparation=`loading`,this.activateButton=this.prompt.record,this.activateButton.textContent=a,this.activateButton.disabled=!0,this.activateButton.hidden=this.autoStartUnlock,this.activateButton.addEventListener(`click`,this.begin),this.cancelButton=this.prompt.cancel,this.cancelButton.addEventListener(`click`,this.cancel),this.element.addEventListener(`cancel`,this.cancel),this.unmountCapture=i?i(this.element):null,i||s.appendChild(this.element),this.measurement=!i&&n.kind===`wallet_iframe`?m({kind:`request_surface`,element:this.element,requestId:n.requestId,postMeasurement:n.postMeasurement}):null,this.cancelButton.focus(),this.result=this.completion.promise,this.initialize(e)}dispose(){this.measurement?.disconnect(),this.expiryTimer!==null&&clearTimeout(this.expiryTimer),this.element.removeEventListener(`cancel`,this.cancel),this.activateButton.removeEventListener(`click`,this.begin),this.cancelButton.removeEventListener(`click`,this.cancel),this.unlockFrame?.dispose(),this.prompt.dispose(),this.unmountCapture?this.unmountCapture(this.settlement):this.element.remove()}async initialize(e){try{await new Promise(C),this.controller.signal.throwIfAborted();let t=await e(this.controller.signal,{parent:this.element,progress:this.prompt.progress});if(this.state.kind===`closed`)return;if(t.kind===`management`){this.element.setAttribute(`aria-label`,`Manage voice`),this.element.dataset.preparation=`ready`,this.state={kind:`capturing`};let e=await t.action(this.controller.signal);this.controller.signal.throwIfAborted(),this.state={kind:`closed`},this.completion.resolve(e);return}let n=t.expiresAtMs===null?null:t.expiresAtMs-Date.now();if(n!==null&&n<=0)throw Error(`VoiceID challenge expired. Start unlock again.`);this.state={kind:`ready`,capture:t},this.expiryTimer=n===null?null:setTimeout(this.expire,n);for(let e of this.element.querySelectorAll(`.seams-voiceid-model-download`))e.remove();this.element.dataset.preparation=`ready`,this.prompt.title.textContent=`Read aloud`,this.status.textContent=`Read naturally, then pause.`,this.activateButton.disabled=!1,this.autoStartUnlock?this.begin():this.activateButton.focus()}catch(e){if(this.state.kind===`closed`)return;this.state={kind:`closed`},this.completion.reject(g(e))}}begin=()=>{if(this.state.kind!==`ready`)return;let e=this.state.capture;this.state={kind:`capturing`},this.perform(e)};async perform(i){this.activateButton.disabled=!0,this.status.textContent=`Opening microphone…`;try{let e=await i.action(this.controller.signal,this.prompt.capture,this.phrase);if(this.state.kind===`closed`)return;this.unlockFrame&&this.unlockSuccess===`show`&&await this.showUnlocked(this.unlockFrame),this.settlement=`succeeded`,this.state={kind:`closed`},this.completion.resolve(e)}catch(a){if(this.state.kind===`closed`)return;if(a instanceof t||a instanceof e||a instanceof n||a instanceof s){if(i.expiresAtMs!==null&&Date.now()>=i.expiresAtMs){this.expire();return}let e=this.phrase;this.phrase=r(e),this.prompt.setPhrase(this.phrase),this.state={kind:`ready`,capture:i},this.activateButton.hidden=!1,this.activateButton.textContent=`Try again`,this.prompt.ready(a.message),this.activateButton.focus();return}this.state={kind:`closed`},this.completion.reject(g(a))}}async showUnlocked(e){this.state={kind:`succeeding`},this.settlement=`succeeded`,this.expiryTimer!==null&&clearTimeout(this.expiryTimer),this.expiryTimer=null,this.cancelButton.disabled=!0;let t=performance.now(),n=d(`authenticated`);await this.prompt.succeed(n.headline,n.message,e.succeed());let r=Math.max(0,1300-(performance.now()-t));await this.element.animate([{opacity:1},{opacity:1,offset:r/(r+240),easing:`ease-in`},{opacity:0}],{duration:r+240,fill:`forwards`}).finished}cancel=()=>{this.state.kind===`closed`||this.state.kind===`succeeding`||(this.state={kind:`closed`},this.controller.abort(),this.completion.reject(new x))};expire=()=>{this.state.kind===`closed`||this.state.kind===`succeeding`||(this.state={kind:`closed`},this.controller.abort(),this.completion.reject(Error(`VoiceID challenge expired. Start unlock again.`)))}},x=class extends Error{constructor(){super(`VoiceID capture was cancelled.`),this.name=`VoiceIdCaptureCancelledError`}};async function S(e){let t=new b(e.prepare,e.purpose,e.measurement,e.unlockSuccess??`show`,e.mountCapture);try{return await t.result}finally{t.dispose()}}function C(e){requestAnimationFrame(w.bind(null,e))}function w(e){setTimeout(e,0)}const T=8;if(l!==8)throw Error(`VoiceID requires a matching Wallet host API.`);function E(e){return{unlock:k.bind(null,e),activate:j.bind(null,e),confirmOperation:D.bind(null,e)}}function D(e,t){return S({purpose:`export`,measurement:t.surfaceMeasurementBinding,prepare:O.bind(null,e,t)})}async function O(e,t,n,r){let i=await import(`./operation-
|
|
81
|
+
`,nonce:h}),_.set(n,r)),r.ensureBase(),e.classList.add(`seams-voiceid-unlock`);let o=n.createElement(`div`);o.className=`seams-voiceid-unlock-header`,t.cancel.className=`seams-voiceid-unlock-back`,t.cancel.setAttribute(`aria-label`,`Back`),t.cancel.replaceChildren(),i(f(),t.cancel),o.append(t.cancel),e.prepend(o),this.footer=n.createElement(`div`),this.footer.className=`seams-voiceid-unlock-footer`,i([a(`span`,null,`Secured by`),` `,a(c,{})],this.footer),e.append(this.footer)}succeed(){let e=this.prompt.cancel;return e.animate([{opacity:1},{opacity:0}],{duration:150,easing:`ease-in`,fill:`forwards`}),{top:e.getBoundingClientRect().top,bottom:this.footer.getBoundingClientRect().top}}dispose(){i(null,this.prompt.cancel),i(null,this.footer)}};const y={activation:`Activate VoiceID`,unlock:`Unlock with VoiceID`,export:`Export keys with VoiceID`};var b=class{result;completion=new u;controller=new AbortController;element;activateButton;cancelButton;status;prompt;unlockFrame;autoStartUnlock;unlockSuccess;unmountCapture;measurement;phrase=r(null);state={kind:`preparing`};settlement=`closed`;expiryTimer=null;constructor(e,t,n,r,i){this.unlockSuccess=r;let a=y[t],s=document.getElementById(`root`)??document.body;if(!s)throw Error(`Wallet activation surface has no mount root.`);this.element=document.createElement(`section`),this.element.className=`seams-wallet-ui seams-auth-method-activation-surface seams-voiceid-activation-surface`,this.element.setAttribute(`role`,`dialog`),this.element.setAttribute(`aria-modal`,`true`),this.element.setAttribute(`aria-label`,a);let c=t===`unlock`&&r===`skip`&&i!==void 0;this.prompt=new o(document,a,this.phrase,c?`segments`:`ring`),this.element.append(this.prompt.element),this.unlockFrame=t===`unlock`&&!c?new v(this.element,this.prompt):null,this.autoStartUnlock=t===`unlock`&&i!==void 0,c&&(this.element.classList.add(`seams-voiceid-in-card`),this.prompt.cancel.hidden=!0),this.status=this.prompt.status,this.status.textContent=`Loading VoiceID…`,this.prompt.title.textContent=`VoiceID`,this.element.dataset.preparation=`loading`,this.activateButton=this.prompt.record,this.activateButton.textContent=a,this.activateButton.disabled=!0,this.activateButton.hidden=this.autoStartUnlock,this.activateButton.addEventListener(`click`,this.begin),this.cancelButton=this.prompt.cancel,this.cancelButton.addEventListener(`click`,this.cancel),this.element.addEventListener(`cancel`,this.cancel),this.unmountCapture=i?i(this.element):null,i||s.appendChild(this.element),this.measurement=!i&&n.kind===`wallet_iframe`?m({kind:`request_surface`,element:this.element,requestId:n.requestId,postMeasurement:n.postMeasurement}):null,this.cancelButton.focus(),this.result=this.completion.promise,this.initialize(e)}dispose(){this.measurement?.disconnect(),this.expiryTimer!==null&&clearTimeout(this.expiryTimer),this.element.removeEventListener(`cancel`,this.cancel),this.activateButton.removeEventListener(`click`,this.begin),this.cancelButton.removeEventListener(`click`,this.cancel),this.unlockFrame?.dispose(),this.prompt.dispose(),this.unmountCapture?this.unmountCapture(this.settlement):this.element.remove()}async initialize(e){try{await new Promise(C),this.controller.signal.throwIfAborted();let t=await e(this.controller.signal,{parent:this.element,progress:this.prompt.progress});if(this.state.kind===`closed`)return;if(t.kind===`management`){this.element.setAttribute(`aria-label`,`Manage voice`),this.element.dataset.preparation=`ready`,this.state={kind:`capturing`};let e=await t.action(this.controller.signal);this.controller.signal.throwIfAborted(),this.state={kind:`closed`},this.completion.resolve(e);return}let n=t.expiresAtMs===null?null:t.expiresAtMs-Date.now();if(n!==null&&n<=0)throw Error(`VoiceID challenge expired. Start unlock again.`);this.state={kind:`ready`,capture:t},this.expiryTimer=n===null?null:setTimeout(this.expire,n);for(let e of this.element.querySelectorAll(`.seams-voiceid-model-download`))e.remove();this.element.dataset.preparation=`ready`,this.prompt.title.textContent=`Read aloud`,this.status.textContent=`Read naturally, then pause.`,this.activateButton.disabled=!1,this.autoStartUnlock?this.begin():this.activateButton.focus()}catch(e){if(this.state.kind===`closed`)return;this.state={kind:`closed`},this.completion.reject(g(e))}}begin=()=>{if(this.state.kind!==`ready`)return;let e=this.state.capture;this.state={kind:`capturing`},this.perform(e)};async perform(i){this.activateButton.disabled=!0,this.status.textContent=`Opening microphone…`;try{let e=await i.action(this.controller.signal,this.prompt.capture,this.phrase);if(this.state.kind===`closed`)return;this.unlockFrame&&this.unlockSuccess===`show`&&await this.showUnlocked(this.unlockFrame),this.settlement=`succeeded`,this.state={kind:`closed`},this.completion.resolve(e)}catch(a){if(this.state.kind===`closed`)return;if(a instanceof t||a instanceof e||a instanceof n||a instanceof s){if(i.expiresAtMs!==null&&Date.now()>=i.expiresAtMs){this.expire();return}let e=this.phrase;this.phrase=r(e),this.prompt.setPhrase(this.phrase),this.state={kind:`ready`,capture:i},this.activateButton.hidden=!1,this.activateButton.textContent=`Try again`,this.prompt.ready(a.message),this.activateButton.focus();return}this.state={kind:`closed`},this.completion.reject(g(a))}}async showUnlocked(e){this.state={kind:`succeeding`},this.settlement=`succeeded`,this.expiryTimer!==null&&clearTimeout(this.expiryTimer),this.expiryTimer=null,this.cancelButton.disabled=!0;let t=performance.now(),n=d(`authenticated`);await this.prompt.succeed(n.headline,n.message,e.succeed());let r=Math.max(0,1300-(performance.now()-t));await this.element.animate([{opacity:1},{opacity:1,offset:r/(r+240),easing:`ease-in`},{opacity:0}],{duration:r+240,fill:`forwards`}).finished}cancel=()=>{this.state.kind===`closed`||this.state.kind===`succeeding`||(this.state={kind:`closed`},this.controller.abort(),this.completion.reject(new x))};expire=()=>{this.state.kind===`closed`||this.state.kind===`succeeding`||(this.state={kind:`closed`},this.controller.abort(),this.completion.reject(Error(`VoiceID challenge expired. Start unlock again.`)))}},x=class extends Error{constructor(){super(`VoiceID capture was cancelled.`),this.name=`VoiceIdCaptureCancelledError`}};async function S(e){let t=new b(e.prepare,e.purpose,e.measurement,e.unlockSuccess??`show`,e.mountCapture);try{return await t.result}finally{t.dispose()}}function C(e){requestAnimationFrame(w.bind(null,e))}function w(e){setTimeout(e,0)}const T=8;if(l!==8)throw Error(`VoiceID requires a matching Wallet host API.`);function E(e){return{unlock:k.bind(null,e),activate:j.bind(null,e),confirmOperation:D.bind(null,e)}}function D(e,t){return S({purpose:`export`,measurement:t.surfaceMeasurementBinding,prepare:O.bind(null,e,t)})}async function O(e,t,n,r){let i=await import(`./operation-B-Hwg9al.js`);return n.throwIfAborted(),i.prepareOperationSurface(t,n,r.progress,e)}function k(e,t){return S({purpose:`unlock`,unlockSuccess:t.purpose===`step_up`?`skip`:`show`,measurement:t.surfaceMeasurementBinding,mountCapture:t.mountCapture,prepare:A.bind(null,e,t)})}async function A(e,t,n,r){let i=await import(`./unlock-Zmv1aA7R.js`);return n.throwIfAborted(),i.prepareUnlockSurface(t,n,r.progress,e)}async function j(e,t){try{return await S({purpose:`activation`,measurement:t.surfaceMeasurementBinding,prepare:M.bind(null,e,t)})}catch(e){if(e instanceof x)return{kind:`cancelled`};throw e}}async function M(e,t,n,r){let i=await import(`./addVoiceId-DgFmNO4V.js`);return n.throwIfAborted(),i.prepareActivationSurface(t,n,r.parent,e)}export{E as createVoiceIdHostPlugin,T as hostApiVersion};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./prompt-
|
|
1
|
+
import"./prompt-bUX1mWKl.js";import{c as e,n as t,s as n}from"./deviceBridge-Cqb5arWN.js";async function r(t,r,a,o){let s=await t.prepareOperation(r);if(!await n(s.scope))throw Error(`Open Manage voice to import or record your enrollment on this device.`);await e(a,r,o),r.throwIfAborted();let c=await s.challenge(r);return r.throwIfAborted(),{kind:`recording`,expiresAtMs:c.expiresAtMs,action:i.bind(null,o,c)}}function i(e,n,r,i,a){return n.complete(t.bind(null,e,{onCapture:i,phrase:a}),r)}export{r as prepareOperationSurface};
|
|
@@ -1,4 +1,4 @@
|
|
|
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: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]&>(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(`,
|
|
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]&>(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
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
3
|
${t}
|
|
4
4
|
position: absolute;
|
|
@@ -510,6 +510,7 @@ ${Pe.split(`{id}`).join(z)}`:en}),J(`div`,{...Le,ref:an,"data-voice-beam":z,"dat
|
|
|
510
510
|
max-width: 21rem;
|
|
511
511
|
align-self: center;
|
|
512
512
|
margin: 0 auto;
|
|
513
|
+
transition: opacity 180ms var(--seams-ease-out, cubic-bezier(0.23, 1, 0.32, 1));
|
|
513
514
|
}
|
|
514
515
|
.seams-voiceid-ribbon {
|
|
515
516
|
display: block;
|
|
@@ -597,25 +598,41 @@ ${Pe.split(`{id}`).join(z)}`:en}),J(`div`,{...Le,ref:an,"data-voice-beam":z,"dat
|
|
|
597
598
|
.seams-voiceid-prompt [hidden] {
|
|
598
599
|
display: none !important;
|
|
599
600
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
.seams-voiceid-
|
|
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;
|
|
605
613
|
appearance: none;
|
|
606
614
|
display: block;
|
|
607
|
-
width: 100
|
|
608
|
-
height:
|
|
615
|
+
width: min(100%, 308px);
|
|
616
|
+
height: 6px;
|
|
609
617
|
border: 0;
|
|
610
|
-
border-radius:
|
|
618
|
+
border-radius: 999px;
|
|
611
619
|
overflow: hidden;
|
|
612
620
|
background: var(--seams-colors-surface, #202b31);
|
|
613
|
-
|
|
621
|
+
color: var(--seams-colors-textPrimary, #eff2f3);
|
|
614
622
|
}
|
|
615
|
-
.seams-voiceid-model-download p { margin: 0 0 0.75rem; color: var(--seams-colors-textSecondary, #9cabb3); font-variant-numeric: tabular-nums; }
|
|
616
623
|
.seams-voiceid-model-download progress::-webkit-progress-bar { background: var(--seams-colors-surface, #202b31); }
|
|
617
|
-
.seams-voiceid-model-download progress::-webkit-progress-value { background: var(--seams-colors-textPrimary, #eff2f3); border-radius:
|
|
618
|
-
.seams-voiceid-model-download progress::-moz-progress-bar { background: var(--seams-colors-textPrimary, #eff2f3); }
|
|
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; }
|
|
619
636
|
@media (hover: hover) and (pointer: fine) {
|
|
620
637
|
.seams-voiceid-close:hover { background: var(--seams-colors-surface, #202b31); }
|
|
621
638
|
.seams-voiceid-primary:hover:not(:disabled) { opacity: 0.9; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./prompt-
|
|
1
|
+
import{s as e}from"./prompt-bUX1mWKl.js";import{c as t,r as n,s as r}from"./deviceBridge-Cqb5arWN.js";async function i(e,n,i,o){let s=await e.prepareUnlock(n),c=s.scope;if(!await r(c))throw Error(`Unlock with a passkey, then open Manage voice to import or record your enrollment.`);await t(i,n,o),n.throwIfAborted();let l=await s.challenge(n),u={challenge:l,initiation:e.mountCapture?`hosted_menu`:`sdk_request`};return n.throwIfAborted(),{kind:`recording`,expiresAtMs:l.expiresAtMs,action:a.bind(null,o,u)}}async function a(t,r,i,a,s){switch(r.initiation){case`sdk_request`:e();break;case`hosted_menu`:break;default:return o(r.initiation)}return r.challenge.complete(n.bind(null,t,{onCapture:a,phrase:s}),i)}function o(e){throw Error(`Unexpected VoiceID initiation: ${String(e)}`)}export{i as prepareUnlockSurface};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seams/voiceid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Optional browser VoiceID authentication for Seams Wallet",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"voice-glow": "0.2.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@seams/wallet": "0.
|
|
53
|
+
"@seams/wallet": "0.49.0",
|
|
54
54
|
"react": ">=19.0.0",
|
|
55
55
|
"react-dom": ">=19.0.0"
|
|
56
56
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,m as c,o as ee,p as l,s as u,t as d,u as f,v as p}from"./prompt-BMATEY7H.js";import{WorkerDeferred as m,assertVoiceOwner as h,base64UrlEncode as g,createBrowserVoiceDevice as _,isFiniteNumber as v,openBrowserVoiceFactor as y,parseVoiceIdDeviceAssertion as te,parseVoiceIdOperationAssertion as b,prepareVoiceOwner as x,readBrowserVoiceDevice as S,requireRecord as C,resolveActivatingVoiceEnrollmentScope as w,resolveVoiceEnrollmentScope as T,toError as E,voiceEnrollmentStorage as D,voiceIdOperationStatementBytes as O,voiceIdWalletSessionChallengeBytes as k}from"../voiceid-host.js";const A=`e04dd7a6a1e23fc7b89e47682ea9d0a3946cf7bc59d07922c3db3efc52ae4269`,j=`redimnet-b1:${A}`,M=new o({path:`/sdk/voiceid/redimnet-b1.onnx`,sha256:A,bytes:8859593,label:`Speaker verification`});async function N(e){let t=await M.prepare(),n=new(await(import(`./ort.wasm.bundle.min-7y-hlRN8.js`))).Tensor(`float32`,e,[1,e.length]);try{let e=await t.run({samples:n});try{let t=e.embedding;if(!t||!(t.data instanceof Float32Array))throw Error(`VoiceID model returned an invalid embedding.`);return P(Array.from(t.data))}finally{for(let t of Object.values(e))t.dispose()}}finally{n.dispose()}}function P(e){if(e.length!==192)throw Error(`VoiceID template dimensions are invalid.`);let t=0;for(let n of e){if(!Number.isFinite(n))throw Error(`VoiceID template is invalid.`);t+=n*n}if(t<1e-12)throw Error(`VoiceID template contains no signal.`);let n=Math.sqrt(t),r=[];for(let t of e)r.push(t/n);return r}function F(e,t){if(e.length!==192||t.length!==192)throw Error(`VoiceID templates are incompatible.`);let n=0;for(let r=0;r<e.length;r+=1)n+=e[r]*t[r];return n}function I(e){return e.asset}function L(e,t){return e+t.size}var R=class{element=document.createElement(`section`);status=document.createElement(`p`);meter=document.createElement(`progress`);retryButton=document.createElement(`button`);retry=null;cancelled=new m;reveal;received=new Map;models;assets;total;constructor(t,n,r){this.parent=t,this.signal=n,this.models=[M,l(r),f],this.assets=[e,...this.models.map(I)],this.total=this.assets.reduce(L,0),this.element.className=`seams-voiceid-model-download`,this.status.setAttribute(`role`,`status`),this.status.setAttribute(`aria-live`,`polite`),this.meter.setAttribute(`aria-label`,`VoiceID download`),this.meter.style.width=`100%`,this.retryButton.type=`button`,this.retryButton.className=`seams-voiceid-primary`,this.retryButton.textContent=`Retry loading`,this.retryButton.hidden=!0,this.retryButton.addEventListener(`click`,this.retryLoading),this.element.append(this.status,this.meter,this.retryButton),this.status.textContent=`Loading saved VoiceID…`,this.reveal=setTimeout(t.append.bind(t,this.element),300),n.addEventListener(`abort`,this.abort,{once:!0})}settle=()=>{clearTimeout(this.reveal),this.signal.removeEventListener(`abort`,this.abort),this.retryButton.removeEventListener(`click`,this.retryLoading)};abort=()=>{let e=new DOMException(`VoiceID preparation was cancelled.`,`AbortError`);this.cancelled.reject(e),this.retry?.reject(e)};retryLoading=()=>{this.retry?.resolve(),this.retry=null};async prepare(){this.signal.throwIfAborted(),await Promise.race([this.prepareUntilReady(),this.cancelled.promise])}async prepareUntilReady(){for(;;){this.signal.throwIfAborted(),this.retryButton.hidden=!0,this.meter.hidden=!1;try{for(let e of this.assets)await e.download(this.update.bind(this,e)),this.signal.throwIfAborted();this.preparing();for(let e of this.models)await e.prepare(),this.signal.throwIfAborted();this.ready();return}catch(e){if(this.signal.throwIfAborted(),!(e instanceof a))throw e;clearTimeout(this.reveal),this.parent.append(this.element),this.element.dataset.state=`failed`,this.meter.hidden=!0,this.status.textContent=e.message,this.retry=new m,this.retryButton.hidden=!1,this.retryButton.focus(),await this.retry.promise}}}update=(e,t)=>{switch(t.kind){case`checking_cache`:return;case`downloading`:this.received.set(e,t.received),this.element.dataset.state=`downloading`;break;case`ready`:this.received.set(e,e.size);break;default:}if(this.element.dataset.state!==`downloading`)return;let n=0;for(let e of this.received.values())n+=e;this.meter.max=this.total,this.meter.value=n,this.status.textContent=`Downloading VoiceID: ${(n/1e6).toFixed(1)} of ${(this.total/1e6).toFixed(1)} MB · ${Math.floor(n/this.total*100)}%`};preparing(){this.element.dataset.state=`preparing`,this.meter.removeAttribute(`value`),this.status.textContent=`Preparing VoiceID…`}ready(){this.element.dataset.state=`ready`,this.meter.hidden=!0,this.status.textContent=`VoiceID is ready.`}};async function z(e,t,n){let r=new R(e,t,n);try{await r.prepare()}finally{r.settle()}}const B=.2,V=D({model:j,parseEnrollment:U});function H(e){if(!Array.isArray(e)||!e.every(v))throw Error(`VoiceID template is invalid.`);let t=P(e);for(let n=0;n<e.length;n+=1)if(Math.abs(e[n]-t[n])>1e-6)throw Error(`VoiceID template is not normalized.`);return e.slice()}function U(e,t){if(e===void 0)return null;let n=C(e,`VoiceID enrollment`),r=C(n.scope,`VoiceID enrollment scope`);if(n.kind!==`browser_voiceid_enrollment_v2`||r.walletId!==t.walletId||r.authorityId!==t.authorityId||r.walletAuthMethodId!==t.walletAuthMethodId||r.deviceKeyId!==t.deviceKeyId||typeof n.generation!=`string`||!n.generation||typeof n.revision!=`number`||!Number.isSafeInteger(n.revision)||n.revision<0)throw Error(`VoiceID enrollment identity is invalid.`);if(n.model!==j)return null;let i=H(n.baseline),a={kind:`baseline`};try{let e=C(n.adaptation,`VoiceID improvements`);if(e.kind===`adapted`&&Array.isArray(e.samples)&&e.samples.length===3){let t=e.samples.map(H);G(i,t),a={kind:`adapted`,samples:t}}}catch{a={kind:`baseline`}}return{kind:`browser_voiceid_enrollment_v2`,scope:t,model:j,generation:n.generation,revision:n.revision,baseline:i,adaptation:a}}function W(e,t){let n=Array(192).fill(0);for(let e of t)for(let r=0;r<n.length;r+=1)n[r]+=e[r]/t.length;let r=P(n);for(let t=0;t<n.length;t+=1)n[t]=(1-B)*e[t]+B*r[t];return P(n)}function G(e,t){if(t.length!==3)throw Error(`Record three samples before saving voice improvements.`);for(let n of t)if(F(e,n)<.45)throw Error(`This sample differs from your original voice. Try again or re-record your enrollment.`);if(F(e,W(e,t))<.98)throw Error(`These samples differ too much from your original voice. Re-record your enrollment instead.`)}function K(e){return V.read(e)}async function q(e,t){let n=await V.readTemplate(e,t),r=n.adaptation;return{template:r.kind===`adapted`?W(n.baseline,r.samples):[...n.baseline],baseline:[...n.baseline],kind:r.kind}}async function J(){let e=await V.readImportable();if(e===void 0)return null;let t=C(e,`Previous VoiceID enrollment`);return t.kind!==`browser_voiceid_enrollment_v1`||t.model!==j?null:H(t.template)}async function Y(e){let{scope:t,signal:n}=e;switch(e.kind){case`activate`:return V.commit({kind:`activate`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,baseline:H(e.baseline)});case`import`:return V.commit({kind:`import`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation,baseline:H(e.baseline)});case`replace`:return V.commit({kind:`replace`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation,baseline:H(e.baseline)});case`improve`:return G(e.snapshot.enrollment.baseline,e.samples),V.commit({kind:`improve`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation,samples:e.samples});case`reset`:return V.commit({kind:`reset`,scope:t,signal:n,guard:e.guard,snapshot:e.snapshot,confirmation:e.confirmation});default:return X(e)}}function X(e){throw Error(`Unsupported VoiceID enrollment change.`)}async function Z(e,t,n,r){await z(e,n,r),n.throwIfAborted();let i=new ne(e,t,n,r);try{await i.result}finally{i.dispose()}}var ne=class{completion=new m;result=this.completion.promise;status;prompt;phrase=c(null);record;cancel;samples=[];phase=`ready`;get closed(){return this.phase===`closed`}controller=new AbortController;guardTimer;checkingGuard=!1;constructor(e,t,n,r){this.plan=t,this.signal=n,this.model=r,this.prompt=new d(e.ownerDocument,`Enroll your voice in this browser`,this.phrase),this.prompt.title.textContent=`Read aloud · 0 of 3 accepted`,this.status=this.prompt.status,this.record=this.prompt.record,this.cancel=this.prompt.cancel,this.record.textContent=`Record sample 1`,this.record.addEventListener(`click`,this.capture),this.cancel.setAttribute(`aria-label`,`Cancel enrollment`),this.cancel.addEventListener(`click`,this.cancelled),this.prompt.ready(t.kind===`improve`?`Read naturally. Your original enrollment stays unchanged.`:`Read the full phrase at your normal pace.`),e.replaceChildren(this.prompt.element),n.addEventListener(`abort`,this.cancelled,{once:!0}),this.guardTimer=setInterval(this.checkGuard,250),n.aborted?this.cancelled():this.record.focus()}capture=()=>{this.collect()};async collect(){if(this.phase!==`ready`)return;let e=this.samples.length+1;try{u(),this.phase=`recording`,this.record.disabled=!0,this.status.textContent=`Opening microphone…`;let e=await t(this.controller.signal,this.prompt.capture);if(this.signal.aborted||this.closed){e.kind===`captured`&&e.samples.fill(0);return}if(e.kind===`insufficient_audio`){this.status.textContent=n(e.quality);return}if(this.plan.kind===`improve`&&e.quality.noise!==`normal`){e.samples.fill(0),this.status.textContent=`Use a quiet place to improve your voice enrollment.`;return}let a;try{if(await h(this.plan.scope,this.plan.guard),this.status.textContent=`Checking your voice…`,(await i(e.samples,this.phrase,this.model)).kind===`mismatch`)throw new r;a=await N(e.samples)}finally{e.samples.fill(0)}if(this.signal.aborted||this.closed){a.fill(0);return}if(this.plan.kind===`improve`&&F(this.plan.snapshot.enrollment.baseline,a)<.45)throw a.fill(0),Error(`Your voice did not match the original enrollment. To replace it, return to Manage voice and choose Record voice again.`);for(let e of this.samples)if(F(e,a)<.45)throw a.fill(0),Error(`This sample differs from the earlier samples. Use the same microphone and try again.`);if(this.samples.push(a),this.samples.length<3){this.prompt.accepted(),this.status.textContent=`Sample ${this.samples.length} accepted. Record the next sample.`,this.record.textContent=`Record sample ${this.samples.length+1}`;return}let o=Array(192).fill(0);for(let e of this.samples)for(let t=0;t<o.length;t+=1)o[t]+=e[t]/3;this.phase=`committing`,this.prompt.title.textContent=`3 of 3 accepted`,this.status.textContent=`Saving voice enrollment…`;let s=this.plan;switch(s.kind){case`activate`:await Y({kind:`activate`,scope:s.scope,guard:s.guard,snapshot:s.snapshot,baseline:P(o),signal:this.controller.signal});break;case`replace`:await Y({kind:`replace`,scope:s.scope,guard:s.guard,snapshot:s.snapshot,baseline:P(o),confirmation:s.confirmation,signal:this.controller.signal});break;case`improve`:await Y({kind:`improve`,scope:s.scope,guard:s.guard,snapshot:s.snapshot,samples:this.samples,confirmation:s.confirmation,signal:this.controller.signal});break;default:return re(s)}if(this.signal.aborted||this.closed)return;this.phase=`closed`,this.prompt.accepted(),this.status.textContent=`Voice enrollment saved.`,this.completion.resolve()}catch(e){if(!this.closed&&this.phase===`committing`){this.phase=`closed`,this.controller.abort(),this.completion.reject(E(e));return}!this.closed&&this.samples.length===3&&this.samples.pop()?.fill(0),this.closed||(this.status.textContent=e instanceof Error?e.message:`VoiceID enrollment failed.`)}finally{this.closed||(this.samples.length<e&&(this.record.textContent=`Retry sample ${e}`,this.status.textContent=`Sample ${e} was not accepted. ${this.status.textContent??``}`),this.phrase=c(this.phrase),this.prompt.setPhrase(this.phrase),this.prompt.title.textContent=`Read aloud · ${this.samples.length} of 3 accepted`,this.prompt.ready(this.status.textContent??``),this.phase=`ready`,this.record.disabled=!1)}}cancelled=()=>{this.closed||(this.phase=`closed`,this.controller.abort(),this.completion.reject(Error(`VoiceID enrollment was cancelled.`)))};checkGuard=()=>{this.closed||this.checkingGuard||(this.checkingGuard=!0,this.validateGuard())};async validateGuard(){try{await h(this.plan.scope,this.plan.guard)}catch(e){this.closed||(this.phase=`closed`,this.controller.abort(),this.completion.reject(E(e)))}finally{this.checkingGuard=!1}}dispose(){this.phase=`closed`,this.controller.abort(),clearInterval(this.guardTimer),this.signal.removeEventListener(`abort`,this.cancelled),this.prompt.dispose(),this.record.removeEventListener(`click`,this.capture),this.cancel.removeEventListener(`click`,this.cancelled);for(let e of this.samples)e.fill(0)}};function re(e){throw Error(`Unsupported VoiceID enrollment capture.`)}async function Q(e,n,r,a,o){let s=await t(n,r);if(s.kind===`insufficient_audio`)return n.throwIfAborted(),s;try{n.throwIfAborted();let t=await i(s.samples,a,o),r=await N(s.samples),c;try{n.throwIfAborted();let t=await q(e,n);try{c=F(r,t.template)}finally{t.template.fill(0),t.baseline.fill(0)}}finally{r.fill(0)}return c<.45?{kind:`mismatch`,quality:s.quality}:t.kind===`matched`?{kind:`matched`}:{kind:`phrase_mismatch`}}finally{s.samples.fill(0)}}async function ie(e,t,n){u();let r=await _(n.walletId,n.walletAuthMethodId),i=await w(r);if(await K(i))await $({kind:`activation`,scope:i,owner:await x(i,`activating`)},n.signal,t.onCapture,t.phrase,e);else{let r=await x(i,`activating`);await Z(t.parent,{kind:`activate`,scope:i,guard:r,snapshot:{kind:`missing`}},n.signal,e)}n.signal.throwIfAborted();let a=await y(r);if(n.signal.aborted)throw a.fill(0),Error(`VoiceID activation was cancelled.`);return{kind:`activated`,publicKeyB64u:r.publicKeyB64u,deviceKeyId:r.deviceKeyId,factorSecret32:a}}async function ae(e,t,n){ee();let{challenge:r}=n;if(r.requestOrigin!==location.origin||r.expiresAtMs<=Date.now())throw Error(`VoiceID challenge is expired or belongs to another Wallet origin.`);let i=await S(r.walletId,r.walletAuthMethodId);if(!i||i.deviceKeyId!==r.deviceKeyId)throw Error(`VoiceID device key is unavailable in this browser.`);if(await $({kind:`active`,scope:await T(r.walletId,r.walletAuthMethodId)},n.signal,t.onCapture,t.phrase,e),n.signal.throwIfAborted(),r.expiresAtMs<=Date.now())throw Error(`VoiceID challenge expired. Start unlock again.`);let a=await crypto.subtle.sign(`Ed25519`,i.privateKey,k(r)),o=await y(i);if(n.signal.aborted||r.expiresAtMs<=Date.now())throw o.fill(0),Error(`VoiceID unlock expired or was cancelled.`);return{kind:`unlocked`,assertion:te({kind:`voiceid_device_assertion_v1`,challenge:r,signatureB64u:g(new Uint8Array(a))}),factorSecret32:o}}async function oe(e,t,n){u();let{statement:r}=n;if(r.requestOrigin!==location.origin||r.expiresAtMs<=Date.now())throw Error(`VoiceID check is expired or belongs to another Wallet origin.`);let i=await S(r.walletId,r.walletAuthMethodId);if(!i||i.deviceKeyId!==r.deviceKeyId)throw Error(`VoiceID device key is unavailable in this browser.`);if(await $({kind:`active`,scope:await T(r.walletId,r.walletAuthMethodId)},n.signal,t.onCapture,t.phrase,e),n.signal.throwIfAborted(),r.expiresAtMs<=Date.now())throw Error(`VoiceID check expired. Start again.`);let a=await crypto.subtle.sign(`Ed25519`,i.privateKey,O(r)),o=await y(i);if(n.signal.aborted||r.expiresAtMs<=Date.now())throw o.fill(0),Error(`VoiceID check expired or was cancelled.`);return{kind:`confirmed`,assertion:b({kind:`voiceid_operation_assertion_v1`,statement:r,signatureB64u:g(new Uint8Array(a))}),factorSecret32:o}}async function $(e,t,n,i,a){let o=await Q(e,t,n,i,a);switch(o.kind){case`matched`:return;case`insufficient_audio`:throw new s(o.quality);case`mismatch`:throw new p(o.quality);case`phrase_mismatch`:throw new r;default:return se(o)}}function se(e){throw Error(`Unexpected voice result: ${String(e)}`)}export{Y as a,z as c,Z as i,oe as n,J as o,ae as r,K as s,ie as t};
|