@mediapipe/tasks-genai 0.10.13 → 0.10.14-rc.20240507
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 +0 -0
- package/genai.d.ts +54 -5
- package/genai_bundle.cjs +1 -1
- package/genai_bundle.cjs.map +1 -1
- package/genai_bundle.mjs +1 -1
- package/genai_bundle.mjs.map +1 -1
- package/package.json +1 -1
- package/wasm/genai_wasm_internal.js +0 -0
- package/wasm/genai_wasm_internal.wasm +0 -0
- package/wasm/genai_wasm_nosimd_internal.js +0 -0
- package/wasm/genai_wasm_nosimd_internal.wasm +0 -0
package/README.md
CHANGED
|
File without changes
|
package/genai.d.ts
CHANGED
|
@@ -23,10 +23,10 @@ declare interface BaseOptions_2 {
|
|
|
23
23
|
*/
|
|
24
24
|
modelAssetPath?: string | undefined;
|
|
25
25
|
/**
|
|
26
|
-
* A buffer containing the model
|
|
27
|
-
* `modelAssetBuffer` can be set.
|
|
26
|
+
* A buffer or stream reader containing the model asset. Only one of
|
|
27
|
+
* `modelAssetPath` or `modelAssetBuffer` can be set.
|
|
28
28
|
*/
|
|
29
|
-
modelAssetBuffer?: Uint8Array | undefined;
|
|
29
|
+
modelAssetBuffer?: Uint8Array | ReadableStreamDefaultReader | undefined;
|
|
30
30
|
/** Overrides the default backend to use for the provided model. */
|
|
31
31
|
delegate?: "CPU" | "GPU" | undefined;
|
|
32
32
|
}
|
|
@@ -137,9 +137,10 @@ export declare class LlmInference extends TaskRunner {
|
|
|
137
137
|
* @export
|
|
138
138
|
* @param wasmFileset A configuration object that provides the location of the
|
|
139
139
|
* Wasm binary and its loader.
|
|
140
|
-
* @param modelAssetBuffer
|
|
140
|
+
* @param modelAssetBuffer An array or a stream containing a binary
|
|
141
|
+
* representation of the model.
|
|
141
142
|
*/
|
|
142
|
-
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<LlmInference>;
|
|
143
|
+
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader): Promise<LlmInference>;
|
|
143
144
|
/**
|
|
144
145
|
* Initializes the Wasm runtime and creates a new `LlmInference` based
|
|
145
146
|
* on the path to the model asset.
|
|
@@ -188,6 +189,30 @@ export declare class LlmInference extends TaskRunner {
|
|
|
188
189
|
* @return The generated text result.
|
|
189
190
|
*/
|
|
190
191
|
generateResponse(text: string, progressListener: ProgressListener): Promise<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Performs LLM Inference on the provided text and waits
|
|
194
|
+
* asynchronously for the response. Only one call to `generateResponse()` can
|
|
195
|
+
* run at a time.
|
|
196
|
+
*
|
|
197
|
+
* @export
|
|
198
|
+
* @param text The text to process.
|
|
199
|
+
* @param loraModel The LoRA model to apply on the text generation.
|
|
200
|
+
* @return The generated text result.
|
|
201
|
+
*/
|
|
202
|
+
generateResponse(text: string, loraModel: LoraModel): Promise<string>;
|
|
203
|
+
/**
|
|
204
|
+
* Performs LLM Inference on the provided text and waits
|
|
205
|
+
* asynchronously for the response. Only one call to `generateResponse()` can
|
|
206
|
+
* run at a time.
|
|
207
|
+
*
|
|
208
|
+
* @export
|
|
209
|
+
* @param text The text to process.
|
|
210
|
+
* @param loraModel The LoRA model to apply on the text generation.
|
|
211
|
+
* @param progressListener A listener that will be triggered when the task has
|
|
212
|
+
* new partial response generated.
|
|
213
|
+
* @return The generated text result.
|
|
214
|
+
*/
|
|
215
|
+
generateResponse(text: string, loraModel: LoraModel, progressListener: ProgressListener): Promise<string>;
|
|
191
216
|
/**
|
|
192
217
|
* Runs an invocation of *only* the tokenization for the LLM, and returns
|
|
193
218
|
* the size (in tokens) of the result. Cannot be called while
|
|
@@ -199,6 +224,17 @@ export declare class LlmInference extends TaskRunner {
|
|
|
199
224
|
* May return undefined if an error occurred.
|
|
200
225
|
*/
|
|
201
226
|
sizeInTokens(text: string): number | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* Load a LoRA model to the LLM Inference Task and the LoRA model can be used
|
|
229
|
+
* by `generateResponse()`. The returned LoRA model can be applied only to the
|
|
230
|
+
* current LLM Inference task.
|
|
231
|
+
*
|
|
232
|
+
* @export
|
|
233
|
+
* @param modelAsset The URL to the model or the ArrayBuffer of the model
|
|
234
|
+
* content.
|
|
235
|
+
* @return A loaded LoRA model.
|
|
236
|
+
*/
|
|
237
|
+
loadLoraModel(modelAsset: string | Uint8Array): Promise<LoraModel>;
|
|
202
238
|
close(): void;
|
|
203
239
|
}
|
|
204
240
|
|
|
@@ -223,6 +259,19 @@ export declare interface LlmInferenceOptions extends TaskRunnerOptions {
|
|
|
223
259
|
* Random seed for sampling tokens.
|
|
224
260
|
*/
|
|
225
261
|
randomSeed?: number;
|
|
262
|
+
/**
|
|
263
|
+
* The LoRA ranks that will be used during inference.
|
|
264
|
+
*/
|
|
265
|
+
loraRanks?: number[];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The LoRA model to be used for `generateResponse()` of a LLM Inference task.
|
|
270
|
+
*/
|
|
271
|
+
export declare class LoraModel {
|
|
272
|
+
readonly owner: LlmInference;
|
|
273
|
+
readonly loraModelId: number;
|
|
274
|
+
constructor(owner: LlmInference);
|
|
226
275
|
}
|
|
227
276
|
|
|
228
277
|
/**
|
package/genai_bundle.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t="undefined"!=typeof self?self:{};function e(e){t:{for(var r=["CLOSURE_FLAGS"],n=t,i=0;i<r.length;i++)if(null==(n=n[r[i]])){r=null;break t}r=n}return null!=(e=r&&r[e])&&e}let r;const n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0;const n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(128>e)n[r++]=e;else{if(2048>e)n[r++]=e>>6|192;else{if(55296<=e&&57343>=e){if(56319>=e&&i<t.length){const o=t.charCodeAt(++i);if(56320<=o&&57343>=o){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.subarray(0,r)}return t}var o,s=e(610401301),a=e(188588736);const u=t.navigator;function c(t){return!!s&&(!!o&&o.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function l(e){var r;return(r=t.navigator)&&(r=r.userAgent)||(r=""),-1!=r.indexOf(e)}function h(){return!!s&&(!!o&&0<o.brands.length)}function f(){return h()?c("Chromium"):(l("Chrome")||l("CriOS"))&&!(!h()&&l("Edge"))||l("Silk")}o=u&&u.userAgentData||null;var d=!h()&&(l("Trident")||l("MSIE"));!l("Android")||f(),f(),l("Safari")&&(f()||!h()&&l("Coast")||!h()&&l("Opera")||!h()&&l("Edge")||(h()?c("Microsoft Edge"):l("Edg/"))||h()&&c("Opera"));var p={},_=null;function g(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=_[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}m();for(var n=0;;){var i=r(-1),o=r(0),s=r(64),a=r(64);if(64===a&&-1===i)break;e(i<<2|o>>4),64!=s&&(e(o<<4&240|s>>2),64!=a&&e(s<<6&192|a))}}(t,(function(t){n[i++]=t})),i!==r?n.subarray(0,i):n}function m(){if(!_){_={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));p[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===_[o]&&(_[o]=i)}}}}var v="undefined"!=typeof Uint8Array,y=!d&&"function"==typeof btoa;function b(t){if(!y){var e;void 0===e&&(e=0),m(),e=p[e];var r=Array(Math.floor(t.length/3)),n=e[64]||"";let u=0,c=0;for(;u<t.length-2;u+=3){var i=t[u],o=t[u+1],s=t[u+2],a=e[i>>2];i=e[(3&i)<<4|o>>4],o=e[(15&o)<<2|s>>6],s=e[63&s],r[c++]=a+i+o+s}switch(a=0,s=n,t.length-u){case 2:s=e[(15&(a=t[u+1]))<<2]||n;case 1:t=t[u],r[c]=e[t>>2]+e[(3&t)<<4|a>>4]+s+n}return r.join("")}for(e="",r=0,n=t.length-10240;r<n;)e+=String.fromCharCode.apply(null,t.subarray(r,r+=10240));return e+=String.fromCharCode.apply(null,r?t.subarray(r):t),btoa(e)}const w=/[-_.]/g,S={"-":"+",_:"/",".":"="};function A(t){return S[t]||""}function T(t){if(!y)return g(t);w.test(t)&&(t=t.replace(w,A)),t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}function E(t){return v&&null!=t&&t instanceof Uint8Array}let I;var P={};let O;function L(t){if(t!==P)throw Error("illegal external caller")}function U(){return O||=new x(null,P)}var x=class{constructor(t,e){if(L(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function k(t){if("string"==typeof t)return{buffer:T(t),s:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),s:!1};if(t.constructor===Uint8Array)return{buffer:t,s:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),s:!1};if(t.constructor===x){L(P);var e=t.i;return{buffer:(null==(e=null==e||E(e)?e:"string"==typeof e?T(e):null)?e:t.i=e)||(I||=new Uint8Array(0)),s:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),s:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function B(){return"function"==typeof BigInt}let N,D=0,j=0;function V(t){const e=0>t;let r=(t=Math.abs(t))>>>0;if(t=Math.floor((t-r)/4294967296),e){const[e,n]=G(r,t);t=n,r=e}D=r>>>0,j=t>>>0}function F(t,e){if(t>>>=0,2097151>=(e>>>=0))var r=""+(4294967296*e+t);else B()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,1e7<=t&&(r+=Math.floor(t/1e7),t%=1e7),1e7<=r&&(e+=Math.floor(r/1e7),r%=1e7),r=e+C(r)+C(t));return r}function C(t){return t=String(t),"0000000".slice(t.length)+t}function M(t){if(16>t.length)V(Number(t));else if(B())t=BigInt(t),D=Number(t&BigInt(4294967295))>>>0,j=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);j=D=0;const r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){const e=Number(t.slice(n,i));j*=1e6,D=1e6*D+e,4294967296<=D&&(j+=Math.trunc(D/4294967296),j>>>=0,D>>>=0)}if(e){const[t,e]=G(D,j);D=t,j=e}}}function G(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function R(t){return t?/^\d+$/.test(t)?(M(t),new z(D,j)):null:W||=new z(0,0)}var z=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let W;function H(t){return t?/^-?\d+$/.test(t)?(M(t),new $(D,j)):null:q||=new $(0,0)}var $=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let q;function K(t,e,r){for(;0<r||127<e;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.i.push(e)}function Y(t,e){for(;127<e;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function J(t,e){if(0<=e)Y(t,e);else{for(let r=0;9>r;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function X(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Q(t,e){return Y(t.i,8*e+2),e=t.i.end(),X(t,e),e.push(t.j),e}function Z(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;127<r;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function tt(t,e,r){Y(t.i,8*e+2),Y(t.i,r.length),X(t,t.i.end()),X(t,r)}class et{constructor(t,e){this.i=t,this.K=e}}function rt(t){return Array.prototype.slice.call(t)}function nt(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var it=nt(),ot=nt("2ex"),st=nt("0dg"),at=it?(t,e)=>{t[it]|=e}:(t,e)=>{void 0!==t.i?t.i|=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}})},ut=it?(t,e)=>{t[it]&=~e}:(t,e)=>{void 0!==t.i&&(t.i&=~e)};function ct(t,e,r){return r?t|e:t&~e}var lt=it?t=>0|t[it]:t=>0|t.i,ht=it?t=>t[it]:t=>t.i,ft=it?(t,e)=>(t[it]=e,t):(t,e)=>(void 0!==t.i?t.i=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}}),t);function dt(t,e){ft(e,-14591&(0|t))}function pt(t,e){ft(e,-14557&(34|t))}function _t(t){return 0===(t=t>>14&1023)?536870912:t}var gt,mt={},vt={};function yt(t){return!(!t||"object"!=typeof t||t.i!==vt)}function bt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function wt(t,e,r){if(!Array.isArray(t)||t.length)return!1;const n=lt(t);return!!(1&n)||!(!e||!(Array.isArray(e)?e.includes(r):e.has(r)))&&(ft(t,1|n),!0)}const St=[];function At(t){if(2&t)throw Error()}ft(St,55),gt=Object.freeze(St);function Tt(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}let Et;function It(){const e=Error();Tt(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function Pt(t){return Tt(t=Error(t),"warning"),t}function Ot(t){if(null!=t&&"number"!=typeof t)throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}Object.freeze(new class{}),Object.freeze(new class{});const Lt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Ut(t){const e=typeof t;return"number"===e?Number.isFinite(t):"string"===e&&Lt.test(t)}function xt(t){if("number"!=typeof t)throw Pt("int32");if(!Number.isFinite(t))throw Pt("int32");return 0|t}function kt(t){return null==t?t:xt(t)}function Bt(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?0|t:void 0}function Nt(t){if(null!=t){if("number"!=typeof t)throw Pt("uint32");if(!Number.isFinite(t))throw Pt("uint32");t>>>=0}return t}function Dt(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?t>>>0:void 0}function jt(t){return"-"!==t[0]&&(20>t.length||20===t.length&&184467>Number(t.substring(0,6)))}function Vt(t){return null==t||"string"==typeof t?t:void 0}function Ft(t,e,r){if(null!=t&&"object"==typeof t&&t.F===mt)return t;if(Array.isArray(t)){var n=lt(t),i=n;return 0===i&&(i|=32&r),(i|=2&r)!==n&&ft(t,i),new e(t)}}let Ct,Mt,Gt;function Rt(t,e,r){if(null==t&&(t=Ct),Ct=void 0,null==t){var n=96;r?(t=[r],n|=512):t=[],e&&(n=-16760833&n|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(n=lt(t)))throw Error("farr");if(64&n)return t;if(n|=64,r&&(n|=512,r!==t[0]))throw Error("mid");t:{const i=(r=t).length;if(i){const t=i-1;if(bt(r[t])){if(1024<=(e=t-(+!!(512&(n|=256))-1)))throw Error("pvtlmt");n=-16760833&n|(1023&e)<<14;break t}}if(e){if(1024<(e=Math.max(e,i-(+!!(512&n)-1))))throw Error("spvt");n=-16760833&n|(1023&e)<<14}}}return ft(t,n),t}function zt(t,e,r,n,i){if(null!=t){if(Array.isArray(t))t=wt(t,void 0,0)?void 0:i&&2<(t)?t:Wt(t,e,r,void 0!==n,i);else if(bt(t)){const o={};for(let s in t)o[s]=zt(t[s],e,r,n,i);t=o}else t=e(t,n);return t}}function Wt(t,e,r,n,i){const o=n||r?lt(t):0;n=n?!!(32&o):void 0,t=rt(t);for(let o=0;o<t.length;o++)t[o]=zt(t[o],e,r,n,i);return r&&r(o,t),t}function Ht(t){return t.F===mt?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(wt(t,void 0,0))return}else{if(E(t))return b(t);if(t instanceof x){const e=t.i;return null==e?"":"string"==typeof e?e:t.i=b(e)}}}return t}(t)}function $t(t,e,r=pt){if(null!=t){if(v&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var n=lt(t);return 2&n?t:(e&&=0===n||!!(32&n)&&!(64&n||!(16&n)),e?ft(t,-12293&(34|n)):Wt(t,$t,4&n?pt:r,!0,!0))}return t.F===mt&&(r=t.m,t=2&(n=ht(r))?t:qt(t,r,n,!0)),t}}function qt(t,e,r,n){return t=t.constructor,Ct=e=function(t,e,r){const n=r||2&e?pt:dt,i=!!(32&e);return t=function(t,e,r){var n=(t=rt(t)).length;const i=256&e?t[n-1]:void 0;for(n+=i?-1:0,e=512&e?1:0;e<n;e++)t[e]=r(t[e]);if(i){e=t[e]={};for(const t in i)e[t]=r(i[t])}return t}(t,e,(t=>$t(t,i,n))),at(t,32|(r?2:0)),t}(e,r,n),e=new t(e),Ct=void 0,e}function Kt(t){const e=t.m,r=ht(e);return 2&r?qt(t,e,r,!1):t}function Yt(t,e,r,n){return!(4&e)||null!=r&&(!n&&0===r&&(4096&e||8192&e)&&5>(t.constructor[st]=1+(0|t.constructor[st]))&&It(),0!==r&&!(r&e))}function Jt(t){return Qt(t=t.m,ht(t),2)}function Xt(t,e,r,n){if(!(0>(e=n+(+!!(512&e)-1))||e>=t.length||e>=r))return t[e]}function Qt(t,e,r,n){if(-1===r)return null;const i=_t(e);if(!(r>=i)){var o=t.length;return n&&256&e&&null!=(n=t[o-1][r])?(Xt(t,e,i,r)&&null!=ot&&(4<=(e=(t=Et??={})[ot]||0)||(t[ot]=e+1,It())),n):Xt(t,e,i,r)}return 256&e?t[t.length-1][r]:void 0}function Zt(t,e,r){const n=t.m;let i=ht(n);return At(i),te(n,i,e,r),t}function te(t,e,r,n,i){const o=_t(e);if(r>=o||i){let s=e;if(256&e)i=t[t.length-1];else{if(null==n)return s;i=t[o+(+!!(512&e)-1)]={},s|=256}return i[r]=n,r<o&&(t[r+(+!!(512&e)-1)]=void 0),s!==e&&ft(t,s),s}return t[r+(+!!(512&e)-1)]=n,256&e&&(r in(t=t[t.length-1])&&delete t[r]),e}function ee(t,e,r){return t=Qt(t,e,r),Array.isArray(t)?t:gt}function re(t,e){return 0===t&&(t=ue(t,e)),ct(t,1,!0)}function ne(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ie(t,e,r){{const a=t.m;let u=ht(a);if(At(u),null==r)te(a,u,e);else{var n,i=lt(r),o=i,s=!!(2&i)||Object.isFrozen(r);if((n=!s)&&(n=!1),Yt(t,i))for(i=21,s&&(r=rt(r),o=0,i=ce(i=ue(i,u),u,!0)),t=0;t<r.length;t++)r[t]=xt(r[t]);n&&(r=rt(r),o=0,i=ce(i=ue(i,u),u,!0)),i!==o&&ft(r,i),te(a,u,e,r)}}}function oe(t,e,r,n){t=t.m;let i=ht(t);At(i),te(t,i,e,("0"===n?0===Number(r):r===n)?void 0:r)}function se(t,e,r){var n=t.m,i=ht(n),o=Qt(n,i,r,!1);return(e=Ft(o,e,i))!==o&&null!=e&&te(n,i,r,e,!1),null==(n=e)||(t=t.m,2&(i=ht(t))||(o=Kt(n))!==n&&te(t,i,r,n=o,!1)),n}function ae(t,e,r){return null==r&&(r=void 0),Zt(t,e,r)}function ue(t,e){return t=ct(t,2,!!(2&e)),t=ct(t,32,!0),ct(t,2048,!1)}function ce(t,e,r){return 32&e&&r||(t=ct(t,32,!1)),t}function le(t,e,r,n){t=t.m;var i=ht(t);At(i);var o=!!(2&i);const s=o?1:2;f&&=!o,o=ee(t,i,e);var a=lt(o);const u=!!(4&a);if(!u){var c=o,l=i,h=!!(2&(a=re(a,i)));h&&(l=ct(l,2,!0));let t=!h,e=!0,n=0,s=0;for(;n<c.length;n++){const i=Ft(c[n],r,l);if(i instanceof r){if(!h){const r=!!(2<(i.m));t&&=!r,e&&=r}c[s++]=i}}s<n&&(c.length=s),a=ct(a,4,!0),a=ct(a,16,e),a=ct(a,8,t),ft(c,a),h&&Object.freeze(c)}if(f&&!(8&a||!o.length&&(1===s||4===s&&32&a))){ne(a)&&(o=rt(o),a=ue(a,i),i=te(t,i,e,o));var f=o;for(c=a,a=0;a<f.length;a++)(l=f[a])!==(h=Kt(l))&&(f[a]=h);c=ct(c,8,!0),c=ct(c,16,!f.length),ft(f,c),a=c}ne(a)||(f=a,(a=(c=1===s||4===s&&!!(32&a))?ct(a,!o.length||16&a&&(!u||32&a)?2:2048,!0):ce(a,i,!0))!==f&&ft(o,a),c&&Object.freeze(o)),2===s&&ne(a)&&(o=rt(o),a=ce(a=ue(a,i),i,!0),ft(o,a),te(t,i,e,o)),e=o,r=null!=n?n:new r,e.push(r),2<(r.m)?ut(e,8):ut(e,16)}function he(t,e,r){oe(t,e,kt(r),0)}function fe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();oe(t,e,r,"")}function de(t,e,r){t=t.m;const n=ht(t);At(n);var i=2&n;let o=Qt(t,n,e);Array.isArray(o)||(o=gt);const s=!!(32&n);let a=lt(o);if(0===a&&s&&!i?(a|=33,ft(o,a)):1&a||(a|=1,ft(o,a)),i?(2&a||at(o,34),Object.freeze(o)):(2&a||2048&a)&&(o=rt(o),i=1,s&&(i|=32),ft(o,i),te(t,n,e,o)),"string"!=typeof r)throw Error();o.push(r)}var pe=class{constructor(t,e){this.m=Rt(t,e)}toJSON(){return _e(this,Wt(this.m,Ht,void 0,void 0,!1),!0)}s(){return!!(2<(this.m))}};function _e(t,e,r){var n=a?void 0:t.constructor.v;const i=ht(r?t.m:e);if(!(t=e.length))return e;let o,s;if(bt(r=e[t-1])){t:{var u=r;let t={},e=!1;for(var c in u){let r=u[c];if(Array.isArray(r)){let t=r;(wt(r,n,+c)||yt(r)&&0===r.size)&&(r=null),r!=t&&(e=!0)}null!=r?t[c]=r:e=!0}if(e){for(var l in t){u=t;break t}u=null}}u!=r&&(o=!0),t--}for(c=+!!(512&i)-1;0<t&&(r=e[l=t-1],l-=c,null==r||wt(r,n,l)||yt(r)&&0===r.size);t--)s=!0;return o||s?(e=Array.prototype.slice.call(e,0,t),u&&e.push(u),e):e}function ge(t,e){if(Array.isArray(e)){var r=lt(e);if(4&r)return e;for(var n=0,i=0;n<e.length;n++){const r=t(e[n]);null!=r&&(e[i++]=r)}return i<n&&(e.length=i),ft(e,-12289&(5|r)),2&r&&Object.freeze(e),e}}pe.prototype.F=mt,pe.prototype.toString=function(){return _e(this,this.m,!1).toString()};const me=Symbol(),ve=Symbol();function ye(t){let e=t[ve];if(!e){const r=Ae(t);e=(t,e)=>Ie(t,e,r),t[ve]=e}return e}const be=Symbol();function we(t){return t.i}function Se(t,e){let r,n;const i=t.i;return(t,o,s)=>i(t,o,s,n||=Ae(e).i,r||=ye(e))}function Ae(t){var e=t[be];if(e)return e;var r=we,n=Se;(e=t[be]={}).i=function(t){switch(typeof t){case"boolean":return Mt||=[0,void 0,!0];case"number":return 0<t?void 0:0===t?Gt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);let i=0;var o=t[++i];o&&o.constructor===Object&&(e.N=o,"function"==typeof(o=t[++i])&&(e.l=o,e.j=t[++i],o=t[++i]));const s={};for(;Array.isArray(o)&&"number"==typeof o[0]&&0<o[0];){for(var a=0;a<o.length;a++)s[o[a]]=o;o=t[++i]}for(a=1;void 0!==o;){let f;"number"==typeof o&&(a+=o,o=t[++i]);var u=void 0;if(o instanceof et?f=o:(f=Ke,i--),f.K){o=t[++i],u=t;var c=i;"function"==typeof o&&(o=o(),u[c]=o),u=o}let d=a+1;for("number"==typeof(o=t[++i])&&0>o&&(d-=o,o=t[++i]);a<d;a++){var l=s[a];c=e;var h=a;l=u?n(f,u):r(f),c[h]=l}}return Te in t&&me in t&&be in t&&(t.length=0),e}const Te=Symbol();function Ee(t,e){var r=t[e];if(r)return r;if((r=t.N)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof et?r:[qe,r]:[r,void 0])[0].i;if(r=r[1]){const e=ye(r),i=Ae(r).i;r=(r=t.j)?r(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}function Ie(t,e,r){var n=ht(t),i=+!!(512&n)-1,o=t.length,s=512&n?1:0;const a=o+(256&n?-1:0);for(;s<a;s++){const n=t[s];if(null==n)continue;const o=s-i,a=Ee(r,o);a&&a(e,n,o)}if(256&n){t=t[o-1];for(let s in t)n=+s,Number.isNaN(n)||null!=(i=t[s])&&(o=Ee(r,n))&&o(e,i,n)}}function Pe(t){return new et(t,!1)}function Oe(t,e,r){null!=(e=Bt(e))&&null!=e&&(Y(t.i,8*r),J(t.i,e))}function Le(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Y(t.i,8*r),t.i.i.push(e?1:0))}function Ue(t,e,r){null!=(e=Vt(e))&&tt(t,r,i(e))}function xe(t,e,r,n,i){null!=(e=e instanceof pe?e.m:Array.isArray(e)?Rt(e,n[0],n[1]):void 0)&&(r=Q(t,r),i(e,t),Z(t,r))}function ke(t,e,r){null!=(e=Bt(e))&&(e=parseInt(e,10),Y(t.i,8*r),J(t.i,e))}var Be,Ne=Pe((function(t,e,r){null!=(e=null==e||"number"==typeof e?e:"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0)&&(Y(t.i,8*r+5),t=t.i,(r=N||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),j=0,e=D=r.getUint32(0,!0),t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255))})),De=Pe((function(t,e,r){t:if(null!=e){if(Ut(e)){if("string"==typeof e){var n=Math.trunc(Number(e));if(Number.isSafeInteger(n))e=String(n);else if(-1!==(n=e.indexOf("."))&&(e=e.substring(0,n)),!("-"===e[0]?20>e.length||20===e.length&&-922337<Number(e.substring(0,7)):19>e.length||19===e.length&&922337>Number(e.substring(0,6))))if(M(e),e=D,2147483648&(n=j))if(B())e=""+(BigInt(0|n)<<BigInt(32)|BigInt(e>>>0));else{const[t,r]=G(e,n);e="-"+F(t,r)}else e=F(e,n);break t}if("number"==typeof e){if(e=Math.trunc(e),!Number.isSafeInteger(e)){V(e),n=D;var i=j;(e=2147483648&i)&&(i=~i>>>0,0==(n=1+~n>>>0)&&(i=i+1>>>0)),n=4294967296*i+(n>>>0),e=e?-n:n}break t}}e=void 0}null!=e&&("string"==typeof e&&H(e),null!=e&&(Y(t.i,8*r),"number"==typeof e?(t=t.i,V(e),K(t,D,j)):(r=H(e),K(t.i,r.j,r.i))))})),je=Pe((function(t,e,r){t:if(null!=e){if(Ut(e)){if("string"==typeof e){var n=Math.trunc(Number(e));Number.isSafeInteger(n)&&0<=n?e=String(n):(-1!==(n=e.indexOf("."))&&(e=e.substring(0,n)),jt(e)||(M(e),e=F(D,j)));break t}if("number"==typeof e){e=0<=(e=Math.trunc(e))&&Number.isSafeInteger(e)?e:function(t){if(0>t){V(t);const e=F(D,j);return t=Number(e),Number.isSafeInteger(t)?t:e}return jt(String(t))?t:(V(t),4294967296*j+(D>>>0))}(e);break t}}e=void 0}null!=e&&("string"==typeof e&&R(e),null!=e&&(Y(t.i,8*r),"number"==typeof e?(t=t.i,V(e),K(t,D,j)):(r=R(e),K(t.i,r.j,r.i))))})),Ve=Pe(Oe),Fe=new et((function(t,e,r){if(null!=(e=ge(Bt,e))&&e.length){r=Q(t,r);for(let r=0;r<e.length;r++)J(t.i,e[r]);Z(t,r)}}),!1),Ce=Pe(Oe),Me=Pe(Oe),Ge=Pe(Le),Re=Pe(Le),ze=new et((function(t,e,r){if(null!=(e=ge(Vt,e)))for(let a=0;a<e.length;a++){var n=t,o=r,s=e[a];null!=s&&tt(n,o,i(s))}}),!1),We=Pe(Ue),He=Pe(Ue),$e=Pe(Ue),qe=new et(xe,!0),Ke=new et(xe,!0);Be=new et((function(t,e,r,n,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)xe(t,e[o],r,n,i)}),!0);var Ye=new et(xe,!0),Je=Pe(ke),Xe=new et((function(t,e,r){if(null!=(e=ge(Bt,e))&&e.length){r=Q(t,r);for(let r=0;r<e.length;r++)J(t.i,e[r]);Z(t,r)}}),!1),Qe=Pe(ke);function Ze(t){return function(){const e=new class{constructor(){this.l=[],this.j=0,this.i=new class{constructor(){this.i=[]}length(){return this.i.length}end(){const t=this.i;return this.i=[],t}}}};Ie(this.m,e,Ae(t)),X(e,e.i.end());const r=new Uint8Array(e.j),n=e.l,i=n.length;let o=0;for(let t=0;t<i;t++){const e=n[t];r.set(e,o),o+=e.length}return e.l=[r],r}}function tr(t,e){if(null!=e)if(Array.isArray(e))Zt(t,2,Wt(e,Ht,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof x||E(e)))throw Error("invalid value in Any.value field: "+e+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");if(null!=e)if("string"==typeof e)e=e?new x(e,P):U();else if(e.constructor!==x){if(!E(e))throw Error();e=e.length?new x(new Uint8Array(e),P):U()}oe(t,2,e,U())}}var er=class extends pe{constructor(t){super(t)}},rr=[0,We,Pe((function(t,e,r){if(null!=e){if(e instanceof pe){const n=e.V;return void(n&&(e=n(e),null!=e&&tt(t,r,k(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||E(e)||e instanceof x?e:void 0)&&tt(t,r,k(e).buffer)}))],nr={},ir=[-2,nr,Ge];nr[336783863]=[0,$e,Ge,-1,Ve,[0,[1,2,3,4,5,6],Ye,[0],Ye,[0,Ge,$e,Ge,Je,-1,Xe,$e,-1,[0,Ge,-1],Je],Ye,[0,$e,-2],Ye,[0,Ve,Ge,-4],Ye,[0,Ve,Je,Ge,-1,Fe,Je,-1],Ye,[0,$e]],[0,$e],Ge,[0,[1,3],[2,4],Ye,[0,Fe],-1,Ye,[0,ze],-1],$e];var or=class extends pe{constructor(t){super(t)}},sr=[0,We,Re],ar=[0,De,-1,Re,-3,De,Fe,We,Ce,De,-1,Re,Ce,Re,-2,We],ur=[-1,{}],cr=[0,$e,1,ur],lr=[0,$e,ze,ur],hr=class extends pe{constructor(t){super(t,500)}C(t){return ae(this,7,t)}};hr.v=[3,4,5,6,8,13,17,1005];var fr=[-500,We,-1,ze,-3,ir,Be,rr,Ce,-1,cr,lr,Be,sr,We,ar,Ce,ze,987,ze],dr=[0,We,-1,ur],pr=[-500,$e,-1,[-1,{}],998,$e],_r=[-500,$e,ze,-1,[-2,{},Ge],997,ze,-1],gr=[-500,$e,ze,ur,998,ze];function mr(t,e){le(t,1,hr,e)}var vr=class extends pe{constructor(){super(void 0,500)}C(t){return ae(this,1001,t)}};vr.v=[1,6,7,9,10,15,16,17,14,1002],vr.prototype.i=Ze([-500,Be,fr,4,Be,pr,Be,_r,Ce,Be,gr,ze,Ce,cr,lr,Be,dr,ze,-2,ar,We,-1,Re,979,ur,Be,rr]);var yr=class extends pe{constructor(t){super(t)}};let br;const wr=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Sr(){if(void 0===br)try{await WebAssembly.instantiate(wr),br=!0}catch{br=!1}return br}async function Ar(t,e=""){const r=await Sr()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var Tr=class{};function Er(){var t=navigator;return"undefined"!=typeof OffscreenCanvas&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(t)||!!((t=t.userAgent.match(/Version\/([\d]+).*Safari/))&&1<=t.length&&17<=Number(t[1])))}async function Ir(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,r)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{r(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}Tr.forVisionTasks=function(t){return Ar("vision",t)},Tr.forTextTasks=function(t){return Ar("text",t)},Tr.forGenAiExperimentalTasks=function(t){return Ar("genai_experimental",t)},Tr.forGenAiTasks=function(t){return Ar("genai",t)},Tr.forAudioTasks=function(t){return Ar("audio",t)},Tr.isSimdSupported=function(){return Sr()};function Pr(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function Or(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const n=new Uint32Array(e.length);for(let r=0;r<e.length;r++)n[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*n.length),t.h.HEAPU32.set(n,e>>2),r(e);for(const e of n)t.h._free(e);t.h._free(e)}function Lr(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Ur(t,e,r){let n=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(r(n,i),n=[]):n.push(t)}}const xr=(kr=class{constructor(t,e){this.l=!0,this.h=t,this.i=null,this.j=0,this.o="function"==typeof this.h._addIntToInputStream,void 0!==e?this.h.canvas=e:Er()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph((new TextEncoder).encode(t),!1)}setGraph(t,e){const r=t.length,n=this.h._malloc(r);this.h.HEAPU8.set(t,n),e?this.h._changeBinaryGraph(r,n):this.h._changeTextGraph(r,n),this.h._free(n)}configureAudio(t,e,r,n,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Pr(this,n||"input_audio",(n=>{Pr(this,i=i||"audio_header",(i=>{this.h._configureAudio(n,i,t,e,r)}))}))}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.h._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.h.gpuOriginForWebTexturesIsBottomLeft=t}attachErrorListener(t){this.h.errorListener=t}attachEmptyPacketListener(t,e){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[t]=e}addAudioToStream(t,e,r){this.addAudioToStreamWithShape(t,0,0,e,r)}addAudioToStreamWithShape(t,e,r,n,i){const o=4*t.length;this.j!==o&&(this.i&&this.h._free(this.i),this.i=this.h._malloc(o),this.j=o),this.h.HEAPF32.set(t,this.i/4),Pr(this,n,(t=>{this.h._addAudioToInputStream(this.i,e,r,t,i)}))}addGpuBufferToStream(t,e,r){Pr(this,e,(e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();const n=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!n)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const[i,o]=void 0!==t.videoWidth?[t.videoWidth,t.videoHeight]:void 0!==t.naturalWidth?[t.naturalWidth,t.naturalHeight]:void 0!==t.displayWidth?[t.displayWidth,t.displayHeight]:[t.width,t.height];!this.l||i===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=i,this.h.canvas.height=o);const[s,a]=[i,o];this.h._addBoundTextureToStream(e,s,a,r)}))}addBoolToStream(t,e,r){Pr(this,e,(e=>{this.h._addBoolToInputStream(t,e,r)}))}addDoubleToStream(t,e,r){Pr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,r)}))}addFloatToStream(t,e,r){Pr(this,e,(e=>{this.h._addFloatToInputStream(t,e,r)}))}addIntToStream(t,e,r){Pr(this,e,(e=>{this.h._addIntToInputStream(t,e,r)}))}addUintToStream(t,e,r){Pr(this,e,(e=>{this.h._addUintToInputStream(t,e,r)}))}addStringToStream(t,e,r){Pr(this,e,(e=>{Pr(this,t,(t=>{this.h._addStringToInputStream(t,e,r)}))}))}addStringRecordToStream(t,e,r){Pr(this,e,(e=>{Or(this,Object.keys(t),(n=>{Or(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(n,i,Object.keys(t).length,e,r)}))}))}))}addProtoToStream(t,e,r,n){Pr(this,r,(r=>{Pr(this,e,(e=>{const i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputStream(i,t.length,e,r,n),this.h._free(i)}))}))}addEmptyPacketToStream(t,e){Pr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(n,e);this.h._addBoolVectorToInputStream(n,e,r)}))}addDoubleVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(n,e);this.h._addDoubleVectorToInputStream(n,e,r)}))}addFloatVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(n,e);this.h._addFloatVectorToInputStream(n,e,r)}))}addIntVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(n,e);this.h._addIntVectorToInputStream(n,e,r)}))}addUintVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(n,e);this.h._addUintVectorToInputStream(n,e,r)}))}addStringVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const e of t)Pr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputStream(n,e,r)}))}addBoolToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){Pr(this,e,(e=>{Pr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,r){Pr(this,r,(r=>{Pr(this,e,(e=>{const n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputSidePacket(n,t.length,e,r),this.h._free(n)}))}))}addBoolVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)}))}addDoubleVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)}))}addFloatVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)}))}addIntVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)}))}addUintVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)}))}addStringVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const e of t)Pr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputSidePacket(r,e)}))}attachBoolListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,r){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachProtoListener(t,r||!1)}))}attachProtoVectorListener(t,e,r){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachProtoVectorListener(t,r||!1)}))}attachAudioListener(t,e,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Lr(this,t,((t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)})),Pr(this,t,(t=>{this.h._attachAudioListener(t,r||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}},class extends kr{S(){this.h._registerModelResourcesGraphService()}});var kr;async function Br(t,e){const r=await(async(t,e,r)=>{var n=hn;if(t&&await Ir(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Ir(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new n(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return await r.C(e),r}async function Nr(t,e){return Br(t,e)}function Dr(t){try{const e=t.A.length;if(1===e)throw Error(t.A[0].message);if(1<e)throw Error("Encountered multiple errors: "+t.A.map((t=>t.message)).join(", "))}finally{t.A=[]}}function jr(t,e){t.u=Math.max(t.u,e)}var Vr=class{constructor(t){this.i=t,this.A=[],this.u=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.A.push(Error(e))})),this.i.S(),this.i.setGraph(t,e),Dr(this)}finishProcessing(){this.i.finishProcessing(),Dr(this)}close(){this.i.closeGraph()}};Vr.prototype.close=Vr.prototype.close;var Fr=class extends pe{constructor(t){super(t)}},Cr=[0,Qe,Ce,Ne,-1,Ve];var Mr=class extends pe{constructor(){super()}};function Gr(t,e,r,n){if(void 0!==t.data){var i=new Uint8Array(t.data.buffer,e,r);return 1===n&&function(t,e,r){t.i.push([e,r]),t.i.sort(((t,e)=>t[0]-e[0])),e=0;for(const[n,i]of t.i){const t=i;(r=n)<=e&&(e=Math.max(e,r+t))}e===t.length&&(t.data=void 0)}(t,e,r),i}}Mr.v=[4];class Rr{constructor(t){this.i=[],this.data=t,this.length=t.length}}var zr=class{constructor(t,e,r){this.i=t,this.j=e,this.l=r}get size(){let t=0;for(let e=0;e<this.i.length;e++)t+=this.i[e].length;return t}},Wr=class extends pe{constructor(){super()}};Wr.v=[4],Wr.prototype.i=Ze([0,We,2,ze,Ce]);var Hr=class extends pe{constructor(){super()}},$r=[0,Re,-5],qr=[0,We,je,-1,Qe],Kr=class extends pe{constructor(){super()}},Yr=[0,Ce,-6,1,Ce,1,[0,Re,Qe,-2],[0,Re,Ne],Qe,-2,[0,Re,-1,Qe,Ne,Je],1,Re],Jr=class extends pe{constructor(){super()}};Jr.v=[5,7];var Xr=[0,[4,6],Yr,Ce,1,Me,ze,He,Xe],Qr=[0,Be,qr,Xr,Ce],Zr=[0,Ce,Re,-1],tn=class extends pe{constructor(){super()}};tn.v=[29],tn.prototype.i=Ze([0,We,8,$r,1,Ce,1,Ce,Qr,Zr,1,Qe,We,Xr,Qr,Ce,5,Qe,Fe,1,Cr]);var en=class extends pe{constructor(){super()}},rn=class extends pe{constructor(){super()}},nn=[2,4];rn.prototype.i=Ze([0,nn,Ce,He,Ce,Ye,[0,1,We]]);const on=function(t){return class e extends t{static async T(t,r){let n;r||=await e.J();const i=[];for(const e of t?.requiredFeatures??[])r.features.has(e)?i.push(e):console.warn(`WebGPU feature ${e} is not supported.`);t={...t,requiredFeatures:i};try{n=await r.requestDevice(t)}catch(t){throw console.error("Unable to initialize WebGPU with the requested features."),t}return r=await r.requestAdapterInfo(),n.adapterInfo=r,n}static async J(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}P(t){if(e)"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.id="canvas_webgpu");else var e=new OffscreenCanvas(1,1);e.getContext("webgpu").configure({device:t,format:navigator.gpu.getPreferredCanvasFormat()}),this.h.preinitializedWebGPUDevice=t}M(){return this.h.ccall("closeGraph","void",[],[],{async:!0})}}}(function(t){return class extends t{addStreamingReaderToInputSidePacket(t,e){this.h.addStreamingReaderToInputSidePacket(((e,r,n)=>async function(t,e,r,n,i){if(2===i)return t.i=[],t.j=()=>Promise.resolve(void 0),t.l(),Promise.resolve(0);for(;t.size<r+n;){var o=await t.j();if(void 0===o)break;t.i.push(new Rr(o))}if(t.size<r+n)throw Error(`Data size is too small: ${t.size}, expected at least ${r+n}.`);o=e._malloc(n)>>>0;let s=0;for(let a=0;a<t.i.length;a++){const u=t.i[a];if(r>=u.length){r-=u.length;continue}const c=Math.min(n,u.length-r);if(void 0===(r=Gr(u,r,c,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(r,o+s),r=0,s+=c,0==(n-=c))break}if(0!==n)throw Error("Data not found.");return Promise.resolve(o)}(t,this.h,e,r,n)),e)}}}(function(t){return class extends t{L(t,e){Pr(this,"lora_model_ref_in",(r=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,r,e)}))}}}(class extends xr{})));class sn extends on{}var an=class{constructor(t){this.j=t,this.i=un,un++}},un=0;async function cn(){const t=await sn.J({powerPreference:"high-performance"});var e=t.limits.maxBufferSize;if(524550144>t.limits.maxStorageBufferBindingSize)throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxStorageBufferBindingSize is at least 524550144 but your device only supports maxStorageBufferBindingSize of ${e}`);if(786825216<=e)e=786825216;else{if(!(524550144<=e))throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxBufferSize is at least 524550144 but your device only supports maxBufferSize of ${e}`);e=524550144}return sn.T({requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e}},t)}function ln(t){const e=function(t){const e=new vr;de(e,10,"text_in"),de(e,10,"token_cost_in"),de(e,10,"lora_model_id_to_apply_in"),de(e,10,"lora_model_ref_in"),de(e,10,"lora_model_id_to_load_in"),de(e,16,"streaming_reader"),de(e,15,"text_out"),de(e,15,"text_end"),de(e,15,"token_cost_out");var r=new hr;fe(r,2,"TokenizerInputBuildCalculator"),de(r,3,"PROMPT:text_in"),de(r,3,"LORA_ID:lora_model_id_to_apply_in"),de(r,4,"prompt"),mr(e,r),fe(r=new hr,2,"ModelDataCalculator"),de(r,6,"MODEL_DATA:__side_packet_1"),de(r,6,"MODEL_TYPE:model_type"),de(r,5,"READ_DATA_FN:streaming_reader"),de(r,3,"LORA_MODEL_SPAN:lora_model_ref_in"),de(r,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),de(r,4,"LORA_DATA:lora_model_data"),mr(e,r),fe(r=new hr,2,"Gpt2UnicodeMappingCalculator"),de(r,5,"MODEL_TYPE:model_type"),de(r,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),mr(e,r),fe(r=new er,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var n=new rn,i=Dt(Jt(t.l))??0;he(n,1,i),fe(i=new en,2,"spm_vocab_model"),null==i&&(i=void 0);var o=n.m,s=ht(o);At(s);for(var a=s,u=0,c=0;c<nn.length;c++){var l=nn[c];null!=Qt(o,a,l)&&(0!==u&&(a=te(o,a,u)),u=l)}if((a=u)&&4!==a&&null!=i&&(s=te(o,s,a)),te(o,s,4,i),he(n,3,2),tr(r,n.i()),fe(n=new hr,2,"TokenizerCalculator"),le(n,8,er,r),de(n,5,"MODEL_DATA:__side_packet_1"),de(n,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),de(n,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),de(n,6,"PROCESSOR_GETTER:__input_side_1"),de(n,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),mr(e,n),fe(r=new er,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),he(n=new tn,12,3),fe(n,1,"llm.tflite"),he(n,14,0),he(n,22,1),i=se(t.l,Fr,3),ae(n,31,i),oe(i=new Hr,1,!0,!1),oe(i,2,!0,!1),oe(i,5,!0,!1),ae(n,10,i),c=t.l,i=c.m,o=ht(i),s=2&o?1:2,a=ee(i,o,4),u=lt(a),Yt(c,u,void 0,!1)){for((4&u||Object.isFrozen(a))&&(a=rt(a),u=ue(u,o),o=te(i,o,4,a)),l=c=0;c<a.length;c++){const t=Bt(a[c]);null!=t&&(a[l++]=t)}l<c&&(a.length=l),u=ct(u=re(u,o),20,!0),u=ct(u,4096,!1),u=ct(u,8192,!1),ft(a,u),2&u&&Object.freeze(a)}return ne(u)||(c=u,(u=(l=1===s||4===s&&!!(32&u))?ct(u,2,!0):ce(u,o,!1))!==c&&ft(a,u),l&&Object.freeze(a)),2===s&&ne(u)&&(a=rt(a),u=ce(u=ue(u,o),o,!1),ft(a,u),te(i,o,4,a)),ie(n,29,a),i=new Jr,he(o=new Kr,1,1),t=Dt(Jt(t.l))??0,he(o,2,t),ae(i,1,o),ae(n,20,i),tr(r,n.i()),fe(t=new hr,2,"LlmGpuCalculator"),le(t,8,er,r),de(t,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),de(t,3,"FINISH:finish"),de(t,3,"LORA_DATA:lora_model_data"),de(t,5,"MODEL_DATA:__side_packet_1"),de(t,4,"DECODED_IDS:__stream_3"),de(t,4,"OUTPUT_END:__stream_4"),fe(r=new or,1,"FINISH"),oe(r,2,!0,!1),le(t,13,or,r),mr(e,t),fe(t=new hr,2,"IsPacketPresentCalculator"),de(t,3,"__stream_4"),de(t,4,"text_end"),mr(e,t),fe(t=new er,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),he(r=new Wr,5,1),de(r,4,"<eos>"),de(r,4,"<|endoftext|>"),tr(t,r.i()),fe(r=new hr,2,"DetokenizerCalculator"),le(r,8,er,t),de(r,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),de(r,5,"PROCESSOR_GETTER:__input_side_1"),de(r,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),de(r,5,"MODEL_DATA:__side_packet_1"),de(r,4,"FINISH_AND_INPUT_OPTIONS:finish"),de(r,4,"WORDS:text_out"),mr(e,r),fe(t=new hr,2,"TokenCostCalculator"),de(t,3,"PROMPT:token_cost_in"),de(t,5,"PROCESSOR_GETTER:__input_side_1"),de(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),de(t,4,"NUM_TOKENS:token_cost_out"),mr(e,t),e}(t);t.i.attachStringVectorListener("text_out",((e,r)=>{var n=0===t.B.length;null==e||0===e.length?n="":(e=(e=(e=e[0]).replaceAll("▁"," ")).replaceAll("<0x0A>","\n"),n&&(e=e.trimStart()),n=e.split("\\[eod\\]",1)[0]),t.B.push(n),t.D&&t.D(n,!1),jr(t,r)})),t.i.attachEmptyPacketListener("text_out",(e=>{jr(t,e)})),t.i.attachBoolListener("text_end",((e,r)=>{t.j=!1,t.I&&t.I(t.B.join("")),t.D&&t.D("",!0),jr(t,r)})),t.i.attachEmptyPacketListener("text_end",(e=>{t.j=!1,jr(t,e)})),t.i.attachIntListener("token_cost_out",((e,r)=>{t.H=e,jr(t,r)})),t.G&&t.i.addStreamingReaderToInputSidePacket(t.G,"streaming_reader");const r=e.i();return t.i.M().then((()=>{t.setGraph(new Uint8Array(r),!0),t.finishProcessing()}))}var hn=class extends Vr{constructor(t,e){if(super(new sn(t,e)),this.B=[],this.j=!1,ae(t=this.l=new Mr,1,e=new yr),this.o=new Fr,ae(this.l,3,this.o),Zt(this.l,2,Nt(512)),t=this.o,!Number.isFinite(2))throw Pt("enum");oe(t,1,2,0),he(this.o,2,1),oe(this.o,3,Ot(1),0),oe(this.o,4,Ot(1),0)}C(t){if(this.j)throw Error("Cannot set options while loading or processing.");let e;this.j=!0,t.baseOptions?.gpuOptions?.device&&this.i.P(t.baseOptions.gpuOptions.device),"maxTokens"in t&&Zt(this.l,2,Nt(t.maxTokens??512)),"topK"in t&&(he(this.o,2,t.topK??1),t.topK&&!t.randomSeed&&console.warn("'topK' option ignored; it requires randomSeed to be set.")),"temperature"in t&&(oe(this.o,4,Ot(t.temperature??1),0),t.temperature&&!t.randomSeed&&console.warn("'temperature' option ignored; it requires randomSeed to be set.")),t.randomSeed&&Zt(this.o,5,kt(t.randomSeed)),"loraRanks"in t&&function(t,e){ie(t,4,e)}(this.l,t.loraRanks??[]);const r=new Promise((t=>{e=t}));if(t.baseOptions?.modelAssetPath||t.baseOptions?.modelAssetBuffer){if(t.baseOptions.modelAssetPath&&t.baseOptions.modelAssetBuffer)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");t.baseOptions.modelAssetPath?this.G=function(t,e){const r=fetch(t.toString()).then((t=>t?.body?.getReader()));return new zr([],(async()=>{let e;try{e=await r}catch(e){throw Error(`Error loading model from "${t.toString()}": ${e}`)}const{value:n,done:i}=await e.read();if(!i)return n}),e)}(t.baseOptions.modelAssetPath,e):t.baseOptions.modelAssetBuffer?(this.G=function(t,e){return new zr([new Rr(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,e),t.baseOptions.modelAssetBuffer=void 0):e()}const n=ln(this).then((()=>{}));return r.then((()=>{n.then((()=>{this.j=!1}))}))}get baseOptions(){return se(this.l,yr,1)}set baseOptions(t){ae(this.l,1,t)}O(t,e,r){if(this.j)throw Error("Previous invocation or loading is still ongoing.");if(this.D="function"==typeof e?e:r,this.B.length=0,this.j=!0,r=this.u+1,this.i.addStringToStream(t,"text_in",r),e instanceof an){if(e.j!==this)throw this.j=!1,Error("The LoRA model was not loaded by this LLM Inference task.");this.i.addUintToStream(e.i,"lora_model_id_to_apply_in",r)}else this.i.addEmptyPacketToStream("lora_model_id_to_apply_in",r);return this.finishProcessing(),new Promise((t=>{this.I=t}))}U(t){if(this.j)throw Error("Previous invocation or loading is still ongoing.");return this.j=!0,this.H=void 0,this.i.addStringToStream(t,"token_cost_in",this.u+1),this.finishProcessing(),this.j=!1,this.H}async R(t){if(this.j)throw Error("Cannot load LoRA model while loading or processing.");this.j=!0;const e=new class{constructor(t,e){this.h=t,this.l=e,this.j=this.h._malloc(e)>>>0,this.o=this.h.HEAPU8,this.i=!!this.j}get offset(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.j}get size(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.l}set(t,e){this.o.set(t,this.j+(e??0))}}(this.i.h,t.length);if(e.set(t),t=new an(this),this.i.L(e,this.u+1),this.i.addUintToStream(t.i,"lora_model_id_to_load_in",this.u+1),this.finishProcessing(),e.i)try{e.h._free(e.j)}catch{}finally{e.i=!1}return this.j=!1,t}close(){super.close()}};hn.prototype.loadLoraModel=hn.prototype.R,hn.prototype.sizeInTokens=hn.prototype.U,hn.prototype.generateResponse=hn.prototype.O,hn.prototype.setOptions=hn.prototype.C,hn.createWebGpuDevice=cn,hn.createFromModelPath=async function(t,e){return Nr(t,e={baseOptions:{gpuOptions:{device:await cn()},modelAssetPath:e}})},hn.createFromModelBuffer=async function(t,e){return Nr(t,e={baseOptions:{gpuOptions:{device:await cn()},modelAssetBuffer:e}})},hn.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await cn();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return Nr(t,e)},exports.FilesetResolver=Tr,exports.LlmInference=hn,exports.TaskRunner=Vr;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t="undefined"!=typeof self?self:{};function e(e){t:{for(var r=["CLOSURE_FLAGS"],n=t,i=0;i<r.length;i++)if(null==(n=n[r[i]])){r=null;break t}r=n}return null!=(e=r&&r[e])&&e}let r;const n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0;const n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(128>e)n[r++]=e;else{if(2048>e)n[r++]=e>>6|192;else{if(55296<=e&&57343>=e){if(56319>=e&&i<t.length){const o=t.charCodeAt(++i);if(56320<=o&&57343>=o){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.subarray(0,r)}return t}var o,s=e(610401301),a=e(188588736);const u=t.navigator;function c(t){return!!s&&(!!o&&o.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function l(e){var r;return(r=t.navigator)&&(r=r.userAgent)||(r=""),-1!=r.indexOf(e)}function h(){return!!s&&(!!o&&0<o.brands.length)}function f(){return h()?c("Chromium"):(l("Chrome")||l("CriOS"))&&!(!h()&&l("Edge"))||l("Silk")}o=u&&u.userAgentData||null;var d=!h()&&(l("Trident")||l("MSIE"));!l("Android")||f(),f(),l("Safari")&&(f()||!h()&&l("Coast")||!h()&&l("Opera")||!h()&&l("Edge")||(h()?c("Microsoft Edge"):l("Edg/"))||h()&&c("Opera"));var p={},_=null;function g(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=_[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}m();for(var n=0;;){var i=r(-1),o=r(0),s=r(64),a=r(64);if(64===a&&-1===i)break;e(i<<2|o>>4),64!=s&&(e(o<<4&240|s>>2),64!=a&&e(s<<6&192|a))}}(t,(function(t){n[i++]=t})),i!==r?n.subarray(0,i):n}function m(){if(!_){_={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));p[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===_[o]&&(_[o]=i)}}}}var y="undefined"!=typeof Uint8Array,v=!d&&"function"==typeof btoa;function b(t){if(!v){var e;void 0===e&&(e=0),m(),e=p[e];var r=Array(Math.floor(t.length/3)),n=e[64]||"";let u=0,c=0;for(;u<t.length-2;u+=3){var i=t[u],o=t[u+1],s=t[u+2],a=e[i>>2];i=e[(3&i)<<4|o>>4],o=e[(15&o)<<2|s>>6],s=e[63&s],r[c++]=a+i+o+s}switch(a=0,s=n,t.length-u){case 2:s=e[(15&(a=t[u+1]))<<2]||n;case 1:t=t[u],r[c]=e[t>>2]+e[(3&t)<<4|a>>4]+s+n}return r.join("")}for(e="",r=0,n=t.length-10240;r<n;)e+=String.fromCharCode.apply(null,t.subarray(r,r+=10240));return e+=String.fromCharCode.apply(null,r?t.subarray(r):t),btoa(e)}const w=/[-_.]/g,S={"-":"+",_:"/",".":"="};function A(t){return S[t]||""}function T(t){if(!v)return g(t);w.test(t)&&(t=t.replace(w,A)),t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}function E(t){return y&&null!=t&&t instanceof Uint8Array}let I;var P={};let O;function L(t){if(t!==P)throw Error("illegal external caller")}function U(){return O||=new x(null,P)}var x=class{constructor(t,e){if(L(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function k(t){if("string"==typeof t)return{buffer:T(t),s:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),s:!1};if(t.constructor===Uint8Array)return{buffer:t,s:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),s:!1};if(t.constructor===x){L(P);var e=t.i;return{buffer:(null==(e=null==e||E(e)?e:"string"==typeof e?T(e):null)?e:t.i=e)||(I||=new Uint8Array(0)),s:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),s:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function B(){return"function"==typeof BigInt}let N,D=0,j=0;function F(t){const e=0>t;let r=(t=Math.abs(t))>>>0;if(t=Math.floor((t-r)/4294967296),e){const[e,n]=G(r,t);t=n,r=e}D=r>>>0,j=t>>>0}function V(t,e){if(t>>>=0,2097151>=(e>>>=0))var r=""+(4294967296*e+t);else B()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,1e7<=t&&(r+=Math.floor(t/1e7),t%=1e7),1e7<=r&&(e+=Math.floor(r/1e7),r%=1e7),r=e+C(r)+C(t));return r}function C(t){return t=String(t),"0000000".slice(t.length)+t}function M(t){if(16>t.length)F(Number(t));else if(B())t=BigInt(t),D=Number(t&BigInt(4294967295))>>>0,j=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);j=D=0;const r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){const e=Number(t.slice(n,i));j*=1e6,D=1e6*D+e,4294967296<=D&&(j+=Math.trunc(D/4294967296),j>>>=0,D>>>=0)}if(e){const[t,e]=G(D,j);D=t,j=e}}}function G(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function R(t){return t?/^\d+$/.test(t)?(M(t),new z(D,j)):null:W||=new z(0,0)}var z=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let W;function $(t){return t?/^-?\d+$/.test(t)?(M(t),new H(D,j)):null:q||=new H(0,0)}var H=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let q;function K(t,e,r){for(;0<r||127<e;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.i.push(e)}function Y(t,e){for(;127<e;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function J(t,e){if(0<=e)Y(t,e);else{for(let r=0;9>r;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function X(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Q(t,e){return Y(t.i,8*e+2),e=t.i.end(),X(t,e),e.push(t.j),e}function Z(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;127<r;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function tt(t,e,r){Y(t.i,8*e+2),Y(t.i,r.length),X(t,t.i.end()),X(t,r)}class et{constructor(t,e){this.i=t,this.K=e}}function rt(t){return Array.prototype.slice.call(t)}function nt(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var it=nt(),ot=nt("2ex"),st=nt("0dg"),at=it?(t,e)=>{t[it]|=e}:(t,e)=>{void 0!==t.i?t.i|=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}})},ut=it?(t,e)=>{t[it]&=~e}:(t,e)=>{void 0!==t.i&&(t.i&=~e)};function ct(t,e,r){return r?t|e:t&~e}var lt=it?t=>0|t[it]:t=>0|t.i,ht=it?t=>t[it]:t=>t.i,ft=it?(t,e)=>(t[it]=e,t):(t,e)=>(void 0!==t.i?t.i=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}}),t);function dt(t,e){ft(e,-14591&(0|t))}function pt(t,e){ft(e,-14557&(34|t))}function _t(t){return 0===(t=t>>14&1023)?536870912:t}var gt,mt={},yt={};function vt(t){return!(!t||"object"!=typeof t||t.i!==yt)}function bt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function wt(t,e,r){if(!Array.isArray(t)||t.length)return!1;const n=lt(t);return!!(1&n)||!(!e||!(Array.isArray(e)?e.includes(r):e.has(r)))&&(ft(t,1|n),!0)}const St=[];function At(t){if(2&t)throw Error()}ft(St,55),gt=Object.freeze(St);function Tt(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}let Et;function It(){const e=Error();Tt(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function Pt(t){return Tt(t=Error(t),"warning"),t}function Ot(t){if(null!=t&&"number"!=typeof t)throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}Object.freeze(new class{}),Object.freeze(new class{});const Lt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Ut(t){const e=typeof t;return"number"===e?Number.isFinite(t):"string"===e&&Lt.test(t)}function xt(t){if("number"!=typeof t)throw Pt("int32");if(!Number.isFinite(t))throw Pt("int32");return 0|t}function kt(t){return null==t?t:xt(t)}function Bt(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?0|t:void 0}function Nt(t){if(null!=t){if("number"!=typeof t)throw Pt("uint32");if(!Number.isFinite(t))throw Pt("uint32");t>>>=0}return t}function Dt(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?t>>>0:void 0}function jt(t){return"-"!==t[0]&&(20>t.length||20===t.length&&184467>Number(t.substring(0,6)))}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Vt(t,e,r){if(null!=t&&"object"==typeof t&&t.G===mt)return t;if(Array.isArray(t)){var n=lt(t),i=n;return 0===i&&(i|=32&r),(i|=2&r)!==n&&ft(t,i),new e(t)}}let Ct,Mt,Gt;function Rt(t,e,r){if(null==t&&(t=Ct),Ct=void 0,null==t){var n=96;r?(t=[r],n|=512):t=[],e&&(n=-16760833&n|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(n=lt(t)))throw Error("farr");if(64&n)return t;if(n|=64,r&&(n|=512,r!==t[0]))throw Error("mid");t:{const i=(r=t).length;if(i){const t=i-1;if(bt(r[t])){if(1024<=(e=t-(+!!(512&(n|=256))-1)))throw Error("pvtlmt");n=-16760833&n|(1023&e)<<14;break t}}if(e){if(1024<(e=Math.max(e,i-(+!!(512&n)-1))))throw Error("spvt");n=-16760833&n|(1023&e)<<14}}}return ft(t,n),t}function zt(t,e,r,n,i){if(null!=t){if(Array.isArray(t))t=wt(t,void 0,0)?void 0:i&&2<(t)?t:Wt(t,e,r,void 0!==n,i);else if(bt(t)){const o={};for(let s in t)o[s]=zt(t[s],e,r,n,i);t=o}else t=e(t,n);return t}}function Wt(t,e,r,n,i){const o=n||r?lt(t):0;n=n?!!(32&o):void 0,t=rt(t);for(let o=0;o<t.length;o++)t[o]=zt(t[o],e,r,n,i);return r&&r(o,t),t}function $t(t){return t.G===mt?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(wt(t,void 0,0))return}else{if(E(t))return b(t);if(t instanceof x){const e=t.i;return null==e?"":"string"==typeof e?e:t.i=b(e)}}}return t}(t)}function Ht(t,e,r=pt){if(null!=t){if(y&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var n=lt(t);return 2&n||(e&&=0===n||!!(32&n)&&!(64&n||!(16&n)),t=e?ft(t,-12293&(34|n)):Wt(t,Ht,4&n?pt:r,!0,!0)),t}return t.G===mt&&(r=t.m,t=2&(n=ht(r))?t:qt(t,r,n,!0)),t}}function qt(t,e,r,n){return t=t.constructor,Ct=e=function(t,e,r){const n=r||2&e?pt:dt,i=!!(32&e);return t=function(t,e,r){var n=(t=rt(t)).length;const i=256&e?t[n-1]:void 0;for(n+=i?-1:0,e=512&e?1:0;e<n;e++)t[e]=r(t[e]);if(i){e=t[e]={};for(const t in i)e[t]=r(i[t])}return t}(t,e,(t=>Ht(t,i,n))),at(t,32|(r?2:0)),t}(e,r,n),e=new t(e),Ct=void 0,e}function Kt(t){const e=t.m,r=ht(e);return 2&r?qt(t,e,r,!1):t}function Yt(t,e,r,n){return!(4&e)||null!=r&&(!n&&0===r&&(4096&e||8192&e)&&5>(t.constructor[st]=1+(0|t.constructor[st]))&&It(),0!==r&&!(r&e))}function Jt(t){return Qt(t=t.m,ht(t),2)}function Xt(t,e,r,n){if(!(0>(e=n+(+!!(512&e)-1))||e>=t.length||e>=r))return t[e]}function Qt(t,e,r,n){if(-1===r)return null;const i=_t(e);if(!(r>=i)){var o=t.length;return n&&256&e&&null!=(n=t[o-1][r])?(Xt(t,e,i,r)&&null!=ot&&(4<=(e=(t=Et??={})[ot]||0)||(t[ot]=e+1,It())),n):Xt(t,e,i,r)}return 256&e?t[t.length-1][r]:void 0}function Zt(t,e,r){const n=t.m;let i=ht(n);return At(i),te(n,i,e,r),t}function te(t,e,r,n,i){const o=_t(e);if(r>=o||i){let s=e;if(256&e)i=t[t.length-1];else{if(null==n)return s;i=t[o+(+!!(512&e)-1)]={},s|=256}return i[r]=n,r<o&&(t[r+(+!!(512&e)-1)]=void 0),s!==e&&ft(t,s),s}return t[r+(+!!(512&e)-1)]=n,256&e&&(r in(t=t[t.length-1])&&delete t[r]),e}function ee(t,e,r){return t=Qt(t,e,r),Array.isArray(t)?t:gt}function re(t,e){return 0===t&&(t=ue(t,e)),ct(t,1,!0)}function ne(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ie(t,e,r){{const a=t.m;let u=ht(a);if(At(u),null==r)te(a,u,e);else{var n,i=lt(r),o=i,s=!!(2&i)||Object.isFrozen(r);if((n=!s)&&(n=!1),Yt(t,i))for(i=21,s&&(r=rt(r),o=0,i=ce(i=ue(i,u),u,!0)),t=0;t<r.length;t++)r[t]=xt(r[t]);n&&(r=rt(r),o=0,i=ce(i=ue(i,u),u,!0)),i!==o&&ft(r,i),te(a,u,e,r)}}}function oe(t,e,r,n){t=t.m;let i=ht(t);At(i),te(t,i,e,("0"===n?0===Number(r):r===n)?void 0:r)}function se(t,e,r){var n=t.m,i=ht(n),o=Qt(n,i,r,!1);return(e=Vt(o,e,i))!==o&&null!=e&&te(n,i,r,e,!1),null==(n=e)||(t=t.m,2&(i=ht(t))||(o=Kt(n))!==n&&te(t,i,r,n=o,!1)),n}function ae(t,e,r){return null==r&&(r=void 0),Zt(t,e,r)}function ue(t,e){return t=ct(t,2,!!(2&e)),t=ct(t,32,!0),ct(t,2048,!1)}function ce(t,e,r){return 32&e&&r||(t=ct(t,32,!1)),t}function le(t,e,r,n){t=t.m;var i=ht(t);At(i);var o=!!(2&i);const s=o?1:2;f&&=!o,o=ee(t,i,e);var a=lt(o);const u=!!(4&a);if(!u){var c=o,l=i,h=!!(2&(a=re(a,i)));h&&(l=ct(l,2,!0));let t=!h,e=!0,n=0,s=0;for(;n<c.length;n++){const i=Vt(c[n],r,l);if(i instanceof r){if(!h){const r=!!(2<(i.m));t&&=!r,e&&=r}c[s++]=i}}s<n&&(c.length=s),a=ct(a,4,!0),a=ct(a,16,e),a=ct(a,8,t),ft(c,a),h&&Object.freeze(c)}if(f&&!(8&a||!o.length&&(1===s||4===s&&32&a))){ne(a)&&(o=rt(o),a=ue(a,i),i=te(t,i,e,o));var f=o;for(c=a,a=0;a<f.length;a++)(l=f[a])!==(h=Kt(l))&&(f[a]=h);c=ct(c,8,!0),c=ct(c,16,!f.length),ft(f,c),a=c}ne(a)||(f=a,(a=(c=1===s||4===s&&!!(32&a))?ct(a,!o.length||16&a&&(!u||32&a)?2:2048,!0):ce(a,i,!0))!==f&&ft(o,a),c&&Object.freeze(o)),2===s&&ne(a)&&(o=rt(o),a=ce(a=ue(a,i),i,!0),ft(o,a),te(t,i,e,o)),e=o,r=null!=n?n:new r,e.push(r),2<(r.m)?ut(e,8):ut(e,16)}function he(t,e,r){oe(t,e,kt(r),0)}function fe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();oe(t,e,r,"")}function de(t,e,r){t=t.m;const n=ht(t);At(n);var i=2&n;let o=Qt(t,n,e);Array.isArray(o)||(o=gt);const s=!!(32&n);let a=lt(o);if(0===a&&s&&!i?(a|=33,ft(o,a)):1&a||(a|=1,ft(o,a)),i?(2&a||at(o,34),Object.freeze(o)):(2&a||2048&a)&&(o=rt(o),i=1,s&&(i|=32),ft(o,i),te(t,n,e,o)),"string"!=typeof r)throw Error();o.push(r)}var pe=class{constructor(t,e){this.m=Rt(t,e)}toJSON(){return _e(this,Wt(this.m,$t,void 0,void 0,!1),!0)}s(){return!!(2<(this.m))}};function _e(t,e,r){var n=a?void 0:t.constructor.v;const i=ht(r?t.m:e);if(!(t=e.length))return e;let o,s;if(bt(r=e[t-1])){t:{var u=r;let t={},e=!1;for(var c in u){let r=u[c];if(Array.isArray(r)){let t=r;(wt(r,n,+c)||vt(r)&&0===r.size)&&(r=null),r!=t&&(e=!0)}null!=r?t[c]=r:e=!0}if(e){for(var l in t){u=t;break t}u=null}}u!=r&&(o=!0),t--}for(c=+!!(512&i)-1;0<t&&(r=e[l=t-1],l-=c,null==r||wt(r,n,l)||vt(r)&&0===r.size);t--)s=!0;return o||s?(e=Array.prototype.slice.call(e,0,t),u&&e.push(u),e):e}function ge(t,e){if(Array.isArray(e)){var r=lt(e);if(4&r)return e;for(var n=0,i=0;n<e.length;n++){const r=t(e[n]);null!=r&&(e[i++]=r)}return i<n&&(e.length=i),ft(e,-12289&(5|r)),2&r&&Object.freeze(e),e}}pe.prototype.G=mt,pe.prototype.toString=function(){return _e(this,this.m,!1).toString()};const me=Symbol(),ye=Symbol();function ve(t){let e=t[ye];if(!e){const r=Ae(t);e=(t,e)=>Ie(t,e,r),t[ye]=e}return e}const be=Symbol();function we(t){return t.i}function Se(t,e){let r,n;const i=t.i;return(t,o,s)=>i(t,o,s,n||=Ae(e).i,r||=ve(e))}function Ae(t){var e=t[be];if(e)return e;var r=we,n=Se;(e=t[be]={}).i=function(t){switch(typeof t){case"boolean":return Mt||=[0,void 0,!0];case"number":return 0<t?void 0:0===t?Gt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);let i=0;var o=t[++i];o&&o.constructor===Object&&(e.N=o,"function"==typeof(o=t[++i])&&(e.l=o,e.j=t[++i],o=t[++i]));const s={};for(;Array.isArray(o)&&"number"==typeof o[0]&&0<o[0];){for(var a=0;a<o.length;a++)s[o[a]]=o;o=t[++i]}for(a=1;void 0!==o;){let f;"number"==typeof o&&(a+=o,o=t[++i]);var u=void 0;if(o instanceof et?f=o:(f=Ke,i--),f.K){o=t[++i],u=t;var c=i;"function"==typeof o&&(o=o(),u[c]=o),u=o}let d=a+1;for("number"==typeof(o=t[++i])&&0>o&&(d-=o,o=t[++i]);a<d;a++){var l=s[a];c=e;var h=a;l=u?n(f,u):r(f),c[h]=l}}return Te in t&&me in t&&be in t&&(t.length=0),e}const Te=Symbol();function Ee(t,e){var r=t[e];if(r)return r;if((r=t.N)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof et?r:[qe,r]:[r,void 0])[0].i;if(r=r[1]){const e=ve(r),i=Ae(r).i;r=(r=t.j)?r(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}function Ie(t,e,r){var n=ht(t),i=+!!(512&n)-1,o=t.length,s=512&n?1:0;const a=o+(256&n?-1:0);for(;s<a;s++){const n=t[s];if(null==n)continue;const o=s-i,a=Ee(r,o);a&&a(e,n,o)}if(256&n){t=t[o-1];for(let s in t)n=+s,Number.isNaN(n)||null!=(i=t[s])&&(o=Ee(r,n))&&o(e,i,n)}}function Pe(t){return new et(t,!1)}function Oe(t,e,r){null!=(e=Bt(e))&&null!=e&&(Y(t.i,8*r),J(t.i,e))}function Le(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Y(t.i,8*r),t.i.i.push(e?1:0))}function Ue(t,e,r){null!=(e=Ft(e))&&tt(t,r,i(e))}function xe(t,e,r,n,i){null!=(e=e instanceof pe?e.m:Array.isArray(e)?Rt(e,n[0],n[1]):void 0)&&(r=Q(t,r),i(e,t),Z(t,r))}function ke(t,e,r){null!=(e=Bt(e))&&(e=parseInt(e,10),Y(t.i,8*r),J(t.i,e))}var Be,Ne=Pe((function(t,e,r){null!=(e=null==e||"number"==typeof e?e:"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0)&&(Y(t.i,8*r+5),t=t.i,(r=N||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),j=0,e=D=r.getUint32(0,!0),t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255))})),De=Pe((function(t,e,r){t:if(null!=e){if(Ut(e)){if("string"==typeof e){var n=Math.trunc(Number(e));if(Number.isSafeInteger(n))e=String(n);else if(-1!==(n=e.indexOf("."))&&(e=e.substring(0,n)),!("-"===e[0]?20>e.length||20===e.length&&-922337<Number(e.substring(0,7)):19>e.length||19===e.length&&922337>Number(e.substring(0,6))))if(M(e),e=D,2147483648&(n=j))if(B())e=""+(BigInt(0|n)<<BigInt(32)|BigInt(e>>>0));else{const[t,r]=G(e,n);e="-"+V(t,r)}else e=V(e,n);break t}if("number"==typeof e){if(e=Math.trunc(e),!Number.isSafeInteger(e)){F(e),n=D;var i=j;(e=2147483648&i)&&(i=~i>>>0,0==(n=1+~n>>>0)&&(i=i+1>>>0)),n=4294967296*i+(n>>>0),e=e?-n:n}break t}}e=void 0}null!=e&&("string"==typeof e&&$(e),null!=e&&(Y(t.i,8*r),"number"==typeof e?(t=t.i,F(e),K(t,D,j)):(r=$(e),K(t.i,r.j,r.i))))})),je=Pe((function(t,e,r){t:if(null!=e){if(Ut(e)){if("string"==typeof e){var n=Math.trunc(Number(e));Number.isSafeInteger(n)&&0<=n?e=String(n):(-1!==(n=e.indexOf("."))&&(e=e.substring(0,n)),jt(e)||(M(e),e=V(D,j)));break t}if("number"==typeof e){e=0<=(e=Math.trunc(e))&&Number.isSafeInteger(e)?e:function(t){if(0>t){F(t);const e=V(D,j);return t=Number(e),Number.isSafeInteger(t)?t:e}return jt(String(t))?t:(F(t),4294967296*j+(D>>>0))}(e);break t}}e=void 0}null!=e&&("string"==typeof e&&R(e),null!=e&&(Y(t.i,8*r),"number"==typeof e?(t=t.i,F(e),K(t,D,j)):(r=R(e),K(t.i,r.j,r.i))))})),Fe=Pe(Oe),Ve=new et((function(t,e,r){if(null!=(e=ge(Bt,e))&&e.length){r=Q(t,r);for(let r=0;r<e.length;r++)J(t.i,e[r]);Z(t,r)}}),!1),Ce=Pe(Oe),Me=Pe(Oe),Ge=Pe(Le),Re=Pe(Le),ze=new et((function(t,e,r){if(null!=(e=ge(Ft,e)))for(let a=0;a<e.length;a++){var n=t,o=r,s=e[a];null!=s&&tt(n,o,i(s))}}),!1),We=Pe(Ue),$e=Pe(Ue),He=Pe(Ue),qe=new et(xe,!0),Ke=new et(xe,!0);Be=new et((function(t,e,r,n,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)xe(t,e[o],r,n,i)}),!0);var Ye=new et(xe,!0),Je=Pe(ke),Xe=new et((function(t,e,r){if(null!=(e=ge(Bt,e))&&e.length){r=Q(t,r);for(let r=0;r<e.length;r++)J(t.i,e[r]);Z(t,r)}}),!1),Qe=Pe(ke);function Ze(t){return function(){const e=new class{constructor(){this.l=[],this.j=0,this.i=new class{constructor(){this.i=[]}length(){return this.i.length}end(){const t=this.i;return this.i=[],t}}}};Ie(this.m,e,Ae(t)),X(e,e.i.end());const r=new Uint8Array(e.j),n=e.l,i=n.length;let o=0;for(let t=0;t<i;t++){const e=n[t];r.set(e,o),o+=e.length}return e.l=[r],r}}function tr(t,e){if(null!=e)if(Array.isArray(e))Zt(t,2,Wt(e,$t,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof x||E(e)))throw Error("invalid value in Any.value field: "+e+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");if(null!=e)if("string"==typeof e)e=e?new x(e,P):U();else if(e.constructor!==x){if(!E(e))throw Error();e=e.length?new x(new Uint8Array(e),P):U()}oe(t,2,e,U())}}var er=class extends pe{constructor(t){super(t)}},rr=[0,We,Pe((function(t,e,r){if(null!=e){if(e instanceof pe){const n=e.V;return void(n&&(e=n(e),null!=e&&tt(t,r,k(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||E(e)||e instanceof x?e:void 0)&&tt(t,r,k(e).buffer)}))],nr={},ir=[-2,nr,Ge];nr[336783863]=[0,He,Ge,-1,Fe,[0,[1,2,3,4,5,6],Ye,[0],Ye,[0,Ge,He,Ge,Je,-1,Xe,He,-1,[0,Ge,-1],Je],Ye,[0,He,-2],Ye,[0,Fe,Ge,-4],Ye,[0,Fe,Je,Ge,-1,Ve,Je,-1],Ye,[0,He]],[0,He],Ge,[0,[1,3],[2,4],Ye,[0,Ve],-1,Ye,[0,ze],-1],He];var or=class extends pe{constructor(t){super(t)}},sr=[0,We,Re],ar=[0,De,-1,Re,-3,De,Ve,We,Ce,De,-1,Re,Ce,Re,-2,We],ur=[-1,{}],cr=[0,He,1,ur],lr=[0,He,ze,ur],hr=class extends pe{constructor(t){super(t,500)}C(t){return ae(this,7,t)}};hr.v=[3,4,5,6,8,13,17,1005];var fr=[-500,We,-1,ze,-3,ir,Be,rr,Ce,-1,cr,lr,Be,sr,We,ar,Ce,ze,987,ze],dr=[0,We,-1,ur],pr=[-500,He,-1,[-1,{}],998,He],_r=[-500,He,ze,-1,[-2,{},Ge],997,ze,-1],gr=[-500,He,ze,ur,998,ze];function mr(t,e){le(t,1,hr,e)}var yr=class extends pe{constructor(){super(void 0,500)}C(t){return ae(this,1001,t)}};yr.v=[1,6,7,9,10,15,16,17,14,1002],yr.prototype.i=Ze([-500,Be,fr,4,Be,pr,Be,_r,Ce,Be,gr,ze,Ce,cr,lr,Be,dr,ze,-2,ar,We,-1,Re,979,ur,Be,rr]);var vr=class extends pe{constructor(t){super(t)}};let br;const wr=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Sr(){if(void 0===br)try{await WebAssembly.instantiate(wr),br=!0}catch{br=!1}return br}async function Ar(t,e=""){const r=await Sr()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var Tr=class{};function Er(){var t=navigator;return"undefined"!=typeof OffscreenCanvas&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(t)||!!((t=t.userAgent.match(/Version\/([\d]+).*Safari/))&&1<=t.length&&17<=Number(t[1])))}async function Ir(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,r)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{r(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}Tr.forVisionTasks=function(t){return Ar("vision",t)},Tr.forTextTasks=function(t){return Ar("text",t)},Tr.forGenAiExperimentalTasks=function(t){return Ar("genai_experimental",t)},Tr.forGenAiTasks=function(t){return Ar("genai",t)},Tr.forAudioTasks=function(t){return Ar("audio",t)},Tr.isSimdSupported=function(){return Sr()};function Pr(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function Or(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const n=new Uint32Array(e.length);for(let r=0;r<e.length;r++)n[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*n.length),t.h.HEAPU32.set(n,e>>2),r(e);for(const e of n)t.h._free(e);t.h._free(e)}function Lr(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Ur(t,e,r){let n=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(r(n,i),n=[]):n.push(t)}}const xr=(kr=class{constructor(t,e){this.l=!0,this.h=t,this.i=null,this.j=0,this.o="function"==typeof this.h._addIntToInputStream,void 0!==e?this.h.canvas=e:Er()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph((new TextEncoder).encode(t),!1)}setGraph(t,e){const r=t.length,n=this.h._malloc(r);this.h.HEAPU8.set(t,n),e?this.h._changeBinaryGraph(r,n):this.h._changeTextGraph(r,n),this.h._free(n)}configureAudio(t,e,r,n,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Pr(this,n||"input_audio",(n=>{Pr(this,i=i||"audio_header",(i=>{this.h._configureAudio(n,i,t,e,r)}))}))}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.h._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.h.gpuOriginForWebTexturesIsBottomLeft=t}attachErrorListener(t){this.h.errorListener=t}attachEmptyPacketListener(t,e){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[t]=e}addAudioToStream(t,e,r){this.addAudioToStreamWithShape(t,0,0,e,r)}addAudioToStreamWithShape(t,e,r,n,i){const o=4*t.length;this.j!==o&&(this.i&&this.h._free(this.i),this.i=this.h._malloc(o),this.j=o),this.h.HEAPF32.set(t,this.i/4),Pr(this,n,(t=>{this.h._addAudioToInputStream(this.i,e,r,t,i)}))}addGpuBufferToStream(t,e,r){Pr(this,e,(e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();const n=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!n)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const[i,o]=void 0!==t.videoWidth?[t.videoWidth,t.videoHeight]:void 0!==t.naturalWidth?[t.naturalWidth,t.naturalHeight]:void 0!==t.displayWidth?[t.displayWidth,t.displayHeight]:[t.width,t.height];!this.l||i===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=i,this.h.canvas.height=o);const[s,a]=[i,o];this.h._addBoundTextureToStream(e,s,a,r)}))}addBoolToStream(t,e,r){Pr(this,e,(e=>{this.h._addBoolToInputStream(t,e,r)}))}addDoubleToStream(t,e,r){Pr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,r)}))}addFloatToStream(t,e,r){Pr(this,e,(e=>{this.h._addFloatToInputStream(t,e,r)}))}addIntToStream(t,e,r){Pr(this,e,(e=>{this.h._addIntToInputStream(t,e,r)}))}addUintToStream(t,e,r){Pr(this,e,(e=>{this.h._addUintToInputStream(t,e,r)}))}addStringToStream(t,e,r){Pr(this,e,(e=>{Pr(this,t,(t=>{this.h._addStringToInputStream(t,e,r)}))}))}addStringRecordToStream(t,e,r){Pr(this,e,(e=>{Or(this,Object.keys(t),(n=>{Or(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(n,i,Object.keys(t).length,e,r)}))}))}))}addProtoToStream(t,e,r,n){Pr(this,r,(r=>{Pr(this,e,(e=>{const i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputStream(i,t.length,e,r,n),this.h._free(i)}))}))}addEmptyPacketToStream(t,e){Pr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(n,e);this.h._addBoolVectorToInputStream(n,e,r)}))}addDoubleVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(n,e);this.h._addDoubleVectorToInputStream(n,e,r)}))}addFloatVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(n,e);this.h._addFloatVectorToInputStream(n,e,r)}))}addIntVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(n,e);this.h._addIntVectorToInputStream(n,e,r)}))}addUintVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(n,e);this.h._addUintVectorToInputStream(n,e,r)}))}addStringVectorToStream(t,e,r){Pr(this,e,(e=>{const n=this.h._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const e of t)Pr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputStream(n,e,r)}))}addBoolToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){Pr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){Pr(this,e,(e=>{Pr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,r){Pr(this,r,(r=>{Pr(this,e,(e=>{const n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputSidePacket(n,t.length,e,r),this.h._free(n)}))}))}addBoolVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)}))}addDoubleVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)}))}addFloatVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)}))}addIntVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)}))}addUintVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)}))}addStringVectorToInputSidePacket(t,e){Pr(this,e,(e=>{const r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const e of t)Pr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputSidePacket(r,e)}))}attachBoolListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,r){Lr(this,t,e),Pr(this,t,(t=>{this.h._attachProtoListener(t,r||!1)}))}attachProtoVectorListener(t,e,r){Ur(this,t,e),Pr(this,t,(t=>{this.h._attachProtoVectorListener(t,r||!1)}))}attachAudioListener(t,e,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Lr(this,t,((t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)})),Pr(this,t,(t=>{this.h._attachAudioListener(t,r||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}},class extends kr{S(){this.h._registerModelResourcesGraphService()}});var kr;async function Br(t,e){const r=await(async(t,e,r)=>{var n=dn;if(t&&await Ir(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Ir(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new n(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return await r.C(e),r}async function Nr(t,e){return Br(t,e)}function Dr(t){try{const e=t.A.length;if(1===e)throw Error(t.A[0].message);if(1<e)throw Error("Encountered multiple errors: "+t.A.map((t=>t.message)).join(", "))}finally{t.A=[]}}function jr(t,e){t.u=Math.max(t.u,e)}var Fr=class{constructor(t){this.i=t,this.A=[],this.u=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.A.push(Error(e))})),this.i.S(),this.i.setGraph(t,e),Dr(this)}finishProcessing(){this.i.finishProcessing(),Dr(this)}close(){this.i.closeGraph()}};Fr.prototype.close=Fr.prototype.close;var Vr=class extends pe{constructor(t){super(t)}},Cr=[0,Qe,Ce,Ne,-1,Fe];var Mr=class extends pe{constructor(){super()}};function Gr(t,e,r,n){if(void 0!==t.data){var i=new Uint8Array(t.data.buffer,e,r);return 1===n&&function(t,e,r){t.i.push([e,r]),t.i.sort(((t,e)=>t[0]-e[0])),e=0;for(const[n,i]of t.i){const t=i;(r=n)<=e&&(e=Math.max(e,r+t))}e===t.length&&(t.data=void 0)}(t,e,r),i}}Mr.v=[4];class Rr{constructor(t){this.i=[],this.data=t,this.length=t.length}}var zr=class{constructor(t,e,r){this.i=t,this.j=e,this.l=r}get size(){let t=0;for(let e=0;e<this.i.length;e++)t+=this.i[e].length;return t}};function Wr(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var $r=class{constructor(t,e){this.h=t,this.l=e,this.j=this.h._malloc(e)>>>0,this.o=this.h.HEAPU8,this.i=!!this.j}get offset(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.j}get size(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.l}set(t,e){this.o.set(t,this.j+(e??0))}},Hr=class extends pe{constructor(){super()}};Hr.v=[4],Hr.prototype.i=Ze([0,We,2,ze,Ce]);var qr=class extends pe{constructor(){super()}},Kr=[0,Re,-5],Yr=[0,We,je,-1,Qe],Jr=class extends pe{constructor(){super()}},Xr=[0,Ce,-6,1,Ce,1,[0,Re,Qe,-2],[0,Re,Ne],Qe,-2,[0,Re,-1,Qe,Ne,Je],1,Re],Qr=class extends pe{constructor(){super()}};Qr.v=[5,7];var Zr=[0,[4,6],Xr,Ce,1,Me,ze,$e,Xe],tn=[0,Be,Yr,Zr,Ce],en=[0,Ce,Re,-1],rn=class extends pe{constructor(){super()}};rn.v=[29],rn.prototype.i=Ze([0,We,8,Kr,1,Ce,1,Ce,tn,en,1,Qe,We,Zr,tn,Ce,5,Qe,Ve,1,Cr]);var nn=class extends pe{constructor(){super()}},on=class extends pe{constructor(){super()}},sn=[2,4];on.prototype.i=Ze([0,sn,Ce,$e,Ce,Ye,[0,1,We]]);const an=function(t){return class e extends t{static async T(t,r){let n;r||=await e.J();const i=[];for(const e of t?.requiredFeatures??[])r.features.has(e)?i.push(e):console.warn(`WebGPU feature ${e} is not supported.`);t={...t,requiredFeatures:i};try{n=await r.requestDevice(t)}catch(t){throw console.error("Unable to initialize WebGPU with the requested features."),t}return r=await r.requestAdapterInfo(),n.adapterInfo=r,n}static async J(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}P(t){if(e)"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.id="canvas_webgpu");else var e=new OffscreenCanvas(1,1);e.getContext("webgpu").configure({device:t,format:navigator.gpu.getPreferredCanvasFormat()}),this.h.preinitializedWebGPUDevice=t}M(){return this.h.ccall("closeGraph","void",[],[],{async:!0})}}}(function(t){return class extends t{addStreamingReaderToInputSidePacket(t,e){this.h.addStreamingReaderToInputSidePacket(((e,r,n)=>async function(t,e,r,n,i){if(2===i)return t.i=[],t.j=()=>Promise.resolve(void 0),t.l(),Promise.resolve(0);for(;t.size<r+n;){var o=await t.j();if(void 0===o)break;t.i.push(new Rr(o))}if(t.size<r+n)throw Error(`Data size is too small: ${t.size}, expected at least ${r+n}.`);o=e._malloc(n)>>>0;let s=0;for(let a=0;a<t.i.length;a++){const u=t.i[a];if(r>=u.length){r-=u.length;continue}const c=Math.min(n,u.length-r);if(void 0===(r=Gr(u,r,c,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(r,o+s),r=0,s+=c,0==(n-=c))break}if(0!==n)throw Error("Data not found.");return Promise.resolve(o)}(t,this.h,e,r,n)),e)}}}(function(t){return class extends t{L(t,e){Pr(this,"lora_model_ref_in",(r=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,r,e)}))}}}(class extends xr{})));class un extends an{}var cn=class{constructor(t){this.j=t,this.i=ln,ln++}},ln=0;async function hn(){const t=await un.J({powerPreference:"high-performance"});var e=t.limits.maxBufferSize;if(524550144>t.limits.maxStorageBufferBindingSize)throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxStorageBufferBindingSize is at least 524550144 but your device only supports maxStorageBufferBindingSize of ${e}`);if(786825216<=e)e=786825216;else{if(!(524550144<=e))throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxBufferSize is at least 524550144 but your device only supports maxBufferSize of ${e}`);e=524550144}return un.T({requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e}},t)}function fn(t){const e=function(t){const e=new yr;de(e,10,"text_in"),de(e,10,"token_cost_in"),de(e,10,"lora_model_id_to_apply_in"),de(e,10,"lora_model_ref_in"),de(e,10,"lora_model_id_to_load_in"),de(e,16,"streaming_reader"),de(e,15,"text_out"),de(e,15,"text_end"),de(e,15,"token_cost_out");var r=new hr;fe(r,2,"TokenizerInputBuildCalculator"),de(r,3,"PROMPT:text_in"),de(r,3,"LORA_ID:lora_model_id_to_apply_in"),de(r,4,"prompt"),mr(e,r),fe(r=new hr,2,"ModelDataCalculator"),de(r,6,"MODEL_DATA:__side_packet_1"),de(r,6,"MODEL_TYPE:model_type"),de(r,5,"READ_DATA_FN:streaming_reader"),de(r,3,"LORA_MODEL_SPAN:lora_model_ref_in"),de(r,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),de(r,4,"LORA_DATA:lora_model_data"),mr(e,r),fe(r=new hr,2,"Gpt2UnicodeMappingCalculator"),de(r,5,"MODEL_TYPE:model_type"),de(r,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),mr(e,r),fe(r=new er,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var n=new on,i=Dt(Jt(t.l))??0;he(n,1,i),fe(i=new nn,2,"spm_vocab_model"),null==i&&(i=void 0);var o=n.m,s=ht(o);At(s);for(var a=s,u=0,c=0;c<sn.length;c++){var l=sn[c];null!=Qt(o,a,l)&&(0!==u&&(a=te(o,a,u)),u=l)}if((a=u)&&4!==a&&null!=i&&(s=te(o,s,a)),te(o,s,4,i),he(n,3,2),tr(r,n.i()),fe(n=new hr,2,"TokenizerCalculator"),le(n,8,er,r),de(n,5,"MODEL_DATA:__side_packet_1"),de(n,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),de(n,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),de(n,6,"PROCESSOR_GETTER:__input_side_1"),de(n,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),mr(e,n),fe(r=new er,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),he(n=new rn,12,3),fe(n,1,"llm.tflite"),he(n,14,0),he(n,22,1),i=se(t.l,Vr,3),ae(n,31,i),oe(i=new qr,1,!0,!1),oe(i,2,!0,!1),oe(i,5,!0,!1),ae(n,10,i),c=t.l,i=c.m,o=ht(i),s=2&o?1:2,a=ee(i,o,4),u=lt(a),Yt(c,u,void 0,!1)){for((4&u||Object.isFrozen(a))&&(a=rt(a),u=ue(u,o),o=te(i,o,4,a)),l=c=0;c<a.length;c++){const t=Bt(a[c]);null!=t&&(a[l++]=t)}l<c&&(a.length=l),u=ct(u=re(u,o),20,!0),u=ct(u,4096,!1),u=ct(u,8192,!1),ft(a,u),2&u&&Object.freeze(a)}return ne(u)||(c=u,(u=(l=1===s||4===s&&!!(32&u))?ct(u,2,!0):ce(u,o,!1))!==c&&ft(a,u),l&&Object.freeze(a)),2===s&&ne(u)&&(a=rt(a),u=ce(u=ue(u,o),o,!1),ft(a,u),te(i,o,4,a)),ie(n,29,a),i=new Qr,he(o=new Jr,1,1),t=Dt(Jt(t.l))??0,he(o,2,t),ae(i,1,o),ae(n,20,i),tr(r,n.i()),fe(t=new hr,2,"LlmGpuCalculator"),le(t,8,er,r),de(t,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),de(t,3,"FINISH:finish"),de(t,3,"LORA_DATA:lora_model_data"),de(t,5,"MODEL_DATA:__side_packet_1"),de(t,4,"DECODED_IDS:__stream_3"),de(t,4,"OUTPUT_END:__stream_4"),fe(r=new or,1,"FINISH"),oe(r,2,!0,!1),le(t,13,or,r),mr(e,t),fe(t=new hr,2,"IsPacketPresentCalculator"),de(t,3,"__stream_4"),de(t,4,"text_end"),mr(e,t),fe(t=new er,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),he(r=new Hr,5,1),de(r,4,"<eos>"),de(r,4,"<|endoftext|>"),tr(t,r.i()),fe(r=new hr,2,"DetokenizerCalculator"),le(r,8,er,t),de(r,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),de(r,5,"PROCESSOR_GETTER:__input_side_1"),de(r,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),de(r,5,"MODEL_DATA:__side_packet_1"),de(r,4,"FINISH_AND_INPUT_OPTIONS:finish"),de(r,4,"WORDS:text_out"),mr(e,r),fe(t=new hr,2,"TokenCostCalculator"),de(t,3,"PROMPT:token_cost_in"),de(t,5,"PROCESSOR_GETTER:__input_side_1"),de(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),de(t,4,"NUM_TOKENS:token_cost_out"),mr(e,t),e}(t);t.i.attachStringVectorListener("text_out",((e,r)=>{var n=0===t.B.length;null==e||0===e.length?n="":(e=(e=(e=e[0]).replaceAll("▁"," ")).replaceAll("<0x0A>","\n"),n&&(e=e.trimStart()),n=e.split("\\[eod\\]",1)[0]),t.B.push(n),t.F&&t.F(n,!1),jr(t,r)})),t.i.attachEmptyPacketListener("text_out",(e=>{jr(t,e)})),t.i.attachBoolListener("text_end",((e,r)=>{t.j=!1,t.I&&t.I(t.B.join("")),t.F&&t.F("",!0),jr(t,r)})),t.i.attachEmptyPacketListener("text_end",(e=>{t.j=!1,jr(t,e)})),t.i.attachIntListener("token_cost_out",((e,r)=>{t.H=e,jr(t,r)})),t.D&&t.i.addStreamingReaderToInputSidePacket(t.D,"streaming_reader");const r=e.i();return t.i.M().then((()=>{t.setGraph(new Uint8Array(r),!0),t.finishProcessing()}))}var dn=class extends Fr{constructor(t,e){if(super(new un(t,e)),this.B=[],this.j=!1,ae(t=this.l=new Mr,1,e=new vr),this.o=new Vr,ae(this.l,3,this.o),Zt(this.l,2,Nt(512)),t=this.o,!Number.isFinite(2))throw Pt("enum");oe(t,1,2,0),he(this.o,2,1),oe(this.o,3,Ot(1),0),oe(this.o,4,Ot(1),0)}C(t){if(this.j)throw Error("Cannot set options while loading or processing.");let e;this.j=!0,t.baseOptions?.gpuOptions?.device&&this.i.P(t.baseOptions.gpuOptions.device),"maxTokens"in t&&Zt(this.l,2,Nt(t.maxTokens??512)),"topK"in t&&(he(this.o,2,t.topK??1),t.topK&&!t.randomSeed&&console.warn("'topK' option ignored; it requires randomSeed to be set.")),"temperature"in t&&(oe(this.o,4,Ot(t.temperature??1),0),t.temperature&&!t.randomSeed&&console.warn("'temperature' option ignored; it requires randomSeed to be set.")),t.randomSeed&&Zt(this.o,5,kt(t.randomSeed)),"loraRanks"in t&&function(t,e){ie(t,4,e)}(this.l,t.loraRanks??[]);const r=new Promise((t=>{e=t}));if(t.baseOptions?.modelAssetPath||t.baseOptions?.modelAssetBuffer){if(t.baseOptions.modelAssetPath&&t.baseOptions.modelAssetBuffer)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");let r=!1;t.baseOptions.modelAssetPath?this.D=function(t,e){const r=fetch(t.toString()).then((t=>t?.body?.getReader()));return new zr([],(async()=>{let e;try{e=await r}catch(e){throw Error(`Error loading model from "${t.toString()}": ${e}`)}const{value:n,done:i}=await e.read();if(!i)return n}),e)}(t.baseOptions.modelAssetPath,e):t.baseOptions.modelAssetBuffer instanceof Uint8Array?(this.D=function(t,e){return new zr([new Rr(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,e),r=!0):t.baseOptions.modelAssetBuffer?(this.D=function(t,e){return new zr([],(async()=>{const{value:e,done:r}=await t.read();if(!r)return e}),e)}(t.baseOptions.modelAssetBuffer,e),r=!0):e(),r&&(t.baseOptions.modelAssetBuffer=void 0)}const n=fn(this).then((()=>{}));return r.then((()=>{n.then((()=>{this.j=!1}))}))}get baseOptions(){return se(this.l,vr,1)}set baseOptions(t){ae(this.l,1,t)}O(t,e,r){if(this.j)throw Error("Previous invocation or loading is still ongoing.");if(this.F="function"==typeof e?e:r,this.B.length=0,this.j=!0,r=this.u+1,this.i.addStringToStream(t,"text_in",r),e instanceof cn){if(e.j!==this)throw this.j=!1,Error("The LoRA model was not loaded by this LLM Inference task.");this.i.addUintToStream(e.i,"lora_model_id_to_apply_in",r)}else this.i.addEmptyPacketToStream("lora_model_id_to_apply_in",r);return this.finishProcessing(),new Promise((t=>{this.I=t}))}U(t){if(this.j)throw Error("Previous invocation or loading is still ongoing.");return this.j=!0,this.H=void 0,this.i.addStringToStream(t,"token_cost_in",this.u+1),this.finishProcessing(),this.j=!1,this.H}async R(t){if(this.j)throw Error("Cannot load LoRA model while loading or processing.");if(this.j=!0,t instanceof Uint8Array){var e=new $r(this.i.h,t.length);e.set(t),t=e}else t=await async function(t,e){var r=await fetch(e.toString());e=Number(r.headers.get("content-length")),t=new $r(t,e);let n=0;for(r=r?.body?.getReader();;){const{value:e,done:i}=await r.read();if(i)break;t.set(e,n),n+=e.byteLength}if(e!==n)throw Wr(t),Error(`File could not be fully loaded to memory, so was not retained. Loaded ${n}/${e} bytes before failure`);return t}(this.i.h,t);return e=new cn(this),this.i.L(t,this.u+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.u+1),this.finishProcessing(),Wr(t),this.j=!1,e}close(){super.close()}};dn.prototype.loadLoraModel=dn.prototype.R,dn.prototype.sizeInTokens=dn.prototype.U,dn.prototype.generateResponse=dn.prototype.O,dn.prototype.setOptions=dn.prototype.C,dn.createWebGpuDevice=hn,dn.createFromModelPath=async function(t,e){return Nr(t,e={baseOptions:{gpuOptions:{device:await hn()},modelAssetPath:e}})},dn.createFromModelBuffer=async function(t,e){return Nr(t,e={baseOptions:{gpuOptions:{device:await hn()},modelAssetBuffer:e}})},dn.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await hn();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return Nr(t,e)},exports.FilesetResolver=Tr,exports.LlmInference=dn,exports.TaskRunner=Fr;
|
|
2
2
|
//# sourceMappingURL=genai_bundle_cjs.js.map
|